@aws-amplify/auth 6.10.2-server-auth.fd0687d.0 → 6.10.2-unstable.25dbd61.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.
Files changed (132) hide show
  1. package/dist/cjs/client/flows/shared/handlePasswordSRP.js +5 -3
  2. package/dist/cjs/client/flows/shared/handlePasswordSRP.js.map +1 -1
  3. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPassword.js +2 -2
  4. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPassword.js.map +1 -1
  5. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js +5 -3
  6. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js.map +1 -1
  7. package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js +2 -2
  8. package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js.map +1 -1
  9. package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js +4 -4
  10. package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js.map +1 -1
  11. package/dist/cjs/{providers/cognito/tokenProvider/constants.js → client/flows/userAuth/types.js} +1 -3
  12. package/dist/cjs/client/flows/userAuth/types.js.map +1 -0
  13. package/dist/cjs/providers/cognito/apis/confirmSignIn.js +2 -1
  14. package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
  15. package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js +4 -2
  16. package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js.map +1 -1
  17. package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js +2 -1
  18. package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js.map +1 -1
  19. package/dist/cjs/providers/cognito/apis/signInWithSRP.js +2 -1
  20. package/dist/cjs/providers/cognito/apis/signInWithSRP.js.map +1 -1
  21. package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js +2 -1
  22. package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js.map +1 -1
  23. package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js +4 -2
  24. package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js.map +1 -1
  25. package/dist/cjs/providers/cognito/index.js +1 -8
  26. package/dist/cjs/providers/cognito/index.js.map +1 -1
  27. package/dist/cjs/providers/cognito/tokenProvider/TokenStore.js +5 -3
  28. package/dist/cjs/providers/cognito/tokenProvider/TokenStore.js.map +1 -1
  29. package/dist/cjs/providers/cognito/tokenProvider/index.js +1 -4
  30. package/dist/cjs/providers/cognito/tokenProvider/index.js.map +1 -1
  31. package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js +64 -0
  32. package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js.map +1 -0
  33. package/dist/cjs/providers/cognito/utils/handleDeviceSRPAuth.js +88 -0
  34. package/dist/cjs/providers/cognito/utils/handleDeviceSRPAuth.js.map +1 -0
  35. package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js +79 -0
  36. package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js.map +1 -0
  37. package/dist/cjs/providers/cognito/utils/oauth/index.js +1 -3
  38. package/dist/cjs/providers/cognito/utils/oauth/index.js.map +1 -1
  39. package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js +28 -0
  40. package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js.map +1 -0
  41. package/dist/cjs/providers/cognito/utils/setActiveSignInUsername.js +13 -0
  42. package/dist/cjs/providers/cognito/utils/setActiveSignInUsername.js.map +1 -0
  43. package/dist/cjs/providers/cognito/utils/signInHelpers.js +23 -227
  44. package/dist/cjs/providers/cognito/utils/signInHelpers.js.map +1 -1
  45. package/dist/esm/client/flows/shared/handlePasswordSRP.mjs +3 -1
  46. package/dist/esm/client/flows/shared/handlePasswordSRP.mjs.map +1 -1
  47. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs +1 -1
  48. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs.map +1 -1
  49. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs +3 -1
  50. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs.map +1 -1
  51. package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs +1 -1
  52. package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs.map +1 -1
  53. package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.d.ts +2 -2
  54. package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs +3 -3
  55. package/dist/esm/client/flows/userAuth/handleWebAuthnSignInResult.mjs.map +1 -1
  56. package/dist/esm/client/flows/userAuth/types.d.ts +6 -0
  57. package/dist/esm/client/flows/userAuth/types.mjs +2 -0
  58. package/dist/esm/client/flows/userAuth/types.mjs.map +1 -0
  59. package/dist/esm/index.mjs +0 -5
  60. package/dist/esm/index.mjs.map +1 -1
  61. package/dist/esm/providers/cognito/apis/confirmSignIn.mjs +2 -1
  62. package/dist/esm/providers/cognito/apis/confirmSignIn.mjs.map +1 -1
  63. package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs +3 -1
  64. package/dist/esm/providers/cognito/apis/signInWithCustomAuth.mjs.map +1 -1
  65. package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs +2 -1
  66. package/dist/esm/providers/cognito/apis/signInWithCustomSRPAuth.mjs.map +1 -1
  67. package/dist/esm/providers/cognito/apis/signInWithRedirect.mjs +0 -1
  68. package/dist/esm/providers/cognito/apis/signInWithRedirect.mjs.map +1 -1
  69. package/dist/esm/providers/cognito/apis/signInWithSRP.mjs +2 -1
  70. package/dist/esm/providers/cognito/apis/signInWithSRP.mjs.map +1 -1
  71. package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs +2 -1
  72. package/dist/esm/providers/cognito/apis/signInWithUserAuth.mjs.map +1 -1
  73. package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs +3 -1
  74. package/dist/esm/providers/cognito/apis/signInWithUserPassword.mjs.map +1 -1
  75. package/dist/esm/providers/cognito/index.d.ts +1 -2
  76. package/dist/esm/providers/cognito/index.mjs +1 -12
  77. package/dist/esm/providers/cognito/index.mjs.map +1 -1
  78. package/dist/esm/providers/cognito/tokenProvider/TokenStore.d.ts +1 -0
  79. package/dist/esm/providers/cognito/tokenProvider/TokenStore.mjs +5 -3
  80. package/dist/esm/providers/cognito/tokenProvider/TokenStore.mjs.map +1 -1
  81. package/dist/esm/providers/cognito/tokenProvider/index.d.ts +1 -2
  82. package/dist/esm/providers/cognito/tokenProvider/index.mjs +1 -2
  83. package/dist/esm/providers/cognito/tokenProvider/index.mjs.map +1 -1
  84. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.d.ts +17 -0
  85. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs +71 -0
  86. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs.map +1 -0
  87. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.d.ts +13 -0
  88. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs +97 -0
  89. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs.map +1 -0
  90. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.d.ts +6 -0
  91. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs +88 -0
  92. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs.map +1 -0
  93. package/dist/esm/providers/cognito/utils/oauth/index.d.ts +0 -1
  94. package/dist/esm/providers/cognito/utils/oauth/index.mjs +0 -1
  95. package/dist/esm/providers/cognito/utils/oauth/index.mjs.map +1 -1
  96. package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.d.ts +7 -0
  97. package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.mjs +26 -0
  98. package/dist/esm/providers/cognito/utils/retryOnResourceNotFoundException.mjs.map +1 -0
  99. package/dist/esm/providers/cognito/utils/setActiveSignInUsername.d.ts +1 -0
  100. package/dist/esm/providers/cognito/utils/setActiveSignInUsername.mjs +12 -0
  101. package/dist/esm/providers/cognito/utils/setActiveSignInUsername.mjs.map +1 -0
  102. package/dist/esm/providers/cognito/utils/signInHelpers.d.ts +2 -26
  103. package/dist/esm/providers/cognito/utils/signInHelpers.mjs +18 -220
  104. package/dist/esm/providers/cognito/utils/signInHelpers.mjs.map +1 -1
  105. package/package.json +5 -5
  106. package/src/client/flows/shared/handlePasswordSRP.ts +3 -5
  107. package/src/client/flows/userAuth/handleSelectChallengeWithPassword.ts +1 -1
  108. package/src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts +3 -5
  109. package/src/client/flows/userAuth/handleUserAuthFlow.ts +1 -1
  110. package/src/client/flows/userAuth/handleWebAuthnSignInResult.ts +6 -8
  111. package/src/client/flows/userAuth/types.ts +15 -0
  112. package/src/providers/cognito/apis/confirmSignIn.ts +1 -1
  113. package/src/providers/cognito/apis/signInWithCustomAuth.ts +2 -2
  114. package/src/providers/cognito/apis/signInWithCustomSRPAuth.ts +1 -1
  115. package/src/providers/cognito/apis/signInWithSRP.ts +1 -1
  116. package/src/providers/cognito/apis/signInWithUserAuth.ts +1 -1
  117. package/src/providers/cognito/apis/signInWithUserPassword.ts +2 -2
  118. package/src/providers/cognito/index.ts +0 -8
  119. package/src/providers/cognito/tokenProvider/TokenStore.ts +3 -4
  120. package/src/providers/cognito/tokenProvider/index.ts +1 -2
  121. package/src/providers/cognito/utils/getNewDeviceMetadata.ts +88 -0
  122. package/src/providers/cognito/utils/handleDeviceSRPAuth.ts +146 -0
  123. package/src/providers/cognito/utils/handlePasswordVerifierChallenge.ts +106 -0
  124. package/src/providers/cognito/utils/oauth/index.ts +0 -1
  125. package/src/providers/cognito/utils/retryOnResourceNotFoundException.ts +34 -0
  126. package/src/providers/cognito/utils/setActiveSignInUsername.ts +10 -0
  127. package/src/providers/cognito/utils/signInHelpers.ts +19 -327
  128. package/dist/cjs/providers/cognito/tokenProvider/constants.js.map +0 -1
  129. package/dist/esm/providers/cognito/tokenProvider/constants.d.ts +0 -1
  130. package/dist/esm/providers/cognito/tokenProvider/constants.mjs +0 -6
  131. package/dist/esm/providers/cognito/tokenProvider/constants.mjs.map +0 -1
  132. package/src/providers/cognito/tokenProvider/constants.ts +0 -4
@@ -7,11 +7,13 @@ exports.handlePasswordSRP = void 0;
7
7
  const utils_1 = require("@aws-amplify/core/internals/utils");
8
8
  const userContextData_1 = require("../../../providers/cognito/utils/userContextData");
9
9
  const srp_1 = require("../../../providers/cognito/utils/srp");
10
- const signInHelpers_1 = require("../../../providers/cognito/utils/signInHelpers");
11
10
  const cognitoIdentityProvider_1 = require("../../../foundation/factories/serviceClients/cognitoIdentityProvider");
12
11
  const factories_1 = require("../../../providers/cognito/factories");
13
12
  const parsers_1 = require("../../../foundation/parsers");
14
13
  const utils_2 = require("../../../utils");
14
+ const handlePasswordVerifierChallenge_1 = require("../../../providers/cognito/utils/handlePasswordVerifierChallenge");
15
+ const retryOnResourceNotFoundException_1 = require("../../../providers/cognito/utils/retryOnResourceNotFoundException");
16
+ const setActiveSignInUsername_1 = require("../../../providers/cognito/utils/setActiveSignInUsername");
15
17
  /**
16
18
  * Handles the Password SRP (Secure Remote Password) authentication flow.
17
19
  * This function can be used with both USER_SRP_AUTH and USER_AUTH flows.
@@ -61,9 +63,9 @@ async function handlePasswordSRP({ username, password, clientMetadata, config, t
61
63
  }, jsonReq);
62
64
  const { ChallengeParameters: challengeParameters, Session: session } = resp;
63
65
  const activeUsername = challengeParameters?.USERNAME ?? username;
64
- (0, signInHelpers_1.setActiveSignInUsername)(activeUsername);
66
+ (0, setActiveSignInUsername_1.setActiveSignInUsername)(activeUsername);
65
67
  if (resp.ChallengeName === 'PASSWORD_VERIFIER') {
66
- return (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handlePasswordVerifierChallenge, [
68
+ return (0, retryOnResourceNotFoundException_1.retryOnResourceNotFoundException)(handlePasswordVerifierChallenge_1.handlePasswordVerifierChallenge, [
67
69
  password,
68
70
  challengeParameters,
69
71
  clientMetadata,
@@ -1 +1 @@
1
- {"version":3,"file":"handlePasswordSRP.js","sources":["../../../../../src/client/flows/shared/handlePasswordSRP.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.handlePasswordSRP = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst srp_1 = require(\"../../../providers/cognito/utils/srp\");\nconst signInHelpers_1 = require(\"../../../providers/cognito/utils/signInHelpers\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\n/**\n * Handles the Password SRP (Secure Remote Password) authentication flow.\n * This function can be used with both USER_SRP_AUTH and USER_AUTH flows.\n *\n * @param {Object} params - The parameters for the Password SRP authentication\n * @param {string} params.username - The username for authentication\n * @param {string} params.password - The user's password\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Token orchestrator for managing auth tokens\n * @param {AuthFlowType} params.authFlow - The type of authentication flow ('USER_SRP_AUTH' or 'USER_AUTH')\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred challenge type when using USER_AUTH flow\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The authentication response\n */\nasync function handlePasswordSRP({ username, password, clientMetadata, config, tokenOrchestrator, authFlow, preferredChallenge, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId?.split('_')[1] || '';\n const authenticationHelper = await (0, srp_1.getAuthenticationHelper)(userPoolName);\n const authParameters = {\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n if (authFlow === 'USER_AUTH' && preferredChallenge) {\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const UserContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReq = {\n AuthFlow: authFlow,\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n const initiateAuth = (0, cognitoIdentityProvider_1.createInitiateAuthClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const resp = await initiateAuth({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignIn),\n }, jsonReq);\n const { ChallengeParameters: challengeParameters, Session: session } = resp;\n const activeUsername = challengeParameters?.USERNAME ?? username;\n (0, signInHelpers_1.setActiveSignInUsername)(activeUsername);\n if (resp.ChallengeName === 'PASSWORD_VERIFIER') {\n return (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handlePasswordVerifierChallenge, [\n password,\n challengeParameters,\n clientMetadata,\n session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return resp;\n}\nexports.handlePasswordSRP = handlePasswordSRP;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,iBAAiB,GAAG,OAAO,CAAC,kDAAkD,CAAC,CAAC;AACtF,MAAM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I,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;;"}
1
+ {"version":3,"file":"handlePasswordSRP.js","sources":["../../../../../src/client/flows/shared/handlePasswordSRP.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.handlePasswordSRP = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst srp_1 = require(\"../../../providers/cognito/utils/srp\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst handlePasswordVerifierChallenge_1 = require(\"../../../providers/cognito/utils/handlePasswordVerifierChallenge\");\nconst retryOnResourceNotFoundException_1 = require(\"../../../providers/cognito/utils/retryOnResourceNotFoundException\");\nconst setActiveSignInUsername_1 = require(\"../../../providers/cognito/utils/setActiveSignInUsername\");\n/**\n * Handles the Password SRP (Secure Remote Password) authentication flow.\n * This function can be used with both USER_SRP_AUTH and USER_AUTH flows.\n *\n * @param {Object} params - The parameters for the Password SRP authentication\n * @param {string} params.username - The username for authentication\n * @param {string} params.password - The user's password\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Token orchestrator for managing auth tokens\n * @param {AuthFlowType} params.authFlow - The type of authentication flow ('USER_SRP_AUTH' or 'USER_AUTH')\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred challenge type when using USER_AUTH flow\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The authentication response\n */\nasync function handlePasswordSRP({ username, password, clientMetadata, config, tokenOrchestrator, authFlow, preferredChallenge, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId?.split('_')[1] || '';\n const authenticationHelper = await (0, srp_1.getAuthenticationHelper)(userPoolName);\n const authParameters = {\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n if (authFlow === 'USER_AUTH' && preferredChallenge) {\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const UserContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReq = {\n AuthFlow: authFlow,\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n const initiateAuth = (0, cognitoIdentityProvider_1.createInitiateAuthClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const resp = await initiateAuth({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignIn),\n }, jsonReq);\n const { ChallengeParameters: challengeParameters, Session: session } = resp;\n const activeUsername = challengeParameters?.USERNAME ?? username;\n (0, setActiveSignInUsername_1.setActiveSignInUsername)(activeUsername);\n if (resp.ChallengeName === 'PASSWORD_VERIFIER') {\n return (0, retryOnResourceNotFoundException_1.retryOnResourceNotFoundException)(handlePasswordVerifierChallenge_1.handlePasswordVerifierChallenge, [\n password,\n challengeParameters,\n clientMetadata,\n session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return resp;\n}\nexports.handlePasswordSRP = handlePasswordSRP;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CA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CAAC,gCAAgC,EAAE,iCAAiC,CAAC,+BAA+B,EAAE;AAC3J,YAAY,QAAQ;AACpB,YAAY,mBAAmB;AAC/B,YAAY,cAAc;AAC1B,YAAY,OAAO;AACnB,YAAY,oBAAoB;AAChC,YAAY,MAAM;AAClB,YAAY,iBAAiB;AAC7B,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAC9C,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;;"}
@@ -10,7 +10,7 @@ const factories_1 = require("../../../providers/cognito/factories");
10
10
  const parsers_1 = require("../../../foundation/parsers");
11
11
  const utils_2 = require("../../../utils");
12
12
  const userContextData_1 = require("../../../providers/cognito/utils/userContextData");
13
- const signInHelpers_1 = require("../../../providers/cognito/utils/signInHelpers");
13
+ const setActiveSignInUsername_1 = require("../../../providers/cognito/utils/setActiveSignInUsername");
14
14
  /**
15
15
  * Handles the SELECT_CHALLENGE response specifically for Password authentication.
16
16
  * This function combines the SELECT_CHALLENGE flow with standard password authentication.
@@ -52,7 +52,7 @@ async function handleSelectChallengeWithPassword(username, password, clientMetad
52
52
  UserContextData: userContextData,
53
53
  });
54
54
  const activeUsername = response.ChallengeParameters?.USERNAME ?? username;
55
- (0, signInHelpers_1.setActiveSignInUsername)(activeUsername);
55
+ (0, setActiveSignInUsername_1.setActiveSignInUsername)(activeUsername);
56
56
  return response;
57
57
  }
58
58
  exports.handleSelectChallengeWithPassword = handleSelectChallengeWithPassword;
@@ -1 +1 @@
1
- {"version":3,"file":"handleSelectChallengeWithPassword.js","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPassword.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.handleSelectChallengeWithPassword = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst signInHelpers_1 = require(\"../../../providers/cognito/utils/signInHelpers\");\n/**\n * Handles the SELECT_CHALLENGE response specifically for Password authentication.\n * This function combines the SELECT_CHALLENGE flow with standard password authentication.\n *\n * @param {string} username - The username for authentication\n * @param {string} password - The user's password\n * @param {ClientMetadata} [clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} config - Cognito User Pool configuration\n * @param {string} session - The current authentication session token\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nasync function handleSelectChallengeWithPassword(username, password, clientMetadata, config, session) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const authParameters = {\n ANSWER: 'PASSWORD',\n USERNAME: username,\n PASSWORD: password,\n };\n const userContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: authParameters,\n ClientId: userPoolClientId,\n ClientMetadata: clientMetadata,\n Session: session,\n UserContextData: userContextData,\n });\n const activeUsername = response.ChallengeParameters?.USERNAME ?? username;\n (0, signInHelpers_1.setActiveSignInUsername)(activeUsername);\n return response;\n}\nexports.handleSelectChallengeWithPassword = handleSelectChallengeWithPassword;\n"],"names":[],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AAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC;AAClD,QAAQ,MAAM,EAAE,IAAI,SAAS,CAAC,uBAAuB,EAAE,UAAU,CAAC;AAClE,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC;AAC5F,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE,cAAc;AAC1C,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,eAAe,EAAE,eAAe;AACxC,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,IAAI,QAAQ,CAAC;AAC9E,IAAI,IAAI,eAAe,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;AACjE,IAAI,OAAO,QAAQ,CAAC;AACpB,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
1
+ {"version":3,"file":"handleSelectChallengeWithPassword.js","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPassword.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.handleSelectChallengeWithPassword = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst setActiveSignInUsername_1 = require(\"../../../providers/cognito/utils/setActiveSignInUsername\");\n/**\n * Handles the SELECT_CHALLENGE response specifically for Password authentication.\n * This function combines the SELECT_CHALLENGE flow with standard password authentication.\n *\n * @param {string} username - The username for authentication\n * @param {string} password - The user's password\n * @param {ClientMetadata} [clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} config - Cognito User Pool configuration\n * @param {string} session - The current authentication session token\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nasync function handleSelectChallengeWithPassword(username, password, clientMetadata, config, session) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const authParameters = {\n ANSWER: 'PASSWORD',\n USERNAME: username,\n PASSWORD: password,\n };\n const userContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: authParameters,\n ClientId: userPoolClientId,\n ClientMetadata: clientMetadata,\n Session: session,\n UserContextData: userContextData,\n });\n const activeUsername = response.ChallengeParameters?.USERNAME ?? username;\n (0, setActiveSignInUsername_1.setActiveSignInUsername)(activeUsername);\n return response;\n}\nexports.handleSelectChallengeWithPassword = handleSelectChallengeWithPassword;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,OAAO,GAAG,OAAO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AClE,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC;AAC5F,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE,cAAc;AAC1C,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,eAAe,EAAE,eAAe;AACxC,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,IAAI,QAAQ,CAAC;AAC9E,IAAI,IAAI,yBAAyB,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;AAC3E,IAAI,OAAO,QAAQ,CAAC;AACpB,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
@@ -11,7 +11,9 @@ const parsers_1 = require("../../../foundation/parsers");
11
11
  const utils_2 = require("../../../utils");
12
12
  const srp_1 = require("../../../providers/cognito/utils/srp");
13
13
  const userContextData_1 = require("../../../providers/cognito/utils/userContextData");
14
- const signInHelpers_1 = require("../../../providers/cognito/utils/signInHelpers");
14
+ const setActiveSignInUsername_1 = require("../../../providers/cognito/utils/setActiveSignInUsername");
15
+ const retryOnResourceNotFoundException_1 = require("../../../providers/cognito/utils/retryOnResourceNotFoundException");
16
+ const handlePasswordVerifierChallenge_1 = require("../../../providers/cognito/utils/handlePasswordVerifierChallenge");
15
17
  /**
16
18
  * Handles the SELECT_CHALLENGE response specifically for Password SRP authentication.
17
19
  * This function combines the SELECT_CHALLENGE flow with Password SRP protocol.
@@ -56,9 +58,9 @@ async function handleSelectChallengeWithPasswordSRP(username, password, clientMe
56
58
  UserContextData: userContextData,
57
59
  });
58
60
  const activeUsername = response.ChallengeParameters?.USERNAME ?? username;
59
- (0, signInHelpers_1.setActiveSignInUsername)(activeUsername);
61
+ (0, setActiveSignInUsername_1.setActiveSignInUsername)(activeUsername);
60
62
  if (response.ChallengeName === 'PASSWORD_VERIFIER') {
61
- return (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handlePasswordVerifierChallenge, [
63
+ return (0, retryOnResourceNotFoundException_1.retryOnResourceNotFoundException)(handlePasswordVerifierChallenge_1.handlePasswordVerifierChallenge, [
62
64
  password,
63
65
  response.ChallengeParameters,
64
66
  clientMetadata,
@@ -1 +1 @@
1
- {"version":3,"file":"handleSelectChallengeWithPasswordSRP.js","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.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.handleSelectChallengeWithPasswordSRP = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst srp_1 = require(\"../../../providers/cognito/utils/srp\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst signInHelpers_1 = require(\"../../../providers/cognito/utils/signInHelpers\");\n/**\n * Handles the SELECT_CHALLENGE response specifically for Password SRP authentication.\n * This function combines the SELECT_CHALLENGE flow with Password SRP protocol.\n *\n * @param {string} username - The username for authentication\n * @param {string} password - The user's password\n * @param {ClientMetadata} [clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} config - Cognito User Pool configuration\n * @param {string} session - The current authentication session token\n * @param {AuthTokenOrchestrator} tokenOrchestrator - Token orchestrator for managing auth tokens\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nasync function handleSelectChallengeWithPasswordSRP(username, password, clientMetadata, config, session, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await (0, srp_1.getAuthenticationHelper)(userPoolName);\n const authParameters = {\n ANSWER: 'PASSWORD_SRP',\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n const userContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: authParameters,\n ClientId: userPoolClientId,\n ClientMetadata: clientMetadata,\n Session: session,\n UserContextData: userContextData,\n });\n const activeUsername = response.ChallengeParameters?.USERNAME ?? username;\n (0, signInHelpers_1.setActiveSignInUsername)(activeUsername);\n if (response.ChallengeName === 'PASSWORD_VERIFIER') {\n return (0, signInHelpers_1.retryOnResourceNotFoundException)(signInHelpers_1.handlePasswordVerifierChallenge, [\n password,\n response.ChallengeParameters,\n clientMetadata,\n response.Session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return response;\n}\nexports.handleSelectChallengeWithPasswordSRP = handleSelectChallengeWithPasswordSRP;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oCAAoC,GAAG,KAAK,CAAC,CAAC;AACtD,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,yBAAyB,GAAG,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../../../../src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.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.handleSelectChallengeWithPasswordSRP = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst srp_1 = require(\"../../../providers/cognito/utils/srp\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst setActiveSignInUsername_1 = require(\"../../../providers/cognito/utils/setActiveSignInUsername\");\nconst retryOnResourceNotFoundException_1 = require(\"../../../providers/cognito/utils/retryOnResourceNotFoundException\");\nconst handlePasswordVerifierChallenge_1 = require(\"../../../providers/cognito/utils/handlePasswordVerifierChallenge\");\n/**\n * Handles the SELECT_CHALLENGE response specifically for Password SRP authentication.\n * This function combines the SELECT_CHALLENGE flow with Password SRP protocol.\n *\n * @param {string} username - The username for authentication\n * @param {string} password - The user's password\n * @param {ClientMetadata} [clientMetadata] - Optional metadata to be sent with auth requests\n * @param {CognitoUserPoolConfig} config - Cognito User Pool configuration\n * @param {string} session - The current authentication session token\n * @param {AuthTokenOrchestrator} tokenOrchestrator - Token orchestrator for managing auth tokens\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nasync function handleSelectChallengeWithPasswordSRP(username, password, clientMetadata, config, session, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await (0, srp_1.getAuthenticationHelper)(userPoolName);\n const authParameters = {\n ANSWER: 'PASSWORD_SRP',\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n const userContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = (0, cognitoIdentityProvider_1.createRespondToAuthChallengeClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: authParameters,\n ClientId: userPoolClientId,\n ClientMetadata: clientMetadata,\n Session: session,\n UserContextData: userContextData,\n });\n const activeUsername = response.ChallengeParameters?.USERNAME ?? username;\n (0, setActiveSignInUsername_1.setActiveSignInUsername)(activeUsername);\n if (response.ChallengeName === 'PASSWORD_VERIFIER') {\n return (0, retryOnResourceNotFoundException_1.retryOnResourceNotFoundException)(handlePasswordVerifierChallenge_1.handlePasswordVerifierChallenge, [\n password,\n response.ChallengeParameters,\n clientMetadata,\n response.Session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return response;\n}\nexports.handleSelectChallengeWithPasswordSRP = handleSelectChallengeWithPasswordSRP;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oCAAoC,GAAG,KAAK,CAAC,CAAC;AACtD,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,yBAAyB,GAAG,OAAO,CAAC,sEAAsE,CAAC,CAAC;AAClH,MAAM,WAAW,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACpE,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,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const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
15
15
  const validation_1 = require("../../../errors/types/validation");
16
- const signInHelpers_1 = require("../../../providers/cognito/utils/signInHelpers");
16
+ const setActiveSignInUsername_1 = require("../../../providers/cognito/utils/setActiveSignInUsername");
17
17
  /**
18
18
  * Handles user authentication flow with configurable challenge preferences.
19
19
  * Supports AuthFactorType challenges through the USER_AUTH flow.
@@ -77,7 +77,7 @@ async function handleUserAuthFlow({ username, clientMetadata, config, tokenOrche
77
77
  // Set the active username immediately after successful authentication attempt
78
78
  // If a user starts a new sign-in while another sign-in is incomplete,
79
79
  // this ensures we're tracking the correct user for subsequent auth challenges.
80
- (0, signInHelpers_1.setActiveSignInUsername)(username);
80
+ (0, setActiveSignInUsername_1.setActiveSignInUsername)(username);
81
81
  return response;
82
82
  }
83
83
  exports.handleUserAuthFlow = handleUserAuthFlow;
@@ -1 +1 @@
1
- {"version":3,"file":"handleUserAuthFlow.js","sources":["../../../../../src/client/flows/userAuth/handleUserAuthFlow.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.handleUserAuthFlow = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst handlePasswordSRP_1 = require(\"../shared/handlePasswordSRP\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst signInHelpers_1 = require(\"../../../providers/cognito/utils/signInHelpers\");\n/**\n * Handles user authentication flow with configurable challenge preferences.\n * Supports AuthFactorType challenges through the USER_AUTH flow.\n *\n * @param {HandleUserAuthFlowInput} params - Authentication flow parameters\n * @param {string} params.username - The username for authentication\n * @param {Record<string, string>} [params.clientMetadata] - Optional metadata to pass to authentication service\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Manages authentication tokens and device tracking\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred authentication method\n * @param {string} [params.password] - Required when preferredChallenge is 'PASSWORD' or 'PASSWORD_SRP'\n *\n * @returns {Promise<InitiateAuthCommandOutput>} The authentication response from Cognito\n */\nasync function handleUserAuthFlow({ username, clientMetadata, config, tokenOrchestrator, preferredChallenge, password, session, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const UserContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const authParameters = { USERNAME: username };\n if (preferredChallenge) {\n if (preferredChallenge === 'PASSWORD_SRP') {\n (0, assertValidationError_1.assertValidationError)(!!password, validation_1.AuthValidationErrorCode.EmptySignInPassword);\n return (0, handlePasswordSRP_1.handlePasswordSRP)({\n username,\n password,\n clientMetadata,\n config,\n tokenOrchestrator,\n authFlow: 'USER_AUTH',\n preferredChallenge,\n });\n }\n if (preferredChallenge === 'PASSWORD') {\n (0, assertValidationError_1.assertValidationError)(!!password, validation_1.AuthValidationErrorCode.EmptySignInPassword);\n authParameters.PASSWORD = password;\n }\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const jsonReq = {\n AuthFlow: 'USER_AUTH',\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n if (session) {\n jsonReq.Session = session;\n }\n const initiateAuth = (0, cognitoIdentityProvider_1.createInitiateAuthClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await initiateAuth({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignIn),\n }, jsonReq);\n // Set the active username immediately after successful authentication attempt\n // If a user starts a new sign-in while another sign-in is incomplete,\n // this ensures we're tracking the correct user for subsequent auth challenges.\n (0, signInHelpers_1.setActiveSignInUsername)(username);\n return response;\n}\nexports.handleUserAuthFlow = handleUserAuthFlow;\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,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,iBAAiB,GAAG,OAAO,CAAC,kDAAkD,CAAC,CAAC;AACtF,MAAM,yBAAyB,GAAG,OAAO,CAAC,sEAAsE,CAAC,CAAC;AAClH,MAAM,WAAW,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACpE,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACnE,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,eAAe,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE;AACnI,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,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Q,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAClC,KAAK;AACL,IAAI,MAAM,YAAY,GAAG,IAAI,yBAAyB,CAAC,wBAAwB,EAAE;AACjF,QAAQ,gBAAgB,EAAE,IAAI,WAAW,CAAC,qCAAqC,EAAE;AACjF,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC;AACxC,QAAQ,MAAM,EAAE,IAAI,SAAS,CAAC,uBAAuB,EAAE,UAAU,CAAC;AAClE,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;AACrF,KAAK,EAAE,OAAO,CAAC,CAAC;AAChB;AACA;AACA;AACA,IAAI,IAAI,eAAe,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;AAC3D,IAAI,OAAO,QAAQ,CAAC;AACpB,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
1
+ {"version":3,"file":"handleUserAuthFlow.js","sources":["../../../../../src/client/flows/userAuth/handleUserAuthFlow.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.handleUserAuthFlow = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst userContextData_1 = require(\"../../../providers/cognito/utils/userContextData\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../../../providers/cognito/factories\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst handlePasswordSRP_1 = require(\"../shared/handlePasswordSRP\");\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst setActiveSignInUsername_1 = require(\"../../../providers/cognito/utils/setActiveSignInUsername\");\n/**\n * Handles user authentication flow with configurable challenge preferences.\n * Supports AuthFactorType challenges through the USER_AUTH flow.\n *\n * @param {HandleUserAuthFlowInput} params - Authentication flow parameters\n * @param {string} params.username - The username for authentication\n * @param {Record<string, string>} [params.clientMetadata] - Optional metadata to pass to authentication service\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {AuthTokenOrchestrator} params.tokenOrchestrator - Manages authentication tokens and device tracking\n * @param {AuthFactorType} [params.preferredChallenge] - Optional preferred authentication method\n * @param {string} [params.password] - Required when preferredChallenge is 'PASSWORD' or 'PASSWORD_SRP'\n *\n * @returns {Promise<InitiateAuthCommandOutput>} The authentication response from Cognito\n */\nasync function handleUserAuthFlow({ username, clientMetadata, config, tokenOrchestrator, preferredChallenge, password, session, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const UserContextData = (0, userContextData_1.getUserContextData)({\n username,\n userPoolId,\n userPoolClientId,\n });\n const authParameters = { USERNAME: username };\n if (preferredChallenge) {\n if (preferredChallenge === 'PASSWORD_SRP') {\n (0, assertValidationError_1.assertValidationError)(!!password, validation_1.AuthValidationErrorCode.EmptySignInPassword);\n return (0, handlePasswordSRP_1.handlePasswordSRP)({\n username,\n password,\n clientMetadata,\n config,\n tokenOrchestrator,\n authFlow: 'USER_AUTH',\n preferredChallenge,\n });\n }\n if (preferredChallenge === 'PASSWORD') {\n (0, assertValidationError_1.assertValidationError)(!!password, validation_1.AuthValidationErrorCode.EmptySignInPassword);\n authParameters.PASSWORD = password;\n }\n authParameters.PREFERRED_CHALLENGE = preferredChallenge;\n }\n const jsonReq = {\n AuthFlow: 'USER_AUTH',\n AuthParameters: authParameters,\n ClientMetadata: clientMetadata,\n ClientId: userPoolClientId,\n UserContextData,\n };\n if (session) {\n jsonReq.Session = session;\n }\n const initiateAuth = (0, cognitoIdentityProvider_1.createInitiateAuthClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await initiateAuth({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.SignIn),\n }, jsonReq);\n // Set the active username immediately after successful authentication attempt\n // If a user starts a new sign-in while another sign-in is incomplete,\n // this ensures we're tracking the correct user for subsequent auth challenges.\n (0, setActiveSignInUsername_1.setActiveSignInUsername)(username);\n return response;\n}\nexports.handleUserAuthFlow = handleUserAuthFlow;\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,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,iBAAiB,GAAG,OAAO,CAAC,kDAAkD,CAAC,CAAC;AACtF,MAAM,yBAAyB,GAAG,OAAO,CAAC,sEAAsE,CAAC,CAAC;AAClH,MAAM,WAAW,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACpE,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACnE,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,yBAAyB,GAAG,OAAO,CAAC,0DAA0D,CAAC,CAAC;AACtG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,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cAAc,EAAE,cAAc;AACtC,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,eAAe;AACvB,KAAK,CAAC;AACN,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAClC,KAAK;AACL,IAAI,MAAM,YAAY,GAAG,IAAI,yBAAyB,CAAC,wBAAwB,EAAE;AACjF,QAAQ,gBAAgB,EAAE,IAAI,WAAW,CAAC,qCAAqC,EAAE;AACjF,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC;AACxC,QAAQ,MAAM,EAAE,IAAI,SAAS,CAAC,uBAAuB,EAAE,UAAU,CAAC;AAClE,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;AACrF,KAAK,EAAE,OAAO,CAAC,CAAC;AAChB;AACA;AACA;AACA,IAAI,IAAI,yBAAyB,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;AACrE,IAAI,OAAO,QAAQ,CAAC;AACpB,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -12,12 +12,12 @@ const parsers_1 = require("../../../foundation/parsers");
12
12
  const factories_1 = require("../../../providers/cognito/factories");
13
13
  const cacheTokens_1 = require("../../../providers/cognito/tokenProvider/cacheTokens");
14
14
  const dispatchSignedInHubEvent_1 = require("../../../providers/cognito/utils/dispatchSignedInHubEvent");
15
- const signInHelpers_1 = require("../../../providers/cognito/utils/signInHelpers");
16
15
  const store_1 = require("../../../client/utils/store");
17
16
  const utils_2 = require("../../../utils");
18
17
  const passkey_1 = require("../../utils/passkey");
19
18
  const errors_1 = require("../../utils/passkey/errors");
20
19
  const AuthError_1 = require("../../../errors/AuthError");
20
+ const getNewDeviceMetadata_1 = require("../../../providers/cognito/utils/getNewDeviceMetadata");
21
21
  async function handleWebAuthnSignInResult(challengeParameters) {
22
22
  const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;
23
23
  (0, utils_1.assertTokenProviderConfig)(authConfig);
@@ -58,7 +58,7 @@ async function handleWebAuthnSignInResult(challengeParameters) {
58
58
  await (0, cacheTokens_1.cacheCognitoTokens)({
59
59
  ...authenticationResult,
60
60
  username,
61
- NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({
61
+ NewDeviceMetadata: await (0, getNewDeviceMetadata_1.getNewDeviceMetadata)({
62
62
  userPoolId: authConfig.userPoolId,
63
63
  userPoolEndpoint: authConfig.userPoolEndpoint,
64
64
  newDeviceMetadata: authenticationResult.NewDeviceMetadata,
@@ -79,10 +79,10 @@ async function handleWebAuthnSignInResult(challengeParameters) {
79
79
  message: 'Sequential WEB_AUTHN challenges returned from underlying service cannot be handled.',
80
80
  });
81
81
  }
82
- return (0, signInHelpers_1.getSignInResult)({
82
+ return {
83
83
  challengeName: nextChallengeName,
84
84
  challengeParameters: nextChallengeParameters,
85
- });
85
+ };
86
86
  }
87
87
  exports.handleWebAuthnSignInResult = handleWebAuthnSignInResult;
88
88
  //# sourceMappingURL=handleWebAuthnSignInResult.js.map
@@ -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 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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C,YAAY,QAAQ;AACpB,YAAY,iBAAiB,EAAE,MAAM,IAAI,eAAe,CAAC,oBAAoB,EAAE;AAC/E,gBAAgB,UAAU,EAAE,UAAU,CAAC,UAAU;AACjD,gBAAgB,gBAAgB,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;;"}
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 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\");\nconst getNewDeviceMetadata_1 = require(\"../../../providers/cognito/utils/getNewDeviceMetadata\");\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, getNewDeviceMetadata_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 {\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,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A0B,GAAG,0BAA0B;;"}
@@ -3,6 +3,4 @@
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.AUTH_KEY_PREFIX = void 0;
7
- exports.AUTH_KEY_PREFIX = 'CognitoIdentityServiceProvider';
8
- //# sourceMappingURL=constants.js.map
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../../src/client/flows/userAuth/types.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 });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -16,6 +16,7 @@ const AuthErrorStrings_1 = require("../../../common/AuthErrorStrings");
16
16
  const cacheTokens_1 = require("../tokenProvider/cacheTokens");
17
17
  const tokenProvider_1 = require("../tokenProvider");
18
18
  const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
19
+ const getNewDeviceMetadata_1 = require("../utils/getNewDeviceMetadata");
19
20
  /**
20
21
  * Continues or completes the sign in process when required by the initial call to `signIn`.
21
22
  *
@@ -66,7 +67,7 @@ async function confirmSignIn(input) {
66
67
  await (0, cacheTokens_1.cacheCognitoTokens)({
67
68
  username,
68
69
  ...AuthenticationResult,
69
- NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({
70
+ NewDeviceMetadata: await (0, getNewDeviceMetadata_1.getNewDeviceMetadata)({
70
71
  userPoolId: authConfig.userPoolId,
71
72
  userPoolEndpoint: authConfig.userPoolEndpoint,
72
73
  newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,
@@ -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 and session has expired.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the session has not expired.',\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)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.confirmSignIn = confirmSignIn;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EA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AAE;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,OAAO,CAAC,sBAAsB,GAAG,CAAC;AAClD,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,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,aAAa,GAAG,aAAa;;"}
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\");\nconst getNewDeviceMetadata_1 = require(\"../utils/getNewDeviceMetadata\");\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 and session has expired.\n\t\t\t`,\n recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' +\n 'and that the session has not expired.',\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, getNewDeviceMetadata_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)(error.name);\n if (result)\n return result;\n throw error;\n }\n}\nexports.confirmSignIn = confirmSignIn;\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,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AAoB,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,OAAO,CAAC,sBAAsB,GAAG,CAAC;AAClD,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,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,aAAa,GAAG,aAAa;;"}
@@ -14,6 +14,8 @@ 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");
17
+ const retryOnResourceNotFoundException_1 = require("../utils/retryOnResourceNotFoundException");
18
+ const getNewDeviceMetadata_1 = require("../utils/getNewDeviceMetadata");
17
19
  /**
18
20
  * Signs a user in using a custom authentication flow without password
19
21
  *
@@ -36,7 +38,7 @@ async function signInWithCustomAuth(input) {
36
38
  (0, assertValidationError_1.assertValidationError)(!!username, validation_1.AuthValidationErrorCode.EmptySignInUsername);
37
39
  (0, assertValidationError_1.assertValidationError)(!password, validation_1.AuthValidationErrorCode.CustomAuthSignInPassword);
38
40
  try {
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);
41
+ const { ChallengeName: retriedChallengeName, ChallengeParameters: retiredChallengeParameters, AuthenticationResult, Session, } = await (0, retryOnResourceNotFoundException_1.retryOnResourceNotFoundException)(signInHelpers_1.handleCustomAuthFlowWithoutSRP, [username, metadata, authConfig, tokenProvider_1.tokenOrchestrator], username, tokenProvider_1.tokenOrchestrator);
40
42
  const activeUsername = (0, signInHelpers_1.getActiveSignInUsername)(username);
41
43
  // sets up local state used during the sign-in process
42
44
  (0, signInStore_1.setActiveSignInState)({
@@ -49,7 +51,7 @@ async function signInWithCustomAuth(input) {
49
51
  await (0, cacheTokens_1.cacheCognitoTokens)({
50
52
  username: activeUsername,
51
53
  ...AuthenticationResult,
52
- NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({
54
+ NewDeviceMetadata: await (0, getNewDeviceMetadata_1.getNewDeviceMetadata)({
53
55
  userPoolId: authConfig.userPoolId,
54
56
  userPoolEndpoint: authConfig.userPoolEndpoint,
55
57
  newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,
@@ -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 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;A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,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,oBAAoB,GAAG,oBAAoB;;"}
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\");\nconst retryOnResourceNotFoundException_1 = require(\"../utils/retryOnResourceNotFoundException\");\nconst getNewDeviceMetadata_1 = require(\"../utils/getNewDeviceMetadata\");\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, retryOnResourceNotFoundException_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, getNewDeviceMetadata_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,MAAM,kCAAkC,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AAChG,MAAM,sBAAsB,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB,CAAC,KAAK,EA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AQ,IAAI,MAAM;AAClB,YAAY,OAAO,MAAM,CAAC;AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
@@ -14,6 +14,7 @@ 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");
17
+ const getNewDeviceMetadata_1 = require("../utils/getNewDeviceMetadata");
17
18
  /**
18
19
  * Signs a user in using a custom authentication flow with SRP
19
20
  *
@@ -50,7 +51,7 @@ async function signInWithCustomSRPAuth(input) {
50
51
  await (0, cacheTokens_1.cacheCognitoTokens)({
51
52
  username: activeUsername,
52
53
  ...AuthenticationResult,
53
- NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({
54
+ NewDeviceMetadata: await (0, getNewDeviceMetadata_1.getNewDeviceMetadata)({
54
55
  userPoolId: authConfig.userPoolId,
55
56
  userPoolEndpoint: authConfig.userPoolEndpoint,
56
57
  newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,
@@ -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 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,uBAA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AAC1B,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB;;"}
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\");\nconst getNewDeviceMetadata_1 = require(\"../utils/getNewDeviceMetadata\");\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, getNewDeviceMetadata_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,OAA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AAG,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;;"}
@@ -14,6 +14,7 @@ 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");
17
+ const getNewDeviceMetadata_1 = require("../utils/getNewDeviceMetadata");
17
18
  const autoSignIn_1 = require("./autoSignIn");
18
19
  /**
19
20
  * Signs a user in
@@ -51,7 +52,7 @@ async function signInWithSRP(input) {
51
52
  await (0, cacheTokens_1.cacheCognitoTokens)({
52
53
  username: activeUsername,
53
54
  ...AuthenticationResult,
54
- NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({
55
+ NewDeviceMetadata: await (0, getNewDeviceMetadata_1.getNewDeviceMetadata)({
55
56
  userPoolId: authConfig.userPoolId,
56
57
  userPoolEndpoint: authConfig.userPoolEndpoint,
57
58
  newDeviceMetadata: AuthenticationResult.NewDeviceMetadata,
@@ -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 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,CAA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aAAa,CAAC,sBAAsB,GAAG,CAAC;AACxD,YAAY,MAAM,CAAC,CAAC,EAAE,0BAA0B,CAAC,wBAAwB,GAAG,CAAC;AAC7E,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,eAAe,GAAG,CAAC;AAChD,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,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,aAAa,GAAG,aAAa;;"}
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 getNewDeviceMetadata_1 = require(\"../utils/getNewDeviceMetadata\");\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, getNewDeviceMetadata_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,O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Aa,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,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,aAAa,GAAG,aAAa;;"}
@@ -16,6 +16,7 @@ const cacheTokens_1 = require("../tokenProvider/cacheTokens");
16
16
  const dispatchSignedInHubEvent_1 = require("../utils/dispatchSignedInHubEvent");
17
17
  const tokenProvider_1 = require("../tokenProvider");
18
18
  const handleUserAuthFlow_1 = require("../../../client/flows/userAuth/handleUserAuthFlow");
19
+ const getNewDeviceMetadata_1 = require("../utils/getNewDeviceMetadata");
19
20
  const autoSignIn_1 = require("./autoSignIn");
20
21
  /**
21
22
  * Signs a user in through a registered email or phone number without a password by by receiving and entering an OTP.
@@ -65,7 +66,7 @@ async function signInWithUserAuth(input) {
65
66
  await (0, cacheTokens_1.cacheCognitoTokens)({
66
67
  username: activeUsername,
67
68
  ...response.AuthenticationResult,
68
- NewDeviceMetadata: await (0, signInHelpers_1.getNewDeviceMetadata)({
69
+ NewDeviceMetadata: await (0, getNewDeviceMetadata_1.getNewDeviceMetadata)({
69
70
  userPoolId: authConfig.userPoolId,
70
71
  userPoolEndpoint: authConfig.userPoolEndpoint,
71
72
  newDeviceMetadata: response.AuthenticationResult.NewDeviceMetadata,