UNPKG

@aws-amplify/auth

Version:
1 lines 2.64 kB
{"version":3,"file":"attemptCompleteOAuthFlow.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/attemptCompleteOAuthFlow.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertOAuthConfig, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { getAuthUserAgentValue } from '../../../../utils';\nimport { oAuthStore } from './oAuthStore';\nimport { completeOAuthFlow } from './completeOAuthFlow';\nimport { getRedirectUrl } from './getRedirectUrl';\nimport { handleFailure } from './handleFailure';\nexport const attemptCompleteOAuthFlow = async (authConfig) => {\n try {\n assertTokenProviderConfig(authConfig);\n assertOAuthConfig(authConfig);\n oAuthStore.setAuthConfig(authConfig);\n }\n catch (_) {\n // no-op\n // This should not happen as Amplify singleton checks the oauth config key\n // unless the oauth config object doesn't contain required properties\n return;\n }\n // No inflight OAuth\n if (!(await oAuthStore.loadOAuthInFlight())) {\n return;\n }\n try {\n const currentUrl = window.location.href;\n const { loginWith, userPoolClientId } = authConfig;\n const { domain, redirectSignIn, responseType } = loginWith.oauth;\n const redirectUri = getRedirectUrl(redirectSignIn);\n await completeOAuthFlow({\n currentUrl,\n clientId: userPoolClientId,\n domain,\n redirectUri,\n responseType,\n userAgentValue: getAuthUserAgentValue(AuthAction.SignInWithRedirect),\n });\n }\n catch (err) {\n await handleFailure(err);\n }\n};\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AAOY,MAAC,wBAAwB,GAAG,OAAO,UAAU,KAAK;AAC9D,IAAI,IAAI;AACR,QAAQ,yBAAyB,CAAC,UAAU,CAAC;AAC7C,QAAQ,iBAAiB,CAAC,UAAU,CAAC;AACrC,QAAQ,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC;AAC5C;AACA,IAAI,OAAO,CAAC,EAAE;AACd;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,IAAI,IAAI,EAAE,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAC,EAAE;AACjD,QAAQ;AACR;AACA,IAAI,IAAI;AACR,QAAQ,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI;AAC/C,QAAQ,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,UAAU;AAC1D,QAAQ,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC,KAAK;AACxE,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC;AAC1D,QAAQ,MAAM,iBAAiB,CAAC;AAChC,YAAY,UAAU;AACtB,YAAY,QAAQ,EAAE,gBAAgB;AACtC,YAAY,MAAM;AAClB,YAAY,WAAW;AACvB,YAAY,YAAY;AACxB,YAAY,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,kBAAkB,CAAC;AAChF,SAAS,CAAC;AACV;AACA,IAAI,OAAO,GAAG,EAAE;AAChB,QAAQ,MAAM,aAAa,CAAC,GAAG,CAAC;AAChC;AACA;;;;"}