@aws-amplify/auth 6.13.4-unstable.e5a8569.0 → 6.14.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/Errors.js.map +1 -1
- package/dist/cjs/client/apis/index.js.map +1 -1
- package/dist/cjs/client/flows/shared/handlePasswordSRP.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js.map +1 -1
- package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js.map +1 -1
- package/dist/cjs/client/utils/index.js.map +1 -1
- package/dist/cjs/client/utils/passkey/errors.js.map +1 -1
- package/dist/cjs/client/utils/passkey/getPasskey.js.map +1 -1
- package/dist/cjs/client/utils/passkey/index.js.map +1 -1
- package/dist/cjs/client/utils/passkey/registerPasskey.js.map +1 -1
- package/dist/cjs/client/utils/passkey/serde.js.map +1 -1
- package/dist/cjs/client/utils/passkey/types/index.js.map +1 -1
- package/dist/cjs/client/utils/store/autoSignInStore.js.map +1 -1
- package/dist/cjs/client/utils/store/signInStore.js.map +1 -1
- package/dist/cjs/errors/AuthError.js.map +1 -1
- package/dist/cjs/errors/utils/assertServiceError.js.map +1 -1
- package/dist/cjs/errors/utils/assertValidationError.js.map +1 -1
- package/dist/cjs/foundation/apis/index.js.map +1 -1
- package/dist/cjs/foundation/convert/base64url/index.js.map +1 -1
- package/dist/cjs/foundation/convert/index.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/constants.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/index.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/shared/handler/index.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createEmptyResponseDeserializer.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createUserPoolDeserializer.js.map +1 -1
- package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/index.js.map +1 -1
- package/dist/cjs/foundation/parsers/index.js.map +1 -1
- package/dist/cjs/foundation/parsers/regionParsers.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/autoSignIn.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/confirmSignUp.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/fetchDevices.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/internal/getCurrentUser.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/server/index.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/setUpTOTP.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithRedirect.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signOut.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signUp.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/updateMFAPreference.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/updateUserAttributes.js.map +1 -1
- package/dist/cjs/providers/cognito/credentialsProvider/IdentityIdProvider.js.map +1 -1
- package/dist/cjs/providers/cognito/credentialsProvider/IdentityIdStore.js.map +1 -1
- package/dist/cjs/providers/cognito/credentialsProvider/credentialsProvider.js.map +1 -1
- package/dist/cjs/providers/cognito/credentialsProvider/index.js.map +1 -1
- package/dist/cjs/providers/cognito/credentialsProvider/utils.js.map +1 -1
- package/dist/cjs/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.js.map +1 -1
- package/dist/cjs/providers/cognito/factories/createCognitoUserPoolEndpointResolver.js.map +1 -1
- package/dist/cjs/providers/cognito/factories/index.js.map +1 -1
- package/dist/cjs/providers/cognito/index.js.map +1 -1
- package/dist/cjs/providers/cognito/tokenProvider/CognitoUserPoolsTokenProvider.js.map +1 -1
- package/dist/cjs/providers/cognito/tokenProvider/TokenOrchestrator.js.map +1 -1
- package/dist/cjs/providers/cognito/tokenProvider/TokenStore.js.map +1 -1
- package/dist/cjs/providers/cognito/tokenProvider/cacheTokens.js.map +1 -1
- package/dist/cjs/providers/cognito/tokenProvider/index.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/apiHelpers.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/dispatchSignedInHubEvent.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/attemptCompleteOAuthFlow.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/cancelOAuthFlow.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/completeOAuthFlow.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/generateCodeVerifier.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.native.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/handleOAuthSignOut.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/handleOAuthSignOut.native.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/index.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/inflightPromise.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/validateState.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/refreshAuthTokens.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/signInHelpers.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/signInWithRedirectStore.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/signUpHelpers.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/AuthenticationHelper/AuthenticationHelper.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/BigInteger/BigInteger.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/BigInteger/index.native.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/calculate/calculateA.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/calculate/calculateS.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/calculate/calculateU.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/calculate/index.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/constants.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/getBytesFromHex.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/getHexFromBytes.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/getNowString.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/getPaddedHex.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/getSignatureString.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/srp/index.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/textEncoder/index.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/textEncoder/index.native.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/types.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/userContextData.js.map +1 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/openAuthSession.js.map +1 -1
- package/dist/cjs/utils/openAuthSession.native.js.map +1 -1
- package/dist/esm/Errors.mjs.map +1 -1
- package/dist/esm/client/flows/shared/handlePasswordSRP.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs.map +1 -1
- package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs.map +1 -1
- package/dist/esm/client/utils/passkey/errors.mjs.map +1 -1
- package/dist/esm/client/utils/passkey/getPasskey.mjs.map +1 -1
- package/dist/esm/client/utils/passkey/registerPasskey.mjs.map +1 -1
- package/dist/esm/client/utils/passkey/serde.mjs.map +1 -1
- package/dist/esm/client/utils/store/autoSignInStore.mjs.map +1 -1
- package/dist/esm/client/utils/store/signInStore.mjs.map +1 -1
- package/dist/esm/errors/AuthError.mjs.map +1 -1
- package/dist/esm/errors/utils/assertServiceError.mjs.map +1 -1
- package/dist/esm/errors/utils/assertValidationError.mjs.map +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/constants.mjs.map +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.mjs.map +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createEmptyResponseDeserializer.mjs.map +1 -1
- package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createUserPoolDeserializer.mjs.map +1 -1
- package/dist/esm/foundation/parsers/regionParsers.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/autoSignIn.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/confirmSignUp.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/fetchDevices.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/internal/getCurrentUser.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/setUpTOTP.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithRedirect.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signOut.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signUp.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/updateMFAPreference.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/updateUserAttributes.mjs.map +1 -1
- package/dist/esm/providers/cognito/credentialsProvider/IdentityIdProvider.mjs.map +1 -1
- package/dist/esm/providers/cognito/credentialsProvider/IdentityIdStore.mjs.map +1 -1
- package/dist/esm/providers/cognito/credentialsProvider/credentialsProvider.mjs.map +1 -1
- package/dist/esm/providers/cognito/credentialsProvider/utils.mjs.map +1 -1
- package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.mjs.map +1 -1
- package/dist/esm/providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs.map +1 -1
- package/dist/esm/providers/cognito/tokenProvider/CognitoUserPoolsTokenProvider.mjs.map +1 -1
- package/dist/esm/providers/cognito/tokenProvider/TokenOrchestrator.mjs.map +1 -1
- package/dist/esm/providers/cognito/tokenProvider/TokenStore.mjs.map +1 -1
- package/dist/esm/providers/cognito/tokenProvider/cacheTokens.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/apiHelpers.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/dispatchSignedInHubEvent.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/attemptCompleteOAuthFlow.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/cancelOAuthFlow.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/completeOAuthFlow.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/generateCodeVerifier.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.native.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.native.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/inflightPromise.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/validateState.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/refreshAuthTokens.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/signInHelpers.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/signInWithRedirectStore.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/signUpHelpers.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/AuthenticationHelper/AuthenticationHelper.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/BigInteger/BigInteger.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/BigInteger/index.native.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/calculate/calculateA.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/calculate/calculateS.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/calculate/calculateU.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/constants.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/getBytesFromHex.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/getHexFromBytes.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/getNowString.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/getPaddedHex.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/srp/getSignatureString.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/textEncoder/index.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/textEncoder/index.native.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/types.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/userContextData.mjs.map +1 -1
- package/dist/esm/utils/openAuthSession.mjs.map +1 -1
- package/dist/esm/utils/openAuthSession.native.mjs.map +1 -1
- package/package.json +105 -105
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlePasswordSRP.mjs","sources":["../../../../../src/client/flows/shared/handlePasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\n/**\n * Handles the Password SRP (Secure Remote Password) authentication flow.\n * This function can be used with both USER_SRP_AUTH and USER_AUTH flows.\n *\n * @param {Object} params - The parameters for the Password SRP authentication\n * @param {string} params.username - The username for authentication\n * @param {string} params.password - The user's password\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Token orchestrator for managing auth tokens\n * @param {AuthFlowType} params.authFlow - The type of authentication flow ('USER_SRP_AUTH' or 'USER_AUTH')\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred challenge type when using USER_AUTH flow\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The authentication response\n */\nexport async function handlePasswordSRP({ username, password, clientMetadata, config, tokenOrchestrator, authFlow, preferredChallenge, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId?.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const authParameters = {\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n if (authFlow === 'USER_AUTH' && preferredChallenge) {\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReq = {\n AuthFlow: authFlow,\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n const initiateAuth = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const resp = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),\n }, jsonReq);\n const { ChallengeParameters: challengeParameters, Session: session } = resp;\n const activeUsername = challengeParameters?.USERNAME ?? username;\n setActiveSignInUsername(activeUsername);\n if (resp.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(handlePasswordVerifierChallenge, [\n password,\n challengeParameters,\n clientMetadata,\n session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return resp;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACxD,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,YAAY,CAAC;AAC5E,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClD,KAAK;AACL,IAAI,IAAI,QAAQ,KAAK,WAAW,IAAI,kBAAkB,EAAE;AACxD,QAAQ,cAAc,CAAC,mBAAmB,GAAG,kBAAkB;AAC/D;
|
|
1
|
+
{"version":3,"file":"handlePasswordSRP.mjs","sources":["../../../../../src/client/flows/shared/handlePasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\n/**\n * Handles the Password SRP (Secure Remote Password) authentication flow.\n * This function can be used with both USER_SRP_AUTH and USER_AUTH flows.\n *\n * @param {Object} params - The parameters for the Password SRP authentication\n * @param {string} params.username - The username for authentication\n * @param {string} params.password - The user's password\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Token orchestrator for managing auth tokens\n * @param {AuthFlowType} params.authFlow - The type of authentication flow ('USER_SRP_AUTH' or 'USER_AUTH')\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred challenge type when using USER_AUTH flow\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The authentication response\n */\nexport async function handlePasswordSRP({ username, password, clientMetadata, config, tokenOrchestrator, authFlow, preferredChallenge, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId?.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const authParameters = {\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n if (authFlow === 'USER_AUTH' && preferredChallenge) {\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReq = {\n AuthFlow: authFlow,\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n const initiateAuth = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const resp = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),\n }, jsonReq);\n const { ChallengeParameters: challengeParameters, Session: session } = resp;\n const activeUsername = challengeParameters?.USERNAME ?? username;\n setActiveSignInUsername(activeUsername);\n if (resp.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(handlePasswordVerifierChallenge, [\n password,\n challengeParameters,\n clientMetadata,\n session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return resp;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACxD,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,YAAY,CAAC;AAC5E,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClD,KAAK;AACL,IAAI,IAAI,QAAQ,KAAK,WAAW,IAAI,kBAAkB,EAAE;AACxD,QAAQ,cAAc,CAAC,mBAAmB,GAAG,kBAAkB;AAC/D,IAAI;AACJ,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,eAAe;AACvB,KAAK;AACL,IAAI,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAClD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC;AACpC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,MAAM,CAAC;AAChE,KAAK,EAAE,OAAO,CAAC;AACf,IAAI,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI;AAC/E,IAAI,MAAM,cAAc,GAAG,mBAAmB,EAAE,QAAQ,IAAI,QAAQ;AACpE,IAAI,uBAAuB,CAAC,cAAc,CAAC;AAC3C,IAAI,IAAI,IAAI,CAAC,aAAa,KAAK,mBAAmB,EAAE;AACpD,QAAQ,OAAO,gCAAgC,CAAC,+BAA+B,EAAE;AACjF,YAAY,QAAQ;AACpB,YAAY,mBAAmB;AAC/B,YAAY,cAAc;AAC1B,YAAY,OAAO;AACnB,YAAY,oBAAoB;AAChC,YAAY,MAAM;AAClB,YAAY,iBAAiB;AAC7B,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC;AAC7C,IAAI;AACJ,IAAI,OAAO,IAAI;AACf;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleSelectChallengeWithPasswordSRP.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';\n/**\n * Handles the SELECT_CHALLENGE response specifically for Password SRP authentication.\n * This function combines the SELECT_CHALLENGE flow with Password SRP protocol.\n *\n * @param {string} username - The username for authentication\n * @param {string} password - The user's password\n * @param {ClientMetadata} [clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} config - Cognito User Pool configuration\n * @param {string} session - The current authentication session token\n * @param {AuthTokenOrchestrator} tokenOrchestrator - Token orchestrator for managing auth tokens\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nexport async function handleSelectChallengeWithPasswordSRP(username, password, clientMetadata, config, session, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const authParameters = {\n ANSWER: 'PASSWORD_SRP',\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n const userContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: authParameters,\n ClientId: userPoolClientId,\n ClientMetadata: clientMetadata,\n Session: session,\n UserContextData: userContextData,\n });\n const activeUsername = response.ChallengeParameters?.USERNAME ?? username;\n setActiveSignInUsername(activeUsername);\n if (response.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(handlePasswordVerifierChallenge, [\n password,\n response.ChallengeParameters,\n clientMetadata,\n response.Session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACnI,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACvD,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,YAAY,CAAC;AAC5E,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,MAAM,EAAE,cAAc;AAC9B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClD,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC;AAClD,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC;AACvE,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE,cAAc;AAC1C,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,eAAe,EAAE,eAAe;AACxC,KAAK,CAAC;AACN,IAAI,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,IAAI,QAAQ;AAC7E,IAAI,uBAAuB,CAAC,cAAc,CAAC;AAC3C,IAAI,IAAI,QAAQ,CAAC,aAAa,KAAK,mBAAmB,EAAE;AACxD,QAAQ,OAAO,gCAAgC,CAAC,+BAA+B,EAAE;AACjF,YAAY,QAAQ;AACpB,YAAY,QAAQ,CAAC,mBAAmB;AACxC,YAAY,cAAc;AAC1B,YAAY,QAAQ,CAAC,OAAO;AAC5B,YAAY,oBAAoB;AAChC,YAAY,MAAM;AAClB,YAAY,iBAAiB;AAC7B,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC;AAC7C;
|
|
1
|
+
{"version":3,"file":"handleSelectChallengeWithPasswordSRP.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';\n/**\n * Handles the SELECT_CHALLENGE response specifically for Password SRP authentication.\n * This function combines the SELECT_CHALLENGE flow with Password SRP protocol.\n *\n * @param {string} username - The username for authentication\n * @param {string} password - The user's password\n * @param {ClientMetadata} [clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} config - Cognito User Pool configuration\n * @param {string} session - The current authentication session token\n * @param {AuthTokenOrchestrator} tokenOrchestrator - Token orchestrator for managing auth tokens\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nexport async function handleSelectChallengeWithPasswordSRP(username, password, clientMetadata, config, session, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const authParameters = {\n ANSWER: 'PASSWORD_SRP',\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n const userContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: authParameters,\n ClientId: userPoolClientId,\n ClientMetadata: clientMetadata,\n Session: session,\n UserContextData: userContextData,\n });\n const activeUsername = response.ChallengeParameters?.USERNAME ?? username;\n setActiveSignInUsername(activeUsername);\n if (response.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(handlePasswordVerifierChallenge, [\n password,\n response.ChallengeParameters,\n clientMetadata,\n response.Session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACnI,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACvD,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,YAAY,CAAC;AAC5E,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,MAAM,EAAE,cAAc;AAC9B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClD,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC;AAClD,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC;AACvE,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE,cAAc;AAC1C,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,eAAe,EAAE,eAAe;AACxC,KAAK,CAAC;AACN,IAAI,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,IAAI,QAAQ;AAC7E,IAAI,uBAAuB,CAAC,cAAc,CAAC;AAC3C,IAAI,IAAI,QAAQ,CAAC,aAAa,KAAK,mBAAmB,EAAE;AACxD,QAAQ,OAAO,gCAAgC,CAAC,+BAA+B,EAAE;AACjF,YAAY,QAAQ;AACpB,YAAY,QAAQ,CAAC,mBAAmB;AACxC,YAAY,cAAc;AAC1B,YAAY,QAAQ,CAAC,OAAO;AAC5B,YAAY,oBAAoB;AAChC,YAAY,MAAM;AAClB,YAAY,iBAAiB;AAC7B,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC;AAC7C,IAAI;AACJ,IAAI,OAAO,QAAQ;AACnB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleUserAuthFlow.mjs","sources":["../../../../../src/client/flows/userAuth/handleUserAuthFlow.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordSRP } from '../shared/handlePasswordSRP';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\n/**\n * Handles user authentication flow with configurable challenge preferences.\n * Supports AuthFactorType challenges through the USER_AUTH flow.\n *\n * @param {HandleUserAuthFlowInput} params - Authentication flow parameters\n * @param {string} params.username - The username for authentication\n * @param {Record<string, string>} [params.clientMetadata] - Optional metadata to pass to authentication service\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Manages authentication tokens and device tracking\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred authentication method\n * @param {string} [params.password] - Required when preferredChallenge is 'PASSWORD' or 'PASSWORD_SRP'\n *\n * @returns {Promise<InitiateAuthCommandOutput>} The authentication response from Cognito\n */\nexport async function handleUserAuthFlow({ username, clientMetadata, config, tokenOrchestrator, preferredChallenge, password, session, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const authParameters = { USERNAME: username };\n if (preferredChallenge) {\n if (preferredChallenge === 'PASSWORD_SRP') {\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n return handlePasswordSRP({\n username,\n password,\n clientMetadata,\n config,\n tokenOrchestrator,\n authFlow: 'USER_AUTH',\n preferredChallenge,\n });\n }\n if (preferredChallenge === 'PASSWORD') {\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n authParameters.PASSWORD = password;\n }\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const jsonReq = {\n AuthFlow: 'USER_AUTH',\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n if (session) {\n jsonReq.Session = session;\n }\n const initiateAuth = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),\n }, jsonReq);\n // Set the active username immediately after successful authentication attempt\n // If a user starts a new sign-in while another sign-in is incomplete,\n // this ensures we're tracking the correct user for subsequent auth challenges.\n setActiveSignInUsername(username);\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjD,IAAI,IAAI,kBAAkB,EAAE;AAC5B,QAAQ,IAAI,kBAAkB,KAAK,cAAc,EAAE;AACnD,YAAY,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAC1F,YAAY,OAAO,iBAAiB,CAAC;AACrC,gBAAgB,QAAQ;AACxB,gBAAgB,QAAQ;AACxB,gBAAgB,cAAc;AAC9B,gBAAgB,MAAM;AACtB,gBAAgB,iBAAiB;AACjC,gBAAgB,QAAQ,EAAE,WAAW;AACrC,gBAAgB,kBAAkB;AAClC,aAAa,CAAC;AACd;
|
|
1
|
+
{"version":3,"file":"handleUserAuthFlow.mjs","sources":["../../../../../src/client/flows/userAuth/handleUserAuthFlow.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordSRP } from '../shared/handlePasswordSRP';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\n/**\n * Handles user authentication flow with configurable challenge preferences.\n * Supports AuthFactorType challenges through the USER_AUTH flow.\n *\n * @param {HandleUserAuthFlowInput} params - Authentication flow parameters\n * @param {string} params.username - The username for authentication\n * @param {Record<string, string>} [params.clientMetadata] - Optional metadata to pass to authentication service\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Manages authentication tokens and device tracking\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred authentication method\n * @param {string} [params.password] - Required when preferredChallenge is 'PASSWORD' or 'PASSWORD_SRP'\n *\n * @returns {Promise<InitiateAuthCommandOutput>} The authentication response from Cognito\n */\nexport async function handleUserAuthFlow({ username, clientMetadata, config, tokenOrchestrator, preferredChallenge, password, session, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const authParameters = { USERNAME: username };\n if (preferredChallenge) {\n if (preferredChallenge === 'PASSWORD_SRP') {\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n return handlePasswordSRP({\n username,\n password,\n clientMetadata,\n config,\n tokenOrchestrator,\n authFlow: 'USER_AUTH',\n preferredChallenge,\n });\n }\n if (preferredChallenge === 'PASSWORD') {\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n authParameters.PASSWORD = password;\n }\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const jsonReq = {\n AuthFlow: 'USER_AUTH',\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n if (session) {\n jsonReq.Session = session;\n }\n const initiateAuth = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),\n }, jsonReq);\n // Set the active username immediately after successful authentication attempt\n // If a user starts a new sign-in while another sign-in is incomplete,\n // this ensures we're tracking the correct user for subsequent auth challenges.\n setActiveSignInUsername(username);\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjD,IAAI,IAAI,kBAAkB,EAAE;AAC5B,QAAQ,IAAI,kBAAkB,KAAK,cAAc,EAAE;AACnD,YAAY,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAC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"file":"handleWebAuthnSignInResult.mjs","sources":["../../../../../src/client/flows/userAuth/handleWebAuthnSignInResult.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthErrorCodes } from '../../../common/AuthErrorStrings';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { cacheCognitoTokens } from '../../../providers/cognito/tokenProvider/cacheTokens';\nimport { dispatchSignedInHubEvent } from '../../../providers/cognito/utils/dispatchSignedInHubEvent';\nimport { setActiveSignInState, signInStore } from '../../../client/utils/store';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getPasskey } from '../../utils/passkey';\nimport { PasskeyErrorCode, assertPasskeyError, } from '../../utils/passkey/errors';\nimport { AuthError } from '../../../errors/AuthError';\nimport { getNewDeviceMetadata } from '../../../providers/cognito/utils/getNewDeviceMetadata';\nexport async function handleWebAuthnSignInResult(challengeParameters) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { username, signInSession, signInDetails, challengeName } = signInStore.getState();\n if (challengeName !== 'WEB_AUTHN' || !username) {\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: 'Unable to proceed due to invalid sign in state.',\n });\n }\n const { CREDENTIAL_REQUEST_OPTIONS: credentialRequestOptions } = challengeParameters;\n assertPasskeyError(!!credentialRequestOptions, PasskeyErrorCode.InvalidPasskeyAuthenticationOptions);\n const cred = await getPasskey(JSON.parse(credentialRequestOptions));\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: authConfig.userPoolEndpoint,\n }),\n });\n const { ChallengeName: nextChallengeName, ChallengeParameters: nextChallengeParameters, AuthenticationResult: authenticationResult, Session: nextSession, } = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(authConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'WEB_AUTHN',\n ChallengeResponses: {\n USERNAME: username,\n CREDENTIAL: JSON.stringify(cred),\n },\n ClientId: authConfig.userPoolClientId,\n Session: signInSession,\n });\n setActiveSignInState({\n signInSession: nextSession,\n username,\n challengeName: nextChallengeName,\n signInDetails,\n });\n if (authenticationResult) {\n await cacheCognitoTokens({\n ...authenticationResult,\n username,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: authenticationResult.NewDeviceMetadata,\n accessToken: authenticationResult.AccessToken,\n }),\n signInDetails,\n });\n signInStore.dispatch({ type: 'RESET_STATE' });\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n if (nextChallengeName === 'WEB_AUTHN') {\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: 'Sequential WEB_AUTHN challenges returned from underlying service cannot be handled.',\n });\n }\n return {\n challengeName: nextChallengeName,\n challengeParameters: nextChallengeParameters,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAeO,eAAe,0BAA0B,CAAC,mBAAmB,EAAE;AACtE,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE;AAC5F,IAAI,IAAI,aAAa,KAAK,WAAW,IAAI,CAAC,QAAQ,EAAE;AACpD,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,cAAc,CAAC,eAAe;AAChD,YAAY,OAAO,EAAE,iDAAiD;AACtE,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"handleWebAuthnSignInResult.mjs","sources":["../../../../../src/client/flows/userAuth/handleWebAuthnSignInResult.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthErrorCodes } from '../../../common/AuthErrorStrings';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { cacheCognitoTokens } from '../../../providers/cognito/tokenProvider/cacheTokens';\nimport { dispatchSignedInHubEvent } from '../../../providers/cognito/utils/dispatchSignedInHubEvent';\nimport { setActiveSignInState, signInStore } from '../../../client/utils/store';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getPasskey } from '../../utils/passkey';\nimport { PasskeyErrorCode, assertPasskeyError, } from '../../utils/passkey/errors';\nimport { AuthError } from '../../../errors/AuthError';\nimport { getNewDeviceMetadata } from '../../../providers/cognito/utils/getNewDeviceMetadata';\nexport async function handleWebAuthnSignInResult(challengeParameters) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { username, signInSession, signInDetails, challengeName } = signInStore.getState();\n if (challengeName !== 'WEB_AUTHN' || !username) {\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: 'Unable to proceed due to invalid sign in state.',\n });\n }\n const { CREDENTIAL_REQUEST_OPTIONS: credentialRequestOptions } = challengeParameters;\n assertPasskeyError(!!credentialRequestOptions, PasskeyErrorCode.InvalidPasskeyAuthenticationOptions);\n const cred = await getPasskey(JSON.parse(credentialRequestOptions));\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: authConfig.userPoolEndpoint,\n }),\n });\n const { ChallengeName: nextChallengeName, ChallengeParameters: nextChallengeParameters, AuthenticationResult: authenticationResult, Session: nextSession, } = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(authConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'WEB_AUTHN',\n ChallengeResponses: {\n USERNAME: username,\n CREDENTIAL: JSON.stringify(cred),\n },\n ClientId: authConfig.userPoolClientId,\n Session: signInSession,\n });\n setActiveSignInState({\n signInSession: nextSession,\n username,\n challengeName: nextChallengeName,\n signInDetails,\n });\n if (authenticationResult) {\n await cacheCognitoTokens({\n ...authenticationResult,\n username,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: authenticationResult.NewDeviceMetadata,\n accessToken: authenticationResult.AccessToken,\n }),\n signInDetails,\n });\n signInStore.dispatch({ type: 'RESET_STATE' });\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n if (nextChallengeName === 'WEB_AUTHN') {\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: 'Sequential WEB_AUTHN challenges returned from underlying service cannot be handled.',\n });\n }\n return {\n challengeName: nextChallengeName,\n challengeParameters: nextChallengeParameters,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAeO,eAAe,0BAA0B,CAAC,mBAAmB,EAAE;AACtE,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,QAAQ,EAA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or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, AmplifyErrorCode, createAssertionFunction, } from '@aws-amplify/core/internals/utils';\nexport class PasskeyError extends AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = PasskeyError;\n Object.setPrototypeOf(this, PasskeyError.prototype);\n }\n}\nexport var PasskeyErrorCode;\n(function (PasskeyErrorCode) {\n // not supported\n PasskeyErrorCode[\"PasskeyNotSupported\"] = \"PasskeyNotSupported\";\n // duplicate passkey\n PasskeyErrorCode[\"PasskeyAlreadyExists\"] = \"PasskeyAlreadyExists\";\n // misconfigurations\n PasskeyErrorCode[\"InvalidPasskeyRegistrationOptions\"] = \"InvalidPasskeyRegistrationOptions\";\n PasskeyErrorCode[\"InvalidPasskeyAuthenticationOptions\"] = \"InvalidPasskeyAuthenticationOptions\";\n PasskeyErrorCode[\"RelyingPartyMismatch\"] = \"RelyingPartyMismatch\";\n // failed credential creation / retrieval\n PasskeyErrorCode[\"PasskeyRegistrationFailed\"] = \"PasskeyRegistrationFailed\";\n PasskeyErrorCode[\"PasskeyRetrievalFailed\"] = \"PasskeyRetrievalFailed\";\n // cancel / aborts\n PasskeyErrorCode[\"PasskeyRegistrationCanceled\"] = \"PasskeyRegistrationCanceled\";\n PasskeyErrorCode[\"PasskeyAuthenticationCanceled\"] = \"PasskeyAuthenticationCanceled\";\n PasskeyErrorCode[\"PasskeyOperationAborted\"] = \"PasskeyOperationAborted\";\n})(PasskeyErrorCode || (PasskeyErrorCode = {}));\nconst notSupportedRecoverySuggestion = 'Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.';\nconst abortOrCancelRecoverySuggestion = 'User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.';\nconst misconfigurationRecoverySuggestion = 'Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.';\nconst passkeyErrorMap = {\n [PasskeyErrorCode.PasskeyNotSupported]: {\n message: 'Passkeys may not be supported on this device.',\n recoverySuggestion: notSupportedRecoverySuggestion,\n },\n [PasskeyErrorCode.InvalidPasskeyRegistrationOptions]: {\n message: 'Invalid passkey registration options.',\n recoverySuggestion: misconfigurationRecoverySuggestion,\n },\n [PasskeyErrorCode.InvalidPasskeyAuthenticationOptions]: {\n message: 'Invalid passkey authentication options.',\n recoverySuggestion: misconfigurationRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyRegistrationFailed]: {\n message: 'Device failed to create passkey.',\n recoverySuggestion: notSupportedRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyRetrievalFailed]: {\n message: 'Device failed to retrieve passkey.',\n recoverySuggestion: 'Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP.',\n },\n [PasskeyErrorCode.PasskeyAlreadyExists]: {\n message: 'Passkey already exists in authenticator.',\n recoverySuggestion: 'Proceed with existing passkey or try again after deleting the credential.',\n },\n [PasskeyErrorCode.PasskeyRegistrationCanceled]: {\n message: 'Passkey registration ceremony has been canceled.',\n recoverySuggestion: abortOrCancelRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyAuthenticationCanceled]: {\n message: 'Passkey authentication ceremony has been canceled.',\n recoverySuggestion: abortOrCancelRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyOperationAborted]: {\n message: 'Passkey operation has been aborted.',\n recoverySuggestion: abortOrCancelRecoverySuggestion,\n },\n [PasskeyErrorCode.RelyingPartyMismatch]: {\n message: 'Relying party does not match current domain.',\n recoverySuggestion: 'Ensure relying party identifier matches current domain.',\n },\n};\nexport const assertPasskeyError = createAssertionFunction(passkeyErrorMap, PasskeyError);\n/**\n * Handle Passkey Authentication Errors\n * https://w3c.github.io/webauthn/#sctn-get-request-exceptions\n *\n * @param err unknown\n * @returns PasskeyError\n */\nexport const handlePasskeyAuthenticationError = (err) => {\n if (err instanceof PasskeyError) {\n return err;\n }\n if (err instanceof Error) {\n if (err.name === 'NotAllowedError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyAuthenticationCanceled];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyAuthenticationCanceled,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n }\n return handlePasskeyError(err);\n};\n/**\n * Handle Passkey Registration Errors\n * https://w3c.github.io/webauthn/#sctn-create-request-exceptions\n *\n * @param err unknown\n * @returns PasskeyError\n */\nexport const handlePasskeyRegistrationError = (err) => {\n if (err instanceof PasskeyError) {\n return err;\n }\n if (err instanceof Error) {\n // Duplicate Passkey\n if (err.name === 'InvalidStateError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyAlreadyExists];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyAlreadyExists,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n // User Cancels Ceremony / Generic Catch All\n if (err.name === 'NotAllowedError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyRegistrationCanceled];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyRegistrationCanceled,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n }\n return handlePasskeyError(err);\n};\n/**\n * Handles Overlapping Passkey Errors Between Registration & Authentication\n * https://w3c.github.io/webauthn/#sctn-create-request-exceptions\n * https://w3c.github.io/webauthn/#sctn-get-request-exceptions\n *\n * @param err unknown\n * @returns PasskeyError\n */\nconst handlePasskeyError = (err) => {\n if (err instanceof Error) {\n // Passkey Operation Aborted\n if (err.name === 'AbortError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyOperationAborted];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyOperationAborted,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n // Relying Party / Domain Mismatch\n if (err.name === 'SecurityError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.RelyingPartyMismatch];\n return new PasskeyError({\n name: PasskeyErrorCode.RelyingPartyMismatch,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n }\n return new PasskeyError({\n name: AmplifyErrorCode.Unknown,\n message: 'An unknown error has occurred.',\n underlyingError: err,\n });\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,YAAY,SAAS,YAAY,CAAC;AAC/C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC;AACrB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,YAAY;AACvC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;AAC3D;AACA;AACU,IAAC;AACX,CAAC,UAAU,gBAAgB,EAAE;AAC7B;AACA,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,qBAAqB;AACnE;AACA,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB;AACrE;AACA,IAAI,gBAAgB,CAAC,mCAAmC,CAAC,GAAG,mCAAmC;AAC/F,IAAI,gBAAgB,CAAC,qCAAqC,CAAC,GAAG,qCAAqC;AACnG,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB;AACrE;AACA,IAAI,gBAAgB,CAAC,2BAA2B,CAAC,GAAG,2BAA2B;AAC/E,IAAI,gBAAgB,CAAC,wBAAwB,CAAC,GAAG,wBAAwB;AACzE;AACA,IAAI,gBAAgB,CAAC,6BAA6B,CAAC,GAAG,6BAA6B;AACnF,IAAI,gBAAgB,CAAC,+BAA+B,CAAC,GAAG,+BAA+B;AACvF,IAAI,gBAAgB,CAAC,yBAAyB,CAAC,GAAG,yBAAyB;AAC3E,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE,CAAC,CAAC;AAC/C,MAAM,8BAA8B,GAAG,uJAAuJ;AAC9L,MAAM,+BAA+B,GAAG,+GAA+G;AACvJ,MAA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kB;AAClC,gBAAgB,eAAe,EAAE,GAAG;AACpC,aAAa,CAAC;AACd;AACA;AACA,IAAI,OAAO,IAAI,YAAY,CAAC;AAC5B,QAAQ,IAAI,EAAE,gBAAgB,CAAC,OAAO;AACtC,QAAQ,OAAO,EAAE,gCAAgC;AACjD,QAAQ,eAAe,EAAE,GAAG;AAC5B,KAAK,CAAC;AACN,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"errors.mjs","sources":["../../../../../src/client/utils/passkey/errors.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, AmplifyErrorCode, createAssertionFunction, } from '@aws-amplify/core/internals/utils';\nexport class PasskeyError extends AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = PasskeyError;\n Object.setPrototypeOf(this, PasskeyError.prototype);\n }\n}\nexport var PasskeyErrorCode;\n(function (PasskeyErrorCode) {\n // not supported\n PasskeyErrorCode[\"PasskeyNotSupported\"] = \"PasskeyNotSupported\";\n // duplicate passkey\n PasskeyErrorCode[\"PasskeyAlreadyExists\"] = \"PasskeyAlreadyExists\";\n // misconfigurations\n PasskeyErrorCode[\"InvalidPasskeyRegistrationOptions\"] = \"InvalidPasskeyRegistrationOptions\";\n PasskeyErrorCode[\"InvalidPasskeyAuthenticationOptions\"] = \"InvalidPasskeyAuthenticationOptions\";\n PasskeyErrorCode[\"RelyingPartyMismatch\"] = \"RelyingPartyMismatch\";\n // failed credential creation / retrieval\n PasskeyErrorCode[\"PasskeyRegistrationFailed\"] = \"PasskeyRegistrationFailed\";\n PasskeyErrorCode[\"PasskeyRetrievalFailed\"] = \"PasskeyRetrievalFailed\";\n // cancel / aborts\n PasskeyErrorCode[\"PasskeyRegistrationCanceled\"] = \"PasskeyRegistrationCanceled\";\n PasskeyErrorCode[\"PasskeyAuthenticationCanceled\"] = \"PasskeyAuthenticationCanceled\";\n PasskeyErrorCode[\"PasskeyOperationAborted\"] = \"PasskeyOperationAborted\";\n})(PasskeyErrorCode || (PasskeyErrorCode = {}));\nconst notSupportedRecoverySuggestion = 'Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.';\nconst abortOrCancelRecoverySuggestion = 'User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.';\nconst misconfigurationRecoverySuggestion = 'Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.';\nconst passkeyErrorMap = {\n [PasskeyErrorCode.PasskeyNotSupported]: {\n message: 'Passkeys may not be supported on this device.',\n recoverySuggestion: notSupportedRecoverySuggestion,\n },\n [PasskeyErrorCode.InvalidPasskeyRegistrationOptions]: {\n message: 'Invalid passkey registration options.',\n recoverySuggestion: misconfigurationRecoverySuggestion,\n },\n [PasskeyErrorCode.InvalidPasskeyAuthenticationOptions]: {\n message: 'Invalid passkey authentication options.',\n recoverySuggestion: misconfigurationRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyRegistrationFailed]: {\n message: 'Device failed to create passkey.',\n recoverySuggestion: notSupportedRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyRetrievalFailed]: {\n message: 'Device failed to retrieve passkey.',\n recoverySuggestion: 'Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP.',\n },\n [PasskeyErrorCode.PasskeyAlreadyExists]: {\n message: 'Passkey already exists in authenticator.',\n recoverySuggestion: 'Proceed with existing passkey or try again after deleting the credential.',\n },\n [PasskeyErrorCode.PasskeyRegistrationCanceled]: {\n message: 'Passkey registration ceremony has been canceled.',\n recoverySuggestion: abortOrCancelRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyAuthenticationCanceled]: {\n message: 'Passkey authentication ceremony has been canceled.',\n recoverySuggestion: abortOrCancelRecoverySuggestion,\n },\n [PasskeyErrorCode.PasskeyOperationAborted]: {\n message: 'Passkey operation has been aborted.',\n recoverySuggestion: abortOrCancelRecoverySuggestion,\n },\n [PasskeyErrorCode.RelyingPartyMismatch]: {\n message: 'Relying party does not match current domain.',\n recoverySuggestion: 'Ensure relying party identifier matches current domain.',\n },\n};\nexport const assertPasskeyError = createAssertionFunction(passkeyErrorMap, PasskeyError);\n/**\n * Handle Passkey Authentication Errors\n * https://w3c.github.io/webauthn/#sctn-get-request-exceptions\n *\n * @param err unknown\n * @returns PasskeyError\n */\nexport const handlePasskeyAuthenticationError = (err) => {\n if (err instanceof PasskeyError) {\n return err;\n }\n if (err instanceof Error) {\n if (err.name === 'NotAllowedError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyAuthenticationCanceled];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyAuthenticationCanceled,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n }\n return handlePasskeyError(err);\n};\n/**\n * Handle Passkey Registration Errors\n * https://w3c.github.io/webauthn/#sctn-create-request-exceptions\n *\n * @param err unknown\n * @returns PasskeyError\n */\nexport const handlePasskeyRegistrationError = (err) => {\n if (err instanceof PasskeyError) {\n return err;\n }\n if (err instanceof Error) {\n // Duplicate Passkey\n if (err.name === 'InvalidStateError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyAlreadyExists];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyAlreadyExists,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n // User Cancels Ceremony / Generic Catch All\n if (err.name === 'NotAllowedError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyRegistrationCanceled];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyRegistrationCanceled,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n }\n return handlePasskeyError(err);\n};\n/**\n * Handles Overlapping Passkey Errors Between Registration & Authentication\n * https://w3c.github.io/webauthn/#sctn-create-request-exceptions\n * https://w3c.github.io/webauthn/#sctn-get-request-exceptions\n *\n * @param err unknown\n * @returns PasskeyError\n */\nconst handlePasskeyError = (err) => {\n if (err instanceof Error) {\n // Passkey Operation Aborted\n if (err.name === 'AbortError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.PasskeyOperationAborted];\n return new PasskeyError({\n name: PasskeyErrorCode.PasskeyOperationAborted,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n // Relying Party / Domain Mismatch\n if (err.name === 'SecurityError') {\n const { message, recoverySuggestion } = passkeyErrorMap[PasskeyErrorCode.RelyingPartyMismatch];\n return new PasskeyError({\n name: PasskeyErrorCode.RelyingPartyMismatch,\n message,\n recoverySuggestion,\n underlyingError: err,\n });\n }\n }\n return new PasskeyError({\n name: AmplifyErrorCode.Unknown,\n message: 'An unknown error has occurred.',\n underlyingError: err,\n });\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,YAAY,SAAS,YAAY,CAAC;AAC/C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC;AACrB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,YAAY;AACvC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;AAC3D,IAAI;AACJ;AACU,IAAC;AACX,CAAC,UAAU,gBAAgB,EAAE;AAC7B;AACA,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,qBAAqB;AACnE;AACA,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB;AACrE;AACA,IAAI,gBAAgB,CAAC,mCAAmC,CAAC,GAAG,mCAAmC;AAC/F,IAAI,gBAAgB,CAAC,qCAAqC,CAAC,GAAG,qCAAqC;AACnG,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,GAAG,sBAAsB;AACrE;AACA,IAAI,gBAAgB,CAAC,2BAA2B,CAAC,GAAG,2BAA2B;AAC/E,IAAI,gBAAgB,CAAC,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,CAAC,uBAAuB;AAC9D,gBAAgB,OAAO;AACvB,gBAAgB,kBAAkB;AAClC,gBAAgB,eAAe,EAAE,GAAG;AACpC,aAAa,CAAC;AACd,QAAQ;AACR;AACA,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE;AAC1C,YAAY,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,eAAe,CAAC,gBAAgB,CAAC,oBAAoB,CAAC;AAC1G,YAAY,OAAO,IAAI,YAAY,CAAC;AACpC,gBAAgB,IAAI,EAAE,gBAAgB,CAAC,oBAAoB;AAC3D,gBAAgB,OAAO;AACvB,gBAAgB,kBAAkB;AAClC,gBAAgB,eAAe,EAAE,GAAG;AACpC,aAAa,CAAC;AACd,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,IAAI,YAAY,CAAC;AAC5B,QAAQ,IAAI,EAAE,gBAAgB,CAAC,OAAO;AACtC,QAAQ,OAAO,EAAE,gCAAgC;AACjD,QAAQ,eAAe,EAAE,GAAG;AAC5B,KAAK,CAAC;AACN,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPasskey.mjs","sources":["../../../../../src/client/utils/passkey/getPasskey.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PasskeyErrorCode, assertPasskeyError, handlePasskeyAuthenticationError, } from './errors';\nimport { getIsPasskeySupported } from './getIsPasskeySupported';\nimport { deserializeJsonToPkcGetOptions, serializePkcWithAssertionToJson, } from './serde';\nimport { assertCredentialIsPkcWithAuthenticatorAssertionResponse, } from './types';\nexport const getPasskey = async (input) => {\n try {\n const isPasskeySupported = getIsPasskeySupported();\n assertPasskeyError(isPasskeySupported, PasskeyErrorCode.PasskeyNotSupported);\n const passkeyGetOptions = deserializeJsonToPkcGetOptions(input);\n const credential = await navigator.credentials.get({\n publicKey: passkeyGetOptions,\n });\n assertCredentialIsPkcWithAuthenticatorAssertionResponse(credential);\n return serializePkcWithAssertionToJson(credential);\n }\n catch (err) {\n throw handlePasskeyAuthenticationError(err);\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKY,MAAC,UAAU,GAAG,OAAO,KAAK,KAAK;AAC3C,IAAI,IAAI;AACR,QAAQ,MAAM,kBAAkB,GAAG,qBAAqB,EAAE;AAC1D,QAAQ,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;AACpF,QAAQ,MAAM,iBAAiB,GAAG,8BAA8B,CAAC,KAAK,CAAC;AACvE,QAAQ,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC;AAC3D,YAAY,SAAS,EAAE,iBAAiB;AACxC,SAAS,CAAC;AACV,QAAQ,uDAAuD,CAAC,UAAU,CAAC;AAC3E,QAAQ,OAAO,+BAA+B,CAAC,UAAU,CAAC;AAC1D;
|
|
1
|
+
{"version":3,"file":"getPasskey.mjs","sources":["../../../../../src/client/utils/passkey/getPasskey.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PasskeyErrorCode, assertPasskeyError, handlePasskeyAuthenticationError, } from './errors';\nimport { getIsPasskeySupported } from './getIsPasskeySupported';\nimport { deserializeJsonToPkcGetOptions, serializePkcWithAssertionToJson, } from './serde';\nimport { assertCredentialIsPkcWithAuthenticatorAssertionResponse, } from './types';\nexport const getPasskey = async (input) => {\n try {\n const isPasskeySupported = getIsPasskeySupported();\n assertPasskeyError(isPasskeySupported, PasskeyErrorCode.PasskeyNotSupported);\n const passkeyGetOptions = deserializeJsonToPkcGetOptions(input);\n const credential = await navigator.credentials.get({\n publicKey: passkeyGetOptions,\n });\n assertCredentialIsPkcWithAuthenticatorAssertionResponse(credential);\n return serializePkcWithAssertionToJson(credential);\n }\n catch (err) {\n throw handlePasskeyAuthenticationError(err);\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKY,MAAC,UAAU,GAAG,OAAO,KAAK,KAAK;AAC3C,IAAI,IAAI;AACR,QAAQ,MAAM,kBAAkB,GAAG,qBAAqB,EAAE;AAC1D,QAAQ,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;AACpF,QAAQ,MAAM,iBAAiB,GAAG,8BAA8B,CAAC,KAAK,CAAC;AACvE,QAAQ,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC;AAC3D,YAAY,SAAS,EAAE,iBAAiB;AACxC,SAAS,CAAC;AACV,QAAQ,uDAAuD,CAAC,UAAU,CAAC;AAC3E,QAAQ,OAAO,+BAA+B,CAAC,UAAU,CAAC;AAC1D,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,gCAAgC,CAAC,GAAG,CAAC;AACnD,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerPasskey.mjs","sources":["../../../../../src/client/utils/passkey/registerPasskey.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertCredentialIsPkcWithAuthenticatorAttestationResponse, } from './types';\nimport { deserializeJsonToPkcCreationOptions, serializePkcWithAttestationToJson, } from './serde';\nimport { PasskeyErrorCode, assertPasskeyError, handlePasskeyRegistrationError, } from './errors';\nimport { getIsPasskeySupported } from './getIsPasskeySupported';\n/**\n * Registers a new passkey for user\n * @param input - PasskeyCreateOptionsJson\n * @returns serialized PasskeyCreateResult\n */\nexport const registerPasskey = async (input) => {\n try {\n const isPasskeySupported = getIsPasskeySupported();\n assertPasskeyError(isPasskeySupported, PasskeyErrorCode.PasskeyNotSupported);\n const passkeyCreationOptions = deserializeJsonToPkcCreationOptions(input);\n const credential = await navigator.credentials.create({\n publicKey: passkeyCreationOptions,\n });\n assertCredentialIsPkcWithAuthenticatorAttestationResponse(credential);\n return serializePkcWithAttestationToJson(credential);\n }\n catch (err) {\n throw handlePasskeyRegistrationError(err);\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,OAAO,KAAK,KAAK;AAChD,IAAI,IAAI;AACR,QAAQ,MAAM,kBAAkB,GAAG,qBAAqB,EAAE;AAC1D,QAAQ,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;AACpF,QAAQ,MAAM,sBAAsB,GAAG,mCAAmC,CAAC,KAAK,CAAC;AACjF,QAAQ,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;AAC9D,YAAY,SAAS,EAAE,sBAAsB;AAC7C,SAAS,CAAC;AACV,QAAQ,yDAAyD,CAAC,UAAU,CAAC;AAC7E,QAAQ,OAAO,iCAAiC,CAAC,UAAU,CAAC;AAC5D;
|
|
1
|
+
{"version":3,"file":"registerPasskey.mjs","sources":["../../../../../src/client/utils/passkey/registerPasskey.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertCredentialIsPkcWithAuthenticatorAttestationResponse, } from './types';\nimport { deserializeJsonToPkcCreationOptions, serializePkcWithAttestationToJson, } from './serde';\nimport { PasskeyErrorCode, assertPasskeyError, handlePasskeyRegistrationError, } from './errors';\nimport { getIsPasskeySupported } from './getIsPasskeySupported';\n/**\n * Registers a new passkey for user\n * @param input - PasskeyCreateOptionsJson\n * @returns serialized PasskeyCreateResult\n */\nexport const registerPasskey = async (input) => {\n try {\n const isPasskeySupported = getIsPasskeySupported();\n assertPasskeyError(isPasskeySupported, PasskeyErrorCode.PasskeyNotSupported);\n const passkeyCreationOptions = deserializeJsonToPkcCreationOptions(input);\n const credential = await navigator.credentials.create({\n publicKey: passkeyCreationOptions,\n });\n assertCredentialIsPkcWithAuthenticatorAttestationResponse(credential);\n return serializePkcWithAttestationToJson(credential);\n }\n catch (err) {\n throw handlePasskeyRegistrationError(err);\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,OAAO,KAAK,KAAK;AAChD,IAAI,IAAI;AACR,QAAQ,MAAM,kBAAkB,GAAG,qBAAqB,EAAE;AAC1D,QAAQ,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;AACpF,QAAQ,MAAM,sBAAsB,GAAG,mCAAmC,CAAC,KAAK,CAAC;AACjF,QAAQ,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;AAC9D,YAAY,SAAS,EAAE,sBAAsB;AAC7C,SAAS,CAAC;AACV,QAAQ,yDAAyD,CAAC,UAAU,CAAC;AAC7E,QAAQ,OAAO,iCAAiC,CAAC,UAAU,CAAC;AAC5D,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,8BAA8B,CAAC,GAAG,CAAC;AACjD,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serde.mjs","sources":["../../../../../src/client/utils/passkey/serde.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { convertArrayBufferToBase64Url, convertBase64UrlToArrayBuffer, } from '../../../foundation/convert';\n/**\n * Deserializes Public Key Credential Creation Options JSON\n * @param input PasskeyCreateOptionsJson\n * @returns PublicKeyCredentialCreationOptions\n */\nexport const deserializeJsonToPkcCreationOptions = (input) => {\n const userIdBuffer = convertBase64UrlToArrayBuffer(input.user.id);\n const challengeBuffer = convertBase64UrlToArrayBuffer(input.challenge);\n const excludeCredentialsWithBuffer = (input.excludeCredentials || []).map(excludeCred => ({\n ...excludeCred,\n id: convertBase64UrlToArrayBuffer(excludeCred.id),\n }));\n return {\n ...input,\n excludeCredentials: excludeCredentialsWithBuffer,\n challenge: challengeBuffer,\n user: {\n ...input.user,\n id: userIdBuffer,\n },\n };\n};\n/**\n * Serializes a Public Key Credential With Attestation to JSON\n * @param input PasskeyCreateResult\n * @returns PasskeyCreateResultJson\n */\nexport const serializePkcWithAttestationToJson = (input) => {\n const response = {\n clientDataJSON: convertArrayBufferToBase64Url(input.response.clientDataJSON),\n attestationObject: convertArrayBufferToBase64Url(input.response.attestationObject),\n transports: input.response.getTransports(),\n publicKeyAlgorithm: input.response.getPublicKeyAlgorithm(),\n authenticatorData: convertArrayBufferToBase64Url(input.response.getAuthenticatorData()),\n };\n const publicKey = input.response.getPublicKey();\n if (publicKey) {\n response.publicKey = convertArrayBufferToBase64Url(publicKey);\n }\n const resultJson = {\n type: input.type,\n id: input.id,\n rawId: convertArrayBufferToBase64Url(input.rawId),\n clientExtensionResults: input.getClientExtensionResults(),\n response,\n };\n if (input.authenticatorAttachment) {\n resultJson.authenticatorAttachment = input.authenticatorAttachment;\n }\n return resultJson;\n};\n/**\n * Deserializes Public Key Credential Get Options JSON\n * @param input PasskeyGetOptionsJson\n * @returns PublicKeyCredentialRequestOptions\n */\nexport const deserializeJsonToPkcGetOptions = (input) => {\n const challengeBuffer = convertBase64UrlToArrayBuffer(input.challenge);\n const allowedCredentialsWithBuffer = (input.allowCredentials || []).map(allowedCred => ({\n ...allowedCred,\n id: convertBase64UrlToArrayBuffer(allowedCred.id),\n }));\n return {\n ...input,\n challenge: challengeBuffer,\n allowCredentials: allowedCredentialsWithBuffer,\n };\n};\n/**\n * Serializes a Public Key Credential With Attestation to JSON\n * @param input PasskeyGetResult\n * @returns PasskeyGetResultJson\n */\nexport const serializePkcWithAssertionToJson = (input) => {\n const response = {\n clientDataJSON: convertArrayBufferToBase64Url(input.response.clientDataJSON),\n authenticatorData: convertArrayBufferToBase64Url(input.response.authenticatorData),\n signature: convertArrayBufferToBase64Url(input.response.signature),\n };\n if (input.response.userHandle) {\n response.userHandle = convertArrayBufferToBase64Url(input.response.userHandle);\n }\n const resultJson = {\n id: input.id,\n rawId: convertArrayBufferToBase64Url(input.rawId),\n type: input.type,\n clientExtensionResults: input.getClientExtensionResults(),\n response,\n };\n if (input.authenticatorAttachment) {\n resultJson.authenticatorAttachment = input.authenticatorAttachment;\n }\n return resultJson;\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,mCAAmC,GAAG,CAAC,KAAK,KAAK;AAC9D,IAAI,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;AACrE,IAAI,MAAM,eAAe,GAAG,6BAA6B,CAAC,KAAK,CAAC,SAAS,CAAC;AAC1E,IAAI,MAAM,4BAA4B,GAAG,CAAC,KAAK,CAAC,kBAAkB,IAAI,EAAE,EAAE,GAAG,CAAC,WAAW,KAAK;AAC9F,QAAQ,GAAG,WAAW;AACtB,QAAQ,EAAE,EAAE,6BAA6B,CAAC,WAAW,CAAC,EAAE,CAAC;AACzD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG,KAAK;AAChB,QAAQ,kBAAkB,EAAE,4BAA4B;AACxD,QAAQ,SAAS,EAAE,eAAe;AAClC,QAAQ,IAAI,EAAE;AACd,YAAY,GAAG,KAAK,CAAC,IAAI;AACzB,YAAY,EAAE,EAAE,YAAY;AAC5B,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,iCAAiC,GAAG,CAAC,KAAK,KAAK;AAC5D,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,cAAc,EAAE,6BAA6B,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;AACpF,QAAQ,iBAAiB,EAAE,6BAA6B,CAAC,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC;AAC1F,QAAQ,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa,EAAE;AAClD,QAAQ,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,qBAAqB,EAAE;AAClE,QAAQ,iBAAiB,EAAE,6BAA6B,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;AAC/F,KAAK;AACL,IAAI,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE;AACnD,IAAI,IAAI,SAAS,EAAE;AACnB,QAAQ,QAAQ,CAAC,SAAS,GAAG,6BAA6B,CAAC,SAAS,CAAC;AACrE;
|
|
1
|
+
{"version":3,"file":"serde.mjs","sources":["../../../../../src/client/utils/passkey/serde.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { convertArrayBufferToBase64Url, convertBase64UrlToArrayBuffer, } from '../../../foundation/convert';\n/**\n * Deserializes Public Key Credential Creation Options JSON\n * @param input PasskeyCreateOptionsJson\n * @returns PublicKeyCredentialCreationOptions\n */\nexport const deserializeJsonToPkcCreationOptions = (input) => {\n const userIdBuffer = convertBase64UrlToArrayBuffer(input.user.id);\n const challengeBuffer = convertBase64UrlToArrayBuffer(input.challenge);\n const excludeCredentialsWithBuffer = (input.excludeCredentials || []).map(excludeCred => ({\n ...excludeCred,\n id: convertBase64UrlToArrayBuffer(excludeCred.id),\n }));\n return {\n ...input,\n excludeCredentials: excludeCredentialsWithBuffer,\n challenge: challengeBuffer,\n user: {\n ...input.user,\n id: userIdBuffer,\n },\n };\n};\n/**\n * Serializes a Public Key Credential With Attestation to JSON\n * @param input PasskeyCreateResult\n * @returns PasskeyCreateResultJson\n */\nexport const serializePkcWithAttestationToJson = (input) => {\n const response = {\n clientDataJSON: convertArrayBufferToBase64Url(input.response.clientDataJSON),\n attestationObject: convertArrayBufferToBase64Url(input.response.attestationObject),\n transports: input.response.getTransports(),\n publicKeyAlgorithm: input.response.getPublicKeyAlgorithm(),\n authenticatorData: convertArrayBufferToBase64Url(input.response.getAuthenticatorData()),\n };\n const publicKey = input.response.getPublicKey();\n if (publicKey) {\n response.publicKey = convertArrayBufferToBase64Url(publicKey);\n }\n const resultJson = {\n type: input.type,\n id: input.id,\n rawId: convertArrayBufferToBase64Url(input.rawId),\n clientExtensionResults: input.getClientExtensionResults(),\n response,\n };\n if (input.authenticatorAttachment) {\n resultJson.authenticatorAttachment = input.authenticatorAttachment;\n }\n return resultJson;\n};\n/**\n * Deserializes Public Key Credential Get Options JSON\n * @param input PasskeyGetOptionsJson\n * @returns PublicKeyCredentialRequestOptions\n */\nexport const deserializeJsonToPkcGetOptions = (input) => {\n const challengeBuffer = convertBase64UrlToArrayBuffer(input.challenge);\n const allowedCredentialsWithBuffer = (input.allowCredentials || []).map(allowedCred => ({\n ...allowedCred,\n id: convertBase64UrlToArrayBuffer(allowedCred.id),\n }));\n return {\n ...input,\n challenge: challengeBuffer,\n allowCredentials: allowedCredentialsWithBuffer,\n };\n};\n/**\n * Serializes a Public Key Credential With Attestation to JSON\n * @param input PasskeyGetResult\n * @returns PasskeyGetResultJson\n */\nexport const serializePkcWithAssertionToJson = (input) => {\n const response = {\n clientDataJSON: convertArrayBufferToBase64Url(input.response.clientDataJSON),\n authenticatorData: convertArrayBufferToBase64Url(input.response.authenticatorData),\n signature: convertArrayBufferToBase64Url(input.response.signature),\n };\n if (input.response.userHandle) {\n response.userHandle = convertArrayBufferToBase64Url(input.response.userHandle);\n }\n const resultJson = {\n id: input.id,\n rawId: convertArrayBufferToBase64Url(input.rawId),\n type: input.type,\n clientExtensionResults: input.getClientExtensionResults(),\n response,\n };\n if (input.authenticatorAttachment) {\n resultJson.authenticatorAttachment = input.authenticatorAttachment;\n }\n return resultJson;\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,mCAAmC,GAAG,CAAC,KAAK,KAAK;AAC9D,IAAI,MAAM,YAAY,GAAG,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;A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,EAAE;AACnC,QAAQ,QAAQ,CAAC,UAAU,GAAG,6BAA6B,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;AACtF,IAAI;AACJ,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,EAAE,EAAE,KAAK,CAAC,EAAE;AACpB,QAAQ,KAAK,EAAE,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC;AACzD,QAAQ,IAAI,EAAE,KAAK,CAAC,IAAI;AACxB,QAAQ,sBAAsB,EAAE,KAAK,CAAC,yBAAyB,EAAE;AACjE,QAAQ,QAAQ;AAChB,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,uBAAuB,EAAE;AACvC,QAAQ,UAAU,CAAC,uBAAuB,GAAG,KAAK,CAAC,uBAAuB;AAC1E,IAAI;AACJ,IAAI,OAAO,UAAU;AACrB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoSignInStore.mjs","sources":["../../../../../src/client/utils/store/autoSignInStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nfunction defaultState() {\n return {\n active: false,\n };\n}\nconst autoSignInReducer = (state, action) => {\n switch (action.type) {\n case 'SET_USERNAME':\n return {\n ...state,\n username: action.value,\n };\n case 'SET_SESSION':\n return {\n ...state,\n session: action.value,\n };\n case 'START':\n return {\n ...state,\n active: true,\n };\n case 'RESET':\n return defaultState();\n default:\n return state;\n }\n};\nconst createAutoSignInStore = (reducer) => {\n let currentState = reducer(defaultState(), { type: 'RESET' });\n return {\n getState: () => currentState,\n dispatch: action => {\n currentState = reducer(currentState, action);\n },\n };\n};\nexport const autoSignInStore = createAutoSignInStore(autoSignInReducer);\n"],"names":[],"mappings":"AAAA;AACA;AACA,SAAS,YAAY,GAAG;AACxB,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,KAAK;AACrB,KAAK;AACL;AACA,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK;AAC7C,IAAI,QAAQ,MAAM,CAAC,IAAI;AACvB,QAAQ,KAAK,cAAc;AAC3B,YAAY,OAAO;AACnB,gBAAgB,GAAG,KAAK;AACxB,gBAAgB,QAAQ,EAAE,MAAM,CAAC,KAAK;AACtC,aAAa;AACb,QAAQ,KAAK,aAAa;AAC1B,YAAY,OAAO;AACnB,gBAAgB,GAAG,KAAK;AACxB,gBAAgB,OAAO,EAAE,MAAM,CAAC,KAAK;AACrC,aAAa;AACb,QAAQ,KAAK,OAAO;AACpB,YAAY,OAAO;AACnB,gBAAgB,GAAG,KAAK;AACxB,gBAAgB,MAAM,EAAE,IAAI;AAC5B,aAAa;AACb,QAAQ,KAAK,OAAO;AACpB,YAAY,OAAO,YAAY,EAAE;AACjC,QAAQ;AACR,YAAY,OAAO,KAAK;AACxB;AACA,CAAC;AACD,MAAM,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAC3C,IAAI,IAAI,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACjE,IAAI,OAAO;AACX,QAAQ,QAAQ,EAAE,MAAM,YAAY;AACpC,QAAQ,QAAQ,EAAE,MAAM,IAAI;AAC5B,YAAY,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;AACxD,
|
|
1
|
+
{"version":3,"file":"autoSignInStore.mjs","sources":["../../../../../src/client/utils/store/autoSignInStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nfunction defaultState() {\n return {\n active: false,\n };\n}\nconst autoSignInReducer = (state, action) => {\n switch (action.type) {\n case 'SET_USERNAME':\n return {\n ...state,\n username: action.value,\n };\n case 'SET_SESSION':\n return {\n ...state,\n session: action.value,\n };\n case 'START':\n return {\n ...state,\n active: true,\n };\n case 'RESET':\n return defaultState();\n default:\n return state;\n }\n};\nconst createAutoSignInStore = (reducer) => {\n let currentState = reducer(defaultState(), { type: 'RESET' });\n return {\n getState: () => currentState,\n dispatch: action => {\n currentState = reducer(currentState, action);\n },\n };\n};\nexport const autoSignInStore = createAutoSignInStore(autoSignInReducer);\n"],"names":[],"mappings":"AAAA;AACA;AACA,SAAS,YAAY,GAAG;AACxB,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,KAAK;AACrB,KAAK;AACL;AACA,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK;AAC7C,IAAI,QAAQ,MAAM,CAAC,IAAI;AACvB,QAAQ,KAAK,cAAc;AAC3B,YAAY,OAAO;AACnB,gBAAgB,GAAG,KAAK;AACxB,gBAAgB,QAAQ,EAAE,MAAM,CAAC,KAAK;AACtC,aAAa;AACb,QAAQ,KAAK,aAAa;AAC1B,YAAY,OAAO;AACnB,gBAAgB,GAAG,KAAK;AACxB,gBAAgB,OAAO,EAAE,MAAM,CAAC,KAAK;AACrC,aAAa;AACb,QAAQ,KAAK,OAAO;AACpB,YAAY,OAAO;AACnB,gBAAgB,GAAG,KAAK;AACxB,gBAAgB,MAAM,EAAE,IAAI;AAC5B,aAAa;AACb,QAAQ,KAAK,OAAO;AACpB,YAAY,OAAO,YAAY,EAAE;AACjC,QAAQ;AACR,YAAY,OAAO,KAAK;AACxB;AACA,CAAC;AACD,MAAM,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAC3C,IAAI,IAAI,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACjE,IAAI,OAAO;AACX,QAAQ,QAAQ,EAAE,MAAM,YAAY;AACpC,QAAQ,QAAQ,EAAE,MAAM,IAAI;AAC5B,YAAY,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;AACxD,QAAQ,CAAC;AACT,KAAK;AACL,CAAC;AACW,MAAC,eAAe,GAAG,qBAAqB,CAAC,iBAAiB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInStore.mjs","sources":["../../../../../src/client/utils/store/signInStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { syncSessionStorage } from '@aws-amplify/core';\n// Minutes until stored session invalidates is defaulted to 3 minutes\n// to maintain parity with Amazon Cognito user pools API behavior\nconst MS_TO_EXPIRY = 3 * 60 * 1000;\nconst TGT_STATE = 'CognitoSignInState';\nconst SIGN_IN_STATE_KEYS = {\n username: `${TGT_STATE}.username`,\n challengeName: `${TGT_STATE}.challengeName`,\n signInSession: `${TGT_STATE}.signInSession`,\n expiry: `${TGT_STATE}.expiry`,\n};\nconst signInReducer = (state, action) => {\n switch (action.type) {\n case 'SET_SIGN_IN_SESSION':\n persistSignInState({ signInSession: action.value });\n return {\n ...state,\n signInSession: action.value,\n };\n case 'SET_SIGN_IN_STATE':\n persistSignInState(action.value);\n return {\n ...action.value,\n };\n case 'SET_CHALLENGE_NAME':\n persistSignInState({ challengeName: action.value });\n return {\n ...state,\n challengeName: action.value,\n };\n case 'SET_USERNAME':\n persistSignInState({ username: action.value });\n return {\n ...state,\n username: action.value,\n };\n case 'SET_INITIAL_STATE':\n return getInitialState();\n case 'RESET_STATE':\n clearPersistedSignInState();\n return getDefaultState();\n // this state is never reachable\n default:\n return state;\n }\n};\nconst isExpired = (expiryDate) => {\n const expiryTimestamp = Number(expiryDate);\n const currentTimestamp = Date.now();\n return expiryTimestamp <= currentTimestamp;\n};\nexport const resetActiveSignInState = () => {\n signInStore.dispatch({ type: 'RESET_STATE' });\n};\nconst clearPersistedSignInState = () => {\n for (const stateKey of Object.values(SIGN_IN_STATE_KEYS)) {\n syncSessionStorage.removeItem(stateKey);\n }\n};\nconst getDefaultState = () => ({\n username: undefined,\n challengeName: undefined,\n signInSession: undefined,\n});\n// Hydrate signInStore from syncSessionStorage if the session has not expired\nconst getInitialState = () => {\n const expiry = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry);\n if (!expiry || isExpired(expiry)) {\n clearPersistedSignInState();\n return getDefaultState();\n }\n const username = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.username) ?? undefined;\n const challengeName = (syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.challengeName) ?? undefined);\n const signInSession = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.signInSession) ?? undefined;\n return {\n username,\n challengeName,\n signInSession,\n };\n};\nconst createStore = reducer => {\n let currentState = reducer(getDefaultState(), { type: 'SET_INITIAL_STATE' });\n return {\n getState: () => currentState,\n dispatch: action => {\n currentState = reducer(currentState, action);\n },\n };\n};\nexport const signInStore = createStore(signInReducer);\nexport function setActiveSignInState(state) {\n signInStore.dispatch({\n type: 'SET_SIGN_IN_STATE',\n value: state,\n });\n}\n// Save local state into Session Storage\nexport const persistSignInState = ({ challengeName, signInSession, username, }) => {\n username && syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.username, username);\n challengeName &&\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.challengeName, challengeName);\n if (signInSession) {\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.signInSession, signInSession);\n // Updates expiry when session is passed\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.expiry, String(Date.now() + MS_TO_EXPIRY));\n }\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;AAClC,MAAM,SAAS,GAAG,oBAAoB;AACtC,MAAM,kBAAkB,GAAG;AAC3B,IAAI,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC;AACrC,IAAI,aAAa,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC;AAC/C,IAAI,aAAa,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC;AAC/C,IAAI,MAAM,EAAE,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC;AACjC,CAAC;AACD,M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gB;AAC9C,CAAC;AACW,MAAC,sBAAsB,GAAG,MAAM;AAC5C,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACjD;AACA,MAAM,yBAAyB,GAAG,MAAM;AACxC,IAAI,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;AAC9D,QAAQ,kBAAkB,CAAC,UAAU,CAAC,QAAQ,CAAC;AAC/C;
|
|
1
|
+
{"version":3,"file":"signInStore.mjs","sources":["../../../../../src/client/utils/store/signInStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { syncSessionStorage } from '@aws-amplify/core';\n// Minutes until stored session invalidates is defaulted to 3 minutes\n// to maintain parity with Amazon Cognito user pools API behavior\nconst MS_TO_EXPIRY = 3 * 60 * 1000;\nconst TGT_STATE = 'CognitoSignInState';\nconst SIGN_IN_STATE_KEYS = {\n username: `${TGT_STATE}.username`,\n challengeName: `${TGT_STATE}.challengeName`,\n signInSession: `${TGT_STATE}.signInSession`,\n expiry: `${TGT_STATE}.expiry`,\n};\nconst signInReducer = (state, action) => {\n switch (action.type) {\n case 'SET_SIGN_IN_SESSION':\n persistSignInState({ signInSession: action.value });\n return {\n ...state,\n signInSession: action.value,\n };\n case 'SET_SIGN_IN_STATE':\n persistSignInState(action.value);\n return {\n ...action.value,\n };\n case 'SET_CHALLENGE_NAME':\n persistSignInState({ challengeName: action.value });\n return {\n ...state,\n challengeName: action.value,\n };\n case 'SET_USERNAME':\n persistSignInState({ username: action.value });\n return {\n ...state,\n username: action.value,\n };\n case 'SET_INITIAL_STATE':\n return getInitialState();\n case 'RESET_STATE':\n clearPersistedSignInState();\n return getDefaultState();\n // this state is never reachable\n default:\n return state;\n }\n};\nconst isExpired = (expiryDate) => {\n const expiryTimestamp = Number(expiryDate);\n const currentTimestamp = Date.now();\n return expiryTimestamp <= currentTimestamp;\n};\nexport const resetActiveSignInState = () => {\n signInStore.dispatch({ type: 'RESET_STATE' });\n};\nconst clearPersistedSignInState = () => {\n for (const stateKey of Object.values(SIGN_IN_STATE_KEYS)) {\n syncSessionStorage.removeItem(stateKey);\n }\n};\nconst getDefaultState = () => ({\n username: undefined,\n challengeName: undefined,\n signInSession: undefined,\n});\n// Hydrate signInStore from syncSessionStorage if the session has not expired\nconst getInitialState = () => {\n const expiry = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry);\n if (!expiry || isExpired(expiry)) {\n clearPersistedSignInState();\n return getDefaultState();\n }\n const username = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.username) ?? undefined;\n const challengeName = (syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.challengeName) ?? undefined);\n const signInSession = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.signInSession) ?? undefined;\n return {\n username,\n challengeName,\n signInSession,\n };\n};\nconst createStore = reducer => {\n let currentState = reducer(getDefaultState(), { type: 'SET_INITIAL_STATE' });\n return {\n getState: () => currentState,\n dispatch: action => {\n currentState = reducer(currentState, action);\n },\n };\n};\nexport const signInStore = createStore(signInReducer);\nexport function setActiveSignInState(state) {\n signInStore.dispatch({\n type: 'SET_SIGN_IN_STATE',\n value: state,\n });\n}\n// Save local state into Session Storage\nexport const persistSignInState = ({ challengeName, signInSession, username, }) => {\n username && syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.username, username);\n challengeName &&\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.challengeName, challengeName);\n if (signInSession) {\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.signInSession, signInSession);\n // Updates expiry when session is passed\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.expiry, String(Date.now() + MS_TO_EXPIRY));\n }\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;AAClC,MAAM,SAAS,G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;AAChG,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthError.mjs","sources":["../../../src/errors/AuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, } from '@aws-amplify/core/internals/utils';\nexport class AuthError extends AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = AuthError;\n Object.setPrototypeOf(this, AuthError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,SAAS,SAAS,YAAY,CAAC;AAC5C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC;AACrB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,SAAS;AACpC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC;AACxD;
|
|
1
|
+
{"version":3,"file":"AuthError.mjs","sources":["../../../src/errors/AuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, } from '@aws-amplify/core/internals/utils';\nexport class AuthError extends AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = AuthError;\n Object.setPrototypeOf(this, AuthError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,SAAS,SAAS,YAAY,CAAC;AAC5C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC;AACrB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,SAAS;AACpC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC;AACxD,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertServiceError.mjs","sources":["../../../../src/errors/utils/assertServiceError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyErrorCode, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../AuthError';\nexport function assertServiceError(error) {\n if (!error ||\n error.name === 'Error' ||\n error instanceof TypeError) {\n throw new AuthError({\n name: AmplifyErrorCode.Unknown,\n message: 'An unknown error has occurred.',\n underlyingError: error,\n });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,kBAAkB,CAAC,KAAK,EAAE;AAC1C,IAAI,IAAI,CAAC,KAAK;AACd,QAAQ,KAAK,CAAC,IAAI,KAAK,OAAO;AAC9B,QAAQ,KAAK,YAAY,SAAS,EAAE;AACpC,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,gBAAgB,CAAC,OAAO;AAC1C,YAAY,OAAO,EAAE,gCAAgC;AACrD,YAAY,eAAe,EAAE,KAAK;AAClC,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"assertServiceError.mjs","sources":["../../../../src/errors/utils/assertServiceError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyErrorCode, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../AuthError';\nexport function assertServiceError(error) {\n if (!error ||\n error.name === 'Error' ||\n error instanceof TypeError) {\n throw new AuthError({\n name: AmplifyErrorCode.Unknown,\n message: 'An unknown error has occurred.',\n underlyingError: error,\n });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,kBAAkB,CAAC,KAAK,EAAE;AAC1C,IAAI,IAAI,CAAC,KAAK;AACd,QAAQ,KAAK,CAAC,IAAI,KAAK,OAAO;AAC9B,QAAQ,KAAK,YAAY,SAAS,EAAE;AACpC,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,gBAAgB,CAAC,OAAO;AAC1C,YAAY,OAAO,EAAE,gCAAgC;AACrD,YAAY,eAAe,EAAE,KAAK;AAClC,SAAS,CAAC;AACV,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertValidationError.mjs","sources":["../../../../src/errors/utils/assertValidationError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { validationErrorMap } from '../../common/AuthErrorStrings';\nimport { AuthError } from '../AuthError';\nexport function assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validationErrorMap[name];\n if (!assertion) {\n throw new AuthError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AACvD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;AACpE,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAClE;
|
|
1
|
+
{"version":3,"file":"assertValidationError.mjs","sources":["../../../../src/errors/utils/assertValidationError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { validationErrorMap } from '../../common/AuthErrorStrings';\nimport { AuthError } from '../AuthError';\nexport function assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validationErrorMap[name];\n if (!assertion) {\n throw new AuthError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AACvD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;AACpE,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAClE,IAAI;AACJ;;;;"}
|
package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/constants.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getRetryDecider, jitteredBackoff, parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { getAmplifyUserAgent } from '@aws-amplify/core/internals/utils';\nimport { COGNITO_IDP_SERVICE_NAME } from '../../../constants';\nexport const DEFAULT_SERVICE_CLIENT_API_CONFIG = {\n service: COGNITO_IDP_SERVICE_NAME,\n retryDecider: getRetryDecider(parseJsonError),\n computeDelay: jitteredBackoff,\n get userAgentValue() {\n return getAmplifyUserAgent();\n },\n cache: 'no-store',\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iCAAiC,GAAG;AACjD,IAAI,OAAO,EAAE,wBAAwB;AACrC,IAAI,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC;AACjD,IAAI,YAAY,EAAE,eAAe;AACjC,IAAI,IAAI,cAAc,GAAG;AACzB,QAAQ,OAAO,mBAAmB,EAAE;AACpC,
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getRetryDecider, jitteredBackoff, parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { getAmplifyUserAgent } from '@aws-amplify/core/internals/utils';\nimport { COGNITO_IDP_SERVICE_NAME } from '../../../constants';\nexport const DEFAULT_SERVICE_CLIENT_API_CONFIG = {\n service: COGNITO_IDP_SERVICE_NAME,\n retryDecider: getRetryDecider(parseJsonError),\n computeDelay: jitteredBackoff,\n get userAgentValue() {\n return getAmplifyUserAgent();\n },\n cache: 'no-store',\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iCAAiC,GAAG;AACjD,IAAI,OAAO,EAAE,wBAAwB;AACrC,IAAI,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC;AACjD,IAAI,YAAY,EAAE,eAAe;AACjC,IAAI,IAAI,cAAc,GAAG;AACzB,QAAQ,OAAO,mBAAmB,EAAE;AACpC,IAAI,CAAC;AACL,IAAI,KAAK,EAAE,UAAU;AACrB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSignUpClient.mjs","sources":["../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { parseJsonBody, parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { validationErrorMap } from '../../../../common/AuthErrorStrings';\nimport { AuthError } from '../../../../errors/AuthError';\nimport { AuthValidationErrorCode } from '../../../../errors/types/validation';\nimport { assertServiceError } from '../../../../errors/utils/assertServiceError';\nimport { SignUpException } from '../../../../providers/cognito/types/errors';\nimport { createUserPoolSerializer } from './shared/serde';\nimport { cognitoUserPoolTransferHandler } from './shared/handler';\nimport { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';\nexport const createSignUpClientDeserializer = () => async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n assertServiceError(error);\n if (\n // Missing Password Error\n // 1 validation error detected: Value at 'password'failed to satisfy constraint: Member must not be null\n error.name === SignUpException.InvalidParameterException &&\n /'password'/.test(error.message) &&\n /Member must not be null/.test(error.message)) {\n const name = AuthValidationErrorCode.EmptySignUpPassword;\n const { message, recoverySuggestion } = validationErrorMap[name];\n throw new AuthError({\n name,\n message,\n recoverySuggestion,\n });\n }\n throw new AuthError({ name: error.name, message: error.message });\n }\n return parseJsonBody(response);\n};\nexport const createSignUpClient = (config) => composeServiceApi(cognitoUserPoolTransferHandler, createUserPoolSerializer('SignUp'), createSignUpClientDeserializer(), {\n ...DEFAULT_SERVICE_CLIENT_API_CONFIG,\n ...config,\n});\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAWY,MAAC,8BAA8B,GAAG,MAAM,OAAO,QAAQ,KAAK;AACxE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ;AACR;AACA;AACA,QAAQ,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,yBAAyB;AAChE,YAAY,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;AAC5C,YAAY,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;AAC3D,YAAY,MAAM,IAAI,GAAG,uBAAuB,CAAC,mBAAmB;AACpE,YAAY,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;AAC5E,YAAY,MAAM,IAAI,SAAS,CAAC;AAChC,gBAAgB,IAAI;AACpB,gBAAgB,OAAO;AACvB,gBAAgB,kBAAkB;AAClC,aAAa,CAAC;AACd;
|
|
1
|
+
{"version":3,"file":"createSignUpClient.mjs","sources":["../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { parseJsonBody, parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { validationErrorMap } from '../../../../common/AuthErrorStrings';\nimport { AuthError } from '../../../../errors/AuthError';\nimport { AuthValidationErrorCode } from '../../../../errors/types/validation';\nimport { assertServiceError } from '../../../../errors/utils/assertServiceError';\nimport { SignUpException } from '../../../../providers/cognito/types/errors';\nimport { createUserPoolSerializer } from './shared/serde';\nimport { cognitoUserPoolTransferHandler } from './shared/handler';\nimport { DEFAULT_SERVICE_CLIENT_API_CONFIG } from './constants';\nexport const createSignUpClientDeserializer = () => async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n assertServiceError(error);\n if (\n // Missing Password Error\n // 1 validation error detected: Value at 'password'failed to satisfy constraint: Member must not be null\n error.name === SignUpException.InvalidParameterException &&\n /'password'/.test(error.message) &&\n /Member must not be null/.test(error.message)) {\n const name = AuthValidationErrorCode.EmptySignUpPassword;\n const { message, recoverySuggestion } = validationErrorMap[name];\n throw new AuthError({\n name,\n message,\n recoverySuggestion,\n });\n }\n throw new AuthError({ name: error.name, message: error.message });\n }\n return parseJsonBody(response);\n};\nexport const createSignUpClient = (config) => composeServiceApi(cognitoUserPoolTransferHandler, createUserPoolSerializer('SignUp'), createSignUpClientDeserializer(), {\n ...DEFAULT_SERVICE_CLIENT_API_CONFIG,\n ...config,\n});\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAWY,MAAC,8BAA8B,GAAG,MAAM,OAAO,QAAQ,KAAK;AACxE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ;AACR;AACA;AACA,QAAQ,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,yBAAyB;AAChE,YAAY,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;AAC5C,YAAY,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;AAC3D,YAAY,MAAM,IAAI,GAAG,uBAAuB,CAAC,mBAAmB;AACpE,YAAY,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;AAC5E,YAAY,MAAM,IAAI,SAAS,CAAC;AAChC,gBAAgB,IAAI;AACpB,gBAAgB,OAAO;AACvB,gBAAgB,kBAAkB;AAClC,aAAa,CAAC;AACd,QAAQ;AACR,QAAQ,MAAM,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AACzE,IAAI;AACJ,IAAI,OAAO,aAAa,CAAC,QAAQ,CAAC;AAClC;AACY,MAAC,kBAAkB,GAAG,CAAC,MAAM,KAAK,iBAAiB,CAAC,8BAA8B,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EAAE,8BAA8B,EAAE,EAAE;AACtK,IAAI,GAAG,iCAAiC;AACxC,IAAI,GAAG,MAAM;AACb,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEmptyResponseDeserializer.mjs","sources":["../../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createEmptyResponseDeserializer.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { assertServiceError } from '../../../../../../errors/utils/assertServiceError';\nimport { AuthError } from '../../../../../../errors/AuthError';\nexport const createEmptyResponseDeserializer = () => async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n assertServiceError(error);\n throw new AuthError({ name: error.name, message: error.message });\n }\n else {\n return undefined;\n }\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,+BAA+B,GAAG,MAAM,OAAO,QAAQ,KAAK;AACzE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ,MAAM,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AACzE;
|
|
1
|
+
{"version":3,"file":"createEmptyResponseDeserializer.mjs","sources":["../../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createEmptyResponseDeserializer.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { assertServiceError } from '../../../../../../errors/utils/assertServiceError';\nimport { AuthError } from '../../../../../../errors/AuthError';\nexport const createEmptyResponseDeserializer = () => async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n assertServiceError(error);\n throw new AuthError({ name: error.name, message: error.message });\n }\n else {\n return undefined;\n }\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,+BAA+B,GAAG,MAAM,OAAO,QAAQ,KAAK;AACzE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ,MAAM,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AACzE,IAAI;AACJ,SAAS;AACT,QAAQ,OAAO,SAAS;AACxB,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUserPoolDeserializer.mjs","sources":["../../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createUserPoolDeserializer.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonBody, parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { assertServiceError } from '../../../../../../errors/utils/assertServiceError';\nimport { AuthError } from '../../../../../../errors/AuthError';\nexport const createUserPoolDeserializer = () => async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n assertServiceError(error);\n throw new AuthError({\n name: error.name,\n message: error.message,\n metadata: error.$metadata,\n });\n }\n return parseJsonBody(response);\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,0BAA0B,GAAG,MAAM,OAAO,QAAQ,KAAK;AACpE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,KAAK,CAAC,IAAI;AAC5B,YAAY,OAAO,EAAE,KAAK,CAAC,OAAO;AAClC,YAAY,QAAQ,EAAE,KAAK,CAAC,SAAS;AACrC,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"createUserPoolDeserializer.mjs","sources":["../../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createUserPoolDeserializer.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseJsonBody, parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { assertServiceError } from '../../../../../../errors/utils/assertServiceError';\nimport { AuthError } from '../../../../../../errors/AuthError';\nexport const createUserPoolDeserializer = () => async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseJsonError(response);\n assertServiceError(error);\n throw new AuthError({\n name: error.name,\n message: error.message,\n metadata: error.$metadata,\n });\n }\n return parseJsonBody(response);\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,0BAA0B,GAAG,MAAM,OAAO,QAAQ,KAAK;AACpE,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC;AACpD,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,KAAK,CAAC,IAAI;AAC5B,YAAY,OAAO,EAAE,KAAK,CAAC,OAAO;AAClC,YAAY,QAAQ,EAAE,KAAK,CAAC,SAAS;AACrC,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,aAAa,CAAC,QAAQ,CAAC;AAClC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regionParsers.mjs","sources":["../../../../src/foundation/parsers/regionParsers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from '../../errors/AuthError';\nexport function getRegionFromUserPoolId(userPoolId) {\n const region = userPoolId?.split('_')[0];\n if (!userPoolId ||\n userPoolId.indexOf('_') < 0 ||\n !region ||\n typeof region !== 'string')\n throw new AuthError({\n name: 'InvalidUserPoolId',\n message: 'Invalid user pool id provided.',\n });\n return region;\n}\nexport function getRegionFromIdentityPoolId(identityPoolId) {\n if (!identityPoolId || !identityPoolId.includes(':')) {\n throw new AuthError({\n name: 'InvalidIdentityPoolIdException',\n message: 'Invalid identity pool id provided.',\n recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',\n });\n }\n return identityPoolId.split(':')[0];\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,SAAS,uBAAuB,CAAC,UAAU,EAAE;AACpD,IAAI,MAAM,MAAM,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5C,IAAI,IAAI,CAAC,UAAU;AACnB,QAAQ,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AACnC,QAAQ,CAAC,MAAM;AACf,QAAQ,OAAO,MAAM,KAAK,QAAQ;AAClC,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,mBAAmB;AACrC,YAAY,OAAO,EAAE,gCAAgC;AACrD,SAAS,CAAC;AACV,IAAI,OAAO,MAAM;AACjB;AACO,SAAS,2BAA2B,CAAC,cAAc,EAAE;AAC5D,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC1D,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,gCAAgC;AAClD,YAAY,OAAO,EAAE,oCAAoC;AACzD,YAAY,kBAAkB,EAAE,0DAA0D;AAC1F,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"regionParsers.mjs","sources":["../../../../src/foundation/parsers/regionParsers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from '../../errors/AuthError';\nexport function getRegionFromUserPoolId(userPoolId) {\n const region = userPoolId?.split('_')[0];\n if (!userPoolId ||\n userPoolId.indexOf('_') < 0 ||\n !region ||\n typeof region !== 'string')\n throw new AuthError({\n name: 'InvalidUserPoolId',\n message: 'Invalid user pool id provided.',\n });\n return region;\n}\nexport function getRegionFromIdentityPoolId(identityPoolId) {\n if (!identityPoolId || !identityPoolId.includes(':')) {\n throw new AuthError({\n name: 'InvalidIdentityPoolIdException',\n message: 'Invalid identity pool id provided.',\n recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',\n });\n }\n return identityPoolId.split(':')[0];\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,SAAS,uBAAuB,CAAC,UAAU,EAAE;AACpD,IAAI,MAAM,MAAM,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5C,IAAI,IAAI,CAAC,UAAU;AACnB,QAAQ,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AACnC,QAAQ,CAAC,MAAM;AACf,QAAQ,OAAO,MAAM,KAAK,QAAQ;AAClC,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,mBAAmB;AACrC,YAAY,OAAO,EAAE,gCAAgC;AACrD,SAAS,CAAC;AACV,IAAI,OAAO,MAAM;AACjB;AACO,SAAS,2BAA2B,CAAC,cAAc,EAAE;AAC5D,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC1D,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,gCAAgC;AAClD,YAAY,OAAO,EAAE,oCAAoC;AACzD,YAAY,kBAAkB,EAAE,0DAA0D;AAC1F,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoSignIn.mjs","sources":["../../../../../src/providers/cognito/apis/autoSignIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { AuthError } from '../../../errors/AuthError';\nimport { AUTO_SIGN_IN_EXCEPTION } from '../../../errors/constants';\nconst initialAutoSignIn = async () => {\n throw new AuthError({\n name: AUTO_SIGN_IN_EXCEPTION,\n message: 'The autoSignIn flow has not started, or has been cancelled/completed.',\n recoverySuggestion: 'Please try to use the signIn API or log out before starting a new autoSignIn flow.',\n });\n};\n/**\n * Signs a user in automatically after finishing the sign-up process.\n *\n * This API will automatically sign a user in if the autoSignIn flow has been completed in the following cases:\n * - User confirmed their account with a verification code sent to their phone or email (default option).\n * - User confirmed their account with a verification link sent to their phone or email. In order to\n * enable this option you need to go to the Amazon Cognito [console](https://aws.amazon.com/pm/cognito),\n * look for your userpool, then go to the `Messaging` tab and enable `link` mode inside the `Verification message` option.\n * Finally you need to define the `signUpVerificationMethod` in your `Auth` config.\n *\n * @example\n * ```typescript\n * Amplify.configure({\n * Auth: {\n * Cognito: {\n * ...cognitoConfig,\n * signUpVerificationMethod: \"link\" // the default value is \"code\"\n * }\n *\t}});\n * ```\n *\n * @throws AutoSignInException - Thrown when the autoSignIn flow has not started, or has been cancelled/completed.\n * @returns The signInOutput.\n *\n * @example\n * ```typescript\n * // handleSignUp.ts\n * async function handleSignUp(\n * username:string,\n * password:string\n * ){\n * try {\n * const { nextStep } = await signUp({\n * username,\n * password,\n * options: {\n * userAttributes:{ email:'email@email.com'},\n * autoSignIn: true // This enables the auto sign-in flow.\n * },\n * });\n *\n * handleSignUpStep(nextStep);\n *\n * } catch (error) {\n * console.log(error);\n * }\n * }\n *\n * // handleConfirmSignUp.ts\n * async function handleConfirmSignUp(username:string, confirmationCode:string) {\n * try {\n * const { nextStep } = await confirmSignUp({\n * username,\n * confirmationCode,\n * });\n *\n * handleSignUpStep(nextStep);\n * } catch (error) {\n * console.log(error);\n * }\n * }\n *\n * // signUpUtils.ts\n * async function handleSignUpStep( step: SignUpOutput[\"nextStep\"]) {\n * switch (step.signUpStep) {\n * case \"CONFIRM_SIGN_UP\":\n *\n * // Redirect end-user to confirm-sign up screen.\n *\n * case \"COMPLETE_AUTO_SIGN_IN\":\n *\t const codeDeliveryDetails = step.codeDeliveryDetails;\n * if (codeDeliveryDetails) {\n * // Redirect user to confirm-sign-up with link screen.\n * }\n * const signInOutput = await autoSignIn();\n * // handle sign-in steps\n * }\n *\n * ```\n */\n// TODO(Eslint): can this be refactored not using `let` on exported member?\n// eslint-disable-next-line import/no-mutable-exports\nexport let autoSignIn = initialAutoSignIn;\n/**\n * Sets the context of autoSignIn at run time.\n * @internal\n */\nexport function setAutoSignIn(callback) {\n autoSignIn = callback;\n}\n/**\n * Resets the context\n *\n * @internal\n */\nexport function resetAutoSignIn(resetCallback = true) {\n if (resetCallback) {\n autoSignIn = initialAutoSignIn;\n }\n autoSignInStore.dispatch({ type: 'RESET' });\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAIA,MAAM,iBAAiB,GAAG,YAAY;AACtC,IAAI,MAAM,IAAI,SAAS,CAAC;AACxB,QAAQ,IAAI,EAAE,sBAAsB;AACpC,QAAQ,OAAO,EAAE,uEAAuE;AACxF,QAAQ,kBAAkB,EAAE,oFAAoF;AAChH,KAAK,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACU,IAAC,UAAU,GAAG;AACxB;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,QAAQ,EAAE;AACxC,IAAI,UAAU,GAAG,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,GAAG,IAAI,EAAE;AACtD,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,UAAU,GAAG,iBAAiB;AACtC;
|
|
1
|
+
{"version":3,"file":"autoSignIn.mjs","sources":["../../../../../src/providers/cognito/apis/autoSignIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { AuthError } from '../../../errors/AuthError';\nimport { AUTO_SIGN_IN_EXCEPTION } from '../../../errors/constants';\nconst initialAutoSignIn = async () => {\n throw new AuthError({\n name: AUTO_SIGN_IN_EXCEPTION,\n message: 'The autoSignIn flow has not started, or has been cancelled/completed.',\n recoverySuggestion: 'Please try to use the signIn API or log out before starting a new autoSignIn flow.',\n });\n};\n/**\n * Signs a user in automatically after finishing the sign-up process.\n *\n * This API will automatically sign a user in if the autoSignIn flow has been completed in the following cases:\n * - User confirmed their account with a verification code sent to their phone or email (default option).\n * - User confirmed their account with a verification link sent to their phone or email. In order to\n * enable this option you need to go to the Amazon Cognito [console](https://aws.amazon.com/pm/cognito),\n * look for your userpool, then go to the `Messaging` tab and enable `link` mode inside the `Verification message` option.\n * Finally you need to define the `signUpVerificationMethod` in your `Auth` config.\n *\n * @example\n * ```typescript\n * Amplify.configure({\n * Auth: {\n * Cognito: {\n * ...cognitoConfig,\n * signUpVerificationMethod: \"link\" // the default value is \"code\"\n * }\n *\t}});\n * ```\n *\n * @throws AutoSignInException - Thrown when the autoSignIn flow has not started, or has been cancelled/completed.\n * @returns The signInOutput.\n *\n * @example\n * ```typescript\n * // handleSignUp.ts\n * async function handleSignUp(\n * username:string,\n * password:string\n * ){\n * try {\n * const { nextStep } = await signUp({\n * username,\n * password,\n * options: {\n * userAttributes:{ email:'email@email.com'},\n * autoSignIn: true // This enables the auto sign-in flow.\n * },\n * });\n *\n * handleSignUpStep(nextStep);\n *\n * } catch (error) {\n * console.log(error);\n * }\n * }\n *\n * // handleConfirmSignUp.ts\n * async function handleConfirmSignUp(username:string, confirmationCode:string) {\n * try {\n * const { nextStep } = await confirmSignUp({\n * username,\n * confirmationCode,\n * });\n *\n * handleSignUpStep(nextStep);\n * } catch (error) {\n * console.log(error);\n * }\n * }\n *\n * // signUpUtils.ts\n * async function handleSignUpStep( step: SignUpOutput[\"nextStep\"]) {\n * switch (step.signUpStep) {\n * case \"CONFIRM_SIGN_UP\":\n *\n * // Redirect end-user to confirm-sign up screen.\n *\n * case \"COMPLETE_AUTO_SIGN_IN\":\n *\t const codeDeliveryDetails = step.codeDeliveryDetails;\n * if (codeDeliveryDetails) {\n * // Redirect user to confirm-sign-up with link screen.\n * }\n * const signInOutput = await autoSignIn();\n * // handle sign-in steps\n * }\n *\n * ```\n */\n// TODO(Eslint): can this be refactored not using `let` on exported member?\n// eslint-disable-next-line import/no-mutable-exports\nexport let autoSignIn = initialAutoSignIn;\n/**\n * Sets the context of autoSignIn at run time.\n * @internal\n */\nexport function setAutoSignIn(callback) {\n autoSignIn = callback;\n}\n/**\n * Resets the context\n *\n * @internal\n */\nexport function resetAutoSignIn(resetCallback = true) {\n if (resetCallback) {\n autoSignIn = initialAutoSignIn;\n }\n autoSignInStore.dispatch({ type: 'RESET' });\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAIA,MAAM,iBAAiB,GAAG,YAAY;AACtC,IAAI,MAAM,IAAI,SAAS,CAAC;AACxB,QAAQ,IAAI,EAAE,sBAAsB;AACpC,QAAQ,OAAO,EAAE,uEAAuE;AACxF,QAAQ,kBAAkB,EAAE,oFAAoF;AAChH,KAAK,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACU,IAAC,UAAU,GAAG;AACxB;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,QAAQ,EAAE;AACxC,IAAI,UAAU,GAAG,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,GAAG,IAAI,EAAE;AACtD,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,UAAU,GAAG,iBAAiB;AACtC,IAAI;AACJ,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC/C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmSignIn.mjs","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { resetActiveSignInState, setActiveSignInState, signInStore, } from '../../../client/utils/store';\nimport { AuthError } from '../../../errors/AuthError';\nimport { getSignInResult, getSignInResultFromError, handleChallengeName, } from '../utils/signInHelpers';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { AuthErrorCodes } from '../../../common/AuthErrorStrings';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\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 */\nexport async function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = signInStore.getState();\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const clientMetaData = options?.clientMetadata;\n assertValidationError(!!challengeResponse, AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process.\n\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 and session has expired.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the session has not expired.',\n });\n try {\n const { Session, ChallengeName: handledChallengeName, AuthenticationResult, ChallengeParameters: handledChallengeParameters, } = await handleChallengeName(username, challengeName, signInSession, challengeResponse, authConfig, tokenOrchestrator, clientMetaData, options);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username,\n ...AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n resetActiveSignInState();\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n assertServiceError(error);\n const result = getSignInResultFromError(error.name);\n if (result)\n return result;\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK;AAChD,IAAI,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE;AAC5F,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc;AAClD,IAAI,qBAAqB,CAAC,CAAC,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,sBAAsB,CAAC;AAC9F,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa;AACrD;AACA,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,cAAc,CAAC,eAAe;AAChD,YAAY,OAAO,EAAE;AACrB;;AAEA;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,YAAY,kBAAkB,EAAE,4EAA4E;AAC5G,gBAAgB,uCAAuC;AACvD,SAAS,CAAC;AACV,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B,GAAG,GAAG,MAAM,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,CAAC;AACrR;AACA,QAAQ,oBAAoB,CAAC;AAC7B,YAAY,aAAa,EAAE,OAAO;AAClC,YAAY,QAAQ;AACpB,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,aAAa;AACzB,SAAS,CAAC;AACV,QAAQ,IAAI,oBAAoB,EAAE;AAClC,YAAY,MAAM,kBAAkB,CAAC;AACrC,gBAAgB,QAAQ;AACxB,gBAAgB,GAAG,oBAAoB;AACvC,gBAAgB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,oBAAoB,UAAU,EAAE,UAAU,CAAC,UAAU;AACrD,oBAAoB,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;AACjE,oBAAoB,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB;AAC7E,oBAAoB,WAAW,EAAE,oBAAoB,CAAC,WAAW;AACjE,iBAAiB,CAAC;AAClB,gBAAgB,aAAa;AAC7B,aAAa,CAAC;AACd,YAAY,sBAAsB,EAAE;AACpC,YAAY,MAAM,wBAAwB,EAAE;AAC5C,YAAY,OAAO;AACnB,gBAAgB,UAAU,EAAE,IAAI;AAChC,gBAAgB,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAChD,aAAa;AACb;
|
|
1
|
+
{"version":3,"file":"confirmSignIn.mjs","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { resetActiveSignInState, setActiveSignInState, signInStore, } from '../../../client/utils/store';\nimport { AuthError } from '../../../errors/AuthError';\nimport { getSignInResult, getSignInResultFromError, handleChallengeName, } from '../utils/signInHelpers';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { AuthErrorCodes } from '../../../common/AuthErrorStrings';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\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 */\nexport async function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = signInStore.getState();\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const clientMetaData = options?.clientMetadata;\n assertValidationError(!!challengeResponse, AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError({\n name: AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process.\n\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 and session has expired.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the session has not expired.',\n });\n try {\n const { Session, ChallengeName: handledChallengeName, AuthenticationResult, ChallengeParameters: handledChallengeParameters, } = await handleChallengeName(username, challengeName, signInSession, challengeResponse, authConfig, tokenOrchestrator, clientMetaData, options);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username,\n ...AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n resetActiveSignInState();\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n assertServiceError(error);\n const result = getSignInResultFromError(error.name);\n if (result)\n return result;\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK;AAChD,IAAI,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE;AAC5F,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc;AAClD,IAAI,qBAAqB,CAAC,CAAC,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,sBAAsB,CAAC;AAC9F,IAAI,IAAI,CAA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EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAChD,aAAa;AACb,QAAQ;AACR,QAAQ,OAAO,eAAe,CAAC;AAC/B,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,mBAAmB,EAAE,0BAA0B;AAC3D,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,kBAAkB,CAAC,KAAK,CAAC;AACjC,QAAQ,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC;AAC3D,QAAQ,IAAI,MAAM;AAClB,YAAY,OAAO,MAAM;AACzB,QAAQ,MAAM,KAAK;AACnB,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmSignUp.mjs","sources":["../../../../../src/providers/cognito/apis/confirmSignUp.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AuthAction, HubInternal, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getUserContextData } from '../utils/userContextData';\nimport { createConfirmSignUpClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Confirms a new user account.\n *\n * @param input - The ConfirmSignUpInput object.\n * @returns ConfirmSignUpOutput\n * @throws -{@link ConfirmSignUpException }\n * Thrown due to an invalid confirmation code.\n * @throws -{@link AuthValidationErrorCode }\n * Thrown due to an empty confirmation code\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function confirmSignUp(input) {\n const { username, confirmationCode, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolId, userPoolClientId, userPoolEndpoint } = authConfig;\n const clientMetadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptyConfirmSignUpUsername);\n assertValidationError(!!confirmationCode, AuthValidationErrorCode.EmptyConfirmSignUpCode);\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const confirmSignUpClient = createConfirmSignUpClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { Session: session } = await confirmSignUpClient({\n region: getRegionFromUserPoolId(authConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignUp),\n }, {\n Username: username,\n ConfirmationCode: confirmationCode,\n ClientMetadata: clientMetadata,\n ForceAliasCreation: options?.forceAliasCreation,\n ClientId: authConfig.userPoolClientId,\n UserContextData,\n });\n return new Promise((resolve, reject) => {\n try {\n const signUpOut = {\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'DONE',\n },\n };\n const autoSignInStoreState = autoSignInStore.getState();\n if (!autoSignInStoreState.active ||\n autoSignInStoreState.username !== username) {\n resolve(signUpOut);\n resetAutoSignIn();\n return;\n }\n autoSignInStore.dispatch({ type: 'SET_SESSION', value: session });\n const stopListener = HubInternal.listen('auth-internal', ({ payload }) => {\n switch (payload.event) {\n case 'autoSignIn':\n resolve({\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'COMPLETE_AUTO_SIGN_IN',\n },\n });\n stopListener();\n }\n });\n HubInternal.dispatch('auth-internal', {\n event: 'confirmSignUp',\n data: signUpOut,\n });\n }\n catch (error) {\n reject(error);\n }\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAA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;AACN,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC5C,QAAQ,IAAI;AACZ,YAAY,MAAM,SAAS,GAAG;AAC9B,gBAAgB,gBAAgB,EAAE,IAAI;AACtC,gBAAgB,QAAQ,EAAE;AAC1B,oBAAoB,UAAU,EAAE,MAAM;AACtC,iBAAiB;AACjB,aAAa;AACb,YAAY,MAAM,oBAAoB,GAAG,eAAe,CAAC,QAAQ,EAAE;AACnE,YAAY,IAAI,CAAC,oBAAoB,CAAC,MAAM;AAC5C,gBAAgB,oBAAoB,CAAC,QAAQ,KAAK,QAAQ,EAAE;AAC5D,gBAAgB,OAAO,CAAC,SAAS,CAAC;AAClC,gBAAgB,eAAe,EAAE;AACjC,gBAAgB;AAChB;
|
|
1
|
+
{"version":3,"file":"confirmSignUp.mjs","sources":["../../../../../src/providers/cognito/apis/confirmSignUp.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AuthAction, HubInternal, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getUserContextData } from '../utils/userContextData';\nimport { createConfirmSignUpClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Confirms a new user account.\n *\n * @param input - The ConfirmSignUpInput object.\n * @returns ConfirmSignUpOutput\n * @throws -{@link ConfirmSignUpException }\n * Thrown due to an invalid confirmation code.\n * @throws -{@link AuthValidationErrorCode }\n * Thrown due to an empty confirmation code\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function confirmSignUp(input) {\n const { username, confirmationCode, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolId, userPoolClientId, userPoolEndpoint } = authConfig;\n const clientMetadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptyConfirmSignUpUsername);\n assertValidationError(!!confirmationCode, AuthValidationErrorCode.EmptyConfirmSignUpCode);\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const confirmSignUpClient = createConfirmSignUpClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { Session: session } = await confirmSignUpClient({\n region: getRegionFromUserPoolId(authConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignUp),\n }, {\n Username: username,\n ConfirmationCode: confirmationCode,\n ClientMetadata: clientMetadata,\n ForceAliasCreation: options?.forceAliasCreation,\n ClientId: authConfig.userPoolClientId,\n UserContextData,\n });\n return new Promise((resolve, reject) => {\n try {\n const signUpOut = {\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'DONE',\n },\n };\n const autoSignInStoreState = autoSignInStore.getState();\n if (!autoSignInStoreState.active ||\n autoSignInStoreState.username !== username) {\n resolve(signUpOut);\n resetAutoSignIn();\n return;\n }\n autoSignInStore.dispatch({ type: 'SET_SESSION', value: session });\n const stopListener = HubInternal.listen('auth-internal', ({ payload }) => {\n switch (payload.event) {\n case 'autoSignIn':\n resolve({\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'COMPLETE_AUTO_SIGN_IN',\n },\n });\n stopListener();\n }\n });\n HubInternal.dispatch('auth-internal', {\n event: 'confirmSignUp',\n data: signUpOut,\n });\n }\n catch (error) {\n reject(error);\n }\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AAI,CAAC,CAAC;AACN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDevices.mjs","sources":["../../../../../src/providers/cognito/apis/fetchDevices.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../utils/types';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createListDevicesClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n// Cognito Documentation for max device\n// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html#API_ListDevices_RequestSyntax\nconst MAX_DEVICES = 60;\n/**\n * Fetches devices that have been remembered using {@link rememberDevice}\n * for the currently authenticated user.\n *\n * @returns FetchDevicesOutput\n * @throws {@link ListDevicesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function fetchDevices() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession();\n assertAuthTokens(tokens);\n const listDevices = createListDevicesClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await listDevices({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.FetchDevices),\n }, {\n AccessToken: tokens.accessToken.toString(),\n Limit: MAX_DEVICES,\n });\n return parseDevicesResponse(response.Devices ?? []);\n}\nconst parseDevicesResponse = async (devices) => {\n return devices.map(({ DeviceKey: id = '', DeviceAttributes = [], DeviceCreateDate, DeviceLastModifiedDate, DeviceLastAuthenticatedDate, }) => {\n let deviceName;\n const attributes = DeviceAttributes.reduce((attrs, { Name, Value }) => {\n if (Name && Value) {\n if (Name === 'device_name')\n deviceName = Value;\n attrs[Name] = Value;\n }\n return attrs;\n }, {});\n const result = {\n id,\n name: deviceName,\n attributes,\n createDate: DeviceCreateDate\n ? new Date(DeviceCreateDate * 1000)\n : undefined,\n lastModifiedDate: DeviceLastModifiedDate\n ? new Date(DeviceLastModifiedDate * 1000)\n : undefined,\n lastAuthenticatedDate: DeviceLastAuthenticatedDate\n ? new Date(DeviceLastAuthenticatedDate * 1000)\n : undefined,\n };\n return result;\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA,MAAM,WAAW,GAAG,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,YAAY,GAAG;AACrC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,EAAE;AAC/C,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAChD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC;AACvC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,YAAY,CAAC;AACtE,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,KAAK,EAAE,WAAW;AAC1B,KAAK,CAAC;AACN,IAAI,OAAO,oBAAoB,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;AACvD;AACA,MAAM,oBAAoB,GAAG,OAAO,OAAO,KAAK;AAChD,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,2BAA2B,GAAG,KAAK;AAClJ,QAAQ,IAAI,UAAU;AACtB,QAAQ,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK;AAC/E,YAAY,IAAI,IAAI,IAAI,KAAK,EAAE;AAC/B,gBAAgB,IAAI,IAAI,KAAK,aAAa;AAC1C,oBAAoB,UAAU,GAAG,KAAK;AACtC,gBAAgB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK;AACnC;
|
|
1
|
+
{"version":3,"file":"fetchDevices.mjs","sources":["../../../../../src/providers/cognito/apis/fetchDevices.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../utils/types';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createListDevicesClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n// Cognito Documentation for max device\n// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html#API_ListDevices_RequestSyntax\nconst MAX_DEVICES = 60;\n/**\n * Fetches devices that have been remembered using {@link rememberDevice}\n * for the currently authenticated user.\n *\n * @returns FetchDevicesOutput\n * @throws {@link ListDevicesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function fetchDevices() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession();\n assertAuthTokens(tokens);\n const listDevices = createListDevicesClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await listDevices({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.FetchDevices),\n }, {\n AccessToken: tokens.accessToken.toString(),\n Limit: MAX_DEVICES,\n });\n return parseDevicesResponse(response.Devices ?? []);\n}\nconst parseDevicesResponse = async (devices) => {\n return devices.map(({ DeviceKey: id = '', DeviceAttributes = [], DeviceCreateDate, DeviceLastModifiedDate, DeviceLastAuthenticatedDate, }) => {\n let deviceName;\n const attributes = DeviceAttributes.reduce((attrs, { Name, Value }) => {\n if (Name && Value) {\n if (Name === 'device_name')\n deviceName = Value;\n attrs[Name] = Value;\n }\n return attrs;\n }, {});\n const result = {\n id,\n name: deviceName,\n attributes,\n createDate: DeviceCreateDate\n ? new Date(DeviceCreateDate * 1000)\n : undefined,\n lastModifiedDate: DeviceLastModifiedDate\n ? new Date(DeviceLastModifiedDate * 1000)\n : undefined,\n lastAuthenticatedDate: DeviceLastAuthenticatedDate\n ? new Date(DeviceLastAuthenticatedDate * 1000)\n : undefined,\n };\n return result;\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA,MAAM,WAAW,GAAG,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,YAAY,GAAG;AACrC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAg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EAAE,EAAE,CAAC;AACd,QAAQ,MAAM,MAAM,GAAG;AACvB,YAAY,EAAE;AACd,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,UAAU;AACtB,YAAY,UAAU,EAAE;AACxB,kBAAkB,IAAI,IAAI,CAAC,gBAAgB,GAAG,IAAI;AAClD,kBAAkB,SAAS;AAC3B,YAAY,gBAAgB,EAAE;AAC9B,kBAAkB,IAAI,IAAI,CAAC,sBAAsB,GAAG,IAAI;AACxD,kBAAkB,SAAS;AAC3B,YAAY,qBAAqB,EAAE;AACnC,kBAAkB,IAAI,IAAI,CAAC,2BAA2B,GAAG,IAAI;AAC7D,kBAAkB,SAAS;AAC3B,SAAS;AACT,QAAQ,OAAO,MAAM;AACrB,IAAI,CAAC,CAAC;AACN,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCurrentUser.mjs","sources":["../../../../../../src/providers/cognito/apis/internal/getCurrentUser.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../../utils/types';\nexport const getCurrentUser = async (amplify) => {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const tokens = await amplify.Auth.getTokens({ forceRefresh: false });\n assertAuthTokens(tokens);\n const { 'cognito:username': username, sub } = tokens.idToken?.payload ?? {};\n const authUser = {\n username: username,\n userId: sub,\n };\n const signInDetails = getSignInDetailsFromTokens(tokens);\n if (signInDetails) {\n authUser.signInDetails = signInDetails;\n }\n return authUser;\n};\nfunction getSignInDetailsFromTokens(tokens) {\n return tokens?.signInDetails;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,cAAc,GAAG,OAAO,OAAO,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACxE,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE;AAC/E,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,MAAM,EAAE,GAAG;AACnB,KAAK;AACL,IAAI,MAAM,aAAa,GAAG,0BAA0B,CAAC,MAAM,CAAC;AAC5D,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,QAAQ,CAAC,aAAa,GAAG,aAAa;AAC9C;
|
|
1
|
+
{"version":3,"file":"getCurrentUser.mjs","sources":["../../../../../../src/providers/cognito/apis/internal/getCurrentUser.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../../utils/types';\nexport const getCurrentUser = async (amplify) => {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const tokens = await amplify.Auth.getTokens({ forceRefresh: false });\n assertAuthTokens(tokens);\n const { 'cognito:username': username, sub } = tokens.idToken?.payload ?? {};\n const authUser = {\n username: username,\n userId: sub,\n };\n const signInDetails = getSignInDetailsFromTokens(tokens);\n if (signInDetails) {\n authUser.signInDetails = signInDetails;\n }\n return authUser;\n};\nfunction getSignInDetailsFromTokens(tokens) {\n return tokens?.signInDetails;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,cAAc,GAAG,OAAO,OAAO,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACxE,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE;AAC/E,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,MAAM,EAAE,GAAG;AACnB,KAAK;AACL,IAAI,MAAM,aAAa,GAAG,0BAA0B,CAAC,MAAM,CAAC;AAC5D,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,QAAQ,CAAC,aAAa,GAAG,aAAa;AAC9C,IAAI;AACJ,IAAI,OAAO,QAAQ;AACnB;AACA,SAAS,0BAA0B,CAAC,MAAM,EAAE;AAC5C,IAAI,OAAO,MAAM,EAAE,aAAa;AAChC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setUpTOTP.mjs","sources":["../../../../../src/providers/cognito/apis/setUpTOTP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nimport { SETUP_TOTP_EXCEPTION, } from '../types/errors';\nimport { getTOTPSetupDetails } from '../utils/signInHelpers';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens } from '../utils/types';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createAssociateSoftwareTokenClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Sets up TOTP for the user.\n *\n * @returns SetUpTOTPOutput\n * @throws -{@link AssociateSoftwareTokenException}\n * Thrown if a service occurs while setting up TOTP.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n **/\nexport async function setUpTOTP() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession({ forceRefresh: false });\n assertAuthTokens(tokens);\n const username = tokens.idToken?.payload['cognito:username'] ?? '';\n const associateSoftwareToken = createAssociateSoftwareTokenClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { SecretCode } = await associateSoftwareToken({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SetUpTOTP),\n }, {\n AccessToken: tokens.accessToken.toString(),\n });\n if (!SecretCode) {\n // This should never happen.\n throw new AuthError({\n name: SETUP_TOTP_EXCEPTION,\n message: 'Failed to set up TOTP.',\n });\n }\n return getTOTPSetupDetails(SecretCode, JSON.stringify(username));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,SAAS,GAAG;AAClC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACtE,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE;AACtE,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,sBAAsB,CAAC;AACxD,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC;AACnE,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB;AACA,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,oBAAoB;AACtC,YAAY,OAAO,EAAE,wBAAwB;AAC7C,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"setUpTOTP.mjs","sources":["../../../../../src/providers/cognito/apis/setUpTOTP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nimport { SETUP_TOTP_EXCEPTION, } from '../types/errors';\nimport { getTOTPSetupDetails } from '../utils/signInHelpers';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens } from '../utils/types';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createAssociateSoftwareTokenClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Sets up TOTP for the user.\n *\n * @returns SetUpTOTPOutput\n * @throws -{@link AssociateSoftwareTokenException}\n * Thrown if a service occurs while setting up TOTP.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n **/\nexport async function setUpTOTP() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession({ forceRefresh: false });\n assertAuthTokens(tokens);\n const username = tokens.idToken?.payload['cognito:username'] ?? '';\n const associateSoftwareToken = createAssociateSoftwareTokenClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { SecretCode } = await associateSoftwareToken({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SetUpTOTP),\n }, {\n AccessToken: tokens.accessToken.toString(),\n });\n if (!SecretCode) {\n // This should never happen.\n throw new AuthError({\n name: SETUP_TOTP_EXCEPTION,\n message: 'Failed to set up TOTP.',\n });\n }\n return getTOTPSetupDetails(SecretCode, JSON.stringify(username));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,SAAS,GAAG;AAClC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACtE,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE;AACtE,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,E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