@ttoss/react-auth 2.4.9 → 2.5.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/esm/index.js +36 -42
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
|
|
3
3
|
// src/Auth.tsx
|
|
4
|
-
import { useNotifications as
|
|
4
|
+
import { useNotifications as useNotifications2 } from "@ttoss/react-notifications";
|
|
5
5
|
import { Flex as Flex5 } from "@ttoss/ui";
|
|
6
6
|
import { useMachine } from "@xstate/react";
|
|
7
7
|
import { confirmResetPassword, confirmSignUp, resendSignUpCode, resetPassword, signIn, signUp } from "aws-amplify/auth";
|
|
8
|
-
import * as
|
|
8
|
+
import * as React5 from "react";
|
|
9
9
|
import { assign, createMachine } from "xstate";
|
|
10
10
|
|
|
11
11
|
// src/AuthCard.tsx
|
|
@@ -531,9 +531,8 @@ var useAuth = () => {
|
|
|
531
531
|
// src/AuthSignIn.tsx
|
|
532
532
|
import { Form as Form4, FormFieldInput as FormFieldInput4, FormFieldPassword as FormFieldPassword2, useForm as useForm4, yup as yup4, yupResolver as yupResolver4 } from "@ttoss/forms";
|
|
533
533
|
import { useI18n as useI18n4 } from "@ttoss/react-i18n";
|
|
534
|
-
import { NotificationsBox as NotificationsBox3
|
|
534
|
+
import { NotificationsBox as NotificationsBox3 } from "@ttoss/react-notifications";
|
|
535
535
|
import { Button as Button4, Flex as Flex3, Link as Link2, Text as Text2 } from "@ttoss/ui";
|
|
536
|
-
import * as React4 from "react";
|
|
537
536
|
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
538
537
|
var AuthSignIn = ({
|
|
539
538
|
onSignIn,
|
|
@@ -544,12 +543,6 @@ var AuthSignIn = ({
|
|
|
544
543
|
const {
|
|
545
544
|
intl
|
|
546
545
|
} = useI18n4();
|
|
547
|
-
const {
|
|
548
|
-
setNotifications
|
|
549
|
-
} = useNotifications2();
|
|
550
|
-
React4.useEffect(() => {
|
|
551
|
-
setNotifications(void 0);
|
|
552
|
-
}, [setNotifications]);
|
|
553
546
|
const schema = yup4.object().shape({
|
|
554
547
|
email: yup4.string().required(intl.formatMessage({
|
|
555
548
|
id: "d1YCuH",
|
|
@@ -687,21 +680,15 @@ var AuthSignIn = ({
|
|
|
687
680
|
// src/AuthSignUp.tsx
|
|
688
681
|
import { Form as Form5, FormFieldCheckbox, FormFieldInput as FormFieldInput5, FormFieldPassword as FormFieldPassword3, useForm as useForm5, yup as yup5, yupResolver as yupResolver5 } from "@ttoss/forms";
|
|
689
682
|
import { useI18n as useI18n5 } from "@ttoss/react-i18n";
|
|
690
|
-
import { NotificationsBox as NotificationsBox4
|
|
683
|
+
import { NotificationsBox as NotificationsBox4 } from "@ttoss/react-notifications";
|
|
691
684
|
import { Flex as Flex4, Link as Link3, Text as Text3 } from "@ttoss/ui";
|
|
692
|
-
import * as
|
|
685
|
+
import * as React4 from "react";
|
|
693
686
|
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
694
687
|
var AuthSignUp = props => {
|
|
695
688
|
const {
|
|
696
689
|
intl
|
|
697
690
|
} = useI18n5();
|
|
698
|
-
const {
|
|
699
|
-
setNotifications
|
|
700
|
-
} = useNotifications3();
|
|
701
|
-
React5.useEffect(() => {
|
|
702
|
-
setNotifications(void 0);
|
|
703
|
-
}, [setNotifications]);
|
|
704
|
-
const schema = React5.useMemo(() => {
|
|
691
|
+
const schema = React4.useMemo(() => {
|
|
705
692
|
return yup5.object().shape({
|
|
706
693
|
email: yup5.string().required(intl.formatMessage({
|
|
707
694
|
id: "d1YCuH",
|
|
@@ -759,7 +746,7 @@ var AuthSignUp = props => {
|
|
|
759
746
|
})) : yup5.boolean()
|
|
760
747
|
});
|
|
761
748
|
}, [intl, props.signUpTerms?.isRequired]);
|
|
762
|
-
const signUpTermsLabel =
|
|
749
|
+
const signUpTermsLabel = React4.useMemo(() => {
|
|
763
750
|
if (!props.signUpTerms) {
|
|
764
751
|
return null;
|
|
765
752
|
}
|
|
@@ -772,7 +759,7 @@ var AuthSignUp = props => {
|
|
|
772
759
|
});
|
|
773
760
|
const termsLinks = props.signUpTerms.terms.map((term, index, terms) => {
|
|
774
761
|
const finalPunctuation = index === terms.length - 1 ? "." : ", ";
|
|
775
|
-
return /* @__PURE__ */jsxs5(
|
|
762
|
+
return /* @__PURE__ */jsxs5(React4.Fragment, {
|
|
776
763
|
children: [/* @__PURE__ */jsx8(Link3, {
|
|
777
764
|
href: term.url,
|
|
778
765
|
target: "_blank",
|
|
@@ -786,7 +773,7 @@ var AuthSignUp = props => {
|
|
|
786
773
|
});
|
|
787
774
|
return label;
|
|
788
775
|
}, [intl, props.signUpTerms]);
|
|
789
|
-
const signUpTermsNode =
|
|
776
|
+
const signUpTermsNode = React4.useMemo(() => {
|
|
790
777
|
if (!props.signUpTerms) {
|
|
791
778
|
return null;
|
|
792
779
|
}
|
|
@@ -967,9 +954,16 @@ var AuthLogic = props => {
|
|
|
967
954
|
const [state, send] = useMachine(authMachine);
|
|
968
955
|
const {
|
|
969
956
|
setLoading,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
957
|
+
addNotification,
|
|
958
|
+
clearNotifications
|
|
959
|
+
} = useNotifications2();
|
|
960
|
+
React5.useEffect(() => {
|
|
961
|
+
clearNotifications();
|
|
962
|
+
}, [state, clearNotifications]);
|
|
963
|
+
React5.useEffect(() => {
|
|
964
|
+
return clearNotifications;
|
|
965
|
+
}, [clearNotifications]);
|
|
966
|
+
const onSignIn = React5.useCallback(async ({
|
|
973
967
|
email,
|
|
974
968
|
password
|
|
975
969
|
}) => {
|
|
@@ -980,7 +974,7 @@ var AuthLogic = props => {
|
|
|
980
974
|
password
|
|
981
975
|
});
|
|
982
976
|
if (result.nextStep.signInStep === "RESET_PASSWORD") {
|
|
983
|
-
|
|
977
|
+
addNotification({
|
|
984
978
|
type: "error",
|
|
985
979
|
message: `For your security, we have updated our system and you need to reset your password in 'forgot your password?' to proceed`
|
|
986
980
|
});
|
|
@@ -998,15 +992,15 @@ var AuthLogic = props => {
|
|
|
998
992
|
break;
|
|
999
993
|
default:
|
|
1000
994
|
}
|
|
1001
|
-
|
|
995
|
+
addNotification({
|
|
1002
996
|
type: "error",
|
|
1003
997
|
message: error.message
|
|
1004
998
|
});
|
|
1005
999
|
} finally {
|
|
1006
1000
|
setLoading(false);
|
|
1007
1001
|
}
|
|
1008
|
-
}, [send, setLoading,
|
|
1009
|
-
const onSignUp =
|
|
1002
|
+
}, [send, setLoading, addNotification]);
|
|
1003
|
+
const onSignUp = React5.useCallback(async ({
|
|
1010
1004
|
email,
|
|
1011
1005
|
password
|
|
1012
1006
|
}) => {
|
|
@@ -1026,15 +1020,15 @@ var AuthLogic = props => {
|
|
|
1026
1020
|
email
|
|
1027
1021
|
});
|
|
1028
1022
|
} catch (error) {
|
|
1029
|
-
|
|
1023
|
+
addNotification({
|
|
1030
1024
|
type: "error",
|
|
1031
1025
|
message: error.message
|
|
1032
1026
|
});
|
|
1033
1027
|
} finally {
|
|
1034
1028
|
setLoading(false);
|
|
1035
1029
|
}
|
|
1036
|
-
}, [send, setLoading,
|
|
1037
|
-
const onConfirmSignUp =
|
|
1030
|
+
}, [send, setLoading, addNotification]);
|
|
1031
|
+
const onConfirmSignUp = React5.useCallback(async ({
|
|
1038
1032
|
email,
|
|
1039
1033
|
code
|
|
1040
1034
|
}) => {
|
|
@@ -1049,20 +1043,20 @@ var AuthLogic = props => {
|
|
|
1049
1043
|
email
|
|
1050
1044
|
});
|
|
1051
1045
|
} catch (error) {
|
|
1052
|
-
|
|
1046
|
+
addNotification({
|
|
1053
1047
|
type: "error",
|
|
1054
1048
|
message: error.message
|
|
1055
1049
|
});
|
|
1056
1050
|
} finally {
|
|
1057
1051
|
setLoading(false);
|
|
1058
1052
|
}
|
|
1059
|
-
}, [send, setLoading,
|
|
1060
|
-
const onReturnToSignIn =
|
|
1053
|
+
}, [send, setLoading, addNotification]);
|
|
1054
|
+
const onReturnToSignIn = React5.useCallback(() => {
|
|
1061
1055
|
send({
|
|
1062
1056
|
type: "RETURN_TO_SIGN_IN"
|
|
1063
1057
|
});
|
|
1064
1058
|
}, [send]);
|
|
1065
|
-
const onForgotPassword =
|
|
1059
|
+
const onForgotPassword = React5.useCallback(async ({
|
|
1066
1060
|
email
|
|
1067
1061
|
}) => {
|
|
1068
1062
|
try {
|
|
@@ -1075,15 +1069,15 @@ var AuthLogic = props => {
|
|
|
1075
1069
|
email
|
|
1076
1070
|
});
|
|
1077
1071
|
} catch (error) {
|
|
1078
|
-
|
|
1072
|
+
addNotification({
|
|
1079
1073
|
type: "error",
|
|
1080
1074
|
message: error.message
|
|
1081
1075
|
});
|
|
1082
1076
|
} finally {
|
|
1083
1077
|
setLoading(false);
|
|
1084
1078
|
}
|
|
1085
|
-
}, [send, setLoading,
|
|
1086
|
-
const onForgotPasswordResetPassword =
|
|
1079
|
+
}, [send, setLoading, addNotification]);
|
|
1080
|
+
const onForgotPasswordResetPassword = React5.useCallback(async ({
|
|
1087
1081
|
email,
|
|
1088
1082
|
code,
|
|
1089
1083
|
newPassword
|
|
@@ -1100,14 +1094,14 @@ var AuthLogic = props => {
|
|
|
1100
1094
|
email
|
|
1101
1095
|
});
|
|
1102
1096
|
} catch (error) {
|
|
1103
|
-
|
|
1097
|
+
addNotification({
|
|
1104
1098
|
type: "error",
|
|
1105
1099
|
message: error.message
|
|
1106
1100
|
});
|
|
1107
1101
|
} finally {
|
|
1108
1102
|
setLoading(false);
|
|
1109
1103
|
}
|
|
1110
|
-
}, [send, setLoading,
|
|
1104
|
+
}, [send, setLoading, addNotification]);
|
|
1111
1105
|
if (isAuthenticated) {
|
|
1112
1106
|
return null;
|
|
1113
1107
|
}
|
|
@@ -1159,7 +1153,7 @@ var Auth = props => {
|
|
|
1159
1153
|
fullScreen: true
|
|
1160
1154
|
}
|
|
1161
1155
|
} = props;
|
|
1162
|
-
const withLogoNode =
|
|
1156
|
+
const withLogoNode = React5.useMemo(() => {
|
|
1163
1157
|
return /* @__PURE__ */jsx9(LogoProvider, {
|
|
1164
1158
|
logo: props.logo,
|
|
1165
1159
|
children: /* @__PURE__ */jsx9(AuthLogic, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "ttoss authentication module for React apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@xstate/react": "^3.2.2",
|
|
29
29
|
"xstate": "^4.38.3",
|
|
30
|
-
"@ttoss/forms": "^0.28.
|
|
30
|
+
"@ttoss/forms": "^0.28.8"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"aws-amplify": "^6.0.0",
|
|
34
34
|
"react": ">=16.8.0",
|
|
35
35
|
"@ttoss/react-i18n": "^2.0.9",
|
|
36
|
-
"@ttoss/
|
|
37
|
-
"@ttoss/
|
|
36
|
+
"@ttoss/react-notifications": "^2.1.0",
|
|
37
|
+
"@ttoss/ui": "^5.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^29.7.0",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"react": "^19.0.0",
|
|
45
45
|
"tsup": "^8.3.5",
|
|
46
46
|
"@ttoss/cloud-auth": "^0.12.27",
|
|
47
|
+
"@ttoss/i18n-cli": "^0.7.26",
|
|
47
48
|
"@ttoss/config": "^1.35.2",
|
|
48
49
|
"@ttoss/react-i18n": "^2.0.9",
|
|
49
|
-
"@ttoss/
|
|
50
|
+
"@ttoss/react-notifications": "^2.1.0",
|
|
50
51
|
"@ttoss/test-utils": "^2.1.22",
|
|
51
|
-
"@ttoss/ui": "^5.
|
|
52
|
-
"@ttoss/react-notifications": "^1.24.71"
|
|
52
|
+
"@ttoss/ui": "^5.2.0"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"React",
|