@aws-amplify/auth 6.8.4-graphql-multi-client.e61d28d.0 → 6.8.4-unstable.29b6c3f.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/client/flows/userAuth/handleWebAuthnSignInResult.js +1 -1
- package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js.map +1 -1
- package/dist/cjs/client/utils/store/signInStore.js +66 -12
- package/dist/cjs/client/utils/store/signInStore.js.map +1 -1
- 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 +4 -4
- package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js +4 -4
- package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js +4 -4
- package/dist/cjs/providers/cognito/apis/signInWithSRP.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js +4 -3
- package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js.map +1 -1
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js +4 -4
- package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js.map +1 -1
- package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs +2 -2
- package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs.map +1 -1
- package/dist/esm/client/utils/store/index.mjs +1 -1
- package/dist/esm/client/utils/store/signInStore.d.ts +4 -1
- package/dist/esm/client/utils/store/signInStore.mjs +65 -11
- package/dist/esm/client/utils/store/signInStore.mjs.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 -4
- package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs +3 -4
- package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs +3 -4
- package/dist/esm/providers/cognito/apis/signInWithSRP.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs +3 -3
- package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs.map +1 -1
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs +3 -4
- package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs.map +1 -1
- package/package.json +5 -5
- package/src/client/flows/userAuth/handleWebAuthnSignInResult.ts +2 -6
- package/src/client/utils/store/signInStore.ts +100 -11
- package/src/providers/cognito/apis/confirmSignIn.ts +2 -2
- package/src/providers/cognito/apis/signInWithCustomAuth.ts +4 -4
- package/src/providers/cognito/apis/signInWithCustomSRPAuth.ts +4 -4
- package/src/providers/cognito/apis/signInWithSRP.ts +4 -4
- package/src/providers/cognito/apis/signInWithUserAuth.ts +5 -5
- package/src/providers/cognito/apis/signInWithUserPassword.ts +4 -4
|
@@ -66,7 +66,7 @@ async function handleWebAuthnSignInResult(challengeParameters) {
|
|
|
66
66
|
}),
|
|
67
67
|
signInDetails,
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
store_1.signInStore.dispatch({ type: 'RESET_STATE' });
|
|
70
70
|
await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();
|
|
71
71
|
return {
|
|
72
72
|
isSignedIn: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleWebAuthnSignInResult.js","sources":["../../../../../src/client/flows/userAuth/handleWebAuthnSignInResult.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.handleWebAuthnSignInResult = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst AuthErrorStrings_1 = require(\"../../../common/AuthErrorStrings\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst cacheTokens_1 = require(\"../../../providers/cognito/tokenProvider/cacheTokens\");\nconst dispatchSignedInHubEvent_1 = require(\"../../../providers/cognito/utils/dispatchSignedInHubEvent\");\nconst signInHelpers_1 = require(\"../../../providers/cognito/utils/signInHelpers\");\nconst store_1 = require(\"../../../client/utils/store\");\nconst utils_2 = require(\"../../../utils\");\nconst passkey_1 = require(\"../../utils/passkey\");\nconst errors_1 = require(\"../../utils/passkey/errors\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nasync function handleWebAuthnSignInResult(challengeParameters) {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const { username, signInSession, signInDetails, challengeName } = store_1.signInStore.getState();\n if (challengeName !== 'WEB_AUTHN' || !username) {\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: 'Unable to proceed due to invalid sign in state.',\n });\n }\n const { CREDENTIAL_REQUEST_OPTIONS: credentialRequestOptions } = challengeParameters;\n (0, errors_1.assertPasskeyError)(!!credentialRequestOptions, errors_1.PasskeyErrorCode.InvalidPasskeyAuthenticationOptions);\n const cred = await (0, passkey_1.getPasskey)(JSON.parse(credentialRequestOptions));\n const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: authConfig.userPoolEndpoint,\n }),\n });\n const { ChallengeName: nextChallengeName, ChallengeParameters: nextChallengeParameters, AuthenticationResult: authenticationResult, Session: nextSession, } = await respondToAuthChallenge({\n region: (0, parsers_1.getRegionFromUserPoolId)(authConfig.userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'WEB_AUTHN',\n ChallengeResponses: {\n USERNAME: username,\n CREDENTIAL: JSON.stringify(cred),\n },\n ClientId: authConfig.userPoolClientId,\n Session: signInSession,\n });\n (0, store_1.setActiveSignInState)({\n signInSession: nextSession,\n username,\n challengeName: nextChallengeName,\n signInDetails,\n });\n if (authenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n ...authenticationResult,\n username,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: authenticationResult.NewDeviceMetadata,\n accessToken: authenticationResult.AccessToken,\n }),\n signInDetails,\n });\n
|
|
1
|
+
{"version":3,"file":"handleWebAuthnSignInResult.js","sources":["../../../../../src/client/flows/userAuth/handleWebAuthnSignInResult.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.handleWebAuthnSignInResult = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst AuthErrorStrings_1 = require(\"../../../common/AuthErrorStrings\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst cacheTokens_1 = require(\"../../../providers/cognito/tokenProvider/cacheTokens\");\nconst dispatchSignedInHubEvent_1 = require(\"../../../providers/cognito/utils/dispatchSignedInHubEvent\");\nconst signInHelpers_1 = require(\"../../../providers/cognito/utils/signInHelpers\");\nconst store_1 = require(\"../../../client/utils/store\");\nconst utils_2 = require(\"../../../utils\");\nconst passkey_1 = require(\"../../utils/passkey\");\nconst errors_1 = require(\"../../utils/passkey/errors\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nasync function handleWebAuthnSignInResult(challengeParameters) {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const { username, signInSession, signInDetails, challengeName } = store_1.signInStore.getState();\n if (challengeName !== 'WEB_AUTHN' || !username) {\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: 'Unable to proceed due to invalid sign in state.',\n });\n }\n const { CREDENTIAL_REQUEST_OPTIONS: credentialRequestOptions } = challengeParameters;\n (0, errors_1.assertPasskeyError)(!!credentialRequestOptions, errors_1.PasskeyErrorCode.InvalidPasskeyAuthenticationOptions);\n const cred = await (0, passkey_1.getPasskey)(JSON.parse(credentialRequestOptions));\n const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: authConfig.userPoolEndpoint,\n }),\n });\n const { ChallengeName: nextChallengeName, ChallengeParameters: nextChallengeParameters, AuthenticationResult: authenticationResult, Session: nextSession, } = await respondToAuthChallenge({\n region: (0, parsers_1.getRegionFromUserPoolId)(authConfig.userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'WEB_AUTHN',\n ChallengeResponses: {\n USERNAME: username,\n CREDENTIAL: JSON.stringify(cred),\n },\n ClientId: authConfig.userPoolClientId,\n Session: signInSession,\n });\n (0, store_1.setActiveSignInState)({\n signInSession: nextSession,\n username,\n challengeName: nextChallengeName,\n signInDetails,\n });\n if (authenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n ...authenticationResult,\n username,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: authenticationResult.NewDeviceMetadata,\n accessToken: authenticationResult.AccessToken,\n }),\n signInDetails,\n });\n store_1.signInStore.dispatch({ type: 'RESET_STATE' });\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n if (nextChallengeName === 'WEB_AUTHN') {\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: 'Sequential WEB_AUTHN challenges returned from underlying service cannot be handled.',\n });\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: nextChallengeName,\n challengeParameters: nextChallengeParameters,\n });\n}\nexports.handleWebAuthnSignInResult = handleWebAuthnSignInResult;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,kBAAkB,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACvE,MAAM,yBAAyB,GAAG,OAAO,CAAC,sEAAsE,CAAC,CAAC;AAClH,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACzD,MAAM,WAAW,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACpE,MAAM,aAAa,GAAG,OAAO,CAAC,sDAAsD,CAAC,CAAC;AACtF,MAAM,0BAA0B,GAAG,OAAO,CAAC,2DAA2D,CAAC,CAAC;AACxG,MAAM,eAAe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gB,EAAE,UAAU,CAAC,gBAAgB;AAC7D,gBAAgB,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB;AACzE,gBAAgB,WAAW,EAAE,oBAAoB,CAAC,WAAW;AAC7D,aAAa,CAAC;AACd,YAAY,aAAa;AACzB,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;AAC9D,QAAQ,MAAM,IAAI,0BAA0B,CAAC,wBAAwB,GAAG,CAAC;AACzE,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,IAAI;AAC5B,YAAY,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAC5C,SAAS,CAAC;AACV,KAAK;AACL,IAAI,IAAI,iBAAiB,KAAK,WAAW,EAAE;AAC3C,QAAQ,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC;AACxC,YAAY,IAAI,EAAE,kBAAkB,CAAC,cAAc,CAAC,eAAe;AACnE,YAAY,OAAO,EAAE,qFAAqF;AAC1G,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,IAAI,eAAe,CAAC,eAAe,EAAE;AAChD,QAAQ,aAAa,EAAE,iBAAiB;AACxC,QAAQ,mBAAmB,EAAE,uBAAuB;AACpD,KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,0BAA0B,GAAG,0BAA0B;;"}
|
|
@@ -3,43 +3,89 @@
|
|
|
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.
|
|
6
|
+
exports.persistSignInState = exports.setActiveSignInState = exports.signInStore = exports.resetActiveSignInState = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
// Minutes until stored session invalidates
|
|
9
|
+
const MS_TO_EXPIRY = 3 * 60 * 1000; // 3 mins
|
|
10
|
+
const TGT_STATE = 'CognitoSignInState';
|
|
11
|
+
const SIGN_IN_STATE_KEYS = {
|
|
12
|
+
username: `${TGT_STATE}.username`,
|
|
13
|
+
challengeName: `${TGT_STATE}.challengeName`,
|
|
14
|
+
signInSession: `${TGT_STATE}.signInSession`,
|
|
15
|
+
expiry: `${TGT_STATE}.expiry`,
|
|
16
|
+
};
|
|
7
17
|
const signInReducer = (state, action) => {
|
|
8
18
|
switch (action.type) {
|
|
9
19
|
case 'SET_SIGN_IN_SESSION':
|
|
20
|
+
(0, exports.persistSignInState)({ signInSession: action.value });
|
|
10
21
|
return {
|
|
11
22
|
...state,
|
|
12
23
|
signInSession: action.value,
|
|
13
24
|
};
|
|
14
25
|
case 'SET_SIGN_IN_STATE':
|
|
26
|
+
(0, exports.persistSignInState)(action.value);
|
|
15
27
|
return {
|
|
16
28
|
...action.value,
|
|
17
29
|
};
|
|
18
30
|
case 'SET_CHALLENGE_NAME':
|
|
31
|
+
(0, exports.persistSignInState)({ challengeName: action.value });
|
|
19
32
|
return {
|
|
20
33
|
...state,
|
|
21
34
|
challengeName: action.value,
|
|
22
35
|
};
|
|
23
36
|
case 'SET_USERNAME':
|
|
37
|
+
(0, exports.persistSignInState)({ username: action.value });
|
|
24
38
|
return {
|
|
25
39
|
...state,
|
|
26
40
|
username: action.value,
|
|
27
41
|
};
|
|
28
42
|
case 'SET_INITIAL_STATE':
|
|
29
|
-
return
|
|
43
|
+
return getInitialState();
|
|
44
|
+
case 'RESET_STATE':
|
|
45
|
+
clearPersistedSignInState();
|
|
46
|
+
return getDefaultState();
|
|
47
|
+
// this state is never reachable
|
|
30
48
|
default:
|
|
31
49
|
return state;
|
|
32
50
|
}
|
|
33
51
|
};
|
|
34
|
-
|
|
52
|
+
const isExpired = (expiryDate) => {
|
|
53
|
+
const expiryTimestamp = Number(expiryDate);
|
|
54
|
+
const currentTimestamp = Date.now();
|
|
55
|
+
return expiryTimestamp <= currentTimestamp;
|
|
56
|
+
};
|
|
57
|
+
const resetActiveSignInState = () => {
|
|
58
|
+
exports.signInStore.dispatch({ type: 'RESET_STATE' });
|
|
59
|
+
};
|
|
60
|
+
exports.resetActiveSignInState = resetActiveSignInState;
|
|
61
|
+
const clearPersistedSignInState = () => {
|
|
62
|
+
for (const stateKey of Object.values(SIGN_IN_STATE_KEYS)) {
|
|
63
|
+
core_1.syncSessionStorage.removeItem(stateKey);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const getDefaultState = () => ({
|
|
67
|
+
username: undefined,
|
|
68
|
+
challengeName: undefined,
|
|
69
|
+
signInSession: undefined,
|
|
70
|
+
});
|
|
71
|
+
// Hydrate signInStore from syncSessionStorage
|
|
72
|
+
const getInitialState = () => {
|
|
73
|
+
const expiry = core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry);
|
|
74
|
+
if (!expiry || isExpired(expiry)) {
|
|
75
|
+
clearPersistedSignInState();
|
|
76
|
+
return getDefaultState();
|
|
77
|
+
}
|
|
78
|
+
const username = core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.username) ?? undefined;
|
|
79
|
+
const challengeName = (core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.challengeName) ?? undefined);
|
|
80
|
+
const signInSession = core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.signInSession) ?? undefined;
|
|
35
81
|
return {
|
|
36
|
-
username
|
|
37
|
-
challengeName
|
|
38
|
-
signInSession
|
|
82
|
+
username,
|
|
83
|
+
challengeName,
|
|
84
|
+
signInSession,
|
|
39
85
|
};
|
|
40
|
-
}
|
|
86
|
+
};
|
|
41
87
|
const createStore = reducer => {
|
|
42
|
-
let currentState = reducer(
|
|
88
|
+
let currentState = reducer(getDefaultState(), { type: 'SET_INITIAL_STATE' });
|
|
43
89
|
return {
|
|
44
90
|
getState: () => currentState,
|
|
45
91
|
dispatch: action => {
|
|
@@ -55,8 +101,16 @@ function setActiveSignInState(state) {
|
|
|
55
101
|
});
|
|
56
102
|
}
|
|
57
103
|
exports.setActiveSignInState = setActiveSignInState;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
104
|
+
// Save local state into Session Storage
|
|
105
|
+
const persistSignInState = ({ challengeName, signInSession, username, }) => {
|
|
106
|
+
username && core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.username, username);
|
|
107
|
+
challengeName &&
|
|
108
|
+
core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.challengeName, challengeName);
|
|
109
|
+
if (signInSession) {
|
|
110
|
+
core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.signInSession, signInSession);
|
|
111
|
+
// Updates expiry when session is passed
|
|
112
|
+
core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.expiry, String(Date.now() + MS_TO_EXPIRY));
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
exports.persistSignInState = persistSignInState;
|
|
62
116
|
//# sourceMappingURL=signInStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInStore.js","sources":["../../../../../src/client/utils/store/signInStore.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.
|
|
1
|
+
{"version":3,"file":"signInStore.js","sources":["../../../../../src/client/utils/store/signInStore.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.persistSignInState = exports.setActiveSignInState = exports.signInStore = exports.resetActiveSignInState = void 0;\nconst core_1 = require(\"@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 (0, exports.persistSignInState)({ signInSession: action.value });\n return {\n ...state,\n signInSession: action.value,\n };\n case 'SET_SIGN_IN_STATE':\n (0, exports.persistSignInState)(action.value);\n return {\n ...action.value,\n };\n case 'SET_CHALLENGE_NAME':\n (0, exports.persistSignInState)({ challengeName: action.value });\n return {\n ...state,\n challengeName: action.value,\n };\n case 'SET_USERNAME':\n (0, exports.persistSignInState)({ username: action.value });\n return {\n ...state,\n username: action.value,\n };\n case 'SET_INITIAL_STATE':\n return getInitialState();\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 resetActiveSignInState = () => {\n exports.signInStore.dispatch({ type: 'RESET_STATE' });\n};\nexports.resetActiveSignInState = resetActiveSignInState;\nconst clearPersistedSignInState = () => {\n for (const stateKey of Object.values(SIGN_IN_STATE_KEYS)) {\n core_1.syncSessionStorage.removeItem(stateKey);\n }\n};\nconst getDefaultState = () => ({\n username: undefined,\n challengeName: undefined,\n signInSession: undefined,\n});\n// Hydrate signInStore from syncSessionStorage\nconst getInitialState = () => {\n const expiry = core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry);\n if (!expiry || isExpired(expiry)) {\n clearPersistedSignInState();\n return getDefaultState();\n }\n const username = core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.username) ?? undefined;\n const challengeName = (core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.challengeName) ?? undefined);\n const signInSession = core_1.syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.signInSession) ?? undefined;\n return {\n username,\n challengeName,\n signInSession,\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};\nexports.signInStore = createStore(signInReducer);\nfunction setActiveSignInState(state) {\n exports.signInStore.dispatch({\n type: 'SET_SIGN_IN_STATE',\n value: state,\n });\n}\nexports.setActiveSignInState = setActiveSignInState;\n// Save local state into Session Storage\nconst persistSignInState = ({ challengeName, signInSession, username, }) => {\n username && core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.username, username);\n challengeName &&\n core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.challengeName, challengeName);\n if (signInSession) {\n core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.signInSession, signInSession);\n // Updates expiry when session is passed\n core_1.syncSessionStorage.setItem(SIGN_IN_STATE_KEYS.expiry, String(Date.now() + MS_TO_EXPIRY));\n }\n};\nexports.persistSignInState = persistSignInState;\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,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AAC1H,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C;AACA,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,SAAS,GAAG,oBAAoB,CAAC;AACvC,MAAM,kBAAkB,GAAG;AAC3B,IAAI,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC;AACrC,IAAI,aAAa,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC;AAC/C,IAAI,aAAa,EAA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I,aAAa;AACjB,QAAQ,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAC3F,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAC3F;AACA,QAAQ,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;AACxG,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmSignIn.js","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.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.confirmSignIn = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst store_1 = require(\"../../../client/utils/store\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst AuthErrorStrings_1 = require(\"../../../common/AuthErrorStrings\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\n/**\n * Continues or completes the sign in process when required by the initial call to `signIn`.\n *\n * @param input - The ConfirmSignInInput object\n * @returns ConfirmSignInOutput\n * @throws -{@link VerifySoftwareTokenException }:\n * Thrown due to an invalid MFA token.\n * @throws -{@link RespondToAuthChallengeException }:\n * Thrown due to an invalid auth challenge response.\n * @throws -{@link AssociateSoftwareTokenException}:\n * Thrown due to a service error during the MFA setup process.\n * @throws -{@link AuthValidationErrorCode }:\n * Thrown when `challengeResponse` is not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = store_1.signInStore.getState();\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!challengeResponse, validation_1.AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process.\n\n\t\t\tThis most likely occurred due to:\n\t\t\t1. signIn was not called before confirmSignIn.\n\t\t\t2. signIn threw an exception.\n\t\t\t3. page was refreshed during the sign in flow.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the page is not refreshed until the sign in process is done.',\n });\n try {\n const { Session, ChallengeName: handledChallengeName, AuthenticationResult, ChallengeParameters: handledChallengeParameters, } = await (0, signInHelpers_1.handleChallengeName)(username, challengeName, signInSession, challengeResponse, authConfig, tokenProvider_1.tokenOrchestrator, clientMetaData, options);\n // sets up local state used during the sign-in process\n (0, store_1.setActiveSignInState)({\n signInSession: Session,\n username,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username,\n ...AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n (0, store_1.
|
|
1
|
+
{"version":3,"file":"confirmSignIn.js","sources":["../../../../../src/providers/cognito/apis/confirmSignIn.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.confirmSignIn = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst store_1 = require(\"../../../client/utils/store\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst AuthErrorStrings_1 = require(\"../../../common/AuthErrorStrings\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\n/**\n * Continues or completes the sign in process when required by the initial call to `signIn`.\n *\n * @param input - The ConfirmSignInInput object\n * @returns ConfirmSignInOutput\n * @throws -{@link VerifySoftwareTokenException }:\n * Thrown due to an invalid MFA token.\n * @throws -{@link RespondToAuthChallengeException }:\n * Thrown due to an invalid auth challenge response.\n * @throws -{@link AssociateSoftwareTokenException}:\n * Thrown due to a service error during the MFA setup process.\n * @throws -{@link AuthValidationErrorCode }:\n * Thrown when `challengeResponse` is not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function confirmSignIn(input) {\n const { challengeResponse, options } = input;\n const { username, challengeName, signInSession, signInDetails } = store_1.signInStore.getState();\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!challengeResponse, validation_1.AuthValidationErrorCode.EmptyChallengeResponse);\n if (!username || !challengeName || !signInSession)\n // TODO: remove this error message for production apps\n throw new AuthError_1.AuthError({\n name: AuthErrorStrings_1.AuthErrorCodes.SignInException,\n message: `\n\t\t\tAn error occurred during the sign in process.\n\n\t\t\tThis most likely occurred due to:\n\t\t\t1. signIn was not called before confirmSignIn.\n\t\t\t2. signIn threw an exception.\n\t\t\t3. page was refreshed during the sign in flow.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the page is not refreshed until the sign in process is done.',\n });\n try {\n const { Session, ChallengeName: handledChallengeName, AuthenticationResult, ChallengeParameters: handledChallengeParameters, } = await (0, signInHelpers_1.handleChallengeName)(username, challengeName, signInSession, challengeResponse, authConfig, tokenProvider_1.tokenOrchestrator, clientMetaData, options);\n // sets up local state used during the sign-in process\n (0, store_1.setActiveSignInState)({\n signInSession: Session,\n username,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username,\n ...AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n (0, store_1.resetActiveSignInState)();\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n (0, assertServiceError_1.assertServiceError)(error);\n const result = (0, signInHelpers_1.getSignInResultFromError)(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|
|
|
10
10
|
const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
|
|
11
11
|
const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
|
|
12
12
|
const signInHelpers_1 = require("../utils/signInHelpers");
|
|
13
|
-
const
|
|
13
|
+
const signInStore_1 = require("../../../client/utils/store/signInStore");
|
|
14
14
|
const cacheTokens_1 = require("../tokenProvider/cacheTokens");
|
|
15
15
|
const tokenProvider_1 = require("../tokenProvider");
|
|
16
16
|
const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
|
|
@@ -39,7 +39,7 @@ async function signInWithCustomAuth(input) {
|
|
|
39
39
|
const { ChallengeName: retriedChallengeName, ChallengeParameters: retiredChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handleCustomAuthFlowWithoutSRP, [username, metadata, authConfig, tokenProvider_1.tokenOrchestrator], username, tokenProvider_1.tokenOrchestrator);
|
|
40
40
|
const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);
|
|
41
41
|
// sets up local state used during the sign-in process
|
|
42
|
-
(0,
|
|
42
|
+
(0, signInStore_1.setActiveSignInState)({
|
|
43
43
|
signInSession: Session,
|
|
44
44
|
username: activeUsername,
|
|
45
45
|
challengeName: retriedChallengeName,
|
|
@@ -57,7 +57,7 @@ async function signInWithCustomAuth(input) {
|
|
|
57
57
|
}),
|
|
58
58
|
signInDetails,
|
|
59
59
|
});
|
|
60
|
-
(0,
|
|
60
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
61
61
|
await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();
|
|
62
62
|
return {
|
|
63
63
|
isSignedIn: true,
|
|
@@ -70,7 +70,7 @@ async function signInWithCustomAuth(input) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
73
|
-
(0,
|
|
73
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
74
74
|
(0, assertServiceError_1.assertServiceError)(error);
|
|
75
75
|
const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);
|
|
76
76
|
if (result)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithCustomAuth.js","sources":["../../../../../src/providers/cognito/apis/signInWithCustomAuth.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.signInWithCustomAuth = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst
|
|
1
|
+
{"version":3,"file":"signInWithCustomAuth.js","sources":["../../../../../src/providers/cognito/apis/signInWithCustomAuth.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.signInWithCustomAuth = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst signInStore_1 = require(\"../../../client/utils/store/signInStore\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\n/**\n * Signs a user in using a custom authentication flow without password\n *\n * @param input - The SignInWithCustomAuthInput object\n * @returns AuthSignInResult\n * @throws service: {@link InitiateAuthException } - Cognito 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 SignInWithCustomAuthOutput - Thrown when the token provider config is invalid.\n */\nasync function signInWithCustomAuth(input) {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITHOUT_SRP',\n };\n const metadata = options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!username, validation_1.AuthValidationErrorCode.EmptySignInUsername);\n (0, assertValidationError_1.assertValidationError)(!password, validation_1.AuthValidationErrorCode.CustomAuthSignInPassword);\n try {\n const { ChallengeName: retriedChallengeName, ChallengeParameters: retiredChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handleCustomAuthFlowWithoutSRP, [username, metadata, authConfig, tokenProvider_1.tokenOrchestrator], username, tokenProvider_1.tokenOrchestrator);\n const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);\n // sets up local state used during the sign-in process\n (0, signInStore_1.setActiveSignInState)({\n signInSession: Session,\n username: activeUsername,\n challengeName: retriedChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username: activeUsername,\n ...AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n (0, signInStore_1.resetActiveSignInState)();\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: retriedChallengeName,\n challengeParameters: retiredChallengeParameters,\n });\n }\n catch (error) {\n (0, signInStore_1.resetActiveSignInState)();\n (0, assertServiceError_1.assertServiceError)(error);\n const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.signInWithCustomAuth = signInWithCustomAuth;\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,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,oBAAoB,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AACjF,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,0BAA0B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AAChE,IAAI,IAAI,OAAO,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AACvD,IAAI,MAA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ors/types/validation");
|
|
|
10
10
|
const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
|
|
11
11
|
const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
|
|
12
12
|
const signInHelpers_1 = require("../utils/signInHelpers");
|
|
13
|
-
const
|
|
13
|
+
const signInStore_1 = require("../../../client/utils/store/signInStore");
|
|
14
14
|
const cacheTokens_1 = require("../tokenProvider/cacheTokens");
|
|
15
15
|
const tokenProvider_1 = require("../tokenProvider");
|
|
16
16
|
const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
|
|
@@ -40,7 +40,7 @@ async function signInWithCustomSRPAuth(input) {
|
|
|
40
40
|
const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.handleCustomSRPAuthFlow)(username, password, metadata, authConfig, tokenProvider_1.tokenOrchestrator);
|
|
41
41
|
const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);
|
|
42
42
|
// sets up local state used during the sign-in process
|
|
43
|
-
(0,
|
|
43
|
+
(0, signInStore_1.setActiveSignInState)({
|
|
44
44
|
signInSession: Session,
|
|
45
45
|
username: activeUsername,
|
|
46
46
|
challengeName: handledChallengeName,
|
|
@@ -58,7 +58,7 @@ async function signInWithCustomSRPAuth(input) {
|
|
|
58
58
|
}),
|
|
59
59
|
signInDetails,
|
|
60
60
|
});
|
|
61
|
-
(0,
|
|
61
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
62
62
|
await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();
|
|
63
63
|
return {
|
|
64
64
|
isSignedIn: true,
|
|
@@ -71,7 +71,7 @@ async function signInWithCustomSRPAuth(input) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
catch (error) {
|
|
74
|
-
(0,
|
|
74
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
75
75
|
(0, assertServiceError_1.assertServiceError)(error);
|
|
76
76
|
const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);
|
|
77
77
|
if (result)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithCustomSRPAuth.js","sources":["../../../../../src/providers/cognito/apis/signInWithCustomSRPAuth.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.signInWithCustomSRPAuth = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst
|
|
1
|
+
{"version":3,"file":"signInWithCustomSRPAuth.js","sources":["../../../../../src/providers/cognito/apis/signInWithCustomSRPAuth.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.signInWithCustomSRPAuth = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst signInStore_1 = require(\"../../../client/utils/store/signInStore\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../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 */\nasync function signInWithCustomSRPAuth(input) {\n const { username, password, options } = input;\n const signInDetails = {\n loginId: username,\n authFlowType: 'CUSTOM_WITH_SRP',\n };\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const metadata = options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!username, validation_1.AuthValidationErrorCode.EmptySignInUsername);\n (0, assertValidationError_1.assertValidationError)(!!password, validation_1.AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.handleCustomSRPAuthFlow)(username, password, metadata, authConfig, tokenProvider_1.tokenOrchestrator);\n const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);\n // sets up local state used during the sign-in process\n (0, signInStore_1.setActiveSignInState)({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username: activeUsername,\n ...AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n (0, signInStore_1.resetActiveSignInState)();\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n (0, signInStore_1.resetActiveSignInState)();\n (0, assertServiceError_1.assertServiceError)(error);\n const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.signInWithCustomSRPAuth = signInWithCustomSRPAuth;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,oBAAoB,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AACjF,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,0BAA0B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,uBAAuB,CAAC,KAAK,EAAE;AAC9C,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,MA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,EAAE;AACnF,oBAAoB,UAAU,EAAE,UAAU,CAAC,UAAU;AACrD,oBAAoB,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;AACjE,oBAAoB,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB;AAC7E,oBAAoB,WAAW,EAAE,oBAAoB,CAAC,WAAW;AACjE,iBAAiB,CAAC;AAClB,gBAAgB,aAAa;AAC7B,aAAa,CAAC,CAAC;AACf,YAAY,CAAC,CAAC,EAAE,aAAa,CAAC,sBAAsB,GAAG,CAAC;AACxD,YAAY,MAAM,CAAC,CAAC,EAAE,0BAA0B,CAAC,wBAAwB,GAAG,CAAC;AAC7E,YAAY,OAAO;AACnB,gBAAgB,UAAU,EAAE,IAAI;AAChC,gBAAgB,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;AAChD,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,eAAe,EAAE;AACpD,YAAY,aAAa,EAAE,oBAAoB;AAC/C,YAAY,mBAAmB,EAAE,0BAA0B;AAC3D,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,aAAa,CAAC,sBAAsB,GAAG,CAAC;AACpD,QAAQ,IAAI,oBAAoB,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAC5D,QAAQ,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,wBAAwB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AACjF,QAAQ,IAAI,MAAM;AAClB,YAAY,OAAO,MAAM,CAAC;AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB;;"}
|
|
@@ -10,7 +10,7 @@ const validation_1 = require("../../../errors/types/validation");
|
|
|
10
10
|
const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
|
|
11
11
|
const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
|
|
12
12
|
const signInHelpers_1 = require("../utils/signInHelpers");
|
|
13
|
-
const
|
|
13
|
+
const signInStore_1 = require("../../../client/utils/store/signInStore");
|
|
14
14
|
const cacheTokens_1 = require("../tokenProvider/cacheTokens");
|
|
15
15
|
const tokenProvider_1 = require("../tokenProvider");
|
|
16
16
|
const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
|
|
@@ -41,7 +41,7 @@ async function signInWithSRP(input) {
|
|
|
41
41
|
const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.handleUserSRPAuthFlow)(username, password, clientMetaData, authConfig, tokenProvider_1.tokenOrchestrator);
|
|
42
42
|
const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);
|
|
43
43
|
// sets up local state used during the sign-in process
|
|
44
|
-
(0,
|
|
44
|
+
(0, signInStore_1.setActiveSignInState)({
|
|
45
45
|
signInSession: Session,
|
|
46
46
|
username: activeUsername,
|
|
47
47
|
challengeName: handledChallengeName,
|
|
@@ -59,7 +59,7 @@ async function signInWithSRP(input) {
|
|
|
59
59
|
}),
|
|
60
60
|
signInDetails,
|
|
61
61
|
});
|
|
62
|
-
(0,
|
|
62
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
63
63
|
await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();
|
|
64
64
|
(0, autoSignIn_1.resetAutoSignIn)();
|
|
65
65
|
return {
|
|
@@ -73,7 +73,7 @@ async function signInWithSRP(input) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
catch (error) {
|
|
76
|
-
(0,
|
|
76
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
77
77
|
(0, autoSignIn_1.resetAutoSignIn)();
|
|
78
78
|
(0, assertServiceError_1.assertServiceError)(error);
|
|
79
79
|
const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithSRP.js","sources":["../../../../../src/providers/cognito/apis/signInWithSRP.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.signInWithSRP = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst
|
|
1
|
+
{"version":3,"file":"signInWithSRP.js","sources":["../../../../../src/providers/cognito/apis/signInWithSRP.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.signInWithSRP = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst signInStore_1 = require(\"../../../client/utils/store/signInStore\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\nconst autoSignIn_1 = require(\"./autoSignIn\");\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 */\nasync function signInWithSRP(input) {\n const { username, password } = input;\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_SRP_AUTH',\n };\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = input.options?.clientMetadata;\n (0, assertValidationError_1.assertValidationError)(!!username, validation_1.AuthValidationErrorCode.EmptySignInUsername);\n (0, assertValidationError_1.assertValidationError)(!!password, validation_1.AuthValidationErrorCode.EmptySignInPassword);\n try {\n const { ChallengeName: handledChallengeName, ChallengeParameters: handledChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.handleUserSRPAuthFlow)(username, password, clientMetaData, authConfig, tokenProvider_1.tokenOrchestrator);\n const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);\n // sets up local state used during the sign-in process\n (0, signInStore_1.setActiveSignInState)({\n signInSession: Session,\n username: activeUsername,\n challengeName: handledChallengeName,\n signInDetails,\n });\n if (AuthenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username: activeUsername,\n ...AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,\n accessToken: AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n (0, signInStore_1.resetActiveSignInState)();\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n (0, autoSignIn_1.resetAutoSignIn)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: handledChallengeName,\n challengeParameters: handledChallengeParameters,\n });\n }\n catch (error) {\n (0, signInStore_1.resetActiveSignInState)();\n (0, autoSignIn_1.resetAutoSignIn)();\n (0, assertServiceError_1.assertServiceError)(error);\n const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.signInWithSRP = signInWithSRP;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,oBAAoB,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AACjF,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,0BAA0B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAChF,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa,CAAC,KAAK,EAAE;AACpC,IAAI,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AACzC,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AAChE,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,OAAO,EAAE,QAAQ;AAC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ValidationE
|
|
|
11
11
|
const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
|
|
12
12
|
const signInHelpers_1 = require("../utils/signInHelpers");
|
|
13
13
|
const store_1 = require("../../../client/utils/store");
|
|
14
|
+
const signInStore_1 = require("../../../client/utils/store/signInStore");
|
|
14
15
|
const cacheTokens_1 = require("../tokenProvider/cacheTokens");
|
|
15
16
|
const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
|
|
16
17
|
const tokenProvider_1 = require("../tokenProvider");
|
|
@@ -54,7 +55,7 @@ async function signInWithUserAuth(input) {
|
|
|
54
55
|
}
|
|
55
56
|
const response = await (0, handleUserAuthFlow_1.handleUserAuthFlow)(handleUserAuthFlowInput);
|
|
56
57
|
const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);
|
|
57
|
-
(0,
|
|
58
|
+
(0, signInStore_1.setActiveSignInState)({
|
|
58
59
|
signInSession: response.Session,
|
|
59
60
|
username: activeUsername,
|
|
60
61
|
challengeName: response.ChallengeName,
|
|
@@ -72,7 +73,7 @@ async function signInWithUserAuth(input) {
|
|
|
72
73
|
}),
|
|
73
74
|
signInDetails,
|
|
74
75
|
});
|
|
75
|
-
(0,
|
|
76
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
76
77
|
await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();
|
|
77
78
|
(0, autoSignIn_1.resetAutoSignIn)();
|
|
78
79
|
return {
|
|
@@ -89,7 +90,7 @@ async function signInWithUserAuth(input) {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
catch (error) {
|
|
92
|
-
(0,
|
|
93
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
93
94
|
(0, autoSignIn_1.resetAutoSignIn)();
|
|
94
95
|
(0, assertServiceError_1.assertServiceError)(error);
|
|
95
96
|
const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signInWithUserAuth.js","sources":["../../../../../src/providers/cognito/apis/signInWithUserAuth.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.signInWithUserAuth = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst store_1 = require(\"../../../client/utils/store\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst handleUserAuthFlow_1 = require(\"../../../client/flows/userAuth/handleUserAuthFlow\");\nconst autoSignIn_1 = require(\"./autoSignIn\");\n/**\n * Signs a user in through a registered email or phone number without a password by by receiving and entering an OTP.\n *\n * @param input - The SignInWithUserAuthInput object\n * @returns SignInWithUserAuthOutput\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 -- needs to change\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function signInWithUserAuth(input) {\n const { username, password, options } = input;\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_AUTH',\n };\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = options?.clientMetadata;\n const preferredChallenge = options?.preferredChallenge;\n (0, assertValidationError_1.assertValidationError)(!!username, validation_1.AuthValidationErrorCode.EmptySignInUsername);\n try {\n const handleUserAuthFlowInput = {\n username,\n config: authConfig,\n tokenOrchestrator: tokenProvider_1.tokenOrchestrator,\n clientMetadata: clientMetaData,\n preferredChallenge,\n password,\n };\n const autoSignInStoreState = store_1.autoSignInStore.getState();\n if (autoSignInStoreState.active &&\n autoSignInStoreState.username === username) {\n handleUserAuthFlowInput.session = autoSignInStoreState.session;\n }\n const response = await (0, handleUserAuthFlow_1.handleUserAuthFlow)(handleUserAuthFlowInput);\n const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);\n (0,
|
|
1
|
+
{"version":3,"file":"signInWithUserAuth.js","sources":["../../../../../src/providers/cognito/apis/signInWithUserAuth.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.signInWithUserAuth = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst signInHelpers_1 = require(\"../utils/signInHelpers\");\nconst store_1 = require(\"../../../client/utils/store\");\nconst signInStore_1 = require(\"../../../client/utils/store/signInStore\");\nconst cacheTokens_1 = require(\"../tokenProvider/cacheTokens\");\nconst dispatchSignedInHubEvent_1 = require(\"../utils/dispatchSignedInHubEvent\");\nconst tokenProvider_1 = require(\"../tokenProvider\");\nconst handleUserAuthFlow_1 = require(\"../../../client/flows/userAuth/handleUserAuthFlow\");\nconst autoSignIn_1 = require(\"./autoSignIn\");\n/**\n * Signs a user in through a registered email or phone number without a password by by receiving and entering an OTP.\n *\n * @param input - The SignInWithUserAuthInput object\n * @returns SignInWithUserAuthOutput\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 -- needs to change\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function signInWithUserAuth(input) {\n const { username, password, options } = input;\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n const signInDetails = {\n loginId: username,\n authFlowType: 'USER_AUTH',\n };\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const clientMetaData = options?.clientMetadata;\n const preferredChallenge = options?.preferredChallenge;\n (0, assertValidationError_1.assertValidationError)(!!username, validation_1.AuthValidationErrorCode.EmptySignInUsername);\n try {\n const handleUserAuthFlowInput = {\n username,\n config: authConfig,\n tokenOrchestrator: tokenProvider_1.tokenOrchestrator,\n clientMetadata: clientMetaData,\n preferredChallenge,\n password,\n };\n const autoSignInStoreState = store_1.autoSignInStore.getState();\n if (autoSignInStoreState.active &&\n autoSignInStoreState.username === username) {\n handleUserAuthFlowInput.session = autoSignInStoreState.session;\n }\n const response = await (0, handleUserAuthFlow_1.handleUserAuthFlow)(handleUserAuthFlowInput);\n const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);\n (0, signInStore_1.setActiveSignInState)({\n signInSession: response.Session,\n username: activeUsername,\n challengeName: response.ChallengeName,\n signInDetails,\n });\n if (response.AuthenticationResult) {\n await (0, cacheTokens_1.cacheCognitoTokens)({\n username: activeUsername,\n ...response.AuthenticationResult,\n NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({\n userPoolId: authConfig.userPoolId,\n userPoolEndpoint: authConfig.userPoolEndpoint,\n newDeviceMetadata: response.AuthenticationResult.NewDeviceMetadata,\n accessToken: response.AuthenticationResult.AccessToken,\n }),\n signInDetails,\n });\n (0, signInStore_1.resetActiveSignInState)();\n await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();\n (0, autoSignIn_1.resetAutoSignIn)();\n return {\n isSignedIn: true,\n nextStep: { signInStep: 'DONE' },\n };\n }\n return (0, signInHelpers_1.getSignInResult)({\n challengeName: response.ChallengeName,\n challengeParameters: response.ChallengeParameters,\n availableChallenges: 'AvailableChallenges' in response\n ? response.AvailableChallenges\n : undefined,\n });\n }\n catch (error) {\n (0, signInStore_1.resetActiveSignInState)();\n (0, autoSignIn_1.resetAutoSignIn)();\n (0, assertServiceError_1.assertServiceError)(error);\n const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.signInWithUserAuth = signInWithUserAuth;\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,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,oBAAoB,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AACjF,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACvD,MAAM,aAAa,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC9D,MAAM,0BAA0B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAChF,MAAM,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,oBAAoB,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAC1F,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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CAAC,eAAe,EAAE;AACpD,YAAY,aAAa,EAAE,QAAQ,CAAC,aAAa;AACjD,YAAY,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;AAC7D,YAAY,mBAAmB,EAAE,qBAAqB,IAAI,QAAQ;AAClE,kBAAkB,QAAQ,CAAC,mBAAmB;AAC9C,kBAAkB,SAAS;AAC3B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,aAAa,CAAC,sBAAsB,GAAG,CAAC;AACpD,QAAQ,IAAI,YAAY,CAAC,eAAe,GAAG,CAAC;AAC5C,QAAQ,IAAI,oBAAoB,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAC5D,QAAQ,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,wBAAwB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AACjF,QAAQ,IAAI,MAAM;AAClB,YAAY,OAAO,MAAM,CAAC;AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -10,7 +10,7 @@ const validation_1 = require("../../../errors/types/validation");
|
|
|
10
10
|
const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
|
|
11
11
|
const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
|
|
12
12
|
const signInHelpers_1 = require("../utils/signInHelpers");
|
|
13
|
-
const
|
|
13
|
+
const signInStore_1 = require("../../../client/utils/store/signInStore");
|
|
14
14
|
const cacheTokens_1 = require("../tokenProvider/cacheTokens");
|
|
15
15
|
const tokenProvider_1 = require("../tokenProvider");
|
|
16
16
|
const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
|
|
@@ -40,7 +40,7 @@ async function signInWithUserPassword(input) {
|
|
|
40
40
|
const { ChallengeName: retiredChallengeName, ChallengeParameters: retriedChallengeParameters, AuthenticationResult, Session, } = await (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handleUserPasswordAuthFlow, [username, password, metadata, authConfig, tokenProvider_1.tokenOrchestrator], username, tokenProvider_1.tokenOrchestrator);
|
|
41
41
|
const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);
|
|
42
42
|
// sets up local state used during the sign-in process
|
|
43
|
-
(0,
|
|
43
|
+
(0, signInStore_1.setActiveSignInState)({
|
|
44
44
|
signInSession: Session,
|
|
45
45
|
username: activeUsername,
|
|
46
46
|
challengeName: retiredChallengeName,
|
|
@@ -58,7 +58,7 @@ async function signInWithUserPassword(input) {
|
|
|
58
58
|
}),
|
|
59
59
|
signInDetails,
|
|
60
60
|
});
|
|
61
|
-
(0,
|
|
61
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
62
62
|
await (0, dispatchSignedInHubEvent_1.dispatchSignedInHubEvent)();
|
|
63
63
|
(0, autoSignIn_1.resetAutoSignIn)();
|
|
64
64
|
return {
|
|
@@ -72,7 +72,7 @@ async function signInWithUserPassword(input) {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
catch (error) {
|
|
75
|
-
(0,
|
|
75
|
+
(0, signInStore_1.resetActiveSignInState)();
|
|
76
76
|
(0, autoSignIn_1.resetAutoSignIn)();
|
|
77
77
|
(0, assertServiceError_1.assertServiceError)(error);
|
|
78
78
|
const result = (0, signInHelpers_1.getSignInResultFromError)(error.name);
|