@aws-amplify/auth 6.5.1-email-mfa-test.4e655bc.0 → 6.5.1-storage-browser.4db9fef.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/AuthErrorStrings.js +2 -2
- package/dist/cjs/common/AuthErrorStrings.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js +2 -2
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/updateMFAPreference.js +1 -2
- package/dist/cjs/providers/cognito/apis/updateMFAPreference.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/signInHelpers.js +130 -183
- package/dist/cjs/providers/cognito/utils/signInHelpers.js.map +1 -1
- package/dist/esm/common/AuthErrorStrings.mjs +2 -2
- package/dist/esm/common/AuthErrorStrings.mjs.map +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/constants.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createAssociateSoftwareTokenClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createChangePasswordClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmDeviceClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmForgotPasswordClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmSignUpClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteUserAttributesClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteUserClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createForgetDeviceClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createForgotPasswordClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserAttributeVerificationCodeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGlobalSignOutClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createInitiateAuthClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createListDevicesClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createResendConfirmationCodeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createRevokeTokenClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSetUserMFAPreferenceClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createUpdateDeviceStatusClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createUpdateUserAttributesClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createVerifySoftwareTokenClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createVerifyUserAttributeClient.d.ts +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/types/sdk.d.ts +3 -24
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs +2 -2
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/updateMFAPreference.mjs +1 -2
- package/dist/esm/providers/cognito/apis/updateMFAPreference.mjs.map +1 -1
- package/dist/esm/providers/cognito/types/inputs.d.ts +0 -1
- package/dist/esm/providers/cognito/utils/signInHelpers.d.ts +3 -4
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs +127 -181
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs.map +1 -1
- package/dist/esm/types/models.d.ts +2 -44
- package/package.json +5 -5
- package/src/common/AuthErrorStrings.ts +2 -4
- package/src/foundation/factories/serviceClients/cognitoIdentityProvider/types/sdk.ts +1 -23
- package/src/providers/cognito/apis/confirmSignIn.ts +2 -2
- package/src/providers/cognito/apis/updateMFAPreference.ts +1 -2
- package/src/providers/cognito/types/inputs.ts +0 -1
- package/src/providers/cognito/utils/signInHelpers.ts +166 -240
- package/src/types/models.ts +1 -48
|
@@ -47,8 +47,8 @@ exports.validationErrorMap = {
|
|
|
47
47
|
recoverySuggestion: 'Do not include a password in your signIn call.',
|
|
48
48
|
},
|
|
49
49
|
[validation_1.AuthValidationErrorCode.IncorrectMFAMethod]: {
|
|
50
|
-
message: 'Incorrect MFA method was chosen. It should be either SMS
|
|
51
|
-
recoverySuggestion: 'Try to pass
|
|
50
|
+
message: 'Incorrect MFA method was chosen. It should be either SMS or TOTP',
|
|
51
|
+
recoverySuggestion: 'Try to pass TOTP or SMS as the challengeResponse',
|
|
52
52
|
},
|
|
53
53
|
[validation_1.AuthValidationErrorCode.EmptyVerifyTOTPSetupCode]: {
|
|
54
54
|
message: 'code is required to verifyTotpSetup',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthErrorStrings.js","sources":["../../../src/common/AuthErrorStrings.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AuthErrorCodes = exports.AuthErrorStrings = exports.validationErrorMap = void 0;\nconst validation_1 = require(\"../errors/types/validation\");\nexports.validationErrorMap = {\n [validation_1.AuthValidationErrorCode.EmptyChallengeResponse]: {\n message: 'challengeResponse is required to confirmSignIn',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmResetPasswordUsername]: {\n message: 'username is required to confirmResetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmSignUpCode]: {\n message: 'code is required to confirmSignUp',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmSignUpUsername]: {\n message: 'username is required to confirmSignUp',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmResetPasswordConfirmationCode]: {\n message: 'confirmationCode is required to confirmResetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmResetPasswordNewPassword]: {\n message: 'newPassword is required to confirmResetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyResendSignUpCodeUsername]: {\n message: 'username is required to confirmSignUp',\n },\n [validation_1.AuthValidationErrorCode.EmptyResetPasswordUsername]: {\n message: 'username is required to resetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptySignInPassword]: {\n message: 'password is required to signIn',\n },\n [validation_1.AuthValidationErrorCode.EmptySignInUsername]: {\n message: 'username is required to signIn',\n },\n [validation_1.AuthValidationErrorCode.EmptySignUpPassword]: {\n message: 'password is required to signUp',\n },\n [validation_1.AuthValidationErrorCode.EmptySignUpUsername]: {\n message: 'username is required to signUp',\n },\n [validation_1.AuthValidationErrorCode.CustomAuthSignInPassword]: {\n message: 'A password is not needed when signing in with CUSTOM_WITHOUT_SRP',\n recoverySuggestion: 'Do not include a password in your signIn call.',\n },\n [validation_1.AuthValidationErrorCode.IncorrectMFAMethod]: {\n message: 'Incorrect MFA method was chosen. It should be either SMS
|
|
1
|
+
{"version":3,"file":"AuthErrorStrings.js","sources":["../../../src/common/AuthErrorStrings.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AuthErrorCodes = exports.AuthErrorStrings = exports.validationErrorMap = void 0;\nconst validation_1 = require(\"../errors/types/validation\");\nexports.validationErrorMap = {\n [validation_1.AuthValidationErrorCode.EmptyChallengeResponse]: {\n message: 'challengeResponse is required to confirmSignIn',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmResetPasswordUsername]: {\n message: 'username is required to confirmResetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmSignUpCode]: {\n message: 'code is required to confirmSignUp',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmSignUpUsername]: {\n message: 'username is required to confirmSignUp',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmResetPasswordConfirmationCode]: {\n message: 'confirmationCode is required to confirmResetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmResetPasswordNewPassword]: {\n message: 'newPassword is required to confirmResetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyResendSignUpCodeUsername]: {\n message: 'username is required to confirmSignUp',\n },\n [validation_1.AuthValidationErrorCode.EmptyResetPasswordUsername]: {\n message: 'username is required to resetPassword',\n },\n [validation_1.AuthValidationErrorCode.EmptySignInPassword]: {\n message: 'password is required to signIn',\n },\n [validation_1.AuthValidationErrorCode.EmptySignInUsername]: {\n message: 'username is required to signIn',\n },\n [validation_1.AuthValidationErrorCode.EmptySignUpPassword]: {\n message: 'password is required to signUp',\n },\n [validation_1.AuthValidationErrorCode.EmptySignUpUsername]: {\n message: 'username is required to signUp',\n },\n [validation_1.AuthValidationErrorCode.CustomAuthSignInPassword]: {\n message: 'A password is not needed when signing in with CUSTOM_WITHOUT_SRP',\n recoverySuggestion: 'Do not include a password in your signIn call.',\n },\n [validation_1.AuthValidationErrorCode.IncorrectMFAMethod]: {\n message: 'Incorrect MFA method was chosen. It should be either SMS or TOTP',\n recoverySuggestion: 'Try to pass TOTP or SMS as the challengeResponse',\n },\n [validation_1.AuthValidationErrorCode.EmptyVerifyTOTPSetupCode]: {\n message: 'code is required to verifyTotpSetup',\n },\n [validation_1.AuthValidationErrorCode.EmptyUpdatePassword]: {\n message: 'oldPassword and newPassword are required to changePassword',\n },\n [validation_1.AuthValidationErrorCode.EmptyConfirmUserAttributeCode]: {\n message: 'confirmation code is required to confirmUserAttribute',\n },\n};\n// TODO: delete this code when the Auth class is removed.\nvar AuthErrorStrings;\n(function (AuthErrorStrings) {\n AuthErrorStrings[\"DEFAULT_MSG\"] = \"Authentication Error\";\n AuthErrorStrings[\"EMPTY_EMAIL\"] = \"Email cannot be empty\";\n AuthErrorStrings[\"EMPTY_PHONE\"] = \"Phone number cannot be empty\";\n AuthErrorStrings[\"EMPTY_USERNAME\"] = \"Username cannot be empty\";\n AuthErrorStrings[\"INVALID_USERNAME\"] = \"The username should either be a string or one of the sign in types\";\n AuthErrorStrings[\"EMPTY_PASSWORD\"] = \"Password cannot be empty\";\n AuthErrorStrings[\"EMPTY_CODE\"] = \"Confirmation code cannot be empty\";\n AuthErrorStrings[\"SIGN_UP_ERROR\"] = \"Error creating account\";\n AuthErrorStrings[\"NO_MFA\"] = \"No valid MFA method provided\";\n AuthErrorStrings[\"INVALID_MFA\"] = \"Invalid MFA type\";\n AuthErrorStrings[\"EMPTY_CHALLENGE\"] = \"Challenge response cannot be empty\";\n AuthErrorStrings[\"NO_USER_SESSION\"] = \"Failed to get the session because the user is empty\";\n AuthErrorStrings[\"NETWORK_ERROR\"] = \"Network Error\";\n AuthErrorStrings[\"DEVICE_CONFIG\"] = \"Device tracking has not been configured in this User Pool\";\n AuthErrorStrings[\"AUTOSIGNIN_ERROR\"] = \"Please use your credentials to sign in\";\n AuthErrorStrings[\"OAUTH_ERROR\"] = \"Couldn't finish OAuth flow, check your User Pool HostedUI settings\";\n})(AuthErrorStrings = exports.AuthErrorStrings || (exports.AuthErrorStrings = {}));\nvar AuthErrorCodes;\n(function (AuthErrorCodes) {\n AuthErrorCodes[\"SignInException\"] = \"SignInException\";\n AuthErrorCodes[\"OAuthSignInError\"] = \"OAuthSignInException\";\n})(AuthErrorCodes = exports.AuthErrorCodes || (exports.AuthErrorCodes = {}));\n"],"names":[],"mappings":";;AACA;AACA;AACA,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oEAAoE,CAAC;AAChH,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,0BAA0B,CAAC;AACpE,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,mCAAmC,CAAC;AACzE,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,wBAAwB,CAAC;AACjE,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,8BAA8B,CAAC;AAChE,IAAI,gBAAgB,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAC;AACzD,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,oCAAoC,CAAC;AAC/E,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,qDAAqD,CAAC;AAChG,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACxD,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,2DAA2D,CAAC;AACpG,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,wCAAwC,CAAC;AACpF,IAAI,gBAAgB,CAAC,aAAa,CAAC,GAAG,oEAAoE,CAAC;AAC3G,CAAC,EAAqB,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;AAEnF,CAAC,UAAU,cAAc,EAAE;AAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC1D,IAAI,cAAc,CAAC,kBAAkB,CAAC,GAAG,sBAAsB,CAAC;AAChE,CAAC,EAAmB,OAAO,CAAC,cAAc,KAAK,OAAO,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;;"}
|
|
@@ -43,8 +43,8 @@ async function confirmSignIn(input) {
|
|
|
43
43
|
throw new AuthError_1.AuthError({
|
|
44
44
|
name: AuthErrorStrings_1.AuthErrorCodes.SignInException,
|
|
45
45
|
message: `
|
|
46
|
-
An error occurred during the sign in process.
|
|
47
|
-
|
|
46
|
+
An error occurred during the sign in process.
|
|
47
|
+
|
|
48
48
|
This most likely occurred due to:
|
|
49
49
|
1. signIn was not called before confirmSignIn.
|
|
50
50
|
2. signIn threw an exception.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmSignIn.js","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.confirmSignIn = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst signInStore_1 = require(\"../utils/signInStore\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst AuthErrorStrings_1 = require(\"../../../common/AuthErrorStrings\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\n/**\n * Continues or completes the sign in process when required by the initial call to `signIn`.\n *\n * @param input - The ConfirmSignInInput object\n * @returns ConfirmSignInOutput\n * @throws -{@link VerifySoftwareTokenException }:\n * Thrown due to an invalid MFA token.\n * @throws -{@link RespondToAuthChallengeException }:\n * Thrown due to an invalid auth challenge response.\n * @throws -{@link AssociateSoftwareTokenException}:\n * Thrown due to a service error during the MFA setup process.\n * @throws -{@link AuthValidationErrorCode }:\n * Thrown when `challengeResponse` is not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = signInStore_1.signInStore.getState();\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!challengeResponse, validation_1.AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process
|
|
1
|
+
{"version":3,"file":"confirmSignIn.js","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.confirmSignIn = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst signInStore_1 = require(\"../utils/signInStore\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst AuthErrorStrings_1 = require(\"../../../common/AuthErrorStrings\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\n/**\n * Continues or completes the sign in process when required by the initial call to `signIn`.\n *\n * @param input - The ConfirmSignInInput object\n * @returns ConfirmSignInOutput\n * @throws -{@link VerifySoftwareTokenException }:\n * Thrown due to an invalid MFA token.\n * @throws -{@link RespondToAuthChallengeException }:\n * Thrown due to an invalid auth challenge response.\n * @throws -{@link AssociateSoftwareTokenException}:\n * Thrown due to a service error during the MFA setup process.\n * @throws -{@link AuthValidationErrorCode }:\n * Thrown when `challengeResponse` is not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = signInStore_1.signInStore.getState();\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!challengeResponse, validation_1.AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process. \n\t\t\t\n\t\t\tThis most likely occurred due to:\n\t\t\t1. signIn was not called before confirmSignIn.\n\t\t\t2. signIn threw an exception.\n\t\t\t3. page was refreshed during the sign in flow.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the page is not refreshed until the sign in process is done.',\n });\n try {\n const { Session, ChallengeName: handledChallengeName, AuthenticationResult, ChallengeParameters: handledChallengeParameters, } = await (0, signInHelpers_1.handleChallengeName)(username, challengeName, signInSession, challengeResponse, authConfig, tokenProvider_1.tokenOrchestrator, clientMetaData, options);\n // sets up local state used during the sign-in process\n (0, signInStore_1.setActiveSignInState)({\n signInSession: Session,\n username,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n (0, signInStore_1.cleanActiveSignInState)();\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username,\n ...AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n (0, assertServiceError_1.assertServiceError)(error);\n const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.confirmSignIn = confirmSignIn;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,aAAa,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACtD,MAAM,WAAW,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACzD,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D,MAAM,oBAAoB,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AACjF,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACvE,MAAM,aAAa,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,0BAA0B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa,CAAC,KAAK,EAAE;AACpC,IAAI,MAAM,EAAE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;AAClB,YAAY,OAAO,MAAM,CAAC;AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -19,7 +19,7 @@ const factories_1 = require("../factories");
|
|
|
19
19
|
* @throws AuthTokenConfigException - Thrown when the token provider config is invalid.
|
|
20
20
|
*/
|
|
21
21
|
async function updateMFAPreference(input) {
|
|
22
|
-
const { sms, totp
|
|
22
|
+
const { sms, totp } = input;
|
|
23
23
|
const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;
|
|
24
24
|
(0, utils_1.assertTokenProviderConfig)(authConfig);
|
|
25
25
|
const { userPoolEndpoint, userPoolId } = authConfig;
|
|
@@ -37,7 +37,6 @@ async function updateMFAPreference(input) {
|
|
|
37
37
|
AccessToken: tokens.accessToken.toString(),
|
|
38
38
|
SMSMfaSettings: getMFASettings(sms),
|
|
39
39
|
SoftwareTokenMfaSettings: getMFASettings(totp),
|
|
40
|
-
EmailMfaSettings: getMFASettings(email),
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
exports.updateMFAPreference = updateMFAPreference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateMFAPreference.js","sources":["../../../../../src/providers/cognito/apis/updateMFAPreference.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getMFASettings = exports.updateMFAPreference = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst types_1 = require(\"../utils/types\");\nconst utils_2 = require(\"../../../utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../factories\");\n/**\n * Updates the MFA preference of the user.\n *\n * @param input - The UpdateMFAPreferenceInput object.\n * @throws -{@link SetUserMFAPreferenceException } - Service error thrown when the MFA preference cannot be updated.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function updateMFAPreference(input) {\n const { sms, totp
|
|
1
|
+
{"version":3,"file":"updateMFAPreference.js","sources":["../../../../../src/providers/cognito/apis/updateMFAPreference.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getMFASettings = exports.updateMFAPreference = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst types_1 = require(\"../utils/types\");\nconst utils_2 = require(\"../../../utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../factories\");\n/**\n * Updates the MFA preference of the user.\n *\n * @param input - The UpdateMFAPreferenceInput object.\n * @throws -{@link SetUserMFAPreferenceException } - Service error thrown when the MFA preference cannot be updated.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function updateMFAPreference(input) {\n const { sms, totp } = input;\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await (0, core_1.fetchAuthSession)({ forceRefresh: false });\n (0, types_1.assertAuthTokens)(tokens);\n const setUserMFAPreference = (0, cognitoIdentityProvider_1.createSetUserMFAPreferenceClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await setUserMFAPreference({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.UpdateMFAPreference),\n }, {\n AccessToken: tokens.accessToken.toString(),\n SMSMfaSettings: getMFASettings(sms),\n SoftwareTokenMfaSettings: getMFASettings(totp),\n });\n}\nexports.updateMFAPreference = updateMFAPreference;\nfunction getMFASettings(mfaPreference) {\n if (mfaPreference === 'DISABLED') {\n return {\n Enabled: false,\n };\n }\n else if (mfaPreference === 'PREFERRED') {\n return {\n Enabled: true,\n PreferredMfa: true,\n };\n }\n else if (mfaPreference === 'ENABLED') {\n return {\n Enabled: true,\n };\n }\n else if (mfaPreference === 'NOT_PREFERRED') {\n return {\n Enabled: true,\n PreferredMfa: false,\n };\n }\n}\nexports.getMFASettings = getMFASettings;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,yBAAyB,GAAG,OAAO,CAAC,sEAAsE,CAAC,CAAC;AAClH,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB,CAAC,KAAK,EAAE;AAC1C,IAAI,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAChC,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAA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IAAI;AACzB,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS,CAAC;AACV,KAAK;AACL,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE;AAC1C,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,SAAS,CAAC;AACV,KAAK;AACL,SAAS,IAAI,aAAa,KAAK,eAAe,EAAE;AAChD,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,YAAY,YAAY,EAAE,KAAK;AAC/B,SAAS,CAAC;AACV,KAAK;AACL,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getActiveSignInUsername = exports.setActiveSignInUsername = exports.retryOnResourceNotFoundException = exports.getNewDeviceMetadata = exports.assertUserNotAuthenticated = exports.isMFATypeEnabled = exports.parseMFATypes = exports.getMFATypes = exports.getMFAType = exports.mapMfaType = exports.handleChallengeName = exports.createAttributes = exports.parseAttributes = exports.getSignInResultFromError = exports.getTOTPSetupDetails = exports.getSignInResult = exports.handlePasswordVerifierChallenge = exports.handleCustomSRPAuthFlow = exports.handleCustomAuthFlowWithoutSRP = exports.handleUserSRPAuthFlow = exports.handleUserPasswordAuthFlow = exports.handleCompleteNewPasswordChallenge = exports.handleSoftwareTokenMFAChallenge = exports.handleSMSMFAChallenge = exports.handleSelectMFATypeChallenge = exports.handleMFASetupChallenge = exports.handleCustomChallenge = void 0;
|
|
7
7
|
const core_1 = require("@aws-amplify/core");
|
|
8
8
|
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
9
|
const AuthError_1 = require("../../../errors/AuthError");
|
|
@@ -69,91 +69,44 @@ async function handleCustomChallenge({ challengeResponse, clientMetadata, sessio
|
|
|
69
69
|
exports.handleCustomChallenge = handleCustomChallenge;
|
|
70
70
|
async function handleMFASetupChallenge({ challengeResponse, username, clientMetadata, session, deviceName, config, }) {
|
|
71
71
|
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
|
|
72
|
-
if (challengeResponse === 'EMAIL') {
|
|
73
|
-
return {
|
|
74
|
-
ChallengeName: 'MFA_SETUP',
|
|
75
|
-
Session: session,
|
|
76
|
-
ChallengeParameters: {
|
|
77
|
-
MFAS_CAN_SETUP: '["EMAIL_OTP"]',
|
|
78
|
-
},
|
|
79
|
-
$metadata: {},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (challengeResponse === 'TOTP') {
|
|
83
|
-
return {
|
|
84
|
-
ChallengeName: 'MFA_SETUP',
|
|
85
|
-
Session: session,
|
|
86
|
-
ChallengeParameters: {
|
|
87
|
-
MFAS_CAN_SETUP: '["SOFTWARE_TOKEN_MFA"]',
|
|
88
|
-
},
|
|
89
|
-
$metadata: {},
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
72
|
const challengeResponses = {
|
|
93
73
|
USERNAME: username,
|
|
94
74
|
};
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
endpointOverride: userPoolEndpoint,
|
|
124
|
-
}),
|
|
125
|
-
});
|
|
126
|
-
return respondToAuthChallenge({ region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId) }, jsonReq);
|
|
127
|
-
}
|
|
128
|
-
const isEmail = /^\S+@\S+\.\S+$/.test(challengeResponse.trim());
|
|
129
|
-
if (isEmail) {
|
|
130
|
-
challengeResponses.EMAIL = challengeResponse;
|
|
131
|
-
const jsonReq = {
|
|
132
|
-
ChallengeName: 'MFA_SETUP',
|
|
133
|
-
ChallengeResponses: challengeResponses,
|
|
134
|
-
Session: session,
|
|
135
|
-
ClientMetadata: clientMetadata,
|
|
136
|
-
ClientId: userPoolClientId,
|
|
137
|
-
};
|
|
138
|
-
const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({
|
|
139
|
-
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
140
|
-
endpointOverride: userPoolEndpoint,
|
|
141
|
-
}),
|
|
142
|
-
});
|
|
143
|
-
return respondToAuthChallenge({ region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId) }, jsonReq);
|
|
144
|
-
}
|
|
145
|
-
throw new AuthError_1.AuthError({
|
|
146
|
-
name: AuthErrorStrings_1.AuthErrorCodes.SignInException,
|
|
147
|
-
message: `Cannot proceed with MFA setup using challengeResponse: ${challengeResponse}`,
|
|
148
|
-
recoverySuggestion: 'Try passing "EMAIL", "TOTP", a valid email, or OTP code as the challengeResponse.',
|
|
75
|
+
const verifySoftwareToken = (0, cognitoIdentityProvider_1.createVerifySoftwareTokenClient)({
|
|
76
|
+
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
77
|
+
endpointOverride: userPoolEndpoint,
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
const { Session } = await verifySoftwareToken({
|
|
81
|
+
region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),
|
|
82
|
+
userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),
|
|
83
|
+
}, {
|
|
84
|
+
UserCode: challengeResponse,
|
|
85
|
+
Session: session,
|
|
86
|
+
FriendlyDeviceName: deviceName,
|
|
87
|
+
});
|
|
88
|
+
signInStore_1.signInStore.dispatch({
|
|
89
|
+
type: 'SET_SIGN_IN_SESSION',
|
|
90
|
+
value: Session,
|
|
91
|
+
});
|
|
92
|
+
const jsonReq = {
|
|
93
|
+
ChallengeName: 'MFA_SETUP',
|
|
94
|
+
ChallengeResponses: challengeResponses,
|
|
95
|
+
Session,
|
|
96
|
+
ClientMetadata: clientMetadata,
|
|
97
|
+
ClientId: userPoolClientId,
|
|
98
|
+
};
|
|
99
|
+
const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({
|
|
100
|
+
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
101
|
+
endpointOverride: userPoolEndpoint,
|
|
102
|
+
}),
|
|
149
103
|
});
|
|
104
|
+
return respondToAuthChallenge({ region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId) }, jsonReq);
|
|
150
105
|
}
|
|
151
106
|
exports.handleMFASetupChallenge = handleMFASetupChallenge;
|
|
152
107
|
async function handleSelectMFATypeChallenge({ challengeResponse, username, clientMetadata, session, config, }) {
|
|
153
108
|
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
|
|
154
|
-
(0, assertValidationError_1.assertValidationError)(challengeResponse === 'TOTP' ||
|
|
155
|
-
challengeResponse === 'SMS' ||
|
|
156
|
-
challengeResponse === 'EMAIL', validation_1.AuthValidationErrorCode.IncorrectMFAMethod);
|
|
109
|
+
(0, assertValidationError_1.assertValidationError)(challengeResponse === 'TOTP' || challengeResponse === 'SMS', validation_1.AuthValidationErrorCode.IncorrectMFAMethod);
|
|
157
110
|
const challengeResponses = {
|
|
158
111
|
USERNAME: username,
|
|
159
112
|
ANSWER: mapMfaType(challengeResponse),
|
|
@@ -182,6 +135,66 @@ async function handleSelectMFATypeChallenge({ challengeResponse, username, clien
|
|
|
182
135
|
}, jsonReq);
|
|
183
136
|
}
|
|
184
137
|
exports.handleSelectMFATypeChallenge = handleSelectMFATypeChallenge;
|
|
138
|
+
async function handleSMSMFAChallenge({ challengeResponse, clientMetadata, session, username, config, }) {
|
|
139
|
+
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
|
|
140
|
+
const challengeResponses = {
|
|
141
|
+
USERNAME: username,
|
|
142
|
+
SMS_MFA_CODE: challengeResponse,
|
|
143
|
+
};
|
|
144
|
+
const UserContextData = (0, userContextData_1.getUserContextData)({
|
|
145
|
+
username,
|
|
146
|
+
userPoolId,
|
|
147
|
+
userPoolClientId,
|
|
148
|
+
});
|
|
149
|
+
const jsonReq = {
|
|
150
|
+
ChallengeName: 'SMS_MFA',
|
|
151
|
+
ChallengeResponses: challengeResponses,
|
|
152
|
+
Session: session,
|
|
153
|
+
ClientMetadata: clientMetadata,
|
|
154
|
+
ClientId: userPoolClientId,
|
|
155
|
+
UserContextData,
|
|
156
|
+
};
|
|
157
|
+
const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({
|
|
158
|
+
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
159
|
+
endpointOverride: userPoolEndpoint,
|
|
160
|
+
}),
|
|
161
|
+
});
|
|
162
|
+
return respondToAuthChallenge({
|
|
163
|
+
region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),
|
|
164
|
+
userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),
|
|
165
|
+
}, jsonReq);
|
|
166
|
+
}
|
|
167
|
+
exports.handleSMSMFAChallenge = handleSMSMFAChallenge;
|
|
168
|
+
async function handleSoftwareTokenMFAChallenge({ challengeResponse, clientMetadata, session, username, config, }) {
|
|
169
|
+
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
|
|
170
|
+
const challengeResponses = {
|
|
171
|
+
USERNAME: username,
|
|
172
|
+
SOFTWARE_TOKEN_MFA_CODE: challengeResponse,
|
|
173
|
+
};
|
|
174
|
+
const UserContextData = (0, userContextData_1.getUserContextData)({
|
|
175
|
+
username,
|
|
176
|
+
userPoolId,
|
|
177
|
+
userPoolClientId,
|
|
178
|
+
});
|
|
179
|
+
const jsonReq = {
|
|
180
|
+
ChallengeName: 'SOFTWARE_TOKEN_MFA',
|
|
181
|
+
ChallengeResponses: challengeResponses,
|
|
182
|
+
Session: session,
|
|
183
|
+
ClientMetadata: clientMetadata,
|
|
184
|
+
ClientId: userPoolClientId,
|
|
185
|
+
UserContextData,
|
|
186
|
+
};
|
|
187
|
+
const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({
|
|
188
|
+
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
189
|
+
endpointOverride: userPoolEndpoint,
|
|
190
|
+
}),
|
|
191
|
+
});
|
|
192
|
+
return respondToAuthChallenge({
|
|
193
|
+
region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),
|
|
194
|
+
userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),
|
|
195
|
+
}, jsonReq);
|
|
196
|
+
}
|
|
197
|
+
exports.handleSoftwareTokenMFAChallenge = handleSoftwareTokenMFAChallenge;
|
|
185
198
|
async function handleCompleteNewPasswordChallenge({ challengeResponse, clientMetadata, session, username, requiredAttributes, config, }) {
|
|
186
199
|
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
|
|
187
200
|
const challengeResponses = {
|
|
@@ -541,52 +554,30 @@ async function getSignInResult(params) {
|
|
|
541
554
|
};
|
|
542
555
|
case 'MFA_SETUP': {
|
|
543
556
|
const { signInSession, username } = signInStore_1.signInStore.getState();
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if (isTotpMfaSetupAvailable && isEmailMfaSetupAvailable) {
|
|
549
|
-
return {
|
|
550
|
-
isSignedIn: false,
|
|
551
|
-
nextStep: {
|
|
552
|
-
signInStep: 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION',
|
|
553
|
-
allowedMFATypes: allowedMfaSetupTypes,
|
|
554
|
-
},
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
if (isEmailMfaSetupAvailable) {
|
|
558
|
-
return {
|
|
559
|
-
isSignedIn: false,
|
|
560
|
-
nextStep: {
|
|
561
|
-
signInStep: 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP',
|
|
562
|
-
},
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
if (isTotpMfaSetupAvailable) {
|
|
566
|
-
const associateSoftwareToken = (0, cognitoIdentityProvider_1.createAssociateSoftwareTokenClient)({
|
|
567
|
-
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
568
|
-
endpointOverride: authConfig.userPoolEndpoint,
|
|
569
|
-
}),
|
|
570
|
-
});
|
|
571
|
-
const { Session, SecretCode: secretCode } = await associateSoftwareToken({ region: (0, parsers_1.getRegionFromUserPoolId)(authConfig.userPoolId) }, {
|
|
572
|
-
Session: signInSession,
|
|
573
|
-
});
|
|
574
|
-
signInStore_1.signInStore.dispatch({
|
|
575
|
-
type: 'SET_SIGN_IN_SESSION',
|
|
576
|
-
value: Session,
|
|
557
|
+
if (!isMFATypeEnabled(challengeParameters, 'TOTP'))
|
|
558
|
+
throw new AuthError_1.AuthError({
|
|
559
|
+
name: AuthErrorStrings_1.AuthErrorCodes.SignInException,
|
|
560
|
+
message: `Cannot initiate MFA setup from available types: ${getMFATypes(parseMFATypes(challengeParameters.MFAS_CAN_SETUP))}`,
|
|
577
561
|
});
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
562
|
+
const associateSoftwareToken = (0, cognitoIdentityProvider_1.createAssociateSoftwareTokenClient)({
|
|
563
|
+
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
564
|
+
endpointOverride: authConfig.userPoolEndpoint,
|
|
565
|
+
}),
|
|
566
|
+
});
|
|
567
|
+
const { Session, SecretCode: secretCode } = await associateSoftwareToken({ region: (0, parsers_1.getRegionFromUserPoolId)(authConfig.userPoolId) }, {
|
|
568
|
+
Session: signInSession,
|
|
569
|
+
});
|
|
570
|
+
signInStore_1.signInStore.dispatch({
|
|
571
|
+
type: 'SET_SIGN_IN_SESSION',
|
|
572
|
+
value: Session,
|
|
589
573
|
});
|
|
574
|
+
return {
|
|
575
|
+
isSignedIn: false,
|
|
576
|
+
nextStep: {
|
|
577
|
+
signInStep: 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP',
|
|
578
|
+
totpSetupDetails: getTOTPSetupDetails(secretCode, username),
|
|
579
|
+
},
|
|
580
|
+
};
|
|
590
581
|
}
|
|
591
582
|
case 'NEW_PASSWORD_REQUIRED':
|
|
592
583
|
return {
|
|
@@ -622,17 +613,6 @@ async function getSignInResult(params) {
|
|
|
622
613
|
signInStep: 'CONFIRM_SIGN_IN_WITH_TOTP_CODE',
|
|
623
614
|
},
|
|
624
615
|
};
|
|
625
|
-
case 'EMAIL_OTP':
|
|
626
|
-
return {
|
|
627
|
-
isSignedIn: false,
|
|
628
|
-
nextStep: {
|
|
629
|
-
signInStep: 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE',
|
|
630
|
-
codeDeliveryDetails: {
|
|
631
|
-
deliveryMedium: challengeParameters.CODE_DELIVERY_DELIVERY_MEDIUM,
|
|
632
|
-
destination: challengeParameters.CODE_DELIVERY_DESTINATION,
|
|
633
|
-
},
|
|
634
|
-
},
|
|
635
|
-
};
|
|
636
616
|
}
|
|
637
617
|
// TODO: remove this error message for production apps
|
|
638
618
|
throw new AuthError_1.AuthError({
|
|
@@ -689,6 +669,14 @@ async function handleChallengeName(username, challengeName, session, challengeRe
|
|
|
689
669
|
const userAttributes = options?.userAttributes;
|
|
690
670
|
const deviceName = options?.friendlyDeviceName;
|
|
691
671
|
switch (challengeName) {
|
|
672
|
+
case 'SMS_MFA':
|
|
673
|
+
return handleSMSMFAChallenge({
|
|
674
|
+
challengeResponse,
|
|
675
|
+
clientMetadata,
|
|
676
|
+
session,
|
|
677
|
+
username,
|
|
678
|
+
config,
|
|
679
|
+
});
|
|
692
680
|
case 'SELECT_MFA_TYPE':
|
|
693
681
|
return handleSelectMFATypeChallenge({
|
|
694
682
|
challengeResponse,
|
|
@@ -726,11 +714,8 @@ async function handleChallengeName(username, challengeName, session, challengeRe
|
|
|
726
714
|
tokenOrchestrator,
|
|
727
715
|
},
|
|
728
716
|
], username, tokenOrchestrator);
|
|
729
|
-
case 'SMS_MFA':
|
|
730
717
|
case 'SOFTWARE_TOKEN_MFA':
|
|
731
|
-
|
|
732
|
-
return handleMFAChallenge({
|
|
733
|
-
challengeName,
|
|
718
|
+
return handleSoftwareTokenMFAChallenge({
|
|
734
719
|
challengeResponse,
|
|
735
720
|
clientMetadata,
|
|
736
721
|
session,
|
|
@@ -741,7 +726,7 @@ async function handleChallengeName(username, challengeName, session, challengeRe
|
|
|
741
726
|
// TODO: remove this error message for production apps
|
|
742
727
|
throw new AuthError_1.AuthError({
|
|
743
728
|
name: AuthErrorStrings_1.AuthErrorCodes.SignInException,
|
|
744
|
-
message: `An error occurred during the sign in process.
|
|
729
|
+
message: `An error occurred during the sign in process.
|
|
745
730
|
${challengeName} challengeName returned by the underlying service was not addressed.`,
|
|
746
731
|
});
|
|
747
732
|
}
|
|
@@ -750,8 +735,6 @@ function mapMfaType(mfa) {
|
|
|
750
735
|
let mfaType = 'SMS_MFA';
|
|
751
736
|
if (mfa === 'TOTP')
|
|
752
737
|
mfaType = 'SOFTWARE_TOKEN_MFA';
|
|
753
|
-
if (mfa === 'EMAIL')
|
|
754
|
-
mfaType = 'EMAIL_OTP';
|
|
755
738
|
return mfaType;
|
|
756
739
|
}
|
|
757
740
|
exports.mapMfaType = mapMfaType;
|
|
@@ -760,8 +743,6 @@ function getMFAType(type) {
|
|
|
760
743
|
return 'SMS';
|
|
761
744
|
if (type === 'SOFTWARE_TOKEN_MFA')
|
|
762
745
|
return 'TOTP';
|
|
763
|
-
if (type === 'EMAIL_OTP')
|
|
764
|
-
return 'EMAIL';
|
|
765
746
|
// TODO: log warning for unknown MFA type
|
|
766
747
|
}
|
|
767
748
|
exports.getMFAType = getMFAType;
|
|
@@ -777,10 +758,14 @@ function parseMFATypes(mfa) {
|
|
|
777
758
|
return JSON.parse(mfa);
|
|
778
759
|
}
|
|
779
760
|
exports.parseMFATypes = parseMFATypes;
|
|
780
|
-
function
|
|
781
|
-
|
|
761
|
+
function isMFATypeEnabled(challengeParams, mfaType) {
|
|
762
|
+
const { MFAS_CAN_SETUP } = challengeParams;
|
|
763
|
+
const mfaTypes = getMFATypes(parseMFATypes(MFAS_CAN_SETUP));
|
|
764
|
+
if (!mfaTypes)
|
|
765
|
+
return false;
|
|
766
|
+
return mfaTypes.includes(mfaType);
|
|
782
767
|
}
|
|
783
|
-
exports.
|
|
768
|
+
exports.isMFATypeEnabled = isMFATypeEnabled;
|
|
784
769
|
async function assertUserNotAuthenticated() {
|
|
785
770
|
let authUser;
|
|
786
771
|
try {
|
|
@@ -878,42 +863,4 @@ function getActiveSignInUsername(username) {
|
|
|
878
863
|
return state.username ?? username;
|
|
879
864
|
}
|
|
880
865
|
exports.getActiveSignInUsername = getActiveSignInUsername;
|
|
881
|
-
async function handleMFAChallenge({ challengeName, challengeResponse, clientMetadata, session, username, config, }) {
|
|
882
|
-
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
|
|
883
|
-
const challengeResponses = {
|
|
884
|
-
USERNAME: username,
|
|
885
|
-
};
|
|
886
|
-
if (challengeName === 'EMAIL_OTP') {
|
|
887
|
-
challengeResponses.EMAIL_OTP_CODE = challengeResponse;
|
|
888
|
-
}
|
|
889
|
-
if (challengeName === 'SMS_MFA') {
|
|
890
|
-
challengeResponses.SMS_MFA_CODE = challengeResponse;
|
|
891
|
-
}
|
|
892
|
-
if (challengeName === 'SOFTWARE_TOKEN_MFA') {
|
|
893
|
-
challengeResponses.SOFTWARE_TOKEN_MFA_CODE = challengeResponse;
|
|
894
|
-
}
|
|
895
|
-
const userContextData = (0, userContextData_1.getUserContextData)({
|
|
896
|
-
username,
|
|
897
|
-
userPoolId,
|
|
898
|
-
userPoolClientId,
|
|
899
|
-
});
|
|
900
|
-
const jsonReq = {
|
|
901
|
-
ChallengeName: challengeName,
|
|
902
|
-
ChallengeResponses: challengeResponses,
|
|
903
|
-
Session: session,
|
|
904
|
-
ClientMetadata: clientMetadata,
|
|
905
|
-
ClientId: userPoolClientId,
|
|
906
|
-
UserContextData: userContextData,
|
|
907
|
-
};
|
|
908
|
-
const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({
|
|
909
|
-
endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({
|
|
910
|
-
endpointOverride: userPoolEndpoint,
|
|
911
|
-
}),
|
|
912
|
-
});
|
|
913
|
-
return respondToAuthChallenge({
|
|
914
|
-
region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),
|
|
915
|
-
userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),
|
|
916
|
-
}, jsonReq);
|
|
917
|
-
}
|
|
918
|
-
exports.handleMFAChallenge = handleMFAChallenge;
|
|
919
866
|
//# sourceMappingURL=signInHelpers.js.map
|