@erikey/react 0.4.36 → 0.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/styles.css +144 -1
- package/dist/styles.css.map +1 -1
- package/dist/ui/index.mjs +111 -42
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/style.css +28 -0
- package/dist/ui/style.css.map +1 -1
- package/package.json +1 -1
- package/src/ui/components/auth/auth-flow.tsx +45 -4
- package/src/ui/components/auth/auth-form.tsx +6 -0
- package/src/ui/components/auth/auth-view.tsx +6 -0
- package/src/ui/components/auth/forms/email-verification-form.tsx +12 -8
- package/src/ui/components/auth/forms/forgot-password-form.tsx +11 -4
- package/src/ui/components/auth/forms/reset-password-form.tsx +18 -8
- package/src/ui/components/auth/forms/sign-in-form.tsx +16 -9
- package/src/ui/components/auth/forms/sign-up-form.tsx +28 -14
- package/src/ui/lib/auth-ui-provider.tsx +5 -0
- package/src/ui/style.css +32 -1
package/dist/ui/index.mjs
CHANGED
|
@@ -12086,7 +12086,8 @@ function EmailVerificationForm({
|
|
|
12086
12086
|
basePath,
|
|
12087
12087
|
viewPaths,
|
|
12088
12088
|
emailVerification,
|
|
12089
|
-
onAuthEvent
|
|
12089
|
+
onAuthEvent,
|
|
12090
|
+
authFlowMode
|
|
12090
12091
|
} = useContext12(AuthUIContext);
|
|
12091
12092
|
localization = { ...contextLocalization, ...localization };
|
|
12092
12093
|
const isOtpMethod = emailVerification?.otp ?? true;
|
|
@@ -12149,13 +12150,15 @@ function EmailVerificationForm({
|
|
|
12149
12150
|
} else {
|
|
12150
12151
|
const session = { user };
|
|
12151
12152
|
onAuthEvent?.({ type: "VERIFICATION_SUCCESS", user, session });
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12153
|
+
if (authFlowMode !== "internal") {
|
|
12154
|
+
navigate(
|
|
12155
|
+
`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
|
|
12156
|
+
);
|
|
12157
|
+
toast({
|
|
12158
|
+
variant: "success",
|
|
12159
|
+
message: localization.EMAIL_VERIFICATION_SUCCESS
|
|
12160
|
+
});
|
|
12161
|
+
}
|
|
12159
12162
|
}
|
|
12160
12163
|
} catch (error) {
|
|
12161
12164
|
const errorMessage = getLocalizedError({
|
|
@@ -12378,7 +12381,9 @@ function ForgotPasswordForm({
|
|
|
12378
12381
|
navigate,
|
|
12379
12382
|
toast,
|
|
12380
12383
|
viewPaths,
|
|
12381
|
-
localizeErrors
|
|
12384
|
+
localizeErrors,
|
|
12385
|
+
onAuthEvent,
|
|
12386
|
+
authFlowMode
|
|
12382
12387
|
} = useContext13(AuthUIContext);
|
|
12383
12388
|
localization = { ...contextLocalization, ...localization };
|
|
12384
12389
|
const formSchema = objectType({
|
|
@@ -12409,13 +12414,16 @@ function ForgotPasswordForm({
|
|
|
12409
12414
|
redirectTo: `${baseURL}${basePath}/${viewPaths.RESET_PASSWORD}`,
|
|
12410
12415
|
fetchOptions
|
|
12411
12416
|
});
|
|
12417
|
+
onAuthEvent?.({ type: "FORGOT_PASSWORD_EMAIL_SENT", email });
|
|
12412
12418
|
toast({
|
|
12413
12419
|
variant: "success",
|
|
12414
12420
|
message: localization.FORGOT_PASSWORD_EMAIL
|
|
12415
12421
|
});
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12422
|
+
if (authFlowMode !== "internal") {
|
|
12423
|
+
navigate(
|
|
12424
|
+
`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
|
|
12425
|
+
);
|
|
12426
|
+
}
|
|
12419
12427
|
} catch (error) {
|
|
12420
12428
|
toast({
|
|
12421
12429
|
variant: "error",
|
|
@@ -12788,7 +12796,9 @@ function ResetPasswordForm({
|
|
|
12788
12796
|
viewPaths,
|
|
12789
12797
|
navigate,
|
|
12790
12798
|
toast,
|
|
12791
|
-
localizeErrors
|
|
12799
|
+
localizeErrors,
|
|
12800
|
+
onAuthEvent,
|
|
12801
|
+
authFlowMode
|
|
12792
12802
|
} = useContext16(AuthUIContext);
|
|
12793
12803
|
const confirmPasswordEnabled = credentials?.confirmPassword;
|
|
12794
12804
|
const contextPasswordValidation = credentials?.passwordValidation;
|
|
@@ -12828,12 +12838,14 @@ function ResetPasswordForm({
|
|
|
12828
12838
|
const searchParams = new URLSearchParams(window.location.search);
|
|
12829
12839
|
const token = searchParams.get("token");
|
|
12830
12840
|
if (!token || token === "INVALID_TOKEN") {
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12841
|
+
if (authFlowMode !== "internal") {
|
|
12842
|
+
navigate(
|
|
12843
|
+
`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
|
|
12844
|
+
);
|
|
12845
|
+
}
|
|
12834
12846
|
toast({ variant: "error", message: localization.INVALID_TOKEN });
|
|
12835
12847
|
}
|
|
12836
|
-
}, [basePath, navigate, toast, viewPaths, localization]);
|
|
12848
|
+
}, [basePath, navigate, toast, viewPaths, localization, authFlowMode]);
|
|
12837
12849
|
async function resetPassword({ newPassword }) {
|
|
12838
12850
|
try {
|
|
12839
12851
|
const searchParams = new URLSearchParams(window.location.search);
|
|
@@ -12843,13 +12855,16 @@ function ResetPasswordForm({
|
|
|
12843
12855
|
token,
|
|
12844
12856
|
fetchOptions: { throw: true }
|
|
12845
12857
|
});
|
|
12858
|
+
onAuthEvent?.({ type: "PASSWORD_RESET_SUCCESS" });
|
|
12846
12859
|
toast({
|
|
12847
12860
|
variant: "success",
|
|
12848
12861
|
message: localization.RESET_PASSWORD_SUCCESS
|
|
12849
12862
|
});
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12863
|
+
if (authFlowMode !== "internal") {
|
|
12864
|
+
navigate(
|
|
12865
|
+
`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
|
|
12866
|
+
);
|
|
12867
|
+
}
|
|
12853
12868
|
} catch (error) {
|
|
12854
12869
|
toast({
|
|
12855
12870
|
variant: "error",
|
|
@@ -13008,7 +13023,8 @@ function SignInForm({
|
|
|
13008
13023
|
Link,
|
|
13009
13024
|
localizeErrors,
|
|
13010
13025
|
emailVerification,
|
|
13011
|
-
onAuthEvent
|
|
13026
|
+
onAuthEvent,
|
|
13027
|
+
authFlowMode
|
|
13012
13028
|
} = useContext17(AuthUIContext);
|
|
13013
13029
|
const rememberMeEnabled = credentials?.rememberMe;
|
|
13014
13030
|
const usernameEnabled = credentials?.username;
|
|
@@ -13072,9 +13088,11 @@ function SignInForm({
|
|
|
13072
13088
|
}
|
|
13073
13089
|
if (response.twoFactorRedirect) {
|
|
13074
13090
|
onAuthEvent?.({ type: "SIGN_IN_REQUIRES_2FA", email });
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13091
|
+
if (authFlowMode !== "internal") {
|
|
13092
|
+
navigate(
|
|
13093
|
+
`${basePath}/${viewPaths.TWO_FACTOR}${window.location.search}`
|
|
13094
|
+
);
|
|
13095
|
+
}
|
|
13078
13096
|
} else {
|
|
13079
13097
|
const user = response.user;
|
|
13080
13098
|
const session = {
|
|
@@ -13105,9 +13123,11 @@ function SignInForm({
|
|
|
13105
13123
|
});
|
|
13106
13124
|
if (errorCode === "EMAIL_NOT_VERIFIED") {
|
|
13107
13125
|
onAuthEvent?.({ type: "SIGN_IN_REQUIRES_VERIFICATION", email });
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13126
|
+
if (authFlowMode !== "internal") {
|
|
13127
|
+
navigate(
|
|
13128
|
+
`${basePath}/${viewPaths.EMAIL_VERIFICATION}?email=${encodeURIComponent(email)}`
|
|
13129
|
+
);
|
|
13130
|
+
}
|
|
13111
13131
|
}
|
|
13112
13132
|
}
|
|
13113
13133
|
}
|
|
@@ -13455,7 +13475,8 @@ function SignUpForm({
|
|
|
13455
13475
|
avatar,
|
|
13456
13476
|
localizeErrors,
|
|
13457
13477
|
emailVerification,
|
|
13458
|
-
onAuthEvent
|
|
13478
|
+
onAuthEvent,
|
|
13479
|
+
authFlowMode
|
|
13459
13480
|
} = useContext19(AuthUIContext);
|
|
13460
13481
|
const confirmPasswordEnabled = credentials?.confirmPassword;
|
|
13461
13482
|
const usernameEnabled = credentials?.username;
|
|
@@ -13670,9 +13691,15 @@ function SignUpForm({
|
|
|
13670
13691
|
onAuthEvent?.({ type: "SIGN_UP_SUCCESS", user });
|
|
13671
13692
|
}
|
|
13672
13693
|
if (response.twoFactorRedirect) {
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13694
|
+
onAuthEvent?.({
|
|
13695
|
+
type: "SIGN_IN_REQUIRES_2FA",
|
|
13696
|
+
email
|
|
13697
|
+
});
|
|
13698
|
+
if (authFlowMode !== "internal") {
|
|
13699
|
+
navigate(
|
|
13700
|
+
`${basePath}/${viewPaths.TWO_FACTOR}${window.location.search}`
|
|
13701
|
+
);
|
|
13702
|
+
}
|
|
13676
13703
|
} else if (response.token && user) {
|
|
13677
13704
|
const session = {
|
|
13678
13705
|
token: response.token,
|
|
@@ -13685,21 +13712,25 @@ function SignUpForm({
|
|
|
13685
13712
|
type: "SIGN_UP_REQUIRES_VERIFICATION",
|
|
13686
13713
|
email
|
|
13687
13714
|
});
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13715
|
+
if (authFlowMode !== "internal") {
|
|
13716
|
+
navigate(
|
|
13717
|
+
`${basePath}/${viewPaths.EMAIL_VERIFICATION}?email=${encodeURIComponent(email)}`
|
|
13718
|
+
);
|
|
13719
|
+
}
|
|
13691
13720
|
} else {
|
|
13692
13721
|
onAuthEvent?.({
|
|
13693
13722
|
type: "SIGN_UP_REQUIRES_VERIFICATION",
|
|
13694
13723
|
email
|
|
13695
13724
|
});
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13725
|
+
if (authFlowMode !== "internal") {
|
|
13726
|
+
navigate(
|
|
13727
|
+
`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
|
|
13728
|
+
);
|
|
13729
|
+
toast({
|
|
13730
|
+
variant: "success",
|
|
13731
|
+
message: localization.SIGN_UP_EMAIL
|
|
13732
|
+
});
|
|
13733
|
+
}
|
|
13703
13734
|
}
|
|
13704
13735
|
} catch (error) {
|
|
13705
13736
|
const errorMessage = getLocalizedError({
|
|
@@ -14388,6 +14419,7 @@ function AuthForm({
|
|
|
14388
14419
|
className,
|
|
14389
14420
|
classNames,
|
|
14390
14421
|
callbackURL,
|
|
14422
|
+
email,
|
|
14391
14423
|
isSubmitting,
|
|
14392
14424
|
localization,
|
|
14393
14425
|
pathname,
|
|
@@ -14552,6 +14584,7 @@ function AuthForm({
|
|
|
14552
14584
|
className,
|
|
14553
14585
|
classNames,
|
|
14554
14586
|
callbackURL,
|
|
14587
|
+
email,
|
|
14555
14588
|
localization,
|
|
14556
14589
|
otpSeparators,
|
|
14557
14590
|
redirectTo,
|
|
@@ -15107,6 +15140,7 @@ function AuthView({
|
|
|
15107
15140
|
callbackURL,
|
|
15108
15141
|
cardHeader,
|
|
15109
15142
|
cardFooter,
|
|
15143
|
+
email,
|
|
15110
15144
|
localization,
|
|
15111
15145
|
path: pathProp,
|
|
15112
15146
|
pathname,
|
|
@@ -15194,6 +15228,7 @@ function AuthView({
|
|
|
15194
15228
|
{
|
|
15195
15229
|
classNames: classNames?.form,
|
|
15196
15230
|
callbackURL,
|
|
15231
|
+
email,
|
|
15197
15232
|
isSubmitting,
|
|
15198
15233
|
localization,
|
|
15199
15234
|
otpSeparators,
|
|
@@ -15542,8 +15577,40 @@ function AuthFlow({
|
|
|
15542
15577
|
const handleAuthEvent = useCallback9(
|
|
15543
15578
|
(event) => {
|
|
15544
15579
|
onEvent?.(event);
|
|
15580
|
+
if (mode === "internal") {
|
|
15581
|
+
switch (event.type) {
|
|
15582
|
+
// Sign-up flow
|
|
15583
|
+
case "SIGN_UP_REQUIRES_VERIFICATION":
|
|
15584
|
+
setCurrentView("EMAIL_VERIFICATION");
|
|
15585
|
+
setVerifyEmail(event.email);
|
|
15586
|
+
break;
|
|
15587
|
+
// Sign-in flow
|
|
15588
|
+
case "SIGN_IN_REQUIRES_2FA":
|
|
15589
|
+
setCurrentView("TWO_FACTOR");
|
|
15590
|
+
break;
|
|
15591
|
+
case "SIGN_IN_REQUIRES_VERIFICATION":
|
|
15592
|
+
setCurrentView("EMAIL_VERIFICATION");
|
|
15593
|
+
setVerifyEmail(event.email);
|
|
15594
|
+
break;
|
|
15595
|
+
// Verification success without token → sign in
|
|
15596
|
+
case "VERIFICATION_SUCCESS":
|
|
15597
|
+
if (!event.session?.token) {
|
|
15598
|
+
setCurrentView("SIGN_IN");
|
|
15599
|
+
}
|
|
15600
|
+
break;
|
|
15601
|
+
// Password reset flow
|
|
15602
|
+
case "PASSWORD_RESET_SUCCESS":
|
|
15603
|
+
setCurrentView("SIGN_IN");
|
|
15604
|
+
break;
|
|
15605
|
+
// View toggles (footer links) - handled by InternalLink
|
|
15606
|
+
case "VIEW_CHANGE":
|
|
15607
|
+
setCurrentView(event.view);
|
|
15608
|
+
if (event.email) setVerifyEmail(event.email);
|
|
15609
|
+
break;
|
|
15610
|
+
}
|
|
15611
|
+
}
|
|
15545
15612
|
},
|
|
15546
|
-
[onEvent]
|
|
15613
|
+
[onEvent, mode]
|
|
15547
15614
|
);
|
|
15548
15615
|
const viewKey = useMemo5(() => {
|
|
15549
15616
|
if (mode === "route") {
|
|
@@ -15558,6 +15625,7 @@ function AuthFlow({
|
|
|
15558
15625
|
basePath,
|
|
15559
15626
|
navigate: handleNavigate,
|
|
15560
15627
|
onAuthEvent: handleAuthEvent,
|
|
15628
|
+
authFlowMode: mode,
|
|
15561
15629
|
redirectTo,
|
|
15562
15630
|
Link: InternalLink,
|
|
15563
15631
|
...providerProps,
|
|
@@ -15568,6 +15636,7 @@ function AuthFlow({
|
|
|
15568
15636
|
classNames,
|
|
15569
15637
|
cardHeader,
|
|
15570
15638
|
cardFooter,
|
|
15639
|
+
email: verifyEmail,
|
|
15571
15640
|
socialLayout,
|
|
15572
15641
|
otpSeparators,
|
|
15573
15642
|
redirectTo,
|