@aws-amplify/auth 6.3.18-unstable.a363362.0 → 6.4.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/constants.js +13 -1
- package/dist/cjs/errors/constants.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signOut.js +2 -2
- package/dist/cjs/providers/cognito/apis/signOut.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.js +18 -9
- package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.native.js +17 -6
- package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.native.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/handleOAuthSignOut.js +2 -2
- package/dist/cjs/providers/cognito/utils/oauth/handleOAuthSignOut.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/handleOAuthSignOut.native.js +4 -2
- package/dist/cjs/providers/cognito/utils/oauth/handleOAuthSignOut.native.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/oauth/oAuthSignOutRedirect.js +2 -2
- package/dist/cjs/providers/cognito/utils/oauth/oAuthSignOutRedirect.js.map +1 -1
- package/dist/esm/errors/constants.d.ts +4 -0
- package/dist/esm/errors/constants.mjs +13 -1
- package/dist/esm/errors/constants.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signOut.mjs +2 -2
- package/dist/esm/providers/cognito/apis/signOut.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.d.ts +1 -1
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.mjs +19 -10
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.native.d.ts +6 -2
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.native.mjs +18 -7
- package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.native.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.d.ts +1 -1
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.mjs +2 -2
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.native.d.ts +2 -1
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.native.mjs +4 -2
- package/dist/esm/providers/cognito/utils/oauth/handleOAuthSignOut.native.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/oauth/oAuthSignOutRedirect.d.ts +1 -1
- package/dist/esm/providers/cognito/utils/oauth/oAuthSignOutRedirect.mjs +2 -2
- package/dist/esm/providers/cognito/utils/oauth/oAuthSignOutRedirect.mjs.map +1 -1
- package/dist/esm/types/inputs.d.ts +3 -0
- package/package.json +104 -104
- package/src/errors/constants.ts +17 -0
- package/src/providers/cognito/apis/signOut.ts +2 -3
- package/src/providers/cognito/utils/oauth/getRedirectUrl.native.ts +24 -7
- package/src/providers/cognito/utils/oauth/getRedirectUrl.ts +27 -11
- package/src/providers/cognito/utils/oauth/handleOAuthSignOut.native.ts +5 -1
- package/src/providers/cognito/utils/oauth/handleOAuthSignOut.ts +2 -1
- package/src/providers/cognito/utils/oauth/oAuthSignOutRedirect.ts +2 -1
- package/src/types/inputs.ts +3 -0
|
@@ -3,18 +3,30 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = exports.TOKEN_REFRESH_EXCEPTION = exports.OAUTH_SIGNOUT_EXCEPTION = exports.invalidOriginException = exports.INVALID_ORIGIN_EXCEPTION = exports.invalidRedirectException = exports.INVALID_REDIRECT_EXCEPTION = exports.AUTO_SIGN_IN_EXCEPTION = exports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = exports.USER_ALREADY_AUTHENTICATED_EXCEPTION = exports.USER_UNAUTHENTICATED_EXCEPTION = void 0;
|
|
6
|
+
exports.UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = exports.TOKEN_REFRESH_EXCEPTION = exports.OAUTH_SIGNOUT_EXCEPTION = exports.invalidOriginException = exports.INVALID_ORIGIN_EXCEPTION = exports.invalidPreferredRedirectUrlException = exports.invalidAppSchemeException = exports.invalidRedirectException = exports.INVALID_PREFERRED_REDIRECT_EXCEPTION = exports.INVALID_APP_SCHEME_EXCEPTION = exports.INVALID_REDIRECT_EXCEPTION = exports.AUTO_SIGN_IN_EXCEPTION = exports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = exports.USER_ALREADY_AUTHENTICATED_EXCEPTION = exports.USER_UNAUTHENTICATED_EXCEPTION = void 0;
|
|
7
7
|
const AuthError_1 = require("./AuthError");
|
|
8
8
|
exports.USER_UNAUTHENTICATED_EXCEPTION = 'UserUnAuthenticatedException';
|
|
9
9
|
exports.USER_ALREADY_AUTHENTICATED_EXCEPTION = 'UserAlreadyAuthenticatedException';
|
|
10
10
|
exports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = 'DeviceMetadataNotFoundException';
|
|
11
11
|
exports.AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';
|
|
12
12
|
exports.INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';
|
|
13
|
+
exports.INVALID_APP_SCHEME_EXCEPTION = 'InvalidAppSchemeException';
|
|
14
|
+
exports.INVALID_PREFERRED_REDIRECT_EXCEPTION = 'InvalidPreferredRedirectUrlException';
|
|
13
15
|
exports.invalidRedirectException = new AuthError_1.AuthError({
|
|
14
16
|
name: exports.INVALID_REDIRECT_EXCEPTION,
|
|
15
17
|
message: 'signInRedirect or signOutRedirect had an invalid format or was not found.',
|
|
16
18
|
recoverySuggestion: 'Please make sure the signIn/Out redirect in your oauth config is valid.',
|
|
17
19
|
});
|
|
20
|
+
exports.invalidAppSchemeException = new AuthError_1.AuthError({
|
|
21
|
+
name: exports.INVALID_APP_SCHEME_EXCEPTION,
|
|
22
|
+
message: 'A valid non-http app scheme was not found in the config.',
|
|
23
|
+
recoverySuggestion: 'Please make sure a valid custom app scheme is present in the config.',
|
|
24
|
+
});
|
|
25
|
+
exports.invalidPreferredRedirectUrlException = new AuthError_1.AuthError({
|
|
26
|
+
name: exports.INVALID_PREFERRED_REDIRECT_EXCEPTION,
|
|
27
|
+
message: 'The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.',
|
|
28
|
+
recoverySuggestion: 'Please make sure a matching preferredRedirectUrl is provided.',
|
|
29
|
+
});
|
|
18
30
|
exports.INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';
|
|
19
31
|
exports.invalidOriginException = new AuthError_1.AuthError({
|
|
20
32
|
name: exports.INVALID_ORIGIN_EXCEPTION,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../src/errors/constants.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = exports.TOKEN_REFRESH_EXCEPTION = exports.OAUTH_SIGNOUT_EXCEPTION = exports.invalidOriginException = exports.INVALID_ORIGIN_EXCEPTION = exports.invalidRedirectException = exports.INVALID_REDIRECT_EXCEPTION = exports.AUTO_SIGN_IN_EXCEPTION = exports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = exports.USER_ALREADY_AUTHENTICATED_EXCEPTION = exports.USER_UNAUTHENTICATED_EXCEPTION = void 0;\nconst AuthError_1 = require(\"./AuthError\");\nexports.USER_UNAUTHENTICATED_EXCEPTION = 'UserUnAuthenticatedException';\nexports.USER_ALREADY_AUTHENTICATED_EXCEPTION = 'UserAlreadyAuthenticatedException';\nexports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = 'DeviceMetadataNotFoundException';\nexports.AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';\nexports.INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';\nexports.invalidRedirectException = new AuthError_1.AuthError({\n name: exports.INVALID_REDIRECT_EXCEPTION,\n message: 'signInRedirect or signOutRedirect had an invalid format or was not found.',\n recoverySuggestion: 'Please make sure the signIn/Out redirect in your oauth config is valid.',\n});\nexports.INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';\nexports.invalidOriginException = new AuthError_1.AuthError({\n name: exports.INVALID_ORIGIN_EXCEPTION,\n message: 'redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin',\n recoverySuggestion: 'Please call signInWithRedirect from the same origin.',\n});\nexports.OAUTH_SIGNOUT_EXCEPTION = 'OAuthSignOutException';\nexports.TOKEN_REFRESH_EXCEPTION = 'TokenRefreshException';\nexports.UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = 'UnexpectedSignInInterruptionException';\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yCAAyC,GAAG,OAAO,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,oCAAoC,GAAG,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/errors/constants.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = exports.TOKEN_REFRESH_EXCEPTION = exports.OAUTH_SIGNOUT_EXCEPTION = exports.invalidOriginException = exports.INVALID_ORIGIN_EXCEPTION = exports.invalidPreferredRedirectUrlException = exports.invalidAppSchemeException = exports.invalidRedirectException = exports.INVALID_PREFERRED_REDIRECT_EXCEPTION = exports.INVALID_APP_SCHEME_EXCEPTION = exports.INVALID_REDIRECT_EXCEPTION = exports.AUTO_SIGN_IN_EXCEPTION = exports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = exports.USER_ALREADY_AUTHENTICATED_EXCEPTION = exports.USER_UNAUTHENTICATED_EXCEPTION = void 0;\nconst AuthError_1 = require(\"./AuthError\");\nexports.USER_UNAUTHENTICATED_EXCEPTION = 'UserUnAuthenticatedException';\nexports.USER_ALREADY_AUTHENTICATED_EXCEPTION = 'UserAlreadyAuthenticatedException';\nexports.DEVICE_METADATA_NOT_FOUND_EXCEPTION = 'DeviceMetadataNotFoundException';\nexports.AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';\nexports.INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';\nexports.INVALID_APP_SCHEME_EXCEPTION = 'InvalidAppSchemeException';\nexports.INVALID_PREFERRED_REDIRECT_EXCEPTION = 'InvalidPreferredRedirectUrlException';\nexports.invalidRedirectException = new AuthError_1.AuthError({\n name: exports.INVALID_REDIRECT_EXCEPTION,\n message: 'signInRedirect or signOutRedirect had an invalid format or was not found.',\n recoverySuggestion: 'Please make sure the signIn/Out redirect in your oauth config is valid.',\n});\nexports.invalidAppSchemeException = new AuthError_1.AuthError({\n name: exports.INVALID_APP_SCHEME_EXCEPTION,\n message: 'A valid non-http app scheme was not found in the config.',\n recoverySuggestion: 'Please make sure a valid custom app scheme is present in the config.',\n});\nexports.invalidPreferredRedirectUrlException = new AuthError_1.AuthError({\n name: exports.INVALID_PREFERRED_REDIRECT_EXCEPTION,\n message: 'The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.',\n recoverySuggestion: 'Please make sure a matching preferredRedirectUrl is provided.',\n});\nexports.INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';\nexports.invalidOriginException = new AuthError_1.AuthError({\n name: exports.INVALID_ORIGIN_EXCEPTION,\n message: 'redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin',\n recoverySuggestion: 'Please call signInWithRedirect from the same origin.',\n});\nexports.OAUTH_SIGNOUT_EXCEPTION = 'OAuthSignOutException';\nexports.TOKEN_REFRESH_EXCEPTION = 'TokenRefreshException';\nexports.UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = 'UnexpectedSignInInterruptionException';\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yCAAyC,GAAG,OAAO,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,oCAAoC,GAAG,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,oCAAoC,GAAG,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,0BAA0B,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,oCAAoC,GAAG,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;AAC3lB,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3C,OAAO,CAAC,8BAA8B,GAAG,8BAA8B,CAAC;AACxE,OAAO,CAAC,oCAAoC,GAAG,mCAAmC,CAAC;AACnF,OAAO,CAAC,mCAAmC,GAAG,iCAAiC,CAAC;AAChF,OAAO,CAAC,sBAAsB,GAAG,qBAAqB,CAAC;AACvD,OAAO,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;AAChE,OAAO,CAAC,4BAA4B,GAAG,2BAA2B,CAAC;AACnE,OAAO,CAAC,oCAAoC,GAAG,sCAAsC,CAAC;AACtF,OAAO,CAAC,wBAAwB,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC;AAC7D,IAAI,IAAI,EAAE,OAAO,CAAC,0BAA0B;AAC5C,IAAI,OAAO,EAAE,2EAA2E;AACxF,IAAI,kBAAkB,EAAE,yEAAyE;AACjG,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,yBAAyB,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC;AAC9D,IAAI,IAAI,EAAE,OAAO,CAAC,4BAA4B;AAC9C,IAAI,OAAO,EAAE,0DAA0D;AACvE,IAAI,kBAAkB,EAAE,sEAAsE;AAC9F,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,oCAAoC,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC;AACzE,IAAI,IAAI,EAAE,OAAO,CAAC,oCAAoC;AACtD,IAAI,OAAO,EAAE,2GAA2G;AACxH,IAAI,kBAAkB,EAAE,+DAA+D;AACvF,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;AAC5D,OAAO,CAAC,sBAAsB,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC;AAC3D,IAAI,IAAI,EAAE,OAAO,CAAC,wBAAwB;AAC1C,IAAI,OAAO,EAAE,uGAAuG;AACpH,IAAI,kBAAkB,EAAE,sDAAsD;AAC9E,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,OAAO,CAAC,yCAAyC,GAAG,uCAAuC;;"}
|
|
@@ -42,11 +42,11 @@ async function signOut(input) {
|
|
|
42
42
|
if (hasOAuthConfig) {
|
|
43
43
|
const oAuthStore = new signInWithRedirectStore_1.DefaultOAuthStore(core_1.defaultStorage);
|
|
44
44
|
oAuthStore.setAuthConfig(cognitoConfig);
|
|
45
|
-
const { type } = (await (0, oauth_1.handleOAuthSignOut)(cognitoConfig, oAuthStore, tokenProvider_1.tokenOrchestrator)) ?? {};
|
|
45
|
+
const { type } = (await (0, oauth_1.handleOAuthSignOut)(cognitoConfig, oAuthStore, tokenProvider_1.tokenOrchestrator, input?.oauth?.redirectUrl)) ?? {};
|
|
46
46
|
if (type === 'error') {
|
|
47
47
|
throw new AuthError_1.AuthError({
|
|
48
48
|
name: constants_1.OAUTH_SIGNOUT_EXCEPTION,
|
|
49
|
-
message:
|
|
49
|
+
message: `An error occurred when attempting to log out from OAuth provider.`,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signOut.js","sources":["../../../../../src/providers/cognito/apis/signOut.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.signOut = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../../utils\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst CognitoIdentityProvider_1 = require(\"../utils/clients/CognitoIdentityProvider\");\nconst utils_3 = require(\"../utils/clients/CognitoIdentityProvider/utils\");\nconst types_1 = require(\"../utils/types\");\nconst oauth_1 = require(\"../utils/oauth\");\nconst signInWithRedirectStore_1 = require(\"../utils/signInWithRedirectStore\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst constants_1 = require(\"../../../errors/constants\");\nconst logger = new core_1.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 */\nasync function signOut(input) {\n const cognitoConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(cognitoConfig);\n if (input?.global) {\n await globalSignOut(cognitoConfig);\n }\n else {\n await clientSignOut(cognitoConfig);\n }\n let hasOAuthConfig;\n try {\n (0, utils_1.assertOAuthConfig)(cognitoConfig);\n hasOAuthConfig = true;\n }\n catch (err) {\n hasOAuthConfig = false;\n }\n if (hasOAuthConfig) {\n const oAuthStore = new signInWithRedirectStore_1.DefaultOAuthStore(core_1.defaultStorage);\n oAuthStore.setAuthConfig(cognitoConfig);\n const { type } = (await (0, oauth_1.handleOAuthSignOut)(cognitoConfig, oAuthStore, tokenProvider_1.tokenOrchestrator)) ?? {};\n if (type === 'error') {\n throw new AuthError_1.AuthError({\n name: constants_1.OAUTH_SIGNOUT_EXCEPTION,\n message:
|
|
1
|
+
{"version":3,"file":"signOut.js","sources":["../../../../../src/providers/cognito/apis/signOut.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.signOut = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../../utils\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst CognitoIdentityProvider_1 = require(\"../utils/clients/CognitoIdentityProvider\");\nconst utils_3 = require(\"../utils/clients/CognitoIdentityProvider/utils\");\nconst types_1 = require(\"../utils/types\");\nconst oauth_1 = require(\"../utils/oauth\");\nconst signInWithRedirectStore_1 = require(\"../utils/signInWithRedirectStore\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst constants_1 = require(\"../../../errors/constants\");\nconst logger = new core_1.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 */\nasync function signOut(input) {\n const cognitoConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(cognitoConfig);\n if (input?.global) {\n await globalSignOut(cognitoConfig);\n }\n else {\n await clientSignOut(cognitoConfig);\n }\n let hasOAuthConfig;\n try {\n (0, utils_1.assertOAuthConfig)(cognitoConfig);\n hasOAuthConfig = true;\n }\n catch (err) {\n hasOAuthConfig = false;\n }\n if (hasOAuthConfig) {\n const oAuthStore = new signInWithRedirectStore_1.DefaultOAuthStore(core_1.defaultStorage);\n oAuthStore.setAuthConfig(cognitoConfig);\n const { type } = (await (0, oauth_1.handleOAuthSignOut)(cognitoConfig, oAuthStore, tokenProvider_1.tokenOrchestrator, input?.oauth?.redirectUrl)) ?? {};\n if (type === 'error') {\n throw new AuthError_1.AuthError({\n name: constants_1.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 tokenProvider_1.tokenOrchestrator.clearTokens();\n await (0, core_1.clearCredentials)();\n core_1.Hub.dispatch('auth', { event: 'signedOut' }, 'Auth', utils_1.AMPLIFY_SYMBOL);\n }\n}\nexports.signOut = signOut;\nasync function clientSignOut(cognitoConfig) {\n try {\n const authTokens = await tokenProvider_1.tokenOrchestrator.getTokenStore().loadTokens();\n (0, types_1.assertAuthTokensWithRefreshToken)(authTokens);\n if (isSessionRevocable(authTokens.accessToken)) {\n await (0, CognitoIdentityProvider_1.revokeToken)({\n region: (0, utils_3.getRegion)(cognitoConfig.userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignOut),\n }, {\n ClientId: cognitoConfig.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 authTokens = await tokenProvider_1.tokenOrchestrator.getTokenStore().loadTokens();\n (0, types_1.assertAuthTokens)(authTokens);\n await (0, CognitoIdentityProvider_1.globalSignOut)({\n region: (0, utils_3.getRegion)(cognitoConfig.userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.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":"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"}
|
|
@@ -6,17 +6,26 @@ exports.getRedirectUrl = void 0;
|
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
const constants_1 = require("../../../../errors/constants");
|
|
8
8
|
/** @internal */
|
|
9
|
-
function getRedirectUrl(redirects) {
|
|
10
|
-
|
|
11
|
-
redirects?.find(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
function getRedirectUrl(redirects, preferredRedirectUrl) {
|
|
10
|
+
if (preferredRedirectUrl) {
|
|
11
|
+
const redirectUrl = redirects?.find(redirect => redirect === preferredRedirectUrl);
|
|
12
|
+
if (!redirectUrl) {
|
|
13
|
+
throw constants_1.invalidPreferredRedirectUrlException;
|
|
14
|
+
}
|
|
15
|
+
return redirectUrl;
|
|
15
16
|
}
|
|
16
|
-
else
|
|
17
|
-
|
|
17
|
+
else {
|
|
18
|
+
const redirectUrlFromTheSameOrigin = redirects?.find(isSameOriginAndPathName) ??
|
|
19
|
+
redirects?.find(isTheSameDomain);
|
|
20
|
+
const redirectUrlFromDifferentOrigin = redirects?.find(isHttps) ?? redirects?.find(isHttp);
|
|
21
|
+
if (redirectUrlFromTheSameOrigin) {
|
|
22
|
+
return redirectUrlFromTheSameOrigin;
|
|
23
|
+
}
|
|
24
|
+
else if (redirectUrlFromDifferentOrigin) {
|
|
25
|
+
throw constants_1.invalidOriginException;
|
|
26
|
+
}
|
|
27
|
+
throw constants_1.invalidRedirectException;
|
|
18
28
|
}
|
|
19
|
-
throw constants_1.invalidRedirectException;
|
|
20
29
|
}
|
|
21
30
|
exports.getRedirectUrl = getRedirectUrl;
|
|
22
31
|
// origin + pathname => https://example.com/app
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedirectUrl.js","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getRedirectUrl = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst constants_1 = require(\"../../../../errors/constants\");\n/** @internal */\nfunction getRedirectUrl(redirects) {\n const redirectUrlFromTheSameOrigin = redirects?.find(isSameOriginAndPathName) ??\n
|
|
1
|
+
{"version":3,"file":"getRedirectUrl.js","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getRedirectUrl = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst constants_1 = require(\"../../../../errors/constants\");\n/** @internal */\nfunction getRedirectUrl(redirects, preferredRedirectUrl) {\n if (preferredRedirectUrl) {\n const redirectUrl = redirects?.find(redirect => redirect === preferredRedirectUrl);\n if (!redirectUrl) {\n throw constants_1.invalidPreferredRedirectUrlException;\n }\n return redirectUrl;\n }\n else {\n const redirectUrlFromTheSameOrigin = redirects?.find(isSameOriginAndPathName) ??\n redirects?.find(isTheSameDomain);\n const redirectUrlFromDifferentOrigin = redirects?.find(isHttps) ?? redirects?.find(isHttp);\n if (redirectUrlFromTheSameOrigin) {\n return redirectUrlFromTheSameOrigin;\n }\n else if (redirectUrlFromDifferentOrigin) {\n throw constants_1.invalidOriginException;\n }\n throw constants_1.invalidRedirectException;\n }\n}\nexports.getRedirectUrl = getRedirectUrl;\n// origin + pathname => https://example.com/app\nconst isSameOriginAndPathName = (redirect) => redirect.startsWith(String(window.location.origin + window.location.pathname ?? '/'));\n// domain => outlook.live.com, github.com\nconst isTheSameDomain = (redirect) => redirect.includes(String(window.location.hostname));\nconst isHttp = (redirect) => redirect.startsWith('http://');\nconst isHttps = (redirect) => redirect.startsWith('https://');\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC;AACA;AACA,MAAM,WAAW,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC5D;AACA,SAAS,cAAc,CAAC,SAAS,EAAE,oBAAoB,EAAE;AACzD,IAAI,IAAI,oBAAoB,EAAE;AAC9B,QAAQ,MAAM,WAAW,GAAG,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,oBAAoB,CAAC,CAAC;AAC3F,QAAQ,IAAI,CAAC,WAAW,EAAE;AAC1B,YAAY,MAAM,WAAW,CAAC,oCAAoC,CAAC;AACnE,SAAS;AACT,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK;AACL,SAAS;AACT,QAAQ,MAAM,4BAA4B,GAAG,SAAS,EAAE,IAAI,CAAC,uBAAuB,CAAC;AACrF,YAAY,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;AAC7C,QAAQ,MAAM,8BAA8B,GAAG,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;AACnG,QAAQ,IAAI,4BAA4B,EAAE;AAC1C,YAAY,OAAO,4BAA4B,CAAC;AAChD,SAAS;AACT,aAAa,IAAI,8BAA8B,EAAE;AACjD,YAAY,MAAM,WAAW,CAAC,sBAAsB,CAAC;AACrD,SAAS;AACT,QAAQ,MAAM,WAAW,CAAC,wBAAwB,CAAC;AACnD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AACxC;AACA,MAAM,uBAAuB,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC;AACpI;AACA,MAAM,eAAe,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1F,MAAM,MAAM,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5D,MAAM,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC;;"}
|
|
@@ -5,13 +5,24 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getRedirectUrl = void 0;
|
|
7
7
|
const constants_1 = require("../../../../errors/constants");
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/**
|
|
9
|
+
* - Validate there is always an appScheme (required), if not throw invalidAppSchemeException.
|
|
10
|
+
* - If a preferredRedirectUrl is given, validate it's in the configured list, if not throw invalidPreferredRedirectUrlException.
|
|
11
|
+
* - If preferredRedirectUrl is not given, use the appScheme which is present in the configured list.
|
|
12
|
+
@internal */
|
|
13
|
+
function getRedirectUrl(redirects, preferredRedirectUrl) {
|
|
14
|
+
// iOS always requires a non http/s url (appScheme) to be registered so we validate it's existence here.
|
|
15
|
+
const appSchemeRedirectUrl = redirects?.find(redirect => !redirect.startsWith('http://') && !redirect.startsWith('https://'));
|
|
16
|
+
if (!appSchemeRedirectUrl) {
|
|
17
|
+
throw constants_1.invalidAppSchemeException;
|
|
13
18
|
}
|
|
14
|
-
|
|
19
|
+
if (preferredRedirectUrl) {
|
|
20
|
+
if (redirects?.includes(preferredRedirectUrl)) {
|
|
21
|
+
return preferredRedirectUrl;
|
|
22
|
+
}
|
|
23
|
+
throw constants_1.invalidPreferredRedirectUrlException;
|
|
24
|
+
}
|
|
25
|
+
return appSchemeRedirectUrl;
|
|
15
26
|
}
|
|
16
27
|
exports.getRedirectUrl = getRedirectUrl;
|
|
17
28
|
//# sourceMappingURL=getRedirectUrl.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedirectUrl.native.js","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.native.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getRedirectUrl = void 0;\nconst constants_1 = require(\"../../../../errors/constants\");\n
|
|
1
|
+
{"version":3,"file":"getRedirectUrl.native.js","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.native.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getRedirectUrl = void 0;\nconst constants_1 = require(\"../../../../errors/constants\");\n/**\n* - Validate there is always an appScheme (required), if not throw invalidAppSchemeException.\n* - If a preferredRedirectUrl is given, validate it's in the configured list, if not throw invalidPreferredRedirectUrlException.\n* - If preferredRedirectUrl is not given, use the appScheme which is present in the configured list.\n@internal */\nfunction getRedirectUrl(redirects, preferredRedirectUrl) {\n // iOS always requires a non http/s url (appScheme) to be registered so we validate it's existence here.\n const appSchemeRedirectUrl = redirects?.find(redirect => !redirect.startsWith('http://') && !redirect.startsWith('https://'));\n if (!appSchemeRedirectUrl) {\n throw constants_1.invalidAppSchemeException;\n }\n if (preferredRedirectUrl) {\n if (redirects?.includes(preferredRedirectUrl)) {\n return preferredRedirectUrl;\n }\n throw constants_1.invalidPreferredRedirectUrlException;\n }\n return appSchemeRedirectUrl;\n}\nexports.getRedirectUrl = getRedirectUrl;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,WAAW,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC5D;AACA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,SAAS,EAAE,oBAAoB,EAAE;AACzD;AACA,IAAI,MAAM,oBAAoB,GAAG,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AAClI,IAAI,IAAI,CAAC,oBAAoB,EAAE;AAC/B,QAAQ,MAAM,WAAW,CAAC,yBAAyB,CAAC;AACpD,KAAK;AACL,IAAI,IAAI,oBAAoB,EAAE;AAC9B,QAAQ,IAAI,SAAS,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EAAE;AACvD,YAAY,OAAO,oBAAoB,CAAC;AACxC,SAAS;AACT,QAAQ,MAAM,WAAW,CAAC,oCAAoC,CAAC;AAC/D,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC;AAChC,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.handleOAuthSignOut = void 0;
|
|
7
7
|
const completeOAuthSignOut_1 = require("./completeOAuthSignOut");
|
|
8
8
|
const oAuthSignOutRedirect_1 = require("./oAuthSignOutRedirect");
|
|
9
|
-
const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator) => {
|
|
9
|
+
const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator, redirectUrl) => {
|
|
10
10
|
const { isOAuthSignIn } = await store.loadOAuthSignIn();
|
|
11
11
|
const oauthMetadata = await tokenOrchestrator.getOAuthMetadata();
|
|
12
12
|
// Clear everything before attempting to visted logout endpoint since the current application
|
|
@@ -20,7 +20,7 @@ const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator) => {
|
|
|
20
20
|
// storage mechanism that is used by Amplify.
|
|
21
21
|
if (isOAuthSignIn || oauthMetadata?.oauthSignIn) {
|
|
22
22
|
// On web, this will always end up being a void action
|
|
23
|
-
return (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig);
|
|
23
|
+
return (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig, false, redirectUrl);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
exports.handleOAuthSignOut = handleOAuthSignOut;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleOAuthSignOut.js","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handleOAuthSignOut = void 0;\nconst completeOAuthSignOut_1 = require(\"./completeOAuthSignOut\");\nconst oAuthSignOutRedirect_1 = require(\"./oAuthSignOutRedirect\");\nconst handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator) => {\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 (0, completeOAuthSignOut_1.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 (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig);\n }\n};\nexports.handleOAuthSignOut = handleOAuthSignOut;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK,EAAE,iBAAiB,KAAK;
|
|
1
|
+
{"version":3,"file":"handleOAuthSignOut.js","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handleOAuthSignOut = void 0;\nconst completeOAuthSignOut_1 = require(\"./completeOAuthSignOut\");\nconst oAuthSignOutRedirect_1 = require(\"./oAuthSignOutRedirect\");\nconst 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 (0, completeOAuthSignOut_1.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 (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig, false, redirectUrl);\n }\n};\nexports.handleOAuthSignOut = handleOAuthSignOut;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,KAAK;AAC3F,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;AAC5D,IAAI,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;AACrE;AACA;AACA,IAAI,MAAM,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AAClE;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,aAAa,IAAI,aAAa,EAAE,WAAW,EAAE;AACrD;AACA,QAAQ,OAAO,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;AACnG,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.handleOAuthSignOut = void 0;
|
|
7
7
|
const completeOAuthSignOut_1 = require("./completeOAuthSignOut");
|
|
8
8
|
const oAuthSignOutRedirect_1 = require("./oAuthSignOutRedirect");
|
|
9
|
-
const handleOAuthSignOut = async (cognitoConfig, store
|
|
9
|
+
const handleOAuthSignOut = async (cognitoConfig, store,
|
|
10
|
+
// No-op here as it's only used in the non-native implementation
|
|
11
|
+
tokenOrchestrator, redirectUrl) => {
|
|
10
12
|
const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();
|
|
11
13
|
if (isOAuthSignIn) {
|
|
12
|
-
const result = await (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig, preferPrivateSession);
|
|
14
|
+
const result = await (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig, preferPrivateSession, redirectUrl);
|
|
13
15
|
// If this was a private session, clear data and tokens regardless of what happened with logout
|
|
14
16
|
// endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.
|
|
15
17
|
const shouldCompleteSignOut = preferPrivateSession || result?.type === 'success';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleOAuthSignOut.native.js","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.native.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handleOAuthSignOut = void 0;\nconst completeOAuthSignOut_1 = require(\"./completeOAuthSignOut\");\nconst oAuthSignOutRedirect_1 = require(\"./oAuthSignOutRedirect\");\nconst handleOAuthSignOut = async (cognitoConfig, store) => {\n const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();\n if (isOAuthSignIn) {\n const result = await (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig, preferPrivateSession);\n // If this was a private session, clear data and tokens regardless of what happened with logout\n // endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.\n const shouldCompleteSignOut = preferPrivateSession || result?.type === 'success';\n if (shouldCompleteSignOut) {\n await (0, completeOAuthSignOut_1.completeOAuthSignOut)(store);\n }\n return result;\n }\n return (0, completeOAuthSignOut_1.completeOAuthSignOut)(store);\n};\nexports.handleOAuthSignOut = handleOAuthSignOut;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"handleOAuthSignOut.native.js","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.native.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handleOAuthSignOut = void 0;\nconst completeOAuthSignOut_1 = require(\"./completeOAuthSignOut\");\nconst oAuthSignOutRedirect_1 = require(\"./oAuthSignOutRedirect\");\nconst handleOAuthSignOut = async (cognitoConfig, store, \n// No-op here as it's only used in the non-native implementation\ntokenOrchestrator, redirectUrl) => {\n const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();\n if (isOAuthSignIn) {\n const result = await (0, oAuthSignOutRedirect_1.oAuthSignOutRedirect)(cognitoConfig, preferPrivateSession, redirectUrl);\n // If this was a private session, clear data and tokens regardless of what happened with logout\n // endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.\n const shouldCompleteSignOut = preferPrivateSession || result?.type === 'success';\n if (shouldCompleteSignOut) {\n await (0, completeOAuthSignOut_1.completeOAuthSignOut)(store);\n }\n return result;\n }\n return (0, completeOAuthSignOut_1.completeOAuthSignOut)(store);\n};\nexports.handleOAuthSignOut = handleOAuthSignOut;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK;AACtD;AACA,iBAAiB,EAAE,WAAW,KAAK;AACnC,IAAI,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;AAClF,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,MAAM,MAAM,GAAG,MAAM,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC;AAChI;AACA;AACA,QAAQ,MAAM,qBAAqB,GAAG,oBAAoB,IAAI,MAAM,EAAE,IAAI,KAAK,SAAS,CAAC;AACzF,QAAQ,IAAI,qBAAqB,EAAE;AACnC,YAAY,MAAM,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AAC1E,SAAS;AACT,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK;AACL,IAAI,OAAO,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;AACnE,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -7,11 +7,11 @@ exports.oAuthSignOutRedirect = void 0;
|
|
|
7
7
|
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
8
|
const utils_2 = require("../../../../utils");
|
|
9
9
|
const getRedirectUrl_1 = require("./getRedirectUrl");
|
|
10
|
-
const oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false) => {
|
|
10
|
+
const oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false, redirectUrl) => {
|
|
11
11
|
(0, utils_1.assertOAuthConfig)(authConfig);
|
|
12
12
|
const { loginWith, userPoolClientId } = authConfig;
|
|
13
13
|
const { domain, redirectSignOut } = loginWith.oauth;
|
|
14
|
-
const signoutUri = (0, getRedirectUrl_1.getRedirectUrl)(redirectSignOut);
|
|
14
|
+
const signoutUri = (0, getRedirectUrl_1.getRedirectUrl)(redirectSignOut, redirectUrl);
|
|
15
15
|
const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({
|
|
16
16
|
client_id: userPoolClientId,
|
|
17
17
|
logout_uri: encodeURIComponent(signoutUri),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthSignOutRedirect.js","sources":["../../../../../../src/providers/cognito/utils/oauth/oAuthSignOutRedirect.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.oAuthSignOutRedirect = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../../../utils\");\nconst getRedirectUrl_1 = require(\"./getRedirectUrl\");\nconst oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false) => {\n (0, utils_1.assertOAuthConfig)(authConfig);\n const { loginWith, userPoolClientId } = authConfig;\n const { domain, redirectSignOut } = loginWith.oauth;\n const signoutUri = (0, getRedirectUrl_1.getRedirectUrl)(redirectSignOut);\n const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({\n client_id: userPoolClientId,\n logout_uri: encodeURIComponent(signoutUri),\n })\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`;\n return (0, utils_2.openAuthSession)(oAuthLogoutEndpoint, redirectSignOut, preferPrivateSession);\n};\nexports.oAuthSignOutRedirect = oAuthSignOutRedirect;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACrD,MAAM,oBAAoB,GAAG,OAAO,UAAU,EAAE,oBAAoB,GAAG,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"oAuthSignOutRedirect.js","sources":["../../../../../../src/providers/cognito/utils/oauth/oAuthSignOutRedirect.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.oAuthSignOutRedirect = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../../../utils\");\nconst getRedirectUrl_1 = require(\"./getRedirectUrl\");\nconst oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false, redirectUrl) => {\n (0, utils_1.assertOAuthConfig)(authConfig);\n const { loginWith, userPoolClientId } = authConfig;\n const { domain, redirectSignOut } = loginWith.oauth;\n const signoutUri = (0, getRedirectUrl_1.getRedirectUrl)(redirectSignOut, redirectUrl);\n const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({\n client_id: userPoolClientId,\n logout_uri: encodeURIComponent(signoutUri),\n })\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`;\n return (0, utils_2.openAuthSession)(oAuthLogoutEndpoint, redirectSignOut, preferPrivateSession);\n};\nexports.oAuthSignOutRedirect = oAuthSignOutRedirect;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACrD,MAAM,oBAAoB,GAAG,OAAO,UAAU,EAAE,oBAAoB,GAAG,KAAK,EAAE,WAAW,KAAK;AAC9F,IAAI,IAAI,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AAC/C,IAAI,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC;AACxD,IAAI,MAAM,UAAU,GAAG,IAAI,gBAAgB,CAAC,cAAc,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;AAC1F,IAAI,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;AAC3E,QAAQ,SAAS,EAAE,gBAAgB;AACnC,QAAQ,UAAU,EAAE,kBAAkB,CAAC,UAAU,CAAC;AAClD,KAAK,CAAC;AACN,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,SAAS,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACrB,IAAI,OAAO,IAAI,OAAO,CAAC,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,oBAAoB,CAAC,CAAC;AACpG,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
|
|
@@ -4,7 +4,11 @@ export declare const USER_ALREADY_AUTHENTICATED_EXCEPTION = "UserAlreadyAuthenti
|
|
|
4
4
|
export declare const DEVICE_METADATA_NOT_FOUND_EXCEPTION = "DeviceMetadataNotFoundException";
|
|
5
5
|
export declare const AUTO_SIGN_IN_EXCEPTION = "AutoSignInException";
|
|
6
6
|
export declare const INVALID_REDIRECT_EXCEPTION = "InvalidRedirectException";
|
|
7
|
+
export declare const INVALID_APP_SCHEME_EXCEPTION = "InvalidAppSchemeException";
|
|
8
|
+
export declare const INVALID_PREFERRED_REDIRECT_EXCEPTION = "InvalidPreferredRedirectUrlException";
|
|
7
9
|
export declare const invalidRedirectException: AuthError;
|
|
10
|
+
export declare const invalidAppSchemeException: AuthError;
|
|
11
|
+
export declare const invalidPreferredRedirectUrlException: AuthError;
|
|
8
12
|
export declare const INVALID_ORIGIN_EXCEPTION = "InvalidOriginException";
|
|
9
13
|
export declare const invalidOriginException: AuthError;
|
|
10
14
|
export declare const OAUTH_SIGNOUT_EXCEPTION = "OAuthSignOutException";
|
|
@@ -7,11 +7,23 @@ const USER_ALREADY_AUTHENTICATED_EXCEPTION = 'UserAlreadyAuthenticatedException'
|
|
|
7
7
|
const DEVICE_METADATA_NOT_FOUND_EXCEPTION = 'DeviceMetadataNotFoundException';
|
|
8
8
|
const AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';
|
|
9
9
|
const INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';
|
|
10
|
+
const INVALID_APP_SCHEME_EXCEPTION = 'InvalidAppSchemeException';
|
|
11
|
+
const INVALID_PREFERRED_REDIRECT_EXCEPTION = 'InvalidPreferredRedirectUrlException';
|
|
10
12
|
const invalidRedirectException = new AuthError({
|
|
11
13
|
name: INVALID_REDIRECT_EXCEPTION,
|
|
12
14
|
message: 'signInRedirect or signOutRedirect had an invalid format or was not found.',
|
|
13
15
|
recoverySuggestion: 'Please make sure the signIn/Out redirect in your oauth config is valid.',
|
|
14
16
|
});
|
|
17
|
+
const invalidAppSchemeException = new AuthError({
|
|
18
|
+
name: INVALID_APP_SCHEME_EXCEPTION,
|
|
19
|
+
message: 'A valid non-http app scheme was not found in the config.',
|
|
20
|
+
recoverySuggestion: 'Please make sure a valid custom app scheme is present in the config.',
|
|
21
|
+
});
|
|
22
|
+
const invalidPreferredRedirectUrlException = new AuthError({
|
|
23
|
+
name: INVALID_PREFERRED_REDIRECT_EXCEPTION,
|
|
24
|
+
message: 'The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.',
|
|
25
|
+
recoverySuggestion: 'Please make sure a matching preferredRedirectUrl is provided.',
|
|
26
|
+
});
|
|
15
27
|
const INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';
|
|
16
28
|
const invalidOriginException = new AuthError({
|
|
17
29
|
name: INVALID_ORIGIN_EXCEPTION,
|
|
@@ -22,5 +34,5 @@ const OAUTH_SIGNOUT_EXCEPTION = 'OAuthSignOutException';
|
|
|
22
34
|
const TOKEN_REFRESH_EXCEPTION = 'TokenRefreshException';
|
|
23
35
|
const UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = 'UnexpectedSignInInterruptionException';
|
|
24
36
|
|
|
25
|
-
export { AUTO_SIGN_IN_EXCEPTION, DEVICE_METADATA_NOT_FOUND_EXCEPTION, INVALID_ORIGIN_EXCEPTION, INVALID_REDIRECT_EXCEPTION, OAUTH_SIGNOUT_EXCEPTION, TOKEN_REFRESH_EXCEPTION, UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION, USER_ALREADY_AUTHENTICATED_EXCEPTION, USER_UNAUTHENTICATED_EXCEPTION, invalidOriginException, invalidRedirectException };
|
|
37
|
+
export { AUTO_SIGN_IN_EXCEPTION, DEVICE_METADATA_NOT_FOUND_EXCEPTION, INVALID_APP_SCHEME_EXCEPTION, INVALID_ORIGIN_EXCEPTION, INVALID_PREFERRED_REDIRECT_EXCEPTION, INVALID_REDIRECT_EXCEPTION, OAUTH_SIGNOUT_EXCEPTION, TOKEN_REFRESH_EXCEPTION, UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION, USER_ALREADY_AUTHENTICATED_EXCEPTION, USER_UNAUTHENTICATED_EXCEPTION, invalidAppSchemeException, invalidOriginException, invalidPreferredRedirectUrlException, invalidRedirectException };
|
|
26
38
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../../../src/errors/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from './AuthError';\nexport const USER_UNAUTHENTICATED_EXCEPTION = 'UserUnAuthenticatedException';\nexport const USER_ALREADY_AUTHENTICATED_EXCEPTION = 'UserAlreadyAuthenticatedException';\nexport const DEVICE_METADATA_NOT_FOUND_EXCEPTION = 'DeviceMetadataNotFoundException';\nexport const AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';\nexport const INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';\nexport const invalidRedirectException = new AuthError({\n name: INVALID_REDIRECT_EXCEPTION,\n message: 'signInRedirect or signOutRedirect had an invalid format or was not found.',\n recoverySuggestion: 'Please make sure the signIn/Out redirect in your oauth config is valid.',\n});\nexport const INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';\nexport const invalidOriginException = new AuthError({\n name: INVALID_ORIGIN_EXCEPTION,\n message: 'redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin',\n recoverySuggestion: 'Please call signInWithRedirect from the same origin.',\n});\nexport const OAUTH_SIGNOUT_EXCEPTION = 'OAuthSignOutException';\nexport const TOKEN_REFRESH_EXCEPTION = 'TokenRefreshException';\nexport const UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = 'UnexpectedSignInInterruptionException';\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,8BAA8B,GAAG,+BAA+B;AACjE,MAAC,oCAAoC,GAAG,oCAAoC;AAC5E,MAAC,mCAAmC,GAAG,kCAAkC;AACzE,MAAC,sBAAsB,GAAG,sBAAsB;AAChD,MAAC,0BAA0B,GAAG,2BAA2B;AACzD,MAAC,wBAAwB,GAAG,IAAI,SAAS,CAAC;AACtD,IAAI,IAAI,EAAE,0BAA0B;AACpC,IAAI,OAAO,EAAE,2EAA2E;AACxF,IAAI,kBAAkB,EAAE,yEAAyE;AACjG,CAAC,EAAE;AACS,MAAC,wBAAwB,GAAG,yBAAyB;AACrD,MAAC,sBAAsB,GAAG,IAAI,SAAS,CAAC;AACpD,IAAI,IAAI,EAAE,wBAAwB;AAClC,IAAI,OAAO,EAAE,uGAAuG;AACpH,IAAI,kBAAkB,EAAE,sDAAsD;AAC9E,CAAC,EAAE;AACS,MAAC,uBAAuB,GAAG,wBAAwB;AACnD,MAAC,uBAAuB,GAAG,wBAAwB;AACnD,MAAC,yCAAyC,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../src/errors/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from './AuthError';\nexport const USER_UNAUTHENTICATED_EXCEPTION = 'UserUnAuthenticatedException';\nexport const USER_ALREADY_AUTHENTICATED_EXCEPTION = 'UserAlreadyAuthenticatedException';\nexport const DEVICE_METADATA_NOT_FOUND_EXCEPTION = 'DeviceMetadataNotFoundException';\nexport const AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';\nexport const INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';\nexport const INVALID_APP_SCHEME_EXCEPTION = 'InvalidAppSchemeException';\nexport const INVALID_PREFERRED_REDIRECT_EXCEPTION = 'InvalidPreferredRedirectUrlException';\nexport const invalidRedirectException = new AuthError({\n name: INVALID_REDIRECT_EXCEPTION,\n message: 'signInRedirect or signOutRedirect had an invalid format or was not found.',\n recoverySuggestion: 'Please make sure the signIn/Out redirect in your oauth config is valid.',\n});\nexport const invalidAppSchemeException = new AuthError({\n name: INVALID_APP_SCHEME_EXCEPTION,\n message: 'A valid non-http app scheme was not found in the config.',\n recoverySuggestion: 'Please make sure a valid custom app scheme is present in the config.',\n});\nexport const invalidPreferredRedirectUrlException = new AuthError({\n name: INVALID_PREFERRED_REDIRECT_EXCEPTION,\n message: 'The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.',\n recoverySuggestion: 'Please make sure a matching preferredRedirectUrl is provided.',\n});\nexport const INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';\nexport const invalidOriginException = new AuthError({\n name: INVALID_ORIGIN_EXCEPTION,\n message: 'redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin',\n recoverySuggestion: 'Please call signInWithRedirect from the same origin.',\n});\nexport const OAUTH_SIGNOUT_EXCEPTION = 'OAuthSignOutException';\nexport const TOKEN_REFRESH_EXCEPTION = 'TokenRefreshException';\nexport const UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = 'UnexpectedSignInInterruptionException';\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,8BAA8B,GAAG,+BAA+B;AACjE,MAAC,oCAAoC,GAAG,oCAAoC;AAC5E,MAAC,mCAAmC,GAAG,kCAAkC;AACzE,MAAC,sBAAsB,GAAG,sBAAsB;AAChD,MAAC,0BAA0B,GAAG,2BAA2B;AACzD,MAAC,4BAA4B,GAAG,4BAA4B;AAC5D,MAAC,oCAAoC,GAAG,uCAAuC;AAC/E,MAAC,wBAAwB,GAAG,IAAI,SAAS,CAAC;AACtD,IAAI,IAAI,EAAE,0BAA0B;AACpC,IAAI,OAAO,EAAE,2EAA2E;AACxF,IAAI,kBAAkB,EAAE,yEAAyE;AACjG,CAAC,EAAE;AACS,MAAC,yBAAyB,GAAG,IAAI,SAAS,CAAC;AACvD,IAAI,IAAI,EAAE,4BAA4B;AACtC,IAAI,OAAO,EAAE,0DAA0D;AACvE,IAAI,kBAAkB,EAAE,sEAAsE;AAC9F,CAAC,EAAE;AACS,MAAC,oCAAoC,GAAG,IAAI,SAAS,CAAC;AAClE,IAAI,IAAI,EAAE,oCAAoC;AAC9C,IAAI,OAAO,EAAE,2GAA2G;AACxH,IAAI,kBAAkB,EAAE,+DAA+D;AACvF,CAAC,EAAE;AACS,MAAC,wBAAwB,GAAG,yBAAyB;AACrD,MAAC,sBAAsB,GAAG,IAAI,SAAS,CAAC;AACpD,IAAI,IAAI,EAAE,wBAAwB;AAClC,IAAI,OAAO,EAAE,uGAAuG;AACpH,IAAI,kBAAkB,EAAE,sDAAsD;AAC9E,CAAC,EAAE;AACS,MAAC,uBAAuB,GAAG,wBAAwB;AACnD,MAAC,uBAAuB,GAAG,wBAAwB;AACnD,MAAC,yCAAyC,GAAG;;;;"}
|
|
@@ -45,11 +45,11 @@ async function signOut(input) {
|
|
|
45
45
|
if (hasOAuthConfig) {
|
|
46
46
|
const oAuthStore = new DefaultOAuthStore(defaultStorage);
|
|
47
47
|
oAuthStore.setAuthConfig(cognitoConfig);
|
|
48
|
-
const { type } = (await handleOAuthSignOut(cognitoConfig, oAuthStore, tokenOrchestrator)) ?? {};
|
|
48
|
+
const { type } = (await handleOAuthSignOut(cognitoConfig, oAuthStore, tokenOrchestrator, input?.oauth?.redirectUrl)) ?? {};
|
|
49
49
|
if (type === 'error') {
|
|
50
50
|
throw new AuthError({
|
|
51
51
|
name: OAUTH_SIGNOUT_EXCEPTION,
|
|
52
|
-
message:
|
|
52
|
+
message: `An error occurred when attempting to log out from OAuth provider.`,
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -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 { globalSignOut as globalSignOutClient, revokeToken, } from '../utils/clients/CognitoIdentityProvider';\nimport { getRegion } from '../utils/clients/CognitoIdentityProvider/utils';\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';\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)) ?? {};\n if (type === 'error') {\n throw new AuthError({\n name: OAUTH_SIGNOUT_EXCEPTION,\n message:
|
|
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 { globalSignOut as globalSignOutClient, revokeToken, } from '../utils/clients/CognitoIdentityProvider';\nimport { getRegion } from '../utils/clients/CognitoIdentityProvider/utils';\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';\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 authTokens = await tokenOrchestrator.getTokenStore().loadTokens();\n assertAuthTokensWithRefreshToken(authTokens);\n if (isSessionRevocable(authTokens.accessToken)) {\n await revokeToken({\n region: getRegion(cognitoConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignOut),\n }, {\n ClientId: cognitoConfig.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 authTokens = await tokenOrchestrator.getTokenStore().loadTokens();\n assertAuthTokens(authTokens);\n await globalSignOutClient({\n region: getRegion(cognitoConfig.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":["globalSignOutClient"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export declare function getRedirectUrl(redirects: string[]): string;
|
|
2
|
+
export declare function getRedirectUrl(redirects: string[], preferredRedirectUrl?: string): string;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { invalidOriginException, invalidRedirectException } from '../../../../errors/constants.mjs';
|
|
1
|
+
import { invalidPreferredRedirectUrlException, invalidOriginException, invalidRedirectException } from '../../../../errors/constants.mjs';
|
|
2
2
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
/** @internal */
|
|
6
|
-
function getRedirectUrl(redirects) {
|
|
7
|
-
|
|
8
|
-
redirects?.find(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
function getRedirectUrl(redirects, preferredRedirectUrl) {
|
|
7
|
+
if (preferredRedirectUrl) {
|
|
8
|
+
const redirectUrl = redirects?.find(redirect => redirect === preferredRedirectUrl);
|
|
9
|
+
if (!redirectUrl) {
|
|
10
|
+
throw invalidPreferredRedirectUrlException;
|
|
11
|
+
}
|
|
12
|
+
return redirectUrl;
|
|
12
13
|
}
|
|
13
|
-
else
|
|
14
|
-
|
|
14
|
+
else {
|
|
15
|
+
const redirectUrlFromTheSameOrigin = redirects?.find(isSameOriginAndPathName) ??
|
|
16
|
+
redirects?.find(isTheSameDomain);
|
|
17
|
+
const redirectUrlFromDifferentOrigin = redirects?.find(isHttps) ?? redirects?.find(isHttp);
|
|
18
|
+
if (redirectUrlFromTheSameOrigin) {
|
|
19
|
+
return redirectUrlFromTheSameOrigin;
|
|
20
|
+
}
|
|
21
|
+
else if (redirectUrlFromDifferentOrigin) {
|
|
22
|
+
throw invalidOriginException;
|
|
23
|
+
}
|
|
24
|
+
throw invalidRedirectException;
|
|
15
25
|
}
|
|
16
|
-
throw invalidRedirectException;
|
|
17
26
|
}
|
|
18
27
|
// origin + pathname => https://example.com/app
|
|
19
28
|
const isSameOriginAndPathName = (redirect) => redirect.startsWith(String(window.location.origin + window.location.pathname ?? '/'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedirectUrl.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { invalidOriginException, invalidRedirectException, } from '../../../../errors/constants';\n/** @internal */\nexport function getRedirectUrl(redirects) {\n const redirectUrlFromTheSameOrigin = redirects?.find(isSameOriginAndPathName) ??\n
|
|
1
|
+
{"version":3,"file":"getRedirectUrl.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { invalidOriginException, invalidPreferredRedirectUrlException, invalidRedirectException, } from '../../../../errors/constants';\n/** @internal */\nexport function getRedirectUrl(redirects, preferredRedirectUrl) {\n if (preferredRedirectUrl) {\n const redirectUrl = redirects?.find(redirect => redirect === preferredRedirectUrl);\n if (!redirectUrl) {\n throw invalidPreferredRedirectUrlException;\n }\n return redirectUrl;\n }\n else {\n const redirectUrlFromTheSameOrigin = redirects?.find(isSameOriginAndPathName) ??\n redirects?.find(isTheSameDomain);\n const redirectUrlFromDifferentOrigin = redirects?.find(isHttps) ?? redirects?.find(isHttp);\n if (redirectUrlFromTheSameOrigin) {\n return redirectUrlFromTheSameOrigin;\n }\n else if (redirectUrlFromDifferentOrigin) {\n throw invalidOriginException;\n }\n throw invalidRedirectException;\n }\n}\n// origin + pathname => https://example.com/app\nconst isSameOriginAndPathName = (redirect) => redirect.startsWith(String(window.location.origin + window.location.pathname ?? '/'));\n// domain => outlook.live.com, github.com\nconst isTheSameDomain = (redirect) => redirect.includes(String(window.location.hostname));\nconst isHttp = (redirect) => redirect.startsWith('http://');\nconst isHttps = (redirect) => redirect.startsWith('https://');\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACO,SAAS,cAAc,CAAC,SAAS,EAAE,oBAAoB,EAAE;AAChE,IAAI,IAAI,oBAAoB,EAAE;AAC9B,QAAQ,MAAM,WAAW,GAAG,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,oBAAoB,CAAC,CAAC;AAC3F,QAAQ,IAAI,CAAC,WAAW,EAAE;AAC1B,YAAY,MAAM,oCAAoC,CAAC;AACvD,SAAS;AACT,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK;AACL,SAAS;AACT,QAAQ,MAAM,4BAA4B,GAAG,SAAS,EAAE,IAAI,CAAC,uBAAuB,CAAC;AACrF,YAAY,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;AAC7C,QAAQ,MAAM,8BAA8B,GAAG,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;AACnG,QAAQ,IAAI,4BAA4B,EAAE;AAC1C,YAAY,OAAO,4BAA4B,CAAC;AAChD,SAAS;AACT,aAAa,IAAI,8BAA8B,EAAE;AACjD,YAAY,MAAM,sBAAsB,CAAC;AACzC,SAAS;AACT,QAAQ,MAAM,wBAAwB,CAAC;AACvC,KAAK;AACL,CAAC;AACD;AACA,MAAM,uBAAuB,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC;AACpI;AACA,MAAM,eAAe,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1F,MAAM,MAAM,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5D,MAAM,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC;;;;"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* - Validate there is always an appScheme (required), if not throw invalidAppSchemeException.
|
|
3
|
+
* - If a preferredRedirectUrl is given, validate it's in the configured list, if not throw invalidPreferredRedirectUrlException.
|
|
4
|
+
* - If preferredRedirectUrl is not given, use the appScheme which is present in the configured list.
|
|
5
|
+
@internal */
|
|
6
|
+
export declare function getRedirectUrl(redirects: string[], preferredRedirectUrl?: string): string;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { invalidAppSchemeException, invalidPreferredRedirectUrlException } from '../../../../errors/constants.mjs';
|
|
2
2
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* - Validate there is always an appScheme (required), if not throw invalidAppSchemeException.
|
|
7
|
+
* - If a preferredRedirectUrl is given, validate it's in the configured list, if not throw invalidPreferredRedirectUrlException.
|
|
8
|
+
* - If preferredRedirectUrl is not given, use the appScheme which is present in the configured list.
|
|
9
|
+
@internal */
|
|
10
|
+
function getRedirectUrl(redirects, preferredRedirectUrl) {
|
|
11
|
+
// iOS always requires a non http/s url (appScheme) to be registered so we validate it's existence here.
|
|
12
|
+
const appSchemeRedirectUrl = redirects?.find(redirect => !redirect.startsWith('http://') && !redirect.startsWith('https://'));
|
|
13
|
+
if (!appSchemeRedirectUrl) {
|
|
14
|
+
throw invalidAppSchemeException;
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
if (preferredRedirectUrl) {
|
|
17
|
+
if (redirects?.includes(preferredRedirectUrl)) {
|
|
18
|
+
return preferredRedirectUrl;
|
|
19
|
+
}
|
|
20
|
+
throw invalidPreferredRedirectUrlException;
|
|
21
|
+
}
|
|
22
|
+
return appSchemeRedirectUrl;
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
export { getRedirectUrl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedirectUrl.native.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport {
|
|
1
|
+
{"version":3,"file":"getRedirectUrl.native.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/getRedirectUrl.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { invalidAppSchemeException, invalidPreferredRedirectUrlException, } from '../../../../errors/constants';\n/**\n* - Validate there is always an appScheme (required), if not throw invalidAppSchemeException.\n* - If a preferredRedirectUrl is given, validate it's in the configured list, if not throw invalidPreferredRedirectUrlException.\n* - If preferredRedirectUrl is not given, use the appScheme which is present in the configured list.\n@internal */\nexport function getRedirectUrl(redirects, preferredRedirectUrl) {\n // iOS always requires a non http/s url (appScheme) to be registered so we validate it's existence here.\n const appSchemeRedirectUrl = redirects?.find(redirect => !redirect.startsWith('http://') && !redirect.startsWith('https://'));\n if (!appSchemeRedirectUrl) {\n throw invalidAppSchemeException;\n }\n if (preferredRedirectUrl) {\n if (redirects?.includes(preferredRedirectUrl)) {\n return preferredRedirectUrl;\n }\n throw invalidPreferredRedirectUrlException;\n }\n return appSchemeRedirectUrl;\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,SAAS,EAAE,oBAAoB,EAAE;AAChE;AACA,IAAI,MAAM,oBAAoB,GAAG,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AAClI,IAAI,IAAI,CAAC,oBAAoB,EAAE;AAC/B,QAAQ,MAAM,yBAAyB,CAAC;AACxC,KAAK;AACL,IAAI,IAAI,oBAAoB,EAAE;AAC9B,QAAQ,IAAI,SAAS,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EAAE;AACvD,YAAY,OAAO,oBAAoB,CAAC;AACxC,SAAS;AACT,QAAQ,MAAM,oCAAoC,CAAC;AACnD,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC;AAChC;;;;"}
|
|
@@ -2,4 +2,4 @@ import { CognitoUserPoolConfig } from '@aws-amplify/core';
|
|
|
2
2
|
import { OpenAuthSessionResult } from '../../../../utils/types';
|
|
3
3
|
import { DefaultOAuthStore } from '../../utils/signInWithRedirectStore';
|
|
4
4
|
import { TokenOrchestrator } from '../../tokenProvider';
|
|
5
|
-
export declare const handleOAuthSignOut: (cognitoConfig: CognitoUserPoolConfig, store: DefaultOAuthStore, tokenOrchestrator: TokenOrchestrator) => Promise<void | OpenAuthSessionResult>;
|
|
5
|
+
export declare const handleOAuthSignOut: (cognitoConfig: CognitoUserPoolConfig, store: DefaultOAuthStore, tokenOrchestrator: TokenOrchestrator, redirectUrl: string | undefined) => Promise<void | OpenAuthSessionResult>;
|
|
@@ -3,7 +3,7 @@ import { oAuthSignOutRedirect } from './oAuthSignOutRedirect.mjs';
|
|
|
3
3
|
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator) => {
|
|
6
|
+
const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator, redirectUrl) => {
|
|
7
7
|
const { isOAuthSignIn } = await store.loadOAuthSignIn();
|
|
8
8
|
const oauthMetadata = await tokenOrchestrator.getOAuthMetadata();
|
|
9
9
|
// Clear everything before attempting to visted logout endpoint since the current application
|
|
@@ -17,7 +17,7 @@ const handleOAuthSignOut = async (cognitoConfig, store, tokenOrchestrator) => {
|
|
|
17
17
|
// storage mechanism that is used by Amplify.
|
|
18
18
|
if (isOAuthSignIn || oauthMetadata?.oauthSignIn) {
|
|
19
19
|
// On web, this will always end up being a void action
|
|
20
|
-
return oAuthSignOutRedirect(cognitoConfig);
|
|
20
|
+
return oAuthSignOutRedirect(cognitoConfig, false, redirectUrl);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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) => {\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);\n }\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK,EAAE,iBAAiB,KAAK;
|
|
1
|
+
{"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,CAAC;AAC5D,IAAI,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;AACrE;AACA;AACA,IAAI,MAAM,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACtC;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,CAAC;AACvE,KAAK;AACL;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CognitoUserPoolConfig } from '@aws-amplify/core';
|
|
2
2
|
import { OpenAuthSessionResult } from '../../../../utils/types';
|
|
3
3
|
import { DefaultOAuthStore } from '../../utils/signInWithRedirectStore';
|
|
4
|
-
|
|
4
|
+
import { TokenOrchestrator } from '../../tokenProvider';
|
|
5
|
+
export declare const handleOAuthSignOut: (cognitoConfig: CognitoUserPoolConfig, store: DefaultOAuthStore, tokenOrchestrator: TokenOrchestrator, redirectUrl: string | undefined) => Promise<void | OpenAuthSessionResult>;
|
|
@@ -3,10 +3,12 @@ import { oAuthSignOutRedirect } from './oAuthSignOutRedirect.mjs';
|
|
|
3
3
|
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
const handleOAuthSignOut = async (cognitoConfig, store
|
|
6
|
+
const handleOAuthSignOut = async (cognitoConfig, store,
|
|
7
|
+
// No-op here as it's only used in the non-native implementation
|
|
8
|
+
tokenOrchestrator, redirectUrl) => {
|
|
7
9
|
const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();
|
|
8
10
|
if (isOAuthSignIn) {
|
|
9
|
-
const result = await oAuthSignOutRedirect(cognitoConfig, preferPrivateSession);
|
|
11
|
+
const result = await oAuthSignOutRedirect(cognitoConfig, preferPrivateSession, redirectUrl);
|
|
10
12
|
// If this was a private session, clear data and tokens regardless of what happened with logout
|
|
11
13
|
// endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.
|
|
12
14
|
const shouldCompleteSignOut = preferPrivateSession || result?.type === 'success';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleOAuthSignOut.native.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.native.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) => {\n const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();\n if (isOAuthSignIn) {\n const result = await oAuthSignOutRedirect(cognitoConfig, preferPrivateSession);\n // If this was a private session, clear data and tokens regardless of what happened with logout\n // endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.\n const shouldCompleteSignOut = preferPrivateSession || result?.type === 'success';\n if (shouldCompleteSignOut) {\n await completeOAuthSignOut(store);\n }\n return result;\n }\n return completeOAuthSignOut(store);\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"handleOAuthSignOut.native.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/handleOAuthSignOut.native.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, \n// No-op here as it's only used in the non-native implementation\ntokenOrchestrator, redirectUrl) => {\n const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();\n if (isOAuthSignIn) {\n const result = await oAuthSignOutRedirect(cognitoConfig, preferPrivateSession, redirectUrl);\n // If this was a private session, clear data and tokens regardless of what happened with logout\n // endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.\n const shouldCompleteSignOut = preferPrivateSession || result?.type === 'success';\n if (shouldCompleteSignOut) {\n await completeOAuthSignOut(store);\n }\n return result;\n }\n return completeOAuthSignOut(store);\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,kBAAkB,GAAG,OAAO,aAAa,EAAE,KAAK;AAC7D;AACA,iBAAiB,EAAE,WAAW,KAAK;AACnC,IAAI,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;AAClF,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,aAAa,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC;AACpG;AACA;AACA,QAAQ,MAAM,qBAAqB,GAAG,oBAAoB,IAAI,MAAM,EAAE,IAAI,KAAK,SAAS,CAAC;AACzF,QAAQ,IAAI,qBAAqB,EAAE;AACnC,YAAY,MAAM,oBAAoB,CAAC,KAAK,CAAC,CAAC;AAC9C,SAAS;AACT,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACvC;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { CognitoUserPoolConfig } from '@aws-amplify/core';
|
|
2
2
|
import { OpenAuthSessionResult } from '../../../../utils/types';
|
|
3
|
-
export declare const oAuthSignOutRedirect: (authConfig: CognitoUserPoolConfig, preferPrivateSession?: boolean) => Promise<void | OpenAuthSessionResult>;
|
|
3
|
+
export declare const oAuthSignOutRedirect: (authConfig: CognitoUserPoolConfig, preferPrivateSession?: boolean, redirectUrl?: string) => Promise<void | OpenAuthSessionResult>;
|
|
@@ -4,11 +4,11 @@ import { getRedirectUrl } from './getRedirectUrl.mjs';
|
|
|
4
4
|
|
|
5
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
-
const oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false) => {
|
|
7
|
+
const oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false, redirectUrl) => {
|
|
8
8
|
assertOAuthConfig(authConfig);
|
|
9
9
|
const { loginWith, userPoolClientId } = authConfig;
|
|
10
10
|
const { domain, redirectSignOut } = loginWith.oauth;
|
|
11
|
-
const signoutUri = getRedirectUrl(redirectSignOut);
|
|
11
|
+
const signoutUri = getRedirectUrl(redirectSignOut, redirectUrl);
|
|
12
12
|
const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({
|
|
13
13
|
client_id: userPoolClientId,
|
|
14
14
|
logout_uri: encodeURIComponent(signoutUri),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthSignOutRedirect.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/oAuthSignOutRedirect.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertOAuthConfig } from '@aws-amplify/core/internals/utils';\nimport { openAuthSession } from '../../../../utils';\nimport { getRedirectUrl } from './getRedirectUrl';\nexport const oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false) => {\n assertOAuthConfig(authConfig);\n const { loginWith, userPoolClientId } = authConfig;\n const { domain, redirectSignOut } = loginWith.oauth;\n const signoutUri = getRedirectUrl(redirectSignOut);\n const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({\n client_id: userPoolClientId,\n logout_uri: encodeURIComponent(signoutUri),\n })\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`;\n return openAuthSession(oAuthLogoutEndpoint, redirectSignOut, preferPrivateSession);\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,oBAAoB,GAAG,OAAO,UAAU,EAAE,oBAAoB,GAAG,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"oAuthSignOutRedirect.mjs","sources":["../../../../../../src/providers/cognito/utils/oauth/oAuthSignOutRedirect.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertOAuthConfig } from '@aws-amplify/core/internals/utils';\nimport { openAuthSession } from '../../../../utils';\nimport { getRedirectUrl } from './getRedirectUrl';\nexport const oAuthSignOutRedirect = async (authConfig, preferPrivateSession = false, redirectUrl) => {\n assertOAuthConfig(authConfig);\n const { loginWith, userPoolClientId } = authConfig;\n const { domain, redirectSignOut } = loginWith.oauth;\n const signoutUri = getRedirectUrl(redirectSignOut, redirectUrl);\n const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({\n client_id: userPoolClientId,\n logout_uri: encodeURIComponent(signoutUri),\n })\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`;\n return openAuthSession(oAuthLogoutEndpoint, redirectSignOut, preferPrivateSession);\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,oBAAoB,GAAG,OAAO,UAAU,EAAE,oBAAoB,GAAG,KAAK,EAAE,WAAW,KAAK;AACrG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAClC,IAAI,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC;AACxD,IAAI,MAAM,UAAU,GAAG,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;AACpE,IAAI,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;AAC3E,QAAQ,SAAS,EAAE,gBAAgB;AACnC,QAAQ,UAAU,EAAE,kBAAkB,CAAC,UAAU,CAAC;AAClD,KAAK,CAAC;AACN,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,SAAS,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACrB,IAAI,OAAO,eAAe,CAAC,mBAA0D,CAAC,CAAC;AACvF;;;;"}
|
|
@@ -27,6 +27,9 @@ export interface AuthSignInInput<ServiceOptions extends AuthServiceOptions = Aut
|
|
|
27
27
|
}
|
|
28
28
|
export interface AuthSignOutInput {
|
|
29
29
|
global: boolean;
|
|
30
|
+
oauth?: {
|
|
31
|
+
redirectUrl?: string;
|
|
32
|
+
};
|
|
30
33
|
}
|
|
31
34
|
export type AuthProvider = 'Amazon' | 'Apple' | 'Facebook' | 'Google';
|
|
32
35
|
export interface AuthSignInWithRedirectInput {
|
package/package.json
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
2
|
+
"name": "@aws-amplify/auth",
|
|
3
|
+
"version": "6.4.0",
|
|
4
|
+
"description": "Auth category of aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"typings": "./dist/esm/index.d.ts",
|
|
8
|
+
"react-native": "./src/index.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/cjs/providers/cognito/apis/signInWithRedirect.js",
|
|
11
|
+
"./dist/esm/providers/cognito/apis/signInWithRedirect.mjs",
|
|
12
|
+
"./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js",
|
|
13
|
+
"./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "yarn lint --fix && jest -w 1 --coverage --logHeapUsage",
|
|
20
|
+
"build-with-test": "npm test && npm run build",
|
|
21
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
22
|
+
"build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
|
|
23
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
24
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
25
|
+
"clean": "npm run clean:size && rimraf lib-esm lib dist",
|
|
26
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
27
|
+
"format": "echo \"Not implemented\"",
|
|
28
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
29
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
30
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 91.18"
|
|
31
|
+
},
|
|
32
|
+
"typesVersions": {
|
|
33
|
+
">=4.2": {
|
|
34
|
+
"cognito": [
|
|
35
|
+
"./dist/esm/providers/cognito/index.d.ts"
|
|
36
|
+
],
|
|
37
|
+
"cognito/server": [
|
|
38
|
+
"./dist/esm/providers/cognito/apis/server/index.d.ts"
|
|
39
|
+
],
|
|
40
|
+
"server": [
|
|
41
|
+
"./dist/esm/server.d.ts"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/esm/index.d.ts",
|
|
48
|
+
"import": "./dist/esm/index.mjs",
|
|
49
|
+
"require": "./dist/cjs/index.js",
|
|
50
|
+
"react-native": "./src/index.ts"
|
|
51
|
+
},
|
|
52
|
+
"./cognito": {
|
|
53
|
+
"types": "./dist/esm/providers/cognito/index.d.ts",
|
|
54
|
+
"import": "./dist/esm/providers/cognito/index.mjs",
|
|
55
|
+
"require": "./dist/cjs/providers/cognito/index.js",
|
|
56
|
+
"react-native": "./src/providers/cognito/index.ts"
|
|
57
|
+
},
|
|
58
|
+
"./cognito/server": {
|
|
59
|
+
"types": "./dist/esm/providers/cognito/apis/server/index.d.ts",
|
|
60
|
+
"import": "./dist/esm/providers/cognito/apis/server/index.mjs",
|
|
61
|
+
"require": "./dist/cjs/providers/cognito/apis/server/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./server": {
|
|
64
|
+
"types": "./dist/esm/server.d.ts",
|
|
65
|
+
"import": "./dist/esm/server.mjs",
|
|
66
|
+
"require": "./dist/cjs/server.js"
|
|
67
|
+
},
|
|
68
|
+
"./enable-oauth-listener": {
|
|
69
|
+
"types": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.d.ts",
|
|
70
|
+
"import": "./dist/esm/providers/cognito/utils/oauth/enableOAuthListener.mjs",
|
|
71
|
+
"require": "./dist/cjs/providers/cognito/utils/oauth/enableOAuthListener.js"
|
|
72
|
+
},
|
|
73
|
+
"./package.json": "./package.json"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
78
|
+
},
|
|
79
|
+
"author": "Amazon Web Services",
|
|
80
|
+
"license": "Apache-2.0",
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
85
|
+
"files": [
|
|
86
|
+
"dist/cjs",
|
|
87
|
+
"dist/esm",
|
|
88
|
+
"src",
|
|
89
|
+
"cognito",
|
|
90
|
+
"server",
|
|
91
|
+
"enable-oauth-listener"
|
|
92
|
+
],
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"tslib": "^2.5.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@aws-amplify/core": "^6.1.0"
|
|
98
|
+
},
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@aws-amplify/core": "6.4.0",
|
|
101
|
+
"@aws-amplify/react-native": "1.1.5",
|
|
102
|
+
"@jest/test-sequencer": "^29.7.0",
|
|
103
|
+
"typescript": "5.0.2"
|
|
104
|
+
},
|
|
105
|
+
"gitHead": "af7e31a49fc1ad9f4e093d0d6129ea9c6b750d89"
|
|
106
106
|
}
|
package/src/errors/constants.ts
CHANGED
|
@@ -10,6 +10,10 @@ export const DEVICE_METADATA_NOT_FOUND_EXCEPTION =
|
|
|
10
10
|
'DeviceMetadataNotFoundException';
|
|
11
11
|
export const AUTO_SIGN_IN_EXCEPTION = 'AutoSignInException';
|
|
12
12
|
export const INVALID_REDIRECT_EXCEPTION = 'InvalidRedirectException';
|
|
13
|
+
export const INVALID_APP_SCHEME_EXCEPTION = 'InvalidAppSchemeException';
|
|
14
|
+
export const INVALID_PREFERRED_REDIRECT_EXCEPTION =
|
|
15
|
+
'InvalidPreferredRedirectUrlException';
|
|
16
|
+
|
|
13
17
|
export const invalidRedirectException = new AuthError({
|
|
14
18
|
name: INVALID_REDIRECT_EXCEPTION,
|
|
15
19
|
message:
|
|
@@ -17,6 +21,19 @@ export const invalidRedirectException = new AuthError({
|
|
|
17
21
|
recoverySuggestion:
|
|
18
22
|
'Please make sure the signIn/Out redirect in your oauth config is valid.',
|
|
19
23
|
});
|
|
24
|
+
export const invalidAppSchemeException = new AuthError({
|
|
25
|
+
name: INVALID_APP_SCHEME_EXCEPTION,
|
|
26
|
+
message: 'A valid non-http app scheme was not found in the config.',
|
|
27
|
+
recoverySuggestion:
|
|
28
|
+
'Please make sure a valid custom app scheme is present in the config.',
|
|
29
|
+
});
|
|
30
|
+
export const invalidPreferredRedirectUrlException = new AuthError({
|
|
31
|
+
name: INVALID_PREFERRED_REDIRECT_EXCEPTION,
|
|
32
|
+
message:
|
|
33
|
+
'The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.',
|
|
34
|
+
recoverySuggestion:
|
|
35
|
+
'Please make sure a matching preferredRedirectUrl is provided.',
|
|
36
|
+
});
|
|
20
37
|
export const INVALID_ORIGIN_EXCEPTION = 'InvalidOriginException';
|
|
21
38
|
export const invalidOriginException = new AuthError({
|
|
22
39
|
name: INVALID_ORIGIN_EXCEPTION,
|
|
@@ -60,7 +60,6 @@ export async function signOut(input?: SignOutInput): Promise<void> {
|
|
|
60
60
|
} catch (err) {
|
|
61
61
|
hasOAuthConfig = false;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
63
|
if (hasOAuthConfig) {
|
|
65
64
|
const oAuthStore = new DefaultOAuthStore(defaultStorage);
|
|
66
65
|
oAuthStore.setAuthConfig(cognitoConfig);
|
|
@@ -69,12 +68,12 @@ export async function signOut(input?: SignOutInput): Promise<void> {
|
|
|
69
68
|
cognitoConfig,
|
|
70
69
|
oAuthStore,
|
|
71
70
|
tokenOrchestrator,
|
|
71
|
+
input?.oauth?.redirectUrl,
|
|
72
72
|
)) ?? {};
|
|
73
73
|
if (type === 'error') {
|
|
74
74
|
throw new AuthError({
|
|
75
75
|
name: OAUTH_SIGNOUT_EXCEPTION,
|
|
76
|
-
message:
|
|
77
|
-
'An error occurred when attempting to log out from OAuth provider.',
|
|
76
|
+
message: `An error occurred when attempting to log out from OAuth provider.`,
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
79
|
} else {
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
invalidAppSchemeException,
|
|
6
|
+
invalidPreferredRedirectUrlException,
|
|
7
|
+
} from '../../../../errors/constants';
|
|
5
8
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* - Validate there is always an appScheme (required), if not throw invalidAppSchemeException.
|
|
11
|
+
* - If a preferredRedirectUrl is given, validate it's in the configured list, if not throw invalidPreferredRedirectUrlException.
|
|
12
|
+
* - If preferredRedirectUrl is not given, use the appScheme which is present in the configured list.
|
|
13
|
+
@internal */
|
|
14
|
+
export function getRedirectUrl(
|
|
15
|
+
redirects: string[],
|
|
16
|
+
preferredRedirectUrl?: string,
|
|
17
|
+
): string {
|
|
18
|
+
// iOS always requires a non http/s url (appScheme) to be registered so we validate it's existence here.
|
|
19
|
+
const appSchemeRedirectUrl = redirects?.find(
|
|
9
20
|
redirect =>
|
|
10
21
|
!redirect.startsWith('http://') && !redirect.startsWith('https://'),
|
|
11
22
|
);
|
|
12
|
-
if (!
|
|
13
|
-
throw
|
|
23
|
+
if (!appSchemeRedirectUrl) {
|
|
24
|
+
throw invalidAppSchemeException;
|
|
25
|
+
}
|
|
26
|
+
if (preferredRedirectUrl) {
|
|
27
|
+
if (redirects?.includes(preferredRedirectUrl)) {
|
|
28
|
+
return preferredRedirectUrl;
|
|
29
|
+
}
|
|
30
|
+
throw invalidPreferredRedirectUrlException;
|
|
14
31
|
}
|
|
15
32
|
|
|
16
|
-
return
|
|
33
|
+
return appSchemeRedirectUrl;
|
|
17
34
|
}
|
|
@@ -2,22 +2,38 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import {
|
|
4
4
|
invalidOriginException,
|
|
5
|
+
invalidPreferredRedirectUrlException,
|
|
5
6
|
invalidRedirectException,
|
|
6
7
|
} from '../../../../errors/constants';
|
|
7
8
|
|
|
8
9
|
/** @internal */
|
|
9
|
-
export function getRedirectUrl(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
export function getRedirectUrl(
|
|
11
|
+
redirects: string[],
|
|
12
|
+
preferredRedirectUrl?: string,
|
|
13
|
+
): string {
|
|
14
|
+
if (preferredRedirectUrl) {
|
|
15
|
+
const redirectUrl = redirects?.find(
|
|
16
|
+
redirect => redirect === preferredRedirectUrl,
|
|
17
|
+
);
|
|
18
|
+
if (!redirectUrl) {
|
|
19
|
+
throw invalidPreferredRedirectUrlException;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return redirectUrl;
|
|
23
|
+
} else {
|
|
24
|
+
const redirectUrlFromTheSameOrigin =
|
|
25
|
+
redirects?.find(isSameOriginAndPathName) ??
|
|
26
|
+
redirects?.find(isTheSameDomain);
|
|
27
|
+
const redirectUrlFromDifferentOrigin =
|
|
28
|
+
redirects?.find(isHttps) ?? redirects?.find(isHttp);
|
|
29
|
+
|
|
30
|
+
if (redirectUrlFromTheSameOrigin) {
|
|
31
|
+
return redirectUrlFromTheSameOrigin;
|
|
32
|
+
} else if (redirectUrlFromDifferentOrigin) {
|
|
33
|
+
throw invalidOriginException;
|
|
34
|
+
}
|
|
35
|
+
throw invalidRedirectException;
|
|
19
36
|
}
|
|
20
|
-
throw invalidRedirectException;
|
|
21
37
|
}
|
|
22
38
|
|
|
23
39
|
// origin + pathname => https://example.com/app
|
|
@@ -5,6 +5,7 @@ import { CognitoUserPoolConfig } from '@aws-amplify/core';
|
|
|
5
5
|
|
|
6
6
|
import { OpenAuthSessionResult } from '../../../../utils/types';
|
|
7
7
|
import { DefaultOAuthStore } from '../../utils/signInWithRedirectStore';
|
|
8
|
+
import { TokenOrchestrator } from '../../tokenProvider';
|
|
8
9
|
|
|
9
10
|
import { completeOAuthSignOut } from './completeOAuthSignOut';
|
|
10
11
|
import { oAuthSignOutRedirect } from './oAuthSignOutRedirect';
|
|
@@ -12,13 +13,16 @@ import { oAuthSignOutRedirect } from './oAuthSignOutRedirect';
|
|
|
12
13
|
export const handleOAuthSignOut = async (
|
|
13
14
|
cognitoConfig: CognitoUserPoolConfig,
|
|
14
15
|
store: DefaultOAuthStore,
|
|
16
|
+
// No-op here as it's only used in the non-native implementation
|
|
17
|
+
tokenOrchestrator: TokenOrchestrator,
|
|
18
|
+
redirectUrl: string | undefined,
|
|
15
19
|
): Promise<void | OpenAuthSessionResult> => {
|
|
16
20
|
const { isOAuthSignIn, preferPrivateSession } = await store.loadOAuthSignIn();
|
|
17
|
-
|
|
18
21
|
if (isOAuthSignIn) {
|
|
19
22
|
const result = await oAuthSignOutRedirect(
|
|
20
23
|
cognitoConfig,
|
|
21
24
|
preferPrivateSession,
|
|
25
|
+
redirectUrl,
|
|
22
26
|
);
|
|
23
27
|
// If this was a private session, clear data and tokens regardless of what happened with logout
|
|
24
28
|
// endpoint. Otherwise, only do so if the logout endpoint was succesfully visited.
|
|
@@ -14,6 +14,7 @@ export const handleOAuthSignOut = async (
|
|
|
14
14
|
cognitoConfig: CognitoUserPoolConfig,
|
|
15
15
|
store: DefaultOAuthStore,
|
|
16
16
|
tokenOrchestrator: TokenOrchestrator,
|
|
17
|
+
redirectUrl: string | undefined,
|
|
17
18
|
): Promise<void | OpenAuthSessionResult> => {
|
|
18
19
|
const { isOAuthSignIn } = await store.loadOAuthSignIn();
|
|
19
20
|
const oauthMetadata = await tokenOrchestrator.getOAuthMetadata();
|
|
@@ -30,6 +31,6 @@ export const handleOAuthSignOut = async (
|
|
|
30
31
|
// storage mechanism that is used by Amplify.
|
|
31
32
|
if (isOAuthSignIn || oauthMetadata?.oauthSignIn) {
|
|
32
33
|
// On web, this will always end up being a void action
|
|
33
|
-
return oAuthSignOutRedirect(cognitoConfig);
|
|
34
|
+
return oAuthSignOutRedirect(cognitoConfig, false, redirectUrl);
|
|
34
35
|
}
|
|
35
36
|
};
|
|
@@ -12,11 +12,12 @@ import { getRedirectUrl } from './getRedirectUrl';
|
|
|
12
12
|
export const oAuthSignOutRedirect = async (
|
|
13
13
|
authConfig: CognitoUserPoolConfig,
|
|
14
14
|
preferPrivateSession = false,
|
|
15
|
+
redirectUrl?: string,
|
|
15
16
|
): Promise<void | OpenAuthSessionResult> => {
|
|
16
17
|
assertOAuthConfig(authConfig);
|
|
17
18
|
const { loginWith, userPoolClientId } = authConfig;
|
|
18
19
|
const { domain, redirectSignOut } = loginWith.oauth;
|
|
19
|
-
const signoutUri = getRedirectUrl(redirectSignOut);
|
|
20
|
+
const signoutUri = getRedirectUrl(redirectSignOut, redirectUrl);
|
|
20
21
|
const oAuthLogoutEndpoint = `https://${domain}/logout?${Object.entries({
|
|
21
22
|
client_id: userPoolClientId,
|
|
22
23
|
logout_uri: encodeURIComponent(signoutUri),
|
package/src/types/inputs.ts
CHANGED