@ttoss/react-auth-core 0.3.5 → 0.4.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.
- package/README.md +24 -0
- package/dist/esm/index.js +58 -27
- package/dist/index.d.cts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +58 -27
- package/i18n/compiled/en.json +10 -0
- package/i18n/lang/en.json +5 -0
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -124,6 +124,8 @@ const {
|
|
|
124
124
|
|
|
125
125
|
Main authentication flow component.
|
|
126
126
|
|
|
127
|
+
#### With External Screen State Management
|
|
128
|
+
|
|
127
129
|
```tsx
|
|
128
130
|
<Auth
|
|
129
131
|
screen={screen} // Current screen state
|
|
@@ -142,6 +144,28 @@ Main authentication flow component.
|
|
|
142
144
|
/>
|
|
143
145
|
```
|
|
144
146
|
|
|
147
|
+
#### With Internal Screen State Management
|
|
148
|
+
|
|
149
|
+
You can also let the Auth component manage its own screen state by using the `initialScreen` prop instead of `screen`/`setScreen`:
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
<Auth
|
|
153
|
+
initialScreen={{ value: 'signUp' }} // Start on sign up screen (optional)
|
|
154
|
+
onSignIn={handleSignIn}
|
|
155
|
+
onSignUp={handleSignUp}
|
|
156
|
+
onForgotPassword={handleForgotPassword}
|
|
157
|
+
/>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
This is useful when you don't need to control the screen state externally. The `initialScreen` prop accepts any valid `AuthScreen` value:
|
|
161
|
+
|
|
162
|
+
- `{ value: 'signIn' }` - Sign in screen (default)
|
|
163
|
+
- `{ value: 'signUp' }` - Sign up screen
|
|
164
|
+
- `{ value: 'forgotPassword' }` - Forgot password screen
|
|
165
|
+
- `{ value: 'confirmSignUpCheckEmail' }` - Email confirmation reminder
|
|
166
|
+
- `{ value: 'confirmSignUpWithCode', context: { email: string } }` - Code confirmation with email context
|
|
167
|
+
- `{ value: 'confirmResetPassword', context: { email: string } }` - Password reset with email context
|
|
168
|
+
|
|
145
169
|
### useAuthScreen Hook
|
|
146
170
|
|
|
147
171
|
Manages authentication screen state and transitions.
|
package/dist/esm/index.js
CHANGED
|
@@ -310,14 +310,29 @@ var AuthForgotPasswordResetPassword = /* @__PURE__ */__name(props => {
|
|
|
310
310
|
const {
|
|
311
311
|
intl
|
|
312
312
|
} = useI18n4();
|
|
313
|
+
const codeValidation = yup3.string().required(intl.formatMessage({
|
|
314
|
+
id: "0XOzcH",
|
|
315
|
+
defaultMessage: [{
|
|
316
|
+
"type": 0,
|
|
317
|
+
"value": "Required field"
|
|
318
|
+
}]
|
|
319
|
+
}));
|
|
313
320
|
const schema = yup3.object().shape({
|
|
314
|
-
code:
|
|
315
|
-
id: "
|
|
321
|
+
code: props.maxCodeLength ? codeValidation.min(props.maxCodeLength, intl.formatMessage({
|
|
322
|
+
id: "S3pjKw",
|
|
316
323
|
defaultMessage: [{
|
|
317
324
|
"type": 0,
|
|
318
|
-
"value": "
|
|
325
|
+
"value": "Minimum "
|
|
326
|
+
}, {
|
|
327
|
+
"type": 1,
|
|
328
|
+
"value": "value"
|
|
329
|
+
}, {
|
|
330
|
+
"type": 0,
|
|
331
|
+
"value": " characters"
|
|
319
332
|
}]
|
|
320
|
-
}
|
|
333
|
+
}, {
|
|
334
|
+
value: props.maxCodeLength
|
|
335
|
+
})).max(props.maxCodeLength, intl.formatMessage({
|
|
321
336
|
id: "SfWKyS",
|
|
322
337
|
defaultMessage: [{
|
|
323
338
|
"type": 0,
|
|
@@ -330,8 +345,8 @@ var AuthForgotPasswordResetPassword = /* @__PURE__ */__name(props => {
|
|
|
330
345
|
"value": " characters"
|
|
331
346
|
}]
|
|
332
347
|
}, {
|
|
333
|
-
value:
|
|
334
|
-
})),
|
|
348
|
+
value: props.maxCodeLength
|
|
349
|
+
})) : codeValidation,
|
|
335
350
|
newPassword: yup3.string().required(intl.formatMessage({
|
|
336
351
|
id: "kdFYba",
|
|
337
352
|
defaultMessage: [{
|
|
@@ -776,7 +791,6 @@ var AuthSignUp = /* @__PURE__ */__name(props => {
|
|
|
776
791
|
import { NotificationCard as NotificationCard3 } from "@ttoss/components/NotificationCard";
|
|
777
792
|
import { notify } from "@ttoss/logger";
|
|
778
793
|
import { useI18n as useI18n7 } from "@ttoss/react-i18n";
|
|
779
|
-
import * as React4 from "react";
|
|
780
794
|
import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary";
|
|
781
795
|
var ErrorFallback = /* @__PURE__ */__name(({
|
|
782
796
|
resetErrorBoundary
|
|
@@ -784,9 +798,9 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
784
798
|
const {
|
|
785
799
|
intl
|
|
786
800
|
} = useI18n7();
|
|
787
|
-
return /* @__PURE__ */
|
|
801
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
788
802
|
role: "alert"
|
|
789
|
-
}, /* @__PURE__ */
|
|
803
|
+
}, /* @__PURE__ */React.createElement(NotificationCard3, {
|
|
790
804
|
type: "error",
|
|
791
805
|
message: intl.formatMessage({
|
|
792
806
|
id: "khMx/2",
|
|
@@ -801,18 +815,30 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
801
815
|
var ErrorBoundary = /* @__PURE__ */__name(({
|
|
802
816
|
children
|
|
803
817
|
}) => {
|
|
804
|
-
return /* @__PURE__ */
|
|
818
|
+
return /* @__PURE__ */React.createElement(ReactErrorBoundary, {
|
|
805
819
|
FallbackComponent: ErrorFallback,
|
|
806
820
|
onError: /* @__PURE__ */__name(error => {
|
|
807
821
|
notify({
|
|
808
822
|
type: "error",
|
|
809
823
|
title: "Authentication Error",
|
|
810
|
-
message: error.message
|
|
824
|
+
message: error instanceof Error ? error.message : String(error)
|
|
811
825
|
});
|
|
812
826
|
}, "onError")
|
|
813
827
|
}, children);
|
|
814
828
|
}, "ErrorBoundary");
|
|
815
829
|
|
|
830
|
+
// src/useAuthScreen.ts
|
|
831
|
+
import * as React4 from "react";
|
|
832
|
+
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
833
|
+
const [screen, setScreen] = React4.useState(initialScreen || {
|
|
834
|
+
value: "signIn"
|
|
835
|
+
});
|
|
836
|
+
return {
|
|
837
|
+
screen,
|
|
838
|
+
setScreen
|
|
839
|
+
};
|
|
840
|
+
}, "useAuthScreen");
|
|
841
|
+
|
|
816
842
|
// src/Auth.tsx
|
|
817
843
|
var AuthLogic = /* @__PURE__ */__name(props => {
|
|
818
844
|
const {
|
|
@@ -825,7 +851,8 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
825
851
|
onConfirmSignUpWithCode,
|
|
826
852
|
onForgotPasswordResetPassword,
|
|
827
853
|
passwordMinimumLength,
|
|
828
|
-
signUpTerms
|
|
854
|
+
signUpTerms,
|
|
855
|
+
maxForgotPasswordCodeLength
|
|
829
856
|
} = props;
|
|
830
857
|
const {
|
|
831
858
|
clearNotifications,
|
|
@@ -896,7 +923,8 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
896
923
|
return /* @__PURE__ */React5.createElement(AuthForgotPasswordResetPassword, {
|
|
897
924
|
onForgotPasswordResetPassword: notificationsWrapper(onForgotPasswordResetPassword),
|
|
898
925
|
onGoToSignIn,
|
|
899
|
-
email: screen.context.email
|
|
926
|
+
email: screen.context.email,
|
|
927
|
+
maxCodeLength: maxForgotPasswordCodeLength
|
|
900
928
|
});
|
|
901
929
|
}
|
|
902
930
|
if (screen.value === "confirmSignUpWithCode" && onConfirmSignUpWithCode) {
|
|
@@ -918,11 +946,26 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
918
946
|
fullScreen: true
|
|
919
947
|
}
|
|
920
948
|
} = props;
|
|
949
|
+
const authScreenHook = useAuthScreen(props.initialScreen);
|
|
950
|
+
const screen = props.screen ?? authScreenHook.screen;
|
|
951
|
+
const setScreen = props.setScreen ?? authScreenHook.setScreen;
|
|
921
952
|
const withLogoNode = React5.useMemo(() => {
|
|
922
953
|
return /* @__PURE__ */React5.createElement(LogoProvider, {
|
|
923
954
|
logo: props.logo
|
|
924
|
-
}, /* @__PURE__ */React5.createElement(ErrorBoundary, null, /* @__PURE__ */React5.createElement(AuthLogic,
|
|
925
|
-
|
|
955
|
+
}, /* @__PURE__ */React5.createElement(ErrorBoundary, null, /* @__PURE__ */React5.createElement(AuthLogic, {
|
|
956
|
+
screen,
|
|
957
|
+
setScreen,
|
|
958
|
+
signUpTerms: props.signUpTerms,
|
|
959
|
+
passwordMinimumLength: props.passwordMinimumLength,
|
|
960
|
+
maxForgotPasswordCodeLength: props.maxForgotPasswordCodeLength,
|
|
961
|
+
onSignIn: props.onSignIn,
|
|
962
|
+
onSignUp: props.onSignUp,
|
|
963
|
+
onConfirmSignUpCheckEmail: props.onConfirmSignUpCheckEmail,
|
|
964
|
+
onConfirmSignUpWithCode: props.onConfirmSignUpWithCode,
|
|
965
|
+
onForgotPassword: props.onForgotPassword,
|
|
966
|
+
onForgotPasswordResetPassword: props.onForgotPasswordResetPassword
|
|
967
|
+
})));
|
|
968
|
+
}, [props, screen, setScreen]);
|
|
926
969
|
if (layout.fullScreen) {
|
|
927
970
|
if (layout.sideContentPosition) {
|
|
928
971
|
return /* @__PURE__ */React5.createElement(AuthFullScreen, null, /* @__PURE__ */React5.createElement(Flex5, {
|
|
@@ -1018,16 +1061,4 @@ var useAuth = /* @__PURE__ */__name(() => {
|
|
|
1018
1061
|
}
|
|
1019
1062
|
return context;
|
|
1020
1063
|
}, "useAuth");
|
|
1021
|
-
|
|
1022
|
-
// src/useAuthScreen.ts
|
|
1023
|
-
import * as React7 from "react";
|
|
1024
|
-
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
1025
|
-
const [screen, setScreen] = React7.useState(initialScreen || {
|
|
1026
|
-
value: "signIn"
|
|
1027
|
-
});
|
|
1028
|
-
return {
|
|
1029
|
-
screen,
|
|
1030
|
-
setScreen
|
|
1031
|
-
};
|
|
1032
|
-
}, "useAuthScreen");
|
|
1033
1064
|
export { Auth, AuthConfirmSignUpCheckEmail, AuthConfirmSignUpWithCode, AuthForgotPassword, AuthForgotPasswordResetPassword, AuthFullScreen, AuthProvider, AuthSignIn, AuthSignUp, ErrorBoundary, useAuth, useAuthScreen };
|
package/dist/index.d.cts
CHANGED
|
@@ -46,7 +46,8 @@ type AuthScreen = {
|
|
|
46
46
|
} | {
|
|
47
47
|
value: 'confirmResetPassword';
|
|
48
48
|
context: {
|
|
49
|
-
email
|
|
49
|
+
email?: string;
|
|
50
|
+
code?: string;
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
53
|
type OnSignInInput = {
|
|
@@ -67,8 +68,8 @@ type OnForgotPasswordInput = {
|
|
|
67
68
|
email: string;
|
|
68
69
|
};
|
|
69
70
|
type OnForgotPasswordResetPasswordInput = {
|
|
70
|
-
email
|
|
71
|
-
code
|
|
71
|
+
email?: string;
|
|
72
|
+
code?: string;
|
|
72
73
|
newPassword: string;
|
|
73
74
|
};
|
|
74
75
|
type OnSignIn = (input: OnSignInInput) => Promise<void> | void;
|
|
@@ -85,11 +86,10 @@ type SignUpTerms = {
|
|
|
85
86
|
}[];
|
|
86
87
|
};
|
|
87
88
|
|
|
88
|
-
type
|
|
89
|
-
screen: AuthScreen;
|
|
90
|
-
setScreen: (screen: AuthScreen) => void;
|
|
89
|
+
type AuthPropsBase = {
|
|
91
90
|
signUpTerms?: SignUpTerms;
|
|
92
91
|
passwordMinimumLength?: number;
|
|
92
|
+
maxForgotPasswordCodeLength?: number;
|
|
93
93
|
onSignIn: OnSignIn;
|
|
94
94
|
onSignUp?: OnSignUp;
|
|
95
95
|
onConfirmSignUpCheckEmail?: OnConfirmSignUpCheckEmail;
|
|
@@ -97,12 +97,22 @@ type AuthLogicProps = {
|
|
|
97
97
|
onForgotPassword?: OnForgotPassword;
|
|
98
98
|
onForgotPasswordResetPassword?: OnForgotPasswordResetPassword;
|
|
99
99
|
};
|
|
100
|
+
type AuthPropsWithScreen = AuthPropsBase & {
|
|
101
|
+
screen: AuthScreen;
|
|
102
|
+
setScreen: (screen: AuthScreen) => void;
|
|
103
|
+
initialScreen?: never;
|
|
104
|
+
};
|
|
105
|
+
type AuthPropsWithInitialScreen = AuthPropsBase & {
|
|
106
|
+
screen?: never;
|
|
107
|
+
setScreen?: never;
|
|
108
|
+
initialScreen?: AuthScreen;
|
|
109
|
+
};
|
|
100
110
|
type AuthLayout = {
|
|
101
111
|
fullScreen?: boolean;
|
|
102
112
|
sideContent?: React$1.ReactNode;
|
|
103
113
|
sideContentPosition?: 'left' | 'right';
|
|
104
114
|
};
|
|
105
|
-
type AuthProps = LogoContextProps &
|
|
115
|
+
type AuthProps = LogoContextProps & (AuthPropsWithScreen | AuthPropsWithInitialScreen) & {
|
|
106
116
|
layout?: AuthLayout;
|
|
107
117
|
};
|
|
108
118
|
declare const Auth: (props: AuthProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -126,7 +136,8 @@ type AuthForgotPasswordProps = {
|
|
|
126
136
|
declare const AuthForgotPassword: (props: AuthForgotPasswordProps) => react_jsx_runtime.JSX.Element;
|
|
127
137
|
|
|
128
138
|
type AuthForgotPasswordResetPasswordProps = {
|
|
129
|
-
email
|
|
139
|
+
email?: string;
|
|
140
|
+
maxCodeLength?: number;
|
|
130
141
|
onForgotPasswordResetPassword: OnForgotPasswordResetPassword;
|
|
131
142
|
onGoToSignIn: () => void;
|
|
132
143
|
passwordMinimumLength?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,8 @@ type AuthScreen = {
|
|
|
46
46
|
} | {
|
|
47
47
|
value: 'confirmResetPassword';
|
|
48
48
|
context: {
|
|
49
|
-
email
|
|
49
|
+
email?: string;
|
|
50
|
+
code?: string;
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
53
|
type OnSignInInput = {
|
|
@@ -67,8 +68,8 @@ type OnForgotPasswordInput = {
|
|
|
67
68
|
email: string;
|
|
68
69
|
};
|
|
69
70
|
type OnForgotPasswordResetPasswordInput = {
|
|
70
|
-
email
|
|
71
|
-
code
|
|
71
|
+
email?: string;
|
|
72
|
+
code?: string;
|
|
72
73
|
newPassword: string;
|
|
73
74
|
};
|
|
74
75
|
type OnSignIn = (input: OnSignInInput) => Promise<void> | void;
|
|
@@ -85,11 +86,10 @@ type SignUpTerms = {
|
|
|
85
86
|
}[];
|
|
86
87
|
};
|
|
87
88
|
|
|
88
|
-
type
|
|
89
|
-
screen: AuthScreen;
|
|
90
|
-
setScreen: (screen: AuthScreen) => void;
|
|
89
|
+
type AuthPropsBase = {
|
|
91
90
|
signUpTerms?: SignUpTerms;
|
|
92
91
|
passwordMinimumLength?: number;
|
|
92
|
+
maxForgotPasswordCodeLength?: number;
|
|
93
93
|
onSignIn: OnSignIn;
|
|
94
94
|
onSignUp?: OnSignUp;
|
|
95
95
|
onConfirmSignUpCheckEmail?: OnConfirmSignUpCheckEmail;
|
|
@@ -97,12 +97,22 @@ type AuthLogicProps = {
|
|
|
97
97
|
onForgotPassword?: OnForgotPassword;
|
|
98
98
|
onForgotPasswordResetPassword?: OnForgotPasswordResetPassword;
|
|
99
99
|
};
|
|
100
|
+
type AuthPropsWithScreen = AuthPropsBase & {
|
|
101
|
+
screen: AuthScreen;
|
|
102
|
+
setScreen: (screen: AuthScreen) => void;
|
|
103
|
+
initialScreen?: never;
|
|
104
|
+
};
|
|
105
|
+
type AuthPropsWithInitialScreen = AuthPropsBase & {
|
|
106
|
+
screen?: never;
|
|
107
|
+
setScreen?: never;
|
|
108
|
+
initialScreen?: AuthScreen;
|
|
109
|
+
};
|
|
100
110
|
type AuthLayout = {
|
|
101
111
|
fullScreen?: boolean;
|
|
102
112
|
sideContent?: React$1.ReactNode;
|
|
103
113
|
sideContentPosition?: 'left' | 'right';
|
|
104
114
|
};
|
|
105
|
-
type AuthProps = LogoContextProps &
|
|
115
|
+
type AuthProps = LogoContextProps & (AuthPropsWithScreen | AuthPropsWithInitialScreen) & {
|
|
106
116
|
layout?: AuthLayout;
|
|
107
117
|
};
|
|
108
118
|
declare const Auth: (props: AuthProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -126,7 +136,8 @@ type AuthForgotPasswordProps = {
|
|
|
126
136
|
declare const AuthForgotPassword: (props: AuthForgotPasswordProps) => react_jsx_runtime.JSX.Element;
|
|
127
137
|
|
|
128
138
|
type AuthForgotPasswordResetPasswordProps = {
|
|
129
|
-
email
|
|
139
|
+
email?: string;
|
|
140
|
+
maxCodeLength?: number;
|
|
130
141
|
onForgotPasswordResetPassword: OnForgotPasswordResetPassword;
|
|
131
142
|
onGoToSignIn: () => void;
|
|
132
143
|
passwordMinimumLength?: number;
|
package/dist/index.js
CHANGED
|
@@ -362,14 +362,29 @@ var AuthForgotPasswordResetPassword = /* @__PURE__ */__name(props => {
|
|
|
362
362
|
const {
|
|
363
363
|
intl
|
|
364
364
|
} = (0, import_react_i18n4.useI18n)();
|
|
365
|
+
const codeValidation = import_forms3.yup.string().required(intl.formatMessage({
|
|
366
|
+
id: "0XOzcH",
|
|
367
|
+
defaultMessage: [{
|
|
368
|
+
"type": 0,
|
|
369
|
+
"value": "Required field"
|
|
370
|
+
}]
|
|
371
|
+
}));
|
|
365
372
|
const schema = import_forms3.yup.object().shape({
|
|
366
|
-
code:
|
|
367
|
-
id: "
|
|
373
|
+
code: props.maxCodeLength ? codeValidation.min(props.maxCodeLength, intl.formatMessage({
|
|
374
|
+
id: "S3pjKw",
|
|
368
375
|
defaultMessage: [{
|
|
369
376
|
"type": 0,
|
|
370
|
-
"value": "
|
|
377
|
+
"value": "Minimum "
|
|
378
|
+
}, {
|
|
379
|
+
"type": 1,
|
|
380
|
+
"value": "value"
|
|
381
|
+
}, {
|
|
382
|
+
"type": 0,
|
|
383
|
+
"value": " characters"
|
|
371
384
|
}]
|
|
372
|
-
}
|
|
385
|
+
}, {
|
|
386
|
+
value: props.maxCodeLength
|
|
387
|
+
})).max(props.maxCodeLength, intl.formatMessage({
|
|
373
388
|
id: "SfWKyS",
|
|
374
389
|
defaultMessage: [{
|
|
375
390
|
"type": 0,
|
|
@@ -382,8 +397,8 @@ var AuthForgotPasswordResetPassword = /* @__PURE__ */__name(props => {
|
|
|
382
397
|
"value": " characters"
|
|
383
398
|
}]
|
|
384
399
|
}, {
|
|
385
|
-
value:
|
|
386
|
-
})),
|
|
400
|
+
value: props.maxCodeLength
|
|
401
|
+
})) : codeValidation,
|
|
387
402
|
newPassword: import_forms3.yup.string().required(intl.formatMessage({
|
|
388
403
|
id: "kdFYba",
|
|
389
404
|
defaultMessage: [{
|
|
@@ -828,7 +843,6 @@ var AuthSignUp = /* @__PURE__ */__name(props => {
|
|
|
828
843
|
var import_NotificationCard3 = require("@ttoss/components/NotificationCard");
|
|
829
844
|
var import_logger = require("@ttoss/logger");
|
|
830
845
|
var import_react_i18n7 = require("@ttoss/react-i18n");
|
|
831
|
-
var React4 = __toESM(require("react"), 1);
|
|
832
846
|
var import_react_error_boundary = require("react-error-boundary");
|
|
833
847
|
var ErrorFallback = /* @__PURE__ */__name(({
|
|
834
848
|
resetErrorBoundary
|
|
@@ -836,9 +850,9 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
836
850
|
const {
|
|
837
851
|
intl
|
|
838
852
|
} = (0, import_react_i18n7.useI18n)();
|
|
839
|
-
return /* @__PURE__ */
|
|
853
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
840
854
|
role: "alert"
|
|
841
|
-
}, /* @__PURE__ */
|
|
855
|
+
}, /* @__PURE__ */React.createElement(import_NotificationCard3.NotificationCard, {
|
|
842
856
|
type: "error",
|
|
843
857
|
message: intl.formatMessage({
|
|
844
858
|
id: "khMx/2",
|
|
@@ -853,18 +867,30 @@ var ErrorFallback = /* @__PURE__ */__name(({
|
|
|
853
867
|
var ErrorBoundary = /* @__PURE__ */__name(({
|
|
854
868
|
children
|
|
855
869
|
}) => {
|
|
856
|
-
return /* @__PURE__ */
|
|
870
|
+
return /* @__PURE__ */React.createElement(import_react_error_boundary.ErrorBoundary, {
|
|
857
871
|
FallbackComponent: ErrorFallback,
|
|
858
872
|
onError: /* @__PURE__ */__name(error => {
|
|
859
873
|
(0, import_logger.notify)({
|
|
860
874
|
type: "error",
|
|
861
875
|
title: "Authentication Error",
|
|
862
|
-
message: error.message
|
|
876
|
+
message: error instanceof Error ? error.message : String(error)
|
|
863
877
|
});
|
|
864
878
|
}, "onError")
|
|
865
879
|
}, children);
|
|
866
880
|
}, "ErrorBoundary");
|
|
867
881
|
|
|
882
|
+
// src/useAuthScreen.ts
|
|
883
|
+
var React4 = __toESM(require("react"), 1);
|
|
884
|
+
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
885
|
+
const [screen, setScreen] = React4.useState(initialScreen || {
|
|
886
|
+
value: "signIn"
|
|
887
|
+
});
|
|
888
|
+
return {
|
|
889
|
+
screen,
|
|
890
|
+
setScreen
|
|
891
|
+
};
|
|
892
|
+
}, "useAuthScreen");
|
|
893
|
+
|
|
868
894
|
// src/Auth.tsx
|
|
869
895
|
var AuthLogic = /* @__PURE__ */__name(props => {
|
|
870
896
|
const {
|
|
@@ -877,7 +903,8 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
877
903
|
onConfirmSignUpWithCode,
|
|
878
904
|
onForgotPasswordResetPassword,
|
|
879
905
|
passwordMinimumLength,
|
|
880
|
-
signUpTerms
|
|
906
|
+
signUpTerms,
|
|
907
|
+
maxForgotPasswordCodeLength
|
|
881
908
|
} = props;
|
|
882
909
|
const {
|
|
883
910
|
clearNotifications,
|
|
@@ -948,7 +975,8 @@ var AuthLogic = /* @__PURE__ */__name(props => {
|
|
|
948
975
|
return /* @__PURE__ */React5.createElement(AuthForgotPasswordResetPassword, {
|
|
949
976
|
onForgotPasswordResetPassword: notificationsWrapper(onForgotPasswordResetPassword),
|
|
950
977
|
onGoToSignIn,
|
|
951
|
-
email: screen.context.email
|
|
978
|
+
email: screen.context.email,
|
|
979
|
+
maxCodeLength: maxForgotPasswordCodeLength
|
|
952
980
|
});
|
|
953
981
|
}
|
|
954
982
|
if (screen.value === "confirmSignUpWithCode" && onConfirmSignUpWithCode) {
|
|
@@ -970,11 +998,26 @@ var Auth = /* @__PURE__ */__name(props => {
|
|
|
970
998
|
fullScreen: true
|
|
971
999
|
}
|
|
972
1000
|
} = props;
|
|
1001
|
+
const authScreenHook = useAuthScreen(props.initialScreen);
|
|
1002
|
+
const screen = props.screen ?? authScreenHook.screen;
|
|
1003
|
+
const setScreen = props.setScreen ?? authScreenHook.setScreen;
|
|
973
1004
|
const withLogoNode = React5.useMemo(() => {
|
|
974
1005
|
return /* @__PURE__ */React5.createElement(LogoProvider, {
|
|
975
1006
|
logo: props.logo
|
|
976
|
-
}, /* @__PURE__ */React5.createElement(ErrorBoundary, null, /* @__PURE__ */React5.createElement(AuthLogic,
|
|
977
|
-
|
|
1007
|
+
}, /* @__PURE__ */React5.createElement(ErrorBoundary, null, /* @__PURE__ */React5.createElement(AuthLogic, {
|
|
1008
|
+
screen,
|
|
1009
|
+
setScreen,
|
|
1010
|
+
signUpTerms: props.signUpTerms,
|
|
1011
|
+
passwordMinimumLength: props.passwordMinimumLength,
|
|
1012
|
+
maxForgotPasswordCodeLength: props.maxForgotPasswordCodeLength,
|
|
1013
|
+
onSignIn: props.onSignIn,
|
|
1014
|
+
onSignUp: props.onSignUp,
|
|
1015
|
+
onConfirmSignUpCheckEmail: props.onConfirmSignUpCheckEmail,
|
|
1016
|
+
onConfirmSignUpWithCode: props.onConfirmSignUpWithCode,
|
|
1017
|
+
onForgotPassword: props.onForgotPassword,
|
|
1018
|
+
onForgotPasswordResetPassword: props.onForgotPasswordResetPassword
|
|
1019
|
+
})));
|
|
1020
|
+
}, [props, screen, setScreen]);
|
|
978
1021
|
if (layout.fullScreen) {
|
|
979
1022
|
if (layout.sideContentPosition) {
|
|
980
1023
|
return /* @__PURE__ */React5.createElement(AuthFullScreen, null, /* @__PURE__ */React5.createElement(import_ui7.Flex, {
|
|
@@ -1070,18 +1113,6 @@ var useAuth = /* @__PURE__ */__name(() => {
|
|
|
1070
1113
|
}
|
|
1071
1114
|
return context;
|
|
1072
1115
|
}, "useAuth");
|
|
1073
|
-
|
|
1074
|
-
// src/useAuthScreen.ts
|
|
1075
|
-
var React7 = __toESM(require("react"), 1);
|
|
1076
|
-
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
1077
|
-
const [screen, setScreen] = React7.useState(initialScreen || {
|
|
1078
|
-
value: "signIn"
|
|
1079
|
-
});
|
|
1080
|
-
return {
|
|
1081
|
-
screen,
|
|
1082
|
-
setScreen
|
|
1083
|
-
};
|
|
1084
|
-
}, "useAuthScreen");
|
|
1085
1116
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1086
1117
|
0 && (module.exports = {
|
|
1087
1118
|
Auth,
|
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.1",
|
|
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/forms": "^0.
|
|
33
|
-
"@ttoss/
|
|
34
|
-
"@ttoss/react-i18n": "^2.0
|
|
35
|
-
"@ttoss/
|
|
36
|
-
"@ttoss/
|
|
37
|
-
"@ttoss/
|
|
32
|
+
"@ttoss/forms": "^0.41.0",
|
|
33
|
+
"@ttoss/react-notifications": "^2.6.0",
|
|
34
|
+
"@ttoss/react-i18n": "^2.1.0",
|
|
35
|
+
"@ttoss/logger": "^0.7.4",
|
|
36
|
+
"@ttoss/ui": "^6.6.0",
|
|
37
|
+
"@ttoss/components": "^2.13.0"
|
|
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/
|
|
47
|
-
"@ttoss/
|
|
48
|
-
"@ttoss/i18n
|
|
49
|
-
"@ttoss/
|
|
50
|
-
"@ttoss/
|
|
51
|
-
"@ttoss/react-notifications": "^2.
|
|
52
|
-
"@ttoss/
|
|
53
|
-
"@ttoss/
|
|
45
|
+
"@ttoss/components": "^2.13.0",
|
|
46
|
+
"@ttoss/forms": "^0.41.0",
|
|
47
|
+
"@ttoss/i18n-cli": "^0.7.39",
|
|
48
|
+
"@ttoss/react-i18n": "^2.1.0",
|
|
49
|
+
"@ttoss/logger": "^0.7.4",
|
|
50
|
+
"@ttoss/config": "^1.36.0",
|
|
51
|
+
"@ttoss/react-notifications": "^2.6.0",
|
|
52
|
+
"@ttoss/ui": "^6.6.0",
|
|
53
|
+
"@ttoss/test-utils": "^4.1.0"
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|
|
56
56
|
"React",
|