UNPKG

@aws-amplify/auth

Version:
1 lines 2.03 kB
{"version":3,"file":"handleOAuthSignOut.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { completeOAuthSignOut } from './completeOAuthSignOut';\nimport { oAuthSignOutRedirect } from './oAuthSignOutRedirect';\nexport const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator, redirectUrl) => {\n const { isOAuthSignIn } = await store.loadOAuthSignIn();\n const oauthMetadata = await tokenOrchestrator.getOAuthMetadata();\n // Clear everything before attempting to visted logout endpoint since the current application\n // state could be wiped away on redirect\n await completeOAuthSignOut(store);\n // The isOAuthSignIn flag is propagated by the oAuthToken store which manages oauth keys in local storage only.\n // These keys are used to determine if a user is in an inflight or signedIn oauth states.\n // However, this behavior represents an issue when 2 apps share the same set of tokens in Cookie storage because the app that didn't\n // start the OAuth will not have access to the oauth keys.\n // A heuristic solution is to add oauth metadata to the tokenOrchestrator which will have access to the underlying\n // storage mechanism that is used by Amplify.\n if (isOAuthSignIn || oauthMetadata?.oauthSignIn) {\n // On web, this will always end up being a void action\n return oAuthSignOutRedirect(cognitoConfig, false, redirectUrl);\n }\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,KAAK;AAClG,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE;AAC3D,IAAI,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,EAAE;AACpE;AACA;AACA,IAAI,MAAM,oBAAoB,CAAC,KAAK,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,aAAa,IAAI,aAAa,EAAE,WAAW,EAAE;AACrD;AACA,QAAQ,OAAO,oBAAoB,CAAC,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC;AACtE;AACA;;;;"}