@rpcbase/auth 0.101.0 → 0.103.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/{handler-2sZNHSqb.js → handler-Bt53h0sk.js} +18 -6
- package/dist/{handler-2sZNHSqb.js.map → handler-Bt53h0sk.js.map} +1 -1
- package/dist/{handler-CXncjnG5.js → handler-Ck7oLQ_R.js} +34 -8
- package/dist/{handler-CXncjnG5.js.map → handler-Ck7oLQ_R.js.map} +1 -1
- package/dist/{handler-D9OypiUL.js → handler-CyP6R8FM.js} +4 -2
- package/dist/{handler-D9OypiUL.js.map → handler-CyP6R8FM.js.map} +1 -1
- package/dist/{handler-j0RdiReb.js → handler-D6zJn86A.js} +23 -7
- package/dist/{handler-j0RdiReb.js.map → handler-D6zJn86A.js.map} +1 -1
- package/dist/{handler-Db6lpg3J.js → handler-DfEsSB4T.js} +34 -9
- package/dist/{handler-Db6lpg3J.js.map → handler-DfEsSB4T.js.map} +1 -1
- package/dist/{handler--2n6PFBR.js → handler-xEpHnzkZ.js} +2 -2
- package/dist/{handler--2n6PFBR.js.map → handler-xEpHnzkZ.js.map} +1 -1
- package/dist/{index-BfZTJlGT.js → index-Bxz6YdiB.js} +4 -2
- package/dist/{index-BfZTJlGT.js.map → index-Bxz6YdiB.js.map} +1 -1
- package/dist/{index-DQy-Vgjt.js → index-C_uBu_fP.js} +4 -2
- package/dist/{index-DQy-Vgjt.js.map → index-C_uBu_fP.js.map} +1 -1
- package/dist/index.js +407 -194
- package/dist/index.js.map +1 -1
- package/dist/{middleware-HjIzPByj.js → middleware-5Zwy7HRL.js} +4 -2
- package/dist/{middleware-HjIzPByj.js.map → middleware-5Zwy7HRL.js.map} +1 -1
- package/dist/oauth/index.js +180 -41
- package/dist/oauth/index.js.map +1 -1
- package/dist/routes.js +1 -1
- package/dist/routes.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
2
3
|
import { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
|
|
3
4
|
import clsx from "clsx";
|
|
4
5
|
import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
|
|
5
|
-
import { r as requestSchema } from "./index-
|
|
6
|
-
import { useState, forwardRef, createElement, useEffect
|
|
7
|
-
import { r as requestSchema$1 } from "./index-
|
|
8
|
-
import { b, a, r } from "./middleware-
|
|
6
|
+
import { r as requestSchema } from "./index-Bxz6YdiB.js";
|
|
7
|
+
import { useState, forwardRef, createElement, useEffect } from "react";
|
|
8
|
+
import { r as requestSchema$1 } from "./index-C_uBu_fP.js";
|
|
9
|
+
import { b, a, r } from "./middleware-5Zwy7HRL.js";
|
|
9
10
|
const LINKS_REDIRECTION_MAP = {
|
|
10
11
|
"/auth/sign-in": {
|
|
11
12
|
"title": "Sign Up",
|
|
@@ -24,88 +25,156 @@ const LINKS_REDIRECTION_MAP = {
|
|
|
24
25
|
"location": "/auth/sign-in"
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
|
-
const AuthLayout = ({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const AuthLayout = (t0) => {
|
|
29
|
+
const $ = c(11);
|
|
30
|
+
const {
|
|
31
|
+
sidePanel: t1,
|
|
32
|
+
children
|
|
33
|
+
} = t0;
|
|
34
|
+
const sidePanel = t1 === void 0 ? null : t1;
|
|
31
35
|
const location = useLocation();
|
|
32
36
|
const linkTitle = LINKS_REDIRECTION_MAP[location.pathname]?.title;
|
|
33
37
|
const linkLocation = LINKS_REDIRECTION_MAP[location.pathname]?.location;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
let t2;
|
|
39
|
+
if ($[0] !== linkLocation || $[1] !== linkTitle) {
|
|
40
|
+
t2 = linkTitle && linkLocation ? /* @__PURE__ */ jsx(Link, { className: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground h-9 px-4 py-2 absolute right-4 top-4 md:right-8 md:top-8", to: linkLocation, children: linkTitle }) : null;
|
|
41
|
+
$[0] = linkLocation;
|
|
42
|
+
$[1] = linkTitle;
|
|
43
|
+
$[2] = t2;
|
|
44
|
+
} else {
|
|
45
|
+
t2 = $[2];
|
|
46
|
+
}
|
|
47
|
+
let t3;
|
|
48
|
+
if ($[3] !== sidePanel) {
|
|
49
|
+
t3 = /* @__PURE__ */ jsx("div", { className: "relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex", children: sidePanel });
|
|
50
|
+
$[3] = sidePanel;
|
|
51
|
+
$[4] = t3;
|
|
52
|
+
} else {
|
|
53
|
+
t3 = $[4];
|
|
54
|
+
}
|
|
55
|
+
let t4;
|
|
56
|
+
if ($[5] !== children) {
|
|
57
|
+
t4 = /* @__PURE__ */ jsx("div", { className: "mx-auto flex w-full flex-col justify-center gap-6 /*sm:w-[350px]*/", children });
|
|
58
|
+
$[5] = children;
|
|
59
|
+
$[6] = t4;
|
|
60
|
+
} else {
|
|
61
|
+
t4 = $[6];
|
|
62
|
+
}
|
|
63
|
+
let t5;
|
|
64
|
+
if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
|
|
65
|
+
t5 = /* @__PURE__ */ jsxs("div", { className: "container relative hidden h-dvh flex-col items-center justify-center md:grid md:w-full lg:max-w-none lg:grid-cols-2 lg:px-0", children: [
|
|
66
|
+
t2,
|
|
67
|
+
t3,
|
|
68
|
+
t4
|
|
69
|
+
] });
|
|
70
|
+
$[7] = t2;
|
|
71
|
+
$[8] = t3;
|
|
72
|
+
$[9] = t4;
|
|
73
|
+
$[10] = t5;
|
|
74
|
+
} else {
|
|
75
|
+
t5 = $[10];
|
|
76
|
+
}
|
|
77
|
+
return t5;
|
|
46
78
|
};
|
|
47
|
-
const AppleSignInButton = ({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const AppleSignInButton = (t0) => {
|
|
80
|
+
const $ = c(7);
|
|
81
|
+
const {
|
|
82
|
+
onPress,
|
|
83
|
+
className
|
|
84
|
+
} = t0;
|
|
85
|
+
let t1;
|
|
86
|
+
if ($[0] !== className) {
|
|
87
|
+
t1 = clsx("\n w-full\n bg-black text-white hover:bg-gray-800\n flex items-center justify-center\n px-6 py-2\n rounded-lg\n font-medium\n transition duration-150 ease-in-out\n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black\n ", className);
|
|
88
|
+
$[0] = className;
|
|
89
|
+
$[1] = t1;
|
|
90
|
+
} else {
|
|
91
|
+
t1 = $[1];
|
|
92
|
+
}
|
|
93
|
+
let t2;
|
|
94
|
+
let t3;
|
|
95
|
+
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
96
|
+
t2 = /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 mr-3", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ jsx("path", { d: "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.539 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" }) });
|
|
97
|
+
t3 = /* @__PURE__ */ jsx("span", { children: "Continue with Apple" });
|
|
98
|
+
$[2] = t2;
|
|
99
|
+
$[3] = t3;
|
|
100
|
+
} else {
|
|
101
|
+
t2 = $[2];
|
|
102
|
+
t3 = $[3];
|
|
103
|
+
}
|
|
104
|
+
let t4;
|
|
105
|
+
if ($[4] !== onPress || $[5] !== t1) {
|
|
106
|
+
t4 = /* @__PURE__ */ jsxs("button", { onClick: onPress, className: t1, children: [
|
|
107
|
+
t2,
|
|
108
|
+
t3
|
|
109
|
+
] });
|
|
110
|
+
$[4] = onPress;
|
|
111
|
+
$[5] = t1;
|
|
112
|
+
$[6] = t4;
|
|
113
|
+
} else {
|
|
114
|
+
t4 = $[6];
|
|
115
|
+
}
|
|
116
|
+
return t4;
|
|
80
117
|
};
|
|
81
|
-
const EmailInput = ({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
const EmailInput = (t0) => {
|
|
119
|
+
const $ = c(12);
|
|
120
|
+
const {
|
|
121
|
+
id,
|
|
122
|
+
className,
|
|
123
|
+
placeholder
|
|
124
|
+
} = t0;
|
|
125
|
+
const {
|
|
126
|
+
register,
|
|
127
|
+
formState
|
|
128
|
+
} = useFormContext();
|
|
87
129
|
const error = formState.errors.email;
|
|
88
130
|
let errorMessage;
|
|
89
131
|
if (typeof error === "string") {
|
|
90
132
|
errorMessage = error;
|
|
91
|
-
} else
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
|
|
133
|
+
} else {
|
|
134
|
+
if (error && typeof error.message === "string") {
|
|
135
|
+
errorMessage = error.message;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let t1;
|
|
139
|
+
if ($[0] !== register) {
|
|
140
|
+
t1 = register("email");
|
|
141
|
+
$[0] = register;
|
|
142
|
+
$[1] = t1;
|
|
143
|
+
} else {
|
|
144
|
+
t1 = $[1];
|
|
145
|
+
}
|
|
146
|
+
let t2;
|
|
147
|
+
if ($[2] !== className || $[3] !== id || $[4] !== placeholder || $[5] !== t1) {
|
|
148
|
+
t2 = /* @__PURE__ */ jsx("input", { id, type: "email", required: true, autoComplete: "email", className, placeholder, ...t1 });
|
|
149
|
+
$[2] = className;
|
|
150
|
+
$[3] = id;
|
|
151
|
+
$[4] = placeholder;
|
|
152
|
+
$[5] = t1;
|
|
153
|
+
$[6] = t2;
|
|
154
|
+
} else {
|
|
155
|
+
t2 = $[6];
|
|
156
|
+
}
|
|
157
|
+
let t3;
|
|
158
|
+
if ($[7] !== errorMessage) {
|
|
159
|
+
t3 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
|
|
160
|
+
$[7] = errorMessage;
|
|
161
|
+
$[8] = t3;
|
|
162
|
+
} else {
|
|
163
|
+
t3 = $[8];
|
|
164
|
+
}
|
|
165
|
+
let t4;
|
|
166
|
+
if ($[9] !== t2 || $[10] !== t3) {
|
|
167
|
+
t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
168
|
+
t2,
|
|
169
|
+
t3
|
|
170
|
+
] });
|
|
171
|
+
$[9] = t2;
|
|
172
|
+
$[10] = t3;
|
|
173
|
+
$[11] = t4;
|
|
174
|
+
} else {
|
|
175
|
+
t4 = $[11];
|
|
176
|
+
}
|
|
177
|
+
return t4;
|
|
109
178
|
};
|
|
110
179
|
const hasUnsafeNextPathChars = (value) => {
|
|
111
180
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -164,13 +233,21 @@ const SignInForm = ({
|
|
|
164
233
|
const json = await res.json().catch(() => null);
|
|
165
234
|
if (!res.ok || !json?.success) {
|
|
166
235
|
const message = json?.error === "invalid_credentials" ? "Invalid email or password." : "Sign-in failed. Please try again.";
|
|
167
|
-
methods.setError("root", {
|
|
236
|
+
methods.setError("root", {
|
|
237
|
+
type: "server",
|
|
238
|
+
message
|
|
239
|
+
});
|
|
168
240
|
return;
|
|
169
241
|
}
|
|
170
242
|
const nextPath = sanitizeNextPath(searchParams.get("next")) ?? "/";
|
|
171
|
-
navigate(nextPath, {
|
|
243
|
+
navigate(nextPath, {
|
|
244
|
+
replace: true
|
|
245
|
+
});
|
|
172
246
|
} catch (err) {
|
|
173
|
-
methods.setError("root", {
|
|
247
|
+
methods.setError("root", {
|
|
248
|
+
type: "server",
|
|
249
|
+
message: "Network error. Please try again."
|
|
250
|
+
});
|
|
174
251
|
}
|
|
175
252
|
};
|
|
176
253
|
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
|
|
@@ -209,21 +286,32 @@ const SignUpForm = ({
|
|
|
209
286
|
const json = await res.json();
|
|
210
287
|
if (!res.ok) {
|
|
211
288
|
const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
|
|
212
|
-
methods.setError("root", {
|
|
289
|
+
methods.setError("root", {
|
|
290
|
+
type: "server",
|
|
291
|
+
message
|
|
292
|
+
});
|
|
213
293
|
return;
|
|
214
294
|
}
|
|
215
295
|
if (!json.success) {
|
|
216
|
-
methods.setError("root", {
|
|
296
|
+
methods.setError("root", {
|
|
297
|
+
type: "server",
|
|
298
|
+
message: "Sign-up failed. Please try again."
|
|
299
|
+
});
|
|
217
300
|
return;
|
|
218
301
|
}
|
|
219
|
-
const search = new URLSearchParams({
|
|
302
|
+
const search = new URLSearchParams({
|
|
303
|
+
email: data.email
|
|
304
|
+
});
|
|
220
305
|
if (otpNextPath) {
|
|
221
306
|
search.set("next", otpNextPath);
|
|
222
307
|
}
|
|
223
308
|
navigate(`/auth/sign-up-otp?${search.toString()}`);
|
|
224
309
|
setServerMessage("Account created. Check your inbox to verify your email.");
|
|
225
310
|
} catch (err) {
|
|
226
|
-
methods.setError("root", {
|
|
311
|
+
methods.setError("root", {
|
|
312
|
+
type: "server",
|
|
313
|
+
message: "Network error. Please try again."
|
|
314
|
+
});
|
|
227
315
|
}
|
|
228
316
|
};
|
|
229
317
|
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
|
|
@@ -232,28 +320,54 @@ const SignUpForm = ({
|
|
|
232
320
|
serverMessage && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-green-700", role: "status", children: serverMessage })
|
|
233
321
|
] }) });
|
|
234
322
|
};
|
|
235
|
-
const RememberMeCheckbox = ({
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
)
|
|
256
|
-
|
|
323
|
+
const RememberMeCheckbox = (t0) => {
|
|
324
|
+
const $ = c(10);
|
|
325
|
+
const {
|
|
326
|
+
label,
|
|
327
|
+
as: t1
|
|
328
|
+
} = t0;
|
|
329
|
+
const Component = t1 === void 0 ? "input" : t1;
|
|
330
|
+
const {
|
|
331
|
+
register
|
|
332
|
+
} = useFormContext();
|
|
333
|
+
let t2;
|
|
334
|
+
if ($[0] !== register) {
|
|
335
|
+
t2 = register("rememberMe");
|
|
336
|
+
$[0] = register;
|
|
337
|
+
$[1] = t2;
|
|
338
|
+
} else {
|
|
339
|
+
t2 = $[1];
|
|
340
|
+
}
|
|
341
|
+
let t3;
|
|
342
|
+
if ($[2] !== Component || $[3] !== t2) {
|
|
343
|
+
t3 = /* @__PURE__ */ jsx(Component, { id: "rememberMe", ...t2 });
|
|
344
|
+
$[2] = Component;
|
|
345
|
+
$[3] = t2;
|
|
346
|
+
$[4] = t3;
|
|
347
|
+
} else {
|
|
348
|
+
t3 = $[4];
|
|
349
|
+
}
|
|
350
|
+
let t4;
|
|
351
|
+
if ($[5] !== label) {
|
|
352
|
+
t4 = /* @__PURE__ */ jsx("label", { htmlFor: "rememberMe", className: "pl-2 block text-sm/6 text-gray-900", children: label });
|
|
353
|
+
$[5] = label;
|
|
354
|
+
$[6] = t4;
|
|
355
|
+
} else {
|
|
356
|
+
t4 = $[6];
|
|
357
|
+
}
|
|
358
|
+
let t5;
|
|
359
|
+
if ($[7] !== t3 || $[8] !== t4) {
|
|
360
|
+
t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
361
|
+
t3,
|
|
362
|
+
t4
|
|
363
|
+
] });
|
|
364
|
+
$[7] = t3;
|
|
365
|
+
$[8] = t4;
|
|
366
|
+
$[9] = t5;
|
|
367
|
+
} else {
|
|
368
|
+
t5 = $[9];
|
|
369
|
+
}
|
|
370
|
+
return t5;
|
|
257
371
|
};
|
|
258
372
|
const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
259
373
|
const toCamelCase = (string) => string.replace(
|
|
@@ -360,73 +474,188 @@ const __iconNode = [
|
|
|
360
474
|
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
361
475
|
];
|
|
362
476
|
const Eye = createLucideIcon("eye", __iconNode);
|
|
363
|
-
const PasswordInput = ({
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
477
|
+
const PasswordInput = (t0) => {
|
|
478
|
+
const $ = c(24);
|
|
479
|
+
const {
|
|
480
|
+
id,
|
|
481
|
+
name: t1,
|
|
482
|
+
className,
|
|
483
|
+
placeholder,
|
|
484
|
+
autoComplete: t2
|
|
485
|
+
} = t0;
|
|
486
|
+
const name = t1 === void 0 ? "password" : t1;
|
|
487
|
+
const autoComplete = t2 === void 0 ? "current-password" : t2;
|
|
370
488
|
const [showPassword, setShowPassword] = useState(false);
|
|
371
|
-
const {
|
|
489
|
+
const {
|
|
490
|
+
register,
|
|
491
|
+
formState
|
|
492
|
+
} = useFormContext();
|
|
372
493
|
const fieldError = formState.errors[name];
|
|
373
494
|
const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
|
|
374
495
|
const inputClassName = className ? `${className} pr-11` : "pr-11";
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
]
|
|
496
|
+
const t3 = showPassword ? "text" : "password";
|
|
497
|
+
const t4 = name;
|
|
498
|
+
let t5;
|
|
499
|
+
if ($[0] !== register || $[1] !== t4) {
|
|
500
|
+
t5 = register(t4);
|
|
501
|
+
$[0] = register;
|
|
502
|
+
$[1] = t4;
|
|
503
|
+
$[2] = t5;
|
|
504
|
+
} else {
|
|
505
|
+
t5 = $[2];
|
|
506
|
+
}
|
|
507
|
+
let t6;
|
|
508
|
+
if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
|
|
509
|
+
t6 = /* @__PURE__ */ jsx("input", { id, type: t3, autoComplete, className: inputClassName, placeholder, ...t5 });
|
|
510
|
+
$[3] = autoComplete;
|
|
511
|
+
$[4] = id;
|
|
512
|
+
$[5] = inputClassName;
|
|
513
|
+
$[6] = placeholder;
|
|
514
|
+
$[7] = t3;
|
|
515
|
+
$[8] = t5;
|
|
516
|
+
$[9] = t6;
|
|
517
|
+
} else {
|
|
518
|
+
t6 = $[9];
|
|
519
|
+
}
|
|
520
|
+
let t7;
|
|
521
|
+
if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
522
|
+
t7 = () => setShowPassword(_temp);
|
|
523
|
+
$[10] = t7;
|
|
524
|
+
} else {
|
|
525
|
+
t7 = $[10];
|
|
526
|
+
}
|
|
527
|
+
const t8 = showPassword ? "Hide characters" : "Show characters";
|
|
528
|
+
let t9;
|
|
529
|
+
if ($[11] !== showPassword) {
|
|
530
|
+
t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, { className: "h-5 w-5", "aria-hidden": true }) : /* @__PURE__ */ jsx(Eye, { className: "h-5 w-5", "aria-hidden": true });
|
|
531
|
+
$[11] = showPassword;
|
|
532
|
+
$[12] = t9;
|
|
533
|
+
} else {
|
|
534
|
+
t9 = $[12];
|
|
535
|
+
}
|
|
536
|
+
let t10;
|
|
537
|
+
if ($[13] !== t8 || $[14] !== t9) {
|
|
538
|
+
t10 = /* @__PURE__ */ jsx("button", { type: "button", className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500", onClick: t7, "aria-label": t8, children: t9 });
|
|
539
|
+
$[13] = t8;
|
|
540
|
+
$[14] = t9;
|
|
541
|
+
$[15] = t10;
|
|
542
|
+
} else {
|
|
543
|
+
t10 = $[15];
|
|
544
|
+
}
|
|
545
|
+
let t11;
|
|
546
|
+
if ($[16] !== t10 || $[17] !== t6) {
|
|
547
|
+
t11 = /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
548
|
+
t6,
|
|
549
|
+
t10
|
|
550
|
+
] });
|
|
551
|
+
$[16] = t10;
|
|
552
|
+
$[17] = t6;
|
|
553
|
+
$[18] = t11;
|
|
554
|
+
} else {
|
|
555
|
+
t11 = $[18];
|
|
556
|
+
}
|
|
557
|
+
let t12;
|
|
558
|
+
if ($[19] !== errorMessage) {
|
|
559
|
+
t12 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
|
|
560
|
+
$[19] = errorMessage;
|
|
561
|
+
$[20] = t12;
|
|
562
|
+
} else {
|
|
563
|
+
t12 = $[20];
|
|
564
|
+
}
|
|
565
|
+
let t13;
|
|
566
|
+
if ($[21] !== t11 || $[22] !== t12) {
|
|
567
|
+
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
568
|
+
t11,
|
|
569
|
+
t12
|
|
570
|
+
] });
|
|
571
|
+
$[21] = t11;
|
|
572
|
+
$[22] = t12;
|
|
573
|
+
$[23] = t13;
|
|
574
|
+
} else {
|
|
575
|
+
t13 = $[23];
|
|
576
|
+
}
|
|
577
|
+
return t13;
|
|
401
578
|
};
|
|
402
|
-
|
|
579
|
+
function _temp(prev) {
|
|
580
|
+
return !prev;
|
|
581
|
+
}
|
|
582
|
+
const useResendCountdown = (t0) => {
|
|
583
|
+
const $ = c(14);
|
|
584
|
+
const seconds = t0 === void 0 ? 60 : t0;
|
|
403
585
|
const [remaining, setRemaining] = useState(seconds);
|
|
404
586
|
const [isCountingDown, setIsCountingDown] = useState(true);
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
587
|
+
let t1;
|
|
588
|
+
let t2;
|
|
589
|
+
if ($[0] !== isCountingDown || $[1] !== seconds) {
|
|
590
|
+
t1 = () => {
|
|
591
|
+
if (!isCountingDown) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const timer = setInterval(() => {
|
|
595
|
+
setRemaining((prev) => {
|
|
596
|
+
if (prev <= 1) {
|
|
597
|
+
setIsCountingDown(false);
|
|
598
|
+
return seconds;
|
|
599
|
+
}
|
|
600
|
+
return prev - 1;
|
|
601
|
+
});
|
|
602
|
+
}, 1e3);
|
|
603
|
+
return () => clearInterval(timer);
|
|
604
|
+
};
|
|
605
|
+
t2 = [isCountingDown, seconds];
|
|
606
|
+
$[0] = isCountingDown;
|
|
607
|
+
$[1] = seconds;
|
|
608
|
+
$[2] = t1;
|
|
609
|
+
$[3] = t2;
|
|
610
|
+
} else {
|
|
611
|
+
t1 = $[2];
|
|
612
|
+
t2 = $[3];
|
|
613
|
+
}
|
|
614
|
+
useEffect(t1, t2);
|
|
615
|
+
let t3;
|
|
616
|
+
if ($[4] !== seconds) {
|
|
617
|
+
t3 = (nextSeconds) => {
|
|
618
|
+
const value = typeof nextSeconds === "number" ? nextSeconds : seconds;
|
|
619
|
+
setRemaining(value);
|
|
620
|
+
setIsCountingDown(true);
|
|
621
|
+
};
|
|
622
|
+
$[4] = seconds;
|
|
623
|
+
$[5] = t3;
|
|
624
|
+
} else {
|
|
625
|
+
t3 = $[5];
|
|
626
|
+
}
|
|
627
|
+
const restart = t3;
|
|
628
|
+
const minutes = Math.floor(remaining / 60);
|
|
629
|
+
const secs = remaining % 60;
|
|
630
|
+
let t4;
|
|
631
|
+
if ($[6] !== secs) {
|
|
632
|
+
t4 = secs.toString().padStart(2, "0");
|
|
633
|
+
$[6] = secs;
|
|
634
|
+
$[7] = t4;
|
|
635
|
+
} else {
|
|
636
|
+
t4 = $[7];
|
|
637
|
+
}
|
|
638
|
+
const formatted = `${minutes}:${t4}`;
|
|
428
639
|
const canResend = !isCountingDown;
|
|
429
|
-
|
|
640
|
+
let t5;
|
|
641
|
+
if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
|
|
642
|
+
t5 = {
|
|
643
|
+
remaining,
|
|
644
|
+
formatted,
|
|
645
|
+
isCountingDown,
|
|
646
|
+
canResend,
|
|
647
|
+
restart
|
|
648
|
+
};
|
|
649
|
+
$[8] = canResend;
|
|
650
|
+
$[9] = formatted;
|
|
651
|
+
$[10] = isCountingDown;
|
|
652
|
+
$[11] = remaining;
|
|
653
|
+
$[12] = restart;
|
|
654
|
+
$[13] = t5;
|
|
655
|
+
} else {
|
|
656
|
+
t5 = $[13];
|
|
657
|
+
}
|
|
658
|
+
return t5;
|
|
430
659
|
};
|
|
431
660
|
const ResendCodeButton = ({
|
|
432
661
|
seconds = 60,
|
|
@@ -435,7 +664,12 @@ const ResendCodeButton = ({
|
|
|
435
664
|
disabled
|
|
436
665
|
}) => {
|
|
437
666
|
const [isSending, setIsSending] = useState(false);
|
|
438
|
-
const {
|
|
667
|
+
const {
|
|
668
|
+
formatted,
|
|
669
|
+
isCountingDown,
|
|
670
|
+
restart,
|
|
671
|
+
canResend
|
|
672
|
+
} = useResendCountdown(seconds);
|
|
439
673
|
const handleClick = async () => {
|
|
440
674
|
if (!canResend || isSending || disabled) return;
|
|
441
675
|
try {
|
|
@@ -451,33 +685,12 @@ const ResendCodeButton = ({
|
|
|
451
685
|
const isDisabled = disabled || isCountingDown || isSending;
|
|
452
686
|
const showCountdown = isDisabled && (isCountingDown || isSending);
|
|
453
687
|
return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
454
|
-
/* @__PURE__ */ jsx(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
"aria-label": "Resend code",
|
|
461
|
-
className: clsx(
|
|
462
|
-
"text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400",
|
|
463
|
-
className
|
|
464
|
-
),
|
|
465
|
-
children: "Resend code"
|
|
466
|
-
}
|
|
467
|
-
),
|
|
468
|
-
showCountdown ? /* @__PURE__ */ jsxs(
|
|
469
|
-
"span",
|
|
470
|
-
{
|
|
471
|
-
"data-testid": "resend-countdown",
|
|
472
|
-
className: "text-sm text-gray-500",
|
|
473
|
-
"aria-live": "polite",
|
|
474
|
-
children: [
|
|
475
|
-
"(",
|
|
476
|
-
formatted,
|
|
477
|
-
")"
|
|
478
|
-
]
|
|
479
|
-
}
|
|
480
|
-
) : null
|
|
688
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, disabled: isDisabled, "aria-label": "Resend code", className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className), children: "Resend code" }),
|
|
689
|
+
showCountdown ? /* @__PURE__ */ jsxs("span", { "data-testid": "resend-countdown", className: "text-sm text-gray-500", "aria-live": "polite", children: [
|
|
690
|
+
"(",
|
|
691
|
+
formatted,
|
|
692
|
+
")"
|
|
693
|
+
] }) : null
|
|
481
694
|
] });
|
|
482
695
|
};
|
|
483
696
|
export {
|