@aws-amplify/auth 6.12.5-local-stack.00864ae.0 → 6.12.5-unstable.5c85092.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 (47) hide show
  1. package/dist/cjs/providers/cognito/credentialsProvider/IdentityIdProvider.js +1 -7
  2. package/dist/cjs/providers/cognito/credentialsProvider/IdentityIdProvider.js.map +1 -1
  3. package/dist/cjs/providers/cognito/credentialsProvider/credentialsProvider.js +2 -13
  4. package/dist/cjs/providers/cognito/credentialsProvider/credentialsProvider.js.map +1 -1
  5. package/dist/cjs/providers/cognito/factories/index.js +1 -3
  6. package/dist/cjs/providers/cognito/factories/index.js.map +1 -1
  7. package/dist/esm/client/flows/shared/handlePasswordSRP.mjs +0 -1
  8. package/dist/esm/client/flows/shared/handlePasswordSRP.mjs.map +1 -1
  9. package/dist/esm/client/flows/userAuth/handleSelectChallenge.mjs +0 -1
  10. package/dist/esm/client/flows/userAuth/handleSelectChallenge.mjs.map +1 -1
  11. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs +0 -1
  12. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs.map +1 -1
  13. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs +0 -1
  14. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs.map +1 -1
  15. package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs +0 -1
  16. package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs.map +1 -1
  17. package/dist/esm/foundation/apis/deleteWebAuthnCredential.mjs +0 -1
  18. package/dist/esm/foundation/apis/deleteWebAuthnCredential.mjs.map +1 -1
  19. package/dist/esm/foundation/apis/listWebAuthnCredentials.mjs +0 -1
  20. package/dist/esm/foundation/apis/listWebAuthnCredentials.mjs.map +1 -1
  21. package/dist/esm/providers/cognito/apis/internal/fetchUserAttributes.mjs +0 -1
  22. package/dist/esm/providers/cognito/apis/internal/fetchUserAttributes.mjs.map +1 -1
  23. package/dist/esm/providers/cognito/credentialsProvider/IdentityIdProvider.mjs +1 -9
  24. package/dist/esm/providers/cognito/credentialsProvider/IdentityIdProvider.mjs.map +1 -1
  25. package/dist/esm/providers/cognito/credentialsProvider/credentialsProvider.mjs +1 -13
  26. package/dist/esm/providers/cognito/credentialsProvider/credentialsProvider.mjs.map +1 -1
  27. package/dist/esm/providers/cognito/factories/index.d.ts +0 -1
  28. package/dist/esm/providers/cognito/factories/index.mjs +0 -1
  29. package/dist/esm/providers/cognito/factories/index.mjs.map +1 -1
  30. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs +0 -1
  31. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs.map +1 -1
  32. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs +0 -1
  33. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs.map +1 -1
  34. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs +0 -1
  35. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs.map +1 -1
  36. package/dist/esm/providers/cognito/utils/refreshAuthTokens.mjs +0 -1
  37. package/dist/esm/providers/cognito/utils/refreshAuthTokens.mjs.map +1 -1
  38. package/package.json +5 -5
  39. package/src/providers/cognito/credentialsProvider/IdentityIdProvider.ts +1 -8
  40. package/src/providers/cognito/credentialsProvider/credentialsProvider.ts +1 -14
  41. package/src/providers/cognito/factories/index.ts +0 -1
  42. package/dist/cjs/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.js +0 -16
  43. package/dist/cjs/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.js.map +0 -1
  44. package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.d.ts +0 -6
  45. package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.mjs +0 -14
  46. package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.mjs.map +0 -1
  47. package/src/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.ts +0 -15
@@ -8,7 +8,6 @@ const core_1 = require("@aws-amplify/core");
8
8
  const AuthError_1 = require("../../../errors/AuthError");
9
9
  const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
10
10
  const parsers_1 = require("../../../foundation/parsers");
11
- const factories_1 = require("../factories");
12
11
  const utils_1 = require("./utils");
13
12
  /**
14
13
  * Provides a Cognito identityId
@@ -40,17 +39,12 @@ async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore,
40
39
  async function generateIdentityId(logins, authConfig) {
41
40
  const identityPoolId = authConfig?.identityPoolId;
42
41
  const region = (0, parsers_1.getRegionFromIdentityPoolId)(identityPoolId);
43
- const getId = (0, core_1.createGetIdClient)({
44
- endpointResolver: (0, factories_1.createCognitoIdentityPoolEndpointResolver)({
45
- endpointOverride: authConfig.identityPoolEndpoint,
46
- }),
47
- });
48
42
  // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API
49
43
  let idResult;
50
44
  // for a first-time user, this will return a brand new identity
51
45
  // for a returning user, this will retrieve the previous identity assocaited with the logins
52
46
  try {
53
- idResult = (await getId({
47
+ idResult = (await (0, core_1.getId)({
54
48
  region,
55
49
  }, {
56
50
  IdentityPoolId: identityPoolId,
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityIdProvider.js","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdProvider.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.cognitoIdentityIdProvider = cognitoIdentityIdProvider;\nconst core_1 = require(\"@aws-amplify/core\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst factories_1 = require(\"../factories\");\nconst utils_1 = require(\"./utils\");\n/**\n * Provides a Cognito identityId\n *\n * @param tokens - The AuthTokens received after SignIn\n * @returns string\n * @throws configuration exceptions: `InvalidIdentityPoolIdException`\n * - Auth errors that may arise from misconfiguration.\n * @throws service exceptions: {@link GetIdException }\n */\nasync function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore, }) {\n identityIdStore.setAuthConfig({ Cognito: authConfig });\n // will return null only if there is no identityId cached or if there is an error retrieving it\n const identityId = await identityIdStore.loadIdentityId();\n if (identityId) {\n return identityId.id;\n }\n const logins = tokens?.idToken\n ? (0, utils_1.formLoginsMap)(tokens.idToken.toString())\n : {};\n const generatedIdentityId = await generateIdentityId(logins, authConfig);\n // Store generated identityId\n identityIdStore.storeIdentityId({\n id: generatedIdentityId,\n type: tokens ? 'primary' : 'guest',\n });\n return generatedIdentityId;\n}\nasync function generateIdentityId(logins, authConfig) {\n const identityPoolId = authConfig?.identityPoolId;\n const region = (0, parsers_1.getRegionFromIdentityPoolId)(identityPoolId);\n const getId = (0, core_1.createGetIdClient)({\n endpointResolver: (0, factories_1.createCognitoIdentityPoolEndpointResolver)({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API\n let idResult;\n // for a first-time user, this will return a brand new identity\n // for a returning user, this will retrieve the previous identity assocaited with the logins\n try {\n idResult = (await getId({\n region,\n }, {\n IdentityPoolId: identityPoolId,\n Logins: logins,\n })).IdentityId;\n }\n catch (e) {\n (0, assertServiceError_1.assertServiceError)(e);\n throw new AuthError_1.AuthError(e);\n }\n if (!idResult) {\n throw new AuthError_1.AuthError({\n name: 'GetIdResponseException',\n message: 'Received undefined response from getId operation',\n recoverySuggestion: 'Make sure to pass a valid identityPoolId in the configuration.',\n });\n }\n return idResult;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO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c,CAAC;AAC7E,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAAE;AAChD,QAAQ,gBAAgB,EAAE,IAAI,WAAW,CAAC,yCAAyC,EAAE;AACrF,YAAY,gBAAgB,EAAE,UAAU,CAAC,oBAAoB;AAC7D,SAAS,CAAC;AACV,KAAK,CAAC;AACN;AACA,IAAI,IAAI,QAAQ;AAChB;AACA;AACA,IAAI,IAAI;AACR,QAAQ,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC;AAChC,YAAY,MAAM;AAClB,SAAS,EAAE;AACX,YAAY,cAAc,EAAE,cAAc;AAC1C,YAAY,MAAM,EAAE,MAAM;AAC1B,SAAS,CAAC,EAAE,UAAU;AACtB;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,IAAI,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,CAAC;AACvD,QAAQ,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1C;AACA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC;AACxC,YAAY,IAAI,EAAE,wBAAwB;AAC1C,YAAY,OAAO,EAAE,kDAAkD;AACvE,YAAY,kBAAkB,EAAE,gEAAgE;AAChG,SAAS,CAAC;AACV;AACA,IAAI,OAAO,QAAQ;AACnB;;"}
1
+ {"version":3,"file":"IdentityIdProvider.js","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdProvider.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.cognitoIdentityIdProvider = cognitoIdentityIdProvider;\nconst core_1 = require(\"@aws-amplify/core\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_1 = require(\"./utils\");\n/**\n * Provides a Cognito identityId\n *\n * @param tokens - The AuthTokens received after SignIn\n * @returns string\n * @throws configuration exceptions: `InvalidIdentityPoolIdException`\n * - Auth errors that may arise from misconfiguration.\n * @throws service exceptions: {@link GetIdException }\n */\nasync function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore, }) {\n identityIdStore.setAuthConfig({ Cognito: authConfig });\n // will return null only if there is no identityId cached or if there is an error retrieving it\n const identityId = await identityIdStore.loadIdentityId();\n if (identityId) {\n return identityId.id;\n }\n const logins = tokens?.idToken\n ? (0, utils_1.formLoginsMap)(tokens.idToken.toString())\n : {};\n const generatedIdentityId = await generateIdentityId(logins, authConfig);\n // Store generated identityId\n identityIdStore.storeIdentityId({\n id: generatedIdentityId,\n type: tokens ? 'primary' : 'guest',\n });\n return generatedIdentityId;\n}\nasync function generateIdentityId(logins, authConfig) {\n const identityPoolId = authConfig?.identityPoolId;\n const region = (0, parsers_1.getRegionFromIdentityPoolId)(identityPoolId);\n // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API\n let idResult;\n // for a first-time user, this will return a brand new identity\n // for a returning user, this will retrieve the previous identity assocaited with the logins\n try {\n idResult = (await (0, core_1.getId)({\n region,\n }, {\n IdentityPoolId: identityPoolId,\n Logins: logins,\n })).IdentityId;\n }\n catch (e) {\n (0, assertServiceError_1.assertServiceError)(e);\n throw new AuthError_1.AuthError(e);\n }\n if (!idResult) {\n throw new AuthError_1.AuthError({\n name: 'GetIdResponseException',\n message: 'Received undefined response from getId operation',\n recoverySuggestion: 'Make sure to pass a valid identityPoolId in the configuration.',\n });\n }\n return idResult;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,yBAAyB,GAAG,yBAAyB;AAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AA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,KAAK,EAAE;AAC5C,YAAY,MAAM;AAClB,SAAS,EAAE;AACX,YAAY,cAAc,EAAE,cAAc;AAC1C,YAAY,MAAM,EAAE,MAAM;AAC1B,SAAS,CAAC,EAAE,UAAU;AACtB;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,IAAI,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,CAAC;AACvD,QAAQ,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1C;AACA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC;AACxC,YAAY,IAAI,EAAE,wBAAwB;AAC1C,YAAY,OAAO,EAAE,kDAAkD;AACvE,YAAY,kBAAkB,EAAE,gEAAgE;AAChG,SAAS,CAAC;AACV;AACA,IAAI,OAAO,QAAQ;AACnB;;"}
@@ -10,7 +10,6 @@ const AuthError_1 = require("../../../errors/AuthError");
10
10
  const assertServiceError_1 = require("../../../errors/utils/assertServiceError");
11
11
  const parsers_1 = require("../../../foundation/parsers");
12
12
  const types_1 = require("../utils/types");
13
- const factories_1 = require("../factories");
14
13
  const IdentityIdProvider_1 = require("./IdentityIdProvider");
15
14
  const utils_2 = require("./utils");
16
15
  const logger = new core_1.ConsoleLogger('CognitoCredentialsProvider');
@@ -74,18 +73,13 @@ class CognitoAWSCredentialsAndIdentityIdProvider {
74
73
  // Clear to discard if any authenticated credentials are set and start with a clean slate
75
74
  this.clearCredentials();
76
75
  const region = (0, parsers_1.getRegionFromIdentityPoolId)(authConfig.identityPoolId);
77
- const getCredentialsForIdentity = (0, core_1.createGetCredentialsForIdentityClient)({
78
- endpointResolver: (0, factories_1.createCognitoIdentityPoolEndpointResolver)({
79
- endpointOverride: authConfig.identityPoolEndpoint,
80
- }),
81
- });
82
76
  // use identityId to obtain guest credentials
83
77
  // save credentials in-memory
84
78
  // No logins params should be passed for guest creds:
85
79
  // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html
86
80
  let clientResult;
87
81
  try {
88
- clientResult = await getCredentialsForIdentity({ region }, {
82
+ clientResult = await (0, core_1.getCredentialsForIdentity)({ region }, {
89
83
  IdentityId: identityId,
90
84
  });
91
85
  }
@@ -138,14 +132,9 @@ class CognitoAWSCredentialsAndIdentityIdProvider {
138
132
  ? (0, utils_2.formLoginsMap)(authTokens.idToken.toString())
139
133
  : {};
140
134
  const region = (0, parsers_1.getRegionFromIdentityPoolId)(authConfig.identityPoolId);
141
- const getCredentialsForIdentity = (0, core_1.createGetCredentialsForIdentityClient)({
142
- endpointResolver: (0, factories_1.createCognitoIdentityPoolEndpointResolver)({
143
- endpointOverride: authConfig.identityPoolEndpoint,
144
- }),
145
- });
146
135
  let clientResult;
147
136
  try {
148
- clientResult = await getCredentialsForIdentity({ region }, {
137
+ clientResult = await (0, core_1.getCredentialsForIdentity)({ region }, {
149
138
  IdentityId: identityId,
150
139
  Logins: logins,
151
140
  });
@@ -1 +1 @@
1
- {"version":3,"file":"credentialsProvider.js","sources":["../../../../../src/providers/cognito/credentialsProvider/credentialsProvider.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.CognitoAWSCredentialsAndIdentityIdProvider = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst types_1 = require(\"../utils/types\");\nconst factories_1 = require(\"../factories\");\nconst IdentityIdProvider_1 = require(\"./IdentityIdProvider\");\nconst utils_2 = require(\"./utils\");\nconst logger = new core_1.ConsoleLogger('CognitoCredentialsProvider');\nconst CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nclass CognitoAWSCredentialsAndIdentityIdProvider {\n constructor(identityIdStore) {\n this._nextCredentialsRefresh = 0;\n this._identityIdStore = identityIdStore;\n }\n async clearCredentialsAndIdentityId() {\n logger.debug('Clearing out credentials and identityId');\n this._credentialsAndIdentityId = undefined;\n await this._identityIdStore.clearIdentityId();\n }\n async clearCredentials() {\n logger.debug('Clearing out in-memory credentials');\n this._credentialsAndIdentityId = undefined;\n }\n async getCredentialsAndIdentityId(getCredentialsOptions) {\n const isAuthenticated = getCredentialsOptions.authenticated;\n const { tokens } = getCredentialsOptions;\n const { authConfig } = getCredentialsOptions;\n try {\n (0, utils_1.assertIdentityPoolIdConfig)(authConfig?.Cognito);\n }\n catch {\n // No identity pool configured, skipping\n return;\n }\n if (!isAuthenticated && !authConfig.Cognito.allowGuestAccess) {\n // TODO(V6): return partial result like Native platforms\n return;\n }\n const { forceRefresh } = getCredentialsOptions;\n const tokenHasChanged = this.hasTokenChanged(tokens);\n const identityId = await (0, IdentityIdProvider_1.cognitoIdentityIdProvider)({\n tokens,\n authConfig: authConfig.Cognito,\n identityIdStore: this._identityIdStore,\n });\n // Clear cached credentials when forceRefresh is true OR the cache token has changed\n if (forceRefresh || tokenHasChanged) {\n this.clearCredentials();\n }\n if (!isAuthenticated) {\n return this.getGuestCredentials(identityId, authConfig.Cognito);\n }\n else {\n (0, types_1.assertIdTokenInAuthTokens)(tokens);\n return this.credsForOIDCTokens(authConfig.Cognito, tokens, identityId);\n }\n }\n async getGuestCredentials(identityId, authConfig) {\n // Return existing in-memory cached credentials only if it exists, is not past it's lifetime and is unauthenticated credentials\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === false) {\n logger.info('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any authenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const region = (0, parsers_1.getRegionFromIdentityPoolId)(authConfig.identityPoolId);\n const getCredentialsForIdentity = (0, core_1.createGetCredentialsForIdentityClient)({\n endpointResolver: (0, factories_1.createCognitoIdentityPoolEndpointResolver)({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // use identityId to obtain guest credentials\n // save credentials in-memory\n // No logins params should be passed for guest creds:\n // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n });\n }\n catch (e) {\n (0, assertServiceError_1.assertServiceError)(e);\n throw new AuthError_1.AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'guest',\n });\n }\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: false,\n };\n return res;\n }\n else {\n throw new AuthError_1.AuthError({\n name: 'CredentialsNotFoundException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n async credsForOIDCTokens(authConfig, authTokens, identityId) {\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === true) {\n logger.debug('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any unauthenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const logins = authTokens.idToken\n ? (0, utils_2.formLoginsMap)(authTokens.idToken.toString())\n : {};\n const region = (0, parsers_1.getRegionFromIdentityPoolId)(authConfig.identityPoolId);\n const getCredentialsForIdentity = (0, core_1.createGetCredentialsForIdentityClient)({\n endpointResolver: (0, factories_1.createCognitoIdentityPoolEndpointResolver)({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n Logins: logins,\n });\n }\n catch (e) {\n (0, assertServiceError_1.assertServiceError)(e);\n throw new AuthError_1.AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n // note: the following call removes guest identityId from the persistent store (localStorage)\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'primary',\n });\n }\n // Store the credentials in-memory along with the expiration\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: true,\n associatedIdToken: authTokens.idToken?.toString(),\n };\n return res;\n }\n else {\n throw new AuthError_1.AuthError({\n name: 'CredentialsException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n isPastTTL() {\n return this._nextCredentialsRefresh === undefined\n ? true\n : this._nextCredentialsRefresh <= Date.now();\n }\n hasTokenChanged(tokens) {\n return (!!tokens &&\n !!this._credentialsAndIdentityId?.associatedIdToken &&\n tokens.idToken?.toString() !==\n this._credentialsAndIdentityId.associatedIdToken);\n }\n}\nexports.CognitoAWSCredentialsAndIdentityIdProvider = CognitoAWSCredentialsAndIdentityIdProvider;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,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,CAAC;AACtD,oBAAoB,EAAE,EAAE,YAAY,CAAC,UAAU;AAC/C,oBAAoB,IAAI,EAAE,SAAS;AACnC,iBAAiB,CAAC;AAClB;AACA;AACA,YAAY,IAAI,CAAC,yBAAyB,GAAG;AAC7C,gBAAgB,GAAG,GAAG;AACtB,gBAAgB,oBAAoB,EAAE,IAAI;AAC1C,gBAAgB,iBAAiB,EAAE,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE;AACjE,aAAa;AACb,YAAY,OAAO,GAAG;AACtB;AACA,aAAa;AACb,YAAY,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC;AAC5C,gBAAgB,IAAI,EAAE,sBAAsB;AAC5C,gBAAgB,OAAO,EAAE,CAAC,0EAA0E,CAAC;AACrG,aAAa,CAAC;AACd;AACA;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,OAAO,IAAI,CAAC,uBAAuB,KAAK;AAChD,cAAc;AACd,cAAc,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE;AACxD;AACA,IAAI,eAAe,CAAC,MAAM,EAAE;AAC5B,QAAQ,QAAQ,CAAC,CAAC,MAAM;AACxB,YAAY,CAAC,CAAC,IAAI,CAAC,yBAAyB,EAAE,iBAAiB;AAC/D,YAAY,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;AACtC,gBAAgB,IAAI,CAAC,yBAAyB,CAAC,iBAAiB;AAChE;AACA;AACA,OAAO,CAAC,0CAA0C,GAAG,0CAA0C;;"}
1
+ {"version":3,"file":"credentialsProvider.js","sources":["../../../../../src/providers/cognito/credentialsProvider/credentialsProvider.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.CognitoAWSCredentialsAndIdentityIdProvider = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst AuthError_1 = require(\"../../../errors/AuthError\");\nconst assertServiceError_1 = require(\"../../../errors/utils/assertServiceError\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst types_1 = require(\"../utils/types\");\nconst IdentityIdProvider_1 = require(\"./IdentityIdProvider\");\nconst utils_2 = require(\"./utils\");\nconst logger = new core_1.ConsoleLogger('CognitoCredentialsProvider');\nconst CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nclass CognitoAWSCredentialsAndIdentityIdProvider {\n constructor(identityIdStore) {\n this._nextCredentialsRefresh = 0;\n this._identityIdStore = identityIdStore;\n }\n async clearCredentialsAndIdentityId() {\n logger.debug('Clearing out credentials and identityId');\n this._credentialsAndIdentityId = undefined;\n await this._identityIdStore.clearIdentityId();\n }\n async clearCredentials() {\n logger.debug('Clearing out in-memory credentials');\n this._credentialsAndIdentityId = undefined;\n }\n async getCredentialsAndIdentityId(getCredentialsOptions) {\n const isAuthenticated = getCredentialsOptions.authenticated;\n const { tokens } = getCredentialsOptions;\n const { authConfig } = getCredentialsOptions;\n try {\n (0, utils_1.assertIdentityPoolIdConfig)(authConfig?.Cognito);\n }\n catch {\n // No identity pool configured, skipping\n return;\n }\n if (!isAuthenticated && !authConfig.Cognito.allowGuestAccess) {\n // TODO(V6): return partial result like Native platforms\n return;\n }\n const { forceRefresh } = getCredentialsOptions;\n const tokenHasChanged = this.hasTokenChanged(tokens);\n const identityId = await (0, IdentityIdProvider_1.cognitoIdentityIdProvider)({\n tokens,\n authConfig: authConfig.Cognito,\n identityIdStore: this._identityIdStore,\n });\n // Clear cached credentials when forceRefresh is true OR the cache token has changed\n if (forceRefresh || tokenHasChanged) {\n this.clearCredentials();\n }\n if (!isAuthenticated) {\n return this.getGuestCredentials(identityId, authConfig.Cognito);\n }\n else {\n (0, types_1.assertIdTokenInAuthTokens)(tokens);\n return this.credsForOIDCTokens(authConfig.Cognito, tokens, identityId);\n }\n }\n async getGuestCredentials(identityId, authConfig) {\n // Return existing in-memory cached credentials only if it exists, is not past it's lifetime and is unauthenticated credentials\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === false) {\n logger.info('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any authenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const region = (0, parsers_1.getRegionFromIdentityPoolId)(authConfig.identityPoolId);\n // use identityId to obtain guest credentials\n // save credentials in-memory\n // No logins params should be passed for guest creds:\n // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html\n let clientResult;\n try {\n clientResult = await (0, core_1.getCredentialsForIdentity)({ region }, {\n IdentityId: identityId,\n });\n }\n catch (e) {\n (0, assertServiceError_1.assertServiceError)(e);\n throw new AuthError_1.AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'guest',\n });\n }\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: false,\n };\n return res;\n }\n else {\n throw new AuthError_1.AuthError({\n name: 'CredentialsNotFoundException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n async credsForOIDCTokens(authConfig, authTokens, identityId) {\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === true) {\n logger.debug('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any unauthenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const logins = authTokens.idToken\n ? (0, utils_2.formLoginsMap)(authTokens.idToken.toString())\n : {};\n const region = (0, parsers_1.getRegionFromIdentityPoolId)(authConfig.identityPoolId);\n let clientResult;\n try {\n clientResult = await (0, core_1.getCredentialsForIdentity)({ region }, {\n IdentityId: identityId,\n Logins: logins,\n });\n }\n catch (e) {\n (0, assertServiceError_1.assertServiceError)(e);\n throw new AuthError_1.AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n // note: the following call removes guest identityId from the persistent store (localStorage)\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'primary',\n });\n }\n // Store the credentials in-memory along with the expiration\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: true,\n associatedIdToken: authTokens.idToken?.toString(),\n };\n return res;\n }\n else {\n throw new AuthError_1.AuthError({\n name: 'CredentialsException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n isPastTTL() {\n return this._nextCredentialsRefresh === undefined\n ? true\n : this._nextCredentialsRefresh <= Date.now();\n }\n hasTokenChanged(tokens) {\n return (!!tokens &&\n !!this._credentialsAndIdentityId?.associatedIdToken &&\n tokens.idToken?.toString() !==\n this._credentialsAndIdentityId.associatedIdToken);\n }\n}\nexports.CognitoAWSCredentialsAndIdentityIdProvider = CognitoAWSCredentialsAndIdentityIdProvider;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,K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AAC,SAAS,CAAC;AAC5C,gBAAgB,IAAI,EAAE,sBAAsB;AAC5C,gBAAgB,OAAO,EAAE,CAAC,0EAA0E,CAAC;AACrG,aAAa,CAAC;AACd;AACA;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,OAAO,IAAI,CAAC,uBAAuB,KAAK;AAChD,cAAc;AACd,cAAc,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE;AACxD;AACA,IAAI,eAAe,CAAC,MAAM,EAAE;AAC5B,QAAQ,QAAQ,CAAC,CAAC,MAAM;AACxB,YAAY,CAAC,CAAC,IAAI,CAAC,yBAAyB,EAAE,iBAAiB;AAC/D,YAAY,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;AACtC,gBAAgB,IAAI,CAAC,yBAAyB,CAAC,iBAAiB;AAChE;AACA;AACA,OAAO,CAAC,0CAA0C,GAAG,0CAA0C;;"}
@@ -1,11 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createCognitoIdentityPoolEndpointResolver = exports.createCognitoUserPoolEndpointResolver = void 0;
4
+ exports.createCognitoUserPoolEndpointResolver = void 0;
5
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
6
  // SPDX-License-Identifier: Apache-2.0
7
7
  var createCognitoUserPoolEndpointResolver_1 = require("./createCognitoUserPoolEndpointResolver");
8
8
  Object.defineProperty(exports, "createCognitoUserPoolEndpointResolver", { enumerable: true, get: function () { return createCognitoUserPoolEndpointResolver_1.createCognitoUserPoolEndpointResolver; } });
9
- var createCognitoIdentityPoolEndpointResolver_1 = require("./createCognitoIdentityPoolEndpointResolver");
10
- Object.defineProperty(exports, "createCognitoIdentityPoolEndpointResolver", { enumerable: true, get: function () { return createCognitoIdentityPoolEndpointResolver_1.createCognitoIdentityPoolEndpointResolver; } });
11
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/providers/cognito/factories/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createCognitoIdentityPoolEndpointResolver = exports.createCognitoUserPoolEndpointResolver = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar createCognitoUserPoolEndpointResolver_1 = require(\"./createCognitoUserPoolEndpointResolver\");\nObject.defineProperty(exports, \"createCognitoUserPoolEndpointResolver\", { enumerable: true, get: function () { return createCognitoUserPoolEndpointResolver_1.createCognitoUserPoolEndpointResolver; } });\nvar createCognitoIdentityPoolEndpointResolver_1 = require(\"./createCognitoIdentityPoolEndpointResolver\");\nObject.defineProperty(exports, \"createCognitoIdentityPoolEndpointResolver\", { enumerable: true, get: function () { return createCognitoIdentityPoolEndpointResolver_1.createCognitoIdentityPoolEndpointResolver; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,yCAAyC,GAAG,OAAO,CAAC,qCAAqC,GAAG,MAAM;AAC1G;AACA;AACA,IAAI,uCAAuC,GAAG,OAAO,CAAC,yCAAyC,CAAC;AAChG,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uCAAuC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uCAAuC,CAAC,qCAAqC,CAAC,EAAE,EAAE,CAAC;AACzM,IAAI,2CAA2C,GAAG,OAAO,CAAC,6CAA6C,CAAC;AACxG,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,2CAA2C,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,2CAA2C,CAAC,yCAAyC,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/providers/cognito/factories/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createCognitoUserPoolEndpointResolver = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar createCognitoUserPoolEndpointResolver_1 = require(\"./createCognitoUserPoolEndpointResolver\");\nObject.defineProperty(exports, \"createCognitoUserPoolEndpointResolver\", { enumerable: true, get: function () { return createCognitoUserPoolEndpointResolver_1.createCognitoUserPoolEndpointResolver; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qCAAqC,GAAG,MAAM;AACtD;AACA;AACA,IAAI,uCAAuC,GAAG,OAAO,CAAC,yCAAyC,CAAC;AAChG,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uCAAuC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uCAAuC,CAAC,qCAAqC,CAAC,EAAE,EAAE,CAAC;;"}
@@ -12,7 +12,6 @@ import '../../../common/AuthErrorStrings.mjs';
12
12
  import '../../../errors/types/validation.mjs';
13
13
  import '../../../providers/cognito/types/errors.mjs';
14
14
  import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
15
- import '@aws-amplify/core';
16
15
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
17
16
  import { getAuthUserAgentValue } from '../../../utils/getAuthUserAgentValue.mjs';
18
17
  import { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"handlePasswordSRP.mjs","sources":["../../../../../src/client/flows/shared/handlePasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { setActiveSignInUsername } from '../../../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 */\nexport async 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 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 = 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 = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const resp = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),\n }, jsonReq);\n const { ChallengeParameters: challengeParameters, Session: session } = resp;\n const activeUsername = challengeParameters?.USERNAME ?? username;\n setActiveSignInUsername(activeUsername);\n if (resp.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(handlePasswordVerifierChallenge, [\n password,\n challengeParameters,\n clientMetadata,\n session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return resp;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACxD,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,YAAY,CAAC;AAC5E,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClD,KAAK;AAC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Ac,EAAE,iBAAiB,CAAC;AAC7C;AACA,IAAI,OAAO,IAAI;AACf;;;;"}
1
+ {"version":3,"file":"handlePasswordSRP.mjs","sources":["../../../../../src/client/flows/shared/handlePasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordVerifierChallenge } from '../../../providers/cognito/utils/handlePasswordVerifierChallenge';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { setActiveSignInUsername } from '../../../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 */\nexport async 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 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 = 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 = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const resp = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),\n }, jsonReq);\n const { ChallengeParameters: challengeParameters, Session: session } = resp;\n const activeUsername = challengeParameters?.USERNAME ?? username;\n setActiveSignInUsername(activeUsername);\n if (resp.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(handlePasswordVerifierChallenge, [\n password,\n challengeParameters,\n clientMetadata,\n session,\n authenticationHelper,\n config,\n tokenOrchestrator,\n ], activeUsername, tokenOrchestrator);\n }\n return resp;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AAC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mBAAmB,EAAE;AACpD,QAAQ,OAAO,gCAAgC,CAAC,+BAA+B,EAAE;AACjF,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;AAC7C;AACA,IAAI,OAAO,IAAI;AACf;;;;"}
@@ -8,7 +8,6 @@ import '../../../errors/types/validation.mjs';
8
8
  import '../../../providers/cognito/types/errors.mjs';
9
9
  import { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.mjs';
10
10
  import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
11
- import '@aws-amplify/core';
12
11
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
13
12
  import { getAuthUserAgentValue } from '../../../utils/getAuthUserAgentValue.mjs';
14
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"handleSelectChallenge.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallenge.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\n/**\n * Handles the SELECT_CHALLENGE response for authentication.\n * Initiates the selected authentication challenge based on user choice.\n *\n * @param {Object} params - The parameters for handling the selected challenge\n * @param {string} params.username - The username for authentication\n * @param {string} params.session - The current authentication session token\n * @param {string} params.selectedChallenge - The challenge type selected by the user\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nexport async function initiateSelectedChallenge({ username, session, selectedChallenge, config, clientMetadata, }) {\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: config.userPoolEndpoint,\n }),\n });\n return respondToAuthChallenge({\n region: getRegionFromUserPoolId(config.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: {\n USERNAME: username,\n ANSWER: selectedChallenge,\n },\n ClientId: config.userPoolClientId,\n Session: session,\n ClientMetadata: clientMetadata,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,GAAG,EAAE;AACnH,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;AACrD,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,OAAO,sBAAsB,CAAC;AAClC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC;AAC1D,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC;AACvE,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE;AAC5B,YAAY,QAAQ,EAAE,QAAQ;AAC9B,YAAY,MAAM,EAAE,iBAAiB;AACrC,SAAS;AACT,QAAQ,QAAQ,EAAE,MAAM,CAAC,gBAAgB;AACzC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,cAAc,EAAE,cAAc;AACtC,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"handleSelectChallenge.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallenge.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\n/**\n * Handles the SELECT_CHALLENGE response for authentication.\n * Initiates the selected authentication challenge based on user choice.\n *\n * @param {Object} params - The parameters for handling the selected challenge\n * @param {string} params.username - The username for authentication\n * @param {string} params.session - The current authentication session token\n * @param {string} params.selectedChallenge - The challenge type selected by the user\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nexport async function initiateSelectedChallenge({ username, session, selectedChallenge, config, clientMetadata, }) {\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: config.userPoolEndpoint,\n }),\n });\n return respondToAuthChallenge({\n region: getRegionFromUserPoolId(config.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: {\n USERNAME: username,\n ANSWER: selectedChallenge,\n },\n ClientId: config.userPoolClientId,\n Session: session,\n ClientMetadata: clientMetadata,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,GAAG,EAAE;AACnH,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;AACrD,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,OAAO,sBAAsB,CAAC;AAClC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC;AAC1D,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC;AACvE,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE;AAC5B,YAAY,QAAQ,EAAE,QAAQ;AAC9B,YAAY,MAAM,EAAE,iBAAiB;AACrC,SAAS;AACT,QAAQ,QAAQ,EAAE,MAAM,CAAC,gBAAgB;AACzC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,cAAc,EAAE,cAAc;AACtC,KAAK,CAAC;AACN;;;;"}
@@ -8,7 +8,6 @@ import '../../../errors/types/validation.mjs';
8
8
  import '../../../providers/cognito/types/errors.mjs';
9
9
  import { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.mjs';
10
10
  import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
11
- import '@aws-amplify/core';
12
11
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
13
12
  import { getAuthUserAgentValue } from '../../../utils/getAuthUserAgentValue.mjs';
14
13
  import { getUserContextData } from '../../../providers/cognito/utils/userContextData.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"handleSelectChallengeWithPassword.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPassword.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { setActiveSignInUsername } from '../../../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 */\nexport async 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 = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(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 setActiveSignInUsername(active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C3C,IAAI,OAAO,QAAQ;AACnB;;;;"}
1
+ {"version":3,"file":"handleSelectChallengeWithPassword.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPassword.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { setActiveSignInUsername } from '../../../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 */\nexport async 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 = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(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 setActiveSignInUsername(activeUsername);\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,iCAAiC,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE;AAC7G,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,MAAM,EAAE,UAAU;AAC1B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC;AAClD,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC;AACvE,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;AACN,IAAI,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,IAAI,QAAQ;AAC7E,IAAI,uBAAuB,CAAC,cAAc,CAAC;AAC3C,IAAI,OAAO,QAAQ;AACnB;;;;"}
@@ -8,7 +8,6 @@ import '../../../errors/types/validation.mjs';
8
8
  import '../../../providers/cognito/types/errors.mjs';
9
9
  import { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.mjs';
10
10
  import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
11
- import '@aws-amplify/core';
12
11
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
13
12
  import { getAuthUserAgentValue } from '../../../utils/getAuthUserAgentValue.mjs';
14
13
  import { getAuthenticationHelper } from '../../../providers/cognito/utils/srp/getAuthenticationHelper.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"handleSelectChallengeWithPasswordSRP.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { handlePasswordVerifierChallenge } from '../../../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 */\nexport async function handleSelectChallengeWithPasswordSRP(username, password, clientMetadata, config, session, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const authParameters = {\n ANSWER: 'PASSWORD_SRP',\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n const userContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(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 setActiveSignInUsername(activeUsername);\n if (response.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(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}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AC;AACN,IAAI,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,IAAI,QAAQ;AAC7E,IAAI,uBAAuB,CAAC,cAAc,CAAC;AAC3C,IAAI,IAAI,QAAQ,CAAC,aAAa,KAAK,mBAAmB,EAAE;AACxD,QAAQ,OAAO,gCAAgC,CAAC,+BAA+B,EAAE;AACjF,YAAY,QAAQ;AACpB,YAAY,QAAQ,CAAC,mBAAmB;AACxC,YAAY,cAAc;AAC1B,YAAY,QAAQ,CAAC,OAAO;AAC5B,YAAY,oBAAoB;AAChC,YAAY,MAAM;AAClB,YAAY,iBAAiB;AAC7B,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC;AAC7C;AACA,IAAI,OAAO,QAAQ;AACnB;;;;"}
1
+ {"version":3,"file":"handleSelectChallengeWithPasswordSRP.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { getAuthenticationHelper } from '../../../providers/cognito/utils/srp';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { setActiveSignInUsername } from '../../../providers/cognito/utils/setActiveSignInUsername';\nimport { retryOnResourceNotFoundException } from '../../../providers/cognito/utils/retryOnResourceNotFoundException';\nimport { handlePasswordVerifierChallenge } from '../../../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 */\nexport async function handleSelectChallengeWithPasswordSRP(username, password, clientMetadata, config, session, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const authParameters = {\n ANSWER: 'PASSWORD_SRP',\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n };\n const userContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(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 setActiveSignInUsername(activeUsername);\n if (response.ChallengeName === 'PASSWORD_VERIFIER') {\n return retryOnResourceNotFoundException(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}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAA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,IAAI,uBAAuB,CAAC,cAAc,CAAC;AAC3C,IAAI,IAAI,QAAQ,CAAC,aAAa,KAAK,mBAAmB,EAAE;AACxD,QAAQ,OAAO,gCAAgC,CAAC,+BAA+B,EAAE;AACjF,YAAY,QAAQ;AACpB,YAAY,QAAQ,CAAC,mBAAmB;AACxC,YAAY,cAAc;AAC1B,YAAY,QAAQ,CAAC,OAAO;AAC5B,YAAY,oBAAoB;AAChC,YAAY,MAAM;AAClB,YAAY,iBAAiB;AAC7B,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC;AAC7C;AACA,IAAI,OAAO,QAAQ;AACnB;;;;"}
@@ -9,7 +9,6 @@ import '../../../common/AuthErrorStrings.mjs';
9
9
  import { AuthValidationErrorCode } from '../../../errors/types/validation.mjs';
10
10
  import '../../../providers/cognito/types/errors.mjs';
11
11
  import { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
12
- import '@aws-amplify/core';
13
12
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
14
13
  import { getAuthUserAgentValue } from '../../../utils/getAuthUserAgentValue.mjs';
15
14
  import { handlePasswordSRP } from '../shared/handlePasswordSRP.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"handleUserAuthFlow.mjs","sources":["../../../../../src/client/flows/userAuth/handleUserAuthFlow.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordSRP } from '../shared/handlePasswordSRP';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { setActiveSignInUsername } from '../../../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 */\nexport async function handleUserAuthFlow({ username, clientMetadata, config, tokenOrchestrator, preferredChallenge, password, session, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const authParameters = { USERNAME: username };\n if (preferredChallenge) {\n if (preferredChallenge === 'PASSWORD_SRP') {\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n return handlePasswordSRP({\n username,\n password,\n clientMetadata,\n config,\n tokenOrchestrator,\n authFlow: 'USER_AUTH',\n preferredChallenge,\n });\n }\n if (preferredChallenge === 'PASSWORD') {\n assertValidationError(!!password, 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 = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(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 setActiveSignInUsername(username);\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjD,IAAI,IAAI,kBAAkB,EAAE;AAC5B,QAAQ,IAAI,kBAAkB,KAAK,cAAc,EAAE;AACnD,YAAY,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAC1F,YAAY,OAAO,iBAAiB,CAAC;AACrC,gBAAgB,QAAQ;AACxB,gBAAgB,QAAQ;AACxB,gBAAgB,cAAc;AAC9B,gBAAgB,MAAM;AACtB,gBAAgB,iBAAiB;AACjC,gBAAgB,QAAQ,EAAE,WAAW;AACrC,gBAAgB,kBAAkB;AAClC,aAAa,CAAC;AACd;AACA,QAAQ,IAAI,kBAAkB,KAAK,UAAU,EAAE;AAC/C,YAAY,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAC1F,YAAY,cAAc,CAAC,QAAQ,GAAG,QAAQ;AAC9C;AACA,QAAQ,cAAc,CAAC,mBAAmB,GAAG,kBAAkB;AAC/D;AACA,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,QAAQ,EAAE,WAAW;AAC7B,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,eAAe;AACvB,KAAK;AACL,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,OAAO,CAAC,OAAO,GAAG,OAAO;AACjC;AACA,IAAI,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAClD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC;AACxC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,MAAM,CAAC;AAChE,KAAK,EAAE,OAAO,CAAC;AACf;AACA;AACA;AACA,IAAI,uBAAuB,CAAC,QAAQ,CAAC;AACrC,IAAI,OAAO,QAAQ;AACnB;;;;"}
1
+ {"version":3,"file":"handleUserAuthFlow.mjs","sources":["../../../../../src/client/flows/userAuth/handleUserAuthFlow.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { getUserContextData } from '../../../providers/cognito/utils/userContextData';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { handlePasswordSRP } from '../shared/handlePasswordSRP';\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { AuthValidationErrorCode } from '../../../errors/types/validation';\nimport { setActiveSignInUsername } from '../../../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 */\nexport async function handleUserAuthFlow({ username, clientMetadata, config, tokenOrchestrator, preferredChallenge, password, session, }) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const authParameters = { USERNAME: username };\n if (preferredChallenge) {\n if (preferredChallenge === 'PASSWORD_SRP') {\n assertValidationError(!!password, AuthValidationErrorCode.EmptySignInPassword);\n return handlePasswordSRP({\n username,\n password,\n clientMetadata,\n config,\n tokenOrchestrator,\n authFlow: 'USER_AUTH',\n preferredChallenge,\n });\n }\n if (preferredChallenge === 'PASSWORD') {\n assertValidationError(!!password, 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 = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await initiateAuth({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(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 setActiveSignInUsername(username);\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,kBAAkB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE;AAC1I,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjD,IAAI,IAAI,kBAAkB,EAAE;AAC5B,QAAQ,IAAI,kBAAkB,KAAK,cAAc,EAAE;AACnD,YAAY,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAC1F,YAAY,OAAO,iBAAiB,CAAC;AACrC,gBAAgB,QAAQ;AACxB,gBAAgB,QAAQ;AACxB,gBAAgB,cAAc;AAC9B,gBAAgB,MAAM;AACtB,gBAAgB,iBAAiB;AACjC,gBAAgB,QAAQ,EAAE,WAAW;AACrC,gBAAgB,kBAAkB;AAClC,aAAa,CAAC;AACd;AACA,QAAQ,IAAI,kBAAkB,KAAK,UAAU,EAAE;AAC/C,YAAY,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,mBAAmB,CAAC;AAC1F,YAAY,cAAc,CAAC,QAAQ,GAAG,QAAQ;AAC9C;AACA,QAAQ,cAAc,CAAC,mBAAmB,GAAG,kBAAkB;AAC/D;AACA,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,QAAQ,EAAE,WAAW;AAC7B,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,eAAe;AACvB,KAAK;AACL,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,OAAO,CAAC,OAAO,GAAG,OAAO;AACjC;AACA,IAAI,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAClD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC;AACxC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,MAAM,CAAC;AAChE,KAAK,EAAE,OAAO,CAAC;AACf;AACA;AACA;AACA,IAAI,uBAAuB,CAAC,QAAQ,CAAC;AACrC,IAAI,OAAO,QAAQ;AACnB;;;;"}
@@ -1,7 +1,6 @@
1
1
  import { assertTokenProviderConfig, AuthAction } from '@aws-amplify/core/internals/utils';
2
2
  import { assertAuthTokens } from '../../providers/cognito/utils/types.mjs';
3
3
  import { createCognitoUserPoolEndpointResolver } from '../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
4
- import '@aws-amplify/core';
5
4
  import { getRegionFromUserPoolId } from '../parsers/regionParsers.mjs';
6
5
  import { getAuthUserAgentValue } from '../../utils/getAuthUserAgentValue.mjs';
7
6
  import '@aws-amplify/core/internals/aws-client-utils/composers';
@@ -1 +1 @@
1
- {"version":3,"file":"deleteWebAuthnCredential.mjs","sources":["../../../../src/foundation/apis/deleteWebAuthnCredential.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../../providers/cognito/utils/types';\nimport { createCognitoUserPoolEndpointResolver } from '../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../parsers';\nimport { getAuthUserAgentValue } from '../../utils';\nimport { createDeleteWebAuthnCredentialClient } from '../factories/serviceClients/cognitoIdentityProvider';\nexport async function deleteWebAuthnCredential(amplify, input) {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await amplify.Auth.fetchAuthSession();\n assertAuthTokens(tokens);\n const deleteWebAuthnCredentialResult = createDeleteWebAuthnCredentialClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await deleteWebAuthnCredentialResult({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.DeleteWebAuthnCredential),\n }, {\n AccessToken: tokens.accessToken.toString(),\n CredentialId: input.credentialId,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAOO,eAAe,wBAAwB,CAAC,OAAO,EAAE,KAAK,EAAE;AAC/D,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;AAC5D,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,8BAA8B,GAAG,oCAAoC,CAAC;AAChF,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,8BAA8B,CAAC;AACzC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,wBAAwB,CAAC;AAClF,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,YAAY,EAAE,KAAK,CAAC,YAAY;AACxC,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"deleteWebAuthnCredential.mjs","sources":["../../../../src/foundation/apis/deleteWebAuthnCredential.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../../providers/cognito/utils/types';\nimport { createCognitoUserPoolEndpointResolver } from '../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../parsers';\nimport { getAuthUserAgentValue } from '../../utils';\nimport { createDeleteWebAuthnCredentialClient } from '../factories/serviceClients/cognitoIdentityProvider';\nexport async function deleteWebAuthnCredential(amplify, input) {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await amplify.Auth.fetchAuthSession();\n assertAuthTokens(tokens);\n const deleteWebAuthnCredentialResult = createDeleteWebAuthnCredentialClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await deleteWebAuthnCredentialResult({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.DeleteWebAuthnCredential),\n }, {\n AccessToken: tokens.accessToken.toString(),\n CredentialId: input.credentialId,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAOO,eAAe,wBAAwB,CAAC,OAAO,EAAE,KAAK,EAAE;AAC/D,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;AAC5D,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,8BAA8B,GAAG,oCAAoC,CAAC;AAChF,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,8BAA8B,CAAC;AACzC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,wBAAwB,CAAC;AAClF,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,YAAY,EAAE,KAAK,CAAC,YAAY;AACxC,KAAK,CAAC;AACN;;;;"}
@@ -1,7 +1,6 @@
1
1
  import { assertTokenProviderConfig, AuthAction } from '@aws-amplify/core/internals/utils';
2
2
  import { assertAuthTokens } from '../../providers/cognito/utils/types.mjs';
3
3
  import { createCognitoUserPoolEndpointResolver } from '../../providers/cognito/factories/createCognitoUserPoolEndpointResolver.mjs';
4
- import '@aws-amplify/core';
5
4
  import { getRegionFromUserPoolId } from '../parsers/regionParsers.mjs';
6
5
  import { getAuthUserAgentValue } from '../../utils/getAuthUserAgentValue.mjs';
7
6
  import '@aws-amplify/core/internals/aws-client-utils/composers';
@@ -1 +1 @@
1
- {"version":3,"file":"listWebAuthnCredentials.mjs","sources":["../../../../src/foundation/apis/listWebAuthnCredentials.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../../providers/cognito/utils/types';\nimport { createCognitoUserPoolEndpointResolver } from '../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../parsers';\nimport { getAuthUserAgentValue } from '../../utils';\nimport { createListWebAuthnCredentialsClient } from '../factories/serviceClients/cognitoIdentityProvider';\nexport async function listWebAuthnCredentials(amplify, input) {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await amplify.Auth.fetchAuthSession();\n assertAuthTokens(tokens);\n const listWebAuthnCredentialsResult = createListWebAuthnCredentialsClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { Credentials: commandCredentials = [], NextToken: nextToken } = await listWebAuthnCredentialsResult({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ListWebAuthnCredentials),\n }, {\n AccessToken: tokens.accessToken.toString(),\n MaxResults: input?.pageSize,\n NextToken: input?.nextToken,\n });\n const credentials = commandCredentials.map(item => ({\n credentialId: item.CredentialId,\n friendlyCredentialName: item.FriendlyCredentialName,\n relyingPartyId: item.RelyingPartyId,\n authenticatorAttachment: item.AuthenticatorAttachment,\n authenticatorTransports: item.AuthenticatorTransports,\n createdAt: item.CreatedAt ? new Date(item.CreatedAt * 1000) : undefined,\n }));\n return {\n credentials,\n nextToken,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAOO,eAAe,uBAAuB,CAAC,OAAO,EAAE,KA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AC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,SAAS;AAC/E,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,WAAW;AACnB,QAAQ,SAAS;AACjB,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"listWebAuthnCredentials.mjs","sources":["../../../../src/foundation/apis/listWebAuthnCredentials.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../../providers/cognito/utils/types';\nimport { createCognitoUserPoolEndpointResolver } from '../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../parsers';\nimport { getAuthUserAgentValue } from '../../utils';\nimport { createListWebAuthnCredentialsClient } from '../factories/serviceClients/cognitoIdentityProvider';\nexport async function listWebAuthnCredentials(amplify, input) {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await amplify.Auth.fetchAuthSession();\n assertAuthTokens(tokens);\n const listWebAuthnCredentialsResult = createListWebAuthnCredentialsClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { Credentials: commandCredentials = [], NextToken: nextToken } = await listWebAuthnCredentialsResult({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ListWebAuthnCredentials),\n }, {\n AccessToken: tokens.accessToken.toString(),\n MaxResults: input?.pageSize,\n NextToken: input?.nextToken,\n });\n const credentials = commandCredentials.map(item => ({\n credentialId: item.CredentialId,\n friendlyCredentialName: item.FriendlyCredentialName,\n relyingPartyId: item.RelyingPartyId,\n authenticatorAttachment: item.AuthenticatorAttachment,\n authenticatorTransports: item.AuthenticatorTransports,\n createdAt: item.CreatedAt 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CAAC,cAAc;AAC3C,QAAQ,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;AAC7D,QAAQ,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;AAC7D,QAAQ,SAAS,EAAE,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,SAAS;AAC/E,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,WAAW;AACnB,QAAQ,SAAS;AACjB,KAAK;AACL;;;;"}
@@ -12,7 +12,6 @@ import '../../../../errors/types/validation.mjs';
12
12
  import '../../types/errors.mjs';
13
13
  import { createGetUserClient } from '../../../../foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserClient.mjs';
14
14
  import { createCognitoUserPoolEndpointResolver } from '../../factories/createCognitoUserPoolEndpointResolver.mjs';
15
- import '@aws-amplify/core';
16
15
 
17
16
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
18
17
  // SPDX-License-Identifier: Apache-2.0
@@ -1 +1 @@
1
- {"version":3,"file":"fetchUserAttributes.mjs","sources":["../../../../../../src/providers/cognito/apis/internal/fetchUserAttributes.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertTokenProviderConfig, fetchAuthSession, } from '@aws-amplify/core/internals/utils';\nimport { getRegionFromUserPoolId } from '../../../../foundation/parsers';\nimport { assertAuthTokens } from '../../utils/types';\nimport { toAuthUserAttribute } from '../../utils/apiHelpers';\nimport { getAuthUserAgentValue } from '../../../../utils';\nimport { createGetUserClient } from '../../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../factories';\nexport const fetchUserAttributes = async (amplify) => {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession(amplify, {\n forceRefresh: false,\n });\n assertAuthTokens(tokens);\n const getUser = createGetUserClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { UserAttributes } = await getUser({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.FetchUserAttributes),\n }, {\n AccessToken: tokens.accessToken.toString(),\n });\n return toAuthUserAttribute(UserAttributes);\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAQY,MAAC,mBAAmB,GAAG,OAAO,OAAO,KAAK;AACtD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE;AACvD,QAAQ,YAAY,EAAE,KAAK;AAC3B,KAAK,CAAC;AACN,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,OAAO,GAAG,mBAAmB,CAAC;AACxC,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,OAAO,CAAC;AAC7C,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,mBAAmB,CAAC;AAC7E,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB,CAAC,cAAc,CAAC;AAC9C;;;;"}
1
+ {"version":3,"file":"fetchUserAttributes.mjs","sources":["../../../../../../src/providers/cognito/apis/internal/fetchUserAttributes.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction, assertTokenProviderConfig, fetchAuthSession, } from '@aws-amplify/core/internals/utils';\nimport { getRegionFromUserPoolId } from '../../../../foundation/parsers';\nimport { assertAuthTokens } from '../../utils/types';\nimport { toAuthUserAttribute } from '../../utils/apiHelpers';\nimport { getAuthUserAgentValue } from '../../../../utils';\nimport { createGetUserClient } from '../../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../factories';\nexport const fetchUserAttributes = async (amplify) => {\n const authConfig = amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession(amplify, {\n forceRefresh: false,\n });\n assertAuthTokens(tokens);\n const getUser = createGetUserClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { UserAttributes } = await getUser({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.FetchUserAttributes),\n }, {\n AccessToken: tokens.accessToken.toString(),\n });\n return toAuthUserAttribute(UserAttributes);\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQY,MAAC,mBAAmB,GAAG,OAAO,OAAO,KAAK;AACtD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO;AACxD,IAAI,yBAAyB,CAAC,UAAU,CAAC;AACzC,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU;AACvD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE;AACvD,QAAQ,YAAY,EAAE,KAAK;AAC3B,KAAK,CAAC;AACN,IAAI,gBAAgB,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,OAAO,GAAG,mBAAmB,CAAC;AACxC,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,OAAO,CAAC;AAC7C,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,mBAAmB,CAAC;AAC7E,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB,CAAC,cAAc,CAAC;AAC9C;;;;"}
@@ -1,10 +1,7 @@
1
- import { createGetIdClient } from '@aws-amplify/core';
1
+ import { getId } from '@aws-amplify/core';
2
2
  import { AuthError } from '../../../errors/AuthError.mjs';
3
3
  import { assertServiceError } from '../../../errors/utils/assertServiceError.mjs';
4
4
  import { getRegionFromIdentityPoolId } from '../../../foundation/parsers/regionParsers.mjs';
5
- import '@aws-amplify/core/internals/utils';
6
- import '@aws-amplify/core/internals/aws-client-utils';
7
- import { createCognitoIdentityPoolEndpointResolver } from '../factories/createCognitoIdentityPoolEndpointResolver.mjs';
8
5
  import { formLoginsMap } from './utils.mjs';
9
6
 
10
7
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -39,11 +36,6 @@ async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore,
39
36
  async function generateIdentityId(logins, authConfig) {
40
37
  const identityPoolId = authConfig?.identityPoolId;
41
38
  const region = getRegionFromIdentityPoolId(identityPoolId);
42
- const getId = createGetIdClient({
43
- endpointResolver: createCognitoIdentityPoolEndpointResolver({
44
- endpointOverride: authConfig.identityPoolEndpoint,
45
- }),
46
- });
47
39
  // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API
48
40
  let idResult;
49
41
  // for a first-time user, this will return a brand new identity
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityIdProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createGetIdClient } from '@aws-amplify/core';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { createCognitoIdentityPoolEndpointResolver } from '../factories';\nimport { formLoginsMap } from './utils';\n/**\n * Provides a Cognito identityId\n *\n * @param tokens - The AuthTokens received after SignIn\n * @returns string\n * @throws configuration exceptions: `InvalidIdentityPoolIdException`\n * - Auth errors that may arise from misconfiguration.\n * @throws service exceptions: {@link GetIdException }\n */\nexport async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore, }) {\n identityIdStore.setAuthConfig({ Cognito: authConfig });\n // will return null only if there is no identityId cached or if there is an error retrieving it\n const identityId = await identityIdStore.loadIdentityId();\n if (identityId) {\n return identityId.id;\n }\n const logins = tokens?.idToken\n ? formLoginsMap(tokens.idToken.toString())\n : {};\n const generatedIdentityId = await generateIdentityId(logins, authConfig);\n // Store generated identityId\n identityIdStore.storeIdentityId({\n id: generatedIdentityId,\n type: tokens ? 'primary' : 'guest',\n });\n return generatedIdentityId;\n}\nasync function generateIdentityId(logins, authConfig) {\n const identityPoolId = authConfig?.identityPoolId;\n const region = getRegionFromIdentityPoolId(identityPoolId);\n const getId = createGetIdClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API\n let idResult;\n // for a first-time user, this will return a brand new identity\n // for a returning user, this will retrieve the previous identity assocaited with the logins\n try {\n idResult = (await getId({\n region,\n }, {\n IdentityPoolId: identityPoolId,\n Logins: logins,\n })).IdentityId;\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (!idResult) {\n throw new AuthError({\n name: 'GetIdResponseException',\n message: 'Received undefined response from getId operation',\n recoverySuggestion: 'Make sure to pass a valid identityPoolId in the configuration.',\n });\n }\n return idResult;\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,EAAE;AAC1F,IAAI,eAAe,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1D;AACA,IAAI,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE;AAC7D,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,OAAO,UAAU,CAAC,EAAE;AAC5B;AACA,IAAI,MAAM,MAAM,GAAG,MAAM,EAAE;AAC3B,UAAU,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;AACjD,UAAU,EAAE;AACZ,IAAI,MAAM,mBAAmB,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC;AAC5E;AACA,IAAI,eAAe,CAAC,eAAe,CAAC;AACpC,QAAQ,EAAE,EAAE,mBAAmB;AAC/B,QAAQ,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;AAC1C,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB;AAC9B;AACA,eAAe,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE;AACtD,IAAI,MAAM,cAAc,GAAG,UAAU,EAAE,cAAc;AACrD,IAAI,MAAM,MAAM,GAAG,2BAA2B,CAAC,cAAc,CAAC;AAC9D,IAAI,MAAM,KAAK,GAAG,iBAAiB,CAAC;AACpC,QAAQ,gBAAgB,EAAE,yCAAyC,CAAC;AACpE,YAAY,gBAAgB,EAAE,UAAU,CAAC,oBAAoB;AAC7D,SAAS,CAAC;AACV,KAAK,CAAC;AACN;AACA,IAAI,IAAI,QAAQ;AAChB;AACA;AACA,IAAI,IAAI;AACR,QAAQ,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC;AAChC,YAAY,MAAM;AAClB,SAAS,EAAE;AACX,YAAY,cAAc,EAAE,cAAc;AAC1C,YAAY,MAAM,EAAE,MAAM;AAC1B,SAAS,CAAC,EAAE,UAAU;AACtB;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,kBAAkB,CAAC,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC;AAC9B;AACA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,wBAAwB;AAC1C,YAAY,OAAO,EAAE,kDAAkD;AACvE,YAAY,kBAAkB,EAAE,gEAAgE;AAChG,SAAS,CAAC;AACV;AACA,IAAI,OAAO,QAAQ;AACnB;;;;"}
1
+ {"version":3,"file":"IdentityIdProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getId } from '@aws-amplify/core';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { formLoginsMap } from './utils';\n/**\n * Provides a Cognito identityId\n *\n * @param tokens - The AuthTokens received after SignIn\n * @returns string\n * @throws configuration exceptions: `InvalidIdentityPoolIdException`\n * - Auth errors that may arise from misconfiguration.\n * @throws service exceptions: {@link GetIdException }\n */\nexport async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore, }) {\n identityIdStore.setAuthConfig({ Cognito: authConfig });\n // will return null only if there is no identityId cached or if there is an error retrieving it\n const identityId = await identityIdStore.loadIdentityId();\n if (identityId) {\n return identityId.id;\n }\n const logins = tokens?.idToken\n ? formLoginsMap(tokens.idToken.toString())\n : {};\n const generatedIdentityId = await generateIdentityId(logins, authConfig);\n // Store generated identityId\n identityIdStore.storeIdentityId({\n id: generatedIdentityId,\n type: tokens ? 'primary' : 'guest',\n });\n return generatedIdentityId;\n}\nasync function generateIdentityId(logins, authConfig) {\n const identityPoolId = authConfig?.identityPoolId;\n const region = getRegionFromIdentityPoolId(identityPoolId);\n // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API\n let idResult;\n // for a first-time user, this will return a brand new identity\n // for a returning user, this will retrieve the previous identity assocaited with the logins\n try {\n idResult = (await getId({\n region,\n }, {\n IdentityPoolId: identityPoolId,\n Logins: logins,\n })).IdentityId;\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (!idResult) {\n throw new AuthError({\n name: 'GetIdResponseException',\n message: 'Received undefined response from getId operation',\n recoverySuggestion: 'Make sure to pass a valid identityPoolId in the configuration.',\n });\n }\n return idResult;\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,EAAE;AAC1F,IAAI,eAAe,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1D;AACA,IAAI,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE;AAC7D,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,OAAO,UAAU,CAAC,EAAE;AAC5B;AACA,IAAI,MAAM,MAAM,GAAG,MAAM,EAAE;AAC3B,UAAU,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;AACjD,UAAU,EAAE;AACZ,IAAI,MAAM,mBAAmB,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC;AAC5E;AACA,IAAI,eAAe,CAAC,eAAe,CAAC;AACpC,QAAQ,EAAE,EAAE,mBAAmB;AAC/B,QAAQ,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;AAC1C,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB;AAC9B;AACA,eAAe,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE;AACtD,IAAI,MAAM,cAAc,GAAG,UAAU,EAAE,cAAc;AACrD,IAAI,MAAM,MAAM,GAAG,2BAA2B,CAAC,cAAc,CAAC;AAC9D;AACA,IAAI,IAAI,QAAQ;AAChB;AACA;AACA,IAAI,IAAI;AACR,QAAQ,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC;AAChC,YAAY,MAAM;AAClB,SAAS,EAAE;AACX,YAAY,cAAc,EAAE,cAAc;AAC1C,YAAY,MAAM,EAAE,MAAM;AAC1B,SAAS,CAAC,EAAE,UAAU;AACtB;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,kBAAkB,CAAC,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC;AAC9B;AACA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,wBAAwB;AAC1C,YAAY,OAAO,EAAE,kDAAkD;AACvE,YAAY,kBAAkB,EAAE,gEAAgE;AAChG,SAAS,CAAC;AACV;AACA,IAAI,OAAO,QAAQ;AACnB;;;;"}
@@ -1,11 +1,9 @@
1
- import { ConsoleLogger, createGetCredentialsForIdentityClient } from '@aws-amplify/core';
1
+ import { ConsoleLogger, getCredentialsForIdentity } from '@aws-amplify/core';
2
2
  import { assertIdentityPoolIdConfig } from '@aws-amplify/core/internals/utils';
3
3
  import { AuthError } from '../../../errors/AuthError.mjs';
4
4
  import { assertServiceError } from '../../../errors/utils/assertServiceError.mjs';
5
5
  import { getRegionFromIdentityPoolId } from '../../../foundation/parsers/regionParsers.mjs';
6
6
  import { assertIdTokenInAuthTokens } from '../utils/types.mjs';
7
- import '@aws-amplify/core/internals/aws-client-utils';
8
- import { createCognitoIdentityPoolEndpointResolver } from '../factories/createCognitoIdentityPoolEndpointResolver.mjs';
9
7
  import { cognitoIdentityIdProvider } from './IdentityIdProvider.mjs';
10
8
  import { formLoginsMap } from './utils.mjs';
11
9
 
@@ -72,11 +70,6 @@ class CognitoAWSCredentialsAndIdentityIdProvider {
72
70
  // Clear to discard if any authenticated credentials are set and start with a clean slate
73
71
  this.clearCredentials();
74
72
  const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);
75
- const getCredentialsForIdentity = createGetCredentialsForIdentityClient({
76
- endpointResolver: createCognitoIdentityPoolEndpointResolver({
77
- endpointOverride: authConfig.identityPoolEndpoint,
78
- }),
79
- });
80
73
  // use identityId to obtain guest credentials
81
74
  // save credentials in-memory
82
75
  // No logins params should be passed for guest creds:
@@ -136,11 +129,6 @@ class CognitoAWSCredentialsAndIdentityIdProvider {
136
129
  ? formLoginsMap(authTokens.idToken.toString())
137
130
  : {};
138
131
  const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);
139
- const getCredentialsForIdentity = createGetCredentialsForIdentityClient({
140
- endpointResolver: createCognitoIdentityPoolEndpointResolver({
141
- endpointOverride: authConfig.identityPoolEndpoint,
142
- }),
143
- });
144
132
  let clientResult;
145
133
  try {
146
134
  clientResult = await getCredentialsForIdentity({ region }, {
@@ -1 +1 @@
1
- {"version":3,"file":"credentialsProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/credentialsProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, createGetCredentialsForIdentityClient, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { assertIdTokenInAuthTokens } from '../utils/types';\nimport { createCognitoIdentityPoolEndpointResolver } from '../factories';\nimport { cognitoIdentityIdProvider } from './IdentityIdProvider';\nimport { formLoginsMap } from './utils';\nconst logger = new ConsoleLogger('CognitoCredentialsProvider');\nconst CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nexport class CognitoAWSCredentialsAndIdentityIdProvider {\n constructor(identityIdStore) {\n this._nextCredentialsRefresh = 0;\n this._identityIdStore = identityIdStore;\n }\n async clearCredentialsAndIdentityId() {\n logger.debug('Clearing out credentials and identityId');\n this._credentialsAndIdentityId = undefined;\n await this._identityIdStore.clearIdentityId();\n }\n async clearCredentials() {\n logger.debug('Clearing out in-memory credentials');\n this._credentialsAndIdentityId = undefined;\n }\n async getCredentialsAndIdentityId(getCredentialsOptions) {\n const isAuthenticated = getCredentialsOptions.authenticated;\n const { tokens } = getCredentialsOptions;\n const { authConfig } = getCredentialsOptions;\n try {\n assertIdentityPoolIdConfig(authConfig?.Cognito);\n }\n catch {\n // No identity pool configured, skipping\n return;\n }\n if (!isAuthenticated && !authConfig.Cognito.allowGuestAccess) {\n // TODO(V6): return partial result like Native platforms\n return;\n }\n const { forceRefresh } = getCredentialsOptions;\n const tokenHasChanged = this.hasTokenChanged(tokens);\n const identityId = await cognitoIdentityIdProvider({\n tokens,\n authConfig: authConfig.Cognito,\n identityIdStore: this._identityIdStore,\n });\n // Clear cached credentials when forceRefresh is true OR the cache token has changed\n if (forceRefresh || tokenHasChanged) {\n this.clearCredentials();\n }\n if (!isAuthenticated) {\n return this.getGuestCredentials(identityId, authConfig.Cognito);\n }\n else {\n assertIdTokenInAuthTokens(tokens);\n return this.credsForOIDCTokens(authConfig.Cognito, tokens, identityId);\n }\n }\n async getGuestCredentials(identityId, authConfig) {\n // Return existing in-memory cached credentials only if it exists, is not past it's lifetime and is unauthenticated credentials\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === false) {\n logger.info('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any authenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n const getCredentialsForIdentity = createGetCredentialsForIdentityClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n // use identityId to obtain guest credentials\n // save credentials in-memory\n // No logins params should be passed for guest creds:\n // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'guest',\n });\n }\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: false,\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsNotFoundException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n async credsForOIDCTokens(authConfig, authTokens, identityId) {\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === true) {\n logger.debug('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any unauthenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const logins = authTokens.idToken\n ? formLoginsMap(authTokens.idToken.toString())\n : {};\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n const getCredentialsForIdentity = createGetCredentialsForIdentityClient({\n endpointResolver: createCognitoIdentityPoolEndpointResolver({\n endpointOverride: authConfig.identityPoolEndpoint,\n }),\n });\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n Logins: logins,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n // note: the following call removes guest identityId from the persistent store (localStorage)\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'primary',\n });\n }\n // Store the credentials in-memory along with the expiration\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: true,\n associatedIdToken: authTokens.idToken?.toString(),\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n isPastTTL() {\n return this._nextCredentialsRefresh === undefined\n ? true\n : this._nextCredentialsRefresh <= Date.now();\n }\n hasTokenChanged(tokens) {\n return (!!tokens &&\n !!this._credentialsAndIdentityId?.associatedIdToken &&\n tokens.idToken?.toString() !==\n this._credentialsAndIdentityId.associatedIdToken);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAUA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,4BAA4B,CAAC;AAC9D,MAAM,eAAe,GAAG,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AiB;AAChE;AACA;;;;"}
1
+ {"version":3,"file":"credentialsProvider.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/credentialsProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, getCredentialsForIdentity, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig, } from '@aws-amplify/core/internals/utils';\nimport { AuthError } from '../../../errors/AuthError';\nimport { assertServiceError } from '../../../errors/utils/assertServiceError';\nimport { getRegionFromIdentityPoolId } from '../../../foundation/parsers';\nimport { assertIdTokenInAuthTokens } from '../utils/types';\nimport { cognitoIdentityIdProvider } from './IdentityIdProvider';\nimport { formLoginsMap } from './utils';\nconst logger = new ConsoleLogger('CognitoCredentialsProvider');\nconst CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nexport class CognitoAWSCredentialsAndIdentityIdProvider {\n constructor(identityIdStore) {\n this._nextCredentialsRefresh = 0;\n this._identityIdStore = identityIdStore;\n }\n async clearCredentialsAndIdentityId() {\n logger.debug('Clearing out credentials and identityId');\n this._credentialsAndIdentityId = undefined;\n await this._identityIdStore.clearIdentityId();\n }\n async clearCredentials() {\n logger.debug('Clearing out in-memory credentials');\n this._credentialsAndIdentityId = undefined;\n }\n async getCredentialsAndIdentityId(getCredentialsOptions) {\n const isAuthenticated = getCredentialsOptions.authenticated;\n const { tokens } = getCredentialsOptions;\n const { authConfig } = getCredentialsOptions;\n try {\n assertIdentityPoolIdConfig(authConfig?.Cognito);\n }\n catch {\n // No identity pool configured, skipping\n return;\n }\n if (!isAuthenticated && !authConfig.Cognito.allowGuestAccess) {\n // TODO(V6): return partial result like Native platforms\n return;\n }\n const { forceRefresh } = getCredentialsOptions;\n const tokenHasChanged = this.hasTokenChanged(tokens);\n const identityId = await cognitoIdentityIdProvider({\n tokens,\n authConfig: authConfig.Cognito,\n identityIdStore: this._identityIdStore,\n });\n // Clear cached credentials when forceRefresh is true OR the cache token has changed\n if (forceRefresh || tokenHasChanged) {\n this.clearCredentials();\n }\n if (!isAuthenticated) {\n return this.getGuestCredentials(identityId, authConfig.Cognito);\n }\n else {\n assertIdTokenInAuthTokens(tokens);\n return this.credsForOIDCTokens(authConfig.Cognito, tokens, identityId);\n }\n }\n async getGuestCredentials(identityId, authConfig) {\n // Return existing in-memory cached credentials only if it exists, is not past it's lifetime and is unauthenticated credentials\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === false) {\n logger.info('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any authenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n // use identityId to obtain guest credentials\n // save credentials in-memory\n // No logins params should be passed for guest creds:\n // https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'guest',\n });\n }\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: false,\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsNotFoundException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n async credsForOIDCTokens(authConfig, authTokens, identityId) {\n if (this._credentialsAndIdentityId &&\n !this.isPastTTL() &&\n this._credentialsAndIdentityId.isAuthenticatedCreds === true) {\n logger.debug('returning stored credentials as they neither past TTL nor expired.');\n return this._credentialsAndIdentityId;\n }\n // Clear to discard if any unauthenticated credentials are set and start with a clean slate\n this.clearCredentials();\n const logins = authTokens.idToken\n ? formLoginsMap(authTokens.idToken.toString())\n : {};\n const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);\n let clientResult;\n try {\n clientResult = await getCredentialsForIdentity({ region }, {\n IdentityId: identityId,\n Logins: logins,\n });\n }\n catch (e) {\n assertServiceError(e);\n throw new AuthError(e);\n }\n if (clientResult?.Credentials?.AccessKeyId &&\n clientResult?.Credentials?.SecretKey) {\n this._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n const res = {\n credentials: {\n accessKeyId: clientResult.Credentials.AccessKeyId,\n secretAccessKey: clientResult.Credentials.SecretKey,\n sessionToken: clientResult.Credentials.SessionToken,\n expiration: clientResult.Credentials.Expiration,\n },\n identityId,\n };\n if (clientResult.IdentityId) {\n res.identityId = clientResult.IdentityId;\n // note: the following call removes guest identityId from the persistent store (localStorage)\n this._identityIdStore.storeIdentityId({\n id: clientResult.IdentityId,\n type: 'primary',\n });\n }\n // Store the credentials in-memory along with the expiration\n this._credentialsAndIdentityId = {\n ...res,\n isAuthenticatedCreds: true,\n associatedIdToken: authTokens.idToken?.toString(),\n };\n return res;\n }\n else {\n throw new AuthError({\n name: 'CredentialsException',\n message: `Cognito did not respond with either Credentials, AccessKeyId or SecretKey.`,\n });\n }\n }\n isPastTTL() {\n return this._nextCredentialsRefresh === undefined\n ? true\n : this._nextCredentialsRefresh <= Date.now();\n }\n hasTokenChanged(tokens) {\n return (!!tokens &&\n !!this._credentialsAndIdentityId?.associatedIdToken &&\n tokens.idToken?.toString() !==\n this._credentialsAndIdentityId.associatedIdToken);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AASA,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ACzC,gBAAgB,GAAG,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU;AACxD;AACA,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC;AACtD,oBAAoB,EAAE,EAAE,YAAY,CAAC,UAAU;AAC/C,oBAAoB,IAAI,EAAE,SAAS;AACnC,iBAAiB,CAAC;AAClB;AACA;AACA,YAAY,IAAI,CAAC,yBAAyB,GAAG;AAC7C,gBAAgB,GAAG,GAAG;AACtB,gBAAgB,oBAAoB,EAAE,IAAI;AAC1C,gBAAgB,iBAAiB,EAAE,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE;AACjE,aAAa;AACb,YAAY,OAAO,GAAG;AACtB;AACA,aAAa;AACb,YAAY,MAAM,IAAI,SAAS,CAAC;AAChC,gBAAgB,IAAI,EAAE,sBAAsB;AAC5C,gBAAgB,OAAO,EAAE,CAAC,0EAA0E,CAAC;AACrG,aAAa,CAAC;AACd;AACA;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,OAAO,IAAI,CAAC,uBAAuB,KAAK;AAChD,cAAc;AACd,cAAc,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE;AACxD;AACA,IAAI,eAAe,CAAC,MAAM,EAAE;AAC5B,QAAQ,QAAQ,CAAC,CAAC,MAAM;AACxB,YAAY,CAAC,CAAC,IAAI,CAAC,yBAAyB,EAAE,iBAAiB;AAC/D,YAAY,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;AACtC,gBAAgB,IAAI,CAAC,yBAAyB,CAAC,iBAAiB;AAChE;AACA;;;;"}
@@ -1,2 +1 @@
1
1
  export { createCognitoUserPoolEndpointResolver } from './createCognitoUserPoolEndpointResolver';
2
- export { createCognitoIdentityPoolEndpointResolver } from './createCognitoIdentityPoolEndpointResolver';
@@ -1,3 +1,2 @@
1
1
  export { createCognitoUserPoolEndpointResolver } from './createCognitoUserPoolEndpointResolver.mjs';
2
- export { createCognitoIdentityPoolEndpointResolver } from './createCognitoIdentityPoolEndpointResolver.mjs';
3
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -8,7 +8,6 @@ import '../../../errors/types/validation.mjs';
8
8
  import '../types/errors.mjs';
9
9
  import { createConfirmDeviceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmDeviceClient.mjs';
10
10
  import { createCognitoUserPoolEndpointResolver } from '../factories/createCognitoUserPoolEndpointResolver.mjs';
11
- import '@aws-amplify/core';
12
11
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
13
12
  import { getAuthenticationHelper } from './srp/getAuthenticationHelper.mjs';
14
13
  import { getBytesFromHex } from './srp/getBytesFromHex.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"getNewDeviceMetadata.mjs","sources":["../../../../../src/providers/cognito/utils/getNewDeviceMetadata.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { base64Encoder, getDeviceName, } from '@aws-amplify/core/internals/utils';\nimport { createConfirmDeviceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthenticationHelper, getBytesFromHex } from './srp';\n/**\n * This function is used to kick off the device management flow.\n *\n * If an error is thrown while generating a hash device or calling the `ConfirmDevice`\n * client, then this API will ignore the error and return undefined. Otherwise the authentication\n * flow will not complete and the user won't be able to be signed in.\n *\n * @returns DeviceMetadata | undefined\n */\nexport async function getNewDeviceMetadata({ userPoolId, userPoolEndpoint, newDeviceMetadata, accessToken, }) {\n if (!newDeviceMetadata)\n return undefined;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const deviceKey = newDeviceMetadata?.DeviceKey;\n const deviceGroupKey = newDeviceMetadata?.DeviceGroupKey;\n try {\n await authenticationHelper.generateHashDevice(deviceGroupKey ?? '', deviceKey ?? '');\n }\n catch (errGenHash) {\n // TODO: log error here\n return undefined;\n }\n const deviceSecretVerifierConfig = {\n Salt: base64Encoder.convert(getBytesFromHex(authenticationHelper.getSaltToHashDevices())),\n PasswordVerifier: base64Encoder.convert(getBytesFromHex(authenticationHelper.getVerifierDevices())),\n };\n const randomPassword = authenticationHelper.getRandomPassword();\n try {\n const confirmDevice = createConfirmDeviceClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await confirmDevice({ region: getRegionFromUserPoolId(userPoolId) }, {\n AccessToken: accessToken,\n DeviceName: await getDeviceName(),\n DeviceKey: newDeviceMetadata?.DeviceKey,\n DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n });\n return {\n deviceKey,\n deviceGroupKey,\n randomPassword,\n };\n }\n catch (error) {\n // TODO: log error here\n return undefined;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,oBAAoB,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,GAAG,EAAE;AAC9G,IAAI,IAAI,CAAC,iBAAiB;AAC1B,QAAQ,OAAO,SAAS;AACxB,IAAI,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACvD,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,YAAY,CAAC;AAC5E,IAAI,MAAM,SAAS,GAAG,iBAAiB,EAAE,SAAS;AAClD,IAAI,MAAM,cAAc,GAAG,iBAAiB,EAAE,cAAc;AAC5D,IAAI,IAAI;AACR,QAAQ,MAAM,oBAAoB,CAAC,kBAAkB,CAAC,cAAc,IAAI,EAAE,EAAE,SAAS,IAAI,EAAE,CAAC;AAC5F;AACA,IAAI,OAAO,UAAU,EAAE;AACvB;AACA,QAAQ,OAAO,SAAS;AACxB;AACA,IAAI,MAAM,0BAA0B,GAAG;AACvC,QAAQ,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,oBAAoB,EAAE,CAAC,CAAC;AACjG,QAAQ,gBAAgB,EAAE,aAAa,CAAC,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAC3G,KAAK;AACL,IAAI,MAAM,cAAc,GAAG,oBAAoB,CAAC,iBAAiB,EAAE;AACnE,IAAI,IAAI;AACR,QAAQ,MAAM,aAAa,GAAG,yBAAyB,CAAC;AACxD,YAAY,gBAAgB,EAAE,qCAAqC,CAAC;AACpE,gBAAgB,gBAAgB,EAAE,gBAAgB;AAClD,aAAa,CAAC;AACd,SAAS,CAAC;AACV,QAAQ,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE;AAC7E,YAAY,WAAW,EAAE,WAAW;AACpC,YAAY,UAAU,EAAE,MAAM,aAAa,EAAE;AAC7C,YAAY,SAAS,EAAE,iBAAiB,EAAE,SAAS;AACnD,YAAY,0BAA0B,EAAE,0BAA0B;AAClE,SAAS,CAAC;AACV,QAAQ,OAAO;AACf,YAAY,SAAS;AACrB,YAAY,cAAc;AAC1B,YAAY,cAAc;AAC1B,SAAS;AACT;AACA,IAAI,OAAO,KAAK,EAAE;AAClB;AACA,QAAQ,OAAO,SAAS;AACxB;AACA;;;;"}
1
+ {"version":3,"file":"getNewDeviceMetadata.mjs","sources":["../../../../../src/providers/cognito/utils/getNewDeviceMetadata.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { base64Encoder, getDeviceName, } from '@aws-amplify/core/internals/utils';\nimport { createConfirmDeviceClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthenticationHelper, getBytesFromHex } from './srp';\n/**\n * This function is used to kick off the device management flow.\n *\n * If an error is thrown while generating a hash device or calling the `ConfirmDevice`\n * client, then this API will ignore the error and return undefined. Otherwise the authentication\n * flow will not complete and the user won't be able to be signed in.\n *\n * @returns DeviceMetadata | undefined\n */\nexport async function getNewDeviceMetadata({ userPoolId, userPoolEndpoint, newDeviceMetadata, accessToken, }) {\n if (!newDeviceMetadata)\n return undefined;\n const userPoolName = userPoolId.split('_')[1] || '';\n const authenticationHelper = await getAuthenticationHelper(userPoolName);\n const deviceKey = newDeviceMetadata?.DeviceKey;\n const deviceGroupKey = newDeviceMetadata?.DeviceGroupKey;\n try {\n await authenticationHelper.generateHashDevice(deviceGroupKey ?? '', deviceKey ?? '');\n }\n catch (errGenHash) {\n // TODO: log error here\n return undefined;\n }\n const deviceSecretVerifierConfig = {\n Salt: base64Encoder.convert(getBytesFromHex(authenticationHelper.getSaltToHashDevices())),\n PasswordVerifier: base64Encoder.convert(getBytesFromHex(authenticationHelper.getVerifierDevices())),\n };\n const randomPassword = authenticationHelper.getRandomPassword();\n try {\n const confirmDevice = createConfirmDeviceClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n await confirmDevice({ region: getRegionFromUserPoolId(userPoolId) }, {\n AccessToken: accessToken,\n DeviceName: await getDeviceName(),\n DeviceKey: newDeviceMetadata?.DeviceKey,\n DeviceSecretVerifierConfig: deviceSecretVerifierConfig,\n });\n return {\n deviceKey,\n deviceGroupKey,\n randomPassword,\n };\n }\n catch (error) {\n // TODO: log error here\n return undefined;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;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Y,UAAU,EAAE,MAAM,aAAa,EAAE;AAC7C,YAAY,SAAS,EAAE,iBAAiB,EAAE,SAAS;AACnD,YAAY,0BAA0B,EAAE,0BAA0B;AAClE,SAAS,CAAC;AACV,QAAQ,OAAO;AACf,YAAY,SAAS;AACrB,YAAY,cAAc;AAC1B,YAAY,cAAc;AAC1B,SAAS;AACT;AACA,IAAI,OAAO,KAAK,EAAE;AAClB;AACA,QAAQ,OAAO,SAAS;AACxB;AACA;;;;"}
@@ -8,7 +8,6 @@ import '../../../errors/types/validation.mjs';
8
8
  import '../types/errors.mjs';
9
9
  import { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.mjs';
10
10
  import { createCognitoUserPoolEndpointResolver } from '../factories/createCognitoUserPoolEndpointResolver.mjs';
11
- import '@aws-amplify/core';
12
11
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
13
12
  import { assertDeviceMetadata } from './types.mjs';
14
13
  import { getAuthenticationHelper } from './srp/getAuthenticationHelper.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"handleDeviceSRPAuth.mjs","sources":["../../../../../src/providers/cognito/utils/handleDeviceSRPAuth.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertDeviceMetadata } from './types';\nimport { getAuthenticationHelper, getNowString, getSignatureString, } from './srp';\nimport { BigInteger } from './srp/BigInteger';\nimport { getUserContextData } from './userContextData';\nexport async function handleDeviceSRPAuth({ username, config, clientMetadata, session, tokenOrchestrator, }) {\n const { userPoolId, userPoolEndpoint } = config;\n const clientId = config.userPoolClientId;\n const deviceMetadata = await tokenOrchestrator?.getDeviceMetadata(username);\n assertDeviceMetadata(deviceMetadata);\n const authenticationHelper = await getAuthenticationHelper(deviceMetadata.deviceGroupKey);\n const challengeResponses = {\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n DEVICE_KEY: deviceMetadata.deviceKey,\n };\n const jsonReqResponseChallenge = {\n ChallengeName: 'DEVICE_SRP_AUTH',\n ClientId: clientId,\n ChallengeResponses: challengeResponses,\n ClientMetadata: clientMetadata,\n Session: session,\n };\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { ChallengeParameters: respondedChallengeParameters, Session } = await respondToAuthChallenge({ region: getRegionFromUserPoolId(userPoolId) }, jsonReqResponseChallenge);\n return handleDevicePasswordVerifier(username, respondedChallengeParameters, clientMetadata, Session, authenticationHelper, config, tokenOrchestrator);\n}\nasync function handleDevicePasswordVerifier(username, challengeParameters, clientMetadata, session, authenticationHelper, { userPoolId, userPoolClientId, userPoolEndpoint }, tokenOrchestrator) {\n const deviceMetadata = await tokenOrchestrator?.getDeviceMetadata(username);\n assertDeviceMetadata(deviceMetadata);\n const serverBValue = new BigInteger(challengeParameters?.SRP_B, 16);\n const salt = new BigInteger(challengeParameters?.SALT, 16);\n const { deviceKey } = deviceMetadata;\n const { deviceGroupKey } = deviceMetadata;\n const hkdf = await authenticationHelper.getPasswordAuthenticationKey({\n username: deviceMetadata.deviceKey,\n password: deviceMetadata.randomPassword,\n serverBValue,\n salt,\n });\n const dateNow = getNowString();\n const challengeResponses = {\n USERNAME: challengeParameters?.USERNAME ?? username,\n PASSWORD_CLAIM_SECRET_BLOCK: challengeParameters?.SECRET_BLOCK,\n TIMESTAMP: dateNow,\n PASSWORD_CLAIM_SIGNATURE: getSignatureString({\n username: deviceKey,\n userPoolName: deviceGroupKey,\n challengeParameters,\n dateNow,\n hkdf,\n }),\n DEVICE_KEY: deviceKey,\n };\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReqResponseChallenge = {\n ChallengeName: 'DEVICE_PASSWORD_VERIFIER',\n ClientId: userPoolClientId,\n ChallengeResponses: challengeResponses,\n Session: session,\n ClientMetadata: clientMetadata,\n UserContextData,\n };\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n return respondToAuthChallenge({ region: getRegionFromUserPoolId(userPoolId) }, jsonReqResponseChallenge);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQO,eAAe,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,GAAG,EAAE;AAC7G,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACnD,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB;AAC5C,IAAI,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,QAAQ,CAAC;AAC/E,IAAI,oBAAoB,CAAC,cAAc,CAAC;AACxC,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,cAAc,CAAC,cAAc,CAAC;AAC7F,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClD,QAAQ,UAAU,EAAE,cAAc,CAAC,SAAS;AAC5C,KAAK;AACL,IAAI,MAAM,wBAAwB,GAAG;AACrC,QAAQ,aAAa,EAAE,iBAAiB;AACxC,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,kBAAkB,EAAE,kBAAkB;AAC9C,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,KAAK;AACL,IAAI,MAAM,sBAAsB,GAAG,kCAAkC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M,kBAAkB,GAAG;AAC/B,QAAQ,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,IAAI,QAAQ;AAC3D,QAAQ,2BAA2B,EAAE,mBAAmB,EAAE,YAAY;AACtE,QAAQ,SAAS,EAAE,OAAO;AAC1B,QAAQ,wBAAwB,EAAE,kBAAkB,CAAC;AACrD,YAAY,QAAQ,EAAE,SAAS;AAC/B,YAAY,YAAY,EAAE,cAAc;AACxC,YAAY,mBAAmB;AAC/B,YAAY,OAAO;AACnB,YAAY,IAAI;AAChB,SAAS,CAAC;AACV,QAAQ,UAAU,EAAE,SAAS;AAC7B,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,wBAAwB,GAAG;AACrC,QAAQ,aAAa,EAAE,0BAA0B;AACjD,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,kBAAkB,EAAE,kBAAkB;AAC9C,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,eAAe;AACvB,KAAK;AACL,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,OAAO,sBAAsB,CAAC,EAAE,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,wBAAwB,CAAC;AAC5G;;;;"}
1
+ {"version":3,"file":"handleDeviceSRPAuth.mjs","sources":["../../../../../src/providers/cognito/utils/handleDeviceSRPAuth.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertDeviceMetadata } from './types';\nimport { getAuthenticationHelper, getNowString, getSignatureString, } from './srp';\nimport { BigInteger } from './srp/BigInteger';\nimport { getUserContextData } from './userContextData';\nexport async function handleDeviceSRPAuth({ username, config, clientMetadata, session, tokenOrchestrator, }) {\n const { userPoolId, userPoolEndpoint } = config;\n const clientId = config.userPoolClientId;\n const deviceMetadata = await tokenOrchestrator?.getDeviceMetadata(username);\n assertDeviceMetadata(deviceMetadata);\n const authenticationHelper = await getAuthenticationHelper(deviceMetadata.deviceGroupKey);\n const challengeResponses = {\n USERNAME: username,\n SRP_A: authenticationHelper.A.toString(16),\n DEVICE_KEY: deviceMetadata.deviceKey,\n };\n const jsonReqResponseChallenge = {\n ChallengeName: 'DEVICE_SRP_AUTH',\n ClientId: clientId,\n ChallengeResponses: challengeResponses,\n ClientMetadata: clientMetadata,\n Session: session,\n };\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { ChallengeParameters: respondedChallengeParameters, Session } = await respondToAuthChallenge({ region: getRegionFromUserPoolId(userPoolId) }, jsonReqResponseChallenge);\n return handleDevicePasswordVerifier(username, respondedChallengeParameters, clientMetadata, Session, authenticationHelper, config, tokenOrchestrator);\n}\nasync function handleDevicePasswordVerifier(username, challengeParameters, clientMetadata, session, authenticationHelper, { userPoolId, userPoolClientId, userPoolEndpoint }, tokenOrchestrator) {\n const deviceMetadata = await tokenOrchestrator?.getDeviceMetadata(username);\n assertDeviceMetadata(deviceMetadata);\n const serverBValue = new BigInteger(challengeParameters?.SRP_B, 16);\n const salt = new BigInteger(challengeParameters?.SALT, 16);\n const { deviceKey } = deviceMetadata;\n const { deviceGroupKey } = deviceMetadata;\n const hkdf = await authenticationHelper.getPasswordAuthenticationKey({\n username: deviceMetadata.deviceKey,\n password: deviceMetadata.randomPassword,\n serverBValue,\n salt,\n });\n const dateNow = getNowString();\n const challengeResponses = {\n USERNAME: challengeParameters?.USERNAME ?? username,\n PASSWORD_CLAIM_SECRET_BLOCK: challengeParameters?.SECRET_BLOCK,\n TIMESTAMP: dateNow,\n PASSWORD_CLAIM_SIGNATURE: getSignatureString({\n username: deviceKey,\n userPoolName: deviceGroupKey,\n challengeParameters,\n dateNow,\n hkdf,\n }),\n DEVICE_KEY: deviceKey,\n };\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReqResponseChallenge = {\n ChallengeName: 'DEVICE_PASSWORD_VERIFIER',\n ClientId: userPoolClientId,\n ChallengeResponses: challengeResponses,\n Session: session,\n ClientMetadata: clientMetadata,\n UserContextData,\n };\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n return respondToAuthChallenge({ region: getRegionFromUserPoolId(userPoolId) }, jsonReqResponseChallenge);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQO,eAAe,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,GAAG,EAAE;AAC7G,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACnD,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB;AAC5C,IAAI,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,QAAQ,CAAC;AAC/E,IAAI,oBAAoB,CAAC,cAAc,CAAC;AACxC,IAAI,MAAM,oBAAoB,GAAG,MAAM,uBAAuB,CAAC,cAAc,CAAC,cAAc,CAAC;AAC7F,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,KAAK,EAAE,oBAAoB,CAAC,CAAC,C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AC;AACN,IAAI,OAAO,sBAAsB,CAAC,EAAE,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,wBAAwB,CAAC;AAC5G;;;;"}
@@ -9,7 +9,6 @@ import '../../../errors/types/validation.mjs';
9
9
  import '../types/errors.mjs';
10
10
  import { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.mjs';
11
11
  import { createCognitoUserPoolEndpointResolver } from '../factories/createCognitoUserPoolEndpointResolver.mjs';
12
- import '@aws-amplify/core';
13
12
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
14
13
  import BigInteger from './srp/BigInteger/BigInteger.mjs';
15
14
  import './srp/constants.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"handlePasswordVerifierChallenge.mjs","sources":["../../../../../src/providers/cognito/utils/handlePasswordVerifierChallenge.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from '../../../errors/AuthError';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getNowString, getSignatureString } from './srp';\nimport { BigInteger } from './srp/BigInteger';\nimport { getUserContextData } from './userContextData';\nimport { handleDeviceSRPAuth } from './handleDeviceSRPAuth';\nexport async function handlePasswordVerifierChallenge(password, challengeParameters, clientMetadata, session, authenticationHelper, config, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId?.split('_')[1] || '';\n const serverBValue = new BigInteger(challengeParameters?.SRP_B, 16);\n const salt = new BigInteger(challengeParameters?.SALT, 16);\n const username = challengeParameters?.USER_ID_FOR_SRP;\n if (!username)\n throw new AuthError({\n name: 'EmptyUserIdForSRPException',\n message: 'USER_ID_FOR_SRP was not found in challengeParameters',\n });\n const hkdf = await authenticationHelper.getPasswordAuthenticationKey({\n username,\n password,\n serverBValue,\n salt,\n });\n const dateNow = getNowString();\n const challengeResponses = {\n USERNAME: username,\n PASSWORD_CLAIM_SECRET_BLOCK: challengeParameters?.SECRET_BLOCK,\n TIMESTAMP: dateNow,\n PASSWORD_CLAIM_SIGNATURE: getSignatureString({\n username,\n userPoolName,\n challengeParameters,\n dateNow,\n hkdf,\n }),\n };\n const deviceMetadata = await tokenOrchestrator.getDeviceMetadata(username);\n if (deviceMetadata && deviceMetadata.deviceKey) {\n challengeResponses.DEVICE_KEY = deviceMetadata.deviceKey;\n }\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReqResponseChallenge = {\n ChallengeName: 'PASSWORD_VERIFIER',\n ChallengeResponses: challengeResponses,\n ClientMetadata: clientMetadata,\n Session: session,\n ClientId: userPoolClientId,\n UserContextData,\n };\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({ region: getRegionFromUserPoolId(userPoolId) }, jsonReqResponseChallenge);\n if (response.ChallengeName === 'DEVICE_SRP_AUTH')\n return handleDeviceSRPAuth({\n username,\n config,\n clientMetadata,\n session: response.Session,\n tokenOrchestrator,\n });\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AASO,eAAe,+BAA+B,CAAC,QAAQ,EAAE,mBAAmB,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,iBAAiB,EAAE;AAC/J,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM;AACrE,IAAI,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;AACxD,IAAI,MAAM,YAAY,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QAAQ,aAAa,EAAE,mBAAmB;AAC1C,QAAQ,kBAAkB,EAAE,kBAAkB;AAC9C,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,eAAe;AACvB,KAAK;AACL,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,EAAE,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,wBAAwB,CAAC;AAC5H,IAAI,IAAI,QAAQ,CAAC,aAAa,KAAK,iBAAiB;AACpD,QAAQ,OAAO,mBAAmB,CAAC;AACnC,YAAY,QAAQ;AACpB,YAAY,MAAM;AAClB,YAAY,cAAc;AAC1B,YAAY,OAAO,EAAE,QAAQ,CAAC,OAAO;AACrC,YAAY,iBAAiB;AAC7B,SAAS,CAAC;AACV,IAAI,OAAO,QAAQ;AACnB;;;;"}
1
+ {"version":3,"file":"handlePasswordVerifierChallenge.mjs","sources":["../../../../../src/providers/cognito/utils/handlePasswordVerifierChallenge.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from '../../../errors/AuthError';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getNowString, getSignatureString } from './srp';\nimport { BigInteger } from './srp/BigInteger';\nimport { getUserContextData } from './userContextData';\nimport { handleDeviceSRPAuth } from './handleDeviceSRPAuth';\nexport async function handlePasswordVerifierChallenge(password, challengeParameters, clientMetadata, session, authenticationHelper, config, tokenOrchestrator) {\n const { userPoolId, userPoolClientId, userPoolEndpoint } = config;\n const userPoolName = userPoolId?.split('_')[1] || '';\n const serverBValue = new BigInteger(challengeParameters?.SRP_B, 16);\n const salt = new BigInteger(challengeParameters?.SALT, 16);\n const username = challengeParameters?.USER_ID_FOR_SRP;\n if (!username)\n throw new AuthError({\n name: 'EmptyUserIdForSRPException',\n message: 'USER_ID_FOR_SRP was not found in challengeParameters',\n });\n const hkdf = await authenticationHelper.getPasswordAuthenticationKey({\n username,\n password,\n serverBValue,\n salt,\n });\n const dateNow = getNowString();\n const challengeResponses = {\n USERNAME: username,\n PASSWORD_CLAIM_SECRET_BLOCK: challengeParameters?.SECRET_BLOCK,\n TIMESTAMP: dateNow,\n PASSWORD_CLAIM_SIGNATURE: getSignatureString({\n username,\n userPoolName,\n challengeParameters,\n dateNow,\n hkdf,\n }),\n };\n const deviceMetadata = await tokenOrchestrator.getDeviceMetadata(username);\n if (deviceMetadata && deviceMetadata.deviceKey) {\n challengeResponses.DEVICE_KEY = deviceMetadata.deviceKey;\n }\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const jsonReqResponseChallenge = {\n ChallengeName: 'PASSWORD_VERIFIER',\n ChallengeResponses: challengeResponses,\n ClientMetadata: clientMetadata,\n Session: session,\n ClientId: userPoolClientId,\n UserContextData,\n };\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await respondToAuthChallenge({ region: getRegionFromUserPoolId(userPoolId) }, jsonReqResponseChallenge);\n if (response.ChallengeName === 'DEVICE_SRP_AUTH')\n return handleDeviceSRPAuth({\n username,\n config,\n clientMetadata,\n session: response.Session,\n tokenOrchestrator,\n });\n return response;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AASO,eAAe,+BAA+B,CAAC,QAAQ,EAAE,mBAAmB,EAAE,cAAc,E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,IAAI,cAAc,CAAC,SAAS,EAAE;AACpD,QAAQ,kBAAkB,CAAC,UAAU,GAAG,cAAc,CAAC,SAAS;AAChE;AACA,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,wBAAwB,GAAG;AACrC,QAAQ,aAAa,EAAE,mBAAmB;AAC1C,QAAQ,kBAAkB,EAAE,kBAAkB;AAC9C,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,eAAe;AACvB,KAAK;AACL,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,EAAE,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,wBAAwB,CAAC;AAC5H,IAAI,IAAI,QAAQ,CAAC,aAAa,KAAK,iBAAiB;AACpD,QAAQ,OAAO,mBAAmB,CAAC;AACnC,YAAY,QAAQ;AACpB,YAAY,MAAM;AAClB,YAAY,cAAc;AAC1B,YAAY,OAAO,EAAE,QAAQ,CAAC,OAAO;AACrC,YAAY,iBAAiB;AAC7B,SAAS,CAAC;AACV,IAAI,OAAO,QAAQ;AACnB;;;;"}
@@ -11,7 +11,6 @@ import '../../../common/AuthErrorStrings.mjs';
11
11
  import '../../../errors/types/validation.mjs';
12
12
  import '../types/errors.mjs';
13
13
  import { createCognitoUserPoolEndpointResolver } from '../factories/createCognitoUserPoolEndpointResolver.mjs';
14
- import '@aws-amplify/core';
15
14
  import { getUserContextData } from './userContextData.mjs';
16
15
 
17
16
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -1 +1 @@
1
- {"version":3,"file":"refreshAuthTokens.mjs","sources":["../../../../../src/providers/cognito/utils/refreshAuthTokens.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertTokenProviderConfig, deDupeAsyncFunction, decodeJWT, } from '@aws-amplify/core/internals/utils';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokensWithRefreshToken } from '../utils/types';\nimport { AuthError } from '../../../errors/AuthError';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getUserContextData } from './userContextData';\nconst refreshAuthTokensFunction = async ({ tokens, authConfig, username, }) => {\n assertTokenProviderConfig(authConfig?.Cognito);\n const { userPoolId, userPoolClientId, userPoolEndpoint } = authConfig.Cognito;\n const region = getRegionFromUserPoolId(userPoolId);\n assertAuthTokensWithRefreshToken(tokens);\n const refreshTokenString = tokens.refreshToken;\n const AuthParameters = {\n REFRESH_TOKEN: refreshTokenString,\n };\n if (tokens.deviceMetadata?.deviceKey) {\n AuthParameters.DEVICE_KEY = tokens.deviceMetadata.deviceKey;\n }\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const initiateAuth = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { AuthenticationResult } = await initiateAuth({ region }, {\n ClientId: userPoolClientId,\n AuthFlow: 'REFRESH_TOKEN_AUTH',\n AuthParameters,\n UserContextData,\n });\n const accessToken = decodeJWT(AuthenticationResult?.AccessToken ?? '');\n const idToken = AuthenticationResult?.IdToken\n ? decodeJWT(AuthenticationResult.IdToken)\n : undefined;\n const { iat } = accessToken.payload;\n // This should never happen. If it does, it's a bug from the service.\n if (!iat) {\n throw new AuthError({\n name: 'iatNotFoundException',\n message: 'iat not found in access token',\n });\n }\n const clockDrift = iat * 1000 - new Date().getTime();\n return {\n accessToken,\n idToken,\n clockDrift,\n refreshToken: refreshTokenString,\n username,\n };\n};\nexport const refreshAuthTokens = deDupeAsyncFunction(refreshAuthTokensFunction);\nexport const refreshAuthTokensWithoutDedupe = refreshAuthTokensFunction;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,yBAAyB,GAAG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,GAAG,KAAK;AAC/E,IAAI,yBAAyB,CAAC,UAAU,EAAE,OAAO,CAAC;AAClD,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,OAAO;AACjF,IAAI,MAAM,MAAM,GAAG,uBAAuB,CAAC,UAAU,CAAC;AACtD,IAAI,gCAAgC,CAAC,MAAM,CAAC;AAC5C,IAAI,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY;AAClD,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,aAAa,EAAE,kBAAkB;AACzC,KAAK;AACL,IAAI,IAAI,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE;AAC1C,QAAQ,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS;AACnE;AACA,IAAI,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC/C,QAAQ,QAAQ;AAChB,QAAQ,UAAU;AAClB,QAAQ,gBAAgB;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAClD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE;AACpE,QAAQ,QAAQ,EAAE,gBAAgB;AAClC,QAAQ,QAAQ,EAAE,oBAAoB;AACtC,QAAQ,cAAc;AACtB,QAAQ,eAAe;AACvB,KAAK,CAAC;AACN,IAAI,MAAM,WAAW,GAAG,SAAS,CAAC,oBAAoB,EAAE,WAAW,IAAI,EAAE,CAAC;AAC1E,IAAI,MAAM,OAAO,GAAG,oBAAoB,EAAE;AAC1C,UAAU,SAAS,CAAC,oBAAoB,CAAC,OAAO;AAChD,UAAU,SAAS;AACnB,IAAI,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,OAAO;AACvC;AACA,IAAI,IAAI,CAAC,GAAG,EAAE;AACd,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,sBAAsB;AACxC,YAAY,OAAO,EAAE,+BAA+B;AACpD,SAAS,CAAC;AACV;AACA,IAAI,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;AACxD,IAAI,OAAO;AACX,QAAQ,WAAW;AACnB,QAAQ,OAAO;AACf,QAAQ,UAAU;AAClB,QAAQ,YAAY,EAAE,kBAAkB;AACxC,QAAQ,QAAQ;AAChB,KAAK;AACL,CAAC;AACW,MAAC,iBAAiB,GAAG,mBAAmB,CAAC,yBAAyB;AAClE,MAAC,8BAA8B,GAAG;;;;"}
1
+ {"version":3,"file":"refreshAuthTokens.mjs","sources":["../../../../../src/providers/cognito/utils/refreshAuthTokens.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertTokenProviderConfig, deDupeAsyncFunction, decodeJWT, } from '@aws-amplify/core/internals/utils';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { assertAuthTokensWithRefreshToken } from '../utils/types';\nimport { AuthError } from '../../../errors/AuthError';\nimport { createInitiateAuthClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\nimport { getUserContextData } from './userContextData';\nconst refreshAuthTokensFunction = async ({ tokens, authConfig, username, }) => {\n assertTokenProviderConfig(authConfig?.Cognito);\n const { userPoolId, userPoolClientId, userPoolEndpoint } = authConfig.Cognito;\n const region = getRegionFromUserPoolId(userPoolId);\n assertAuthTokensWithRefreshToken(tokens);\n const refreshTokenString = tokens.refreshToken;\n const AuthParameters = {\n REFRESH_TOKEN: refreshTokenString,\n };\n if (tokens.deviceMetadata?.deviceKey) {\n AuthParameters.DEVICE_KEY = tokens.deviceMetadata.deviceKey;\n }\n const UserContextData = getUserContextData({\n username,\n userPoolId,\n userPoolClientId,\n });\n const initiateAuth = createInitiateAuthClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const { AuthenticationResult } = await initiateAuth({ region }, {\n ClientId: userPoolClientId,\n AuthFlow: 'REFRESH_TOKEN_AUTH',\n AuthParameters,\n UserContextData,\n });\n const accessToken = decodeJWT(AuthenticationResult?.AccessToken ?? '');\n const idToken = AuthenticationResult?.IdToken\n ? decodeJWT(AuthenticationResult.IdToken)\n : undefined;\n const { iat } = accessToken.payload;\n // This should never happen. If it does, it's a bug from the service.\n if (!iat) {\n throw new AuthError({\n name: 'iatNotFoundException',\n message: 'iat not found in access token',\n });\n }\n const clockDrift = iat * 1000 - new Date().getTime();\n return {\n accessToken,\n idToken,\n clockDrift,\n refreshToken: refreshTokenString,\n username,\n };\n};\nexport const refreshAuthTokens = deDupeAsyncFunction(refreshAuthTokensFunction);\nexport const refreshAuthTokensWithoutDedupe = refreshAuthTokensFunction;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,yBAAyB,GAAG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,GAAG,KAAK;AAC/E,IAAI,yBAAyB,CAAC,UAAU,EAAE,OAAO,CAAC;AAClD,IAAI,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,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;AACxC,YAAY,OAAO,EAAE,+BAA+B;AACpD,SAAS,CAAC;AACV;AACA,IAAI,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;AACxD,IAAI,OAAO;AACX,QAAQ,WAAW;AACnB,QAAQ,OAAO;AACf,QAAQ,UAAU;AAClB,QAAQ,YAAY,EAAE,kBAAkB;AACxC,QAAQ,QAAQ;AAChB,KAAK;AACL,CAAC;AACW,MAAC,iBAAiB,GAAG,mBAAmB,CAAC,yBAAyB;AAClE,MAAC,8BAA8B,GAAG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/auth",
3
- "version": "6.12.5-local-stack.00864ae.0+00864ae",
3
+ "version": "6.12.5-unstable.5c85092.0+5c85092",
4
4
  "description": "Auth category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -96,12 +96,12 @@
96
96
  "tslib": "^2.5.0"
97
97
  },
98
98
  "peerDependencies": {
99
- "@aws-amplify/core": "6.11.5-local-stack.00864ae.0+00864ae"
99
+ "@aws-amplify/core": "6.11.5-unstable.5c85092.0+5c85092"
100
100
  },
101
101
  "devDependencies": {
102
- "@aws-amplify/core": "6.11.5-local-stack.00864ae.0+00864ae",
103
- "@aws-amplify/react-native": "1.1.10-local-stack.00864ae.0+00864ae",
102
+ "@aws-amplify/core": "6.11.5-unstable.5c85092.0+5c85092",
103
+ "@aws-amplify/react-native": "1.1.10-unstable.5c85092.0+5c85092",
104
104
  "@jest/test-sequencer": "^29.7.0"
105
105
  },
106
- "gitHead": "00864aec571d0509655eea0673e896d69d434972"
106
+ "gitHead": "5c85092c768bc1bd6d4f2dcedc12292f05f78bb2"
107
107
  }
@@ -1,14 +1,13 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { AuthTokens, Identity, createGetIdClient } from '@aws-amplify/core';
4
+ import { AuthTokens, Identity, getId } from '@aws-amplify/core';
5
5
  import { CognitoIdentityPoolConfig } from '@aws-amplify/core/internals/utils';
6
6
 
7
7
  import { AuthError } from '../../../errors/AuthError';
8
8
  import { assertServiceError } from '../../../errors/utils/assertServiceError';
9
9
  import { getRegionFromIdentityPoolId } from '../../../foundation/parsers';
10
10
  import { GetIdException } from '../types/errors';
11
- import { createCognitoIdentityPoolEndpointResolver } from '../factories';
12
11
 
13
12
  import { IdentityIdStore } from './types';
14
13
  import { formLoginsMap } from './utils';
@@ -59,12 +58,6 @@ async function generateIdentityId(
59
58
  const identityPoolId = authConfig?.identityPoolId;
60
59
  const region = getRegionFromIdentityPoolId(identityPoolId);
61
60
 
62
- const getId = createGetIdClient({
63
- endpointResolver: createCognitoIdentityPoolEndpointResolver({
64
- endpointOverride: authConfig.identityPoolEndpoint,
65
- }),
66
- });
67
-
68
61
  // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API
69
62
  let idResult: string | undefined;
70
63
  // for a first-time user, this will return a brand new identity
@@ -7,7 +7,7 @@ import {
7
7
  CredentialsAndIdentityId,
8
8
  CredentialsAndIdentityIdProvider,
9
9
  GetCredentialsOptions,
10
- createGetCredentialsForIdentityClient,
10
+ getCredentialsForIdentity,
11
11
  } from '@aws-amplify/core';
12
12
  import {
13
13
  CognitoIdentityPoolConfig,
@@ -18,7 +18,6 @@ import { AuthError } from '../../../errors/AuthError';
18
18
  import { assertServiceError } from '../../../errors/utils/assertServiceError';
19
19
  import { getRegionFromIdentityPoolId } from '../../../foundation/parsers';
20
20
  import { assertIdTokenInAuthTokens } from '../utils/types';
21
- import { createCognitoIdentityPoolEndpointResolver } from '../factories';
22
21
 
23
22
  import { IdentityIdStore } from './types';
24
23
  import { cognitoIdentityIdProvider } from './IdentityIdProvider';
@@ -114,12 +113,6 @@ export class CognitoAWSCredentialsAndIdentityIdProvider
114
113
 
115
114
  const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);
116
115
 
117
- const getCredentialsForIdentity = createGetCredentialsForIdentityClient({
118
- endpointResolver: createCognitoIdentityPoolEndpointResolver({
119
- endpointOverride: authConfig.identityPoolEndpoint,
120
- }),
121
- });
122
-
123
116
  // use identityId to obtain guest credentials
124
117
  // save credentials in-memory
125
118
  // No logins params should be passed for guest creds:
@@ -201,12 +194,6 @@ export class CognitoAWSCredentialsAndIdentityIdProvider
201
194
 
202
195
  const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);
203
196
 
204
- const getCredentialsForIdentity = createGetCredentialsForIdentityClient({
205
- endpointResolver: createCognitoIdentityPoolEndpointResolver({
206
- endpointOverride: authConfig.identityPoolEndpoint,
207
- }),
208
- });
209
-
210
197
  let clientResult:
211
198
  | Awaited<ReturnType<typeof getCredentialsForIdentity>>
212
199
  | undefined;
@@ -1,4 +1,3 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export { createCognitoUserPoolEndpointResolver } from './createCognitoUserPoolEndpointResolver';
4
- export { createCognitoIdentityPoolEndpointResolver } from './createCognitoIdentityPoolEndpointResolver';
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createCognitoIdentityPoolEndpointResolver = void 0;
5
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
- // SPDX-License-Identifier: Apache-2.0
7
- const core_1 = require("@aws-amplify/core");
8
- const utils_1 = require("@aws-amplify/core/internals/utils");
9
- const createCognitoIdentityPoolEndpointResolver = ({ endpointOverride }) => (input) => {
10
- if (endpointOverride) {
11
- return { url: new utils_1.AmplifyUrl(endpointOverride) };
12
- }
13
- return (0, core_1.cognitoIdentityPoolEndpointResolver)(input);
14
- };
15
- exports.createCognitoIdentityPoolEndpointResolver = createCognitoIdentityPoolEndpointResolver;
16
- //# sourceMappingURL=createCognitoIdentityPoolEndpointResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createCognitoIdentityPoolEndpointResolver.js","sources":["../../../../../src/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createCognitoIdentityPoolEndpointResolver = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst createCognitoIdentityPoolEndpointResolver = ({ endpointOverride }) => (input) => {\n if (endpointOverride) {\n return { url: new utils_1.AmplifyUrl(endpointOverride) };\n }\n return (0, core_1.cognitoIdentityPoolEndpointResolver)(input);\n};\nexports.createCognitoIdentityPoolEndpointResolver = createCognitoIdentityPoolEndpointResolver;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,yCAAyC,GAAG,MAAM;AAC1D;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,yCAAyC,GAAG,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,KAAK,KAAK;AACvF,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;AAChE;AACA,IAAI,OAAO,IAAI,MAAM,CAAC,mCAAmC,EAAE,KAAK,CAAC;AACjE,CAAC;AACD,OAAO,CAAC,yCAAyC,GAAG,yCAAyC;;"}
@@ -1,6 +0,0 @@
1
- import { EndpointResolverOptions } from '@aws-amplify/core/internals/aws-client-utils';
2
- export declare const createCognitoIdentityPoolEndpointResolver: ({ endpointOverride }: {
3
- endpointOverride: string | undefined;
4
- }) => (input: EndpointResolverOptions) => {
5
- url: URL;
6
- };
@@ -1,14 +0,0 @@
1
- import { cognitoIdentityPoolEndpointResolver } from '@aws-amplify/core';
2
- import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
3
-
4
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
- // SPDX-License-Identifier: Apache-2.0
6
- const createCognitoIdentityPoolEndpointResolver = ({ endpointOverride }) => (input) => {
7
- if (endpointOverride) {
8
- return { url: new AmplifyUrl(endpointOverride) };
9
- }
10
- return cognitoIdentityPoolEndpointResolver(input);
11
- };
12
-
13
- export { createCognitoIdentityPoolEndpointResolver };
14
- //# sourceMappingURL=createCognitoIdentityPoolEndpointResolver.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createCognitoIdentityPoolEndpointResolver.mjs","sources":["../../../../../src/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { cognitoIdentityPoolEndpointResolver } from '@aws-amplify/core';\nimport { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nexport const createCognitoIdentityPoolEndpointResolver = ({ endpointOverride }) => (input) => {\n if (endpointOverride) {\n return { url: new AmplifyUrl(endpointOverride) };\n }\n return cognitoIdentityPoolEndpointResolver(input);\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,yCAAyC,GAAG,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,KAAK,KAAK;AAC9F,IAAI,IAAI,gBAAgB,EAAE;AAC1B,QAAQ,OAAO,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACxD;AACA,IAAI,OAAO,mCAAmC,CAAC,KAAK,CAAC;AACrD;;;;"}
@@ -1,15 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { cognitoIdentityPoolEndpointResolver } from '@aws-amplify/core';
4
- import { EndpointResolverOptions } from '@aws-amplify/core/internals/aws-client-utils';
5
- import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
6
-
7
- export const createCognitoIdentityPoolEndpointResolver =
8
- ({ endpointOverride }: { endpointOverride: string | undefined }) =>
9
- (input: EndpointResolverOptions): { url: URL } => {
10
- if (endpointOverride) {
11
- return { url: new AmplifyUrl(endpointOverride) };
12
- }
13
-
14
- return cognitoIdentityPoolEndpointResolver(input);
15
- };