@aws-amplify/auth 6.4.2 → 6.4.3-unstable.555defc.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/providers/cognito/apis/confirmSignIn.js +1 -1
- package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js +2 -2
- package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js +2 -2
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js +2 -2
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js +2 -2
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js.map +1 -1
- package/dist/cjs/providers/cognito/utils/signInStore.js +66 -14
- package/dist/cjs/providers/cognito/utils/signInStore.js.map +1 -1
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs +2 -2
- package/dist/esm/providers/cognito/apis/confirmSignIn.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs +3 -3
- package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs +3 -3
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs +3 -3
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs +3 -3
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs.map +1 -1
- package/dist/esm/providers/cognito/utils/signInStore.d.ts +3 -1
- package/dist/esm/providers/cognito/utils/signInStore.mjs +66 -13
- package/dist/esm/providers/cognito/utils/signInStore.mjs.map +1 -1
- package/package.json +104 -104
- package/src/providers/cognito/apis/confirmSignIn.ts +3 -6
- package/src/providers/cognito/apis/signInWithCustomAuth.ts +3 -6
- package/src/providers/cognito/apis/signInWithCustomSRPAuth.ts +3 -6
- package/src/providers/cognito/apis/signInWithSRP.ts +3 -6
- package/src/providers/cognito/apis/signInWithUserPassword.ts +3 -6
- package/src/providers/cognito/utils/signInStore.ts +99 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithCustomSRPAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithCustomSRPAuth.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleCustomSRPAuthFlow, } from '../utils/signInHelpers';\nimport {
|
|
1
|
+
{"version":3,"file":"signInWithCustomSRPAuth.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithCustomSRPAuth.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleCustomSRPAuthFlow, } from '../utils/signInHelpers';\nimport { setActiveSignInState, signInStore } from '../utils/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\n/**\n * Signs a user in using a custom authentication flow with SRP\n *\n * @param input - The SignInWithCustomSRPAuthInput object\n * @returns SignInWithCustomSRPAuthOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito\n * service errors thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithCustomSRPAuth(input) {\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITH_SRP',\n };\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await handleCustomSRPAuthFlow(username, password, metadata, authConfig, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n signInStore.dispatch({ type: 'RESET_STATE' });\n await cacheCognitoTokens({\n username: activeUsername,\n ...AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n signInStore.dispatch({ type: 'RESET_STATE' });\n assertServiceError(error);\n const result = getSignInResultFromError(error.name);\n if (result)\n return result;\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,uBAAuB,CAAC,KAAK,EAAE;AACrD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AAClD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,iBAAiB;AACvC,KAAK,CAAC;AACN,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,QAAQ,GAAG,OAAO,EAAE,cAAc,CAAC;AAC7C,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AACnF,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AACnF,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,OAAO,GAAG,GAAG,MAAM,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;AACpO,QAAQ,MAAM,cAAc,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AACjE;AACA,QAAQ,oBAAoB,CAAC;AAC7B,YAAY,aAAa,EAAE,OAAO;AAClC,YAAY,QAAQ,EAAE,cAAc;AACpC,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,aAAa;AAC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orCode } from '../../../errors/types/validation.mjs';
|
|
|
4
4
|
import { assertValidationError } from '../../../errors/utils/assertValidationError.mjs';
|
|
5
5
|
import { assertServiceError } from '../../../errors/utils/assertServiceError.mjs';
|
|
6
6
|
import { handleUserSRPAuthFlow, getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError } from '../utils/signInHelpers.mjs';
|
|
7
|
-
import { setActiveSignInState,
|
|
7
|
+
import { setActiveSignInState, signInStore } from '../utils/signInStore.mjs';
|
|
8
8
|
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens.mjs';
|
|
9
9
|
import '../utils/refreshAuthTokens.mjs';
|
|
10
10
|
import '../tokenProvider/errorHelpers.mjs';
|
|
@@ -47,7 +47,7 @@ async function signInWithSRP(input) {
|
|
|
47
47
|
signInDetails,
|
|
48
48
|
});
|
|
49
49
|
if (AuthenticationResult) {
|
|
50
|
-
|
|
50
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
51
51
|
await cacheCognitoTokens({
|
|
52
52
|
username: activeUsername,
|
|
53
53
|
...AuthenticationResult,
|
|
@@ -71,7 +71,7 @@ async function signInWithSRP(input) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
catch (error) {
|
|
74
|
-
|
|
74
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
75
75
|
assertServiceError(error);
|
|
76
76
|
const result = getSignInResultFromError(error.name);
|
|
77
77
|
if (result)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithSRP.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleUserSRPAuthFlow, } from '../utils/signInHelpers';\nimport {
|
|
1
|
+
{"version":3,"file":"signInWithSRP.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleUserSRPAuthFlow, } from '../utils/signInHelpers';\nimport { setActiveSignInState, signInStore } from '../utils/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\n/**\n * Signs a user in\n *\n * @param input - The SignInWithSRPInput object\n * @returns SignInWithSRPOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException } - Cognito service errors\n * thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithSRP(input) {\n const { username, password } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_SRP_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const clientMetaData = input.options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await handleUserSRPAuthFlow(username, password, clientMetaData, authConfig, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n signInStore.dispatch({ type: 'RESET_STATE' });\n await cacheCognitoTokens({\n username: activeUsername,\n ...AuthenticationResult,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n signInStore.dispatch({ type: 'RESET_STATE' });\n assertServiceError(error);\n const result = getSignInResultFromError(error.name);\n if (result)\n return result;\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AACzC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,eAAe;AACrC,KAAK,CAAC;AACN,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC;AACzD,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAu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EAAE;AAChD,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,OAAO,eAAe,CAAC;AAC/B,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,mBAAmB,EAAE,0BAA0B;AAC3D,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;AACtD,QAAQ,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAClC,QAAQ,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5D,QAAQ,IAAI,MAAM;AAClB,YAAY,OAAO,MAAM,CAAC;AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL;;;;"}
|
|
@@ -4,7 +4,7 @@ import { AuthValidationErrorCode } from '../../../errors/types/validation.mjs';
|
|
|
4
4
|
import { assertServiceError } from '../../../errors/utils/assertServiceError.mjs';
|
|
5
5
|
import { assertValidationError } from '../../../errors/utils/assertValidationError.mjs';
|
|
6
6
|
import { retryOnResourceNotFoundException, handleUserPasswordAuthFlow, getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError } from '../utils/signInHelpers.mjs';
|
|
7
|
-
import { setActiveSignInState,
|
|
7
|
+
import { setActiveSignInState, signInStore } from '../utils/signInStore.mjs';
|
|
8
8
|
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens.mjs';
|
|
9
9
|
import '../utils/refreshAuthTokens.mjs';
|
|
10
10
|
import '../tokenProvider/errorHelpers.mjs';
|
|
@@ -46,6 +46,7 @@ async function signInWithUserPassword(input) {
|
|
|
46
46
|
signInDetails,
|
|
47
47
|
});
|
|
48
48
|
if (AuthenticationResult) {
|
|
49
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
49
50
|
await cacheCognitoTokens({
|
|
50
51
|
...AuthenticationResult,
|
|
51
52
|
username: activeUsername,
|
|
@@ -57,7 +58,6 @@ async function signInWithUserPassword(input) {
|
|
|
57
58
|
}),
|
|
58
59
|
signInDetails,
|
|
59
60
|
});
|
|
60
|
-
cleanActiveSignInState();
|
|
61
61
|
await dispatchSignedInHubEvent();
|
|
62
62
|
return {
|
|
63
63
|
isSignedIn: true,
|
|
@@ -70,7 +70,7 @@ async function signInWithUserPassword(input) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
73
|
-
|
|
73
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
74
74
|
assertServiceError(error);
|
|
75
75
|
const result = getSignInResultFromError(error.name);
|
|
76
76
|
if (result)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithUserPassword.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithUserPassword.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleUserPasswordAuthFlow, retryOnResourceNotFoundException, } from '../utils/signInHelpers';\nimport {
|
|
1
|
+
{"version":3,"file":"signInWithUserPassword.mjs","sources":["../../../../../src/providers/cognito/apis/signInWithUserPassword.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { assertTokenProviderConfig } from '@aws-amplify/core/internals/utils';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { getActiveSignInUsername, getNewDeviceMetadata, getSignInResult, getSignInResultFromError, handleUserPasswordAuthFlow, retryOnResourceNotFoundException, } from '../utils/signInHelpers';\nimport { setActiveSignInState, signInStore } from '../utils/signInStore';\nimport { cacheCognitoTokens } from '../tokenProvider/cacheTokens';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { dispatchSignedInHubEvent } from '../utils/dispatchSignedInHubEvent';\n/**\n * Signs a user in using USER_PASSWORD_AUTH AuthFlowType\n *\n * @param input - The SignInWithUserPasswordInput object\n * @returns SignInWithUserPasswordOutput\n * @throws service: {@link InitiateAuthException } - Cognito service error thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signInWithUserPassword(input) {\n const { username, password, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_PASSWORD_AUTH',\n };\n assertTokenProviderConfig(authConfig);\n const metadata = options?.clientMetadata;\n assertValidationError(!!username, AuthValidationErrorCode.EmptySignInUsername);\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: retiredChallengeName, ChallengeParameters: retriedChallengeParameters, AuthenticationResult, Session, } = await retryOnResourceNotFoundException(handleUserPasswordAuthFlow, [username, password, metadata, authConfig, tokenOrchestrator], username, tokenOrchestrator);\n const activeUsername = getActiveSignInUsername(username);\n // sets up local state used during the sign-in process\n setActiveSignInState({\n signInSession: Session,\n username: activeUsername,\n challengeName: retiredChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n signInStore.dispatch({ type: 'RESET_STATE' });\n await cacheCognitoTokens({\n ...AuthenticationResult,\n username: activeUsername,\n NewDeviceMetadata: await getNewDeviceMetadata({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n await dispatchSignedInHubEvent();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return getSignInResult({\n challengeName: retiredChallengeName,\n challengeParameters: retriedChallengeParameters,\n });\n }\n catch (error) {\n signInStore.dispatch({ type: 'RESET_STATE' });\n assertServiceError(error);\n const result = getSignInResultFromError(error.name);\n if (result)\n return result;\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,sBAAsB,CAAC,KAAK,EAAE;AACpD,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AAClD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AACzB,QAAQ,YAAY,EAAE,oBAAoB;AAC1C,KAAK,CAAC;AACN,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,QAAQ,GAAG,OAAO,EAAE,cAAc,CAAC;AAC7C,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AACnF,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AACnF,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,OAAO,GAAG,GAAG,MAAM,gCAAgC,CAAC,0BAA0B,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,iBAAiB,C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AAClC,QAAQ,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5D,QAAQ,IAAI,MAAM;AAClB,YAAY,OAAO,MAAM,CAAC;AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL;;;;"}
|
|
@@ -20,11 +20,13 @@ type SignInAction = {
|
|
|
20
20
|
} | {
|
|
21
21
|
type: 'SET_SIGN_IN_SESSION';
|
|
22
22
|
value?: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'RESET_STATE';
|
|
23
25
|
};
|
|
24
26
|
export declare const signInStore: {
|
|
25
27
|
getState(): SignInState;
|
|
26
28
|
dispatch(action: SignInAction): void;
|
|
27
29
|
};
|
|
28
30
|
export declare function setActiveSignInState(state: SignInState): void;
|
|
29
|
-
export declare
|
|
31
|
+
export declare const persistSignInState: ({ challengeName, signInSession, username, }: SignInState) => void;
|
|
30
32
|
export {};
|
|
@@ -1,41 +1,86 @@
|
|
|
1
|
+
import { syncSessionStorage } from '@aws-amplify/core';
|
|
2
|
+
|
|
1
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
// Minutes until stored session invalidates
|
|
6
|
+
const MS_TO_EXPIRY = 3 * 60 * 1000; // 3 mins
|
|
7
|
+
const TGT_STATE = 'CognitoSignInState';
|
|
8
|
+
const SIGN_IN_STATE_KEYS = {
|
|
9
|
+
username: `${TGT_STATE}.username`,
|
|
10
|
+
challengeName: `${TGT_STATE}.challengeName`,
|
|
11
|
+
signInSession: `${TGT_STATE}.signInSession`,
|
|
12
|
+
expiry: `${TGT_STATE}.expiry`,
|
|
13
|
+
};
|
|
3
14
|
const signInReducer = (state, action) => {
|
|
4
15
|
switch (action.type) {
|
|
5
16
|
case 'SET_SIGN_IN_SESSION':
|
|
17
|
+
persistSignInState({ signInSession: action.value });
|
|
6
18
|
return {
|
|
7
19
|
...state,
|
|
8
20
|
signInSession: action.value,
|
|
9
21
|
};
|
|
10
22
|
case 'SET_SIGN_IN_STATE':
|
|
23
|
+
persistSignInState(action.value);
|
|
11
24
|
return {
|
|
12
25
|
...action.value,
|
|
13
26
|
};
|
|
14
27
|
case 'SET_CHALLENGE_NAME':
|
|
28
|
+
persistSignInState({ challengeName: action.value });
|
|
15
29
|
return {
|
|
16
30
|
...state,
|
|
17
31
|
challengeName: action.value,
|
|
18
32
|
};
|
|
19
33
|
case 'SET_USERNAME':
|
|
34
|
+
persistSignInState({ username: action.value });
|
|
20
35
|
return {
|
|
21
36
|
...state,
|
|
22
37
|
username: action.value,
|
|
23
38
|
};
|
|
24
39
|
case 'SET_INITIAL_STATE':
|
|
25
|
-
return
|
|
40
|
+
return initializeState();
|
|
41
|
+
case 'RESET_STATE':
|
|
42
|
+
clearPersistedSignInState();
|
|
43
|
+
return getDefaultState();
|
|
44
|
+
// this state is never reachable
|
|
26
45
|
default:
|
|
27
46
|
return state;
|
|
28
47
|
}
|
|
29
48
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
const isExpired = (expiryDate) => {
|
|
50
|
+
const expiryTimestamp = Number(expiryDate);
|
|
51
|
+
const currentTimestamp = Date.now();
|
|
52
|
+
return expiryTimestamp <= currentTimestamp;
|
|
53
|
+
};
|
|
54
|
+
const clearPersistedSignInState = () => {
|
|
55
|
+
for (const storedKey of Object.values(SIGN_IN_STATE_KEYS)) {
|
|
56
|
+
syncSessionStorage.removeItem(storedKey);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const getDefaultState = () => ({
|
|
60
|
+
username: undefined,
|
|
61
|
+
challengeName: undefined,
|
|
62
|
+
signInSession: undefined,
|
|
63
|
+
});
|
|
64
|
+
// Hydrate signInStore from Synced Session Storage
|
|
65
|
+
const initializeState = () => {
|
|
66
|
+
const expiry = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry);
|
|
67
|
+
if (!expiry || (expiry && isExpired(expiry))) {
|
|
68
|
+
clearPersistedSignInState();
|
|
69
|
+
return getDefaultState();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const username = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.username) ?? undefined;
|
|
73
|
+
const challengeName = (syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.challengeName) ?? undefined);
|
|
74
|
+
const signInSession = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.signInSession) ?? undefined;
|
|
75
|
+
return {
|
|
76
|
+
username,
|
|
77
|
+
challengeName,
|
|
78
|
+
signInSession,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
37
82
|
const createStore = reducer => {
|
|
38
|
-
let currentState = reducer(
|
|
83
|
+
let currentState = reducer(getDefaultState(), { type: 'SET_INITIAL_STATE' });
|
|
39
84
|
return {
|
|
40
85
|
getState: () => currentState,
|
|
41
86
|
dispatch: action => {
|
|
@@ -50,9 +95,17 @@ function setActiveSignInState(state) {
|
|
|
50
95
|
value: state,
|
|
51
96
|
});
|
|
52
97
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
98
|
+
// Save local state into Session Storage
|
|
99
|
+
const persistSignInState = ({ challengeName, signInSession, username, }) => {
|
|
100
|
+
username && syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.username, username);
|
|
101
|
+
challengeName &&
|
|
102
|
+
syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.challengeName, challengeName);
|
|
103
|
+
if (signInSession) {
|
|
104
|
+
syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.signInSession, signInSession);
|
|
105
|
+
// Updates expiry when session is passed
|
|
106
|
+
syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.expiry, String(Date.now() + MS_TO_EXPIRY));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
56
109
|
|
|
57
|
-
export {
|
|
110
|
+
export { persistSignInState, setActiveSignInState, signInStore };
|
|
58
111
|
//# sourceMappingURL=signInStore.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInStore.mjs","sources":["../../../../../src/providers/cognito/utils/signInStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst signInReducer = (state, action) => {\n switch (action.type) {\n case 'SET_SIGN_IN_SESSION':\n return {\n ...state,\n signInSession: action.value,\n };\n case 'SET_SIGN_IN_STATE':\n return {\n ...action.value,\n };\n case 'SET_CHALLENGE_NAME':\n return {\n ...state,\n challengeName: action.value,\n };\n case 'SET_USERNAME':\n return {\n ...state,\n username: action.value,\n };\n case 'SET_INITIAL_STATE':\n return
|
|
1
|
+
{"version":3,"file":"signInStore.mjs","sources":["../../../../../src/providers/cognito/utils/signInStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { syncSessionStorage } from '@aws-amplify/core';\n// Minutes until stored session invalidates\nconst MS_TO_EXPIRY = 3 * 60 * 1000; // 3 mins\nconst TGT_STATE = 'CognitoSignInState';\nconst SIGN_IN_STATE_KEYS = {\n username: `${TGT_STATE}.username`,\n challengeName: `${TGT_STATE}.challengeName`,\n signInSession: `${TGT_STATE}.signInSession`,\n expiry: `${TGT_STATE}.expiry`,\n};\nconst signInReducer = (state, action) => {\n switch (action.type) {\n case 'SET_SIGN_IN_SESSION':\n persistSignInState({ signInSession: action.value });\n return {\n ...state,\n signInSession: action.value,\n };\n case 'SET_SIGN_IN_STATE':\n persistSignInState(action.value);\n return {\n ...action.value,\n };\n case 'SET_CHALLENGE_NAME':\n persistSignInState({ challengeName: action.value });\n return {\n ...state,\n challengeName: action.value,\n };\n case 'SET_USERNAME':\n persistSignInState({ username: action.value });\n return {\n ...state,\n username: action.value,\n };\n case 'SET_INITIAL_STATE':\n return initializeState();\n case 'RESET_STATE':\n clearPersistedSignInState();\n return getDefaultState();\n // this state is never reachable\n default:\n return state;\n }\n};\nconst isExpired = (expiryDate) => {\n const expiryTimestamp = Number(expiryDate);\n const currentTimestamp = Date.now();\n return expiryTimestamp <= currentTimestamp;\n};\nconst clearPersistedSignInState = () => {\n for (const storedKey of Object.values(SIGN_IN_STATE_KEYS)) {\n syncSessionStorage.removeItem(storedKey);\n }\n};\nconst getDefaultState = () => ({\n username: undefined,\n challengeName: undefined,\n signInSession: undefined,\n});\n// Hydrate signInStore from Synced Session Storage\nconst initializeState = () => {\n const expiry = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry);\n if (!expiry || (expiry && isExpired(expiry))) {\n clearPersistedSignInState();\n return getDefaultState();\n }\n else {\n const username = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.username) ?? undefined;\n const challengeName = (syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.challengeName) ?? undefined);\n const signInSession = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.signInSession) ?? undefined;\n return {\n username,\n challengeName,\n signInSession,\n };\n }\n};\nconst createStore = reducer => {\n let currentState = reducer(getDefaultState(), { type: 'SET_INITIAL_STATE' });\n return {\n getState: () => currentState,\n dispatch: action => {\n currentState = reducer(currentState, action);\n },\n };\n};\nexport const signInStore = createStore(signInReducer);\nexport function setActiveSignInState(state) {\n signInStore.dispatch({\n type: 'SET_SIGN_IN_STATE',\n value: state,\n });\n}\n// Save local state into Session Storage\nexport const persistSignInState = ({ challengeName, signInSession, username, }) => {\n username && syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.username, username);\n challengeName &&\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.challengeName, challengeName);\n if (signInSession) {\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.signInSession, signInSession);\n // Updates expiry when session is passed\n syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.expiry, String(Date.now() + MS_TO_EXPIRY));\n }\n};\n"],"names":[],"mappings":";;AAAA;AACA;A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-
|
|
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.3-unstable.555defc.0+555defc",
|
|
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.4.3-unstable.555defc.0+555defc"
|
|
98
|
+
},
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@aws-amplify/core": "6.4.3-unstable.555defc.0+555defc",
|
|
101
|
+
"@aws-amplify/react-native": "1.1.6-unstable.555defc.0+555defc",
|
|
102
|
+
"@jest/test-sequencer": "^29.7.0",
|
|
103
|
+
"typescript": "5.0.2"
|
|
104
|
+
},
|
|
105
|
+
"gitHead": "555defc9b9915db513a58ffe642ebbd1d6adb9e0"
|
|
106
106
|
}
|
|
@@ -10,11 +10,7 @@ import {
|
|
|
10
10
|
VerifySoftwareTokenException,
|
|
11
11
|
} from '../types/errors';
|
|
12
12
|
import { ConfirmSignInInput, ConfirmSignInOutput } from '../types';
|
|
13
|
-
import {
|
|
14
|
-
cleanActiveSignInState,
|
|
15
|
-
setActiveSignInState,
|
|
16
|
-
signInStore,
|
|
17
|
-
} from '../utils/signInStore';
|
|
13
|
+
import { setActiveSignInState, signInStore } from '../utils/signInStore';
|
|
18
14
|
import { AuthError } from '../../../errors/AuthError';
|
|
19
15
|
import {
|
|
20
16
|
getNewDeviceMetadata,
|
|
@@ -109,7 +105,8 @@ export async function confirmSignIn(
|
|
|
109
105
|
});
|
|
110
106
|
|
|
111
107
|
if (AuthenticationResult) {
|
|
112
|
-
|
|
108
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
109
|
+
|
|
113
110
|
await cacheCognitoTokens({
|
|
114
111
|
username,
|
|
115
112
|
...AuthenticationResult,
|
|
@@ -21,10 +21,7 @@ import {
|
|
|
21
21
|
SignInWithCustomAuthInput,
|
|
22
22
|
SignInWithCustomAuthOutput,
|
|
23
23
|
} from '../types';
|
|
24
|
-
import {
|
|
25
|
-
cleanActiveSignInState,
|
|
26
|
-
setActiveSignInState,
|
|
27
|
-
} from '../utils/signInStore';
|
|
24
|
+
import { setActiveSignInState, signInStore } from '../utils/signInStore';
|
|
28
25
|
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens';
|
|
29
26
|
import {
|
|
30
27
|
ChallengeName,
|
|
@@ -84,7 +81,7 @@ export async function signInWithCustomAuth(
|
|
|
84
81
|
signInDetails,
|
|
85
82
|
});
|
|
86
83
|
if (AuthenticationResult) {
|
|
87
|
-
|
|
84
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
88
85
|
|
|
89
86
|
await cacheCognitoTokens({
|
|
90
87
|
username: activeUsername,
|
|
@@ -111,7 +108,7 @@ export async function signInWithCustomAuth(
|
|
|
111
108
|
challengeParameters: retiredChallengeParameters as ChallengeParameters,
|
|
112
109
|
});
|
|
113
110
|
} catch (error) {
|
|
114
|
-
|
|
111
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
115
112
|
assertServiceError(error);
|
|
116
113
|
const result = getSignInResultFromError(error.name);
|
|
117
114
|
if (result) return result;
|
|
@@ -23,10 +23,7 @@ import {
|
|
|
23
23
|
SignInWithCustomSRPAuthInput,
|
|
24
24
|
SignInWithCustomSRPAuthOutput,
|
|
25
25
|
} from '../types';
|
|
26
|
-
import {
|
|
27
|
-
cleanActiveSignInState,
|
|
28
|
-
setActiveSignInState,
|
|
29
|
-
} from '../utils/signInStore';
|
|
26
|
+
import { setActiveSignInState, signInStore } from '../utils/signInStore';
|
|
30
27
|
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens';
|
|
31
28
|
import {
|
|
32
29
|
ChallengeName,
|
|
@@ -89,6 +86,7 @@ export async function signInWithCustomSRPAuth(
|
|
|
89
86
|
signInDetails,
|
|
90
87
|
});
|
|
91
88
|
if (AuthenticationResult) {
|
|
89
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
92
90
|
await cacheCognitoTokens({
|
|
93
91
|
username: activeUsername,
|
|
94
92
|
...AuthenticationResult,
|
|
@@ -100,7 +98,6 @@ export async function signInWithCustomSRPAuth(
|
|
|
100
98
|
}),
|
|
101
99
|
signInDetails,
|
|
102
100
|
});
|
|
103
|
-
cleanActiveSignInState();
|
|
104
101
|
|
|
105
102
|
await dispatchSignedInHubEvent();
|
|
106
103
|
|
|
@@ -115,7 +112,7 @@ export async function signInWithCustomSRPAuth(
|
|
|
115
112
|
challengeParameters: handledChallengeParameters as ChallengeParameters,
|
|
116
113
|
});
|
|
117
114
|
} catch (error) {
|
|
118
|
-
|
|
115
|
+
signInStore.dispatch({ type: 'RESET_STATE' });
|
|
119
116
|
assertServiceError(error);
|
|
120
117
|
const result = getSignInResultFromError(error.name);
|
|
121
118
|
if (result) return result;
|