@aws-amplify/auth 6.12.4 → 6.12.5-local-stack.00864ae.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 (217) hide show
  1. package/dist/cjs/client/apis/associateWebAuthnCredential.js +1 -2
  2. package/dist/cjs/client/apis/associateWebAuthnCredential.js.map +1 -1
  3. package/dist/cjs/client/apis/deleteWebAuthnCredential.js +1 -2
  4. package/dist/cjs/client/apis/deleteWebAuthnCredential.js.map +1 -1
  5. package/dist/cjs/client/apis/listWebAuthnCredentials.js +1 -2
  6. package/dist/cjs/client/apis/listWebAuthnCredentials.js.map +1 -1
  7. package/dist/cjs/client/flows/shared/handlePasswordSRP.js +1 -2
  8. package/dist/cjs/client/flows/shared/handlePasswordSRP.js.map +1 -1
  9. package/dist/cjs/client/flows/userAuth/handleSelectChallenge.js +1 -2
  10. package/dist/cjs/client/flows/userAuth/handleSelectChallenge.js.map +1 -1
  11. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPassword.js +1 -2
  12. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPassword.js.map +1 -1
  13. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js +1 -2
  14. package/dist/cjs/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.js.map +1 -1
  15. package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js +1 -2
  16. package/dist/cjs/client/flows/userAuth/handleUserAuthFlow.js.map +1 -1
  17. package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js +1 -2
  18. package/dist/cjs/client/flows/userAuth/handleWebAuthnSignInResult.js.map +1 -1
  19. package/dist/cjs/client/utils/passkey/errors.js +1 -1
  20. package/dist/cjs/client/utils/passkey/errors.js.map +1 -1
  21. package/dist/cjs/client/utils/passkey/types/index.js +3 -3
  22. package/dist/cjs/client/utils/passkey/types/index.js.map +1 -1
  23. package/dist/cjs/client/utils/passkey/types/shared.js +1 -2
  24. package/dist/cjs/client/utils/passkey/types/shared.js.map +1 -1
  25. package/dist/cjs/client/utils/store/signInStore.js +2 -2
  26. package/dist/cjs/client/utils/store/signInStore.js.map +1 -1
  27. package/dist/cjs/common/AuthErrorStrings.js +5 -2
  28. package/dist/cjs/common/AuthErrorStrings.js.map +1 -1
  29. package/dist/cjs/errors/types/validation.js +2 -1
  30. package/dist/cjs/errors/types/validation.js.map +1 -1
  31. package/dist/cjs/errors/utils/assertServiceError.js +1 -2
  32. package/dist/cjs/errors/utils/assertServiceError.js.map +1 -1
  33. package/dist/cjs/errors/utils/assertValidationError.js +1 -2
  34. package/dist/cjs/errors/utils/assertValidationError.js.map +1 -1
  35. package/dist/cjs/foundation/apis/deleteWebAuthnCredential.js +1 -2
  36. package/dist/cjs/foundation/apis/deleteWebAuthnCredential.js.map +1 -1
  37. package/dist/cjs/foundation/apis/listWebAuthnCredentials.js +1 -2
  38. package/dist/cjs/foundation/apis/listWebAuthnCredentials.js.map +1 -1
  39. package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/types/errors.js +8 -4
  40. package/dist/cjs/foundation/factories/serviceClients/cognitoIdentityProvider/types/errors.js.map +1 -1
  41. package/dist/cjs/foundation/parsers/regionParsers.js +2 -3
  42. package/dist/cjs/foundation/parsers/regionParsers.js.map +1 -1
  43. package/dist/cjs/providers/cognito/apis/autoSignIn.js +3 -3
  44. package/dist/cjs/providers/cognito/apis/autoSignIn.js.map +1 -1
  45. package/dist/cjs/providers/cognito/apis/confirmResetPassword.js +1 -2
  46. package/dist/cjs/providers/cognito/apis/confirmResetPassword.js.map +1 -1
  47. package/dist/cjs/providers/cognito/apis/confirmSignIn.js +1 -2
  48. package/dist/cjs/providers/cognito/apis/confirmSignIn.js.map +1 -1
  49. package/dist/cjs/providers/cognito/apis/confirmSignUp.js +1 -2
  50. package/dist/cjs/providers/cognito/apis/confirmSignUp.js.map +1 -1
  51. package/dist/cjs/providers/cognito/apis/confirmUserAttribute.js +1 -2
  52. package/dist/cjs/providers/cognito/apis/confirmUserAttribute.js.map +1 -1
  53. package/dist/cjs/providers/cognito/apis/deleteUser.js +1 -2
  54. package/dist/cjs/providers/cognito/apis/deleteUser.js.map +1 -1
  55. package/dist/cjs/providers/cognito/apis/deleteUserAttributes.js +1 -2
  56. package/dist/cjs/providers/cognito/apis/deleteUserAttributes.js.map +1 -1
  57. package/dist/cjs/providers/cognito/apis/fetchDevices.js +1 -2
  58. package/dist/cjs/providers/cognito/apis/fetchDevices.js.map +1 -1
  59. package/dist/cjs/providers/cognito/apis/fetchMFAPreference.js +1 -2
  60. package/dist/cjs/providers/cognito/apis/fetchMFAPreference.js.map +1 -1
  61. package/dist/cjs/providers/cognito/apis/forgetDevice.js +1 -2
  62. package/dist/cjs/providers/cognito/apis/forgetDevice.js.map +1 -1
  63. package/dist/cjs/providers/cognito/apis/rememberDevice.js +1 -2
  64. package/dist/cjs/providers/cognito/apis/rememberDevice.js.map +1 -1
  65. package/dist/cjs/providers/cognito/apis/resendSignUpCode.js +1 -2
  66. package/dist/cjs/providers/cognito/apis/resendSignUpCode.js.map +1 -1
  67. package/dist/cjs/providers/cognito/apis/resetPassword.js +1 -2
  68. package/dist/cjs/providers/cognito/apis/resetPassword.js.map +1 -1
  69. package/dist/cjs/providers/cognito/apis/setUpTOTP.js +1 -2
  70. package/dist/cjs/providers/cognito/apis/setUpTOTP.js.map +1 -1
  71. package/dist/cjs/providers/cognito/apis/signIn.js +1 -2
  72. package/dist/cjs/providers/cognito/apis/signIn.js.map +1 -1
  73. package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js +1 -2
  74. package/dist/cjs/providers/cognito/apis/signInWithCustomAuth.js.map +1 -1
  75. package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js +1 -2
  76. package/dist/cjs/providers/cognito/apis/signInWithCustomSRPAuth.js.map +1 -1
  77. package/dist/cjs/providers/cognito/apis/signInWithRedirect.js +1 -2
  78. package/dist/cjs/providers/cognito/apis/signInWithRedirect.js.map +1 -1
  79. package/dist/cjs/providers/cognito/apis/signInWithSRP.js +1 -2
  80. package/dist/cjs/providers/cognito/apis/signInWithSRP.js.map +1 -1
  81. package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js +1 -2
  82. package/dist/cjs/providers/cognito/apis/signInWithUserAuth.js.map +1 -1
  83. package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js +1 -2
  84. package/dist/cjs/providers/cognito/apis/signInWithUserPassword.js.map +1 -1
  85. package/dist/cjs/providers/cognito/apis/signOut.js +1 -2
  86. package/dist/cjs/providers/cognito/apis/signOut.js.map +1 -1
  87. package/dist/cjs/providers/cognito/apis/signUp.js +1 -2
  88. package/dist/cjs/providers/cognito/apis/signUp.js.map +1 -1
  89. package/dist/cjs/providers/cognito/apis/updateMFAPreference.js +2 -3
  90. package/dist/cjs/providers/cognito/apis/updateMFAPreference.js.map +1 -1
  91. package/dist/cjs/providers/cognito/apis/updatePassword.js +1 -2
  92. package/dist/cjs/providers/cognito/apis/updatePassword.js.map +1 -1
  93. package/dist/cjs/providers/cognito/apis/verifyTOTPSetup.js +1 -2
  94. package/dist/cjs/providers/cognito/apis/verifyTOTPSetup.js.map +1 -1
  95. package/dist/cjs/providers/cognito/credentialsProvider/IdentityIdProvider.js +8 -3
  96. package/dist/cjs/providers/cognito/credentialsProvider/IdentityIdProvider.js.map +1 -1
  97. package/dist/cjs/providers/cognito/credentialsProvider/credentialsProvider.js +13 -2
  98. package/dist/cjs/providers/cognito/credentialsProvider/credentialsProvider.js.map +1 -1
  99. package/dist/cjs/providers/cognito/credentialsProvider/utils.js +1 -2
  100. package/dist/cjs/providers/cognito/credentialsProvider/utils.js.map +1 -1
  101. package/dist/cjs/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.js +16 -0
  102. package/dist/cjs/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.js.map +1 -0
  103. package/dist/cjs/providers/cognito/factories/index.js +3 -1
  104. package/dist/cjs/providers/cognito/factories/index.js.map +1 -1
  105. package/dist/cjs/providers/cognito/tokenProvider/TokenStore.js +2 -2
  106. package/dist/cjs/providers/cognito/tokenProvider/TokenStore.js.map +1 -1
  107. package/dist/cjs/providers/cognito/tokenProvider/cacheTokens.js +1 -2
  108. package/dist/cjs/providers/cognito/tokenProvider/cacheTokens.js.map +1 -1
  109. package/dist/cjs/providers/cognito/tokenProvider/errorHelpers.js +1 -1
  110. package/dist/cjs/providers/cognito/tokenProvider/errorHelpers.js.map +1 -1
  111. package/dist/cjs/providers/cognito/types/errors.js +48 -24
  112. package/dist/cjs/providers/cognito/types/errors.js.map +1 -1
  113. package/dist/cjs/providers/cognito/utils/apiHelpers.js +2 -3
  114. package/dist/cjs/providers/cognito/utils/apiHelpers.js.map +1 -1
  115. package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js +1 -2
  116. package/dist/cjs/providers/cognito/utils/getNewDeviceMetadata.js.map +1 -1
  117. package/dist/cjs/providers/cognito/utils/handleDeviceSRPAuth.js +1 -2
  118. package/dist/cjs/providers/cognito/utils/handleDeviceSRPAuth.js.map +1 -1
  119. package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js +1 -2
  120. package/dist/cjs/providers/cognito/utils/handlePasswordVerifierChallenge.js.map +1 -1
  121. package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.js +2 -5
  122. package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.js.map +1 -1
  123. package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.native.js +1 -2
  124. package/dist/cjs/providers/cognito/utils/oauth/getRedirectUrl.native.js.map +1 -1
  125. package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js +1 -2
  126. package/dist/cjs/providers/cognito/utils/retryOnResourceNotFoundException.js.map +1 -1
  127. package/dist/cjs/providers/cognito/utils/setActiveSignInUsername.js +1 -2
  128. package/dist/cjs/providers/cognito/utils/setActiveSignInUsername.js.map +1 -1
  129. package/dist/cjs/providers/cognito/utils/signInHelpers.js +22 -23
  130. package/dist/cjs/providers/cognito/utils/signInHelpers.js.map +1 -1
  131. package/dist/cjs/providers/cognito/utils/signUpHelpers.js +3 -3
  132. package/dist/cjs/providers/cognito/utils/signUpHelpers.js.map +1 -1
  133. package/dist/cjs/providers/cognito/utils/types.js +6 -6
  134. package/dist/cjs/providers/cognito/utils/types.js.map +1 -1
  135. package/dist/cjs/providers/cognito/utils/userContextData.js +1 -2
  136. package/dist/cjs/providers/cognito/utils/userContextData.js.map +1 -1
  137. package/dist/cjs/providers/cognito/utils/userContextData.native.js +1 -2
  138. package/dist/cjs/providers/cognito/utils/userContextData.native.js.map +1 -1
  139. package/dist/cjs/types/Auth.js +2 -1
  140. package/dist/cjs/types/Auth.js.map +1 -1
  141. package/dist/esm/client/flows/shared/handlePasswordSRP.mjs +1 -0
  142. package/dist/esm/client/flows/shared/handlePasswordSRP.mjs.map +1 -1
  143. package/dist/esm/client/flows/userAuth/handleSelectChallenge.mjs +1 -0
  144. package/dist/esm/client/flows/userAuth/handleSelectChallenge.mjs.map +1 -1
  145. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs +1 -0
  146. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPassword.mjs.map +1 -1
  147. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs +1 -0
  148. package/dist/esm/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.mjs.map +1 -1
  149. package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs +1 -0
  150. package/dist/esm/client/flows/userAuth/handleUserAuthFlow.mjs.map +1 -1
  151. package/dist/esm/foundation/apis/deleteWebAuthnCredential.mjs +1 -0
  152. package/dist/esm/foundation/apis/deleteWebAuthnCredential.mjs.map +1 -1
  153. package/dist/esm/foundation/apis/listWebAuthnCredentials.mjs +1 -0
  154. package/dist/esm/foundation/apis/listWebAuthnCredentials.mjs.map +1 -1
  155. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/constants.d.ts +1 -1
  156. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createAssociateSoftwareTokenClient.d.ts +2 -2
  157. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createChangePasswordClient.d.ts +2 -2
  158. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createCompleteWebAuthnRegistrationClient.d.ts +2 -2
  159. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmDeviceClient.d.ts +2 -2
  160. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmForgotPasswordClient.d.ts +2 -2
  161. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createConfirmSignUpClient.d.ts +2 -2
  162. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteUserAttributesClient.d.ts +2 -2
  163. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteUserClient.d.ts +2 -2
  164. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createDeleteWebAuthnCredentialClient.d.ts +2 -2
  165. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createForgetDeviceClient.d.ts +2 -2
  166. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createForgotPasswordClient.d.ts +2 -2
  167. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserAttributeVerificationCodeClient.d.ts +2 -2
  168. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGetUserClient.d.ts +2 -2
  169. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createGlobalSignOutClient.d.ts +2 -2
  170. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createInitiateAuthClient.d.ts +2 -2
  171. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createListDevicesClient.d.ts +2 -2
  172. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createListWebAuthnCredentialsClient.d.ts +2 -2
  173. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createResendConfirmationCodeClient.d.ts +2 -2
  174. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createRespondToAuthChallengeClient.d.ts +2 -2
  175. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createRevokeTokenClient.d.ts +2 -2
  176. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSetUserMFAPreferenceClient.d.ts +2 -2
  177. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createSignUpClient.d.ts +3 -3
  178. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createStartWebAuthnRegistrationClient.d.ts +2 -2
  179. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createUpdateDeviceStatusClient.d.ts +2 -2
  180. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createUpdateUserAttributesClient.d.ts +2 -2
  181. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createVerifySoftwareTokenClient.d.ts +2 -2
  182. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/createVerifyUserAttributeClient.d.ts +2 -2
  183. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createEmptyResponseDeserializer.d.ts +1 -1
  184. package/dist/esm/foundation/factories/serviceClients/cognitoIdentityProvider/shared/serde/createUserPoolDeserializer.d.ts +1 -1
  185. package/dist/esm/providers/cognito/apis/internal/fetchUserAttributes.mjs +1 -0
  186. package/dist/esm/providers/cognito/apis/internal/fetchUserAttributes.mjs.map +1 -1
  187. package/dist/esm/providers/cognito/credentialsProvider/IdentityIdProvider.mjs +9 -1
  188. package/dist/esm/providers/cognito/credentialsProvider/IdentityIdProvider.mjs.map +1 -1
  189. package/dist/esm/providers/cognito/credentialsProvider/credentialsProvider.mjs +13 -1
  190. package/dist/esm/providers/cognito/credentialsProvider/credentialsProvider.mjs.map +1 -1
  191. package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.d.ts +6 -0
  192. package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.mjs +14 -0
  193. package/dist/esm/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.mjs.map +1 -0
  194. package/dist/esm/providers/cognito/factories/index.d.ts +1 -0
  195. package/dist/esm/providers/cognito/factories/index.mjs +1 -0
  196. package/dist/esm/providers/cognito/factories/index.mjs.map +1 -1
  197. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs +1 -0
  198. package/dist/esm/providers/cognito/utils/getNewDeviceMetadata.mjs.map +1 -1
  199. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs +1 -0
  200. package/dist/esm/providers/cognito/utils/handleDeviceSRPAuth.mjs.map +1 -1
  201. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs +1 -0
  202. package/dist/esm/providers/cognito/utils/handlePasswordVerifierChallenge.mjs.map +1 -1
  203. package/dist/esm/providers/cognito/utils/oauth/attemptCompleteOAuthFlow.d.ts +1 -1
  204. package/dist/esm/providers/cognito/utils/oauth/completeOAuthFlow.d.ts +1 -1
  205. package/dist/esm/providers/cognito/utils/oauth/generateCodeVerifier.d.ts +1 -1
  206. package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.mjs +1 -3
  207. package/dist/esm/providers/cognito/utils/oauth/getRedirectUrl.mjs.map +1 -1
  208. package/dist/esm/providers/cognito/utils/refreshAuthTokens.d.ts +1 -1
  209. package/dist/esm/providers/cognito/utils/refreshAuthTokens.mjs +1 -0
  210. package/dist/esm/providers/cognito/utils/refreshAuthTokens.mjs.map +1 -1
  211. package/dist/esm/providers/cognito/utils/signInHelpers.d.ts +1 -1
  212. package/package.json +105 -106
  213. package/src/providers/cognito/credentialsProvider/IdentityIdProvider.ts +8 -1
  214. package/src/providers/cognito/credentialsProvider/credentialsProvider.ts +14 -1
  215. package/src/providers/cognito/factories/createCognitoIdentityPoolEndpointResolver.ts +15 -0
  216. package/src/providers/cognito/factories/index.ts +1 -0
  217. package/src/providers/cognito/utils/oauth/getRedirectUrl.ts +1 -2
@@ -4,10 +4,10 @@ export declare const createListDevicesClient: (config: ServiceClientFactoryInput
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").ListDevicesRequest) => Promise<ListDevicesCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createListWebAuthnCredentialsClient: (config: ServiceClient
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").ListWebAuthnCredentialsInput) => Promise<ListWebAuthnCredentialsCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createResendConfirmationCodeClient: (config: ServiceClientF
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").ResendConfirmationCodeRequest) => Promise<ResendConfirmationCodeCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createRespondToAuthChallengeClient: (config: ServiceClientF
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").RespondToAuthChallengeRequest) => Promise<RespondToAuthChallengeCommandOutput>;
@@ -9,10 +9,10 @@ export declare const createRevokeTokenClient: (config: ServiceClientFactoryInput
9
9
  url: URL;
10
10
  })) | undefined;
11
11
  service?: string | undefined;
12
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
12
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
15
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
16
16
  } & {
17
17
  [x: string]: unknown;
18
18
  }, input: RevokeTokenInput) => Promise<RevokeTokenOutput>;
@@ -4,10 +4,10 @@ export declare const createSetUserMFAPreferenceClient: (config: ServiceClientFac
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").SetUserMFAPreferenceRequest) => Promise<SetUserMFAPreferenceCommandOutput>;
@@ -1,15 +1,15 @@
1
1
  import { HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
2
2
  import { ServiceClientFactoryInput, SignUpCommandOutput } from './types';
3
- export declare const createSignUpClientDeserializer: () => (response: HttpResponse) => Promise<SignUpCommandOutput>;
3
+ export declare const createSignUpClientDeserializer: () => ((response: HttpResponse) => Promise<SignUpCommandOutput>);
4
4
  export declare const createSignUpClient: (config: ServiceClientFactoryInput) => (config: {
5
5
  endpointResolver?: (((options: import("@aws-amplify/core/internals/aws-client-utils").EndpointResolverOptions, input?: any) => import("@aws-amplify/core/internals/aws-client-utils").Endpoint) & ((options: import("@aws-amplify/core/internals/aws-client-utils").EndpointResolverOptions) => {
6
6
  url: URL;
7
7
  })) | undefined;
8
8
  service?: string | undefined;
9
- retryDecider?: (((response?: HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
9
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
10
10
  computeDelay?: ((attempt: number) => number) | undefined;
11
11
  userAgentValue?: string | undefined;
12
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
12
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
13
13
  } & {
14
14
  [x: string]: unknown;
15
15
  }, input: import("./types").SignUpRequest) => Promise<SignUpCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createStartWebAuthnRegistrationClient: (config: ServiceClie
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").StartWebAuthnRegistrationRequest) => Promise<StartWebAuthnRegistrationCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createUpdateDeviceStatusClient: (config: ServiceClientFacto
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").UpdateDeviceStatusRequest) => Promise<UpdateDeviceStatusCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createUpdateUserAttributesClient: (config: ServiceClientFac
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").UpdateUserAttributesRequest) => Promise<UpdateUserAttributesCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createVerifySoftwareTokenClient: (config: ServiceClientFact
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").VerifySoftwareTokenRequest) => Promise<VerifySoftwareTokenCommandOutput>;
@@ -4,10 +4,10 @@ export declare const createVerifyUserAttributeClient: (config: ServiceClientFact
4
4
  url: URL;
5
5
  })) | undefined;
6
6
  service?: string | undefined;
7
- retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext | undefined) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
7
+ retryDecider?: (((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & ((response?: import("@aws-amplify/core/internals/aws-client-utils").HttpResponse, error?: unknown) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>)) | undefined;
8
8
  computeDelay?: ((attempt: number) => number) | undefined;
9
9
  userAgentValue?: string | undefined;
10
- cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
10
+ cache?: "default" | "no-store" | "force-cache" | "no-cache" | "only-if-cached" | "reload" | undefined;
11
11
  } & {
12
12
  [x: string]: unknown;
13
13
  }, input: import("./types").VerifyUserAttributeRequest) => Promise<VerifyUserAttributeCommandOutput>;
@@ -1,2 +1,2 @@
1
1
  import { HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
2
- export declare const createEmptyResponseDeserializer: <Output>() => (response: HttpResponse) => Promise<Output | undefined>;
2
+ export declare const createEmptyResponseDeserializer: <Output>() => ((response: HttpResponse) => Promise<Output | undefined>);
@@ -1,2 +1,2 @@
1
1
  import { HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
2
- export declare const createUserPoolDeserializer: <Output>() => (response: HttpResponse) => Promise<Output>;
2
+ export declare const createUserPoolDeserializer: <Output>() => ((response: HttpResponse) => Promise<Output>);
@@ -12,6 +12,7 @@ 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';
15
16
 
16
17
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
17
18
  // 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,7 +1,10 @@
1
- import { getId } from '@aws-amplify/core';
1
+ import { createGetIdClient } 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';
5
8
  import { formLoginsMap } from './utils.mjs';
6
9
 
7
10
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -36,6 +39,11 @@ async function cognitoIdentityIdProvider({ tokens, authConfig, identityIdStore,
36
39
  async function generateIdentityId(logins, authConfig) {
37
40
  const identityPoolId = authConfig?.identityPoolId;
38
41
  const region = getRegionFromIdentityPoolId(identityPoolId);
42
+ const getId = createGetIdClient({
43
+ endpointResolver: createCognitoIdentityPoolEndpointResolver({
44
+ endpointOverride: authConfig.identityPoolEndpoint,
45
+ }),
46
+ });
39
47
  // IdentityId is absent so get it using IdentityPoolId with Cognito's GetId API
40
48
  let idResult;
41
49
  // 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 { 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
+ {"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,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C1C,YAAY,OAAO,EAAE,kDAAkD;AACvE,YAAY,kBAAkB,EAAE,gEAAgE;AAChG,SAAS,CAAC;AACV;AACA,IAAI,OAAO,QAAQ;AACnB;;;;"}
@@ -1,9 +1,11 @@
1
- import { ConsoleLogger, getCredentialsForIdentity } from '@aws-amplify/core';
1
+ import { ConsoleLogger, createGetCredentialsForIdentityClient } 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';
7
9
  import { cognitoIdentityIdProvider } from './IdentityIdProvider.mjs';
8
10
  import { formLoginsMap } from './utils.mjs';
9
11
 
@@ -70,6 +72,11 @@ class CognitoAWSCredentialsAndIdentityIdProvider {
70
72
  // Clear to discard if any authenticated credentials are set and start with a clean slate
71
73
  this.clearCredentials();
72
74
  const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);
75
+ const getCredentialsForIdentity = createGetCredentialsForIdentityClient({
76
+ endpointResolver: createCognitoIdentityPoolEndpointResolver({
77
+ endpointOverride: authConfig.identityPoolEndpoint,
78
+ }),
79
+ });
73
80
  // use identityId to obtain guest credentials
74
81
  // save credentials in-memory
75
82
  // No logins params should be passed for guest creds:
@@ -129,6 +136,11 @@ class CognitoAWSCredentialsAndIdentityIdProvider {
129
136
  ? formLoginsMap(authTokens.idToken.toString())
130
137
  : {};
131
138
  const region = getRegionFromIdentityPoolId(authConfig.identityPoolId);
139
+ const getCredentialsForIdentity = createGetCredentialsForIdentityClient({
140
+ endpointResolver: createCognitoIdentityPoolEndpointResolver({
141
+ endpointOverride: authConfig.identityPoolEndpoint,
142
+ }),
143
+ });
132
144
  let clientResult;
133
145
  try {
134
146
  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, 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.idTo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ACnE,iBAAiB;AACjB,gBAAgB,UAAU;AAC1B,aAAa;AACb,YAAY,IAAI,YAAY,CAAC,UAAU,EAAE;AACzC,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
+ {"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?.to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AC,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;;;;"}
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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 +1,2 @@
1
1
  export { createCognitoUserPoolEndpointResolver } from './createCognitoUserPoolEndpointResolver';
2
+ export { createCognitoIdentityPoolEndpointResolver } from './createCognitoIdentityPoolEndpointResolver';
@@ -1,2 +1,3 @@
1
1
  export { createCognitoUserPoolEndpointResolver } from './createCognitoUserPoolEndpointResolver.mjs';
2
+ export { createCognitoIdentityPoolEndpointResolver } from './createCognitoIdentityPoolEndpointResolver.mjs';
2
3
  //# 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,6 +8,7 @@ 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';
11
12
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
12
13
  import { getAuthenticationHelper } from './srp/getAuthenticationHelper.mjs';
13
14
  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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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;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;;;;"}
@@ -8,6 +8,7 @@ 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';
11
12
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
12
13
  import { assertDeviceMetadata } from './types.mjs';
13
14
  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,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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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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;;;;"}
@@ -9,6 +9,7 @@ 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';
12
13
  import { getRegionFromUserPoolId } from '../../../foundation/parsers/regionParsers.mjs';
13
14
  import BigInteger from './srp/BigInteger/BigInteger.mjs';
14
15
  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,GAAG,IAAI,UAAU,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC;AACvE,IAAI,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC;AAC9D,IAAI,MAAM,QAAQ,GAAG,mBAAmB,EAAE,eAAe;AACzD,IAAI,IAAI,CAAC,QAAQ;AACjB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,4BAA4B;AAC9C,YAAY,OAAO,EAAE,sDAAsD;AAC3E,SAAS,CAAC;AACV,IAAI,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,4BAA4B,CAAC;AACzE,QAAQ,QAAQ;AAChB,QAAQ,QAAQ;AAChB,QAAQ,YAAY;AACpB,QAAQ,IAAI;AACZ,KAAK,CAAC;AACN,IAAI,MAAM,OAAO,GAAG,YAAY,EAAE;AAClC,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,2BAA2B,EAAE,mBAAmB,EAAE,YAAY;AACtE,QAAQ,SAAS,EAAE,OAAO;AAC1B,QAAQ,wBAAwB,EA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;;"}
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,GAAG,IAAI,UAAU,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC;AACvE,IAAI,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC;AAC9D,IAAI,MAAM,QAAQ,GAAG,mBAAmB,EAAE,eAAe;AACzD,IAAI,IAAI,CAAC,QAAQ;AACjB,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC5B,YAAY,IAAI,EAAE,4BAA4B;AAC9C,YAAY,OAAO,EAAE,sDAAsD;AAC3E,SAAS,CAAC;AACV,IAAI,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,4BAA4B,CAAC;AACzE,QAAQ,QAAQ;AAChB,QAAQ,QAAQ;AAChB,QAAQ,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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,2 +1,2 @@
1
1
  import { AuthConfig } from '@aws-amplify/core';
2
- export declare const attemptCompleteOAuthFlow: (authConfig: AuthConfig['Cognito']) => Promise<void>;
2
+ export declare const attemptCompleteOAuthFlow: (authConfig: AuthConfig["Cognito"]) => Promise<void>;
@@ -5,5 +5,5 @@ export declare const completeOAuthFlow: ({ currentUrl, userAgentValue, clientId,
5
5
  redirectUri: string;
6
6
  responseType: string;
7
7
  domain: string;
8
- preferPrivateSession?: boolean | undefined;
8
+ preferPrivateSession?: boolean;
9
9
  }) => Promise<void>;
@@ -11,6 +11,6 @@
11
11
  */
12
12
  export declare const generateCodeVerifier: (length: number) => {
13
13
  value: string;
14
- method: 'S256';
14
+ method: "S256";
15
15
  toCodeChallenge(): string;
16
16
  };