@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":"signInWithCustomAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithCustomAuth.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleCustomAuthFlowWithoutSRP, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { retryOnResourceNotFoundException } from '../utils/retryOnResourceNotFoundException';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\n/**\n * Signs a user in using a custom authentication flow without password\n *\n * @param input - The SignInWithCustomAuthInput object\n * @returns AuthSignInResult\n * @throws service: {@link InitiateAuthException } - Cognito service errors thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws SignInWithCustomAuthOutput - Thrown when the token provider config is invalid.\n */\nexport async function signInWithCustomAuth(input) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITHOUT_SRP',\n };\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!password, AuthValidationErrorCode.CustomAuthSignInPassword);\n try {\n const { ChallengeName: retriedChallengeName, ChallengeParameters: retiredChallengeParameters, AuthenticationResult, Session, } = await retryOnResourceNotFoundException(handleCustomAuthFlowWithoutSRP, [username, metadata, authConfig, tokenOrchestrator], username, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: retriedChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\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: retriedChallengeName,\n challengeParameters: retiredChallengeParameters,\n });\n }\n catch (error) {\n resetActiveSignInState();\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;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,oBAAoB,CAAC,KAAK,EAAE;AAClD,IAAI,MAAM,UAAU,GA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;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":"signInWithCustomAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithCustomAuth.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleCustomAuthFlowWithoutSRP, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { retryOnResourceNotFoundException } from '../utils/retryOnResourceNotFoundException';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\n/**\n * Signs a user in using a custom authentication flow without password\n *\n * @param input - The SignInWithCustomAuthInput object\n * @returns AuthSignInResult\n * @throws service: {@link InitiateAuthException } - Cognito service errors thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws SignInWithCustomAuthOutput - Thrown when the token provider config is invalid.\n */\nexport async function signInWithCustomAuth(input) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITHOUT_SRP',\n };\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!password, AuthValidationErrorCode.CustomAuthSignInPassword);\n try {\n const { ChallengeName: retriedChallengeName, ChallengeParameters: retiredChallengeParameters, AuthenticationResult, Session, } = await retryOnResourceNotFoundException(handleCustomAuthFlowWithoutSRP, [username, metadata, authConfig, tokenOrchestrator], username, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: retriedChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\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: retriedChallengeName,\n challengeParameters: retiredChallengeParameters,\n });\n }\n catch (error) {\n resetActiveSignInState();\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;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,oBAAoB,CAAC,KAAK,EAAE;AAClD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,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AoB,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,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,sBAAsB,EAAE;AAChC,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":"signInWithCustomSRPAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithCustomSRPAuth.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleCustomSRPAuthFlow, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\n/**\n * Signs a user in using a custom authentication flow with SRP\n *\n * @param input - The SignInWithCustomSRPAuthInput object\n * @returns SignInWithCustomSRPAuthOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito\n * service errors thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithCustomSRPAuth(input) {\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITH_SRP',\n };\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await handleCustomSRPAuthFlow(username, password, metadata, authConfig, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\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 resetActiveSignInState();\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;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,uBAAuB,CAAC,KAAK,EAAE;AACrD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK;AACjD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,iBAAiB;AACvC,KAAK;AACL,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,QAAQ,GAAG,OAAO,EAAE,cAAc;AAC5C,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,OAAO,GAAG,GAAG,MAAM,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,CAAC;AACnO,QAAQ,MAAM,cAAc,GAAG,uBAAuB,CAAC,QAAQ,CAAC;AAChE;AACA,QAAQ,oBAAoB,CAAC;AAC7B,YAAY,aAAa,EAAE,OAAO;AAClC,YAAY,QAAQ,EAAE,cAAc;AACpC,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,aAAa;AACzB,SAAS,CAAC;AACV,QAAQ,IAAI,oBAAoB,EAAE;AAClC,YAAY,MAAM,kBAAkB,CAAC;AACrC,gBAAgB,QAAQ,EAAE,cAAc;AACxC,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":"signInWithCustomSRPAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithCustomSRPAuth.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleCustomSRPAuthFlow, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\n/**\n * Signs a user in using a custom authentication flow with SRP\n *\n * @param input - The SignInWithCustomSRPAuthInput object\n * @returns SignInWithCustomSRPAuthOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito\n * service errors thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithCustomSRPAuth(input) {\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITH_SRP',\n };\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await handleCustomSRPAuthFlow(username, password, metadata, authConfig, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\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 resetActiveSignInState();\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;AAYA;AACA;AACA;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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,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,sBAAsB,EAAE;AAChC,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":"signInWithRedirect.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithRedirect.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, assertOAuthConfig, assertTokenProviderConfig, isBrowser, urlSafeEncode, } from '@aws-amplify/core/internals/utils';\nimport '../utils/oauth/enableOAuthListener';\nimport { cognitoHostedUIIdentityProviderMap } from '../types/models';\nimport { getAuthUserAgentValue, openAuthSession } from '../../../utils';\nimport { assertUserNotAuthenticated } from '../utils/signInHelpers';\nimport { completeOAuthFlow, generateCodeVerifier, generateState, getRedirectUrl, handleFailure, oAuthStore, } from '../utils/oauth';\nimport { createOAuthError } from '../utils/oauth/createOAuthError';\nimport { listenForOAuthFlowCancellation } from '../utils/oauth/cancelOAuthFlow';\n/**\n * Signs in a user with OAuth. Redirects the application to an Identity Provider.\n *\n * @param input - The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI\n *\n * @throws AuthTokenConfigException - Thrown when the user pool config is invalid.\n * @throws OAuthNotConfigureException - Thrown when the oauth config is invalid.\n */\nexport async function signInWithRedirect(input) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n assertOAuthConfig(authConfig);\n oAuthStore.setAuthConfig(authConfig);\n await assertUserNotAuthenticated();\n let provider = 'COGNITO'; // Default\n if (typeof input?.provider === 'string') {\n provider = cognitoHostedUIIdentityProviderMap[input.provider];\n }\n else if (input?.provider?.custom) {\n provider = input.provider.custom;\n }\n return oauthSignIn({\n oauthConfig: authConfig.loginWith.oauth,\n clientId: authConfig.userPoolClientId,\n provider,\n customState: input?.customState,\n preferPrivateSession: input?.options?.preferPrivateSession,\n options: {\n loginHint: input?.options?.loginHint,\n lang: input?.options?.lang,\n nonce: input?.options?.nonce,\n },\n });\n}\nconst oauthSignIn = async ({ oauthConfig, provider, clientId, customState, preferPrivateSession, options, }) => {\n const { domain, redirectSignIn, responseType, scopes } = oauthConfig;\n const { loginHint, lang, nonce } = options ?? {};\n const randomState = generateState();\n /* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito\n single-encodes/decodes url on first sign in and double-encodes/decodes url\n when user already signed in. Using encodeURIComponent, Base32, Base64 add\n characters % or = which on further encoding becomes unsafe. '=' create issue\n for parsing query params.\n Refer: https://github.com/aws-amplify/amplify-js/issues/5218 */\n const state = customState\n ? `${randomState}-${urlSafeEncode(customState)}`\n : randomState;\n const { value, method, toCodeChallenge } = generateCodeVerifier(128);\n const redirectUri = getRedirectUrl(oauthConfig.redirectSignIn);\n if (isBrowser())\n oAuthStore.storeOAuthInFlight(true);\n oAuthStore.storeOAuthState(state);\n oAuthStore.storePKCE(value);\n const queryString = Object.entries({\n redirect_uri: redirectUri,\n response_type: responseType,\n client_id: clientId,\n identity_provider: provider,\n scope: scopes.join(' '),\n // eslint-disable-next-line camelcase\n ...(loginHint && { login_hint: loginHint }),\n ...(lang && { lang }),\n ...(nonce && { nonce }),\n state,\n ...(responseType === 'code' && {\n code_challenge: toCodeChallenge(),\n code_challenge_method: method,\n }),\n })\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join('&');\n // TODO(v6): use URL object instead\n const oAuthUrl = `https://${domain}/oauth2/authorize?${queryString}`;\n // this will only take effect in the following scenarios:\n // 1. the user cancels the OAuth flow on web via back button, and\n // 2. when bfcache is enabled\n listenForOAuthFlowCancellation(oAuthStore);\n // the following is effective only in react-native as openAuthSession resolves only in react-native\n const { type, error, url } = (await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ??\n {};\n try {\n if (type === 'error') {\n throw createOAuthError(String(error));\n }\n if (type === 'success' && url) {\n await completeOAuthFlow({\n currentUrl: url,\n clientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: getAuthUserAgentValue(AuthAction.SignInWithRedirect),\n preferPrivateSession,\n });\n }\n }\n catch (err) {\n await handleFailure(err);\n // rethrow the error so it can be caught by `await signInWithRedirect()` in react-native\n throw err;\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,KAAK,EAAE;AAChD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,iBAAiB,CAAC,UAAU,CAAC;AACjC,IAAI,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC;AACxC,IAAI,MAAM,0BAA0B,EAAE;AACtC,IAAI,IAAI,QAAQ,GAAG,SAAS,CAAC;AAC7B,IAAI,IAAI,OAAO,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE;AAC7C,QAAQ,QAAQ,GAAG,kCAAkC,CAAC,KAAK,CAAC,QAAQ,CAAC;AACrE;
|
|
1
|
+
{"version":3,"file":"signInWithRedirect.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithRedirect.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, assertOAuthConfig, assertTokenProviderConfig, isBrowser, urlSafeEncode, } from '@aws-amplify/core/internals/utils';\nimport '../utils/oauth/enableOAuthListener';\nimport { cognitoHostedUIIdentityProviderMap } from '../types/models';\nimport { getAuthUserAgentValue, openAuthSession } from '../../../utils';\nimport { assertUserNotAuthenticated } from '../utils/signInHelpers';\nimport { completeOAuthFlow, generateCodeVerifier, generateState, getRedirectUrl, handleFailure, oAuthStore, } from '../utils/oauth';\nimport { createOAuthError } from '../utils/oauth/createOAuthError';\nimport { listenForOAuthFlowCancellation } from '../utils/oauth/cancelOAuthFlow';\n/**\n * Signs in a user with OAuth. Redirects the application to an Identity Provider.\n *\n * @param input - The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI\n *\n * @throws AuthTokenConfigException - Thrown when the user pool config is invalid.\n * @throws OAuthNotConfigureException - Thrown when the oauth config is invalid.\n */\nexport async function signInWithRedirect(input) {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n assertOAuthConfig(authConfig);\n oAuthStore.setAuthConfig(authConfig);\n await assertUserNotAuthenticated();\n let provider = 'COGNITO'; // Default\n if (typeof input?.provider === 'string') {\n provider = cognitoHostedUIIdentityProviderMap[input.provider];\n }\n else if (input?.provider?.custom) {\n provider = input.provider.custom;\n }\n return oauthSignIn({\n oauthConfig: authConfig.loginWith.oauth,\n clientId: authConfig.userPoolClientId,\n provider,\n customState: input?.customState,\n preferPrivateSession: input?.options?.preferPrivateSession,\n options: {\n loginHint: input?.options?.loginHint,\n lang: input?.options?.lang,\n nonce: input?.options?.nonce,\n },\n });\n}\nconst oauthSignIn = async ({ oauthConfig, provider, clientId, customState, preferPrivateSession, options, }) => {\n const { domain, redirectSignIn, responseType, scopes } = oauthConfig;\n const { loginHint, lang, nonce } = options ?? {};\n const randomState = generateState();\n /* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito\n single-encodes/decodes url on first sign in and double-encodes/decodes url\n when user already signed in. Using encodeURIComponent, Base32, Base64 add\n characters % or = which on further encoding becomes unsafe. '=' create issue\n for parsing query params.\n Refer: https://github.com/aws-amplify/amplify-js/issues/5218 */\n const state = customState\n ? `${randomState}-${urlSafeEncode(customState)}`\n : randomState;\n const { value, method, toCodeChallenge } = generateCodeVerifier(128);\n const redirectUri = getRedirectUrl(oauthConfig.redirectSignIn);\n if (isBrowser())\n oAuthStore.storeOAuthInFlight(true);\n oAuthStore.storeOAuthState(state);\n oAuthStore.storePKCE(value);\n const queryString = Object.entries({\n redirect_uri: redirectUri,\n response_type: responseType,\n client_id: clientId,\n identity_provider: provider,\n scope: scopes.join(' '),\n // eslint-disable-next-line camelcase\n ...(loginHint && { login_hint: loginHint }),\n ...(lang && { lang }),\n ...(nonce && { nonce }),\n state,\n ...(responseType === 'code' && {\n code_challenge: toCodeChallenge(),\n code_challenge_method: method,\n }),\n })\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join('&');\n // TODO(v6): use URL object instead\n const oAuthUrl = `https://${domain}/oauth2/authorize?${queryString}`;\n // this will only take effect in the following scenarios:\n // 1. the user cancels the OAuth flow on web via back button, and\n // 2. when bfcache is enabled\n listenForOAuthFlowCancellation(oAuthStore);\n // the following is effective only in react-native as openAuthSession resolves only in react-native\n const { type, error, url } = (await openAuthSession(oAuthUrl, redirectSignIn, preferPrivateSession)) ??\n {};\n try {\n if (type === 'error') {\n throw createOAuthError(String(error));\n }\n if (type === 'success' && url) {\n await completeOAuthFlow({\n currentUrl: url,\n clientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: getAuthUserAgentValue(AuthAction.SignInWithRedirect),\n preferPrivateSession,\n });\n }\n }\n catch (err) {\n await handleFailure(err);\n // rethrow the error so it can be caught by `await signInWithRedirect()` in react-native\n throw err;\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,KAAK,EAAE;AAChD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,iBAAiB,CAAC,UAAU,CAAC;AACjC,IAAI,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC;AACxC,IAAI,MAAM,0BAA0B,EAAE;AACtC,IAAI,IAAI,QAAQ,GAAG,SAAS,CAAC;AAC7B,IAAI,IAAI,OAAO,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE;AAC7C,QAAQ,QAAQ,GAAG,kCAAkC,CAAC,KAAK,CAAC,QAAQ,CAAC;AACrE,IAAI;AACJ,SAAS,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE;AACtC,QAAQ,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM;AACxC,IAAI;AACJ,IAAI,OAAO,WAAW,CAAC;AACvB,QAAQ,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK;AAC/C,QAAQ,QAAQ,EAAE,UAAU,CAAC,gBAAgB;AAC7C,QAAQ,QAAQ;AAChB,QAAQ,WAAW,EAAE,KAAK,EAAE,WAAW;AACvC,QAAQ,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,oBAAoB;AA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AAgB,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,kBAAkB,CAAC;AACpF,gBAAgB,oBAAoB;AACpC,aAAa,CAAC;AACd,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,aAAa,CAAC,GAAG,CAAC;AAChC;AACA,QAAQ,MAAM,GAAG;AACjB,IAAI;AACJ,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithSRP.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithSRP.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleUserSRPAuthFlow, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in\n *\n * @param input - The SignInWithSRPInput object\n * @returns SignInWithSRPOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito service errors\n * thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithSRP(input) {\n const { username, password } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_SRP_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const clientMetaData = input.options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await handleUserSRPAuthFlow(username, password, clientMetaData, authConfig, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\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 resetAutoSignIn();\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 resetActiveSignInState();\n resetAutoSignIn();\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;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK;AACxC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,Q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AAE;AAC5C,YAAY,eAAe,EAAE;AAC7B,YAAY,OAAO;AACnB,gBAAgB,UAAU,EAAE,IAAI;AAChC,gBAAgB,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAChD,aAAa;AACb;
|
|
1
|
+
{"version":3,"file":"signInWithSRP.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithSRP.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleUserSRPAuthFlow, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in\n *\n * @param input - The SignInWithSRPInput object\n * @returns SignInWithSRPOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito service errors\n * thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithSRP(input) {\n const { username, password } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_SRP_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const clientMetaData = input.options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await handleUserSRPAuthFlow(username, password, clientMetaData, authConfig, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\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 resetAutoSignIn();\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 resetActiveSignInState();\n resetAutoSignIn();\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;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK;AACxC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,eAAe;AACrC,KAAK;AACL,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,cAAc,GAAG,KAAK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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,sBAAsB,EAAE;AAChC,QAAQ,eAAe,EAAE;AACzB,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":"signInWithUserAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithUserAuth.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, } from '../utils/signInHelpers';\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { handleUserAuthFlow, } from '../../../client/flows/userAuth/handleUserAuthFlow';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in through a registered email or phone number without a password by by receiving and entering an OTP.\n *\n * @param input - The SignInWithUserAuthInput object\n * @returns SignInWithUserAuthOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito service errors\n * thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password -- needs to change\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithUserAuth(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const clientMetaData = options?.clientMetadata;\n const preferredChallenge = options?.preferredChallenge;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n try {\n const handleUserAuthFlowInput = {\n username,\n config: authConfig,\n tokenOrchestrator,\n clientMetadata: clientMetaData,\n preferredChallenge,\n password,\n };\n const autoSignInStoreState = autoSignInStore.getState();\n if (autoSignInStoreState.active &&\n autoSignInStoreState.username === username) {\n handleUserAuthFlowInput.session = autoSignInStoreState.session;\n }\n const response = await handleUserAuthFlow(handleUserAuthFlowInput);\n const activeUsername = getActiveSignInUsername(username);\n setActiveSignInState({\n signInSession: response.Session,\n username: activeUsername,\n challengeName: response.ChallengeName,\n signInDetails,\n });\n if (response.AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\n ...response.AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: response.AuthenticationResult.NewDeviceMetadata,\n accessToken: response.AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n resetActiveSignInState();\n await dispatchSignedInHubEvent();\n resetAutoSignIn();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: response.ChallengeName,\n challengeParameters: response.ChallengeParameters,\n availableChallenges: 'AvailableChallenges' in response\n ? response.AvailableChallenges\n : undefined,\n });\n }\n catch (error) {\n resetActiveSignInState();\n resetAutoSignIn();\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;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,KAAK,EAAE;AAChD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,WAAW;AACjC,KAAK;AACL,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc;AAClD,IAAI,MAAM,kBAAkB,GAAG,OAAO,EAAE,kBAAkB;AAC1D,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,IAAI;AACR,QAAQ,MAAM,uBAAuB,GAAG;AACxC,YAAY,QAAQ;AACpB,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,iBAAiB;AAC7B,YAAY,cAAc,EAAE,cAAc;AAC1C,YAAY,kBAAkB;AAC9B,YAAY,QAAQ;AACpB,SAAS;AACT,QAAQ,MAAM,oBAAoB,GAAG,eAAe,CAAC,QAAQ,EAAE;AAC/D,QAAQ,IAAI,oBAAoB,CAAC,MAAM;AACvC,YAAY,oBAAoB,CAAC,QAAQ,KAAK,QAAQ,EAAE;AACxD,YAAY,uBAAuB,CAAC,OAAO,GAAG,oBAAoB,CAAC,OAAO;AAC1E;
|
|
1
|
+
{"version":3,"file":"signInWithUserAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithUserAuth.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, } from '../utils/signInHelpers';\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { handleUserAuthFlow, } from '../../../client/flows/userAuth/handleUserAuthFlow';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in through a registered email or phone number without a password by by receiving and entering an OTP.\n *\n * @param input - The SignInWithUserAuthInput object\n * @returns SignInWithUserAuthOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito service errors\n * thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password -- needs to change\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithUserAuth(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const clientMetaData = options?.clientMetadata;\n const preferredChallenge = options?.preferredChallenge;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n try {\n const handleUserAuthFlowInput = {\n username,\n config: authConfig,\n tokenOrchestrator,\n clientMetadata: clientMetaData,\n preferredChallenge,\n password,\n };\n const autoSignInStoreState = autoSignInStore.getState();\n if (autoSignInStoreState.active &&\n autoSignInStoreState.username === username) {\n handleUserAuthFlowInput.session = autoSignInStoreState.session;\n }\n const response = await handleUserAuthFlow(handleUserAuthFlowInput);\n const activeUsername = getActiveSignInUsername(username);\n setActiveSignInState({\n signInSession: response.Session,\n username: activeUsername,\n challengeName: response.ChallengeName,\n signInDetails,\n });\n if (response.AuthenticationResult) {\n await cacheCognitoTokens({\n username: activeUsername,\n ...response.AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: response.AuthenticationResult.NewDeviceMetadata,\n accessToken: response.AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n resetActiveSignInState();\n await dispatchSignedInHubEvent();\n resetAutoSignIn();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: response.ChallengeName,\n challengeParameters: response.ChallengeParameters,\n availableChallenges: 'AvailableChallenges' in response\n ? response.AvailableChallenges\n : undefined,\n });\n }\n catch (error) {\n resetActiveSignInState();\n resetAutoSignIn();\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;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,KAAK,EAAE;AAChD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,WAAW;AACjC,KAA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AAgB,EAAE,UAAU,CAAC,gBAAgB;AACjE,oBAAoB,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB;AACtF,oBAAoB,WAAW,EAAE,QAAQ,CAAC,oBAAoB,CAAC,WAAW;AAC1E,iBAAiB,CAAC;AAClB,gBAAgB,aAAa;AAC7B,aAAa,CAAC;AACd,YAAY,sBAAsB,EAAE;AACpC,YAAY,MAAM,wBAAwB,EAAE;AAC5C,YAAY,eAAe,EAAE;AAC7B,YAAY,OAAO;AACnB,gBAAgB,UAAU,EAAE,IAAI;AAChC,gBAAgB,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAChD,aAAa;AACb,QAAQ;AACR,QAAQ,OAAO,eAAe,CAAC;AAC/B,YAAY,aAAa,EAAE,QAAQ,CAAC,aAAa;AACjD,YAAY,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;AAC7D,YAAY,mBAAmB,EAAE,qBAAqB,IAAI;AAC1D,kBAAkB,QAAQ,CAAC;AAC3B,kBAAkB,SAAS;AAC3B,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,sBAAsB,EAAE;AAChC,QAAQ,eAAe,EAAE;AACzB,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":"signInWithUserPassword.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithUserPassword.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleUserPasswordAuthFlow, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { retryOnResourceNotFoundException } from '../utils/retryOnResourceNotFoundException';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in using USER_PASSWORD_AUTH AuthFlowType\n *\n * @param input - The SignInWithUserPasswordInput object\n * @returns SignInWithUserPasswordOutput\n * @throws service: {@link InitiateAuthException } - Cognito service error thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithUserPassword(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_PASSWORD_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: retiredChallengeName, ChallengeParameters: retriedChallengeParameters, AuthenticationResult, Session, } = await retryOnResourceNotFoundException(handleUserPasswordAuthFlow, [username, password, metadata, authConfig, tokenOrchestrator], username, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: retiredChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n ...AuthenticationResult,\n username: activeUsername,\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 resetAutoSignIn();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: retiredChallengeName,\n challengeParameters: retriedChallengeParameters,\n });\n }\n catch (error) {\n resetActiveSignInState();\n resetAutoSignIn();\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;AACO,eAAe,sBAAsB,CAAC,KAAK,EAAE;AACpD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,oBAAoB;AAC1C,KAAK;AACL,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,QAAQ,GAAG,OAAO,EAAE,cAAc;AAC5C,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,OAAO,GAAG,GAAG,MAAM,gCAAgC,CAAC,0BAA0B,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,iBAAiB,CAAC;AACvS,QAAQ,MAAM,cAAc,GAAG,uBAAuB,CAAC,QAAQ,CAAC;AAChE;AACA,QAAQ,oBAAoB,CAAC;AAC7B,YAAY,aAAa,EAAE,OAAO;AAClC,YAAY,QAAQ,EAAE,cAAc;AACpC,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,aAAa;AACzB,SAAS,CAAC;AACV,QAAQ,IAAI,oBAAoB,EAAE;AAClC,YAAY,MAAM,kBAAkB,CAAC;AACrC,gBAAgB,GAAG,oBAAoB;AACvC,gBAAgB,QAAQ,EAAE,cAAc;AACxC,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,eAAe,EAAE;AAC7B,YAAY,OAAO;AACnB,gBAAgB,UAAU,EAAE,IAAI;AAChC,gBAAgB,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAChD,aAAa;AACb;
|
|
1
|
+
{"version":3,"file":"signInWithUserPassword.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithUserPassword.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 { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { getActiveSignInUsername, getSignInResult, getSignInResultFromError, handleUserPasswordAuthFlow, } from '../utils/signInHelpers';\nimport { resetActiveSignInState, setActiveSignInState, } from '../../../client/utils/store/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\nimport { retryOnResourceNotFoundException } from '../utils/retryOnResourceNotFoundException';\nimport { getNewDeviceMetadata } from '../utils/getNewDeviceMetadata';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in using USER_PASSWORD_AUTH AuthFlowType\n *\n * @param input - The SignInWithUserPasswordInput object\n * @returns SignInWithUserPasswordOutput\n * @throws service: {@link InitiateAuthException } - Cognito service error thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithUserPassword(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_PASSWORD_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: retiredChallengeName, ChallengeParameters: retriedChallengeParameters, AuthenticationResult, Session, } = await retryOnResourceNotFoundException(handleUserPasswordAuthFlow, [username, password, metadata, authConfig, tokenOrchestrator], username, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: retiredChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await cacheCognitoTokens({\n ...AuthenticationResult,\n username: activeUsername,\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 resetAutoSignIn();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: retiredChallengeName,\n challengeParameters: retriedChallengeParameters,\n });\n }\n catch (error) {\n resetActiveSignInState();\n resetAutoSignIn();\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;AACO,eAAe,sBAAsB,CAAC,KAAK,EAAE;AACpD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,oBAAoB;AAC1C,KAAK;AACL,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,QAAQ,GAAG,OAAO,EAAE,cAAc;AAC5C,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAA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AAE;AAClB,QAAQ,sBAAsB,EAAE;AAChC,QAAQ,eAAe,EAAE;AACzB,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":"signOut.mjs","sources":["../../../../../src/providers/cognito/apis/signOut.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, ConsoleLogger, Hub, clearCredentials, defaultStorage, } from '@aws-amplify/core';\nimport { AMPLIFY_SYMBOL, AuthAction, assertOAuthConfig, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens, assertAuthTokensWithRefreshToken, } from '../utils/types';\nimport { handleOAuthSignOut } from '../utils/oauth';\nimport { DefaultOAuthStore } from '../utils/signInWithRedirectStore';\nimport { AuthError } from '../../../errors/AuthError';\nimport { OAUTH_SIGNOUT_EXCEPTION } from '../../../errors/constants';\nimport { createGlobalSignOutClient, createRevokeTokenClient, } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nconst logger = new ConsoleLogger('Auth');\n/**\n * Signs a user out\n *\n * @param input - The SignOutInput object\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signOut(input) {\n const cognitoConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(cognitoConfig);\n if (input?.global) {\n await globalSignOut(cognitoConfig);\n }\n else {\n await clientSignOut(cognitoConfig);\n }\n let hasOAuthConfig;\n try {\n assertOAuthConfig(cognitoConfig);\n hasOAuthConfig = true;\n }\n catch (err) {\n hasOAuthConfig = false;\n }\n if (hasOAuthConfig) {\n const oAuthStore = new DefaultOAuthStore(defaultStorage);\n oAuthStore.setAuthConfig(cognitoConfig);\n const { type } = (await handleOAuthSignOut(cognitoConfig, oAuthStore, tokenOrchestrator, input?.oauth?.redirectUrl)) ?? {};\n if (type === 'error') {\n throw new AuthError({\n name: OAUTH_SIGNOUT_EXCEPTION,\n message: `An error occurred when attempting to log out from OAuth provider.`,\n });\n }\n }\n else {\n // complete sign out\n tokenOrchestrator.clearTokens();\n await clearCredentials();\n Hub.dispatch('auth', { event: 'signedOut' }, 'Auth', AMPLIFY_SYMBOL);\n }\n}\nasync function clientSignOut(cognitoConfig) {\n try {\n const { userPoolEndpoint, userPoolId, userPoolClientId } = cognitoConfig;\n const authTokens = await tokenOrchestrator.getTokenStore().loadTokens();\n assertAuthTokensWithRefreshToken(authTokens);\n if (isSessionRevocable(authTokens.accessToken)) {\n const revokeToken = createRevokeTokenClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await revokeToken({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignOut),\n }, {\n ClientId: userPoolClientId,\n Token: authTokens.refreshToken,\n });\n }\n }\n catch (err) {\n // this shouldn't throw\n logger.debug('Client signOut error caught but will proceed with token removal');\n }\n}\nasync function globalSignOut(cognitoConfig) {\n try {\n const { userPoolEndpoint, userPoolId } = cognitoConfig;\n const authTokens = await tokenOrchestrator.getTokenStore().loadTokens();\n assertAuthTokens(authTokens);\n const globalSignOutClient = createGlobalSignOutClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await globalSignOutClient({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignOut),\n }, {\n AccessToken: authTokens.accessToken.toString(),\n });\n }\n catch (err) {\n // it should not throw\n logger.debug('Global signOut error caught but will proceed with token removal');\n }\n}\nconst isSessionRevocable = (token) => !!token?.payload?.origin_jti;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAaA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,OAAO,CAAC,KAAK,EAAE;AACrC,IAAI,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AAC3D,IAAI,yBAAyB,CAAC,aAAa,CAAC;AAC5C,IAAI,IAAI,KAAK,EAAE,MAAM,EAAE;AACvB,QAAQ,MAAM,aAAa,CAAC,aAAa,CAAC;AAC1C;
|
|
1
|
+
{"version":3,"file":"signOut.mjs","sources":["../../../../../src/providers/cognito/apis/signOut.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, ConsoleLogger, Hub, clearCredentials, defaultStorage, } from '@aws-amplify/core';\nimport { AMPLIFY_SYMBOL, AuthAction, assertOAuthConfig, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens, assertAuthTokensWithRefreshToken, } from '../utils/types';\nimport { handleOAuthSignOut } from '../utils/oauth';\nimport { DefaultOAuthStore } from '../utils/signInWithRedirectStore';\nimport { AuthError } from '../../../errors/AuthError';\nimport { OAUTH_SIGNOUT_EXCEPTION } from '../../../errors/constants';\nimport { createGlobalSignOutClient, createRevokeTokenClient, } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nconst logger = new ConsoleLogger('Auth');\n/**\n * Signs a user out\n *\n * @param input - The SignOutInput object\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signOut(input) {\n const cognitoConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(cognitoConfig);\n if (input?.global) {\n await globalSignOut(cognitoConfig);\n }\n else {\n await clientSignOut(cognitoConfig);\n }\n let hasOAuthConfig;\n try {\n assertOAuthConfig(cognitoConfig);\n hasOAuthConfig = true;\n }\n catch (err) {\n hasOAuthConfig = false;\n }\n if (hasOAuthConfig) {\n const oAuthStore = new DefaultOAuthStore(defaultStorage);\n oAuthStore.setAuthConfig(cognitoConfig);\n const { type } = (await handleOAuthSignOut(cognitoConfig, oAuthStore, tokenOrchestrator, input?.oauth?.redirectUrl)) ?? {};\n if (type === 'error') {\n throw new AuthError({\n name: OAUTH_SIGNOUT_EXCEPTION,\n message: `An error occurred when attempting to log out from OAuth provider.`,\n });\n }\n }\n else {\n // complete sign out\n tokenOrchestrator.clearTokens();\n await clearCredentials();\n Hub.dispatch('auth', { event: 'signedOut' }, 'Auth', AMPLIFY_SYMBOL);\n }\n}\nasync function clientSignOut(cognitoConfig) {\n try {\n const { userPoolEndpoint, userPoolId, userPoolClientId } = cognitoConfig;\n const authTokens = await tokenOrchestrator.getTokenStore().loadTokens();\n assertAuthTokensWithRefreshToken(authTokens);\n if (isSessionRevocable(authTokens.accessToken)) {\n const revokeToken = createRevokeTokenClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await revokeToken({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignOut),\n }, {\n ClientId: userPoolClientId,\n Token: authTokens.refreshToken,\n });\n }\n }\n catch (err) {\n // this shouldn't throw\n logger.debug('Client signOut error caught but will proceed with token removal');\n }\n}\nasync function globalSignOut(cognitoConfig) {\n try {\n const { userPoolEndpoint, userPoolId } = cognitoConfig;\n const authTokens = await tokenOrchestrator.getTokenStore().loadTokens();\n assertAuthTokens(authTokens);\n const globalSignOutClient = createGlobalSignOutClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await globalSignOutClient({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignOut),\n }, {\n AccessToken: authTokens.accessToken.toString(),\n });\n }\n catch (err) {\n // it should not throw\n logger.debug('Global signOut error caught but will proceed with token removal');\n }\n}\nconst isSessionRevocable = (token) => !!token?.payload?.origin_jti;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAaA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,OAAO,CAAC,KAAK,EAAE;AACrC,IAAI,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AAC3D,IAAI,yBAAyB,CAAC,aAAa,CAAC;AAC5C,IAAI,IAAI,KAAK,EAAE,MAAM,EAAE;AACvB,QAAQ,MAAM,aAAa,CAAC,aAAa,CAAC;AAC1C,IAAI;AACJ,SAAS;AACT,QAAQ,MAAM,aAAa,CAAC,aAAa,CAAC;AAC1C,IAAI;AACJ,IAAI,IAAI,cAAc;AACtB,IAAI,IAAI;AACR,QAAQ,iBAAiB,CAAC,aAAa,CAAC;AACxC,QAAQ,cAAc,GAAG,IAAI;AAC7B,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,cAAc,GAAG,KAAK;AAC9B,IAAI;AACJ,IAAI,IAAI,cAAc,EAAE;AACxB,QAAQ,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC;AAChE,QAAQ,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC;AAC/C,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,kBAAkB,CAAC,aAAa,EAAE,UAAU,EAAE,iBAAi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d,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB;AACA,QAAQ,MAAM,CAAC,KAAK,CAAC,iEAAiE,CAAC;AACvF,IAAI;AACJ;AACA,eAAe,aAAa,CAAC,aAAa,EAAE;AAC5C,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,aAAa;AAC9D,QAAQ,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,CAAC,UAAU,EAAE;AAC/E,QAAQ,gBAAgB,CAAC,UAAU,CAAC;AACpC,QAAQ,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAC9D,YAAY,gBAAgB,EAAE,qCAAqC,CAAC;AACpE,gBAAgB,gBAAgB,EAAE,gBAAgB;AAClD,aAAa,CAAC;AACd,SAAS,CAAC;AACV,QAAQ,MAAM,mBAAmB,CAAC;AAClC,YAAY,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACvD,YAAY,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC;AACrE,SAAS,EAAE;AACX,YAAY,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC,QAAQ,EAAE;AAC1D,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,GAAG,EAAE;AAChB;AACA,QAAQ,MAAM,CAAC,KAAK,CAAC,iEAAiE,CAAC;AACvF,IAAI;AACJ;AACA,MAAM,kBAAkB,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signUp.mjs","sources":["../../../../../src/providers/cognito/apis/signUp.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 { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { toAttributeType } from '../utils/apiHelpers';\nimport { autoSignInUserConfirmed, autoSignInWhenUserIsConfirmedWithLink, handleCodeAutoSignIn, } from '../utils/signUpHelpers';\nimport { getUserContextData } from '../utils/userContextData';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createSignUpClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { setAutoSignIn } from './autoSignIn';\n/**\n * Creates a user\n *\n * @param input - The SignUpInput object\n * @returns SignUpOutput\n * @throws service: {@link SignUpException } - Cognito service errors thrown during the sign-up process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signUp(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signUpVerificationMethod = authConfig?.signUpVerificationMethod ?? 'code';\n const { clientMetadata, validationData, autoSignIn } = input.options ?? {};\n assertTokenProviderConfig(authConfig);\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignUpUsername);\n const signInServiceOptions = typeof autoSignIn !== 'boolean' ? autoSignIn : undefined;\n const signInInput = {\n username,\n options: signInServiceOptions,\n };\n // if the authFlowType is 'CUSTOM_WITHOUT_SRP' then we don't include the password\n if (signInServiceOptions?.authFlowType !== 'CUSTOM_WITHOUT_SRP') {\n signInInput.password = password;\n }\n const { userPoolId, userPoolClientId, userPoolEndpoint } = authConfig;\n const signUpClient = createSignUpClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const signUpClientInput = {\n Username: username,\n Password: undefined,\n UserAttributes: options?.userAttributes && toAttributeType(options?.userAttributes),\n ClientMetadata: clientMetadata,\n ValidationData: validationData && toAttributeType(validationData),\n ClientId: userPoolClientId,\n UserContextData: getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n }),\n };\n if (password) {\n signUpClientInput.Password = password;\n }\n const { UserSub: userId, CodeDeliveryDetails: cdd, UserConfirmed: userConfirmed, Session: session, } = await signUpClient({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignUp),\n }, signUpClientInput);\n if (signInServiceOptions || autoSignIn === true) {\n autoSignInStore.dispatch({ type: 'START' });\n autoSignInStore.dispatch({ type: 'SET_USERNAME', value: username });\n autoSignInStore.dispatch({ type: 'SET_SESSION', value: session });\n }\n const codeDeliveryDetails = {\n destination: cdd?.Destination,\n deliveryMedium: cdd?.DeliveryMedium,\n attributeName: cdd?.AttributeName,\n };\n const isSignUpComplete = !!userConfirmed;\n const isAutoSignInStarted = autoSignInStore.getState().active;\n // Sign Up Complete\n // No Confirm Sign In Step Required\n if (isSignUpComplete) {\n if (isAutoSignInStarted) {\n setAutoSignIn(autoSignInUserConfirmed(signInInput));\n return {\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'COMPLETE_AUTO_SIGN_IN',\n },\n userId,\n };\n }\n return {\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'DONE',\n },\n userId,\n };\n }\n // Sign Up Not Complete\n // Confirm Sign Up Step Required\n if (isAutoSignInStarted) {\n // Confirmation Via Link Occurs In Separate Context\n // AutoSignIn Fn Will Initiate Polling Once Executed\n if (signUpVerificationMethod === 'link') {\n setAutoSignIn(autoSignInWhenUserIsConfirmedWithLink(signInInput));\n return {\n isSignUpComplete: false,\n nextStep: {\n signUpStep: 'COMPLETE_AUTO_SIGN_IN',\n codeDeliveryDetails,\n },\n userId,\n };\n }\n // Confirmation Via Code Occurs In Same Context\n // AutoSignIn Next Step Will Be Returned From Confirm Sign Up\n handleCodeAutoSignIn(signInInput);\n }\n return {\n isSignUpComplete: false,\n nextStep: {\n signUpStep: 'CONFIRM_SIGN_UP',\n codeDeliveryDetails,\n },\n userId,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,MAAM,CAAC,KAAK,EAAE;AACpC,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK;AACjD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,wBAAwB,GAAG,UAAU,EAAE,wBAAwB,IAAI,MAAM;AACnF,IAAI,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE;AAC9E,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAClF,IAAI,MAAM,oBAAoB,GAAG,OAAO,UAAU,KAAK,SAAS,GAAG,UAAU,GAAG,SAAS;AACzF,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,QAAQ;AAChB,QAAQ,OAAO,EAAE,oBAAoB;AACrC,KAAK;AACL;AACA,IAAI,IAAI,oBAAoB,EAAE,YAAY,KAAK,oBAAoB,EAAE;AACrE,QAAQ,WAAW,CAAC,QAAQ,GAAG,QAAQ;AACvC;
|
|
1
|
+
{"version":3,"file":"signUp.mjs","sources":["../../../../../src/providers/cognito/apis/signUp.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 { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { toAttributeType } from '../utils/apiHelpers';\nimport { autoSignInUserConfirmed, autoSignInWhenUserIsConfirmedWithLink, handleCodeAutoSignIn, } from '../utils/signUpHelpers';\nimport { getUserContextData } from '../utils/userContextData';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createSignUpClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { autoSignInStore } from '../../../client/utils/store';\nimport { setAutoSignIn } from './autoSignIn';\n/**\n * Creates a user\n *\n * @param input - The SignUpInput object\n * @returns SignUpOutput\n * @throws service: {@link SignUpException } - Cognito service errors thrown during the sign-up process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signUp(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signUpVerificationMethod = authConfig?.signUpVerificationMethod ?? 'code';\n const { clientMetadata, validationData, autoSignIn } = input.options ?? {};\n assertTokenProviderConfig(authConfig);\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignUpUsername);\n const signInServiceOptions = typeof autoSignIn !== 'boolean' ? autoSignIn : undefined;\n const signInInput = {\n username,\n options: signInServiceOptions,\n };\n // if the authFlowType is 'CUSTOM_WITHOUT_SRP' then we don't include the password\n if (signInServiceOptions?.authFlowType !== 'CUSTOM_WITHOUT_SRP') {\n signInInput.password = password;\n }\n const { userPoolId, userPoolClientId, userPoolEndpoint } = authConfig;\n const signUpClient = createSignUpClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const signUpClientInput = {\n Username: username,\n Password: undefined,\n UserAttributes: options?.userAttributes && toAttributeType(options?.userAttributes),\n ClientMetadata: clientMetadata,\n ValidationData: validationData && toAttributeType(validationData),\n ClientId: userPoolClientId,\n UserContextData: getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n }),\n };\n if (password) {\n signUpClientInput.Password = password;\n }\n const { UserSub: userId, CodeDeliveryDetails: cdd, UserConfirmed: userConfirmed, Session: session, } = await signUpClient({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignUp),\n }, signUpClientInput);\n if (signInServiceOptions || autoSignIn === true) {\n autoSignInStore.dispatch({ type: 'START' });\n autoSignInStore.dispatch({ type: 'SET_USERNAME', value: username });\n autoSignInStore.dispatch({ type: 'SET_SESSION', value: session });\n }\n const codeDeliveryDetails = {\n destination: cdd?.Destination,\n deliveryMedium: cdd?.DeliveryMedium,\n attributeName: cdd?.AttributeName,\n };\n const isSignUpComplete = !!userConfirmed;\n const isAutoSignInStarted = autoSignInStore.getState().active;\n // Sign Up Complete\n // No Confirm Sign In Step Required\n if (isSignUpComplete) {\n if (isAutoSignInStarted) {\n setAutoSignIn(autoSignInUserConfirmed(signInInput));\n return {\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'COMPLETE_AUTO_SIGN_IN',\n },\n userId,\n };\n }\n return {\n isSignUpComplete: true,\n nextStep: {\n signUpStep: 'DONE',\n },\n userId,\n };\n }\n // Sign Up Not Complete\n // Confirm Sign Up Step Required\n if (isAutoSignInStarted) {\n // Confirmation Via Link Occurs In Separate Context\n // AutoSignIn Fn Will Initiate Polling Once Executed\n if (signUpVerificationMethod === 'link') {\n setAutoSignIn(autoSignInWhenUserIsConfirmedWithLink(signInInput));\n return {\n isSignUpComplete: false,\n nextStep: {\n signUpStep: 'COMPLETE_AUTO_SIGN_IN',\n codeDeliveryDetails,\n },\n userId,\n };\n }\n // Confirmation Via Code Occurs In Same Context\n // AutoSignIn Next Step Will Be Returned From Confirm Sign Up\n handleCodeAutoSignIn(signInInput);\n }\n return {\n isSignUpComplete: false,\n nextStep: {\n signUpStep: 'CONFIRM_SIGN_UP',\n codeDeliveryDetails,\n },\n userId,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;A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ference.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 { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens } from '../utils/types';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createSetUserMFAPreferenceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Updates the MFA preference of the user.\n *\n * @param input - The UpdateMFAPreferenceInput object.\n * @throws -{@link SetUserMFAPreferenceException } - Service error thrown when the MFA preference cannot be updated.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function updateMFAPreference(input) {\n const { sms, totp, email } = input;\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 setUserMFAPreference = createSetUserMFAPreferenceClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await setUserMFAPreference({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.UpdateMFAPreference),\n }, {\n AccessToken: tokens.accessToken.toString(),\n SMSMfaSettings: getMFASettings(sms),\n SoftwareTokenMfaSettings: getMFASettings(totp),\n EmailMfaSettings: getMFASettings(email),\n });\n}\nexport function getMFASettings(mfaPreference) {\n if (mfaPreference === 'DISABLED') {\n return {\n Enabled: false,\n };\n }\n else if (mfaPreference === 'PREFERRED') {\n return {\n Enabled: true,\n PreferredMfa: true,\n };\n }\n else if (mfaPreference === 'ENABLED') {\n return {\n Enabled: true,\n };\n }\n else if (mfaPreference === 'NOT_PREFERRED') {\n return {\n Enabled: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AC1B,SAAS;AACT;
|
|
1
|
+
{"version":3,"file":"updateMFAPreference.mjs","sources":["../../../../../src/providers/cognito/apis/updateMFAPreference.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 { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokens } from '../utils/types';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createSetUserMFAPreferenceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Updates the MFA preference of the user.\n *\n * @param input - The UpdateMFAPreferenceInput object.\n * @throws -{@link SetUserMFAPreferenceException } - Service error thrown when the MFA preference cannot be updated.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function updateMFAPreference(input) {\n const { sms, totp, email } = input;\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 setUserMFAPreference = createSetUserMFAPreferenceClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await setUserMFAPreference({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.UpdateMFAPreference),\n }, {\n AccessToken: tokens.accessToken.toString(),\n SMSMfaSettings: getMFASettings(sms),\n SoftwareTokenMfaSettings: getMFASettings(totp),\n EmailMfaSettings: getMFASettings(email),\n });\n}\nexport function getMFASettings(mfaPreference) {\n if (mfaPreference === 'DISABLED') {\n return {\n Enabled: false,\n };\n }\n else if (mfaPreference === 'PREFERRED') {\n return {\n Enabled: true,\n PreferredMfa: true,\n };\n }\n else if (mfaPreference === 'ENABLED') {\n return {\n Enabled: true,\n };\n }\n else if (mfaPreference === 'NOT_PREFERRED') {\n return {\n Enabled: true,\n PreferredMfa: false,\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,mBAAmB,CAAC,KAAK,EAAE;AACjD,IAAI,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK;AACtC,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,oBAAoB,GAAG,gCAAgC,CAAC;AAClE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,oBAAoB,CAAC;AAC/B,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,mBAAmB,CAAC;AAC7E,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC;AAC3C,QAAQ,wBAAwB,EAAE,cAAc,CAAC,IAAI,CAAC;AACtD,QAAQ,gBAAgB,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/C,KAAK,CAAC;AACN;AACO,SAAS,cAAc,CAAC,aAAa,EAAE;AAC9C,IAAI,IAAI,aAAa,KAAK,UAAU,EAAE;AACtC,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,KAAK;AAC1B,SAAS;AACT,IAAI;AACJ,SAAS,IAAI,aAAa,KAAK,WAAW,EAAE;AAC5C,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS;AACT,IAAI;AACJ,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE;AAC1C,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,SAAS;AACT,IAAI;AACJ,SAAS,IAAI,aAAa,KAAK,eAAe,EAAE;AAChD,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,IAAI;AACzB,YAAY,YAAY,EAAE,KAAK;AAC/B,SAAS;AACT,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateUserAttributes.mjs","sources":["../../../../../src/providers/cognito/apis/updateUserAttributes.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 { toAttributeType } from '../utils/apiHelpers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createUpdateUserAttributesClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Updates user's attributes while authenticated.\n *\n * @param input - The UpdateUserAttributesInput object\n * @returns UpdateUserAttributesOutput\n * @throws - {@link UpdateUserAttributesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport const updateUserAttributes = async (input) => {\n const { userAttributes, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const clientMetadata = options?.clientMetadata;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession({ forceRefresh: false });\n assertAuthTokens(tokens);\n const updateUserAttributesClient = createUpdateUserAttributesClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { CodeDeliveryDetailsList } = await updateUserAttributesClient({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.UpdateUserAttributes),\n }, {\n AccessToken: tokens.accessToken.toString(),\n ClientMetadata: clientMetadata,\n UserAttributes: toAttributeType(userAttributes),\n });\n return {\n ...getConfirmedAttributes(userAttributes),\n ...getUnConfirmedAttributes(CodeDeliveryDetailsList),\n };\n};\nfunction getConfirmedAttributes(attributes) {\n const confirmedAttributes = {};\n Object.keys(attributes)?.forEach(key => {\n confirmedAttributes[key] = {\n isUpdated: true,\n nextStep: {\n updateAttributeStep: 'DONE',\n },\n };\n });\n return confirmedAttributes;\n}\nfunction getUnConfirmedAttributes(codeDeliveryDetailsList) {\n const unConfirmedAttributes = {};\n codeDeliveryDetailsList?.forEach(codeDeliveryDetails => {\n const { AttributeName, DeliveryMedium, Destination } = codeDeliveryDetails;\n if (AttributeName)\n unConfirmedAttributes[AttributeName] = {\n isUpdated: false,\n nextStep: {\n updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE',\n codeDeliveryDetails: {\n attributeName: AttributeName,\n deliveryMedium: DeliveryMedium,\n destination: Destination,\n },\n },\n };\n });\n return unConfirmedAttributes;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,oBAAoB,GAAG,OAAO,KAAK,KAAK;AACrD,IAAI,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,KAAK;AAC7C,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC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AACtB,gBAAgB,mBAAmB,EAAE,MAAM;AAC3C,aAAa;AACb,SAAS;AACT,
|
|
1
|
+
{"version":3,"file":"updateUserAttributes.mjs","sources":["../../../../../src/providers/cognito/apis/updateUserAttributes.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 { toAttributeType } from '../utils/apiHelpers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createUpdateUserAttributesClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n/**\n * Updates user's attributes while authenticated.\n *\n * @param input - The UpdateUserAttributesInput object\n * @returns UpdateUserAttributesOutput\n * @throws - {@link UpdateUserAttributesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport const updateUserAttributes = async (input) => {\n const { userAttributes, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const clientMetadata = options?.clientMetadata;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession({ forceRefresh: false });\n assertAuthTokens(tokens);\n const updateUserAttributesClient = createUpdateUserAttributesClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { CodeDeliveryDetailsList } = await updateUserAttributesClient({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.UpdateUserAttributes),\n }, {\n AccessToken: tokens.accessToken.toString(),\n ClientMetadata: clientMetadata,\n UserAttributes: toAttributeType(userAttributes),\n });\n return {\n ...getConfirmedAttributes(userAttributes),\n ...getUnConfirmedAttributes(CodeDeliveryDetailsList),\n };\n};\nfunction getConfirmedAttributes(attributes) {\n const confirmedAttributes = {};\n Object.keys(attributes)?.forEach(key => {\n confirmedAttributes[key] = {\n isUpdated: true,\n nextStep: {\n updateAttributeStep: 'DONE',\n },\n };\n });\n return confirmedAttributes;\n}\nfunction getUnConfirmedAttributes(codeDeliveryDetailsList) {\n const unConfirmedAttributes = {};\n codeDeliveryDetailsList?.forEach(codeDeliveryDetails => {\n const { AttributeName, DeliveryMedium, Destination } = codeDeliveryDetails;\n if (AttributeName)\n unConfirmedAttributes[AttributeName] = {\n isUpdated: false,\n nextStep: {\n updateAttributeStep: 'CONFIRM_ATTRIBUTE_WITH_CODE',\n codeDeliveryDetails: {\n attributeName: AttributeName,\n deliveryMedium: DeliveryMedium,\n destination: Destination,\n },\n },\n };\n });\n return unConfirmedAttributes;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,oBAAoB,GAAG,OAAO,KAAK,KAAK;AACrD,IAAI,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,KAAK;AAC7C,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc;AAClD,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,0BAA0B,GAAG,gCAAgC,CAAC;AACxE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN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6B;AACtE,oBAAoB,mBAAmB,EAAE;AACzC,wBAAwB,aAAa,EAAE,aAAa;AACpD,wBAAwB,cAAc,EAAE,cAAc;AACtD,wBAAwB,WAAW,EAAE,WAAW;AAChD,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,IAAI,CAAC,CAAC;AACN,IAAI,OAAO,qBAAqB;AAChC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityIdProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createGetIdClient } from '@aws-amplify/core';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { createCognitoIdentityPoolEndpointResolver } from '../factories';\nimport { formLoginsMap } from './utils';\n/**\n * Provides a Cognito identityId\n *\n * @param tokens - The AuthTokens received after SignIn\n * @returns string\n * @throws configuration exceptions: `InvalidIdentityPoolIdException`\n * - Auth errors that may arise from misconfiguration.\n * @throws service exceptions: {@link GetIdException }\n */\nexport async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore, }) {\n identityIdStore.setAuthConfig({ Cognito: authConfig });\n // will return null only if there is no identityId cached or if there is an error retrieving it\n const identityId = await identityIdStore.loadIdentityId();\n if (identityId) {\n return identityId.id;\n }\n const logins = tokens?.idToken\n ? formLoginsMap(tokens.idToken.toString())\n : {};\n const generatedIdentityId = await generateIdentityId(logins, authConfig);\n // Store generated identityId\n identityIdStore.storeIdentityId({\n id: generatedIdentityId,\n type: tokens ? 'primary' : 'guest',\n });\n return generatedIdentityId;\n}\nasync function generateIdentityId(logins, authConfig) {\n const identityPoolId = authConfig?.identityPoolId;\n const region = getRegionFromIdentityPoolId(identityPoolId);\n const getId = createGetIdClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API\n let idResult;\n // for a first-time user, this will return a brand new identity\n // for a returning user, this will retrieve the previous identity assocaited with the logins\n try {\n idResult = (await getId({\n region,\n }, {\n IdentityPoolId: identityPoolId,\n Logins: logins,\n })).IdentityId;\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (!idResult) {\n throw new AuthError({\n name: 'GetIdResponseException',\n message: 'Received undefined response from getId operation',\n recoverySuggestion: 'Make sure to pass a valid identityPoolId in the configuration.',\n });\n }\n return idResult;\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,EAAE;AAC1F,IAAI,eAAe,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1D;AACA,IAAI,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE;AAC7D,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,OAAO,UAAU,CAAC,EAAE;AAC5B;
|
|
1
|
+
{"version":3,"file":"IdentityIdProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createGetIdClient } from '@aws-amplify/core';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { createCognitoIdentityPoolEndpointResolver } from '../factories';\nimport { formLoginsMap } from './utils';\n/**\n * Provides a Cognito identityId\n *\n * @param tokens - The AuthTokens received after SignIn\n * @returns string\n * @throws configuration exceptions: `InvalidIdentityPoolIdException`\n * - Auth errors that may arise from misconfiguration.\n * @throws service exceptions: {@link GetIdException }\n */\nexport async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore, }) {\n identityIdStore.setAuthConfig({ Cognito: authConfig });\n // will return null only if there is no identityId cached or if there is an error retrieving it\n const identityId = await identityIdStore.loadIdentityId();\n if (identityId) {\n return identityId.id;\n }\n const logins = tokens?.idToken\n ? formLoginsMap(tokens.idToken.toString())\n : {};\n const generatedIdentityId = await generateIdentityId(logins, authConfig);\n // Store generated identityId\n identityIdStore.storeIdentityId({\n id: generatedIdentityId,\n type: tokens ? 'primary' : 'guest',\n });\n return generatedIdentityId;\n}\nasync function generateIdentityId(logins, authConfig) {\n const identityPoolId = authConfig?.identityPoolId;\n const region = getRegionFromIdentityPoolId(identityPoolId);\n const getId = createGetIdClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API\n let idResult;\n // for a first-time user, this will return a brand new identity\n // for a returning user, this will retrieve the previous identity assocaited with the logins\n try {\n idResult = (await getId({\n region,\n }, {\n IdentityPoolId: identityPoolId,\n Logins: logins,\n })).IdentityId;\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (!idResult) {\n throw new AuthError({\n name: 'GetIdResponseException',\n message: 'Received undefined response from getId operation',\n recoverySuggestion: 'Make sure to pass a valid identityPoolId in the configuration.',\n });\n }\n return idResult;\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,EAAE;AAC1F,IAAI,eAAe,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1D;AACA,IAAI,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE;AAC7D,IAAI,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C5B,YAAY,IAAI,EAAE,wBAAwB;AAC1C,YAAY,OAAO,EAAE,kDAAkD;AACvE,YAAY,kBAAkB,EAAE,gEAAgE;AAChG,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,QAAQ;AACnB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityIdStore.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig } from '@aws-amplify/core/internals/utils';\nimport { getAuthStorageKeys } from '../tokenProvider/TokenStore';\nimport { IdentityIdStorageKeys } from './types';\nconst logger = new ConsoleLogger('DefaultIdentityIdStore');\nexport class DefaultIdentityIdStore {\n setAuthConfig(authConfigParam) {\n assertIdentityPoolIdConfig(authConfigParam.Cognito);\n this.authConfig = authConfigParam;\n this._authKeys = createKeysForAuthStorage('Cognito', authConfigParam.Cognito.identityPoolId);\n }\n constructor(keyValueStorage) {\n this._authKeys = {};\n this._hasGuestIdentityId = false;\n this.keyValueStorage = keyValueStorage;\n }\n async loadIdentityId() {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n try {\n if (this._primaryIdentityId) {\n return {\n id: this._primaryIdentityId,\n type: 'primary',\n };\n }\n else {\n const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);\n if (storedIdentityId) {\n this._hasGuestIdentityId = true;\n return {\n id: storedIdentityId,\n type: 'guest',\n };\n }\n return null;\n }\n }\n catch (err) {\n logger.log('Error getting stored IdentityId.', err);\n return null;\n }\n }\n async storeIdentityId(identity) {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n if (identity.type === 'guest') {\n this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);\n // Clear in-memory storage of primary identityId\n this._primaryIdentityId = undefined;\n this._hasGuestIdentityId = true;\n }\n else {\n this._primaryIdentityId = identity.id;\n // Clear locally stored guest id\n if (this._hasGuestIdentityId) {\n this.keyValueStorage.removeItem(this._authKeys.identityId);\n this._hasGuestIdentityId = false;\n }\n }\n }\n async clearIdentityId() {\n this._primaryIdentityId = undefined;\n await this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n}\nconst createKeysForAuthStorage = (provider, identifier) => {\n return getAuthStorageKeys(IdentityIdStorageKeys)(`com.amplify.${provider}`, identifier);\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,wBAAwB,CAAC;AACnD,MAAM,sBAAsB,CAAC;AACpC,IAAI,aAAa,CAAC,eAAe,EAAE;AACnC,QAAQ,0BAA0B,CAAC,eAAe,CAAC,OAAO,CAAC;AAC3D,QAAQ,IAAI,CAAC,UAAU,GAAG,eAAe;AACzC,QAAQ,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC;AACpG;
|
|
1
|
+
{"version":3,"file":"IdentityIdStore.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig } from '@aws-amplify/core/internals/utils';\nimport { getAuthStorageKeys } from '../tokenProvider/TokenStore';\nimport { IdentityIdStorageKeys } from './types';\nconst logger = new ConsoleLogger('DefaultIdentityIdStore');\nexport class DefaultIdentityIdStore {\n setAuthConfig(authConfigParam) {\n assertIdentityPoolIdConfig(authConfigParam.Cognito);\n this.authConfig = authConfigParam;\n this._authKeys = createKeysForAuthStorage('Cognito', authConfigParam.Cognito.identityPoolId);\n }\n constructor(keyValueStorage) {\n this._authKeys = {};\n this._hasGuestIdentityId = false;\n this.keyValueStorage = keyValueStorage;\n }\n async loadIdentityId() {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n try {\n if (this._primaryIdentityId) {\n return {\n id: this._primaryIdentityId,\n type: 'primary',\n };\n }\n else {\n const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);\n if (storedIdentityId) {\n this._hasGuestIdentityId = true;\n return {\n id: storedIdentityId,\n type: 'guest',\n };\n }\n return null;\n }\n }\n catch (err) {\n logger.log('Error getting stored IdentityId.', err);\n return null;\n }\n }\n async storeIdentityId(identity) {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n if (identity.type === 'guest') {\n this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);\n // Clear in-memory storage of primary identityId\n this._primaryIdentityId = undefined;\n this._hasGuestIdentityId = true;\n }\n else {\n this._primaryIdentityId = identity.id;\n // Clear locally stored guest id\n if (this._hasGuestIdentityId) {\n this.keyValueStorage.removeItem(this._authKeys.identityId);\n this._hasGuestIdentityId = false;\n }\n }\n }\n async clearIdentityId() {\n this._primaryIdentityId = undefined;\n await this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n}\nconst createKeysForAuthStorage = (provider, identifier) => {\n return getAuthStorageKeys(IdentityIdStorageKeys)(`com.amplify.${provider}`, identifier);\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,wBAAwB,CAAC;AACnD,MAAM,sBAAsB,CAAC;AACpC,IAAI,aAAa,CAAC,eAAe,EAAE;AACnC,QAAQ,0BAA0B,CAAC,eAAe,CAAC,OAAO,CAAC;AAC3D,QAAQ,IAAI,CAAC,UAAU,GAAG,eAAe;AACzC,QAAQ,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC;AACpG,IAAI;AACJ,IAAI,WAAW,CAAC,eAAe,EAAE;AACjC,QAAQ,IAAI,CAAC,SAAS,GAAG,EAAE;AAC3B,QAAQ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YAAY,IAAI,CAAC,mBAAmB,GAAG,IAAI;AAC3C,QAAQ;AACR,aAAa;AACb,YAAY,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC,EAAE;AACjD;AACA,YAAY,IAAI,IAAI,CAAC,mBAAmB,EAAE;AAC1C,gBAAgB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;AAC1E,gBAAgB,IAAI,CAAC,mBAAmB,GAAG,KAAK;AAChD,YAAY;AACZ,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,CAAC,kBAAkB,GAAG,SAAS;AAC3C,QAAQ,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;AACxE,IAAI;AACJ;AACA,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAC3D,IAAI,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC;AAC3F,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentialsProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/credentialsProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, createGetCredentialsForIdentityClient, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { assertIdTokenInAuthTokens } from '../utils/types';\nimport { createCognitoIdentityPoolEndpointResolver } from '../factories';\nimport { cognitoIdentityIdProvider } from './IdentityIdProvider';\nimport { formLoginsMap } from './utils';\nconst logger = new ConsoleLogger('CognitoCredentialsProvider');\nconst CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nexport class CognitoAWSCredentialsAndIdentityIdProvider {\n constructor(identityIdStore) {\n this._nextCredentialsRefresh = 0;\n this._identityIdStore = identityIdStore;\n }\n async clearCredentialsAndIdentityId() {\n logger.debug('Clearing out credentials and identityId');\n this._credentialsAndIdentityId = undefined;\n await this._identityIdStore.clearIdentityId();\n }\n async clearCredentials() {\n logger.debug('Clearing out in-memory credentials');\n this._credentialsAndIdentityId = undefined;\n }\n async getCredentialsAndIdentityId(getCredentialsOptions) {\n const isAuthenticated = getCredentialsOptions.authenticated;\n const { tokens } = getCredentialsOptions;\n const { authConfig } = getCredentialsOptions;\n try {\n assertIdentityPoolIdConfig(authConfig?.Cognito);\n }\n catch {\n // No identity pool configured, skipping\n return;\n }\n if (!isAuthenticated && !authConfig.Cognito.allowGuestAccess) {\n // TODO(V6): return partial result like Native platforms\n return;\n }\n const { forceRefresh } = getCredentialsOptions;\n const tokenHasChanged = this.hasTokenChanged(tokens);\n const identityId = await cognitoIdentityIdProvider({\n tokens,\n authConfig: authConfig.Cognito,\n identityIdStore: this._identityIdStore,\n });\n // Clear cached credentials when forceRefresh is true OR the cache token has changed\n if (forceRefresh || tokenHasChanged) {\n this.clearCredentials();\n }\n if (!isAuthenticated) {\n return this.getGuestCredentials(identityId, authConfig.Cognito);\n }\n else {\n assertIdTokenInAuthTokens(tokens);\n return this.credsForOIDCTokens(authConfig.Cognito, tokens, identityId);\n }\n }\n async getGuestCredentials(identityId, authConfig) {\n // Return existing in-memory cached credentials only if it exists, is not past it's lifetime and is unauthenticated credentials\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === false) {\n logger.info('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any authenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n const getCredentialsForIdentity = createGetCredentialsForIdentityClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // use identityId to obtain guest credentials\n // save credentials in-memory\n // No logins params should be passed for guest creds:\n // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'guest',\n });\n }\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: false,\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsNotFoundException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n async credsForOIDCTokens(authConfig, authTokens, identityId) {\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === true) {\n logger.debug('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any unauthenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const logins = authTokens.idToken\n ? formLoginsMap(authTokens.idToken.toString())\n : {};\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n const getCredentialsForIdentity = createGetCredentialsForIdentityClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n Logins: logins,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n // note: the following call removes guest identityId from the persistent store (localStorage)\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'primary',\n });\n }\n // Store the credentials in-memory along with the expiration\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: true,\n associatedIdToken: authTokens.idToken?.toString(),\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n isPastTTL() {\n return this._nextCredentialsRefresh === undefined\n ? true\n : this._nextCredentialsRefresh <= Date.now();\n }\n hasTokenChanged(tokens) {\n return (!!tokens &&\n !!this._credentialsAndIdentityId?.associatedIdToken &&\n tokens.idToken?.toString() !==\n this._credentialsAndIdentityId.associatedIdToken);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAUA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,4BAA4B,CAAC;AAC9D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAChC,MAAM,0CAA0C,CAAC;AACxD,IAAI,WAAW,CAAC,eAAe,EAAE;AACjC,QAAQ,IAAI,CAAC,uBAAuB,GAAG,CAAC;AACxC,QAAQ,IAAI,CAA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AAC,UAAU;AACnE,iBAAiB;AACjB,gBAAgB,UAAU;AAC1B,aAAa;AACb,YAAY,IAAI,YAAY,CAAC,UAAU,EAAE;AACzC,gBAAgB,GAAG,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU;AACxD;AACA,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC;AACtD,oBAAoB,EAAE,EAAE,YAAY,CAAC,UAAU;AAC/C,oBAAoB,IAAI,EAAE,SAAS;AACnC,iBAAiB,CAAC;AAClB;AACA;AACA,YAAY,IAAI,CAAC,yBAAyB,GAAG;AAC7C,gBAAgB,GAAG,GAAG;AACtB,gBAAgB,oBAAoB,EAAE,IAAI;AAC1C,gBAAgB,iBAAiB,EAAE,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE;AACjE,aAAa;AACb,YAAY,OAAO,GAAG;AACtB;AACA,aAAa;AACb,YAAY,MAAM,IAAI,SAAS,CAAC;AAChC,gBAAgB,IAAI,EAAE,sBAAsB;AAC5C,gBAAgB,OAAO,EAAE,CAAC,0EAA0E,CAAC;AACrG,aAAa,CAAC;AACd;AACA;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,OAAO,IAAI,CAAC,uBAAuB,KAAK;AAChD,cAAc;AACd,cAAc,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE;AACxD;AACA,IAAI,eAAe,CAAC,MAAM,EAAE;AAC5B,QAAQ,QAAQ,CAAC,CAAC,MAAM;AACxB,YAAY,CAAC,CAAC,IAAI,CAAC,yBAAyB,EAAE,iBAAiB;AAC/D,YAAY,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;AACtC,gBAAgB,IAAI,CAAC,yBAAyB,CAAC,iBAAiB;AAChE;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"credentialsProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/credentialsProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, createGetCredentialsForIdentityClient, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { assertIdTokenInAuthTokens } from '../utils/types';\nimport { createCognitoIdentityPoolEndpointResolver } from '../factories';\nimport { cognitoIdentityIdProvider } from './IdentityIdProvider';\nimport { formLoginsMap } from './utils';\nconst logger = new ConsoleLogger('CognitoCredentialsProvider');\nconst CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nexport class CognitoAWSCredentialsAndIdentityIdProvider {\n constructor(identityIdStore) {\n this._nextCredentialsRefresh = 0;\n this._identityIdStore = identityIdStore;\n }\n async clearCredentialsAndIdentityId() {\n logger.debug('Clearing out credentials and identityId');\n this._credentialsAndIdentityId = undefined;\n await this._identityIdStore.clearIdentityId();\n }\n async clearCredentials() {\n logger.debug('Clearing out in-memory credentials');\n this._credentialsAndIdentityId = undefined;\n }\n async getCredentialsAndIdentityId(getCredentialsOptions) {\n const isAuthenticated = getCredentialsOptions.authenticated;\n const { tokens } = getCredentialsOptions;\n const { authConfig } = getCredentialsOptions;\n try {\n assertIdentityPoolIdConfig(authConfig?.Cognito);\n }\n catch {\n // No identity pool configured, skipping\n return;\n }\n if (!isAuthenticated && !authConfig.Cognito.allowGuestAccess) {\n // TODO(V6): return partial result like Native platforms\n return;\n }\n const { forceRefresh } = getCredentialsOptions;\n const tokenHasChanged = this.hasTokenChanged(tokens);\n const identityId = await cognitoIdentityIdProvider({\n tokens,\n authConfig: authConfig.Cognito,\n identityIdStore: this._identityIdStore,\n });\n // Clear cached credentials when forceRefresh is true OR the cache token has changed\n if (forceRefresh || tokenHasChanged) {\n this.clearCredentials();\n }\n if (!isAuthenticated) {\n return this.getGuestCredentials(identityId, authConfig.Cognito);\n }\n else {\n assertIdTokenInAuthTokens(tokens);\n return this.credsForOIDCTokens(authConfig.Cognito, tokens, identityId);\n }\n }\n async getGuestCredentials(identityId, authConfig) {\n // Return existing in-memory cached credentials only if it exists, is not past it's lifetime and is unauthenticated credentials\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === false) {\n logger.info('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any authenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n const getCredentialsForIdentity = createGetCredentialsForIdentityClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // use identityId to obtain guest credentials\n // save credentials in-memory\n // No logins params should be passed for guest creds:\n // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'guest',\n });\n }\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: false,\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsNotFoundException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n async credsForOIDCTokens(authConfig, authTokens, identityId) {\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === true) {\n logger.debug('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any unauthenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const logins = authTokens.idToken\n ? formLoginsMap(authTokens.idToken.toString())\n : {};\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n const getCredentialsForIdentity = createGetCredentialsForIdentityClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n Logins: logins,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n // note: the following call removes guest identityId from the persistent store (localStorage)\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'primary',\n });\n }\n // Store the credentials in-memory along with the expiration\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: true,\n associatedIdToken: authTokens.idToken?.toString(),\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n isPastTTL() {\n return this._nextCredentialsRefresh === undefined\n ? true\n : this._nextCredentialsRefresh <= Date.now();\n }\n hasTokenChanged(tokens) {\n return (!!tokens &&\n !!this._credentialsAndIdentityId?.associatedId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G;AAChB,QAAQ,OAAO,IAAI,CAAC,uBAAuB,KAAK;AAChD,cAAc;AACd,cAAc,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE;AACxD,IAAI;AACJ,IAAI,eAAe,CAAC,MAAM,EAAE;AAC5B,QAAQ,QAAQ,CAAC,CAAC,MAAM;AACxB,YAAY,CAAC,CAAC,IAAI,CAAC,yBAAyB,EAAE,iBAAiB;AAC/D,YAAY,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;AACtC,gBAAgB,IAAI,CAAC,yBAAyB,CAAC,iBAAiB;AAChE,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/utils.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { decodeJWT } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nexport function formLoginsMap(idToken) {\n const issuer = decodeJWT(idToken).payload.iss;\n const res = {};\n if (!issuer) {\n throw new AuthError({\n name: 'InvalidIdTokenException',\n message: 'Invalid Idtoken.',\n });\n }\n const domainName = issuer.replace(/(^\\w+:|^)\\/\\//, '');\n res[domainName] = idToken;\n return res;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,aAAa,CAAC,OAAO,EAAE;AACvC,IAAI,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG;AACjD,IAAI,MAAM,GAAG,GAAG,EAAE;AAClB,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,yBAAyB;AAC3C,YAAY,OAAO,EAAE,kBAAkB;AACvC,SAAS,CAAC;AACV;
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/utils.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { decodeJWT } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nexport function formLoginsMap(idToken) {\n const issuer = decodeJWT(idToken).payload.iss;\n const res = {};\n if (!issuer) {\n throw new AuthError({\n name: 'InvalidIdTokenException',\n message: 'Invalid Idtoken.',\n });\n }\n const domainName = issuer.replace(/(^\\w+:|^)\\/\\//, '');\n res[domainName] = idToken;\n return res;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,aAAa,CAAC,OAAO,EAAE;AACvC,IAAI,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG;AACjD,IAAI,MAAM,GAAG,GAAG,EAAE;AAClB,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,yBAAyB;AAC3C,YAAY,OAAO,EAAE,kBAAkB;AACvC,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;AAC1D,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,OAAO;AAC7B,IAAI,OAAO,GAAG;AACd;;;;"}
|
package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCognitoIdentityPoolEndpointResolver.mjs","sources":["../../../../../src/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { cognitoIdentityPoolEndpointResolver } from '@aws-amplify/core';\nimport { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nexport const createCognitoIdentityPoolEndpointResolver = ({ endpointOverride }) => (input) => {\n if (endpointOverride) {\n return { url: new AmplifyUrl(endpointOverride) };\n }\n return cognitoIdentityPoolEndpointResolver(input);\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,yCAAyC,GAAG,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,KAAK,KAAK;AAC9F,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACxD;
|
|
1
|
+
{"version":3,"file":"createCognitoIdentityPoolEndpointResolver.mjs","sources":["../../../../../src/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { cognitoIdentityPoolEndpointResolver } from '@aws-amplify/core';\nimport { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nexport const createCognitoIdentityPoolEndpointResolver = ({ endpointOverride }) => (input) => {\n if (endpointOverride) {\n return { url: new AmplifyUrl(endpointOverride) };\n }\n return cognitoIdentityPoolEndpointResolver(input);\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,yCAAyC,GAAG,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,KAAK,KAAK;AAC9F,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACxD,IAAI;AACJ,IAAI,OAAO,mCAAmC,CAAC,KAAK,CAAC;AACrD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCognitoUserPoolEndpointResolver.mjs","sources":["../../../../../src/providers/cognito/factories/createCognitoUserPoolEndpointResolver.ts"],"sourcesContent":["import { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nimport { cognitoUserPoolEndpointResolver } from '../../../foundation/cognitoUserPoolEndpointResolver';\nexport const createCognitoUserPoolEndpointResolver = ({ endpointOverride }) => (input) => {\n if (endpointOverride) {\n return { url: new AmplifyUrl(endpointOverride) };\n }\n return cognitoUserPoolEndpointResolver(input);\n};\n"],"names":[],"mappings":";;;AAEY,MAAC,qCAAqC,GAAG,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,KAAK,KAAK;AAC1F,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACxD;
|
|
1
|
+
{"version":3,"file":"createCognitoUserPoolEndpointResolver.mjs","sources":["../../../../../src/providers/cognito/factories/createCognitoUserPoolEndpointResolver.ts"],"sourcesContent":["import { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nimport { cognitoUserPoolEndpointResolver } from '../../../foundation/cognitoUserPoolEndpointResolver';\nexport const createCognitoUserPoolEndpointResolver = ({ endpointOverride }) => (input) => {\n if (endpointOverride) {\n return { url: new AmplifyUrl(endpointOverride) };\n }\n return cognitoUserPoolEndpointResolver(input);\n};\n"],"names":[],"mappings":";;;AAEY,MAAC,qCAAqC,GAAG,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,KAAK,KAAK;AAC1F,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACxD,IAAI;AACJ,IAAI,OAAO,+BAA+B,CAAC,KAAK,CAAC;AACjD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CognitoUserPoolsTokenProvider.mjs","sources":["../../../../../src/providers/cognito/tokenProvider/CognitoUserPoolsTokenProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { defaultStorage, } from '@aws-amplify/core';\nimport { refreshAuthTokens } from '../utils/refreshAuthTokens';\nimport { DefaultTokenStore } from './TokenStore';\nimport { TokenOrchestrator } from './TokenOrchestrator';\nexport class CognitoUserPoolsTokenProvider {\n constructor() {\n this.authTokenStore = new DefaultTokenStore();\n this.authTokenStore.setKeyValueStorage(defaultStorage);\n this.tokenOrchestrator = new TokenOrchestrator();\n this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore);\n this.tokenOrchestrator.setTokenRefresher(refreshAuthTokens);\n }\n getTokens({ forceRefresh } = { forceRefresh: false }) {\n return this.tokenOrchestrator.getTokens({ forceRefresh });\n }\n setKeyValueStorage(keyValueStorage) {\n this.authTokenStore.setKeyValueStorage(keyValueStorage);\n }\n setAuthConfig(authConfig) {\n this.authTokenStore.setAuthConfig(authConfig);\n this.tokenOrchestrator.setAuthConfig(authConfig);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKO,MAAM,6BAA6B,CAAC;AAC3C,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI,iBAAiB,EAAE;AACrD,QAAQ,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC;AAC9D,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE;AACxD,QAAQ,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC;AACrE,QAAQ,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;AACnE;
|
|
1
|
+
{"version":3,"file":"CognitoUserPoolsTokenProvider.mjs","sources":["../../../../../src/providers/cognito/tokenProvider/CognitoUserPoolsTokenProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { defaultStorage, } from '@aws-amplify/core';\nimport { refreshAuthTokens } from '../utils/refreshAuthTokens';\nimport { DefaultTokenStore } from './TokenStore';\nimport { TokenOrchestrator } from './TokenOrchestrator';\nexport class CognitoUserPoolsTokenProvider {\n constructor() {\n this.authTokenStore = new DefaultTokenStore();\n this.authTokenStore.setKeyValueStorage(defaultStorage);\n this.tokenOrchestrator = new TokenOrchestrator();\n this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore);\n this.tokenOrchestrator.setTokenRefresher(refreshAuthTokens);\n }\n getTokens({ forceRefresh } = { forceRefresh: false }) {\n return this.tokenOrchestrator.getTokens({ forceRefresh });\n }\n setKeyValueStorage(keyValueStorage) {\n this.authTokenStore.setKeyValueStorage(keyValueStorage);\n }\n setAuthConfig(authConfig) {\n this.authTokenStore.setAuthConfig(authConfig);\n this.tokenOrchestrator.setAuthConfig(authConfig);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKO,MAAM,6BAA6B,CAAC;AAC3C,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI,iBAAiB,EAAE;AACrD,QAAQ,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC;AAC9D,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE;AACxD,QAAQ,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC;AACrE,QAAQ,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;AACnE,IAAI;AACJ,IAAI,SAAS,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE;AAC1D,QAAQ,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;AACjE,IAAI;AACJ,IAAI,kBAAkB,CAAC,eAAe,EAAE;AACxC,QAAQ,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC;AAC/D,IAAI;AACJ,IAAI,aAAa,CAAC,UAAU,EAAE;AAC9B,QAAQ,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC;AACrD,QAAQ,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,UAAU,CAAC;AACxD,IAAI;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenOrchestrator.mjs","sources":["../../../../../src/providers/cognito/tokenProvider/TokenOrchestrator.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Hub, } from '@aws-amplify/core';\nimport { AMPLIFY_SYMBOL, AmplifyErrorCode, assertTokenProviderConfig, isBrowser, isTokenExpired, } from '@aws-amplify/core/internals/utils';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { AuthError } from '../../../errors/AuthError';\nimport { oAuthStore } from '../utils/oauth/oAuthStore';\nimport { addInflightPromise } from '../utils/oauth/inflightPromise';\nexport class TokenOrchestrator {\n constructor() {\n this.waitForInflightOAuth = isBrowser()\n ? async () => {\n if (!(await oAuthStore.loadOAuthInFlight())) {\n return;\n }\n if (this.inflightPromise) {\n return this.inflightPromise;\n }\n // when there is valid oauth config and there is an inflight oauth flow, try\n // to block async calls that require fetching tokens before the oauth flow completes\n // e.g. getCurrentUser, fetchAuthSession etc.\n this.inflightPromise = new Promise((resolve, _reject) => {\n addInflightPromise(resolve);\n });\n return this.inflightPromise;\n }\n : async () => {\n // no-op for non-browser environments\n };\n }\n setAuthConfig(authConfig) {\n oAuthStore.setAuthConfig(authConfig.Cognito);\n this.authConfig = authConfig;\n }\n setTokenRefresher(tokenRefresher) {\n this.tokenRefresher = tokenRefresher;\n }\n setAuthTokenStore(tokenStore) {\n this.tokenStore = tokenStore;\n }\n getTokenStore() {\n if (!this.tokenStore) {\n throw new AuthError({\n name: 'EmptyTokenStoreException',\n message: 'TokenStore not set',\n });\n }\n return this.tokenStore;\n }\n getTokenRefresher() {\n if (!this.tokenRefresher) {\n throw new AuthError({\n name: 'EmptyTokenRefresherException',\n message: 'TokenRefresher not set',\n });\n }\n return this.tokenRefresher;\n }\n async getTokens(options) {\n let tokens;\n try {\n assertTokenProviderConfig(this.authConfig?.Cognito);\n }\n catch (_err) {\n // Token provider not configured\n return null;\n }\n await this.waitForInflightOAuth();\n this.inflightPromise = undefined;\n tokens = await this.getTokenStore().loadTokens();\n const username = await this.getTokenStore().getLastAuthUser();\n if (tokens === null) {\n return null;\n }\n const idTokenExpired = !!tokens?.idToken &&\n isTokenExpired({\n expiresAt: (tokens.idToken?.payload?.exp ?? 0) * 1000,\n clockDrift: tokens.clockDrift ?? 0,\n });\n const accessTokenExpired = isTokenExpired({\n expiresAt: (tokens.accessToken?.payload?.exp ?? 0) * 1000,\n clockDrift: tokens.clockDrift ?? 0,\n });\n if (options?.forceRefresh || idTokenExpired || accessTokenExpired) {\n tokens = await this.refreshTokens({\n tokens,\n username,\n });\n if (tokens === null) {\n return null;\n }\n }\n return {\n accessToken: tokens?.accessToken,\n idToken: tokens?.idToken,\n signInDetails: tokens?.signInDetails,\n };\n }\n async refreshTokens({ tokens, username, }) {\n try {\n const { signInDetails } = tokens;\n const newTokens = await this.getTokenRefresher()({\n tokens,\n authConfig: this.authConfig,\n username,\n });\n newTokens.signInDetails = signInDetails;\n await this.setTokens({ tokens: newTokens });\n Hub.dispatch('auth', { event: 'tokenRefresh' }, 'Auth', AMPLIFY_SYMBOL);\n return newTokens;\n }\n catch (err) {\n return this.handleErrors(err);\n }\n }\n handleErrors(err) {\n assertServiceError(err);\n if (err.name !== AmplifyErrorCode.NetworkError) {\n // TODO(v6): Check errors on client\n this.clearTokens();\n }\n Hub.dispatch('auth', {\n event: 'tokenRefresh_failure',\n data: { error: err },\n }, 'Auth', AMPLIFY_SYMBOL);\n if (err.name.startsWith('NotAuthorizedException')) {\n return null;\n }\n throw err;\n }\n async setTokens({ tokens }) {\n return this.getTokenStore().storeTokens(tokens);\n }\n async clearTokens() {\n return this.getTokenStore().clearTokens();\n }\n getDeviceMetadata(username) {\n return this.getTokenStore().getDeviceMetadata(username);\n }\n clearDeviceMetadata(username) {\n return this.getTokenStore().clearDeviceMetadata(username);\n }\n setOAuthMetadata(metadata) {\n return this.getTokenStore().setOAuthMetadata(metadata);\n }\n getOAuthMetadata() {\n return this.getTokenStore().getOAuthMetadata();\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AAOO,MAAM,iBAAiB,CAAC;AAC/B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,oBAAoB,GAAG,SAAS;AAC7C,cAAc,YAAY;AAC1B,gBAAgB,IAAI,EAAE,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAC,EAAE;AAC7D,oBAAoB;AACpB;
|
|
1
|
+
{"version":3,"file":"TokenOrchestrator.mjs","sources":["../../../../../src/providers/cognito/tokenProvider/TokenOrchestrator.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Hub, } from '@aws-amplify/core';\nimport { AMPLIFY_SYMBOL, AmplifyErrorCode, assertTokenProviderConfig, isBrowser, isTokenExpired, } from '@aws-amplify/core/internals/utils';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { AuthError } from '../../../errors/AuthError';\nimport { oAuthStore } from '../utils/oauth/oAuthStore';\nimport { addInflightPromise } from '../utils/oauth/inflightPromise';\nexport class TokenOrchestrator {\n constructor() {\n this.waitForInflightOAuth = isBrowser()\n ? async () => {\n if (!(await oAuthStore.loadOAuthInFlight())) {\n return;\n }\n if (this.inflightPromise) {\n return this.inflightPromise;\n }\n // when there is valid oauth config and there is an inflight oauth flow, try\n // to block async calls that require fetching tokens before the oauth flow completes\n // e.g. getCurrentUser, fetchAuthSession etc.\n this.inflightPromise = new Promise((resolve, _reject) => {\n addInflightPromise(resolve);\n });\n return this.inflightPromise;\n }\n : async () => {\n // no-op for non-browser environments\n };\n }\n setAuthConfig(authConfig) {\n oAuthStore.setAuthConfig(authConfig.Cognito);\n this.authConfig = authConfig;\n }\n setTokenRefresher(tokenRefresher) {\n this.tokenRefresher = tokenRefresher;\n }\n setAuthTokenStore(tokenStore) {\n this.tokenStore = tokenStore;\n }\n getTokenStore() {\n if (!this.tokenStore) {\n throw new AuthError({\n name: 'EmptyTokenStoreException',\n message: 'TokenStore not set',\n });\n }\n return this.tokenStore;\n }\n getTokenRefresher() {\n if (!this.tokenRefresher) {\n throw new AuthError({\n name: 'EmptyTokenRefresherException',\n message: 'TokenRefresher not set',\n });\n }\n return this.tokenRefresher;\n }\n async getTokens(options) {\n let tokens;\n try {\n assertTokenProviderConfig(this.authConfig?.Cognito);\n }\n catch (_err) {\n // Token provider not configured\n return null;\n }\n await this.waitForInflightOAuth();\n this.inflightPromise = undefined;\n tokens = await this.getTokenStore().loadTokens();\n const username = await this.getTokenStore().getLastAuthUser();\n if (tokens === null) {\n return null;\n }\n const idTokenExpired = !!tokens?.idToken &&\n isTokenExpired({\n expiresAt: (tokens.idToken?.payload?.exp ?? 0) * 1000,\n clockDrift: tokens.clockDrift ?? 0,\n });\n const accessTokenExpired = isTokenExpired({\n expiresAt: (tokens.accessToken?.payload?.exp ?? 0) * 1000,\n clockDrift: tokens.clockDrift ?? 0,\n });\n if (options?.forceRefresh || idTokenExpired || accessTokenExpired) {\n tokens = await this.refreshTokens({\n tokens,\n username,\n });\n if (tokens === null) {\n return null;\n }\n }\n return {\n accessToken: tokens?.accessToken,\n idToken: tokens?.idToken,\n signInDetails: tokens?.signInDetails,\n };\n }\n async refreshTokens({ tokens, username, }) {\n try {\n const { signInDetails } = tokens;\n const newTokens = await this.getTokenRefresher()({\n tokens,\n authConfig: this.authConfig,\n username,\n });\n newTokens.signInDetails = signInDetails;\n await this.setTokens({ tokens: newTokens });\n Hub.dispatch('auth', { event: 'tokenRefresh' }, 'Auth', AMPLIFY_SYMBOL);\n return newTokens;\n }\n catch (err) {\n return this.handleErrors(err);\n }\n }\n handleErrors(err) {\n assertServiceError(err);\n if (err.name !== AmplifyErrorCode.NetworkError) {\n // TODO(v6): Check errors on client\n this.clearTokens();\n }\n Hub.dispatch('auth', {\n event: 'tokenRefresh_failure',\n data: { error: err },\n }, 'Auth', AMPLIFY_SYMBOL);\n if (err.name.startsWith('NotAuthorizedException')) {\n return null;\n }\n throw err;\n }\n async setTokens({ tokens }) {\n return this.getTokenStore().storeTokens(tokens);\n }\n async clearTokens() {\n return this.getTokenStore().clearTokens();\n }\n getDeviceMetadata(username) {\n return this.getTokenStore().getDeviceMetadata(username);\n }\n clearDeviceMetadata(username) {\n return this.getTokenStore().clearDeviceMetadata(username);\n }\n setOAuthMetadata(metadata) {\n return this.getTokenStore().setOAuthMetadata(metadata);\n }\n getOAuthMetadata() {\n return this.getTokenStore().getOAuthMetadata();\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AAOO,MAAM,iBAAiB,CAAC;AAC/B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,oBAAoB,GAAG,SAAS;AAC7C,cAAc,YAAY;AAC1B,gBAAgB,IAAI,EAAE,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAC,EAAE;AAC7D,oBAAoB;AACpB,gBAAgB;AAChB,gBAAgB,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1C,oBAAoB,OAAO,IAAI,CAAC,eAAe;AAC/C,gBAAgB;AAChB;AACA;AACA;AACA,gBAAgB,IAAI,CAAC,eAAe,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK;AACzE,oBAAoB,kBAAkB,CAAC,OAAO,CAAC;AAC/C,gBAAgB,CAAC,CAAC;AAClB,gBAAgB,OAAO,IAAI,CAAC,eAAe;AAC3C,YAAY;AACZ,cAAc,YAAY;AAC1B;AACA,YAAY,CAAC;AACb,IAAI;AACJ,IAAI,aAAa,CAAC,UAAU,EAAE;AAC9B,QAAQ,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;AACpD,QAAQ,IAAI,CAAC,UAAU,GAAG,UAAU;AACpC,IAAI;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