@aws-amplify/auth
Version:
Auth category of aws-amplify
1 lines • 1.82 kB
Source Map (JSON)
{"version":3,"file":"validateState.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/validateState.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from '../../../../errors/AuthError';\nimport { AuthErrorTypes } from '../../../../types/Auth';\nimport { oAuthStore } from './oAuthStore';\nexport const flowCancelledMessage = '`signInWithRedirect` has been canceled.';\nexport const validationFailedMessage = 'An error occurred while validating the state.';\nexport const validationRecoverySuggestion = 'Try to initiate an OAuth flow from Amplify';\nexport const validateState = async (state) => {\n const savedState = await oAuthStore.loadOAuthState();\n // This is because savedState only exists if the flow was initiated by Amplify\n const validatedState = state === savedState ? savedState : undefined;\n if (!validatedState) {\n throw new AuthError({\n name: AuthErrorTypes.OAuthSignInError,\n message: state === null ? flowCancelledMessage : validationFailedMessage,\n recoverySuggestion: state === null ? undefined : validationRecoverySuggestion,\n });\n }\n return validatedState;\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,oBAAoB,GAAG;AACxB,MAAC,uBAAuB,GAAG;AAC3B,MAAC,4BAA4B,GAAG;AAChC,MAAC,aAAa,GAAG,OAAO,KAAK,KAAK;AAC9C,IAAI,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,cAAc,EAAE;AACxD;AACA,IAAI,MAAM,cAAc,GAAG,KAAK,KAAK,UAAU,GAAG,UAAU,GAAG,SAAS;AACxE,IAAI,IAAI,CAAC,cAAc,EAAE;AACzB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,cAAc,CAAC,gBAAgB;AACjD,YAAY,OAAO,EAAE,KAAK,KAAK,IAAI,GAAG,oBAAoB,GAAG,uBAAuB;AACpF,YAAY,kBAAkB,EAAE,KAAK,KAAK,IAAI,GAAG,SAAS,GAAG,4BAA4B;AACzF,SAAS,CAAC;AACV;AACA,IAAI,OAAO,cAAc;AACzB;;;;"}