From 7f63dae8a9cceac4e30d9ceb52f476d61a5b5733 Mon Sep 17 00:00:00 2001 From: Omar Scher Date: Mon, 20 Nov 2023 11:39:36 -0500 Subject: [PATCH] fix: api call missing auth token --- examples/javascript/src/lib/jane-service.mjs | 12 ++++++------ examples/javascript/src/pre-signup-lambda/index.mjs | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/javascript/src/lib/jane-service.mjs b/examples/javascript/src/lib/jane-service.mjs index a8b2635..b657125 100644 --- a/examples/javascript/src/lib/jane-service.mjs +++ b/examples/javascript/src/lib/jane-service.mjs @@ -32,8 +32,8 @@ const createUser = async (data, token) => { // } // } -const ensureExternalUserExists = async (data) => { - const response = await apiService.post(`${COGNITO_API}/ensure_external_user_exists`, data) +const ensureExternalUserExists = async (data, token) => { + const response = await apiService.post(`${COGNITO_API}/ensure_external_user_exists`, data, token) return { success: response.statusCode === 200, @@ -134,16 +134,16 @@ const verifySSOUser = async (data, token) => { const parsedData = { ...data, user_attributes: { - ...data.user_attributes, + ...data.user_attributes, identities: JSON.parse(data.user_attributes.identities) - } - } + } + } const response = await apiService.post( `${COGNITO_API}/verify_sso_user`, parsedData, token ) - + const result = { errorMessage: "", user: response.body?.user, diff --git a/examples/javascript/src/pre-signup-lambda/index.mjs b/examples/javascript/src/pre-signup-lambda/index.mjs index 23684d2..ea11e11 100644 --- a/examples/javascript/src/pre-signup-lambda/index.mjs +++ b/examples/javascript/src/pre-signup-lambda/index.mjs @@ -26,7 +26,7 @@ export const handler = async (event) => { external_id: event.userName, email: userData.email, user_attributes: userData.user_attributes, - }) + }, token) if (!success) { throw new Error(`ensureExternalUserExists was not successful: ${errorMessage}`) diff --git a/package.json b/package.json index 5953f9c..3a79bb2 100755 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "make:dist": "mkdir -p dist/migration-lambda && mkdir -p dist/post-confirmation-lambda && mkdir -p dist/pre-signup-lambda", "compile:migration-lambda": "npm run make:dist && esbuild examples/javascript/src/migration-lambda/index.mjs --platform=node --target=es2020 --bundle --minify --outfile=dist/migration-lambda/index.js", "compile:post-confirmation-lambda": "npm run make:dist && esbuild examples/javascript/src/post-confirmation-lambda/index.mjs --platform=node --target=es2020 --bundle --minify --outfile=dist/post-confirmation-lambda/index.js", - "compile:pre-signup-lambda": "npm run make:dist && esbuild examples/javascript/src/pre-signup-lambda/index.mjs --platform=node --target=es2020 --bundle --minify --outfile=dist/pre-signup-lambda/index.js", + "compile:pre-signup-lambda": "npm run make:dist && esbuild examples/javascript/src/pre-signup-lambda/index.mjs --platform=node --target=es2020 --bundle --outfile=dist/pre-signup-lambda/index.js", "zip:migration-lambda": "cd dist/migration-lambda && zip -r ../migrateUserHandler.zip .", "zip:post-confirmation-lambda": "cd dist/post-confirmation-lambda && zip -r ../postConfirmationHandler.zip .", "zip:pre-signup-lambda": "cd dist/pre-signup-lambda && zip -r ../preSignUpHandler.zip .",