@erikey/react 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +19 -19
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +16 -0
- package/dist/styles.css.map +1 -1
- package/dist/ui/index.mjs +194 -104
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +13 -1
- package/src/__tests__/setup.ts +124 -0
- package/src/__tests__/ui/auth-flow.test.tsx +408 -0
- package/src/__tests__/ui/forms/email-otp-form.test.tsx +190 -0
- package/src/__tests__/ui/forms/sign-in-form.test.tsx +273 -0
- package/src/__tests__/ui/ssr.test.tsx +102 -0
- package/src/__tests__/utils/mock-auth-client.ts +298 -0
- package/src/__tests__/utils/render-with-provider.tsx +129 -0
- package/src/ui/components/auth/auth-flow.tsx +93 -50
- package/src/ui/components/auth/auth-form.tsx +3 -0
- package/src/ui/components/auth/auth-view.tsx +3 -0
- package/src/ui/components/auth/forms/email-otp-form.tsx +58 -14
- package/src/ui/components/auth/forms/email-verification-form.tsx +5 -1
- package/src/ui/components/auth/forms/magic-link-form.tsx +19 -6
- package/src/ui/components/auth/forms/sign-up-form.tsx +13 -3
- package/src/ui/components/auth/forms/two-factor-form.tsx +9 -2
- package/src/ui/components/ui/form.tsx +6 -4
- package/src/ui/hooks/use-auth-data.ts +9 -3
- package/src/ui/hooks/use-authenticate.ts +2 -0
- package/src/ui/hooks/use-captcha.tsx +5 -5
- package/src/ui/lib/auth-ui-provider.tsx +8 -2
- package/src/ui/lib/image-utils.ts +7 -0
package/dist/ui/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
1
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
2
2
|
import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
|
|
3
3
|
|
|
4
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
4
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/shared/src/utils.js
|
|
5
5
|
var toKebabCase = (string2) => string2.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
6
6
|
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
7
7
|
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
8
8
|
}).join(" ").trim();
|
|
9
9
|
|
|
10
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
10
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/Icon.js
|
|
11
11
|
import { forwardRef, createElement } from "react";
|
|
12
12
|
|
|
13
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
13
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
14
14
|
var defaultAttributes = {
|
|
15
15
|
xmlns: "http://www.w3.org/2000/svg",
|
|
16
16
|
width: 24,
|
|
@@ -23,7 +23,7 @@ var defaultAttributes = {
|
|
|
23
23
|
strokeLinejoin: "round"
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
26
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/Icon.js
|
|
27
27
|
var Icon = forwardRef(
|
|
28
28
|
({
|
|
29
29
|
color = "currentColor",
|
|
@@ -55,7 +55,7 @@ var Icon = forwardRef(
|
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
58
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
59
59
|
var createLucideIcon = (iconName, iconNode) => {
|
|
60
60
|
const Component = forwardRef2(
|
|
61
61
|
({ className, ...props }, ref) => createElement2(Icon, {
|
|
@@ -69,23 +69,23 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
|
69
69
|
return Component;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
72
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/arrow-left.js
|
|
73
73
|
var ArrowLeft = createLucideIcon("ArrowLeft", [
|
|
74
74
|
["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
|
|
75
75
|
["path", { d: "M19 12H5", key: "x3x0zl" }]
|
|
76
76
|
]);
|
|
77
77
|
|
|
78
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
78
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/check.js
|
|
79
79
|
var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
|
|
80
80
|
|
|
81
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
81
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/cloud-upload.js
|
|
82
82
|
var CloudUpload = createLucideIcon("CloudUpload", [
|
|
83
83
|
["path", { d: "M12 13v8", key: "1l5pq0" }],
|
|
84
84
|
["path", { d: "M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242", key: "1pljnt" }],
|
|
85
85
|
["path", { d: "m8 17 4-4 4 4", key: "1quai1" }]
|
|
86
86
|
]);
|
|
87
87
|
|
|
88
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
88
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/eye-off.js
|
|
89
89
|
var EyeOff = createLucideIcon("EyeOff", [
|
|
90
90
|
[
|
|
91
91
|
"path",
|
|
@@ -105,7 +105,7 @@ var EyeOff = createLucideIcon("EyeOff", [
|
|
|
105
105
|
["path", { d: "m2 2 20 20", key: "1ooewy" }]
|
|
106
106
|
]);
|
|
107
107
|
|
|
108
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
108
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/eye.js
|
|
109
109
|
var Eye = createLucideIcon("Eye", [
|
|
110
110
|
[
|
|
111
111
|
"path",
|
|
@@ -117,7 +117,7 @@ var Eye = createLucideIcon("Eye", [
|
|
|
117
117
|
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
118
118
|
]);
|
|
119
119
|
|
|
120
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
120
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/fingerprint.js
|
|
121
121
|
var Fingerprint = createLucideIcon("Fingerprint", [
|
|
122
122
|
["path", { d: "M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4", key: "1nerag" }],
|
|
123
123
|
["path", { d: "M14 13.12c0 2.38 0 6.38-1 8.88", key: "o46ks0" }],
|
|
@@ -130,27 +130,27 @@ var Fingerprint = createLucideIcon("Fingerprint", [
|
|
|
130
130
|
["path", { d: "M9 6.8a6 6 0 0 1 9 5.2v2", key: "1fr1j5" }]
|
|
131
131
|
]);
|
|
132
132
|
|
|
133
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
133
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/loader-circle.js
|
|
134
134
|
var LoaderCircle = createLucideIcon("LoaderCircle", [
|
|
135
135
|
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
136
136
|
]);
|
|
137
137
|
|
|
138
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
138
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/lock.js
|
|
139
139
|
var Lock = createLucideIcon("Lock", [
|
|
140
140
|
["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
|
|
141
141
|
["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
|
|
142
142
|
]);
|
|
143
143
|
|
|
144
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
144
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/mail.js
|
|
145
145
|
var Mail = createLucideIcon("Mail", [
|
|
146
146
|
["rect", { width: "20", height: "16", x: "2", y: "4", rx: "2", key: "18n3k1" }],
|
|
147
147
|
["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7", key: "1ocrg3" }]
|
|
148
148
|
]);
|
|
149
149
|
|
|
150
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
150
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/minus.js
|
|
151
151
|
var Minus = createLucideIcon("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
|
|
152
152
|
|
|
153
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
153
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/qr-code.js
|
|
154
154
|
var QrCode = createLucideIcon("QrCode", [
|
|
155
155
|
["rect", { width: "5", height: "5", x: "3", y: "3", rx: "1", key: "1tu5fj" }],
|
|
156
156
|
["rect", { width: "5", height: "5", x: "16", y: "3", rx: "1", key: "1v8r4q" }],
|
|
@@ -166,7 +166,7 @@ var QrCode = createLucideIcon("QrCode", [
|
|
|
166
166
|
["path", { d: "M12 21v-1", key: "1880an" }]
|
|
167
167
|
]);
|
|
168
168
|
|
|
169
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
169
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/send.js
|
|
170
170
|
var Send = createLucideIcon("Send", [
|
|
171
171
|
[
|
|
172
172
|
"path",
|
|
@@ -178,7 +178,7 @@ var Send = createLucideIcon("Send", [
|
|
|
178
178
|
["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
|
|
179
179
|
]);
|
|
180
180
|
|
|
181
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
181
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/trash-2.js
|
|
182
182
|
var Trash2 = createLucideIcon("Trash2", [
|
|
183
183
|
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
184
184
|
["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
|
|
@@ -187,13 +187,13 @@ var Trash2 = createLucideIcon("Trash2", [
|
|
|
187
187
|
["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
|
|
188
188
|
]);
|
|
189
189
|
|
|
190
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
190
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/user-round.js
|
|
191
191
|
var UserRound = createLucideIcon("UserRound", [
|
|
192
192
|
["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
|
|
193
193
|
["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
|
|
194
194
|
]);
|
|
195
195
|
|
|
196
|
-
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@
|
|
196
|
+
// ../../../node_modules/.pnpm/lucide-react@0.462.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/wallet.js
|
|
197
197
|
var Wallet = createLucideIcon("Wallet", [
|
|
198
198
|
[
|
|
199
199
|
"path",
|
|
@@ -6890,6 +6890,8 @@ function useAuthData({
|
|
|
6890
6890
|
const initialized = useRef(false);
|
|
6891
6891
|
const previousUserId = useRef(void 0);
|
|
6892
6892
|
const [error, setError] = useState3(null);
|
|
6893
|
+
const cacheEntryRef = useRef(cacheEntry);
|
|
6894
|
+
cacheEntryRef.current = cacheEntry;
|
|
6893
6895
|
const refetch = useCallback(async () => {
|
|
6894
6896
|
const existingRequest = authDataCache.getInFlightRequest(stableCacheKey);
|
|
6895
6897
|
if (existingRequest) {
|
|
@@ -6905,7 +6907,7 @@ function useAuthData({
|
|
|
6905
6907
|
}
|
|
6906
6908
|
return;
|
|
6907
6909
|
}
|
|
6908
|
-
if (
|
|
6910
|
+
if (cacheEntryRef.current?.data !== void 0) {
|
|
6909
6911
|
authDataCache.setRefetching(stableCacheKey, true);
|
|
6910
6912
|
}
|
|
6911
6913
|
const fetchPromise = queryFnRef.current();
|
|
@@ -6941,7 +6943,7 @@ function useAuthData({
|
|
|
6941
6943
|
authDataCache.setRefetching(stableCacheKey, false);
|
|
6942
6944
|
authDataCache.removeInFlightRequest(stableCacheKey);
|
|
6943
6945
|
}
|
|
6944
|
-
}, [stableCacheKey, toast, localization, localizeErrors
|
|
6946
|
+
}, [stableCacheKey, toast, localization, localizeErrors]);
|
|
6945
6947
|
useEffect4(() => {
|
|
6946
6948
|
const currentUserId = sessionData?.user?.id;
|
|
6947
6949
|
if (!sessionData) {
|
|
@@ -7814,10 +7816,14 @@ var organizationViewPaths = {
|
|
|
7814
7816
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
7815
7817
|
var DefaultLink = ({ href, className, children }) => /* @__PURE__ */ jsx2("a", { className, href, children });
|
|
7816
7818
|
var defaultNavigate = (href) => {
|
|
7817
|
-
window
|
|
7819
|
+
if (typeof window !== "undefined") {
|
|
7820
|
+
window.location.href = href;
|
|
7821
|
+
}
|
|
7818
7822
|
};
|
|
7819
7823
|
var defaultReplace = (href) => {
|
|
7820
|
-
window
|
|
7824
|
+
if (typeof window !== "undefined") {
|
|
7825
|
+
window.location.replace(href);
|
|
7826
|
+
}
|
|
7821
7827
|
};
|
|
7822
7828
|
var defaultToast = () => {
|
|
7823
7829
|
};
|
|
@@ -8216,6 +8222,7 @@ function AuthCallback({ redirectTo }) {
|
|
|
8216
8222
|
// src/ui/components/auth/auth-flow.tsx
|
|
8217
8223
|
import {
|
|
8218
8224
|
useCallback as useCallback9,
|
|
8225
|
+
useContext as useContext30,
|
|
8219
8226
|
useMemo as useMemo5,
|
|
8220
8227
|
useState as useState16
|
|
8221
8228
|
} from "react";
|
|
@@ -9018,7 +9025,7 @@ function Separator({
|
|
|
9018
9025
|
// src/ui/components/auth/auth-form.tsx
|
|
9019
9026
|
import { useContext as useContext22, useEffect as useEffect20 } from "react";
|
|
9020
9027
|
|
|
9021
|
-
// ../../../node_modules/.pnpm/react-hook-form@7.66.1_react@
|
|
9028
|
+
// ../../../node_modules/.pnpm/react-hook-form@7.66.1_react@18.3.1/node_modules/react-hook-form/dist/index.esm.mjs
|
|
9022
9029
|
import React2 from "react";
|
|
9023
9030
|
var isCheckBoxInput = (element) => element.type === "checkbox";
|
|
9024
9031
|
var isDateObject = (value) => value instanceof Date;
|
|
@@ -10817,7 +10824,7 @@ function useForm(props = {}) {
|
|
|
10817
10824
|
return _formControl.current;
|
|
10818
10825
|
}
|
|
10819
10826
|
|
|
10820
|
-
// ../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.66.1_react@
|
|
10827
|
+
// ../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.66.1_react@18.3.1_/node_modules/@hookform/resolvers/dist/resolvers.mjs
|
|
10821
10828
|
var r2 = (t2, r3, o2) => {
|
|
10822
10829
|
if (t2 && "reportValidity" in t2) {
|
|
10823
10830
|
const s3 = get(o2, r3);
|
|
@@ -11025,7 +11032,7 @@ var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
|
11025
11032
|
var $output = Symbol("ZodOutput");
|
|
11026
11033
|
var $input = Symbol("ZodInput");
|
|
11027
11034
|
|
|
11028
|
-
// ../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.66.1_react@
|
|
11035
|
+
// ../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.66.1_react@18.3.1_/node_modules/@hookform/resolvers/zod/dist/zod.mjs
|
|
11029
11036
|
function t(r3, e) {
|
|
11030
11037
|
try {
|
|
11031
11038
|
var o2 = r3();
|
|
@@ -11145,27 +11152,27 @@ function useCaptcha({
|
|
|
11145
11152
|
}
|
|
11146
11153
|
case "google-recaptcha-v2-checkbox": {
|
|
11147
11154
|
const recaptchaRef = captchaRef;
|
|
11148
|
-
response = recaptchaRef.current
|
|
11155
|
+
response = recaptchaRef.current?.getValue?.();
|
|
11149
11156
|
break;
|
|
11150
11157
|
}
|
|
11151
11158
|
case "google-recaptcha-v2-invisible": {
|
|
11152
11159
|
const recaptchaRef = captchaRef;
|
|
11153
|
-
response = await recaptchaRef.current
|
|
11160
|
+
response = await recaptchaRef.current?.executeAsync?.();
|
|
11154
11161
|
break;
|
|
11155
11162
|
}
|
|
11156
11163
|
case "cloudflare-turnstile": {
|
|
11157
11164
|
const turnstileRef = captchaRef;
|
|
11158
|
-
response = turnstileRef.current
|
|
11165
|
+
response = turnstileRef.current?.getResponse?.();
|
|
11159
11166
|
break;
|
|
11160
11167
|
}
|
|
11161
11168
|
case "hcaptcha": {
|
|
11162
11169
|
const hcaptchaRef = captchaRef;
|
|
11163
|
-
response = hcaptchaRef.current
|
|
11170
|
+
response = hcaptchaRef.current?.getResponse?.();
|
|
11164
11171
|
break;
|
|
11165
11172
|
}
|
|
11166
11173
|
case "captchafox": {
|
|
11167
11174
|
const captchafoxRef = captchaRef;
|
|
11168
|
-
response = captchafoxRef.current
|
|
11175
|
+
response = captchafoxRef.current?.getResponse?.();
|
|
11169
11176
|
break;
|
|
11170
11177
|
}
|
|
11171
11178
|
}
|
|
@@ -11413,12 +11420,12 @@ var FormField = ({
|
|
|
11413
11420
|
var useFormField = () => {
|
|
11414
11421
|
const fieldContext = React3.useContext(FormFieldContext);
|
|
11415
11422
|
const itemContext = React3.useContext(FormItemContext);
|
|
11423
|
+
if (!fieldContext?.name) {
|
|
11424
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
11425
|
+
}
|
|
11416
11426
|
const { getFieldState } = useFormContext();
|
|
11417
11427
|
const formState = useFormState({ name: fieldContext.name });
|
|
11418
11428
|
const fieldState = getFieldState(fieldContext.name, formState);
|
|
11419
|
-
if (!fieldContext) {
|
|
11420
|
-
throw new Error("useFormField should be used within <FormField>");
|
|
11421
|
-
}
|
|
11422
11429
|
const { id } = itemContext;
|
|
11423
11430
|
return {
|
|
11424
11431
|
id,
|
|
@@ -11512,7 +11519,7 @@ function Input({ className, type, ...props }) {
|
|
|
11512
11519
|
// src/ui/components/ui/input-otp.tsx
|
|
11513
11520
|
import * as React4 from "react";
|
|
11514
11521
|
|
|
11515
|
-
// ../../../node_modules/.pnpm/input-otp@1.4.2_react-dom@
|
|
11522
|
+
// ../../../node_modules/.pnpm/input-otp@1.4.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/input-otp/dist/index.mjs
|
|
11516
11523
|
import * as n2 from "react";
|
|
11517
11524
|
import * as U from "react";
|
|
11518
11525
|
import * as S from "react";
|
|
@@ -11849,7 +11856,8 @@ function EmailForm({
|
|
|
11849
11856
|
authClient,
|
|
11850
11857
|
localization: contextLocalization,
|
|
11851
11858
|
toast,
|
|
11852
|
-
localizeErrors
|
|
11859
|
+
localizeErrors,
|
|
11860
|
+
onAuthEvent
|
|
11853
11861
|
} = useContext11(AuthUIContext);
|
|
11854
11862
|
localization = { ...contextLocalization, ...localization };
|
|
11855
11863
|
const formSchema = objectType({
|
|
@@ -11868,6 +11876,7 @@ function EmailForm({
|
|
|
11868
11876
|
setIsSubmitting?.(form.formState.isSubmitting);
|
|
11869
11877
|
}, [form.formState.isSubmitting, setIsSubmitting]);
|
|
11870
11878
|
async function sendEmailOTP({ email: email2 }) {
|
|
11879
|
+
onAuthEvent?.({ type: "SIGN_IN_START", email: email2 });
|
|
11871
11880
|
const fetchOptions = {
|
|
11872
11881
|
throw: true,
|
|
11873
11882
|
headers: await getCaptchaHeaders("/email-otp/send-verification-otp")
|
|
@@ -11884,13 +11893,19 @@ function EmailForm({
|
|
|
11884
11893
|
});
|
|
11885
11894
|
setEmail(email2);
|
|
11886
11895
|
} catch (error) {
|
|
11896
|
+
const errorMessage = getLocalizedError({
|
|
11897
|
+
error,
|
|
11898
|
+
localization,
|
|
11899
|
+
localizeErrors
|
|
11900
|
+
});
|
|
11901
|
+
const errorCode = error?.error?.code;
|
|
11902
|
+
onAuthEvent?.({
|
|
11903
|
+
type: "SIGN_IN_ERROR",
|
|
11904
|
+
error: { message: errorMessage, code: errorCode }
|
|
11905
|
+
});
|
|
11887
11906
|
toast({
|
|
11888
11907
|
variant: "error",
|
|
11889
|
-
message:
|
|
11890
|
-
error,
|
|
11891
|
-
localization,
|
|
11892
|
-
localizeErrors
|
|
11893
|
-
})
|
|
11908
|
+
message: errorMessage
|
|
11894
11909
|
});
|
|
11895
11910
|
}
|
|
11896
11911
|
}
|
|
@@ -11961,7 +11976,8 @@ function OTPForm({
|
|
|
11961
11976
|
authClient,
|
|
11962
11977
|
localization: contextLocalization,
|
|
11963
11978
|
toast,
|
|
11964
|
-
localizeErrors
|
|
11979
|
+
localizeErrors,
|
|
11980
|
+
onAuthEvent
|
|
11965
11981
|
} = useContext11(AuthUIContext);
|
|
11966
11982
|
localization = { ...contextLocalization, ...localization };
|
|
11967
11983
|
const { onSuccess, isPending: transitionPending } = useOnSuccessTransition({
|
|
@@ -11986,20 +12002,33 @@ function OTPForm({
|
|
|
11986
12002
|
}, [form.formState.isSubmitting, transitionPending, setIsSubmitting]);
|
|
11987
12003
|
async function verifyCode({ code }) {
|
|
11988
12004
|
try {
|
|
11989
|
-
await authClient.signIn.emailOtp({
|
|
12005
|
+
const data = await authClient.signIn.emailOtp({
|
|
11990
12006
|
email: email2,
|
|
11991
12007
|
otp: code,
|
|
11992
12008
|
fetchOptions: { throw: true }
|
|
11993
12009
|
});
|
|
12010
|
+
const user = data.user;
|
|
12011
|
+
const session = {
|
|
12012
|
+
token: data.token,
|
|
12013
|
+
user
|
|
12014
|
+
};
|
|
12015
|
+
onAuthEvent?.({ type: "SIGN_IN_SUCCESS", user, session });
|
|
12016
|
+
onAuthEvent?.({ type: "AUTH_SUCCESS", user, session });
|
|
11994
12017
|
await onSuccess();
|
|
11995
12018
|
} catch (error) {
|
|
12019
|
+
const errorMessage = getLocalizedError({
|
|
12020
|
+
error,
|
|
12021
|
+
localization,
|
|
12022
|
+
localizeErrors
|
|
12023
|
+
});
|
|
12024
|
+
const errorCode = error?.error?.code;
|
|
12025
|
+
onAuthEvent?.({
|
|
12026
|
+
type: "SIGN_IN_ERROR",
|
|
12027
|
+
error: { message: errorMessage, code: errorCode }
|
|
12028
|
+
});
|
|
11996
12029
|
toast({
|
|
11997
12030
|
variant: "error",
|
|
11998
|
-
message:
|
|
11999
|
-
error,
|
|
12000
|
-
localization,
|
|
12001
|
-
localizeErrors
|
|
12002
|
-
})
|
|
12031
|
+
message: errorMessage
|
|
12003
12032
|
});
|
|
12004
12033
|
form.reset();
|
|
12005
12034
|
}
|
|
@@ -12025,7 +12054,10 @@ function OTPForm({
|
|
|
12025
12054
|
onChange: (value) => {
|
|
12026
12055
|
field.onChange(value);
|
|
12027
12056
|
if (value.length === 6) {
|
|
12028
|
-
form.handleSubmit(verifyCode)()
|
|
12057
|
+
form.handleSubmit(verifyCode)().catch(
|
|
12058
|
+
() => {
|
|
12059
|
+
}
|
|
12060
|
+
);
|
|
12029
12061
|
}
|
|
12030
12062
|
},
|
|
12031
12063
|
containerClassName: classNames?.otpInputContainer,
|
|
@@ -12300,7 +12332,10 @@ function EmailVerificationForm({
|
|
|
12300
12332
|
onChange: (value) => {
|
|
12301
12333
|
field.onChange(value);
|
|
12302
12334
|
if (value.length === 6) {
|
|
12303
|
-
form.handleSubmit(verifyCode)()
|
|
12335
|
+
form.handleSubmit(verifyCode)().catch(
|
|
12336
|
+
() => {
|
|
12337
|
+
}
|
|
12338
|
+
);
|
|
12304
12339
|
}
|
|
12305
12340
|
},
|
|
12306
12341
|
containerClassName: classNames?.otpInputContainer,
|
|
@@ -12518,7 +12553,8 @@ function MagicLinkForm({
|
|
|
12518
12553
|
redirectTo: contextRedirectTo,
|
|
12519
12554
|
viewPaths,
|
|
12520
12555
|
toast,
|
|
12521
|
-
localizeErrors
|
|
12556
|
+
localizeErrors,
|
|
12557
|
+
onAuthEvent
|
|
12522
12558
|
} = useContext14(AuthUIContext);
|
|
12523
12559
|
localization = { ...contextLocalization, ...localization };
|
|
12524
12560
|
const getRedirectTo = useCallback5(
|
|
@@ -12552,6 +12588,7 @@ function MagicLinkForm({
|
|
|
12552
12588
|
setIsSubmitting?.(form.formState.isSubmitting);
|
|
12553
12589
|
}, [form.formState.isSubmitting, setIsSubmitting]);
|
|
12554
12590
|
async function sendMagicLink({ email: email2 }) {
|
|
12591
|
+
onAuthEvent?.({ type: "SIGN_IN_START", email: email2 });
|
|
12555
12592
|
try {
|
|
12556
12593
|
const fetchOptions = {
|
|
12557
12594
|
throw: true,
|
|
@@ -12568,13 +12605,19 @@ function MagicLinkForm({
|
|
|
12568
12605
|
});
|
|
12569
12606
|
form.reset();
|
|
12570
12607
|
} catch (error) {
|
|
12608
|
+
const errorMessage = getLocalizedError({
|
|
12609
|
+
error,
|
|
12610
|
+
localization,
|
|
12611
|
+
localizeErrors
|
|
12612
|
+
});
|
|
12613
|
+
const errorCode = error?.error?.code;
|
|
12614
|
+
onAuthEvent?.({
|
|
12615
|
+
type: "SIGN_IN_ERROR",
|
|
12616
|
+
error: { message: errorMessage, code: errorCode }
|
|
12617
|
+
});
|
|
12571
12618
|
toast({
|
|
12572
12619
|
variant: "error",
|
|
12573
|
-
message:
|
|
12574
|
-
error,
|
|
12575
|
-
localization,
|
|
12576
|
-
localizeErrors
|
|
12577
|
-
})
|
|
12620
|
+
message: errorMessage
|
|
12578
12621
|
});
|
|
12579
12622
|
resetCaptcha();
|
|
12580
12623
|
}
|
|
@@ -13247,6 +13290,11 @@ import { useCallback as useCallback6, useContext as useContext19, useEffect as u
|
|
|
13247
13290
|
|
|
13248
13291
|
// src/ui/lib/image-utils.ts
|
|
13249
13292
|
async function resizeAndCropImage(file, name, size, extension) {
|
|
13293
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
13294
|
+
throw new Error(
|
|
13295
|
+
"resizeAndCropImage requires a browser environment (window and document must be defined)"
|
|
13296
|
+
);
|
|
13297
|
+
}
|
|
13250
13298
|
const image = await loadImage(file);
|
|
13251
13299
|
const canvas = document.createElement("canvas");
|
|
13252
13300
|
canvas.width = canvas.height = size;
|
|
@@ -13593,10 +13641,17 @@ function SignUpForm({
|
|
|
13593
13641
|
resolver: a(formSchema),
|
|
13594
13642
|
defaultValues
|
|
13595
13643
|
});
|
|
13596
|
-
isSubmitting = isSubmitting || form.formState.isSubmitting || transitionPending;
|
|
13644
|
+
isSubmitting = isSubmitting || form.formState.isSubmitting || transitionPending || uploadingAvatar;
|
|
13597
13645
|
useEffect17(() => {
|
|
13598
|
-
setIsSubmitting?.(
|
|
13599
|
-
|
|
13646
|
+
setIsSubmitting?.(
|
|
13647
|
+
form.formState.isSubmitting || transitionPending || uploadingAvatar
|
|
13648
|
+
);
|
|
13649
|
+
}, [
|
|
13650
|
+
form.formState.isSubmitting,
|
|
13651
|
+
transitionPending,
|
|
13652
|
+
uploadingAvatar,
|
|
13653
|
+
setIsSubmitting
|
|
13654
|
+
]);
|
|
13600
13655
|
const handleAvatarChange = async (file) => {
|
|
13601
13656
|
if (!avatar) return;
|
|
13602
13657
|
setUploadingAvatar(true);
|
|
@@ -14103,6 +14158,7 @@ function TwoFactorForm({
|
|
|
14103
14158
|
const initialSendRef = useRef8(false);
|
|
14104
14159
|
const {
|
|
14105
14160
|
authClient,
|
|
14161
|
+
authFlowMode,
|
|
14106
14162
|
basePath,
|
|
14107
14163
|
hooks: { useSession },
|
|
14108
14164
|
localization: contextLocalization,
|
|
@@ -14176,7 +14232,9 @@ function TwoFactorForm({
|
|
|
14176
14232
|
})
|
|
14177
14233
|
});
|
|
14178
14234
|
if (error.error.code === "INVALID_TWO_FACTOR_COOKIE") {
|
|
14179
|
-
|
|
14235
|
+
if (authFlowMode !== "internal") {
|
|
14236
|
+
history.back();
|
|
14237
|
+
}
|
|
14180
14238
|
}
|
|
14181
14239
|
}
|
|
14182
14240
|
initialSendRef.current = false;
|
|
@@ -14282,7 +14340,8 @@ function TwoFactorForm({
|
|
|
14282
14340
|
if (value.length === 6) {
|
|
14283
14341
|
form.handleSubmit(
|
|
14284
14342
|
verifyCode
|
|
14285
|
-
)()
|
|
14343
|
+
)().catch(() => {
|
|
14344
|
+
});
|
|
14286
14345
|
}
|
|
14287
14346
|
},
|
|
14288
14347
|
containerClassName: classNames?.otpInputContainer,
|
|
@@ -14445,6 +14504,7 @@ function AuthForm({
|
|
|
14445
14504
|
const signUpEnabled = !!signUp;
|
|
14446
14505
|
localization = { ...contextLocalization, ...localization };
|
|
14447
14506
|
useEffect20(() => {
|
|
14507
|
+
if (typeof window === "undefined" || !viewPaths) return;
|
|
14448
14508
|
if (pathname && !getViewByPath(viewPaths, pathname)) {
|
|
14449
14509
|
console.error(`Invalid auth view: ${pathname}`);
|
|
14450
14510
|
replace(`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`);
|
|
@@ -15183,6 +15243,7 @@ function AuthView({
|
|
|
15183
15243
|
setIsSubmitting(value);
|
|
15184
15244
|
};
|
|
15185
15245
|
useEffect23(() => {
|
|
15246
|
+
if (typeof window === "undefined") return;
|
|
15186
15247
|
const handlePageHide = () => setIsSubmitting(false);
|
|
15187
15248
|
window.addEventListener("pagehide", handlePageHide);
|
|
15188
15249
|
return () => {
|
|
@@ -15479,37 +15540,62 @@ var flowViewToPathKey = {
|
|
|
15479
15540
|
RECOVER_ACCOUNT: "RECOVER_ACCOUNT"
|
|
15480
15541
|
};
|
|
15481
15542
|
function parsePathToView(path) {
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
15543
|
+
try {
|
|
15544
|
+
const url = new URL(path, "http://localhost");
|
|
15545
|
+
const pathname = url.pathname;
|
|
15546
|
+
const email2 = url.searchParams.get("email") || void 0;
|
|
15547
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
15548
|
+
const lastSegment = segments[segments.length - 1] || "";
|
|
15549
|
+
if (lastSegment === "email-verification" || pathname.includes("/email-verification")) {
|
|
15550
|
+
return { view: "EMAIL_VERIFICATION", email: email2 };
|
|
15551
|
+
}
|
|
15552
|
+
if (lastSegment === "two-factor" || pathname.includes("/two-factor")) {
|
|
15553
|
+
return { view: "TWO_FACTOR", email: email2 };
|
|
15554
|
+
}
|
|
15555
|
+
if (lastSegment === "forgot-password" || pathname.includes("/forgot-password")) {
|
|
15556
|
+
return { view: "FORGOT_PASSWORD", email: email2 };
|
|
15557
|
+
}
|
|
15558
|
+
if (lastSegment === "reset-password" || pathname.includes("/reset-password")) {
|
|
15559
|
+
return { view: "RESET_PASSWORD", email: email2 };
|
|
15560
|
+
}
|
|
15561
|
+
if (lastSegment === "sign-up" || pathname.includes("/sign-up")) {
|
|
15562
|
+
return { view: "SIGN_UP", email: email2 };
|
|
15563
|
+
}
|
|
15564
|
+
if (lastSegment === "magic-link" || pathname.includes("/magic-link")) {
|
|
15565
|
+
return { view: "MAGIC_LINK", email: email2 };
|
|
15566
|
+
}
|
|
15567
|
+
if (lastSegment === "email-otp" || pathname.includes("/email-otp")) {
|
|
15568
|
+
return { view: "EMAIL_OTP", email: email2 };
|
|
15569
|
+
}
|
|
15570
|
+
if (lastSegment === "recover-account" || pathname.includes("/recover-account")) {
|
|
15571
|
+
return { view: "RECOVER_ACCOUNT", email: email2 };
|
|
15572
|
+
}
|
|
15504
15573
|
return { view: "SIGN_IN", email: email2 };
|
|
15574
|
+
} catch {
|
|
15575
|
+
return { view: "SIGN_IN" };
|
|
15505
15576
|
}
|
|
15506
|
-
if (pathname.includes("recover-account")) {
|
|
15507
|
-
return { view: "TWO_FACTOR", email: email2 };
|
|
15508
|
-
}
|
|
15509
|
-
return { view: "SIGN_IN", email: email2 };
|
|
15510
15577
|
}
|
|
15511
15578
|
function isAuthPath(href) {
|
|
15512
|
-
|
|
15579
|
+
const authSegments = [
|
|
15580
|
+
"sign-in",
|
|
15581
|
+
"sign-up",
|
|
15582
|
+
"email-verification",
|
|
15583
|
+
"two-factor",
|
|
15584
|
+
"forgot-password",
|
|
15585
|
+
"reset-password",
|
|
15586
|
+
"magic-link",
|
|
15587
|
+
"email-otp",
|
|
15588
|
+
"recover-account"
|
|
15589
|
+
];
|
|
15590
|
+
try {
|
|
15591
|
+
const url = new URL(href, "http://localhost");
|
|
15592
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
15593
|
+
return segments.some((segment) => authSegments.includes(segment));
|
|
15594
|
+
} catch {
|
|
15595
|
+
return authSegments.some(
|
|
15596
|
+
(authPath) => href.includes(`/${authPath}`) || href.endsWith(authPath) || href === authPath
|
|
15597
|
+
);
|
|
15598
|
+
}
|
|
15513
15599
|
}
|
|
15514
15600
|
var AUTH_FLOW_STATE_KEY = "erikey_auth_flow_state";
|
|
15515
15601
|
function getPersistedState() {
|
|
@@ -15519,7 +15605,8 @@ function getPersistedState() {
|
|
|
15519
15605
|
if (stored) {
|
|
15520
15606
|
return JSON.parse(stored);
|
|
15521
15607
|
}
|
|
15522
|
-
} catch {
|
|
15608
|
+
} catch (error) {
|
|
15609
|
+
console.warn("[AuthFlow] Failed to read persisted state:", error);
|
|
15523
15610
|
}
|
|
15524
15611
|
return null;
|
|
15525
15612
|
}
|
|
@@ -15530,14 +15617,16 @@ function persistState(view, email2) {
|
|
|
15530
15617
|
AUTH_FLOW_STATE_KEY,
|
|
15531
15618
|
JSON.stringify({ view, email: email2 })
|
|
15532
15619
|
);
|
|
15533
|
-
} catch {
|
|
15620
|
+
} catch (error) {
|
|
15621
|
+
console.warn("[AuthFlow] Failed to persist state:", error);
|
|
15534
15622
|
}
|
|
15535
15623
|
}
|
|
15536
15624
|
function clearPersistedState() {
|
|
15537
15625
|
if (typeof window === "undefined") return;
|
|
15538
15626
|
try {
|
|
15539
15627
|
sessionStorage.removeItem(AUTH_FLOW_STATE_KEY);
|
|
15540
|
-
} catch {
|
|
15628
|
+
} catch (error) {
|
|
15629
|
+
console.warn("[AuthFlow] Failed to clear persisted state:", error);
|
|
15541
15630
|
}
|
|
15542
15631
|
}
|
|
15543
15632
|
function AuthFlow({
|
|
@@ -15656,7 +15745,7 @@ function AuthFlow({
|
|
|
15656
15745
|
// Sign-in flow
|
|
15657
15746
|
case "SIGN_IN_REQUIRES_2FA":
|
|
15658
15747
|
setCurrentView("TWO_FACTOR");
|
|
15659
|
-
persistState("TWO_FACTOR");
|
|
15748
|
+
persistState("TWO_FACTOR", event.email);
|
|
15660
15749
|
break;
|
|
15661
15750
|
case "SIGN_IN_REQUIRES_VERIFICATION":
|
|
15662
15751
|
setCurrentView("EMAIL_VERIFICATION");
|
|
@@ -15732,22 +15821,22 @@ function AuthFlow({
|
|
|
15732
15821
|
);
|
|
15733
15822
|
}
|
|
15734
15823
|
function useAuthFlowEvent() {
|
|
15735
|
-
const
|
|
15736
|
-
return
|
|
15824
|
+
const { onAuthEvent } = useContext30(AuthUIContext);
|
|
15825
|
+
return onAuthEvent;
|
|
15737
15826
|
}
|
|
15738
15827
|
|
|
15739
15828
|
// src/ui/components/auth-loading.tsx
|
|
15740
|
-
import { useContext as
|
|
15829
|
+
import { useContext as useContext31 } from "react";
|
|
15741
15830
|
function AuthLoading({ children }) {
|
|
15742
15831
|
const {
|
|
15743
15832
|
hooks: { useSession }
|
|
15744
|
-
} =
|
|
15833
|
+
} = useContext31(AuthUIContext);
|
|
15745
15834
|
const { isPending } = useSession();
|
|
15746
15835
|
return isPending ? children : null;
|
|
15747
15836
|
}
|
|
15748
15837
|
|
|
15749
15838
|
// src/ui/hooks/use-authenticate.ts
|
|
15750
|
-
import { useContext as
|
|
15839
|
+
import { useContext as useContext32, useEffect as useEffect24 } from "react";
|
|
15751
15840
|
function useAuthenticate(options) {
|
|
15752
15841
|
const { authView = "SIGN_IN", enabled = true } = options ?? {};
|
|
15753
15842
|
const {
|
|
@@ -15755,10 +15844,11 @@ function useAuthenticate(options) {
|
|
|
15755
15844
|
basePath,
|
|
15756
15845
|
viewPaths,
|
|
15757
15846
|
replace
|
|
15758
|
-
} =
|
|
15847
|
+
} = useContext32(AuthUIContext);
|
|
15759
15848
|
const { data, isPending, error, refetch } = useSession();
|
|
15760
15849
|
const sessionData = data;
|
|
15761
15850
|
useEffect24(() => {
|
|
15851
|
+
if (typeof window === "undefined") return;
|
|
15762
15852
|
if (!enabled || isPending || sessionData) return;
|
|
15763
15853
|
const searchParams = new URLSearchParams(window.location.search);
|
|
15764
15854
|
const redirectTo = searchParams.get("redirectTo") || window.location.pathname + window.location.search;
|
|
@@ -15796,21 +15886,21 @@ function RedirectToSignUp() {
|
|
|
15796
15886
|
}
|
|
15797
15887
|
|
|
15798
15888
|
// src/ui/components/signed-in.tsx
|
|
15799
|
-
import { useContext as
|
|
15889
|
+
import { useContext as useContext33 } from "react";
|
|
15800
15890
|
function SignedIn({ children }) {
|
|
15801
15891
|
const {
|
|
15802
15892
|
hooks: { useSession }
|
|
15803
|
-
} =
|
|
15893
|
+
} = useContext33(AuthUIContext);
|
|
15804
15894
|
const { data } = useSession();
|
|
15805
15895
|
return data ? children : null;
|
|
15806
15896
|
}
|
|
15807
15897
|
|
|
15808
15898
|
// src/ui/components/signed-out.tsx
|
|
15809
|
-
import { useContext as
|
|
15899
|
+
import { useContext as useContext34 } from "react";
|
|
15810
15900
|
function SignedOut({ children }) {
|
|
15811
15901
|
const {
|
|
15812
15902
|
hooks: { useSession }
|
|
15813
|
-
} =
|
|
15903
|
+
} = useContext34(AuthUIContext);
|
|
15814
15904
|
const { data, isPending } = useSession();
|
|
15815
15905
|
return !data && !isPending ? children : null;
|
|
15816
15906
|
}
|