mailsentry-auth 0.2.3 → 0.2.4
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.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +133 -29
- package/dist/index.mjs +193 -89
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -555,6 +555,14 @@ declare class AuthService extends BaseService implements IAuthService {
|
|
|
555
555
|
* Logout user
|
|
556
556
|
*/
|
|
557
557
|
logout(): Promise<void>;
|
|
558
|
+
/**
|
|
559
|
+
* Send forgot password email
|
|
560
|
+
*/
|
|
561
|
+
forgotPassword(email: string): Promise<void>;
|
|
562
|
+
/**
|
|
563
|
+
* Resend verification code
|
|
564
|
+
*/
|
|
565
|
+
resendVerification(email: string): Promise<void>;
|
|
558
566
|
}
|
|
559
567
|
|
|
560
568
|
/**
|
|
@@ -568,6 +576,8 @@ declare const AUTH_ENDPOINTS: {
|
|
|
568
576
|
readonly GET_USER_PROFILE: "/auth/user/profile";
|
|
569
577
|
readonly GET_ME: "/auth/user/me";
|
|
570
578
|
readonly LOGOUT: "/auth/logout";
|
|
579
|
+
readonly FORGOT_PASSWORD: "/auth/user/forget-password";
|
|
580
|
+
readonly RESEND_VERIFICATION: "/auth/user/generate-verification";
|
|
571
581
|
};
|
|
572
582
|
/**
|
|
573
583
|
* Endpoint builder utility
|
|
@@ -581,6 +591,8 @@ declare class EndpointBuilder {
|
|
|
581
591
|
readonly GET_USER_PROFILE: "/auth/user/profile";
|
|
582
592
|
readonly GET_ME: "/auth/user/me";
|
|
583
593
|
readonly LOGOUT: "/auth/logout";
|
|
594
|
+
readonly FORGOT_PASSWORD: "/auth/user/forget-password";
|
|
595
|
+
readonly RESEND_VERIFICATION: "/auth/user/generate-verification";
|
|
584
596
|
};
|
|
585
597
|
}
|
|
586
598
|
|
|
@@ -830,6 +842,14 @@ declare class AuthOrchestrator implements IAuthOrchestrator {
|
|
|
830
842
|
* Get detailed token information
|
|
831
843
|
*/
|
|
832
844
|
getTokenInfo(): Promise<AuthActionResult>;
|
|
845
|
+
/**
|
|
846
|
+
* Handle forgot password flow
|
|
847
|
+
*/
|
|
848
|
+
handleForgotPassword(email: string): Promise<AuthActionResult>;
|
|
849
|
+
/**
|
|
850
|
+
* Handle resend verification code
|
|
851
|
+
*/
|
|
852
|
+
handleResendVerification(email: string): Promise<AuthActionResult>;
|
|
833
853
|
}
|
|
834
854
|
/**
|
|
835
855
|
* Authentication Orchestrator Factory
|
|
@@ -987,9 +1007,8 @@ interface PasswordStepProps extends BaseStepProps {
|
|
|
987
1007
|
interface VerificationStepProps extends BaseStepProps {
|
|
988
1008
|
email: string;
|
|
989
1009
|
onSubmit: (verificationCode: string) => void | Promise<void>;
|
|
990
|
-
onResendCode?: () => void
|
|
1010
|
+
onResendCode?: () => void | Promise<void>;
|
|
991
1011
|
codeLength?: number;
|
|
992
|
-
showResendButton?: boolean;
|
|
993
1012
|
}
|
|
994
1013
|
|
|
995
1014
|
interface ForgotPasswordStepProps extends BaseStepProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -555,6 +555,14 @@ declare class AuthService extends BaseService implements IAuthService {
|
|
|
555
555
|
* Logout user
|
|
556
556
|
*/
|
|
557
557
|
logout(): Promise<void>;
|
|
558
|
+
/**
|
|
559
|
+
* Send forgot password email
|
|
560
|
+
*/
|
|
561
|
+
forgotPassword(email: string): Promise<void>;
|
|
562
|
+
/**
|
|
563
|
+
* Resend verification code
|
|
564
|
+
*/
|
|
565
|
+
resendVerification(email: string): Promise<void>;
|
|
558
566
|
}
|
|
559
567
|
|
|
560
568
|
/**
|
|
@@ -568,6 +576,8 @@ declare const AUTH_ENDPOINTS: {
|
|
|
568
576
|
readonly GET_USER_PROFILE: "/auth/user/profile";
|
|
569
577
|
readonly GET_ME: "/auth/user/me";
|
|
570
578
|
readonly LOGOUT: "/auth/logout";
|
|
579
|
+
readonly FORGOT_PASSWORD: "/auth/user/forget-password";
|
|
580
|
+
readonly RESEND_VERIFICATION: "/auth/user/generate-verification";
|
|
571
581
|
};
|
|
572
582
|
/**
|
|
573
583
|
* Endpoint builder utility
|
|
@@ -581,6 +591,8 @@ declare class EndpointBuilder {
|
|
|
581
591
|
readonly GET_USER_PROFILE: "/auth/user/profile";
|
|
582
592
|
readonly GET_ME: "/auth/user/me";
|
|
583
593
|
readonly LOGOUT: "/auth/logout";
|
|
594
|
+
readonly FORGOT_PASSWORD: "/auth/user/forget-password";
|
|
595
|
+
readonly RESEND_VERIFICATION: "/auth/user/generate-verification";
|
|
584
596
|
};
|
|
585
597
|
}
|
|
586
598
|
|
|
@@ -830,6 +842,14 @@ declare class AuthOrchestrator implements IAuthOrchestrator {
|
|
|
830
842
|
* Get detailed token information
|
|
831
843
|
*/
|
|
832
844
|
getTokenInfo(): Promise<AuthActionResult>;
|
|
845
|
+
/**
|
|
846
|
+
* Handle forgot password flow
|
|
847
|
+
*/
|
|
848
|
+
handleForgotPassword(email: string): Promise<AuthActionResult>;
|
|
849
|
+
/**
|
|
850
|
+
* Handle resend verification code
|
|
851
|
+
*/
|
|
852
|
+
handleResendVerification(email: string): Promise<AuthActionResult>;
|
|
833
853
|
}
|
|
834
854
|
/**
|
|
835
855
|
* Authentication Orchestrator Factory
|
|
@@ -987,9 +1007,8 @@ interface PasswordStepProps extends BaseStepProps {
|
|
|
987
1007
|
interface VerificationStepProps extends BaseStepProps {
|
|
988
1008
|
email: string;
|
|
989
1009
|
onSubmit: (verificationCode: string) => void | Promise<void>;
|
|
990
|
-
onResendCode?: () => void
|
|
1010
|
+
onResendCode?: () => void | Promise<void>;
|
|
991
1011
|
codeLength?: number;
|
|
992
|
-
showResendButton?: boolean;
|
|
993
1012
|
}
|
|
994
1013
|
|
|
995
1014
|
interface ForgotPasswordStepProps extends BaseStepProps {
|
package/dist/index.js
CHANGED
|
@@ -566,6 +566,9 @@ var PasswordStep = ({
|
|
|
566
566
|
// src/components/auth/verification-step.tsx
|
|
567
567
|
|
|
568
568
|
|
|
569
|
+
|
|
570
|
+
var RESEND_COUNTDOWN_SECONDS = 60;
|
|
571
|
+
var COUNTDOWN_INTERVAL_MS = 1e3;
|
|
569
572
|
var VerificationStep = ({
|
|
570
573
|
title,
|
|
571
574
|
description,
|
|
@@ -574,27 +577,48 @@ var VerificationStep = ({
|
|
|
574
577
|
submitButtonText,
|
|
575
578
|
isLoading = false,
|
|
576
579
|
codeLength = 5,
|
|
577
|
-
showResendButton = true,
|
|
578
580
|
initialValues,
|
|
579
581
|
email
|
|
580
582
|
}) => {
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
583
|
+
const [countdown, setCountdown] = _react.useState.call(void 0, RESEND_COUNTDOWN_SECONDS);
|
|
584
|
+
const canResend = _react.useMemo.call(void 0, () => countdown === 0, [countdown]);
|
|
585
|
+
_react.useEffect.call(void 0, () => {
|
|
586
|
+
if (countdown === 0) return;
|
|
587
|
+
const timer = setTimeout(() => {
|
|
588
|
+
setCountdown((prev) => prev - 1);
|
|
589
|
+
}, COUNTDOWN_INTERVAL_MS);
|
|
590
|
+
return () => clearTimeout(timer);
|
|
591
|
+
}, [countdown]);
|
|
592
|
+
const handleSubmit = _react.useCallback.call(void 0,
|
|
593
|
+
async (values) => {
|
|
594
|
+
await onSubmit(values.verificationCode);
|
|
595
|
+
},
|
|
596
|
+
[onSubmit]
|
|
597
|
+
);
|
|
598
|
+
const handleResendClick = _react.useCallback.call(void 0, async () => {
|
|
599
|
+
if (!canResend || !onResendCode) return;
|
|
600
|
+
setCountdown(RESEND_COUNTDOWN_SECONDS);
|
|
601
|
+
await onResendCode();
|
|
602
|
+
}, [canResend, onResendCode]);
|
|
603
|
+
const fields = _react.useMemo.call(void 0,
|
|
604
|
+
() => [getVerificationField(codeLength, { disabled: isLoading }, email)],
|
|
605
|
+
[codeLength, isLoading, email]
|
|
606
|
+
);
|
|
607
|
+
const resendButtonText = _react.useMemo.call(void 0,
|
|
608
|
+
() => canResend ? "Resend verification code" : `Resend verification code (${countdown}s)`,
|
|
609
|
+
[canResend, countdown]
|
|
610
|
+
);
|
|
611
|
+
const additionalActions = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
588
612
|
_antd.Button,
|
|
589
613
|
{
|
|
590
614
|
type: "link",
|
|
591
|
-
onClick:
|
|
592
|
-
disabled: isLoading,
|
|
615
|
+
onClick: handleResendClick,
|
|
616
|
+
disabled: isLoading || !canResend,
|
|
593
617
|
block: true,
|
|
594
618
|
className: "mb-2",
|
|
595
|
-
children:
|
|
619
|
+
children: resendButtonText
|
|
596
620
|
}
|
|
597
|
-
)
|
|
621
|
+
);
|
|
598
622
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
599
623
|
BaseForm,
|
|
600
624
|
{
|
|
@@ -631,6 +655,9 @@ var FinishStep = () => {
|
|
|
631
655
|
|
|
632
656
|
// src/components/auth/forgot-password-step.tsx
|
|
633
657
|
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
var { Title: Title2 } = _antd.Typography;
|
|
634
661
|
var ForgotPasswordStep = ({
|
|
635
662
|
title,
|
|
636
663
|
description,
|
|
@@ -640,13 +667,23 @@ var ForgotPasswordStep = ({
|
|
|
640
667
|
submitButtonText,
|
|
641
668
|
initialValues
|
|
642
669
|
}) => {
|
|
670
|
+
const [showSuccess, setShowSuccess] = _react.useState.call(void 0, false);
|
|
671
|
+
_react.useEffect.call(void 0, () => {
|
|
672
|
+
if (showSuccess) {
|
|
673
|
+
const timer = setTimeout(() => {
|
|
674
|
+
setShowSuccess(false);
|
|
675
|
+
}, 5e3);
|
|
676
|
+
return () => clearTimeout(timer);
|
|
677
|
+
}
|
|
678
|
+
}, [showSuccess]);
|
|
643
679
|
const handleSubmit = async (values) => {
|
|
644
680
|
await onSubmit(values.email);
|
|
681
|
+
setShowSuccess(true);
|
|
645
682
|
};
|
|
646
683
|
const fields = [
|
|
647
684
|
getEmailField({ disabled: isLoading, value: email })
|
|
648
685
|
];
|
|
649
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
686
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: showSuccess ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Title2, { level: 3, className: "block mb-6", children: "We've sent an email with instructions to reset your password. Please check your inbox." }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
650
687
|
BaseForm,
|
|
651
688
|
{
|
|
652
689
|
title,
|
|
@@ -657,7 +694,7 @@ var ForgotPasswordStep = ({
|
|
|
657
694
|
isLoading,
|
|
658
695
|
initialValues: initialValues || { email }
|
|
659
696
|
}
|
|
660
|
-
);
|
|
697
|
+
) });
|
|
661
698
|
};
|
|
662
699
|
|
|
663
700
|
// src/components/auth/step-renderer.tsx
|
|
@@ -702,10 +739,10 @@ var createPropsFactoryRegistry = ({
|
|
|
702
739
|
description: `Please enter the verification code sent to ${state.email}`,
|
|
703
740
|
submitButtonText: "Verify Email",
|
|
704
741
|
email: state.email,
|
|
705
|
-
onSubmit: handlers.handleVerificationSubmit
|
|
742
|
+
onSubmit: handlers.handleVerificationSubmit || (async () => {
|
|
743
|
+
}),
|
|
706
744
|
onResendCode: handlers.handleResendCode,
|
|
707
|
-
codeLength: configs.verificationStepConfig.codeLength
|
|
708
|
-
showResendButton: configs.verificationStepConfig.showResendButton
|
|
745
|
+
codeLength: configs.verificationStepConfig.codeLength
|
|
709
746
|
}),
|
|
710
747
|
["finish" /* FINISH */]: () => __spreadProps(__spreadValues({}, baseProps), {
|
|
711
748
|
title: "Success",
|
|
@@ -1969,7 +2006,11 @@ var AUTH_ENDPOINTS = {
|
|
|
1969
2006
|
GET_USER_PROFILE: "/auth/user/profile",
|
|
1970
2007
|
GET_ME: "/auth/user/me",
|
|
1971
2008
|
// User logout
|
|
1972
|
-
LOGOUT: "/auth/logout"
|
|
2009
|
+
LOGOUT: "/auth/logout",
|
|
2010
|
+
// Password reset
|
|
2011
|
+
FORGOT_PASSWORD: "/auth/user/forget-password",
|
|
2012
|
+
// Verification
|
|
2013
|
+
RESEND_VERIFICATION: "/auth/user/generate-verification"
|
|
1973
2014
|
};
|
|
1974
2015
|
var EndpointBuilder = class {
|
|
1975
2016
|
};
|
|
@@ -2028,6 +2069,20 @@ var AuthService = class extends BaseService {
|
|
|
2028
2069
|
const endpoint = AUTH_ENDPOINTS.LOGOUT;
|
|
2029
2070
|
return this.post(endpoint);
|
|
2030
2071
|
}
|
|
2072
|
+
/**
|
|
2073
|
+
* Send forgot password email
|
|
2074
|
+
*/
|
|
2075
|
+
async forgotPassword(email) {
|
|
2076
|
+
const endpoint = AUTH_ENDPOINTS.FORGOT_PASSWORD;
|
|
2077
|
+
return this.post(endpoint, { email });
|
|
2078
|
+
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Resend verification code
|
|
2081
|
+
*/
|
|
2082
|
+
async resendVerification(email) {
|
|
2083
|
+
const endpoint = AUTH_ENDPOINTS.RESEND_VERIFICATION;
|
|
2084
|
+
return this.post(endpoint, { email });
|
|
2085
|
+
}
|
|
2031
2086
|
};
|
|
2032
2087
|
|
|
2033
2088
|
// src/services/auth/manager/user-storage-manager.ts
|
|
@@ -2613,6 +2668,32 @@ var AuthOrchestrator = class {
|
|
|
2613
2668
|
return this.errorHandler.handle(error, "Get token info");
|
|
2614
2669
|
}
|
|
2615
2670
|
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Handle forgot password flow
|
|
2673
|
+
*/
|
|
2674
|
+
async handleForgotPassword(email) {
|
|
2675
|
+
try {
|
|
2676
|
+
await this.authService.forgotPassword(email);
|
|
2677
|
+
return AuthResultFactory.createSuccess({
|
|
2678
|
+
message: "We've sent an email with instructions to reset your password. Please check your inbox."
|
|
2679
|
+
});
|
|
2680
|
+
} catch (error) {
|
|
2681
|
+
return this.errorHandler.handle(error, "Forgot password");
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
/**
|
|
2685
|
+
* Handle resend verification code
|
|
2686
|
+
*/
|
|
2687
|
+
async handleResendVerification(email) {
|
|
2688
|
+
try {
|
|
2689
|
+
await this.authService.resendVerification(email);
|
|
2690
|
+
return AuthResultFactory.createSuccess({
|
|
2691
|
+
message: "Verification code sent successfully."
|
|
2692
|
+
});
|
|
2693
|
+
} catch (error) {
|
|
2694
|
+
return this.errorHandler.handle(error, "Resend verification");
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2616
2697
|
};
|
|
2617
2698
|
var AuthOrchestratorFactory = class {
|
|
2618
2699
|
/**
|
|
@@ -3085,8 +3166,7 @@ function AuthFlowContainer({
|
|
|
3085
3166
|
showEmailField: true
|
|
3086
3167
|
},
|
|
3087
3168
|
verificationStepConfig: {
|
|
3088
|
-
codeLength: 5
|
|
3089
|
-
showResendButton: false
|
|
3169
|
+
codeLength: 5
|
|
3090
3170
|
}
|
|
3091
3171
|
};
|
|
3092
3172
|
const stepperConfig = {
|
|
@@ -3154,9 +3234,9 @@ function AuthFlowContainer({
|
|
|
3154
3234
|
return await authOrchestrator.handleEmailVerification(email, code);
|
|
3155
3235
|
},
|
|
3156
3236
|
{
|
|
3157
|
-
onSuccess: (data) => {
|
|
3237
|
+
onSuccess: async (data) => {
|
|
3158
3238
|
setAuthData(data);
|
|
3159
|
-
handlePasswordSubmitAfterVerification(password);
|
|
3239
|
+
await handlePasswordSubmitAfterVerification(password);
|
|
3160
3240
|
setPassword("");
|
|
3161
3241
|
},
|
|
3162
3242
|
onError: (error) => {
|
|
@@ -3198,6 +3278,20 @@ function AuthFlowContainer({
|
|
|
3198
3278
|
}
|
|
3199
3279
|
);
|
|
3200
3280
|
};
|
|
3281
|
+
const handleResendCode = async () => {
|
|
3282
|
+
await executeAction(
|
|
3283
|
+
async () => {
|
|
3284
|
+
return await authOrchestrator.handleResendVerification(email);
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
onSuccess: () => {
|
|
3288
|
+
},
|
|
3289
|
+
onError: (error) => {
|
|
3290
|
+
console.error(error);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
);
|
|
3294
|
+
};
|
|
3201
3295
|
const handleSuccess = () => {
|
|
3202
3296
|
stepperActions.goToStep("finish" /* FINISH */);
|
|
3203
3297
|
setTimeout(() => {
|
|
@@ -3217,7 +3311,18 @@ function AuthFlowContainer({
|
|
|
3217
3311
|
clearAll();
|
|
3218
3312
|
};
|
|
3219
3313
|
const handleForgotPassword = async (emailValue) => {
|
|
3220
|
-
|
|
3314
|
+
await executeAction(
|
|
3315
|
+
async () => {
|
|
3316
|
+
return await authOrchestrator.handleForgotPassword(emailValue);
|
|
3317
|
+
},
|
|
3318
|
+
{
|
|
3319
|
+
onSuccess: () => {
|
|
3320
|
+
},
|
|
3321
|
+
onError: (error) => {
|
|
3322
|
+
console.error(error);
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
);
|
|
3221
3326
|
};
|
|
3222
3327
|
const onForgotPasswordClick = () => {
|
|
3223
3328
|
stepperActions.goToStep("forgot-password" /* FORGOT_PASSWORD */);
|
|
@@ -3228,8 +3333,7 @@ function AuthFlowContainer({
|
|
|
3228
3333
|
handleEmailSubmit,
|
|
3229
3334
|
handlePasswordSubmit,
|
|
3230
3335
|
handleVerificationSubmit,
|
|
3231
|
-
handleResendCode
|
|
3232
|
-
},
|
|
3336
|
+
handleResendCode,
|
|
3233
3337
|
goBackToEmail,
|
|
3234
3338
|
goBackToPassword,
|
|
3235
3339
|
onGoogleSignIn: handleGoogleSignIn,
|
|
@@ -3477,7 +3581,7 @@ var ProfileStateRenderer = () => {
|
|
|
3477
3581
|
// src/components/demo/cross-tab-demo.tsx
|
|
3478
3582
|
|
|
3479
3583
|
|
|
3480
|
-
var { Title:
|
|
3584
|
+
var { Title: Title3, Text: Text2, Paragraph: Paragraph2 } = _antd.Typography;
|
|
3481
3585
|
var CrossTabDemo = () => {
|
|
3482
3586
|
var _a;
|
|
3483
3587
|
const { isAuthenticated, user } = useAuth();
|
|
@@ -3490,7 +3594,7 @@ var CrossTabDemo = () => {
|
|
|
3490
3594
|
style: { marginTop: "2rem" },
|
|
3491
3595
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _antd.Space, { direction: "vertical", size: "middle", className: "w-full", children: [
|
|
3492
3596
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
3493
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3597
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Title3, { level: 4, children: "Current Status" }),
|
|
3494
3598
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _antd.Space, { children: [
|
|
3495
3599
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { strong: true, children: "Authentication:" }),
|
|
3496
3600
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _antd.Tag, { color: isAuthenticated ? "green" : "red", children: isAuthenticated ? "Authenticated" : "Not Authenticated" })
|
|
@@ -3509,7 +3613,7 @@ var CrossTabDemo = () => {
|
|
|
3509
3613
|
] })
|
|
3510
3614
|
] }),
|
|
3511
3615
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
3512
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3616
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Title3, { level: 4, children: "How It Works" }),
|
|
3513
3617
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paragraph2, { children: "This application now supports enhanced cross-tab authentication handling:" }),
|
|
3514
3618
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { marginLeft: "1rem" }, children: [
|
|
3515
3619
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Paragraph2, { children: [
|
|
@@ -3531,7 +3635,7 @@ var CrossTabDemo = () => {
|
|
|
3531
3635
|
] })
|
|
3532
3636
|
] }),
|
|
3533
3637
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
3534
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3638
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Title3, { level: 4, children: "Test Instructions" }),
|
|
3535
3639
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Paragraph2, { children: [
|
|
3536
3640
|
"1. Open this page in multiple browser tabs",
|
|
3537
3641
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "br", {}),
|
package/dist/index.mjs
CHANGED
|
@@ -564,8 +564,11 @@ var PasswordStep = ({
|
|
|
564
564
|
};
|
|
565
565
|
|
|
566
566
|
// src/components/auth/verification-step.tsx
|
|
567
|
+
import { useState as useState2, useEffect as useEffect2, useCallback, useMemo as useMemo2 } from "react";
|
|
567
568
|
import { Button as Button4 } from "antd";
|
|
568
|
-
import {
|
|
569
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
570
|
+
var RESEND_COUNTDOWN_SECONDS = 60;
|
|
571
|
+
var COUNTDOWN_INTERVAL_MS = 1e3;
|
|
569
572
|
var VerificationStep = ({
|
|
570
573
|
title,
|
|
571
574
|
description,
|
|
@@ -574,27 +577,48 @@ var VerificationStep = ({
|
|
|
574
577
|
submitButtonText,
|
|
575
578
|
isLoading = false,
|
|
576
579
|
codeLength = 5,
|
|
577
|
-
showResendButton = true,
|
|
578
580
|
initialValues,
|
|
579
581
|
email
|
|
580
582
|
}) => {
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
583
|
+
const [countdown, setCountdown] = useState2(RESEND_COUNTDOWN_SECONDS);
|
|
584
|
+
const canResend = useMemo2(() => countdown === 0, [countdown]);
|
|
585
|
+
useEffect2(() => {
|
|
586
|
+
if (countdown === 0) return;
|
|
587
|
+
const timer = setTimeout(() => {
|
|
588
|
+
setCountdown((prev) => prev - 1);
|
|
589
|
+
}, COUNTDOWN_INTERVAL_MS);
|
|
590
|
+
return () => clearTimeout(timer);
|
|
591
|
+
}, [countdown]);
|
|
592
|
+
const handleSubmit = useCallback(
|
|
593
|
+
async (values) => {
|
|
594
|
+
await onSubmit(values.verificationCode);
|
|
595
|
+
},
|
|
596
|
+
[onSubmit]
|
|
597
|
+
);
|
|
598
|
+
const handleResendClick = useCallback(async () => {
|
|
599
|
+
if (!canResend || !onResendCode) return;
|
|
600
|
+
setCountdown(RESEND_COUNTDOWN_SECONDS);
|
|
601
|
+
await onResendCode();
|
|
602
|
+
}, [canResend, onResendCode]);
|
|
603
|
+
const fields = useMemo2(
|
|
604
|
+
() => [getVerificationField(codeLength, { disabled: isLoading }, email)],
|
|
605
|
+
[codeLength, isLoading, email]
|
|
606
|
+
);
|
|
607
|
+
const resendButtonText = useMemo2(
|
|
608
|
+
() => canResend ? "Resend verification code" : `Resend verification code (${countdown}s)`,
|
|
609
|
+
[canResend, countdown]
|
|
610
|
+
);
|
|
611
|
+
const additionalActions = /* @__PURE__ */ jsx9(
|
|
588
612
|
Button4,
|
|
589
613
|
{
|
|
590
614
|
type: "link",
|
|
591
|
-
onClick:
|
|
592
|
-
disabled: isLoading,
|
|
615
|
+
onClick: handleResendClick,
|
|
616
|
+
disabled: isLoading || !canResend,
|
|
593
617
|
block: true,
|
|
594
618
|
className: "mb-2",
|
|
595
|
-
children:
|
|
619
|
+
children: resendButtonText
|
|
596
620
|
}
|
|
597
|
-
)
|
|
621
|
+
);
|
|
598
622
|
return /* @__PURE__ */ jsx9(
|
|
599
623
|
BaseForm,
|
|
600
624
|
{
|
|
@@ -611,7 +635,7 @@ var VerificationStep = ({
|
|
|
611
635
|
};
|
|
612
636
|
|
|
613
637
|
// src/components/auth/step-renderer.tsx
|
|
614
|
-
import
|
|
638
|
+
import React4 from "react";
|
|
615
639
|
|
|
616
640
|
// src/components/auth/finish-step.tsx
|
|
617
641
|
import { Flex as Flex2, Result } from "antd";
|
|
@@ -630,7 +654,10 @@ var FinishStep = () => {
|
|
|
630
654
|
};
|
|
631
655
|
|
|
632
656
|
// src/components/auth/forgot-password-step.tsx
|
|
633
|
-
import {
|
|
657
|
+
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
658
|
+
import { Typography as Typography3 } from "antd";
|
|
659
|
+
import { Fragment as Fragment3, jsx as jsx11 } from "react/jsx-runtime";
|
|
660
|
+
var { Title: Title2 } = Typography3;
|
|
634
661
|
var ForgotPasswordStep = ({
|
|
635
662
|
title,
|
|
636
663
|
description,
|
|
@@ -640,13 +667,23 @@ var ForgotPasswordStep = ({
|
|
|
640
667
|
submitButtonText,
|
|
641
668
|
initialValues
|
|
642
669
|
}) => {
|
|
670
|
+
const [showSuccess, setShowSuccess] = useState3(false);
|
|
671
|
+
useEffect3(() => {
|
|
672
|
+
if (showSuccess) {
|
|
673
|
+
const timer = setTimeout(() => {
|
|
674
|
+
setShowSuccess(false);
|
|
675
|
+
}, 5e3);
|
|
676
|
+
return () => clearTimeout(timer);
|
|
677
|
+
}
|
|
678
|
+
}, [showSuccess]);
|
|
643
679
|
const handleSubmit = async (values) => {
|
|
644
680
|
await onSubmit(values.email);
|
|
681
|
+
setShowSuccess(true);
|
|
645
682
|
};
|
|
646
683
|
const fields = [
|
|
647
684
|
getEmailField({ disabled: isLoading, value: email })
|
|
648
685
|
];
|
|
649
|
-
return /* @__PURE__ */ jsx11(
|
|
686
|
+
return /* @__PURE__ */ jsx11(Fragment3, { children: showSuccess ? /* @__PURE__ */ jsx11(Title2, { level: 3, className: "block mb-6", children: "We've sent an email with instructions to reset your password. Please check your inbox." }) : /* @__PURE__ */ jsx11(
|
|
650
687
|
BaseForm,
|
|
651
688
|
{
|
|
652
689
|
title,
|
|
@@ -657,7 +694,7 @@ var ForgotPasswordStep = ({
|
|
|
657
694
|
isLoading,
|
|
658
695
|
initialValues: initialValues || { email }
|
|
659
696
|
}
|
|
660
|
-
);
|
|
697
|
+
) });
|
|
661
698
|
};
|
|
662
699
|
|
|
663
700
|
// src/components/auth/step-renderer.tsx
|
|
@@ -702,10 +739,10 @@ var createPropsFactoryRegistry = ({
|
|
|
702
739
|
description: `Please enter the verification code sent to ${state.email}`,
|
|
703
740
|
submitButtonText: "Verify Email",
|
|
704
741
|
email: state.email,
|
|
705
|
-
onSubmit: handlers.handleVerificationSubmit
|
|
742
|
+
onSubmit: handlers.handleVerificationSubmit || (async () => {
|
|
743
|
+
}),
|
|
706
744
|
onResendCode: handlers.handleResendCode,
|
|
707
|
-
codeLength: configs.verificationStepConfig.codeLength
|
|
708
|
-
showResendButton: configs.verificationStepConfig.showResendButton
|
|
745
|
+
codeLength: configs.verificationStepConfig.codeLength
|
|
709
746
|
}),
|
|
710
747
|
["finish" /* FINISH */]: () => __spreadProps(__spreadValues({}, baseProps), {
|
|
711
748
|
title: "Success",
|
|
@@ -725,29 +762,29 @@ var createPropsFactoryRegistry = ({
|
|
|
725
762
|
})
|
|
726
763
|
});
|
|
727
764
|
var useStepRenderer = () => {
|
|
728
|
-
const registry =
|
|
729
|
-
const getStepComponent =
|
|
765
|
+
const registry = React4.useMemo(() => createStepRegistry(), []);
|
|
766
|
+
const getStepComponent = React4.useCallback((step) => {
|
|
730
767
|
return registry[step] || null;
|
|
731
768
|
}, [registry]);
|
|
732
769
|
return { getStepComponent };
|
|
733
770
|
};
|
|
734
771
|
|
|
735
772
|
// src/components/auth/auth-flow-container.tsx
|
|
736
|
-
import
|
|
773
|
+
import React5, { useState as useState7 } from "react";
|
|
737
774
|
import { Steps, Col, Button as Button5, Flex as Flex3, Row, Space as Space4 } from "antd";
|
|
738
775
|
import { ArrowLeftOutlined as ArrowLeftOutlined2 } from "@ant-design/icons";
|
|
739
776
|
import Image from "next/image";
|
|
740
777
|
import { cva } from "class-variance-authority";
|
|
741
778
|
|
|
742
779
|
// src/hooks/useAuthActionHandler.ts
|
|
743
|
-
import { useState as
|
|
780
|
+
import { useState as useState4, useCallback as useCallback2 } from "react";
|
|
744
781
|
var useAuthActionHandler = () => {
|
|
745
|
-
const [state, setState] =
|
|
782
|
+
const [state, setState] = useState4({
|
|
746
783
|
isLoading: false,
|
|
747
784
|
error: null,
|
|
748
785
|
success: null
|
|
749
786
|
});
|
|
750
|
-
const transformError =
|
|
787
|
+
const transformError = useCallback2((error) => {
|
|
751
788
|
if (error instanceof Error) {
|
|
752
789
|
return error.message;
|
|
753
790
|
}
|
|
@@ -756,22 +793,22 @@ var useAuthActionHandler = () => {
|
|
|
756
793
|
}
|
|
757
794
|
return "An unexpected error occurred";
|
|
758
795
|
}, []);
|
|
759
|
-
const clearError =
|
|
796
|
+
const clearError = useCallback2(() => {
|
|
760
797
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { error: null }));
|
|
761
798
|
}, []);
|
|
762
|
-
const clearSuccess =
|
|
799
|
+
const clearSuccess = useCallback2(() => {
|
|
763
800
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { success: null }));
|
|
764
801
|
}, []);
|
|
765
|
-
const clearAll =
|
|
802
|
+
const clearAll = useCallback2(() => {
|
|
766
803
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { error: null, success: null }));
|
|
767
804
|
}, []);
|
|
768
|
-
const setSuccess =
|
|
805
|
+
const setSuccess = useCallback2((message) => {
|
|
769
806
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { success: message, error: null }));
|
|
770
807
|
}, []);
|
|
771
|
-
const setError =
|
|
808
|
+
const setError = useCallback2((error) => {
|
|
772
809
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { error, success: null }));
|
|
773
810
|
}, []);
|
|
774
|
-
const executeAction =
|
|
811
|
+
const executeAction = useCallback2(async (action, options = {}) => {
|
|
775
812
|
const {
|
|
776
813
|
clearStatesBeforeAction = true,
|
|
777
814
|
preserveSuccessOnError = false,
|
|
@@ -831,38 +868,38 @@ var useAuthActionHandler = () => {
|
|
|
831
868
|
};
|
|
832
869
|
|
|
833
870
|
// src/hooks/useStepper.ts
|
|
834
|
-
import { useState as
|
|
871
|
+
import { useState as useState5, useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
835
872
|
var useStepper = (config2) => {
|
|
836
873
|
const { steps, initialStep } = config2;
|
|
837
874
|
if (!steps || steps.length === 0) {
|
|
838
875
|
throw new Error("useStepper: steps array cannot be empty");
|
|
839
876
|
}
|
|
840
877
|
const firstStepId = initialStep || steps[0].id;
|
|
841
|
-
const [currentStep, setCurrentStep] =
|
|
842
|
-
const currentStepIndex =
|
|
878
|
+
const [currentStep, setCurrentStep] = useState5(firstStepId);
|
|
879
|
+
const currentStepIndex = useMemo3(() => {
|
|
843
880
|
return steps.findIndex((step) => step.id === currentStep);
|
|
844
881
|
}, [steps, currentStep]);
|
|
845
|
-
const isFirstStep =
|
|
846
|
-
const isLastStep =
|
|
847
|
-
const progress =
|
|
882
|
+
const isFirstStep = useMemo3(() => currentStepIndex === 0, [currentStepIndex]);
|
|
883
|
+
const isLastStep = useMemo3(() => currentStepIndex === steps.length - 1, [currentStepIndex, steps.length]);
|
|
884
|
+
const progress = useMemo3(() => {
|
|
848
885
|
return steps.length > 0 ? (currentStepIndex + 1) / steps.length : 0;
|
|
849
886
|
}, [currentStepIndex, steps.length]);
|
|
850
|
-
const getStepIndex =
|
|
887
|
+
const getStepIndex = useCallback3((step) => {
|
|
851
888
|
return steps.findIndex((s) => s.id === step);
|
|
852
889
|
}, [steps]);
|
|
853
|
-
const getStepByIndex =
|
|
890
|
+
const getStepByIndex = useCallback3((index) => {
|
|
854
891
|
return steps[index];
|
|
855
892
|
}, [steps]);
|
|
856
|
-
const isStepValid =
|
|
893
|
+
const isStepValid = useCallback3((step) => {
|
|
857
894
|
const stepIndex = getStepIndex(step);
|
|
858
895
|
if (stepIndex === -1) return false;
|
|
859
896
|
const stepConfig = steps[stepIndex];
|
|
860
897
|
return !stepConfig.disabled;
|
|
861
898
|
}, [steps, getStepIndex]);
|
|
862
|
-
const getProgressPercentage =
|
|
899
|
+
const getProgressPercentage = useCallback3(() => {
|
|
863
900
|
return Math.round(progress * 100);
|
|
864
901
|
}, [progress]);
|
|
865
|
-
const goToStep =
|
|
902
|
+
const goToStep = useCallback3((step) => {
|
|
866
903
|
const stepIndex = getStepIndex(step);
|
|
867
904
|
if (stepIndex === -1) {
|
|
868
905
|
console.warn(`useStepper: Step not found: ${step}`);
|
|
@@ -870,7 +907,7 @@ var useStepper = (config2) => {
|
|
|
870
907
|
}
|
|
871
908
|
setCurrentStep(step);
|
|
872
909
|
}, [getStepIndex]);
|
|
873
|
-
const goToNext =
|
|
910
|
+
const goToNext = useCallback3(() => {
|
|
874
911
|
if (isLastStep) {
|
|
875
912
|
console.warn("useStepper: Already at the last step");
|
|
876
913
|
return;
|
|
@@ -881,7 +918,7 @@ var useStepper = (config2) => {
|
|
|
881
918
|
setCurrentStep(nextStep.id);
|
|
882
919
|
}
|
|
883
920
|
}, [isLastStep, currentStepIndex, getStepByIndex]);
|
|
884
|
-
const goToPrevious =
|
|
921
|
+
const goToPrevious = useCallback3(() => {
|
|
885
922
|
if (isFirstStep) {
|
|
886
923
|
console.warn("useStepper: Already at the first step");
|
|
887
924
|
return;
|
|
@@ -892,7 +929,7 @@ var useStepper = (config2) => {
|
|
|
892
929
|
setCurrentStep(prevStep.id);
|
|
893
930
|
}
|
|
894
931
|
}, [isFirstStep, currentStepIndex, getStepByIndex]);
|
|
895
|
-
const goToIndex =
|
|
932
|
+
const goToIndex = useCallback3((index) => {
|
|
896
933
|
const step = getStepByIndex(index);
|
|
897
934
|
if (step) {
|
|
898
935
|
goToStep(step.id);
|
|
@@ -900,7 +937,7 @@ var useStepper = (config2) => {
|
|
|
900
937
|
console.warn(`useStepper: Invalid step index: ${index}`);
|
|
901
938
|
}
|
|
902
939
|
}, [getStepByIndex, goToStep]);
|
|
903
|
-
const reset =
|
|
940
|
+
const reset = useCallback3(() => {
|
|
904
941
|
setCurrentStep(firstStepId);
|
|
905
942
|
}, [firstStepId]);
|
|
906
943
|
return {
|
|
@@ -929,7 +966,7 @@ var useStepper = (config2) => {
|
|
|
929
966
|
};
|
|
930
967
|
|
|
931
968
|
// src/hooks/useStepRegistry.ts
|
|
932
|
-
import { useMemo as
|
|
969
|
+
import { useMemo as useMemo4 } from "react";
|
|
933
970
|
function useStepRegistry({
|
|
934
971
|
baseProps: actionState,
|
|
935
972
|
handlers,
|
|
@@ -938,23 +975,23 @@ function useStepRegistry({
|
|
|
938
975
|
getStepComponent,
|
|
939
976
|
stepperState
|
|
940
977
|
}) {
|
|
941
|
-
const baseProps =
|
|
978
|
+
const baseProps = useMemo4(
|
|
942
979
|
() => ({
|
|
943
980
|
isLoading: actionState.isLoading
|
|
944
981
|
}),
|
|
945
982
|
[actionState.isLoading]
|
|
946
983
|
);
|
|
947
|
-
const registryParams =
|
|
984
|
+
const registryParams = useMemo4(
|
|
948
985
|
() => ({ baseProps, handlers, state, configs }),
|
|
949
986
|
[baseProps, handlers, state, configs]
|
|
950
987
|
);
|
|
951
|
-
const propsFactoryRegistry =
|
|
988
|
+
const propsFactoryRegistry = useMemo4(
|
|
952
989
|
() => createPropsFactoryRegistry(registryParams),
|
|
953
990
|
[registryParams]
|
|
954
991
|
);
|
|
955
992
|
const currentStep = stepperState.currentStep;
|
|
956
993
|
const SelectedComponent = getStepComponent(currentStep);
|
|
957
|
-
const stepProps =
|
|
994
|
+
const stepProps = useMemo4(() => {
|
|
958
995
|
const factory = propsFactoryRegistry[currentStep];
|
|
959
996
|
if (!factory) {
|
|
960
997
|
console.warn(`No props factory found for step: ${currentStep}`);
|
|
@@ -966,7 +1003,7 @@ function useStepRegistry({
|
|
|
966
1003
|
}
|
|
967
1004
|
|
|
968
1005
|
// src/hooks/useAuthEventBus.ts
|
|
969
|
-
import { useEffect as
|
|
1006
|
+
import { useEffect as useEffect4 } from "react";
|
|
970
1007
|
|
|
971
1008
|
// src/config/middleware.ts
|
|
972
1009
|
var _MiddlewareConfig = class _MiddlewareConfig {
|
|
@@ -1116,7 +1153,7 @@ var CrossTabBehaviorHandler = class {
|
|
|
1116
1153
|
};
|
|
1117
1154
|
|
|
1118
1155
|
// src/hooks/useSharedEventBus.ts
|
|
1119
|
-
import { useMemo as
|
|
1156
|
+
import { useMemo as useMemo5 } from "react";
|
|
1120
1157
|
|
|
1121
1158
|
// src/services/utils/event-bus.ts
|
|
1122
1159
|
var REGISTRY_KEY = "__bc_event_buses__";
|
|
@@ -1178,13 +1215,13 @@ var BroadcastChannelEventBus = class _BroadcastChannelEventBus {
|
|
|
1178
1215
|
|
|
1179
1216
|
// src/hooks/useSharedEventBus.ts
|
|
1180
1217
|
function useSharedEventBus() {
|
|
1181
|
-
return
|
|
1218
|
+
return useMemo5(() => BroadcastChannelEventBus.getInstance("auth-event-channel" /* AUTH */), []);
|
|
1182
1219
|
}
|
|
1183
1220
|
|
|
1184
1221
|
// src/hooks/useAuthEventBus.ts
|
|
1185
1222
|
var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
|
|
1186
1223
|
const eventBus = useSharedEventBus();
|
|
1187
|
-
|
|
1224
|
+
useEffect4(() => {
|
|
1188
1225
|
const handleEvent = (e) => {
|
|
1189
1226
|
var _a;
|
|
1190
1227
|
const currentPageType = CrossTabBehaviorHandler.getCurrentPageType();
|
|
@@ -1214,7 +1251,7 @@ var useAuthEventBus = ({ onLoggedOut, onLoggedIn } = {}) => {
|
|
|
1214
1251
|
};
|
|
1215
1252
|
|
|
1216
1253
|
// src/hooks/useSignInRequiredParams.ts
|
|
1217
|
-
import { useEffect as
|
|
1254
|
+
import { useEffect as useEffect5 } from "react";
|
|
1218
1255
|
import { useSearchParams } from "next/navigation";
|
|
1219
1256
|
|
|
1220
1257
|
// node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
|
|
@@ -1969,7 +2006,11 @@ var AUTH_ENDPOINTS = {
|
|
|
1969
2006
|
GET_USER_PROFILE: "/auth/user/profile",
|
|
1970
2007
|
GET_ME: "/auth/user/me",
|
|
1971
2008
|
// User logout
|
|
1972
|
-
LOGOUT: "/auth/logout"
|
|
2009
|
+
LOGOUT: "/auth/logout",
|
|
2010
|
+
// Password reset
|
|
2011
|
+
FORGOT_PASSWORD: "/auth/user/forget-password",
|
|
2012
|
+
// Verification
|
|
2013
|
+
RESEND_VERIFICATION: "/auth/user/generate-verification"
|
|
1973
2014
|
};
|
|
1974
2015
|
var EndpointBuilder = class {
|
|
1975
2016
|
};
|
|
@@ -2028,6 +2069,20 @@ var AuthService = class extends BaseService {
|
|
|
2028
2069
|
const endpoint = AUTH_ENDPOINTS.LOGOUT;
|
|
2029
2070
|
return this.post(endpoint);
|
|
2030
2071
|
}
|
|
2072
|
+
/**
|
|
2073
|
+
* Send forgot password email
|
|
2074
|
+
*/
|
|
2075
|
+
async forgotPassword(email) {
|
|
2076
|
+
const endpoint = AUTH_ENDPOINTS.FORGOT_PASSWORD;
|
|
2077
|
+
return this.post(endpoint, { email });
|
|
2078
|
+
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Resend verification code
|
|
2081
|
+
*/
|
|
2082
|
+
async resendVerification(email) {
|
|
2083
|
+
const endpoint = AUTH_ENDPOINTS.RESEND_VERIFICATION;
|
|
2084
|
+
return this.post(endpoint, { email });
|
|
2085
|
+
}
|
|
2031
2086
|
};
|
|
2032
2087
|
|
|
2033
2088
|
// src/services/auth/manager/user-storage-manager.ts
|
|
@@ -2613,6 +2668,32 @@ var AuthOrchestrator = class {
|
|
|
2613
2668
|
return this.errorHandler.handle(error, "Get token info");
|
|
2614
2669
|
}
|
|
2615
2670
|
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Handle forgot password flow
|
|
2673
|
+
*/
|
|
2674
|
+
async handleForgotPassword(email) {
|
|
2675
|
+
try {
|
|
2676
|
+
await this.authService.forgotPassword(email);
|
|
2677
|
+
return AuthResultFactory.createSuccess({
|
|
2678
|
+
message: "We've sent an email with instructions to reset your password. Please check your inbox."
|
|
2679
|
+
});
|
|
2680
|
+
} catch (error) {
|
|
2681
|
+
return this.errorHandler.handle(error, "Forgot password");
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
/**
|
|
2685
|
+
* Handle resend verification code
|
|
2686
|
+
*/
|
|
2687
|
+
async handleResendVerification(email) {
|
|
2688
|
+
try {
|
|
2689
|
+
await this.authService.resendVerification(email);
|
|
2690
|
+
return AuthResultFactory.createSuccess({
|
|
2691
|
+
message: "Verification code sent successfully."
|
|
2692
|
+
});
|
|
2693
|
+
} catch (error) {
|
|
2694
|
+
return this.errorHandler.handle(error, "Resend verification");
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2616
2697
|
};
|
|
2617
2698
|
var AuthOrchestratorFactory = class {
|
|
2618
2699
|
/**
|
|
@@ -2635,7 +2716,7 @@ var AuthOrchestratorFactory = class {
|
|
|
2635
2716
|
function useSignInRequiredParams() {
|
|
2636
2717
|
const searchParams = useSearchParams();
|
|
2637
2718
|
const eventBus = useSharedEventBus();
|
|
2638
|
-
|
|
2719
|
+
useEffect5(() => {
|
|
2639
2720
|
const signInRequired = searchParams.get(MiddlewareConfig.QUERY_PARAMS.LOGIN_REQUIRED);
|
|
2640
2721
|
const authChecked = searchParams.get(MiddlewareConfig.QUERY_PARAMS.AUTH_CHECKED);
|
|
2641
2722
|
if (signInRequired === MiddlewareConfig.QUERY_VALUES.LOGIN_REQUIRED && authChecked === MiddlewareConfig.QUERY_VALUES.AUTH_CHECKED) {
|
|
@@ -2649,7 +2730,7 @@ function useSignInRequiredParams() {
|
|
|
2649
2730
|
}
|
|
2650
2731
|
|
|
2651
2732
|
// src/hooks/use-user.ts
|
|
2652
|
-
import { useEffect as
|
|
2733
|
+
import { useEffect as useEffect6 } from "react";
|
|
2653
2734
|
|
|
2654
2735
|
// src/store/user-store.ts
|
|
2655
2736
|
import { create } from "zustand";
|
|
@@ -2904,7 +2985,7 @@ var useAuth = () => {
|
|
|
2904
2985
|
var useAuthInitializer = () => {
|
|
2905
2986
|
const { refreshUser } = useUserActions();
|
|
2906
2987
|
const { isLoading } = useUserData();
|
|
2907
|
-
|
|
2988
|
+
useEffect6(() => {
|
|
2908
2989
|
const initializeUser = async () => {
|
|
2909
2990
|
if (!isLoading) {
|
|
2910
2991
|
try {
|
|
@@ -2994,13 +3075,13 @@ var isPublicUser = (user) => {
|
|
|
2994
3075
|
};
|
|
2995
3076
|
|
|
2996
3077
|
// src/hooks/useAuthFlowModal.ts
|
|
2997
|
-
import { useState as
|
|
3078
|
+
import { useState as useState6, useEffect as useEffect7 } from "react";
|
|
2998
3079
|
var useAuthFlowModal = () => {
|
|
2999
|
-
const [isModalOpen, setIsModalOpen] =
|
|
3000
|
-
const [isInitialLoading, setIsInitialLoading] =
|
|
3080
|
+
const [isModalOpen, setIsModalOpen] = useState6(false);
|
|
3081
|
+
const [isInitialLoading, setIsInitialLoading] = useState6(true);
|
|
3001
3082
|
const eventBus = useSharedEventBus();
|
|
3002
3083
|
const { isLoading: userLoading } = useUserData();
|
|
3003
|
-
|
|
3084
|
+
useEffect7(() => {
|
|
3004
3085
|
const handleAuthEvent = (event) => {
|
|
3005
3086
|
if (event.type === "auth.signin_required_modal" /* SignInRequiredModal */) {
|
|
3006
3087
|
setIsModalOpen(true);
|
|
@@ -3012,7 +3093,7 @@ var useAuthFlowModal = () => {
|
|
|
3012
3093
|
subscription.unsubscribe();
|
|
3013
3094
|
};
|
|
3014
3095
|
}, [eventBus]);
|
|
3015
|
-
|
|
3096
|
+
useEffect7(() => {
|
|
3016
3097
|
if (!userLoading) {
|
|
3017
3098
|
const timer = setTimeout(() => {
|
|
3018
3099
|
setIsInitialLoading(false);
|
|
@@ -3072,10 +3153,10 @@ function AuthFlowContainer({
|
|
|
3072
3153
|
const authOrchestrator = AuthOrchestratorFactory.create();
|
|
3073
3154
|
const { state: actionState, executeAction, clearAll } = useAuthActionHandler();
|
|
3074
3155
|
const { getStepComponent } = useStepRenderer();
|
|
3075
|
-
const [email, setEmail] =
|
|
3076
|
-
const [password, setPassword] =
|
|
3077
|
-
const [authIntent, setAuthIntent] =
|
|
3078
|
-
const [authData, setAuthData] =
|
|
3156
|
+
const [email, setEmail] = useState7("");
|
|
3157
|
+
const [password, setPassword] = useState7("");
|
|
3158
|
+
const [authIntent, setAuthIntent] = useState7("login" /* LOGIN */);
|
|
3159
|
+
const [authData, setAuthData] = useState7(null);
|
|
3079
3160
|
const config2 = {
|
|
3080
3161
|
showSteps: true,
|
|
3081
3162
|
showBackToHome: true,
|
|
@@ -3085,8 +3166,7 @@ function AuthFlowContainer({
|
|
|
3085
3166
|
showEmailField: true
|
|
3086
3167
|
},
|
|
3087
3168
|
verificationStepConfig: {
|
|
3088
|
-
codeLength: 5
|
|
3089
|
-
showResendButton: false
|
|
3169
|
+
codeLength: 5
|
|
3090
3170
|
}
|
|
3091
3171
|
};
|
|
3092
3172
|
const stepperConfig = {
|
|
@@ -3154,9 +3234,9 @@ function AuthFlowContainer({
|
|
|
3154
3234
|
return await authOrchestrator.handleEmailVerification(email, code);
|
|
3155
3235
|
},
|
|
3156
3236
|
{
|
|
3157
|
-
onSuccess: (data) => {
|
|
3237
|
+
onSuccess: async (data) => {
|
|
3158
3238
|
setAuthData(data);
|
|
3159
|
-
handlePasswordSubmitAfterVerification(password);
|
|
3239
|
+
await handlePasswordSubmitAfterVerification(password);
|
|
3160
3240
|
setPassword("");
|
|
3161
3241
|
},
|
|
3162
3242
|
onError: (error) => {
|
|
@@ -3198,6 +3278,20 @@ function AuthFlowContainer({
|
|
|
3198
3278
|
}
|
|
3199
3279
|
);
|
|
3200
3280
|
};
|
|
3281
|
+
const handleResendCode = async () => {
|
|
3282
|
+
await executeAction(
|
|
3283
|
+
async () => {
|
|
3284
|
+
return await authOrchestrator.handleResendVerification(email);
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
onSuccess: () => {
|
|
3288
|
+
},
|
|
3289
|
+
onError: (error) => {
|
|
3290
|
+
console.error(error);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
);
|
|
3294
|
+
};
|
|
3201
3295
|
const handleSuccess = () => {
|
|
3202
3296
|
stepperActions.goToStep("finish" /* FINISH */);
|
|
3203
3297
|
setTimeout(() => {
|
|
@@ -3209,7 +3303,7 @@ function AuthFlowContainer({
|
|
|
3209
3303
|
setEmail("");
|
|
3210
3304
|
clearAll();
|
|
3211
3305
|
};
|
|
3212
|
-
const goBackToHome =
|
|
3306
|
+
const goBackToHome = React5.useCallback(() => {
|
|
3213
3307
|
window.location.href = "/";
|
|
3214
3308
|
}, []);
|
|
3215
3309
|
const goBackToPassword = () => {
|
|
@@ -3217,7 +3311,18 @@ function AuthFlowContainer({
|
|
|
3217
3311
|
clearAll();
|
|
3218
3312
|
};
|
|
3219
3313
|
const handleForgotPassword = async (emailValue) => {
|
|
3220
|
-
|
|
3314
|
+
await executeAction(
|
|
3315
|
+
async () => {
|
|
3316
|
+
return await authOrchestrator.handleForgotPassword(emailValue);
|
|
3317
|
+
},
|
|
3318
|
+
{
|
|
3319
|
+
onSuccess: () => {
|
|
3320
|
+
},
|
|
3321
|
+
onError: (error) => {
|
|
3322
|
+
console.error(error);
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
);
|
|
3221
3326
|
};
|
|
3222
3327
|
const onForgotPasswordClick = () => {
|
|
3223
3328
|
stepperActions.goToStep("forgot-password" /* FORGOT_PASSWORD */);
|
|
@@ -3228,8 +3333,7 @@ function AuthFlowContainer({
|
|
|
3228
3333
|
handleEmailSubmit,
|
|
3229
3334
|
handlePasswordSubmit,
|
|
3230
3335
|
handleVerificationSubmit,
|
|
3231
|
-
handleResendCode
|
|
3232
|
-
},
|
|
3336
|
+
handleResendCode,
|
|
3233
3337
|
goBackToEmail,
|
|
3234
3338
|
goBackToPassword,
|
|
3235
3339
|
onGoogleSignIn: handleGoogleSignIn,
|
|
@@ -3245,7 +3349,7 @@ function AuthFlowContainer({
|
|
|
3245
3349
|
getStepComponent,
|
|
3246
3350
|
stepperState
|
|
3247
3351
|
});
|
|
3248
|
-
const hiddenSteps =
|
|
3352
|
+
const hiddenSteps = React5.useMemo(
|
|
3249
3353
|
() => /* @__PURE__ */ new Set(["forgot-password" /* FORGOT_PASSWORD */]),
|
|
3250
3354
|
[]
|
|
3251
3355
|
);
|
|
@@ -3253,7 +3357,7 @@ function AuthFlowContainer({
|
|
|
3253
3357
|
const currentVisibleStepIndex = visibleSteps.findIndex(
|
|
3254
3358
|
(step) => step.id === stepperState.currentStep
|
|
3255
3359
|
);
|
|
3256
|
-
const backActionMap =
|
|
3360
|
+
const backActionMap = React5.useMemo(
|
|
3257
3361
|
() => ({
|
|
3258
3362
|
["forgot-password" /* FORGOT_PASSWORD */]: () => {
|
|
3259
3363
|
stepperActions.goToStep("email" /* EMAIL */);
|
|
@@ -3271,7 +3375,7 @@ function AuthFlowContainer({
|
|
|
3271
3375
|
stepperActions.goToPrevious();
|
|
3272
3376
|
clearAll();
|
|
3273
3377
|
};
|
|
3274
|
-
const topButton =
|
|
3378
|
+
const topButton = React5.useMemo(() => {
|
|
3275
3379
|
const buttonMap = {
|
|
3276
3380
|
["forgot-password" /* FORGOT_PASSWORD */]: {
|
|
3277
3381
|
label: "Go to Login",
|
|
@@ -3376,7 +3480,7 @@ var AuthInitializer = ({ children }) => {
|
|
|
3376
3480
|
};
|
|
3377
3481
|
|
|
3378
3482
|
// src/components/profile/profile-state-renderer.tsx
|
|
3379
|
-
import { useState as
|
|
3483
|
+
import { useState as useState8, useEffect as useEffect8 } from "react";
|
|
3380
3484
|
import { Dropdown, Button as Button6 } from "antd";
|
|
3381
3485
|
import { MailOutlined, CrownOutlined, LogoutOutlined, UserOutlined } from "@ant-design/icons";
|
|
3382
3486
|
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
@@ -3392,8 +3496,8 @@ var UNAUTHENTICATED_COMPONENT_MAP = {
|
|
|
3392
3496
|
["/" /* HOME */]: DefaultUnauthenticated
|
|
3393
3497
|
};
|
|
3394
3498
|
var useUnauthenticatedStrategy = () => {
|
|
3395
|
-
const [pageType, setPageType] =
|
|
3396
|
-
|
|
3499
|
+
const [pageType, setPageType] = useState8("/" /* HOME */);
|
|
3500
|
+
useEffect8(() => {
|
|
3397
3501
|
const currentPageType = CrossTabBehaviorHandler.getCurrentPageType();
|
|
3398
3502
|
setPageType(currentPageType);
|
|
3399
3503
|
}, []);
|
|
@@ -3475,9 +3579,9 @@ var ProfileStateRenderer = () => {
|
|
|
3475
3579
|
};
|
|
3476
3580
|
|
|
3477
3581
|
// src/components/demo/cross-tab-demo.tsx
|
|
3478
|
-
import { Card, Typography as
|
|
3582
|
+
import { Card, Typography as Typography4, Tag, Space as Space5 } from "antd";
|
|
3479
3583
|
import { Fragment as Fragment6, jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3480
|
-
var { Title:
|
|
3584
|
+
var { Title: Title3, Text: Text2, Paragraph: Paragraph2 } = Typography4;
|
|
3481
3585
|
var CrossTabDemo = () => {
|
|
3482
3586
|
var _a;
|
|
3483
3587
|
const { isAuthenticated, user } = useAuth();
|
|
@@ -3490,7 +3594,7 @@ var CrossTabDemo = () => {
|
|
|
3490
3594
|
style: { marginTop: "2rem" },
|
|
3491
3595
|
children: /* @__PURE__ */ jsxs9(Space5, { direction: "vertical", size: "middle", className: "w-full", children: [
|
|
3492
3596
|
/* @__PURE__ */ jsxs9("div", { children: [
|
|
3493
|
-
/* @__PURE__ */ jsx16(
|
|
3597
|
+
/* @__PURE__ */ jsx16(Title3, { level: 4, children: "Current Status" }),
|
|
3494
3598
|
/* @__PURE__ */ jsxs9(Space5, { children: [
|
|
3495
3599
|
/* @__PURE__ */ jsx16(Text2, { strong: true, children: "Authentication:" }),
|
|
3496
3600
|
/* @__PURE__ */ jsx16(Tag, { color: isAuthenticated ? "green" : "red", children: isAuthenticated ? "Authenticated" : "Not Authenticated" })
|
|
@@ -3509,7 +3613,7 @@ var CrossTabDemo = () => {
|
|
|
3509
3613
|
] })
|
|
3510
3614
|
] }),
|
|
3511
3615
|
/* @__PURE__ */ jsxs9("div", { children: [
|
|
3512
|
-
/* @__PURE__ */ jsx16(
|
|
3616
|
+
/* @__PURE__ */ jsx16(Title3, { level: 4, children: "How It Works" }),
|
|
3513
3617
|
/* @__PURE__ */ jsx16(Paragraph2, { children: "This application now supports enhanced cross-tab authentication handling:" }),
|
|
3514
3618
|
/* @__PURE__ */ jsxs9("div", { style: { marginLeft: "1rem" }, children: [
|
|
3515
3619
|
/* @__PURE__ */ jsxs9(Paragraph2, { children: [
|
|
@@ -3531,7 +3635,7 @@ var CrossTabDemo = () => {
|
|
|
3531
3635
|
] })
|
|
3532
3636
|
] }),
|
|
3533
3637
|
/* @__PURE__ */ jsxs9("div", { children: [
|
|
3534
|
-
/* @__PURE__ */ jsx16(
|
|
3638
|
+
/* @__PURE__ */ jsx16(Title3, { level: 4, children: "Test Instructions" }),
|
|
3535
3639
|
/* @__PURE__ */ jsxs9(Paragraph2, { children: [
|
|
3536
3640
|
"1. Open this page in multiple browser tabs",
|
|
3537
3641
|
/* @__PURE__ */ jsx16("br", {}),
|
package/package.json
CHANGED