@aws-amplify/ui 6.9.1 → 6.10.1

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 (44) hide show
  1. package/dist/esm/helpers/authenticator/facade.mjs +4 -2
  2. package/dist/esm/helpers/authenticator/formFields/defaults.mjs +4 -0
  3. package/dist/esm/helpers/authenticator/getRoute.mjs +4 -0
  4. package/dist/esm/helpers/authenticator/textUtil.mjs +30 -0
  5. package/dist/esm/i18n/dictionaries/authenticator/de.mjs +8 -0
  6. package/dist/esm/i18n/dictionaries/authenticator/defaultTexts.mjs +8 -0
  7. package/dist/esm/i18n/dictionaries/authenticator/en.mjs +8 -0
  8. package/dist/esm/i18n/dictionaries/authenticator/es.mjs +8 -0
  9. package/dist/esm/i18n/dictionaries/authenticator/fr.mjs +8 -0
  10. package/dist/esm/i18n/dictionaries/authenticator/he.mjs +8 -0
  11. package/dist/esm/i18n/dictionaries/authenticator/id.mjs +8 -0
  12. package/dist/esm/i18n/dictionaries/authenticator/it.mjs +8 -0
  13. package/dist/esm/i18n/dictionaries/authenticator/ja.mjs +8 -0
  14. package/dist/esm/i18n/dictionaries/authenticator/kr.mjs +8 -0
  15. package/dist/esm/i18n/dictionaries/authenticator/nb.mjs +8 -0
  16. package/dist/esm/i18n/dictionaries/authenticator/nl.mjs +8 -0
  17. package/dist/esm/i18n/dictionaries/authenticator/pl.mjs +8 -0
  18. package/dist/esm/i18n/dictionaries/authenticator/pt.mjs +8 -0
  19. package/dist/esm/i18n/dictionaries/authenticator/ru.mjs +8 -0
  20. package/dist/esm/i18n/dictionaries/authenticator/sv.mjs +8 -0
  21. package/dist/esm/i18n/dictionaries/authenticator/th.mjs +8 -0
  22. package/dist/esm/i18n/dictionaries/authenticator/tr.mjs +9 -1
  23. package/dist/esm/i18n/dictionaries/authenticator/ua.mjs +8 -0
  24. package/dist/esm/i18n/dictionaries/authenticator/zh.mjs +8 -0
  25. package/dist/esm/machines/authenticator/actions.mjs +22 -5
  26. package/dist/esm/machines/authenticator/actors/signIn.mjs +53 -49
  27. package/dist/esm/machines/authenticator/actors/signUp.mjs +2 -0
  28. package/dist/esm/machines/authenticator/actors/utils.mjs +13 -1
  29. package/dist/esm/machines/authenticator/guards.mjs +13 -1
  30. package/dist/esm/machines/authenticator/index.mjs +2 -1
  31. package/dist/esm/utils/utils.mjs +1 -1
  32. package/dist/index.js +306 -59
  33. package/dist/types/helpers/authenticator/facade.d.ts +4 -2
  34. package/dist/types/helpers/authenticator/textUtil.d.ts +7 -1
  35. package/dist/types/i18n/dictionaries/authenticator/defaultTexts.d.ts +8 -0
  36. package/dist/types/i18n/dictionaries/index.d.ts +8 -0
  37. package/dist/types/i18n/translations.d.ts +8 -0
  38. package/dist/types/machines/authenticator/actors/signIn.d.ts +2 -3
  39. package/dist/types/machines/authenticator/actors/signUp.d.ts +2 -3
  40. package/dist/types/machines/authenticator/actors/utils.d.ts +2 -0
  41. package/dist/types/machines/authenticator/types.d.ts +6 -3
  42. package/dist/types/types/authenticator/form.d.ts +1 -1
  43. package/dist/types/utils/utils.d.ts +1 -1
  44. package/package.json +2 -2
@@ -40,6 +40,7 @@ const handleAutoSignInResponse = {
40
40
  'setChallengeName',
41
41
  'setMissingAttributes',
42
42
  'setTotpSecretCode',
43
+ 'setAllowedMfaTypes',
43
44
  ],
44
45
  target: '#signUpActor.resolved',
45
46
  },
@@ -243,6 +244,7 @@ function signUpActor({ services }) {
243
244
  totpSecretCode: context.totpSecretCode,
244
245
  username: context.username,
245
246
  unverifiedUserAttributes: context.unverifiedUserAttributes,
247
+ allowedMfaTypes: context.allowedMfaTypes,
246
248
  }),
247
249
  },
248
250
  },
@@ -6,5 +6,17 @@ const getFederatedSignInState = (target) => ({
6
6
  onError: { actions: 'setRemoteError', target },
7
7
  },
8
8
  });
9
+ const getConfirmSignInFormValuesKey = (signInStep) => {
10
+ if ([
11
+ 'CONTINUE_SIGN_IN_WITH_MFA_SELECTION',
12
+ 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION',
13
+ ].includes(signInStep)) {
14
+ return 'mfa_type';
15
+ }
16
+ if (signInStep === 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP') {
17
+ return 'email';
18
+ }
19
+ return 'confirmation_code';
20
+ };
9
21
 
10
- export { getFederatedSignInState };
22
+ export { getConfirmSignInFormValuesKey, getFederatedSignInState };
@@ -1,6 +1,7 @@
1
1
  const SIGN_IN_STEP_MFA_CONFIRMATION = [
2
2
  'CONFIRM_SIGN_IN_WITH_SMS_CODE',
3
3
  'CONFIRM_SIGN_IN_WITH_TOTP_CODE',
4
+ 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE',
4
5
  ];
5
6
  // response next step guards
6
7
  const shouldConfirmSignInWithNewPassword = (_, { data }) => data?.nextStep.signInStep ===
@@ -20,12 +21,21 @@ const isConfirmSignUpStep = (_, { data }) => data?.step === 'CONFIRM_SIGN_UP';
20
21
  // actor entry guards read `step` from actor context
21
22
  const shouldConfirmSignIn = ({ step }) => SIGN_IN_STEP_MFA_CONFIRMATION.includes(step);
22
23
  const shouldSetupTotp = ({ step }) => step === 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP';
24
+ const shouldSetupEmail = ({ step }) => step === 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP';
25
+ const shouldSelectMfaType = ({ step }) => [
26
+ 'CONTINUE_SIGN_IN_WITH_MFA_SELECTION',
27
+ 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION',
28
+ ].includes(step);
23
29
  const shouldResetPassword = ({ step }) => step === 'RESET_PASSWORD';
24
30
  const shouldConfirmResetPassword = ({ step }) => step === 'CONFIRM_RESET_PASSWORD_WITH_CODE';
25
31
  const shouldConfirmSignUp = ({ step }) => step === 'CONFIRM_SIGN_UP';
26
32
  // miscellaneous guards
27
33
  const shouldVerifyAttribute = (_, { data }) => {
28
- const { phone_number_verified, email_verified } = data;
34
+ const { email, phone_number, phone_number_verified, email_verified } = data;
35
+ // if neither email nor phone_number exist
36
+ // there is nothing to verify
37
+ if (!email && !phone_number)
38
+ return false;
29
39
  // email/phone_verified is returned as a string
30
40
  const emailNotVerified = email_verified === undefined || email_verified === 'false';
31
41
  const phoneNotVerified = phone_number_verified === undefined || phone_number_verified === 'false';
@@ -64,6 +74,8 @@ const GUARDS = {
64
74
  shouldResetPassword,
65
75
  shouldResetPasswordFromSignIn,
66
76
  shouldSetupTotp,
77
+ shouldSetupEmail,
78
+ shouldSelectMfaType,
67
79
  shouldVerifyAttribute,
68
80
  };
69
81
 
@@ -275,7 +275,7 @@ function createAuthenticatorMachine(options) {
275
275
  { cond: 'hasActor', actions: forwardTo(({ actorRef }) => actorRef) },
276
276
  ]),
277
277
  setActorDoneData: assign({
278
- actorDoneData: (context, event) => ({
278
+ actorDoneData: (_, event) => ({
279
279
  challengeName: event.data.challengeName,
280
280
  codeDeliveryDetails: event.data.codeDeliveryDetails,
281
281
  missingAttributes: event.data.missingAttributes,
@@ -284,6 +284,7 @@ function createAuthenticatorMachine(options) {
284
284
  step: event.data.step,
285
285
  totpSecretCode: event.data.totpSecretCode,
286
286
  unverifiedUserAttributes: event.data.unverifiedUserAttributes,
287
+ allowedMfaTypes: event.data.allowedMfaTypes,
287
288
  }),
288
289
  }),
289
290
  applyAmplifyConfig: assign({
@@ -184,7 +184,7 @@ const classNameModifierByFlag = (base, modifier, flag) => {
184
184
  * @returns formatted string array
185
185
  */
186
186
  function templateJoin(values, template) {
187
- return values.reduce((acc, curr) => `${acc}${isString(curr) ? template(curr) : ''}`, '');
187
+ return values.reduce((acc, curr, index) => `${acc}${isString(curr) ? template(curr, index, values) : ''}`, '');
188
188
  }
189
189
  /**
190
190
  * A function that does nothing