@ttoss/react-auth 1.6.41 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -120,7 +120,7 @@ var useAuth = () => {
120
120
  };
121
121
 
122
122
  // src/Auth.tsx
123
- var React5 = __toESM(require("react"));
123
+ var React6 = __toESM(require("react"));
124
124
  var import_aws_amplify2 = require("aws-amplify");
125
125
 
126
126
  // src/AuthCard.tsx
@@ -280,32 +280,115 @@ var AuthConfirmSignUp = ({
280
280
  });
281
281
  };
282
282
 
283
- // src/AuthFullScreen.tsx
283
+ // src/AuthForgotPassword.tsx
284
284
  var import_ui2 = require("@ttoss/ui");
285
+ var import_forms2 = require("@ttoss/forms");
286
+ var import_react_notifications2 = require("@ttoss/react-notifications");
287
+ var import_react_i18n2 = require("@ttoss/react-i18n");
285
288
  var import_jsx_runtime4 = require("react/jsx-runtime");
286
- var AuthFullScreen = ({
287
- children
289
+ var AuthForgotPassword = ({
290
+ onForgotPassword,
291
+ onCancel,
292
+ onSignUp
288
293
  }) => {
289
- return /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui2.Flex, {
294
+ const {
295
+ intl
296
+ } = (0, import_react_i18n2.useI18n)();
297
+ const schema = import_forms2.yup.object().shape({
298
+ email: import_forms2.yup.string().required(intl.formatMessage({
299
+ id: "5oOshZ",
300
+ defaultMessage: [{
301
+ "type": 0,
302
+ "value": "Enter your email address"
303
+ }]
304
+ })).email(intl.formatMessage({
305
+ id: "SnONhb",
306
+ defaultMessage: [{
307
+ "type": 0,
308
+ "value": "Please, insert a valid e-mail"
309
+ }]
310
+ }))
311
+ }).required();
312
+ const formMethods = (0, import_forms2.useForm)({
313
+ resolver: (0, import_forms2.yupResolver)(schema),
314
+ mode: "onBlur"
315
+ });
316
+ return /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_forms2.Form, {
317
+ ...formMethods,
290
318
  sx: {
291
- height: "100vh",
292
- width: "100vw",
293
- justifyContent: "center",
294
- alignItems: "center",
295
- margin: 0,
296
- backgroundPosition: "center",
297
- backgroundRepeat: "no-repeat",
298
- backgroundSize: "cover"
319
+ maxWidth: "390px"
299
320
  },
300
- children
321
+ onSubmit: ({
322
+ email
323
+ }) => {
324
+ return onForgotPassword({
325
+ email
326
+ });
327
+ },
328
+ children: /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(AuthCard, {
329
+ buttonLabel: intl.formatMessage({
330
+ id: "mZzmNV",
331
+ defaultMessage: [{
332
+ "type": 0,
333
+ "value": "Recover Password"
334
+ }]
335
+ }),
336
+ isValidForm: formMethods.formState.isValid,
337
+ title: intl.formatMessage({
338
+ id: "S4bbEj",
339
+ defaultMessage: [{
340
+ "type": 0,
341
+ "value": "Recovering Password"
342
+ }]
343
+ }),
344
+ extraButton: /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui2.Button, {
345
+ sx: {
346
+ textAlign: "center",
347
+ display: "initial"
348
+ },
349
+ variant: "secondary",
350
+ onClick: onCancel,
351
+ children: intl.formatMessage({
352
+ id: "6PdOcy",
353
+ defaultMessage: [{
354
+ "type": 0,
355
+ "value": "Cancel"
356
+ }]
357
+ })
358
+ }),
359
+ children: [/* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_forms2.FormFieldInput, {
360
+ name: "email",
361
+ label: intl.formatMessage({
362
+ id: "XreZg+",
363
+ defaultMessage: [{
364
+ "type": 0,
365
+ "value": "Registered Email"
366
+ }]
367
+ })
368
+ }), /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_react_notifications2.NotificationsBox, {}), /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui2.Text, {
369
+ sx: {
370
+ marginTop: "xl",
371
+ cursor: "pointer"
372
+ },
373
+ as: import_ui2.Link,
374
+ onClick: onSignUp,
375
+ children: intl.formatMessage({
376
+ id: "lZvoYL",
377
+ defaultMessage: [{
378
+ "type": 0,
379
+ "value": "Sign up now"
380
+ }]
381
+ })
382
+ })]
383
+ })
301
384
  });
302
385
  };
303
386
 
304
- // src/AuthSignIn.tsx
387
+ // src/AuthForgotPasswordResetPassword.tsx
305
388
  var React3 = __toESM(require("react"));
306
389
  var import_ui3 = require("@ttoss/ui");
307
- var import_forms2 = require("@ttoss/forms");
308
- var import_react_notifications2 = require("@ttoss/react-notifications");
390
+ var import_forms3 = require("@ttoss/forms");
391
+ var import_react_notifications3 = require("@ttoss/react-notifications");
309
392
 
310
393
  // ../cloud-auth/dist/esm/index.js
311
394
  var PASSWORD_MINIMUM_LENGTH = 8;
@@ -550,9 +633,186 @@ createAuthTemplate.CognitoUserPoolLogicalId = CognitoUserPoolLogicalId;
550
633
  createAuthTemplate.CognitoUserPoolClientLogicalId = CognitoUserPoolClientLogicalId;
551
634
  createAuthTemplate.CognitoIdentityPoolLogicalId = CognitoIdentityPoolLogicalId;
552
635
 
553
- // src/AuthSignIn.tsx
554
- var import_react_i18n2 = require("@ttoss/react-i18n");
636
+ // src/AuthForgotPasswordResetPassword.tsx
637
+ var import_react_i18n3 = require("@ttoss/react-i18n");
555
638
  var import_jsx_runtime5 = require("react/jsx-runtime");
639
+ var AuthForgotPasswordResetPassword = ({
640
+ email,
641
+ onForgotPasswordResetPassword,
642
+ onCancel
643
+ }) => {
644
+ const {
645
+ intl
646
+ } = (0, import_react_i18n3.useI18n)();
647
+ const schema = React3.useMemo(() => {
648
+ return import_forms3.yup.object().shape({
649
+ code: import_forms3.yup.string().required(intl.formatMessage({
650
+ id: "0XOzcH",
651
+ defaultMessage: [{
652
+ "type": 0,
653
+ "value": "Required field"
654
+ }]
655
+ })).max(6, intl.formatMessage({
656
+ id: "S3pjKw",
657
+ defaultMessage: [{
658
+ "type": 0,
659
+ "value": "Minimum "
660
+ }, {
661
+ "type": 1,
662
+ "value": "value"
663
+ }, {
664
+ "type": 0,
665
+ "value": " characters"
666
+ }]
667
+ }, {
668
+ value: 6
669
+ })),
670
+ password: import_forms3.yup.string().required(intl.formatMessage({
671
+ id: "kdFYba",
672
+ defaultMessage: [{
673
+ "type": 0,
674
+ "value": "Password field is required"
675
+ }]
676
+ })).min(PASSWORD_MINIMUM_LENGTH, intl.formatMessage({
677
+ id: "TZ4WUk",
678
+ defaultMessage: [{
679
+ "type": 0,
680
+ "value": "Password requires "
681
+ }, {
682
+ "type": 1,
683
+ "value": "value"
684
+ }, {
685
+ "type": 0,
686
+ "value": " characters"
687
+ }]
688
+ }, {
689
+ value: PASSWORD_MINIMUM_LENGTH
690
+ })).trim(),
691
+ confirmPassword: import_forms3.yup.string().required(intl.formatMessage({
692
+ id: "NJ57Qj",
693
+ defaultMessage: [{
694
+ "type": 0,
695
+ "value": "Confirm password field is required"
696
+ }]
697
+ })).oneOf([import_forms3.yup.ref("password")], intl.formatMessage({
698
+ id: "WU/CqP",
699
+ defaultMessage: [{
700
+ "type": 0,
701
+ "value": "Passwords are not the same"
702
+ }]
703
+ }))
704
+ }).required();
705
+ }, [intl]);
706
+ const formMethods = (0, import_forms3.useForm)({
707
+ resolver: (0, import_forms3.yupResolver)(schema),
708
+ mode: "onBlur"
709
+ });
710
+ return /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms3.Form, {
711
+ ...formMethods,
712
+ sx: {
713
+ maxWidth: "390px"
714
+ },
715
+ onSubmit: ({
716
+ code,
717
+ password
718
+ }) => {
719
+ return onForgotPasswordResetPassword({
720
+ email,
721
+ code,
722
+ newPassword: password
723
+ });
724
+ },
725
+ children: /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(AuthCard, {
726
+ buttonLabel: intl.formatMessage({
727
+ id: "mZzmNV",
728
+ defaultMessage: [{
729
+ "type": 0,
730
+ "value": "Recover Password"
731
+ }]
732
+ }),
733
+ isValidForm: formMethods.formState.isValid,
734
+ title: intl.formatMessage({
735
+ id: "S4bbEj",
736
+ defaultMessage: [{
737
+ "type": 0,
738
+ "value": "Recovering Password"
739
+ }]
740
+ }),
741
+ extraButton: /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Button, {
742
+ sx: {
743
+ textAlign: "center",
744
+ display: "initial"
745
+ },
746
+ variant: "secondary",
747
+ onClick: onCancel,
748
+ children: intl.formatMessage({
749
+ id: "6PdOcy",
750
+ defaultMessage: [{
751
+ "type": 0,
752
+ "value": "Cancel"
753
+ }]
754
+ })
755
+ }),
756
+ children: [/* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms3.FormFieldInput, {
757
+ name: "code",
758
+ label: intl.formatMessage({
759
+ id: "42HafR",
760
+ defaultMessage: [{
761
+ "type": 0,
762
+ "value": "Code"
763
+ }]
764
+ })
765
+ }), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms3.FormFieldPassword, {
766
+ name: "password",
767
+ label: intl.formatMessage({
768
+ id: "PylVqx",
769
+ defaultMessage: [{
770
+ "type": 0,
771
+ "value": "Password"
772
+ }]
773
+ })
774
+ }), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms3.FormFieldPassword, {
775
+ name: "confirmPassword",
776
+ label: intl.formatMessage({
777
+ id: "lY+cuM",
778
+ defaultMessage: [{
779
+ "type": 0,
780
+ "value": "Confirm password"
781
+ }]
782
+ })
783
+ }), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_react_notifications3.NotificationsBox, {})]
784
+ })
785
+ });
786
+ };
787
+
788
+ // src/AuthFullScreen.tsx
789
+ var import_ui4 = require("@ttoss/ui");
790
+ var import_jsx_runtime6 = require("react/jsx-runtime");
791
+ var AuthFullScreen = ({
792
+ children
793
+ }) => {
794
+ return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui4.Flex, {
795
+ sx: {
796
+ height: "100vh",
797
+ width: "100vw",
798
+ justifyContent: "center",
799
+ alignItems: "center",
800
+ margin: 0,
801
+ backgroundPosition: "center",
802
+ backgroundRepeat: "no-repeat",
803
+ backgroundSize: "cover"
804
+ },
805
+ children
806
+ });
807
+ };
808
+
809
+ // src/AuthSignIn.tsx
810
+ var React4 = __toESM(require("react"));
811
+ var import_ui5 = require("@ttoss/ui");
812
+ var import_forms4 = require("@ttoss/forms");
813
+ var import_react_notifications4 = require("@ttoss/react-notifications");
814
+ var import_react_i18n4 = require("@ttoss/react-i18n");
815
+ var import_jsx_runtime7 = require("react/jsx-runtime");
556
816
  var AuthSignIn = ({
557
817
  onSignIn,
558
818
  onSignUp,
@@ -561,15 +821,15 @@ var AuthSignIn = ({
561
821
  }) => {
562
822
  const {
563
823
  intl
564
- } = (0, import_react_i18n2.useI18n)();
824
+ } = (0, import_react_i18n4.useI18n)();
565
825
  const {
566
826
  setNotifications
567
- } = (0, import_react_notifications2.useNotifications)();
568
- React3.useEffect(() => {
827
+ } = (0, import_react_notifications4.useNotifications)();
828
+ React4.useEffect(() => {
569
829
  setNotifications(void 0);
570
830
  }, [setNotifications]);
571
- const schema = import_forms2.yup.object().shape({
572
- email: import_forms2.yup.string().required(intl.formatMessage({
831
+ const schema = import_forms4.yup.object().shape({
832
+ email: import_forms4.yup.string().required(intl.formatMessage({
573
833
  id: "d1YCuH",
574
834
  defaultMessage: [{
575
835
  "type": 0,
@@ -582,7 +842,7 @@ var AuthSignIn = ({
582
842
  "value": "Please, insert a valid e-mail"
583
843
  }]
584
844
  })),
585
- password: import_forms2.yup.string().required(intl.formatMessage({
845
+ password: import_forms4.yup.string().required(intl.formatMessage({
586
846
  id: "kdFYba",
587
847
  defaultMessage: [{
588
848
  "type": 0,
@@ -606,22 +866,22 @@ var AuthSignIn = ({
606
866
  // remember: yup.boolean(),
607
867
  });
608
868
 
609
- const formMethods = (0, import_forms2.useForm)({
869
+ const formMethods = (0, import_forms4.useForm)({
610
870
  defaultValues,
611
871
  mode: "onBlur",
612
- resolver: (0, import_forms2.yupResolver)(schema)
872
+ resolver: (0, import_forms4.yupResolver)(schema)
613
873
  });
614
874
  const onSubmitForm = data => {
615
875
  return onSignIn(data);
616
876
  };
617
- return /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms2.Form, {
877
+ return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_forms4.Form, {
618
878
  sx: {
619
879
  maxWidth: "390px",
620
880
  width: "100%"
621
881
  },
622
882
  ...formMethods,
623
883
  onSubmit: onSubmitForm,
624
- children: /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(AuthCard, {
884
+ children: /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(AuthCard, {
625
885
  title: intl.formatMessage({
626
886
  id: "F2iS37",
627
887
  defaultMessage: [{
@@ -637,7 +897,7 @@ var AuthSignIn = ({
637
897
  }]
638
898
  }),
639
899
  isValidForm: formMethods.formState.isValid,
640
- extraButton: /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Button, {
900
+ extraButton: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui5.Button, {
641
901
  type: "button",
642
902
  variant: "secondary",
643
903
  sx: {
@@ -654,12 +914,12 @@ var AuthSignIn = ({
654
914
  }]
655
915
  })
656
916
  }),
657
- children: [/* @__PURE__ */(0, import_jsx_runtime5.jsxs)(import_ui3.Flex, {
917
+ children: [/* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_ui5.Flex, {
658
918
  sx: {
659
919
  flexDirection: "column",
660
920
  gap: "xl"
661
921
  },
662
- children: [/* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms2.FormFieldInput, {
922
+ children: [/* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_forms4.FormFieldInput, {
663
923
  name: "email",
664
924
  label: intl.formatMessage({
665
925
  id: "5E12mO",
@@ -668,7 +928,7 @@ var AuthSignIn = ({
668
928
  "value": "Email"
669
929
  }]
670
930
  })
671
- }), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms2.FormFieldPassword, {
931
+ }), /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_forms4.FormFieldPassword, {
672
932
  name: "password",
673
933
  label: intl.formatMessage({
674
934
  id: "PylVqx",
@@ -678,16 +938,17 @@ var AuthSignIn = ({
678
938
  }]
679
939
  })
680
940
  })]
681
- }), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Flex, {
941
+ }), /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui5.Flex, {
682
942
  sx: {
683
943
  justifyContent: "space-between",
684
944
  marginTop: "lg"
685
945
  },
686
- children: /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Text, {
946
+ children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui5.Text, {
687
947
  sx: {
688
- marginLeft: "auto"
948
+ marginLeft: "auto",
949
+ cursor: "pointer"
689
950
  },
690
- as: import_ui3.Link,
951
+ as: import_ui5.Link,
691
952
  onClick: onForgotPassword,
692
953
  children: intl.formatMessage({
693
954
  id: "BtK6KR",
@@ -697,33 +958,33 @@ var AuthSignIn = ({
697
958
  }]
698
959
  })
699
960
  })
700
- }), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_react_notifications2.NotificationsBox, {})]
961
+ }), /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_react_notifications4.NotificationsBox, {})]
701
962
  })
702
963
  });
703
964
  };
704
965
 
705
966
  // src/AuthSignUp.tsx
706
- var React4 = __toESM(require("react"));
707
- var import_ui4 = require("@ttoss/ui");
708
- var import_forms3 = require("@ttoss/forms");
709
- var import_react_notifications3 = require("@ttoss/react-notifications");
710
- var import_react_i18n3 = require("@ttoss/react-i18n");
711
- var import_jsx_runtime6 = require("react/jsx-runtime");
967
+ var React5 = __toESM(require("react"));
968
+ var import_ui6 = require("@ttoss/ui");
969
+ var import_forms5 = require("@ttoss/forms");
970
+ var import_react_notifications5 = require("@ttoss/react-notifications");
971
+ var import_react_i18n5 = require("@ttoss/react-i18n");
972
+ var import_jsx_runtime8 = require("react/jsx-runtime");
712
973
  var AuthSignUp = ({
713
974
  onSignUp,
714
975
  onReturnToSignIn
715
976
  }) => {
716
977
  const {
717
978
  intl
718
- } = (0, import_react_i18n3.useI18n)();
979
+ } = (0, import_react_i18n5.useI18n)();
719
980
  const {
720
981
  setNotifications
721
- } = (0, import_react_notifications3.useNotifications)();
722
- React4.useEffect(() => {
982
+ } = (0, import_react_notifications5.useNotifications)();
983
+ React5.useEffect(() => {
723
984
  setNotifications(void 0);
724
985
  }, [setNotifications]);
725
- const schema = import_forms3.yup.object().shape({
726
- email: import_forms3.yup.string().required(intl.formatMessage({
986
+ const schema = import_forms5.yup.object().shape({
987
+ email: import_forms5.yup.string().required(intl.formatMessage({
727
988
  id: "d1YCuH",
728
989
  defaultMessage: [{
729
990
  "type": 0,
@@ -736,7 +997,7 @@ var AuthSignUp = ({
736
997
  "value": "Invalid email"
737
998
  }]
738
999
  })),
739
- password: import_forms3.yup.string().required(intl.formatMessage({
1000
+ password: import_forms5.yup.string().required(intl.formatMessage({
740
1001
  id: "kdFYba",
741
1002
  defaultMessage: [{
742
1003
  "type": 0,
@@ -757,13 +1018,13 @@ var AuthSignUp = ({
757
1018
  }, {
758
1019
  value: PASSWORD_MINIMUM_LENGTH
759
1020
  })).trim(),
760
- confirmPassword: import_forms3.yup.string().required(intl.formatMessage({
1021
+ confirmPassword: import_forms5.yup.string().required(intl.formatMessage({
761
1022
  id: "NJ57Qj",
762
1023
  defaultMessage: [{
763
1024
  "type": 0,
764
1025
  "value": "Confirm password field is required"
765
1026
  }]
766
- })).oneOf([import_forms3.yup.ref("password")], intl.formatMessage({
1027
+ })).oneOf([import_forms5.yup.ref("password")], intl.formatMessage({
767
1028
  id: "WU/CqP",
768
1029
  defaultMessage: [{
769
1030
  "type": 0,
@@ -771,21 +1032,21 @@ var AuthSignUp = ({
771
1032
  }]
772
1033
  }))
773
1034
  });
774
- const formMethods = (0, import_forms3.useForm)({
1035
+ const formMethods = (0, import_forms5.useForm)({
775
1036
  mode: "all",
776
- resolver: (0, import_forms3.yupResolver)(schema)
1037
+ resolver: (0, import_forms5.yupResolver)(schema)
777
1038
  });
778
1039
  const onSubmitForm = data => {
779
1040
  return onSignUp(data);
780
1041
  };
781
- return /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.Form, {
1042
+ return /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_forms5.Form, {
782
1043
  sx: {
783
1044
  maxWidth: "390px",
784
1045
  width: "100%"
785
1046
  },
786
1047
  ...formMethods,
787
1048
  onSubmit: onSubmitForm,
788
- children: /* @__PURE__ */(0, import_jsx_runtime6.jsxs)(AuthCard, {
1049
+ children: /* @__PURE__ */(0, import_jsx_runtime8.jsxs)(AuthCard, {
789
1050
  buttonLabel: intl.formatMessage({
790
1051
  id: "URJDrG",
791
1052
  defaultMessage: [{
@@ -801,12 +1062,12 @@ var AuthSignUp = ({
801
1062
  }]
802
1063
  }),
803
1064
  isValidForm: formMethods.formState.isValid,
804
- extraButton: /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui4.Text, {
1065
+ extraButton: /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_ui6.Text, {
805
1066
  sx: {
806
1067
  cursor: "pointer"
807
1068
  },
808
1069
  onClick: onReturnToSignIn,
809
- as: import_ui4.Link,
1070
+ as: import_ui6.Link,
810
1071
  children: intl.formatMessage({
811
1072
  id: "rx8HF/",
812
1073
  defaultMessage: [{
@@ -815,12 +1076,12 @@ var AuthSignUp = ({
815
1076
  }]
816
1077
  })
817
1078
  }),
818
- children: [/* @__PURE__ */(0, import_jsx_runtime6.jsxs)(import_ui4.Flex, {
1079
+ children: [/* @__PURE__ */(0, import_jsx_runtime8.jsxs)(import_ui6.Flex, {
819
1080
  sx: {
820
1081
  flexDirection: "column",
821
1082
  gap: "xl"
822
1083
  },
823
- children: [/* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.FormFieldInput, {
1084
+ children: [/* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_forms5.FormFieldInput, {
824
1085
  name: "email",
825
1086
  label: intl.formatMessage({
826
1087
  id: "5E12mO",
@@ -829,7 +1090,7 @@ var AuthSignUp = ({
829
1090
  "value": "Email"
830
1091
  }]
831
1092
  })
832
- }), /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.FormFieldPassword, {
1093
+ }), /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_forms5.FormFieldPassword, {
833
1094
  name: "password",
834
1095
  label: intl.formatMessage({
835
1096
  id: "PylVqx",
@@ -838,7 +1099,7 @@ var AuthSignUp = ({
838
1099
  "value": "Password"
839
1100
  }]
840
1101
  })
841
- }), /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.FormFieldPassword, {
1102
+ }), /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_forms5.FormFieldPassword, {
842
1103
  name: "confirmPassword",
843
1104
  label: intl.formatMessage({
844
1105
  id: "lY+cuM",
@@ -848,7 +1109,7 @@ var AuthSignUp = ({
848
1109
  }]
849
1110
  })
850
1111
  })]
851
- }), /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_react_notifications3.NotificationsBox, {})]
1112
+ }), /* @__PURE__ */(0, import_jsx_runtime8.jsx)(import_react_notifications5.NotificationsBox, {})]
852
1113
  })
853
1114
  });
854
1115
  };
@@ -856,8 +1117,8 @@ var AuthSignUp = ({
856
1117
  // src/Auth.tsx
857
1118
  var import_xstate = require("xstate");
858
1119
  var import_react = require("@xstate/react");
859
- var import_react_notifications4 = require("@ttoss/react-notifications");
860
- var import_jsx_runtime7 = require("react/jsx-runtime");
1120
+ var import_react_notifications6 = require("@ttoss/react-notifications");
1121
+ var import_jsx_runtime9 = require("react/jsx-runtime");
861
1122
  var authMachine = (0, import_xstate.createMachine)({
862
1123
  predictableActionArguments: true,
863
1124
  initial: "signIn",
@@ -870,6 +1131,9 @@ var authMachine = (0, import_xstate.createMachine)({
870
1131
  SIGN_UP_RESEND_CONFIRMATION: {
871
1132
  actions: ["assignEmail"],
872
1133
  target: "signUpConfirm"
1134
+ },
1135
+ FORGOT_PASSWORD: {
1136
+ target: "forgotPassword"
873
1137
  }
874
1138
  }
875
1139
  },
@@ -891,13 +1155,41 @@ var authMachine = (0, import_xstate.createMachine)({
891
1155
  target: "signIn"
892
1156
  }
893
1157
  }
1158
+ },
1159
+ forgotPassword: {
1160
+ on: {
1161
+ RETURN_TO_SIGN_IN: {
1162
+ target: "signIn"
1163
+ },
1164
+ SIGN_UP: {
1165
+ target: "signUp"
1166
+ },
1167
+ FORGOT_PASSWORD_RESET_PASSWORD: {
1168
+ actions: ["assignEmail"],
1169
+ target: "forgotPasswordResetPassword"
1170
+ }
1171
+ }
1172
+ },
1173
+ forgotPasswordResetPassword: {
1174
+ on: {
1175
+ FORGOT_PASSWORD_CONFIRMED: {
1176
+ actions: ["assignEmail"],
1177
+ target: "signIn"
1178
+ },
1179
+ RETURN_TO_SIGN_IN: {
1180
+ target: "signIn"
1181
+ }
1182
+ }
894
1183
  }
895
1184
  }
896
1185
  }, {
897
1186
  actions: {
898
1187
  assignEmail: (0, import_xstate.assign)({
899
1188
  email: (_, event) => {
900
- return event.email;
1189
+ if ("email" in event) {
1190
+ return event.email;
1191
+ }
1192
+ return void 0;
901
1193
  }
902
1194
  })
903
1195
  }
@@ -910,8 +1202,8 @@ var AuthLogic = () => {
910
1202
  const {
911
1203
  setLoading,
912
1204
  setNotifications
913
- } = (0, import_react_notifications4.useNotifications)();
914
- const onSignIn = React5.useCallback(async ({
1205
+ } = (0, import_react_notifications6.useNotifications)();
1206
+ const onSignIn = React6.useCallback(async ({
915
1207
  email,
916
1208
  password
917
1209
  }) => {
@@ -937,7 +1229,7 @@ var AuthLogic = () => {
937
1229
  setLoading(false);
938
1230
  }
939
1231
  }, [send, setLoading, setNotifications]);
940
- const onSignUp = React5.useCallback(async ({
1232
+ const onSignUp = React6.useCallback(async ({
941
1233
  email,
942
1234
  password
943
1235
  }) => {
@@ -963,7 +1255,7 @@ var AuthLogic = () => {
963
1255
  setLoading(false);
964
1256
  }
965
1257
  }, [send, setLoading, setNotifications]);
966
- const onConfirmSignUp = React5.useCallback(async ({
1258
+ const onConfirmSignUp = React6.useCallback(async ({
967
1259
  email,
968
1260
  code
969
1261
  }) => {
@@ -983,31 +1275,90 @@ var AuthLogic = () => {
983
1275
  setLoading(false);
984
1276
  }
985
1277
  }, [send, setLoading, setNotifications]);
986
- const onReturnToSignIn = React5.useCallback(() => {
1278
+ const onReturnToSignIn = React6.useCallback(() => {
987
1279
  send({
988
1280
  type: "RETURN_TO_SIGN_IN"
989
1281
  });
990
1282
  }, [send]);
1283
+ const onForgotPassword = React6.useCallback(async ({
1284
+ email
1285
+ }) => {
1286
+ try {
1287
+ setLoading(true);
1288
+ await import_aws_amplify2.Auth.forgotPassword(email);
1289
+ send({
1290
+ type: "FORGOT_PASSWORD_RESET_PASSWORD",
1291
+ email
1292
+ });
1293
+ } catch (error) {
1294
+ setNotifications({
1295
+ type: "error",
1296
+ message: error.message
1297
+ });
1298
+ } finally {
1299
+ setLoading(false);
1300
+ }
1301
+ }, [send, setLoading, setNotifications]);
1302
+ const onForgotPasswordResetPassword = React6.useCallback(async ({
1303
+ email,
1304
+ code,
1305
+ newPassword
1306
+ }) => {
1307
+ try {
1308
+ setLoading(true);
1309
+ await import_aws_amplify2.Auth.forgotPasswordSubmit(email, code, newPassword);
1310
+ send({
1311
+ type: "FORGOT_PASSWORD_CONFIRMED",
1312
+ email
1313
+ });
1314
+ } catch (error) {
1315
+ setNotifications({
1316
+ type: "error",
1317
+ message: error.message
1318
+ });
1319
+ } finally {
1320
+ setLoading(false);
1321
+ }
1322
+ }, [send, setLoading, setNotifications]);
991
1323
  if (isAuthenticated) {
992
1324
  return null;
993
1325
  }
994
1326
  if (state.matches("signUp")) {
995
- return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(AuthSignUp, {
1327
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthSignUp, {
996
1328
  onSignUp,
997
1329
  onReturnToSignIn
998
1330
  });
999
1331
  }
1000
1332
  if (state.matches("signUpConfirm")) {
1001
- return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(AuthConfirmSignUp, {
1333
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthConfirmSignUp, {
1002
1334
  onConfirmSignUp,
1003
1335
  email: state.context.email
1004
1336
  });
1005
1337
  }
1006
- return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(AuthSignIn, {
1338
+ if (state.matches("forgotPassword")) {
1339
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthForgotPassword, {
1340
+ onForgotPassword,
1341
+ onCancel: onReturnToSignIn,
1342
+ onSignUp: () => {
1343
+ return send("SIGN_UP");
1344
+ }
1345
+ });
1346
+ }
1347
+ if (state.matches("forgotPasswordResetPassword")) {
1348
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthForgotPasswordResetPassword, {
1349
+ email: state.context.email,
1350
+ onForgotPasswordResetPassword,
1351
+ onCancel: onReturnToSignIn
1352
+ });
1353
+ }
1354
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthSignIn, {
1007
1355
  onSignIn,
1008
1356
  onSignUp: () => {
1009
1357
  return send("SIGN_UP");
1010
1358
  },
1359
+ onForgotPassword: () => {
1360
+ return send("FORGOT_PASSWORD");
1361
+ },
1011
1362
  defaultValues: {
1012
1363
  email: state.context.email
1013
1364
  }
@@ -1017,14 +1368,14 @@ var Auth2 = ({
1017
1368
  logo,
1018
1369
  fullScreen = true
1019
1370
  }) => {
1020
- const withLogoNode = React5.useMemo(() => {
1021
- return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(LogoProvider, {
1371
+ const withLogoNode = React6.useMemo(() => {
1372
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(LogoProvider, {
1022
1373
  logo,
1023
- children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(AuthLogic, {})
1374
+ children: /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthLogic, {})
1024
1375
  });
1025
1376
  }, [logo]);
1026
1377
  if (fullScreen) {
1027
- return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(AuthFullScreen, {
1378
+ return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(AuthFullScreen, {
1028
1379
  children: withLogoNode
1029
1380
  });
1030
1381
  }