@ttoss/react-auth-core 0.3.5 → 0.4.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 +32 -33
- package/dist/index.js +32 -33
- package/i18n/compiled/en.json +10 -0
- package/i18n/lang/en.json +5 -0
- package/package.json +19 -19
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __name = (target, value) => __defProp(target, "name", {
|
|
|
9
9
|
// src/Auth.tsx
|
|
10
10
|
import { useNotifications as useNotifications2 } from "@ttoss/react-notifications";
|
|
11
11
|
import { Flex as Flex5 } from "@ttoss/ui";
|
|
12
|
-
import * as
|
|
12
|
+
import * as React4 from "react";
|
|
13
13
|
|
|
14
14
|
// src/AuthCard.tsx
|
|
15
15
|
import { useNotifications } from "@ttoss/react-notifications";
|
|
@@ -776,7 +776,6 @@ var AuthSignUp = /* @__PURE__ */__name(props => {
|
|
|
776
776
|
import { NotificationCard as NotificationCard3 } from "@ttoss/components/NotificationCard";
|
|
777
777
|
import { notify } from "@ttoss/logger";
|
|
778
778
|
import { useI18n as useI18n7 } from "@ttoss/react-i18n";
|
|
779
|
-
import * as React4 from "react";
|
|
780
779
|
import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary";
|
|
781
780
|
var ErrorFallback = /* @__PURE__ */__name(({
|
|
782
781
|
resetErrorBoundary
|
|
@@ -784,9 +783,9 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
784
783
|
const {
|
|
785
784
|
intl
|
|
786
785
|
} = useI18n7();
|
|
787
|
-
return /* @__PURE__ */
|
|
786
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
788
787
|
role: "alert"
|
|
789
|
-
}, /* @__PURE__ */
|
|
788
|
+
}, /* @__PURE__ */React.createElement(NotificationCard3, {
|
|
790
789
|
type: "error",
|
|
791
790
|
message: intl.formatMessage({
|
|
792
791
|
id: "khMx/2",
|
|
@@ -801,13 +800,13 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
801
800
|
var ErrorBoundary = /* @__PURE__ */__name(({
|
|
802
801
|
children
|
|
803
802
|
}) => {
|
|
804
|
-
return /* @__PURE__ */
|
|
803
|
+
return /* @__PURE__ */React.createElement(ReactErrorBoundary, {
|
|
805
804
|
FallbackComponent: ErrorFallback,
|
|
806
805
|
onError: /* @__PURE__ */__name(error => {
|
|
807
806
|
notify({
|
|
808
807
|
type: "error",
|
|
809
808
|
title: "Authentication Error",
|
|
810
|
-
message: error.message
|
|
809
|
+
message: error instanceof Error ? error.message : String(error)
|
|
811
810
|
});
|
|
812
811
|
}, "onError")
|
|
813
812
|
}, children);
|
|
@@ -831,10 +830,10 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
831
830
|
clearNotifications,
|
|
832
831
|
setLoading
|
|
833
832
|
} = useNotifications2();
|
|
834
|
-
|
|
833
|
+
React4.useEffect(() => {
|
|
835
834
|
clearNotifications();
|
|
836
835
|
}, [screen.value, clearNotifications]);
|
|
837
|
-
|
|
836
|
+
React4.useEffect(() => {
|
|
838
837
|
return clearNotifications;
|
|
839
838
|
}, [clearNotifications]);
|
|
840
839
|
const onGoToSignIn = /* @__PURE__ */__name(() => {
|
|
@@ -842,7 +841,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
842
841
|
value: "signIn"
|
|
843
842
|
});
|
|
844
843
|
}, "onGoToSignIn");
|
|
845
|
-
const onGoToSignUp =
|
|
844
|
+
const onGoToSignUp = React4.useCallback(() => {
|
|
846
845
|
if (!onSignUp) {
|
|
847
846
|
return void 0;
|
|
848
847
|
}
|
|
@@ -850,7 +849,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
850
849
|
value: "signUp"
|
|
851
850
|
});
|
|
852
851
|
}, [onSignUp, setScreen]);
|
|
853
|
-
const onGoToForgotPassword =
|
|
852
|
+
const onGoToForgotPassword = React4.useCallback(() => {
|
|
854
853
|
if (!onForgotPassword) {
|
|
855
854
|
return void 0;
|
|
856
855
|
}
|
|
@@ -870,7 +869,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
870
869
|
};
|
|
871
870
|
}, "notificationsWrapper");
|
|
872
871
|
if (screen.value === "signIn") {
|
|
873
|
-
return /* @__PURE__ */
|
|
872
|
+
return /* @__PURE__ */React4.createElement(AuthSignIn, {
|
|
874
873
|
onSignIn: notificationsWrapper(onSignIn),
|
|
875
874
|
onGoToSignUp: onSignUp && onGoToSignUp,
|
|
876
875
|
onGoToForgotPassword: onForgotPassword && onGoToForgotPassword,
|
|
@@ -878,7 +877,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
878
877
|
});
|
|
879
878
|
}
|
|
880
879
|
if (screen.value === "signUp" && onSignUp) {
|
|
881
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */React4.createElement(AuthSignUp, {
|
|
882
881
|
onSignUp: notificationsWrapper(onSignUp),
|
|
883
882
|
passwordMinimumLength,
|
|
884
883
|
onGoToSignIn,
|
|
@@ -886,27 +885,27 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
886
885
|
});
|
|
887
886
|
}
|
|
888
887
|
if (screen.value === "forgotPassword" && onForgotPassword) {
|
|
889
|
-
return /* @__PURE__ */
|
|
888
|
+
return /* @__PURE__ */React4.createElement(AuthForgotPassword, {
|
|
890
889
|
onForgotPassword: notificationsWrapper(onForgotPassword),
|
|
891
890
|
onGoToSignIn,
|
|
892
891
|
onGoToSignUp: onSignUp && onGoToSignUp
|
|
893
892
|
});
|
|
894
893
|
}
|
|
895
894
|
if (screen.value === "confirmResetPassword" && onForgotPasswordResetPassword) {
|
|
896
|
-
return /* @__PURE__ */
|
|
895
|
+
return /* @__PURE__ */React4.createElement(AuthForgotPasswordResetPassword, {
|
|
897
896
|
onForgotPasswordResetPassword: notificationsWrapper(onForgotPasswordResetPassword),
|
|
898
897
|
onGoToSignIn,
|
|
899
898
|
email: screen.context.email
|
|
900
899
|
});
|
|
901
900
|
}
|
|
902
901
|
if (screen.value === "confirmSignUpWithCode" && onConfirmSignUpWithCode) {
|
|
903
|
-
return /* @__PURE__ */
|
|
902
|
+
return /* @__PURE__ */React4.createElement(AuthConfirmSignUpWithCode, {
|
|
904
903
|
onConfirmSignUpWithCode: notificationsWrapper(onConfirmSignUpWithCode),
|
|
905
904
|
email: screen.context.email
|
|
906
905
|
});
|
|
907
906
|
}
|
|
908
907
|
if (screen.value === "confirmSignUpCheckEmail" && onConfirmSignUpCheckEmail) {
|
|
909
|
-
return /* @__PURE__ */
|
|
908
|
+
return /* @__PURE__ */React4.createElement(AuthConfirmSignUpCheckEmail, {
|
|
910
909
|
onConfirmSignUpCheckEmail
|
|
911
910
|
});
|
|
912
911
|
}
|
|
@@ -918,20 +917,20 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
918
917
|
fullScreen: true
|
|
919
918
|
}
|
|
920
919
|
} = props;
|
|
921
|
-
const withLogoNode =
|
|
922
|
-
return /* @__PURE__ */
|
|
920
|
+
const withLogoNode = React4.useMemo(() => {
|
|
921
|
+
return /* @__PURE__ */React4.createElement(LogoProvider, {
|
|
923
922
|
logo: props.logo
|
|
924
|
-
}, /* @__PURE__ */
|
|
923
|
+
}, /* @__PURE__ */React4.createElement(ErrorBoundary, null, /* @__PURE__ */React4.createElement(AuthLogic, props)));
|
|
925
924
|
}, [props]);
|
|
926
925
|
if (layout.fullScreen) {
|
|
927
926
|
if (layout.sideContentPosition) {
|
|
928
|
-
return /* @__PURE__ */
|
|
927
|
+
return /* @__PURE__ */React4.createElement(AuthFullScreen, null, /* @__PURE__ */React4.createElement(Flex5, {
|
|
929
928
|
sx: {
|
|
930
929
|
width: "100%",
|
|
931
930
|
height: "100%",
|
|
932
931
|
flexDirection: layout.sideContentPosition === "left" ? "row" : "row-reverse"
|
|
933
932
|
}
|
|
934
|
-
}, /* @__PURE__ */
|
|
933
|
+
}, /* @__PURE__ */React4.createElement(Flex5, {
|
|
935
934
|
sx: {
|
|
936
935
|
width: "100%",
|
|
937
936
|
height: "100%",
|
|
@@ -939,7 +938,7 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
939
938
|
justifyContent: "center",
|
|
940
939
|
alignItems: "center"
|
|
941
940
|
}
|
|
942
|
-
}, layout.sideContent), /* @__PURE__ */
|
|
941
|
+
}, layout.sideContent), /* @__PURE__ */React4.createElement(Flex5, {
|
|
943
942
|
sx: {
|
|
944
943
|
width: "100%",
|
|
945
944
|
height: "100%",
|
|
@@ -949,15 +948,15 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
949
948
|
}
|
|
950
949
|
}, withLogoNode)));
|
|
951
950
|
}
|
|
952
|
-
return /* @__PURE__ */
|
|
951
|
+
return /* @__PURE__ */React4.createElement(AuthFullScreen, null, withLogoNode);
|
|
953
952
|
}
|
|
954
953
|
return withLogoNode;
|
|
955
954
|
}, "Auth");
|
|
956
955
|
|
|
957
956
|
// src/AuthProvider.tsx
|
|
958
957
|
import { useNotifications as useNotifications3 } from "@ttoss/react-notifications";
|
|
959
|
-
import * as
|
|
960
|
-
var AuthContext = /* @__PURE__ */
|
|
958
|
+
import * as React5 from "react";
|
|
959
|
+
var AuthContext = /* @__PURE__ */React5.createContext(null);
|
|
961
960
|
var UNAUTHENTICATED_USER = {
|
|
962
961
|
user: null,
|
|
963
962
|
tokens: null,
|
|
@@ -971,15 +970,15 @@ var AuthProvider = /* @__PURE__ */__name(props => {
|
|
|
971
970
|
const {
|
|
972
971
|
setLoading
|
|
973
972
|
} = useNotifications3();
|
|
974
|
-
const [authData, setAuthData] =
|
|
973
|
+
const [authData, setAuthData] = React5.useState({
|
|
975
974
|
user: null,
|
|
976
975
|
tokens: null,
|
|
977
976
|
isAuthenticated: void 0
|
|
978
977
|
});
|
|
979
|
-
|
|
978
|
+
React5.useEffect(() => {
|
|
980
979
|
setLoading(authData.isAuthenticated === void 0);
|
|
981
980
|
}, [authData.isAuthenticated, setLoading]);
|
|
982
|
-
|
|
981
|
+
React5.useEffect(() => {
|
|
983
982
|
const fetchAuthData = /* @__PURE__ */__name(async () => {
|
|
984
983
|
try {
|
|
985
984
|
const data = await getAuthData?.();
|
|
@@ -994,14 +993,14 @@ var AuthProvider = /* @__PURE__ */__name(props => {
|
|
|
994
993
|
}, "fetchAuthData");
|
|
995
994
|
fetchAuthData();
|
|
996
995
|
}, [getAuthData]);
|
|
997
|
-
const signOut =
|
|
996
|
+
const signOut = React5.useCallback(async () => {
|
|
998
997
|
await signOutProp?.();
|
|
999
998
|
setAuthData(UNAUTHENTICATED_USER);
|
|
1000
999
|
}, [signOutProp]);
|
|
1001
1000
|
if (authData.isAuthenticated === void 0) {
|
|
1002
1001
|
return null;
|
|
1003
1002
|
}
|
|
1004
|
-
return /* @__PURE__ */
|
|
1003
|
+
return /* @__PURE__ */React5.createElement(AuthContext.Provider, {
|
|
1005
1004
|
value: {
|
|
1006
1005
|
signOut,
|
|
1007
1006
|
isAuthenticated: authData.isAuthenticated ?? false,
|
|
@@ -1012,7 +1011,7 @@ var AuthProvider = /* @__PURE__ */__name(props => {
|
|
|
1012
1011
|
}, props.children);
|
|
1013
1012
|
}, "AuthProvider");
|
|
1014
1013
|
var useAuth = /* @__PURE__ */__name(() => {
|
|
1015
|
-
const context =
|
|
1014
|
+
const context = React5.useContext(AuthContext);
|
|
1016
1015
|
if (!context) {
|
|
1017
1016
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1018
1017
|
}
|
|
@@ -1020,9 +1019,9 @@ var useAuth = /* @__PURE__ */__name(() => {
|
|
|
1020
1019
|
}, "useAuth");
|
|
1021
1020
|
|
|
1022
1021
|
// src/useAuthScreen.ts
|
|
1023
|
-
import * as
|
|
1022
|
+
import * as React6 from "react";
|
|
1024
1023
|
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
1025
|
-
const [screen, setScreen] =
|
|
1024
|
+
const [screen, setScreen] = React6.useState(initialScreen || {
|
|
1026
1025
|
value: "signIn"
|
|
1027
1026
|
});
|
|
1028
1027
|
return {
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
61
61
|
// src/Auth.tsx
|
|
62
62
|
var import_react_notifications6 = require("@ttoss/react-notifications");
|
|
63
63
|
var import_ui7 = require("@ttoss/ui");
|
|
64
|
-
var
|
|
64
|
+
var React4 = __toESM(require("react"), 1);
|
|
65
65
|
|
|
66
66
|
// src/AuthCard.tsx
|
|
67
67
|
var import_react_notifications = require("@ttoss/react-notifications");
|
|
@@ -828,7 +828,6 @@ var AuthSignUp = /* @__PURE__ */__name(props => {
|
|
|
828
828
|
var import_NotificationCard3 = require("@ttoss/components/NotificationCard");
|
|
829
829
|
var import_logger = require("@ttoss/logger");
|
|
830
830
|
var import_react_i18n7 = require("@ttoss/react-i18n");
|
|
831
|
-
var React4 = __toESM(require("react"), 1);
|
|
832
831
|
var import_react_error_boundary = require("react-error-boundary");
|
|
833
832
|
var ErrorFallback = /* @__PURE__ */__name(({
|
|
834
833
|
resetErrorBoundary
|
|
@@ -836,9 +835,9 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
836
835
|
const {
|
|
837
836
|
intl
|
|
838
837
|
} = (0, import_react_i18n7.useI18n)();
|
|
839
|
-
return /* @__PURE__ */
|
|
838
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
840
839
|
role: "alert"
|
|
841
|
-
}, /* @__PURE__ */
|
|
840
|
+
}, /* @__PURE__ */React.createElement(import_NotificationCard3.NotificationCard, {
|
|
842
841
|
type: "error",
|
|
843
842
|
message: intl.formatMessage({
|
|
844
843
|
id: "khMx/2",
|
|
@@ -853,13 +852,13 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
853
852
|
var ErrorBoundary = /* @__PURE__ */__name(({
|
|
854
853
|
children
|
|
855
854
|
}) => {
|
|
856
|
-
return /* @__PURE__ */
|
|
855
|
+
return /* @__PURE__ */React.createElement(import_react_error_boundary.ErrorBoundary, {
|
|
857
856
|
FallbackComponent: ErrorFallback,
|
|
858
857
|
onError: /* @__PURE__ */__name(error => {
|
|
859
858
|
(0, import_logger.notify)({
|
|
860
859
|
type: "error",
|
|
861
860
|
title: "Authentication Error",
|
|
862
|
-
message: error.message
|
|
861
|
+
message: error instanceof Error ? error.message : String(error)
|
|
863
862
|
});
|
|
864
863
|
}, "onError")
|
|
865
864
|
}, children);
|
|
@@ -883,10 +882,10 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
883
882
|
clearNotifications,
|
|
884
883
|
setLoading
|
|
885
884
|
} = (0, import_react_notifications6.useNotifications)();
|
|
886
|
-
|
|
885
|
+
React4.useEffect(() => {
|
|
887
886
|
clearNotifications();
|
|
888
887
|
}, [screen.value, clearNotifications]);
|
|
889
|
-
|
|
888
|
+
React4.useEffect(() => {
|
|
890
889
|
return clearNotifications;
|
|
891
890
|
}, [clearNotifications]);
|
|
892
891
|
const onGoToSignIn = /* @__PURE__ */__name(() => {
|
|
@@ -894,7 +893,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
894
893
|
value: "signIn"
|
|
895
894
|
});
|
|
896
895
|
}, "onGoToSignIn");
|
|
897
|
-
const onGoToSignUp =
|
|
896
|
+
const onGoToSignUp = React4.useCallback(() => {
|
|
898
897
|
if (!onSignUp) {
|
|
899
898
|
return void 0;
|
|
900
899
|
}
|
|
@@ -902,7 +901,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
902
901
|
value: "signUp"
|
|
903
902
|
});
|
|
904
903
|
}, [onSignUp, setScreen]);
|
|
905
|
-
const onGoToForgotPassword =
|
|
904
|
+
const onGoToForgotPassword = React4.useCallback(() => {
|
|
906
905
|
if (!onForgotPassword) {
|
|
907
906
|
return void 0;
|
|
908
907
|
}
|
|
@@ -922,7 +921,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
922
921
|
};
|
|
923
922
|
}, "notificationsWrapper");
|
|
924
923
|
if (screen.value === "signIn") {
|
|
925
|
-
return /* @__PURE__ */
|
|
924
|
+
return /* @__PURE__ */React4.createElement(AuthSignIn, {
|
|
926
925
|
onSignIn: notificationsWrapper(onSignIn),
|
|
927
926
|
onGoToSignUp: onSignUp && onGoToSignUp,
|
|
928
927
|
onGoToForgotPassword: onForgotPassword && onGoToForgotPassword,
|
|
@@ -930,7 +929,7 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
930
929
|
});
|
|
931
930
|
}
|
|
932
931
|
if (screen.value === "signUp" && onSignUp) {
|
|
933
|
-
return /* @__PURE__ */
|
|
932
|
+
return /* @__PURE__ */React4.createElement(AuthSignUp, {
|
|
934
933
|
onSignUp: notificationsWrapper(onSignUp),
|
|
935
934
|
passwordMinimumLength,
|
|
936
935
|
onGoToSignIn,
|
|
@@ -938,27 +937,27 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
938
937
|
});
|
|
939
938
|
}
|
|
940
939
|
if (screen.value === "forgotPassword" && onForgotPassword) {
|
|
941
|
-
return /* @__PURE__ */
|
|
940
|
+
return /* @__PURE__ */React4.createElement(AuthForgotPassword, {
|
|
942
941
|
onForgotPassword: notificationsWrapper(onForgotPassword),
|
|
943
942
|
onGoToSignIn,
|
|
944
943
|
onGoToSignUp: onSignUp && onGoToSignUp
|
|
945
944
|
});
|
|
946
945
|
}
|
|
947
946
|
if (screen.value === "confirmResetPassword" && onForgotPasswordResetPassword) {
|
|
948
|
-
return /* @__PURE__ */
|
|
947
|
+
return /* @__PURE__ */React4.createElement(AuthForgotPasswordResetPassword, {
|
|
949
948
|
onForgotPasswordResetPassword: notificationsWrapper(onForgotPasswordResetPassword),
|
|
950
949
|
onGoToSignIn,
|
|
951
950
|
email: screen.context.email
|
|
952
951
|
});
|
|
953
952
|
}
|
|
954
953
|
if (screen.value === "confirmSignUpWithCode" && onConfirmSignUpWithCode) {
|
|
955
|
-
return /* @__PURE__ */
|
|
954
|
+
return /* @__PURE__ */React4.createElement(AuthConfirmSignUpWithCode, {
|
|
956
955
|
onConfirmSignUpWithCode: notificationsWrapper(onConfirmSignUpWithCode),
|
|
957
956
|
email: screen.context.email
|
|
958
957
|
});
|
|
959
958
|
}
|
|
960
959
|
if (screen.value === "confirmSignUpCheckEmail" && onConfirmSignUpCheckEmail) {
|
|
961
|
-
return /* @__PURE__ */
|
|
960
|
+
return /* @__PURE__ */React4.createElement(AuthConfirmSignUpCheckEmail, {
|
|
962
961
|
onConfirmSignUpCheckEmail
|
|
963
962
|
});
|
|
964
963
|
}
|
|
@@ -970,20 +969,20 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
970
969
|
fullScreen: true
|
|
971
970
|
}
|
|
972
971
|
} = props;
|
|
973
|
-
const withLogoNode =
|
|
974
|
-
return /* @__PURE__ */
|
|
972
|
+
const withLogoNode = React4.useMemo(() => {
|
|
973
|
+
return /* @__PURE__ */React4.createElement(LogoProvider, {
|
|
975
974
|
logo: props.logo
|
|
976
|
-
}, /* @__PURE__ */
|
|
975
|
+
}, /* @__PURE__ */React4.createElement(ErrorBoundary, null, /* @__PURE__ */React4.createElement(AuthLogic, props)));
|
|
977
976
|
}, [props]);
|
|
978
977
|
if (layout.fullScreen) {
|
|
979
978
|
if (layout.sideContentPosition) {
|
|
980
|
-
return /* @__PURE__ */
|
|
979
|
+
return /* @__PURE__ */React4.createElement(AuthFullScreen, null, /* @__PURE__ */React4.createElement(import_ui7.Flex, {
|
|
981
980
|
sx: {
|
|
982
981
|
width: "100%",
|
|
983
982
|
height: "100%",
|
|
984
983
|
flexDirection: layout.sideContentPosition === "left" ? "row" : "row-reverse"
|
|
985
984
|
}
|
|
986
|
-
}, /* @__PURE__ */
|
|
985
|
+
}, /* @__PURE__ */React4.createElement(import_ui7.Flex, {
|
|
987
986
|
sx: {
|
|
988
987
|
width: "100%",
|
|
989
988
|
height: "100%",
|
|
@@ -991,7 +990,7 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
991
990
|
justifyContent: "center",
|
|
992
991
|
alignItems: "center"
|
|
993
992
|
}
|
|
994
|
-
}, layout.sideContent), /* @__PURE__ */
|
|
993
|
+
}, layout.sideContent), /* @__PURE__ */React4.createElement(import_ui7.Flex, {
|
|
995
994
|
sx: {
|
|
996
995
|
width: "100%",
|
|
997
996
|
height: "100%",
|
|
@@ -1001,15 +1000,15 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
1001
1000
|
}
|
|
1002
1001
|
}, withLogoNode)));
|
|
1003
1002
|
}
|
|
1004
|
-
return /* @__PURE__ */
|
|
1003
|
+
return /* @__PURE__ */React4.createElement(AuthFullScreen, null, withLogoNode);
|
|
1005
1004
|
}
|
|
1006
1005
|
return withLogoNode;
|
|
1007
1006
|
}, "Auth");
|
|
1008
1007
|
|
|
1009
1008
|
// src/AuthProvider.tsx
|
|
1010
1009
|
var import_react_notifications7 = require("@ttoss/react-notifications");
|
|
1011
|
-
var
|
|
1012
|
-
var AuthContext = /* @__PURE__ */
|
|
1010
|
+
var React5 = __toESM(require("react"), 1);
|
|
1011
|
+
var AuthContext = /* @__PURE__ */React5.createContext(null);
|
|
1013
1012
|
var UNAUTHENTICATED_USER = {
|
|
1014
1013
|
user: null,
|
|
1015
1014
|
tokens: null,
|
|
@@ -1023,15 +1022,15 @@ var AuthProvider = /* @__PURE__ */__name(props => {
|
|
|
1023
1022
|
const {
|
|
1024
1023
|
setLoading
|
|
1025
1024
|
} = (0, import_react_notifications7.useNotifications)();
|
|
1026
|
-
const [authData, setAuthData] =
|
|
1025
|
+
const [authData, setAuthData] = React5.useState({
|
|
1027
1026
|
user: null,
|
|
1028
1027
|
tokens: null,
|
|
1029
1028
|
isAuthenticated: void 0
|
|
1030
1029
|
});
|
|
1031
|
-
|
|
1030
|
+
React5.useEffect(() => {
|
|
1032
1031
|
setLoading(authData.isAuthenticated === void 0);
|
|
1033
1032
|
}, [authData.isAuthenticated, setLoading]);
|
|
1034
|
-
|
|
1033
|
+
React5.useEffect(() => {
|
|
1035
1034
|
const fetchAuthData = /* @__PURE__ */__name(async () => {
|
|
1036
1035
|
try {
|
|
1037
1036
|
const data = await getAuthData?.();
|
|
@@ -1046,14 +1045,14 @@ var AuthProvider = /* @__PURE__ */__name(props => {
|
|
|
1046
1045
|
}, "fetchAuthData");
|
|
1047
1046
|
fetchAuthData();
|
|
1048
1047
|
}, [getAuthData]);
|
|
1049
|
-
const signOut =
|
|
1048
|
+
const signOut = React5.useCallback(async () => {
|
|
1050
1049
|
await signOutProp?.();
|
|
1051
1050
|
setAuthData(UNAUTHENTICATED_USER);
|
|
1052
1051
|
}, [signOutProp]);
|
|
1053
1052
|
if (authData.isAuthenticated === void 0) {
|
|
1054
1053
|
return null;
|
|
1055
1054
|
}
|
|
1056
|
-
return /* @__PURE__ */
|
|
1055
|
+
return /* @__PURE__ */React5.createElement(AuthContext.Provider, {
|
|
1057
1056
|
value: {
|
|
1058
1057
|
signOut,
|
|
1059
1058
|
isAuthenticated: authData.isAuthenticated ?? false,
|
|
@@ -1064,7 +1063,7 @@ var AuthProvider = /* @__PURE__ */__name(props => {
|
|
|
1064
1063
|
}, props.children);
|
|
1065
1064
|
}, "AuthProvider");
|
|
1066
1065
|
var useAuth = /* @__PURE__ */__name(() => {
|
|
1067
|
-
const context =
|
|
1066
|
+
const context = React5.useContext(AuthContext);
|
|
1068
1067
|
if (!context) {
|
|
1069
1068
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1070
1069
|
}
|
|
@@ -1072,9 +1071,9 @@ var useAuth = /* @__PURE__ */__name(() => {
|
|
|
1072
1071
|
}, "useAuth");
|
|
1073
1072
|
|
|
1074
1073
|
// src/useAuthScreen.ts
|
|
1075
|
-
var
|
|
1074
|
+
var React6 = __toESM(require("react"), 1);
|
|
1076
1075
|
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
1077
|
-
const [screen, setScreen] =
|
|
1076
|
+
const [screen, setScreen] = React6.useState(initialScreen || {
|
|
1078
1077
|
value: "signIn"
|
|
1079
1078
|
});
|
|
1080
1079
|
return {
|
package/i18n/compiled/en.json
CHANGED
package/i18n/lang/en.json
CHANGED
|
@@ -205,6 +205,11 @@
|
|
|
205
205
|
"defaultMessage": "Field is required",
|
|
206
206
|
"description": "Field is required"
|
|
207
207
|
},
|
|
208
|
+
"UibUNJ": {
|
|
209
|
+
"module": "@ttoss/forms",
|
|
210
|
+
"defaultMessage": "Invalid Value for Field of type {expected}",
|
|
211
|
+
"description": "Invalid Value"
|
|
212
|
+
},
|
|
208
213
|
"ZhaPt0": {
|
|
209
214
|
"module": "@ttoss/forms",
|
|
210
215
|
"defaultMessage": "Invalid Value for Field of type {type}",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Core authentication components and abstractions for React apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -25,32 +25,32 @@
|
|
|
25
25
|
],
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"react-error-boundary": "^6.
|
|
28
|
+
"react-error-boundary": "^6.1.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=16.8.0",
|
|
32
|
-
"@ttoss/
|
|
33
|
-
"@ttoss/
|
|
34
|
-
"@ttoss/
|
|
35
|
-
"@ttoss/
|
|
36
|
-
"@ttoss/
|
|
37
|
-
"@ttoss/
|
|
32
|
+
"@ttoss/components": "^2.13.0",
|
|
33
|
+
"@ttoss/react-i18n": "^2.1.0",
|
|
34
|
+
"@ttoss/forms": "^0.41.0",
|
|
35
|
+
"@ttoss/react-notifications": "^2.6.0",
|
|
36
|
+
"@ttoss/ui": "^6.6.0",
|
|
37
|
+
"@ttoss/logger": "^0.7.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^29.7.0",
|
|
41
|
-
"@types/react": "^19.2.
|
|
41
|
+
"@types/react": "^19.2.14",
|
|
42
42
|
"jest": "^30.2.0",
|
|
43
|
-
"react": "^19.2.
|
|
43
|
+
"react": "^19.2.4",
|
|
44
44
|
"tsup": "^8.5.1",
|
|
45
|
-
"@ttoss/components": "^2.
|
|
46
|
-
"@ttoss/config": "^1.
|
|
47
|
-
"@ttoss/
|
|
48
|
-
"@ttoss/i18n
|
|
49
|
-
"@ttoss/react-
|
|
50
|
-
"@ttoss/
|
|
51
|
-
"@ttoss/
|
|
52
|
-
"@ttoss/
|
|
53
|
-
"@ttoss/ui": "^6.
|
|
45
|
+
"@ttoss/components": "^2.13.0",
|
|
46
|
+
"@ttoss/config": "^1.36.0",
|
|
47
|
+
"@ttoss/i18n-cli": "^0.7.39",
|
|
48
|
+
"@ttoss/react-i18n": "^2.1.0",
|
|
49
|
+
"@ttoss/react-notifications": "^2.6.0",
|
|
50
|
+
"@ttoss/test-utils": "^4.1.0",
|
|
51
|
+
"@ttoss/forms": "^0.41.0",
|
|
52
|
+
"@ttoss/logger": "^0.7.4",
|
|
53
|
+
"@ttoss/ui": "^6.6.0"
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|
|
56
56
|
"React",
|