@insforge/react 0.4.0 → 0.4.5
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 +2 -11
- package/dist/atoms.cjs +158 -139
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.d.cts +72 -41
- package/dist/atoms.d.ts +72 -41
- package/dist/atoms.js +159 -141
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +544 -798
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +64 -94
- package/dist/components.d.ts +64 -94
- package/dist/components.js +544 -798
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +217 -310
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.d.cts +10 -13
- package/dist/forms.d.ts +10 -13
- package/dist/forms.js +218 -311
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +581 -794
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -16
- package/dist/index.d.ts +31 -16
- package/dist/index.js +581 -794
- package/dist/index.js.map +1 -1
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +0 -11
- package/dist/router.d.ts +0 -11
- package/dist/router.js.map +1 -1
- package/dist/styles.css +212 -3
- package/dist/types.d.cts +11 -613
- package/dist/types.d.ts +11 -613
- package/package.json +7 -2
package/dist/components.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
-
var
|
|
4
|
+
var reactRouterDom = require('react-router-dom');
|
|
5
|
+
require('@insforge/sdk');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
var lucideReact = require('lucide-react');
|
|
7
8
|
var zod = require('zod');
|
|
@@ -119,21 +120,12 @@ function AuthErrorBanner({ error }) {
|
|
|
119
120
|
if (!error) {
|
|
120
121
|
return null;
|
|
121
122
|
}
|
|
122
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-errorBanner if-internal-eb2m7k", children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
123
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
124
|
-
lucideReact.AlertTriangle,
|
|
125
|
-
{
|
|
126
|
-
style: { width: "1.5rem", height: "1.5rem", flexShrink: 0, color: "#dc2626" }
|
|
127
|
-
}
|
|
128
|
-
),
|
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-errorBanner if-internal-eb2m7k", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-errorBanner-content", children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "if-errorBanner-icon" }),
|
|
129
125
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-errorBanner-text", children: error })
|
|
130
126
|
] }) });
|
|
131
127
|
}
|
|
132
|
-
function AuthFormField({
|
|
133
|
-
label,
|
|
134
|
-
id,
|
|
135
|
-
...props
|
|
136
|
-
}) {
|
|
128
|
+
function AuthFormField({ label, id, ...props }) {
|
|
137
129
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-formField if-internal-f9n6p2", children: [
|
|
138
130
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "if-formField-label if-internal-l3k8m1", children: label }),
|
|
139
131
|
/* @__PURE__ */ jsxRuntime.jsx("input", { id, className: "if-formField-input if-internal-i2v8k4", ...props })
|
|
@@ -260,14 +252,17 @@ function AuthSubmitButton({
|
|
|
260
252
|
children,
|
|
261
253
|
isLoading = false,
|
|
262
254
|
confirmed = false,
|
|
263
|
-
disabled = false
|
|
255
|
+
disabled = false,
|
|
256
|
+
type = "submit",
|
|
257
|
+
onClick
|
|
264
258
|
}) {
|
|
265
259
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
266
260
|
"button",
|
|
267
261
|
{
|
|
268
|
-
type
|
|
262
|
+
type,
|
|
269
263
|
className: "if-submitButton if-internal-b8p3m4",
|
|
270
264
|
disabled: disabled || isLoading || confirmed,
|
|
265
|
+
onClick,
|
|
271
266
|
children: [
|
|
272
267
|
isLoading && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "if-submitButton-icon if-submitButton-spinner", size: 20 }),
|
|
273
268
|
confirmed && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { className: "if-submitButton-icon", size: 20 }),
|
|
@@ -276,24 +271,16 @@ function AuthSubmitButton({
|
|
|
276
271
|
}
|
|
277
272
|
);
|
|
278
273
|
}
|
|
279
|
-
function AuthLink({
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
href
|
|
283
|
-
}) {
|
|
284
|
-
const currentSearch = typeof window !== "undefined" ? window.location.search : "";
|
|
274
|
+
function AuthLink({ text, linkText, href }) {
|
|
275
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
276
|
+
const currentSearch = searchParams.toString();
|
|
285
277
|
const finalHref = (() => {
|
|
286
278
|
if (!currentSearch) {
|
|
287
279
|
return href;
|
|
288
280
|
}
|
|
289
281
|
try {
|
|
290
282
|
const url = new URL(href, window.location.origin);
|
|
291
|
-
|
|
292
|
-
currentParams.forEach((value, key) => {
|
|
293
|
-
if (!url.searchParams.has(key)) {
|
|
294
|
-
url.searchParams.set(key, value);
|
|
295
|
-
}
|
|
296
|
-
});
|
|
283
|
+
url.search = currentSearch;
|
|
297
284
|
return url.pathname + url.search;
|
|
298
285
|
} catch {
|
|
299
286
|
return href;
|
|
@@ -650,28 +637,26 @@ function AuthVerificationCodeInput({
|
|
|
650
637
|
}
|
|
651
638
|
function AuthEmailVerificationStep({
|
|
652
639
|
email,
|
|
653
|
-
description,
|
|
654
640
|
method = "code",
|
|
655
641
|
onVerifyCode
|
|
656
642
|
}) {
|
|
657
|
-
const {
|
|
658
|
-
const [insforge] = react.useState(() => sdk.createClient({ baseUrl }));
|
|
643
|
+
const { sendVerificationEmail } = useInsforge();
|
|
659
644
|
const [resendDisabled, setResendDisabled] = react.useState(true);
|
|
660
645
|
const [resendCountdown, setResendCountdown] = react.useState(60);
|
|
661
646
|
const [isSending, setIsSending] = react.useState(false);
|
|
662
647
|
const [verificationCode, setVerificationCode] = react.useState("");
|
|
663
648
|
const [isVerifying, setIsVerifying] = react.useState(false);
|
|
664
|
-
const [verificationError, setVerificationError] = react.useState("");
|
|
665
649
|
const defaultDescription = method === "code" ? "We've sent a 6-digit verification code to {email}. Please enter it below to verify your account. The code will expire in 10 minutes." : "We've sent a verification link to {email}. Please check your email and click the link to verify your account. The link will expire in 10 minutes.";
|
|
666
650
|
react.useEffect(() => {
|
|
667
651
|
const sendInitialEmail = async () => {
|
|
668
652
|
try {
|
|
669
|
-
await
|
|
670
|
-
} catch {
|
|
653
|
+
await sendVerificationEmail(email);
|
|
654
|
+
} catch (error) {
|
|
655
|
+
console.error("Failed to send verification email:", error);
|
|
671
656
|
}
|
|
672
657
|
};
|
|
673
658
|
void sendInitialEmail();
|
|
674
|
-
}, [email,
|
|
659
|
+
}, [email, sendVerificationEmail]);
|
|
675
660
|
react.useEffect(() => {
|
|
676
661
|
if (resendCountdown > 0) {
|
|
677
662
|
const timer = setInterval(() => {
|
|
@@ -690,9 +675,8 @@ function AuthEmailVerificationStep({
|
|
|
690
675
|
setResendDisabled(true);
|
|
691
676
|
setResendCountdown(60);
|
|
692
677
|
setIsSending(true);
|
|
693
|
-
setVerificationError("");
|
|
694
678
|
try {
|
|
695
|
-
await
|
|
679
|
+
await sendVerificationEmail(email);
|
|
696
680
|
} catch {
|
|
697
681
|
setResendDisabled(false);
|
|
698
682
|
setResendCountdown(0);
|
|
@@ -700,123 +684,157 @@ function AuthEmailVerificationStep({
|
|
|
700
684
|
setIsSending(false);
|
|
701
685
|
}
|
|
702
686
|
};
|
|
703
|
-
const
|
|
704
|
-
if (!onVerifyCode) {
|
|
687
|
+
const handleSubmit = async () => {
|
|
688
|
+
if (!onVerifyCode || verificationCode.length !== 6) {
|
|
705
689
|
return;
|
|
706
690
|
}
|
|
707
691
|
setIsVerifying(true);
|
|
708
|
-
setVerificationError("");
|
|
709
692
|
try {
|
|
710
|
-
await onVerifyCode(
|
|
711
|
-
} catch (error) {
|
|
712
|
-
setVerificationError(
|
|
713
|
-
error instanceof Error ? error.message : "Invalid verification code. Please try again."
|
|
714
|
-
);
|
|
715
|
-
setVerificationCode("");
|
|
693
|
+
await onVerifyCode(verificationCode);
|
|
716
694
|
} finally {
|
|
717
695
|
setIsVerifying(false);
|
|
696
|
+
setVerificationCode("");
|
|
718
697
|
}
|
|
719
698
|
};
|
|
720
|
-
const displayDescription =
|
|
721
|
-
|
|
722
|
-
|
|
699
|
+
const displayDescription = defaultDescription;
|
|
700
|
+
const isLinkMethod = method === "link";
|
|
701
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep", children: [
|
|
702
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
723
703
|
part,
|
|
724
704
|
index < array.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-verificationCode-email", children: email })
|
|
725
705
|
] }, index)) }),
|
|
726
|
-
|
|
706
|
+
!isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeContainer", children: [
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
708
|
+
AuthVerificationCodeInput,
|
|
709
|
+
{
|
|
710
|
+
value: verificationCode,
|
|
711
|
+
onChange: setVerificationCode,
|
|
712
|
+
email,
|
|
713
|
+
disabled: isVerifying
|
|
714
|
+
}
|
|
715
|
+
) }),
|
|
727
716
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
728
|
-
|
|
717
|
+
AuthSubmitButton,
|
|
729
718
|
{
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" })
|
|
719
|
+
type: "button",
|
|
720
|
+
isLoading: isVerifying,
|
|
721
|
+
disabled: isVerifying || verificationCode.length !== 6,
|
|
722
|
+
onClick: () => {
|
|
723
|
+
void handleSubmit();
|
|
724
|
+
},
|
|
725
|
+
children: isVerifying ? "Verifying..." : "Verify Code"
|
|
738
726
|
}
|
|
739
|
-
)
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
"
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
727
|
+
)
|
|
728
|
+
] }),
|
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-resendContainer", children: [
|
|
730
|
+
"Didn't receive the email?",
|
|
731
|
+
" ",
|
|
732
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
733
|
+
"button",
|
|
734
|
+
{
|
|
735
|
+
onClick: () => {
|
|
736
|
+
void handleResend();
|
|
737
|
+
},
|
|
738
|
+
disabled: resendDisabled || isSending,
|
|
739
|
+
className: "if-verificationStep-resendButton",
|
|
740
|
+
children: isSending ? "Sending..." : resendDisabled ? `Retry in (${resendCountdown}s)` : "Click to resend"
|
|
741
|
+
}
|
|
742
|
+
)
|
|
743
|
+
] })
|
|
744
|
+
] });
|
|
745
|
+
}
|
|
746
|
+
function AuthResetPasswordVerificationStep({
|
|
747
|
+
email,
|
|
748
|
+
method,
|
|
749
|
+
onVerifyCode,
|
|
750
|
+
onResendEmail
|
|
751
|
+
}) {
|
|
752
|
+
const [resendDisabled, setResendDisabled] = react.useState(true);
|
|
753
|
+
const [resendCountdown, setResendCountdown] = react.useState(60);
|
|
754
|
+
const [isSending, setIsSending] = react.useState(false);
|
|
755
|
+
const [verificationCode, setVerificationCode] = react.useState("");
|
|
756
|
+
const [isVerifying, setIsVerifying] = react.useState(false);
|
|
757
|
+
react.useEffect(() => {
|
|
758
|
+
if (resendCountdown > 0) {
|
|
759
|
+
const timer = setInterval(() => {
|
|
760
|
+
setResendCountdown((prev) => {
|
|
761
|
+
if (prev <= 1) {
|
|
762
|
+
setResendDisabled(false);
|
|
763
|
+
return 0;
|
|
764
|
+
}
|
|
765
|
+
return prev - 1;
|
|
766
|
+
});
|
|
767
|
+
}, 1e3);
|
|
768
|
+
return () => clearInterval(timer);
|
|
769
|
+
}
|
|
770
|
+
}, [resendCountdown]);
|
|
771
|
+
const handleResend = react.useCallback(async () => {
|
|
772
|
+
setResendDisabled(true);
|
|
773
|
+
setResendCountdown(60);
|
|
774
|
+
setIsSending(true);
|
|
775
|
+
try {
|
|
776
|
+
await onResendEmail();
|
|
777
|
+
} catch {
|
|
778
|
+
setResendDisabled(false);
|
|
779
|
+
setResendCountdown(0);
|
|
780
|
+
} finally {
|
|
781
|
+
setIsSending(false);
|
|
782
|
+
}
|
|
783
|
+
}, [onResendEmail]);
|
|
784
|
+
const handleSubmit = async () => {
|
|
785
|
+
if (!onVerifyCode || verificationCode.length !== 6) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
setIsVerifying(true);
|
|
789
|
+
try {
|
|
790
|
+
await onVerifyCode(verificationCode);
|
|
791
|
+
} finally {
|
|
792
|
+
setIsVerifying(false);
|
|
793
|
+
setVerificationCode("");
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
const isLinkMethod = method === "link";
|
|
797
|
+
const description = isLinkMethod ? `We've sent a password reset link to ${email}. Please check your email and click the link to reset your password. The link will expire in 10 minutes.` : `We've sent a 6-digit verification code to ${email}. Please enter it below to reset your password. The code will expire in 10 minutes.`;
|
|
798
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep", children: [
|
|
799
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-description", children: description }),
|
|
800
|
+
!isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeContainer", children: [
|
|
801
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
802
|
+
AuthVerificationCodeInput,
|
|
803
|
+
{
|
|
804
|
+
value: verificationCode,
|
|
805
|
+
onChange: setVerificationCode,
|
|
806
|
+
email,
|
|
807
|
+
disabled: isVerifying
|
|
808
|
+
}
|
|
809
|
+
) }),
|
|
810
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
811
|
+
AuthSubmitButton,
|
|
812
|
+
{
|
|
813
|
+
type: "button",
|
|
814
|
+
isLoading: isVerifying,
|
|
815
|
+
disabled: isVerifying || verificationCode.length !== 6,
|
|
816
|
+
onClick: () => {
|
|
817
|
+
void handleSubmit();
|
|
818
|
+
},
|
|
819
|
+
children: isVerifying ? "Verifying..." : "Continue"
|
|
820
|
+
}
|
|
821
|
+
)
|
|
822
|
+
] }),
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-resendContainer", children: [
|
|
824
|
+
"Didn't receive the email?",
|
|
825
|
+
" ",
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
+
"button",
|
|
828
|
+
{
|
|
829
|
+
onClick: () => {
|
|
830
|
+
void handleResend();
|
|
831
|
+
},
|
|
832
|
+
disabled: resendDisabled || isSending,
|
|
833
|
+
className: "if-verificationStep-resendButton",
|
|
834
|
+
children: isSending ? "Sending..." : resendDisabled ? `Retry in (${resendCountdown}s)` : "Click to resend"
|
|
835
|
+
}
|
|
836
|
+
)
|
|
837
|
+
] })
|
|
820
838
|
] });
|
|
821
839
|
}
|
|
822
840
|
function SignInForm({
|
|
@@ -846,8 +864,7 @@ function SignInForm({
|
|
|
846
864
|
signUpUrl = "/sign-up",
|
|
847
865
|
dividerText = "or",
|
|
848
866
|
showVerificationStep = false,
|
|
849
|
-
onVerifyCode
|
|
850
|
-
verificationDescription
|
|
867
|
+
onVerifyCode
|
|
851
868
|
}) {
|
|
852
869
|
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
853
870
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -858,14 +875,7 @@ function SignInForm({
|
|
|
858
875
|
}
|
|
859
876
|
),
|
|
860
877
|
/* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
|
|
861
|
-
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
862
|
-
AuthEmailVerificationStep,
|
|
863
|
-
{
|
|
864
|
-
email,
|
|
865
|
-
description: verificationDescription,
|
|
866
|
-
onVerifyCode
|
|
867
|
-
}
|
|
868
|
-
) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
878
|
+
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(AuthEmailVerificationStep, { email, onVerifyCode }) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
869
879
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
870
880
|
AuthFormField,
|
|
871
881
|
{
|
|
@@ -915,16 +925,17 @@ function SignInForm({
|
|
|
915
925
|
] })
|
|
916
926
|
] });
|
|
917
927
|
}
|
|
918
|
-
function SignIn({
|
|
919
|
-
const { signIn,
|
|
928
|
+
function SignIn({ onError, ...uiProps }) {
|
|
929
|
+
const { signIn, verifyEmail, loginWithOAuth } = useInsforge();
|
|
920
930
|
const { authConfig } = usePublicAuthConfig();
|
|
921
931
|
const [email, setEmail] = react.useState("");
|
|
922
932
|
const [password, setPassword] = react.useState("");
|
|
923
933
|
const [error, setError] = react.useState("");
|
|
924
934
|
const [loading, setLoading] = react.useState(false);
|
|
925
935
|
const [step, setStep] = react.useState("form");
|
|
926
|
-
const [oauthLoading
|
|
927
|
-
const [
|
|
936
|
+
const [oauthLoading] = react.useState(null);
|
|
937
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
938
|
+
const redirectUrl = searchParams.get("redirect");
|
|
928
939
|
async function handleSubmit(e) {
|
|
929
940
|
e.preventDefault();
|
|
930
941
|
setLoading(true);
|
|
@@ -940,10 +951,13 @@ function SignIn({ afterSignInUrl, onSuccess, onError, ...uiProps }) {
|
|
|
940
951
|
throw new Error(result.error);
|
|
941
952
|
}
|
|
942
953
|
const { user, accessToken, redirectTo } = result;
|
|
943
|
-
if (
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
954
|
+
if (user) {
|
|
955
|
+
const finalUrl = new URL(redirectTo || redirectUrl || "", window.location.origin);
|
|
956
|
+
finalUrl.searchParams.set("access_token", accessToken);
|
|
957
|
+
finalUrl.searchParams.set("user_id", user.id);
|
|
958
|
+
finalUrl.searchParams.set("email", user.email);
|
|
959
|
+
finalUrl.searchParams.set("name", user.name);
|
|
960
|
+
window.location.href = finalUrl.toString();
|
|
947
961
|
}
|
|
948
962
|
} catch (err) {
|
|
949
963
|
const errorMessage = err instanceof Error ? err.message : "Sign in failed";
|
|
@@ -956,38 +970,28 @@ function SignIn({ afterSignInUrl, onSuccess, onError, ...uiProps }) {
|
|
|
956
970
|
}
|
|
957
971
|
}
|
|
958
972
|
async function handleVerifyCode(code) {
|
|
973
|
+
setError("");
|
|
959
974
|
try {
|
|
960
|
-
const result = await
|
|
961
|
-
if (result
|
|
975
|
+
const result = await verifyEmail(email, code);
|
|
976
|
+
if (result?.error) {
|
|
962
977
|
throw new Error(result.error.message || "Verification failed");
|
|
963
978
|
}
|
|
964
|
-
if (result
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
979
|
+
if (result?.user) {
|
|
980
|
+
const finalUrl = new URL(result.redirectTo || redirectUrl || "", window.location.origin);
|
|
981
|
+
finalUrl.searchParams.set("access_token", result.accessToken);
|
|
982
|
+
finalUrl.searchParams.set("user_id", result.user.id);
|
|
983
|
+
finalUrl.searchParams.set("email", result.user.email);
|
|
984
|
+
finalUrl.searchParams.set("name", result.user.name);
|
|
985
|
+
window.location.href = finalUrl.toString();
|
|
968
986
|
}
|
|
969
987
|
} catch (err) {
|
|
970
988
|
const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
|
|
971
|
-
throw new Error(errorMessage);
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
async function handleOAuth(provider) {
|
|
975
|
-
try {
|
|
976
|
-
setOauthLoading(provider);
|
|
977
|
-
setError("");
|
|
978
|
-
await insforge.auth.signInWithOAuth({
|
|
979
|
-
provider,
|
|
980
|
-
redirectTo: afterSignInUrl
|
|
981
|
-
});
|
|
982
|
-
} catch (err) {
|
|
983
|
-
const errorMessage = err instanceof Error ? err.message : `${provider} sign in failed`;
|
|
984
989
|
setError(errorMessage);
|
|
985
|
-
if (onError) {
|
|
986
|
-
onError(new Error(errorMessage));
|
|
987
|
-
}
|
|
988
|
-
setOauthLoading(null);
|
|
989
990
|
}
|
|
990
991
|
}
|
|
992
|
+
function handleOAuth(provider) {
|
|
993
|
+
loginWithOAuth(provider, redirectUrl || "");
|
|
994
|
+
}
|
|
991
995
|
if (!authConfig) {
|
|
992
996
|
return null;
|
|
993
997
|
}
|
|
@@ -1036,8 +1040,7 @@ function SignUpForm({
|
|
|
1036
1040
|
signInUrl = "/sign-in",
|
|
1037
1041
|
dividerText = "or",
|
|
1038
1042
|
showVerificationStep = false,
|
|
1039
|
-
onVerifyCode
|
|
1040
|
-
verificationDescription
|
|
1043
|
+
onVerifyCode
|
|
1041
1044
|
}) {
|
|
1042
1045
|
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
1043
1046
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1048,14 +1051,7 @@ function SignUpForm({
|
|
|
1048
1051
|
}
|
|
1049
1052
|
),
|
|
1050
1053
|
/* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
|
|
1051
|
-
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1052
|
-
AuthEmailVerificationStep,
|
|
1053
|
-
{
|
|
1054
|
-
email,
|
|
1055
|
-
description: verificationDescription,
|
|
1056
|
-
onVerifyCode
|
|
1057
|
-
}
|
|
1058
|
-
) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
1054
|
+
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(AuthEmailVerificationStep, { email, onVerifyCode }) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
1059
1055
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1060
1056
|
AuthFormField,
|
|
1061
1057
|
{
|
|
@@ -1131,16 +1127,17 @@ function createPasswordSchema(options) {
|
|
|
1131
1127
|
return schema;
|
|
1132
1128
|
}
|
|
1133
1129
|
createPasswordSchema();
|
|
1134
|
-
function SignUp({
|
|
1135
|
-
const { signUp,
|
|
1130
|
+
function SignUp({ onError, ...uiProps }) {
|
|
1131
|
+
const { signUp, verifyEmail, loginWithOAuth } = useInsforge();
|
|
1136
1132
|
const { authConfig } = usePublicAuthConfig();
|
|
1137
1133
|
const [email, setEmail] = react.useState("");
|
|
1138
1134
|
const [password, setPassword] = react.useState("");
|
|
1139
1135
|
const [error, setError] = react.useState("");
|
|
1140
1136
|
const [loading, setLoading] = react.useState(false);
|
|
1141
1137
|
const [step, setStep] = react.useState("form");
|
|
1142
|
-
const [oauthLoading
|
|
1143
|
-
const [
|
|
1138
|
+
const [oauthLoading] = react.useState(null);
|
|
1139
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
1140
|
+
const redirectUrl = searchParams.get("redirect");
|
|
1144
1141
|
async function handleSubmit(e) {
|
|
1145
1142
|
e.preventDefault();
|
|
1146
1143
|
setLoading(true);
|
|
@@ -1182,9 +1179,12 @@ function SignUp({ afterSignUpUrl, onSuccess, onError, ...uiProps }) {
|
|
|
1182
1179
|
return;
|
|
1183
1180
|
}
|
|
1184
1181
|
if (result.accessToken && result.user) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1182
|
+
const finalUrl = new URL(result.redirectTo || redirectUrl || "", window.location.origin);
|
|
1183
|
+
finalUrl.searchParams.set("access_token", result.accessToken);
|
|
1184
|
+
finalUrl.searchParams.set("user_id", result.user.id);
|
|
1185
|
+
finalUrl.searchParams.set("email", result.user.email);
|
|
1186
|
+
finalUrl.searchParams.set("name", result.user.name);
|
|
1187
|
+
window.location.href = finalUrl.toString();
|
|
1188
1188
|
}
|
|
1189
1189
|
} catch (err) {
|
|
1190
1190
|
const errorMessage = err instanceof Error ? err.message : "Sign up failed";
|
|
@@ -1197,38 +1197,28 @@ function SignUp({ afterSignUpUrl, onSuccess, onError, ...uiProps }) {
|
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
1199
|
async function handleVerifyCode(code) {
|
|
1200
|
+
setError("");
|
|
1200
1201
|
try {
|
|
1201
|
-
const result = await
|
|
1202
|
-
if (result
|
|
1202
|
+
const result = await verifyEmail(email, code);
|
|
1203
|
+
if (result?.error) {
|
|
1203
1204
|
throw new Error(result.error.message || "Verification failed");
|
|
1204
1205
|
}
|
|
1205
|
-
if (result
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1206
|
+
if (result?.user) {
|
|
1207
|
+
const finalUrl = new URL(result.redirectTo || redirectUrl || "", window.location.origin);
|
|
1208
|
+
finalUrl.searchParams.set("access_token", result.accessToken);
|
|
1209
|
+
finalUrl.searchParams.set("user_id", result.user.id);
|
|
1210
|
+
finalUrl.searchParams.set("email", result.user.email);
|
|
1211
|
+
finalUrl.searchParams.set("name", result.user.name);
|
|
1212
|
+
window.location.href = finalUrl.toString();
|
|
1209
1213
|
}
|
|
1210
1214
|
} catch (err) {
|
|
1211
1215
|
const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
|
|
1212
|
-
throw new Error(errorMessage);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
async function handleOAuth(provider) {
|
|
1216
|
-
try {
|
|
1217
|
-
setOauthLoading(provider);
|
|
1218
|
-
setError("");
|
|
1219
|
-
await insforge.auth.signInWithOAuth({
|
|
1220
|
-
provider,
|
|
1221
|
-
redirectTo: afterSignUpUrl
|
|
1222
|
-
});
|
|
1223
|
-
} catch (err) {
|
|
1224
|
-
const errorMessage = err instanceof Error ? err.message : `${provider} sign up failed`;
|
|
1225
1216
|
setError(errorMessage);
|
|
1226
|
-
if (onError) {
|
|
1227
|
-
onError(new Error(errorMessage));
|
|
1228
|
-
}
|
|
1229
|
-
setOauthLoading(null);
|
|
1230
1217
|
}
|
|
1231
1218
|
}
|
|
1219
|
+
function handleOAuth(provider) {
|
|
1220
|
+
loginWithOAuth(provider, redirectUrl || "");
|
|
1221
|
+
}
|
|
1232
1222
|
if (!authConfig) {
|
|
1233
1223
|
return null;
|
|
1234
1224
|
}
|
|
@@ -1258,7 +1248,6 @@ function ForgotPasswordForm({
|
|
|
1258
1248
|
onSubmit,
|
|
1259
1249
|
error,
|
|
1260
1250
|
loading = false,
|
|
1261
|
-
success = false,
|
|
1262
1251
|
title = "Forgot Password?",
|
|
1263
1252
|
subtitle = "Enter your email address and we'll send you a code to reset your password.",
|
|
1264
1253
|
emailLabel = "Email",
|
|
@@ -1267,53 +1256,30 @@ function ForgotPasswordForm({
|
|
|
1267
1256
|
loadingButtonText = "Sending...",
|
|
1268
1257
|
backToSignInText = "Remember your password?",
|
|
1269
1258
|
backToSignInUrl = "/sign-in",
|
|
1270
|
-
|
|
1271
|
-
|
|
1259
|
+
showVerificationStep = false,
|
|
1260
|
+
resetPasswordMethod = "code",
|
|
1261
|
+
onVerifyCode,
|
|
1262
|
+
onResendEmail
|
|
1272
1263
|
}) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1264
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
1265
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1266
|
+
AuthHeader,
|
|
1276
1267
|
{
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1280
|
-
"div",
|
|
1281
|
-
{
|
|
1282
|
-
style: {
|
|
1283
|
-
width: "4rem",
|
|
1284
|
-
height: "4rem",
|
|
1285
|
-
borderRadius: "50%",
|
|
1286
|
-
backgroundColor: "#D1FAE5",
|
|
1287
|
-
display: "flex",
|
|
1288
|
-
alignItems: "center",
|
|
1289
|
-
justifyContent: "center"
|
|
1290
|
-
},
|
|
1291
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1292
|
-
"svg",
|
|
1293
|
-
{
|
|
1294
|
-
style: { width: "2rem", height: "2rem", color: "#059669" },
|
|
1295
|
-
fill: "none",
|
|
1296
|
-
strokeLinecap: "round",
|
|
1297
|
-
strokeLinejoin: "round",
|
|
1298
|
-
strokeWidth: "2",
|
|
1299
|
-
viewBox: "0 0 24 24",
|
|
1300
|
-
stroke: "currentColor",
|
|
1301
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 13l4 4L19 7" })
|
|
1302
|
-
}
|
|
1303
|
-
)
|
|
1304
|
-
}
|
|
1305
|
-
),
|
|
1306
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title", style: { textAlign: "center" }, children: successTitle }),
|
|
1307
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle", style: { textAlign: "center" }, children: successMessage || `We've sent a password reset link to ${email}. Please check your email and follow the instructions.` }),
|
|
1308
|
-
/* @__PURE__ */ jsxRuntime.jsx("a", { href: backToSignInUrl, className: "if-authLink-link", style: { marginTop: "1rem" }, children: "Back to Sign In" })
|
|
1309
|
-
]
|
|
1268
|
+
title: showVerificationStep ? resetPasswordMethod === "link" ? "Check Your Email" : "Enter Reset Code" : title,
|
|
1269
|
+
subtitle: showVerificationStep ? "" : subtitle
|
|
1310
1270
|
}
|
|
1311
|
-
)
|
|
1312
|
-
}
|
|
1313
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
1314
|
-
/* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title, subtitle }),
|
|
1271
|
+
),
|
|
1315
1272
|
/* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
|
|
1316
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1273
|
+
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1274
|
+
AuthResetPasswordVerificationStep,
|
|
1275
|
+
{
|
|
1276
|
+
email,
|
|
1277
|
+
method: resetPasswordMethod,
|
|
1278
|
+
onVerifyCode,
|
|
1279
|
+
onResendEmail: onResendEmail || (async () => {
|
|
1280
|
+
})
|
|
1281
|
+
}
|
|
1282
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
1317
1283
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1318
1284
|
AuthFormField,
|
|
1319
1285
|
{
|
|
@@ -1329,7 +1295,7 @@ function ForgotPasswordForm({
|
|
|
1329
1295
|
),
|
|
1330
1296
|
/* @__PURE__ */ jsxRuntime.jsx(AuthSubmitButton, { isLoading: loading, disabled: loading, children: loading ? loadingButtonText : submitButtonText })
|
|
1331
1297
|
] }),
|
|
1332
|
-
/* @__PURE__ */ jsxRuntime.jsx(AuthLink, { text: backToSignInText, linkText: "Back to Sign In", href: backToSignInUrl })
|
|
1298
|
+
!showVerificationStep && /* @__PURE__ */ jsxRuntime.jsx(AuthLink, { text: backToSignInText, linkText: "Back to Sign In", href: backToSignInUrl })
|
|
1333
1299
|
] });
|
|
1334
1300
|
}
|
|
1335
1301
|
function ResetPasswordForm({
|
|
@@ -1350,11 +1316,12 @@ function ResetPasswordForm({
|
|
|
1350
1316
|
confirmPasswordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
1351
1317
|
submitButtonText = "Reset Password",
|
|
1352
1318
|
loadingButtonText = "Resetting...",
|
|
1353
|
-
|
|
1354
|
-
backToSignInUrl = "/sign-in",
|
|
1355
|
-
successTitle = "Password Reset Successful!",
|
|
1356
|
-
successMessage = "Your password has been successfully reset. You can now sign in with your new password."
|
|
1319
|
+
successTitle = "Password Reset Successful!"
|
|
1357
1320
|
}) {
|
|
1321
|
+
let successMessage = "Your password has been successfully reset. You can close this page and sign in with your new password.";
|
|
1322
|
+
if (authConfig && authConfig.verifyEmailMethod === "code") {
|
|
1323
|
+
successMessage = "Your password has been successfully reset. You can wait for redirect to sign in with your new password.";
|
|
1324
|
+
}
|
|
1358
1325
|
if (success) {
|
|
1359
1326
|
return /* @__PURE__ */ jsxRuntime.jsx(AuthContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1360
1327
|
"div",
|
|
@@ -1389,8 +1356,7 @@ function ResetPasswordForm({
|
|
|
1389
1356
|
}
|
|
1390
1357
|
),
|
|
1391
1358
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title", style: { textAlign: "center" }, children: successTitle }),
|
|
1392
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle", style: { textAlign: "center" }, children: successMessage })
|
|
1393
|
-
/* @__PURE__ */ jsxRuntime.jsx("a", { href: backToSignInUrl, className: "if-authLink-link", style: { marginTop: "1rem" }, children: "Back to Sign In" })
|
|
1359
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle", style: { textAlign: "center" }, children: successMessage })
|
|
1394
1360
|
]
|
|
1395
1361
|
}
|
|
1396
1362
|
) });
|
|
@@ -1427,64 +1393,115 @@ function ResetPasswordForm({
|
|
|
1427
1393
|
}
|
|
1428
1394
|
),
|
|
1429
1395
|
/* @__PURE__ */ jsxRuntime.jsx(AuthSubmitButton, { isLoading: loading, disabled: loading, children: loading ? loadingButtonText : submitButtonText })
|
|
1430
|
-
] })
|
|
1431
|
-
/* @__PURE__ */ jsxRuntime.jsx(AuthLink, { text: backToSignInText, linkText: "Back to Sign In", href: backToSignInUrl })
|
|
1396
|
+
] })
|
|
1432
1397
|
] });
|
|
1433
1398
|
}
|
|
1434
|
-
function
|
|
1435
|
-
|
|
1436
|
-
backToSignInUrl = "/sign-in",
|
|
1437
|
-
onSuccess,
|
|
1438
|
-
onError,
|
|
1439
|
-
...uiProps
|
|
1440
|
-
}) {
|
|
1441
|
-
const { resetPassword } = useInsforge();
|
|
1399
|
+
function ForgotPassword({ onError, ...uiProps }) {
|
|
1400
|
+
const { sendResetPasswordEmail, exchangeResetPasswordToken, resetPassword } = useInsforge();
|
|
1442
1401
|
const { authConfig } = usePublicAuthConfig();
|
|
1402
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
1403
|
+
const [step, setStep] = react.useState("email");
|
|
1404
|
+
const [email, setEmail] = react.useState("");
|
|
1405
|
+
const [resetToken, setResetToken] = react.useState("");
|
|
1443
1406
|
const [newPassword, setNewPassword] = react.useState("");
|
|
1444
1407
|
const [confirmPassword, setConfirmPassword] = react.useState("");
|
|
1445
1408
|
const [error, setError] = react.useState("");
|
|
1446
1409
|
const [loading, setLoading] = react.useState(false);
|
|
1447
1410
|
const [success, setSuccess] = react.useState(false);
|
|
1448
|
-
|
|
1411
|
+
const [showVerificationStep, setShowVerificationStep] = react.useState(false);
|
|
1412
|
+
async function handleEmailSubmit(e) {
|
|
1449
1413
|
e.preventDefault();
|
|
1450
1414
|
setLoading(true);
|
|
1451
1415
|
setError("");
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
return;
|
|
1456
|
-
}
|
|
1457
|
-
if (newPassword !== confirmPassword) {
|
|
1458
|
-
setError("Passwords do not match");
|
|
1459
|
-
setLoading(false);
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
if (!token) {
|
|
1463
|
-
setError("Reset token is missing");
|
|
1464
|
-
setLoading(false);
|
|
1465
|
-
return;
|
|
1466
|
-
}
|
|
1467
|
-
const passwordZodSchema = createPasswordSchema({
|
|
1468
|
-
minLength: authConfig.passwordMinLength,
|
|
1469
|
-
requireUppercase: authConfig.requireUppercase,
|
|
1470
|
-
requireLowercase: authConfig.requireLowercase,
|
|
1471
|
-
requireNumber: authConfig.requireNumber,
|
|
1472
|
-
requireSpecialChar: authConfig.requireSpecialChar
|
|
1473
|
-
});
|
|
1474
|
-
const passwordValidation = passwordZodSchema.safeParse(newPassword);
|
|
1475
|
-
if (!passwordValidation.success) {
|
|
1476
|
-
const firstError = passwordValidation.error.issues[0];
|
|
1416
|
+
const emailValidation = emailSchema.safeParse(email);
|
|
1417
|
+
if (!emailValidation.success) {
|
|
1418
|
+
const firstError = emailValidation.error.issues[0];
|
|
1477
1419
|
setError(firstError.message);
|
|
1478
1420
|
setLoading(false);
|
|
1479
1421
|
return;
|
|
1480
1422
|
}
|
|
1481
1423
|
try {
|
|
1482
|
-
const result = await
|
|
1424
|
+
const result = await sendResetPasswordEmail(emailValidation.data);
|
|
1425
|
+
if (result?.success) {
|
|
1426
|
+
setShowVerificationStep(true);
|
|
1427
|
+
} else {
|
|
1428
|
+
const errorMessage = result?.message || "Failed to send reset email";
|
|
1429
|
+
setError(errorMessage);
|
|
1430
|
+
if (onError) {
|
|
1431
|
+
onError(new Error(errorMessage));
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
} catch (err) {
|
|
1435
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to send reset email";
|
|
1436
|
+
setError(errorMessage);
|
|
1437
|
+
if (onError) {
|
|
1438
|
+
onError(new Error(errorMessage));
|
|
1439
|
+
}
|
|
1440
|
+
} finally {
|
|
1441
|
+
setLoading(false);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
async function handleVerifyCode(code) {
|
|
1445
|
+
setError("");
|
|
1446
|
+
try {
|
|
1447
|
+
const result = await exchangeResetPasswordToken(email, code);
|
|
1448
|
+
if ("error" in result) {
|
|
1449
|
+
throw new Error(result.error.message || "Failed to verify code");
|
|
1450
|
+
}
|
|
1451
|
+
if (result.token) {
|
|
1452
|
+
setResetToken(result.token);
|
|
1453
|
+
setStep("password");
|
|
1454
|
+
}
|
|
1455
|
+
} catch (err) {
|
|
1456
|
+
const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
|
|
1457
|
+
setError(errorMessage);
|
|
1458
|
+
if (onError) {
|
|
1459
|
+
onError(new Error(errorMessage));
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
async function handleResendEmail() {
|
|
1464
|
+
await sendResetPasswordEmail(email);
|
|
1465
|
+
}
|
|
1466
|
+
async function handleResetPasswordSubmit(e) {
|
|
1467
|
+
e.preventDefault();
|
|
1468
|
+
setLoading(true);
|
|
1469
|
+
setError("");
|
|
1470
|
+
if (newPassword !== confirmPassword) {
|
|
1471
|
+
setError("Passwords do not match");
|
|
1472
|
+
setLoading(false);
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
if (!authConfig) {
|
|
1476
|
+
setError("Configuration not loaded");
|
|
1477
|
+
setLoading(false);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
const passwordZodSchema = createPasswordSchema({
|
|
1481
|
+
minLength: authConfig.passwordMinLength,
|
|
1482
|
+
requireUppercase: authConfig.requireUppercase,
|
|
1483
|
+
requireLowercase: authConfig.requireLowercase,
|
|
1484
|
+
requireNumber: authConfig.requireNumber,
|
|
1485
|
+
requireSpecialChar: authConfig.requireSpecialChar
|
|
1486
|
+
});
|
|
1487
|
+
const passwordValidation = passwordZodSchema.safeParse(newPassword);
|
|
1488
|
+
if (!passwordValidation.success) {
|
|
1489
|
+
const firstError = passwordValidation.error.issues[0];
|
|
1490
|
+
setError(firstError.message);
|
|
1491
|
+
setLoading(false);
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
try {
|
|
1495
|
+
const result = await resetPassword(resetToken, newPassword);
|
|
1483
1496
|
if (result?.message) {
|
|
1484
1497
|
setSuccess(true);
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1498
|
+
const signInUrl = new URL("/sign-in", window.location.origin);
|
|
1499
|
+
searchParams.forEach((value, key) => {
|
|
1500
|
+
signInUrl.searchParams.set(key, value);
|
|
1501
|
+
});
|
|
1502
|
+
setTimeout(() => {
|
|
1503
|
+
window.location.href = signInUrl.toString();
|
|
1504
|
+
}, 2e3);
|
|
1488
1505
|
} else {
|
|
1489
1506
|
const errorMessage = "Failed to reset password";
|
|
1490
1507
|
setError(errorMessage);
|
|
@@ -1505,6 +1522,25 @@ function ResetPassword({
|
|
|
1505
1522
|
if (!authConfig) {
|
|
1506
1523
|
return null;
|
|
1507
1524
|
}
|
|
1525
|
+
if (step === "email") {
|
|
1526
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
|
+
ForgotPasswordForm,
|
|
1528
|
+
{
|
|
1529
|
+
email,
|
|
1530
|
+
onEmailChange: setEmail,
|
|
1531
|
+
onSubmit: (e) => {
|
|
1532
|
+
void handleEmailSubmit(e);
|
|
1533
|
+
},
|
|
1534
|
+
error,
|
|
1535
|
+
loading,
|
|
1536
|
+
showVerificationStep,
|
|
1537
|
+
resetPasswordMethod: authConfig.resetPasswordMethod,
|
|
1538
|
+
onVerifyCode: handleVerifyCode,
|
|
1539
|
+
onResendEmail: handleResendEmail,
|
|
1540
|
+
...uiProps
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1508
1544
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1509
1545
|
ResetPasswordForm,
|
|
1510
1546
|
{
|
|
@@ -1512,83 +1548,71 @@ function ResetPassword({
|
|
|
1512
1548
|
confirmPassword,
|
|
1513
1549
|
onNewPasswordChange: setNewPassword,
|
|
1514
1550
|
onConfirmPasswordChange: setConfirmPassword,
|
|
1515
|
-
onSubmit:
|
|
1551
|
+
onSubmit: handleResetPasswordSubmit,
|
|
1516
1552
|
error,
|
|
1517
1553
|
loading,
|
|
1518
1554
|
success,
|
|
1519
1555
|
authConfig,
|
|
1520
|
-
backToSignInUrl,
|
|
1521
1556
|
...uiProps
|
|
1522
1557
|
}
|
|
1523
1558
|
);
|
|
1524
1559
|
}
|
|
1525
|
-
function
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
...uiProps
|
|
1530
|
-
}) {
|
|
1531
|
-
const { sendResetPasswordEmail, baseUrl } = useInsforge();
|
|
1560
|
+
function ResetPassword({ onError, ...uiProps }) {
|
|
1561
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
1562
|
+
const token = searchParams.get("token");
|
|
1563
|
+
const { resetPassword } = useInsforge();
|
|
1532
1564
|
const { authConfig } = usePublicAuthConfig();
|
|
1533
|
-
const [
|
|
1534
|
-
const [
|
|
1535
|
-
const [email, setEmail] = react.useState("");
|
|
1536
|
-
const [verificationCode, setVerificationCode] = react.useState("");
|
|
1537
|
-
const [resetToken, setResetToken] = react.useState("");
|
|
1565
|
+
const [newPassword, setNewPassword] = react.useState("");
|
|
1566
|
+
const [confirmPassword, setConfirmPassword] = react.useState("");
|
|
1538
1567
|
const [error, setError] = react.useState("");
|
|
1539
1568
|
const [loading, setLoading] = react.useState(false);
|
|
1540
1569
|
const [success, setSuccess] = react.useState(false);
|
|
1541
|
-
|
|
1542
|
-
const [resendCountdown, setResendCountdown] = react.useState(60);
|
|
1543
|
-
const [isSendingCode, setIsSendingCode] = react.useState(false);
|
|
1544
|
-
const [isVerifyingCode, setIsVerifyingCode] = react.useState(false);
|
|
1545
|
-
react.useEffect(() => {
|
|
1546
|
-
if (resendCountdown > 0 && step === "code") {
|
|
1547
|
-
const timer = setInterval(() => {
|
|
1548
|
-
setResendCountdown((prev) => {
|
|
1549
|
-
if (prev <= 1) {
|
|
1550
|
-
setResendDisabled(false);
|
|
1551
|
-
return 0;
|
|
1552
|
-
}
|
|
1553
|
-
return prev - 1;
|
|
1554
|
-
});
|
|
1555
|
-
}, 1e3);
|
|
1556
|
-
return () => clearInterval(timer);
|
|
1557
|
-
}
|
|
1558
|
-
}, [resendCountdown, step]);
|
|
1559
|
-
async function handleEmailSubmit(e) {
|
|
1570
|
+
async function handleSubmit(e) {
|
|
1560
1571
|
e.preventDefault();
|
|
1561
1572
|
setLoading(true);
|
|
1562
1573
|
setError("");
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1574
|
+
if (!authConfig) {
|
|
1575
|
+
setError("Configuration not loaded. Please refresh the page.");
|
|
1576
|
+
setLoading(false);
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
if (newPassword !== confirmPassword) {
|
|
1580
|
+
setError("Passwords do not match");
|
|
1581
|
+
setLoading(false);
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
if (!token) {
|
|
1585
|
+
setError("Reset token is missing");
|
|
1586
|
+
setLoading(false);
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
const passwordZodSchema = createPasswordSchema({
|
|
1590
|
+
minLength: authConfig.passwordMinLength,
|
|
1591
|
+
requireUppercase: authConfig.requireUppercase,
|
|
1592
|
+
requireLowercase: authConfig.requireLowercase,
|
|
1593
|
+
requireNumber: authConfig.requireNumber,
|
|
1594
|
+
requireSpecialChar: authConfig.requireSpecialChar
|
|
1595
|
+
});
|
|
1596
|
+
const passwordValidation = passwordZodSchema.safeParse(newPassword);
|
|
1597
|
+
if (!passwordValidation.success) {
|
|
1598
|
+
const firstError = passwordValidation.error.issues[0];
|
|
1566
1599
|
setError(firstError.message);
|
|
1567
1600
|
setLoading(false);
|
|
1568
1601
|
return;
|
|
1569
1602
|
}
|
|
1570
1603
|
try {
|
|
1571
|
-
const result = await
|
|
1572
|
-
if (result?.
|
|
1573
|
-
|
|
1574
|
-
setSuccess(true);
|
|
1575
|
-
if (onSuccess) {
|
|
1576
|
-
onSuccess();
|
|
1577
|
-
}
|
|
1578
|
-
} else {
|
|
1579
|
-
setStep("code");
|
|
1580
|
-
setResendDisabled(true);
|
|
1581
|
-
setResendCountdown(60);
|
|
1582
|
-
}
|
|
1604
|
+
const result = await resetPassword(token, newPassword);
|
|
1605
|
+
if (result?.message) {
|
|
1606
|
+
setSuccess(true);
|
|
1583
1607
|
} else {
|
|
1584
|
-
const errorMessage =
|
|
1608
|
+
const errorMessage = "Failed to reset password";
|
|
1585
1609
|
setError(errorMessage);
|
|
1586
1610
|
if (onError) {
|
|
1587
1611
|
onError(new Error(errorMessage));
|
|
1588
1612
|
}
|
|
1589
1613
|
}
|
|
1590
1614
|
} catch (err) {
|
|
1591
|
-
const errorMessage = err instanceof Error ? err.message : "Failed to
|
|
1615
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to reset password";
|
|
1592
1616
|
setError(errorMessage);
|
|
1593
1617
|
if (onError) {
|
|
1594
1618
|
onError(new Error(errorMessage));
|
|
@@ -1597,297 +1621,157 @@ function ForgotPassword({
|
|
|
1597
1621
|
setLoading(false);
|
|
1598
1622
|
}
|
|
1599
1623
|
}
|
|
1600
|
-
async function handleVerifyCode(code) {
|
|
1601
|
-
setIsVerifyingCode(true);
|
|
1602
|
-
setError("");
|
|
1603
|
-
setVerificationCode(code);
|
|
1604
|
-
try {
|
|
1605
|
-
const result = await insforge.auth.exchangeResetPasswordToken({ email, code });
|
|
1606
|
-
if (result.error) {
|
|
1607
|
-
throw new Error(result.error.message || "Failed to verify code");
|
|
1608
|
-
}
|
|
1609
|
-
if (result.data) {
|
|
1610
|
-
setResetToken(result.data.token);
|
|
1611
|
-
setStep("password");
|
|
1612
|
-
}
|
|
1613
|
-
} catch (err) {
|
|
1614
|
-
const errorMessage = err instanceof Error ? err.message : "Invalid verification code";
|
|
1615
|
-
setError(errorMessage);
|
|
1616
|
-
setVerificationCode("");
|
|
1617
|
-
} finally {
|
|
1618
|
-
setIsVerifyingCode(false);
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
const handleResendCode = react.useCallback(async () => {
|
|
1622
|
-
setResendDisabled(true);
|
|
1623
|
-
setResendCountdown(60);
|
|
1624
|
-
setIsSendingCode(true);
|
|
1625
|
-
setError("");
|
|
1626
|
-
try {
|
|
1627
|
-
await sendResetPasswordEmail(email);
|
|
1628
|
-
} catch (err) {
|
|
1629
|
-
const errorMessage = err instanceof Error ? err.message : "Failed to resend code";
|
|
1630
|
-
setError(errorMessage);
|
|
1631
|
-
setResendDisabled(false);
|
|
1632
|
-
setResendCountdown(0);
|
|
1633
|
-
} finally {
|
|
1634
|
-
setIsSendingCode(false);
|
|
1635
|
-
}
|
|
1636
|
-
}, [email, sendResetPasswordEmail]);
|
|
1637
|
-
function handlePasswordResetSuccess(redirectTo) {
|
|
1638
|
-
const targetUrl = redirectTo || backToSignInUrl;
|
|
1639
|
-
if (onSuccess) {
|
|
1640
|
-
onSuccess();
|
|
1641
|
-
}
|
|
1642
|
-
setTimeout(() => {
|
|
1643
|
-
window.location.href = targetUrl;
|
|
1644
|
-
}, 1500);
|
|
1645
|
-
}
|
|
1646
1624
|
if (!authConfig) {
|
|
1647
1625
|
return null;
|
|
1648
1626
|
}
|
|
1649
|
-
if (
|
|
1650
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1651
|
-
ForgotPasswordForm,
|
|
1652
|
-
{
|
|
1653
|
-
email,
|
|
1654
|
-
onEmailChange: setEmail,
|
|
1655
|
-
onSubmit: (e) => {
|
|
1656
|
-
void handleEmailSubmit(e);
|
|
1657
|
-
},
|
|
1658
|
-
error,
|
|
1659
|
-
loading,
|
|
1660
|
-
success,
|
|
1661
|
-
backToSignInUrl,
|
|
1662
|
-
...uiProps
|
|
1663
|
-
}
|
|
1664
|
-
);
|
|
1665
|
-
}
|
|
1666
|
-
if (step === "code") {
|
|
1627
|
+
if (!token) {
|
|
1667
1628
|
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
1629
|
+
/* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title: "Invalid Reset Link", subtitle: "" }),
|
|
1668
1630
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1669
|
-
AuthHeader,
|
|
1670
|
-
{
|
|
1671
|
-
title: "Enter Reset Code",
|
|
1672
|
-
subtitle: `We've sent a 6-digit verification code to ${email}. Please enter it below to reset your password. The code will expire in 10 minutes.`
|
|
1673
|
-
}
|
|
1674
|
-
),
|
|
1675
|
-
/* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error }),
|
|
1676
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1677
1631
|
"div",
|
|
1678
1632
|
{
|
|
1679
1633
|
style: {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
alignItems: "center"
|
|
1634
|
+
padding: "1.5rem",
|
|
1635
|
+
backgroundColor: "#FEE2E2",
|
|
1636
|
+
borderRadius: "0.5rem",
|
|
1637
|
+
border: "1px solid #DC2626"
|
|
1685
1638
|
},
|
|
1686
|
-
children:
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
{
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
},
|
|
1699
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1700
|
-
"div",
|
|
1701
|
-
{
|
|
1702
|
-
style: {
|
|
1703
|
-
display: "flex",
|
|
1704
|
-
flexDirection: "column",
|
|
1705
|
-
gap: "0.75rem",
|
|
1706
|
-
marginTop: "0.5rem"
|
|
1707
|
-
},
|
|
1708
|
-
children: [
|
|
1709
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1710
|
-
AuthVerificationCodeInput,
|
|
1711
|
-
{
|
|
1712
|
-
value: verificationCode,
|
|
1713
|
-
onChange: setVerificationCode,
|
|
1714
|
-
email,
|
|
1715
|
-
disabled: isVerifyingCode,
|
|
1716
|
-
onComplete: (code) => {
|
|
1717
|
-
void handleVerifyCode(code);
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
),
|
|
1721
|
-
isVerifyingCode && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle", style: { textAlign: "center" }, children: "Verifying..." })
|
|
1722
|
-
]
|
|
1723
|
-
}
|
|
1724
|
-
)
|
|
1725
|
-
}
|
|
1726
|
-
),
|
|
1727
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1728
|
-
"div",
|
|
1729
|
-
{
|
|
1730
|
-
style: {
|
|
1731
|
-
width: "100%",
|
|
1732
|
-
fontSize: "0.875rem",
|
|
1733
|
-
textAlign: "center",
|
|
1734
|
-
color: "#828282",
|
|
1735
|
-
fontFamily: "var(--if-font-family)"
|
|
1736
|
-
},
|
|
1737
|
-
children: [
|
|
1738
|
-
"Didn't receive the email?",
|
|
1739
|
-
" ",
|
|
1740
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1741
|
-
"button",
|
|
1742
|
-
{
|
|
1743
|
-
onClick: () => {
|
|
1744
|
-
void handleResendCode();
|
|
1745
|
-
},
|
|
1746
|
-
disabled: resendDisabled || isSendingCode,
|
|
1747
|
-
style: {
|
|
1748
|
-
color: "#000",
|
|
1749
|
-
fontWeight: 500,
|
|
1750
|
-
transition: "all 0.2s",
|
|
1751
|
-
cursor: resendDisabled || isSendingCode ? "not-allowed" : "pointer",
|
|
1752
|
-
background: "none",
|
|
1753
|
-
border: "none",
|
|
1754
|
-
padding: 0,
|
|
1755
|
-
textDecoration: resendDisabled || isSendingCode ? "none" : "underline",
|
|
1756
|
-
opacity: resendDisabled || isSendingCode ? 0.5 : 1,
|
|
1757
|
-
fontFamily: "var(--if-font-family)"
|
|
1758
|
-
},
|
|
1759
|
-
children: isSendingCode ? "Sending..." : resendDisabled ? `Retry in (${resendCountdown}s)` : "Click to resend"
|
|
1760
|
-
}
|
|
1761
|
-
)
|
|
1762
|
-
]
|
|
1763
|
-
}
|
|
1764
|
-
)
|
|
1765
|
-
]
|
|
1639
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1640
|
+
"p",
|
|
1641
|
+
{
|
|
1642
|
+
style: {
|
|
1643
|
+
fontSize: "0.875rem",
|
|
1644
|
+
color: "#DC2626",
|
|
1645
|
+
margin: 0,
|
|
1646
|
+
fontFamily: "var(--if-font-family)"
|
|
1647
|
+
},
|
|
1648
|
+
children: "The password reset link is missing or invalid. Please request a new password reset link."
|
|
1649
|
+
}
|
|
1650
|
+
)
|
|
1766
1651
|
}
|
|
1767
|
-
)
|
|
1768
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle", style: { textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: backToSignInUrl, className: "if-authLink-link", children: "Back to Sign In" }) })
|
|
1652
|
+
)
|
|
1769
1653
|
] });
|
|
1770
1654
|
}
|
|
1771
|
-
|
|
1772
|
-
ResetPassword,
|
|
1773
|
-
{
|
|
1774
|
-
token: resetToken,
|
|
1775
|
-
backToSignInUrl,
|
|
1776
|
-
onSuccess: handlePasswordResetSuccess,
|
|
1777
|
-
onError
|
|
1778
|
-
}
|
|
1779
|
-
);
|
|
1780
|
-
}
|
|
1781
|
-
function VerifyEmailStatus({
|
|
1782
|
-
status,
|
|
1783
|
-
error,
|
|
1784
|
-
verifyingTitle = "Verifying your email...",
|
|
1785
|
-
successTitle = "Email Verified!",
|
|
1786
|
-
successMessage = "Your email has been verified successfully. You can close this page and return to your app.",
|
|
1787
|
-
errorTitle = "Verification Failed"
|
|
1788
|
-
}) {
|
|
1789
|
-
if (status === "verifying") {
|
|
1655
|
+
if (success) {
|
|
1790
1656
|
return /* @__PURE__ */ jsxRuntime.jsx(AuthContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1791
1657
|
"div",
|
|
1792
1658
|
{
|
|
1793
|
-
style: {
|
|
1794
|
-
width: "100%",
|
|
1795
|
-
display: "flex",
|
|
1796
|
-
flexDirection: "column",
|
|
1797
|
-
alignItems: "center",
|
|
1798
|
-
justifyContent: "center",
|
|
1799
|
-
gap: "1.5rem"
|
|
1800
|
-
},
|
|
1659
|
+
style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "1rem" },
|
|
1801
1660
|
children: [
|
|
1802
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title", children: verifyingTitle }),
|
|
1803
1661
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1804
1662
|
"div",
|
|
1805
1663
|
{
|
|
1806
|
-
className: "if-submitButton-spinner",
|
|
1807
1664
|
style: {
|
|
1665
|
+
width: "4rem",
|
|
1666
|
+
height: "4rem",
|
|
1808
1667
|
borderRadius: "50%",
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1668
|
+
backgroundColor: "#D1FAE5",
|
|
1669
|
+
display: "flex",
|
|
1670
|
+
alignItems: "center",
|
|
1671
|
+
justifyContent: "center"
|
|
1672
|
+
},
|
|
1673
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1674
|
+
"svg",
|
|
1675
|
+
{
|
|
1676
|
+
style: { width: "2rem", height: "2rem", color: "#059669" },
|
|
1677
|
+
fill: "none",
|
|
1678
|
+
strokeLinecap: "round",
|
|
1679
|
+
strokeLinejoin: "round",
|
|
1680
|
+
strokeWidth: "2",
|
|
1681
|
+
viewBox: "0 0 24 24",
|
|
1682
|
+
stroke: "currentColor",
|
|
1683
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 13l4 4L19 7" })
|
|
1684
|
+
}
|
|
1685
|
+
)
|
|
1686
|
+
}
|
|
1687
|
+
),
|
|
1688
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1689
|
+
"h2",
|
|
1690
|
+
{
|
|
1691
|
+
style: {
|
|
1692
|
+
fontSize: "1.5rem",
|
|
1693
|
+
fontWeight: 600,
|
|
1694
|
+
color: "#000",
|
|
1695
|
+
margin: 0,
|
|
1696
|
+
textAlign: "center",
|
|
1697
|
+
fontFamily: "var(--if-font-family)"
|
|
1698
|
+
},
|
|
1699
|
+
children: "Password Reset Successfully"
|
|
1700
|
+
}
|
|
1701
|
+
),
|
|
1702
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1703
|
+
"p",
|
|
1704
|
+
{
|
|
1705
|
+
style: {
|
|
1706
|
+
fontSize: "0.875rem",
|
|
1707
|
+
color: "#828282",
|
|
1708
|
+
textAlign: "center",
|
|
1709
|
+
margin: 0,
|
|
1710
|
+
fontFamily: "var(--if-font-family)"
|
|
1711
|
+
},
|
|
1712
|
+
children: "Your password has been reset successfully. You can now close this page and return to the login page in your original tab."
|
|
1813
1713
|
}
|
|
1814
1714
|
)
|
|
1815
1715
|
]
|
|
1816
1716
|
}
|
|
1817
1717
|
) });
|
|
1818
1718
|
}
|
|
1719
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1720
|
+
ResetPasswordForm,
|
|
1721
|
+
{
|
|
1722
|
+
newPassword,
|
|
1723
|
+
confirmPassword,
|
|
1724
|
+
onNewPasswordChange: setNewPassword,
|
|
1725
|
+
onConfirmPasswordChange: setConfirmPassword,
|
|
1726
|
+
onSubmit: handleSubmit,
|
|
1727
|
+
error,
|
|
1728
|
+
loading,
|
|
1729
|
+
success: false,
|
|
1730
|
+
authConfig,
|
|
1731
|
+
...uiProps
|
|
1732
|
+
}
|
|
1733
|
+
);
|
|
1734
|
+
}
|
|
1735
|
+
function VerifyEmailStatus({
|
|
1736
|
+
status,
|
|
1737
|
+
error,
|
|
1738
|
+
verifyingTitle = "Verifying your email...",
|
|
1739
|
+
successTitle = "Email Verified!",
|
|
1740
|
+
successMessage = "Your email has been verified successfully. You can close this page and sign in to your app.",
|
|
1741
|
+
errorTitle = "Verification Failed"
|
|
1742
|
+
}) {
|
|
1743
|
+
if (status === "verifying") {
|
|
1744
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verifyStatus-container", children: [
|
|
1745
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title", children: verifyingTitle }),
|
|
1746
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-submitButton-spinner if-verifyStatus-spinner" })
|
|
1747
|
+
] }) });
|
|
1748
|
+
}
|
|
1819
1749
|
if (status === "error") {
|
|
1820
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AuthContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1821
|
-
"
|
|
1750
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContainer, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verifyStatus-container-stretch", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-authHeader if-internal-h3m7w5", children: [
|
|
1751
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "if-authHeader-title if-internal-t4p1k9", children: errorTitle }),
|
|
1752
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "if-authHeader-subtitle if-internal-s7q2m3", children: [
|
|
1753
|
+
error || "The verification link is invalid or has expired.",
|
|
1754
|
+
" Please try again or contact support if the problem persists. You can close this page and return to your app."
|
|
1755
|
+
] })
|
|
1756
|
+
] }) }) });
|
|
1757
|
+
}
|
|
1758
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContainer, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verifyStatus-container-stretch", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verifyStatus-successContent", children: [
|
|
1759
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verifyStatus-successIcon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1760
|
+
"svg",
|
|
1822
1761
|
{
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
}
|
|
1831
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-authHeader if-internal-h3m7w5", children: [
|
|
1832
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "if-authHeader-title if-internal-t4p1k9", children: errorTitle }),
|
|
1833
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "if-authHeader-subtitle if-internal-s7q2m3", style: { lineHeight: "1.5" }, children: [
|
|
1834
|
-
error || "The verification link is invalid or has expired.",
|
|
1835
|
-
" Please try again or contact support if the problem persists. You can close this page and return to your app."
|
|
1836
|
-
] })
|
|
1837
|
-
] })
|
|
1762
|
+
className: "if-verifyStatus-successIconSvg",
|
|
1763
|
+
fill: "none",
|
|
1764
|
+
strokeLinecap: "round",
|
|
1765
|
+
strokeLinejoin: "round",
|
|
1766
|
+
strokeWidth: "2",
|
|
1767
|
+
viewBox: "0 0 24 24",
|
|
1768
|
+
stroke: "currentColor",
|
|
1769
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 13l4 4L19 7" })
|
|
1838
1770
|
}
|
|
1839
|
-
) })
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
{
|
|
1844
|
-
style: {
|
|
1845
|
-
width: "100%",
|
|
1846
|
-
display: "flex",
|
|
1847
|
-
flexDirection: "column",
|
|
1848
|
-
alignItems: "stretch",
|
|
1849
|
-
justifyContent: "center",
|
|
1850
|
-
gap: "1.5rem"
|
|
1851
|
-
},
|
|
1852
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1853
|
-
"div",
|
|
1854
|
-
{
|
|
1855
|
-
style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "1rem" },
|
|
1856
|
-
children: [
|
|
1857
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1858
|
-
"div",
|
|
1859
|
-
{
|
|
1860
|
-
style: {
|
|
1861
|
-
width: "4rem",
|
|
1862
|
-
height: "4rem",
|
|
1863
|
-
borderRadius: "50%",
|
|
1864
|
-
backgroundColor: "#D1FAE5",
|
|
1865
|
-
display: "flex",
|
|
1866
|
-
alignItems: "center",
|
|
1867
|
-
justifyContent: "center"
|
|
1868
|
-
},
|
|
1869
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1870
|
-
"svg",
|
|
1871
|
-
{
|
|
1872
|
-
style: { width: "2rem", height: "2rem", color: "#059669" },
|
|
1873
|
-
fill: "none",
|
|
1874
|
-
strokeLinecap: "round",
|
|
1875
|
-
strokeLinejoin: "round",
|
|
1876
|
-
strokeWidth: "2",
|
|
1877
|
-
viewBox: "0 0 24 24",
|
|
1878
|
-
stroke: "currentColor",
|
|
1879
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 13l4 4L19 7" })
|
|
1880
|
-
}
|
|
1881
|
-
)
|
|
1882
|
-
}
|
|
1883
|
-
),
|
|
1884
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title", style: { textAlign: "center" }, children: successTitle }),
|
|
1885
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle", style: { textAlign: "center" }, children: successMessage })
|
|
1886
|
-
]
|
|
1887
|
-
}
|
|
1888
|
-
)
|
|
1889
|
-
}
|
|
1890
|
-
) });
|
|
1771
|
+
) }),
|
|
1772
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title if-verifyStatus-textCenter", children: successTitle }),
|
|
1773
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-authHeader-subtitle if-verifyStatus-textCenter", children: successMessage })
|
|
1774
|
+
] }) }) });
|
|
1891
1775
|
}
|
|
1892
1776
|
function VerifyEmail({ token, onSuccess, onError, ...uiProps }) {
|
|
1893
1777
|
const { verifyEmail } = useInsforge();
|
|
@@ -1988,93 +1872,43 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
|
|
|
1988
1872
|
}
|
|
1989
1873
|
const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
|
|
1990
1874
|
const buttonClassName = mode === "detailed" ? "if-userButton if-userButton-detailed" : "if-userButton";
|
|
1991
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
{
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
"
|
|
2011
|
-
"
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
alignItems: "flex-start",
|
|
2029
|
-
gap: "0.125rem"
|
|
2030
|
-
},
|
|
2031
|
-
children: [
|
|
2032
|
-
user.name && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2033
|
-
"div",
|
|
2034
|
-
{
|
|
2035
|
-
style: {
|
|
2036
|
-
fontSize: "0.875rem",
|
|
2037
|
-
fontWeight: 600,
|
|
2038
|
-
color: "#1f1f1f",
|
|
2039
|
-
lineHeight: "1.25rem",
|
|
2040
|
-
textAlign: "left"
|
|
2041
|
-
},
|
|
2042
|
-
children: user.name
|
|
2043
|
-
}
|
|
2044
|
-
),
|
|
2045
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2046
|
-
"div",
|
|
2047
|
-
{
|
|
2048
|
-
style: {
|
|
2049
|
-
fontSize: "0.75rem",
|
|
2050
|
-
color: "#828282",
|
|
2051
|
-
lineHeight: "1rem",
|
|
2052
|
-
textAlign: "left"
|
|
2053
|
-
},
|
|
2054
|
-
children: user.email
|
|
2055
|
-
}
|
|
2056
|
-
)
|
|
2057
|
-
]
|
|
2058
|
-
}
|
|
2059
|
-
)
|
|
2060
|
-
]
|
|
2061
|
-
}
|
|
2062
|
-
),
|
|
2063
|
-
isOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-userButton-menu", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2064
|
-
"button",
|
|
2065
|
-
{
|
|
2066
|
-
onClick: handleSignOut,
|
|
2067
|
-
className: "if-userButton-menuItem",
|
|
2068
|
-
style: { color: "#DC2626" },
|
|
2069
|
-
children: [
|
|
2070
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { style: { width: "1.25rem", height: "1.25rem" } }),
|
|
2071
|
-
"Sign out"
|
|
2072
|
-
]
|
|
2073
|
-
}
|
|
2074
|
-
) })
|
|
2075
|
-
]
|
|
2076
|
-
}
|
|
2077
|
-
);
|
|
1875
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-userButton-container if-internal-ub3k8p", ref: dropdownRef, children: [
|
|
1876
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1877
|
+
"button",
|
|
1878
|
+
{
|
|
1879
|
+
className: buttonClassName,
|
|
1880
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1881
|
+
"aria-expanded": isOpen,
|
|
1882
|
+
"aria-haspopup": "true",
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-userButton-avatar", children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1885
|
+
"img",
|
|
1886
|
+
{
|
|
1887
|
+
src: user.avatarUrl,
|
|
1888
|
+
alt: user.email,
|
|
1889
|
+
onError: () => setImageError(true),
|
|
1890
|
+
className: "if-userButton-avatarImage"
|
|
1891
|
+
}
|
|
1892
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-userButton-avatarInitials", children: initials }) }),
|
|
1893
|
+
mode === "detailed" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-userButton-info", children: [
|
|
1894
|
+
user.name && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-userButton-name", children: user.name }),
|
|
1895
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-userButton-email", children: user.email })
|
|
1896
|
+
] })
|
|
1897
|
+
]
|
|
1898
|
+
}
|
|
1899
|
+
),
|
|
1900
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-userButton-menu", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1901
|
+
"button",
|
|
1902
|
+
{
|
|
1903
|
+
onClick: handleSignOut,
|
|
1904
|
+
className: "if-userButton-menuItem if-userButton-menuItem-signout",
|
|
1905
|
+
children: [
|
|
1906
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "if-userButton-menuItem-icon" }),
|
|
1907
|
+
"Sign out"
|
|
1908
|
+
]
|
|
1909
|
+
}
|
|
1910
|
+
) })
|
|
1911
|
+
] });
|
|
2078
1912
|
}
|
|
2079
1913
|
function Protect({
|
|
2080
1914
|
children,
|
|
@@ -2132,94 +1966,6 @@ function SignedOut({ children }) {
|
|
|
2132
1966
|
}
|
|
2133
1967
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
2134
1968
|
}
|
|
2135
|
-
function InsforgeCallback({
|
|
2136
|
-
redirectTo = "/",
|
|
2137
|
-
onSuccess,
|
|
2138
|
-
onError,
|
|
2139
|
-
loadingComponent,
|
|
2140
|
-
onRedirect
|
|
2141
|
-
}) {
|
|
2142
|
-
const isProcessingRef = react.useRef(false);
|
|
2143
|
-
const { isLoaded, isSignedIn } = useInsforge();
|
|
2144
|
-
react.useEffect(() => {
|
|
2145
|
-
if (!isLoaded) {
|
|
2146
|
-
return;
|
|
2147
|
-
}
|
|
2148
|
-
if (isProcessingRef.current) {
|
|
2149
|
-
return;
|
|
2150
|
-
}
|
|
2151
|
-
isProcessingRef.current = true;
|
|
2152
|
-
const processCallback = () => {
|
|
2153
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
2154
|
-
const error = searchParams.get("error");
|
|
2155
|
-
if (error) {
|
|
2156
|
-
if (onError) {
|
|
2157
|
-
onError(error);
|
|
2158
|
-
} else {
|
|
2159
|
-
const errorUrl = "/?error=" + encodeURIComponent(error);
|
|
2160
|
-
if (onRedirect) {
|
|
2161
|
-
onRedirect(errorUrl);
|
|
2162
|
-
} else {
|
|
2163
|
-
window.location.href = errorUrl;
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
return;
|
|
2167
|
-
}
|
|
2168
|
-
if (!isSignedIn) {
|
|
2169
|
-
const errorMsg = "authentication_failed";
|
|
2170
|
-
if (onError) {
|
|
2171
|
-
onError(errorMsg);
|
|
2172
|
-
} else {
|
|
2173
|
-
const errorUrl = "/?error=" + encodeURIComponent(errorMsg);
|
|
2174
|
-
if (onRedirect) {
|
|
2175
|
-
onRedirect(errorUrl);
|
|
2176
|
-
} else {
|
|
2177
|
-
window.location.href = errorUrl;
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
return;
|
|
2181
|
-
}
|
|
2182
|
-
window.history.replaceState({}, "", window.location.pathname);
|
|
2183
|
-
if (onSuccess) {
|
|
2184
|
-
onSuccess();
|
|
2185
|
-
}
|
|
2186
|
-
if (onRedirect) {
|
|
2187
|
-
onRedirect(redirectTo);
|
|
2188
|
-
} else {
|
|
2189
|
-
window.location.href = redirectTo;
|
|
2190
|
-
}
|
|
2191
|
-
};
|
|
2192
|
-
processCallback();
|
|
2193
|
-
}, [isLoaded, isSignedIn, redirectTo, onSuccess, onError, onRedirect]);
|
|
2194
|
-
const defaultLoading = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2195
|
-
"div",
|
|
2196
|
-
{
|
|
2197
|
-
style: {
|
|
2198
|
-
display: "flex",
|
|
2199
|
-
alignItems: "center",
|
|
2200
|
-
justifyContent: "center",
|
|
2201
|
-
minHeight: "100vh"
|
|
2202
|
-
},
|
|
2203
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center" }, children: [
|
|
2204
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "if-authHeader-title", style: { marginBottom: "1rem" }, children: "Completing authentication..." }),
|
|
2205
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2206
|
-
"div",
|
|
2207
|
-
{
|
|
2208
|
-
className: "if-submitButton-spinner",
|
|
2209
|
-
style: {
|
|
2210
|
-
borderRadius: "50%",
|
|
2211
|
-
height: "3rem",
|
|
2212
|
-
width: "3rem",
|
|
2213
|
-
borderBottom: "2px solid #2563EB",
|
|
2214
|
-
margin: "0 auto"
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
)
|
|
2218
|
-
] })
|
|
2219
|
-
}
|
|
2220
|
-
);
|
|
2221
|
-
return loadingComponent || defaultLoading;
|
|
2222
|
-
}
|
|
2223
1969
|
|
|
2224
1970
|
exports.AuthBranding = AuthBranding;
|
|
2225
1971
|
exports.AuthContainer = AuthContainer;
|
|
@@ -2233,11 +1979,11 @@ exports.AuthOAuthButton = AuthOAuthButton;
|
|
|
2233
1979
|
exports.AuthOAuthProviders = AuthOAuthProviders;
|
|
2234
1980
|
exports.AuthPasswordField = AuthPasswordField;
|
|
2235
1981
|
exports.AuthPasswordStrengthIndicator = AuthPasswordStrengthIndicator;
|
|
1982
|
+
exports.AuthResetPasswordVerificationStep = AuthResetPasswordVerificationStep;
|
|
2236
1983
|
exports.AuthSubmitButton = AuthSubmitButton;
|
|
2237
1984
|
exports.AuthVerificationCodeInput = AuthVerificationCodeInput;
|
|
2238
1985
|
exports.ForgotPassword = ForgotPassword;
|
|
2239
1986
|
exports.ForgotPasswordForm = ForgotPasswordForm;
|
|
2240
|
-
exports.InsforgeCallback = InsforgeCallback;
|
|
2241
1987
|
exports.Protect = Protect;
|
|
2242
1988
|
exports.ResetPassword = ResetPassword;
|
|
2243
1989
|
exports.ResetPasswordForm = ResetPasswordForm;
|