@rpcbase/auth 0.118.0 → 0.120.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-BNDemOGd.js +79 -0
- package/dist/handler-BNDemOGd.js.map +1 -0
- package/dist/handler-Bt53h0sk.js +64 -0
- package/dist/handler-Bt53h0sk.js.map +1 -0
- package/dist/handler-C4cw739Z.js +59 -0
- package/dist/handler-C4cw739Z.js.map +1 -0
- package/dist/handler-Ck7oLQ_R.js +87 -0
- package/dist/handler-Ck7oLQ_R.js.map +1 -0
- package/dist/handler-CyP6R8FM.js +24 -0
- package/dist/handler-CyP6R8FM.js.map +1 -0
- package/dist/handler-D6zJn86A.js +82 -0
- package/dist/handler-D6zJn86A.js.map +1 -0
- package/dist/handler-D7KnXlx3.js +58 -0
- package/dist/handler-D7KnXlx3.js.map +1 -0
- package/dist/handler-D8HfTbUs.js +58 -0
- package/dist/handler-D8HfTbUs.js.map +1 -0
- package/dist/handler-DfEsSB4T.js +74 -0
- package/dist/handler-DfEsSB4T.js.map +1 -0
- package/dist/index-Bxz6YdiB.js +20 -0
- package/dist/index-Bxz6YdiB.js.map +1 -0
- package/dist/index-C_uBu_fP.js +20 -0
- package/dist/index-C_uBu_fP.js.map +1 -0
- package/dist/index.js +685 -705
- package/dist/index.js.map +1 -1
- package/dist/middleware-8IfSkEEy.js +25 -0
- package/dist/middleware-8IfSkEEy.js.map +1 -0
- package/dist/oauth/index.js +746 -625
- package/dist/oauth/index.js.map +1 -1
- package/dist/routes.js +9 -18
- package/dist/routes.js.map +1 -1
- package/dist/schemas-Dn3gHDGz.js +3706 -0
- package/dist/schemas-Dn3gHDGz.js.map +1 -0
- package/package.json +1 -1
- package/dist/handler-BH38xcvj.js +0 -60
- package/dist/handler-BH38xcvj.js.map +0 -1
- package/dist/handler-Bjxe8iM2.js +0 -67
- package/dist/handler-Bjxe8iM2.js.map +0 -1
- package/dist/handler-CVeU9Nyf.js +0 -85
- package/dist/handler-CVeU9Nyf.js.map +0 -1
- package/dist/handler-CrTy-N1A.js +0 -51
- package/dist/handler-CrTy-N1A.js.map +0 -1
- package/dist/handler-D2-FmmDc.js +0 -56
- package/dist/handler-D2-FmmDc.js.map +0 -1
- package/dist/handler-D4-sXlBe.js +0 -74
- package/dist/handler-D4-sXlBe.js.map +0 -1
- package/dist/handler-D87G4mz9.js +0 -67
- package/dist/handler-D87G4mz9.js.map +0 -1
- package/dist/handler-DKrwSIQz.js +0 -19
- package/dist/handler-DKrwSIQz.js.map +0 -1
- package/dist/handler-tJUJWqII.js +0 -59
- package/dist/handler-tJUJWqII.js.map +0 -1
- package/dist/middleware-BbKZ_rOe.js +0 -18
- package/dist/middleware-BbKZ_rOe.js.map +0 -1
- package/dist/schemas-BKnjeqQ9.js +0 -3380
- package/dist/schemas-BKnjeqQ9.js.map +0 -1
- package/dist/sign-in-C9a-NvBu.js +0 -18
- package/dist/sign-in-C9a-NvBu.js.map +0 -1
- package/dist/sign-up-DqDJxb2D.js +0 -18
- package/dist/sign-up-DqDJxb2D.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,726 +1,706 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as requestSchema$1 } from "./sign-up-DqDJxb2D.js";
|
|
3
|
-
import { n as requireSession, r as restrictSessionMiddleware, t as redirectAuthMiddleware } from "./middleware-BbKZ_rOe.js";
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
4
2
|
import { c } from "react/compiler-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import { Link, useLocation, useNavigate, useSearchParams } from "@rpcbase/router";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
|
|
8
4
|
import clsx from "clsx";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
import { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
|
|
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 { r, a, b } from "./middleware-8IfSkEEy.js";
|
|
10
|
+
const LINKS_REDIRECTION_MAP = {
|
|
11
|
+
"/auth/sign-in": {
|
|
12
|
+
"title": "Sign Up",
|
|
13
|
+
"location": "/auth/sign-up"
|
|
14
|
+
},
|
|
15
|
+
"/auth/sign-up": {
|
|
16
|
+
"title": "Sign In",
|
|
17
|
+
"location": "/auth/sign-in"
|
|
18
|
+
},
|
|
19
|
+
"/auth/logout-success": {
|
|
20
|
+
"title": "Sign In",
|
|
21
|
+
"location": "/auth/sign-in"
|
|
22
|
+
}
|
|
24
23
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
} else t5 = $[10];
|
|
76
|
-
return t5;
|
|
24
|
+
const AuthLayout = (t0) => {
|
|
25
|
+
const $ = c(11);
|
|
26
|
+
const {
|
|
27
|
+
sidePanel: t1,
|
|
28
|
+
children
|
|
29
|
+
} = t0;
|
|
30
|
+
const sidePanel = t1 === void 0 ? null : t1;
|
|
31
|
+
const location = useLocation();
|
|
32
|
+
const linkTitle = LINKS_REDIRECTION_MAP[location.pathname]?.title;
|
|
33
|
+
const linkLocation = LINKS_REDIRECTION_MAP[location.pathname]?.location;
|
|
34
|
+
let t2;
|
|
35
|
+
if ($[0] !== linkLocation || $[1] !== linkTitle) {
|
|
36
|
+
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;
|
|
37
|
+
$[0] = linkLocation;
|
|
38
|
+
$[1] = linkTitle;
|
|
39
|
+
$[2] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t2 = $[2];
|
|
42
|
+
}
|
|
43
|
+
let t3;
|
|
44
|
+
if ($[3] !== sidePanel) {
|
|
45
|
+
t3 = /* @__PURE__ */ jsx("div", { className: "relative hidden h-full flex-col bg-muted p-10 text-white dark:border-r lg:flex", children: sidePanel });
|
|
46
|
+
$[3] = sidePanel;
|
|
47
|
+
$[4] = t3;
|
|
48
|
+
} else {
|
|
49
|
+
t3 = $[4];
|
|
50
|
+
}
|
|
51
|
+
let t4;
|
|
52
|
+
if ($[5] !== children) {
|
|
53
|
+
t4 = /* @__PURE__ */ jsx("div", { className: "mx-auto flex w-full flex-col justify-center gap-6 /*sm:w-[350px]*/", children });
|
|
54
|
+
$[5] = children;
|
|
55
|
+
$[6] = t4;
|
|
56
|
+
} else {
|
|
57
|
+
t4 = $[6];
|
|
58
|
+
}
|
|
59
|
+
let t5;
|
|
60
|
+
if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
|
|
61
|
+
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: [
|
|
62
|
+
t2,
|
|
63
|
+
t3,
|
|
64
|
+
t4
|
|
65
|
+
] });
|
|
66
|
+
$[7] = t2;
|
|
67
|
+
$[8] = t3;
|
|
68
|
+
$[9] = t4;
|
|
69
|
+
$[10] = t5;
|
|
70
|
+
} else {
|
|
71
|
+
t5 = $[10];
|
|
72
|
+
}
|
|
73
|
+
return t5;
|
|
77
74
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
} else t4 = $[6];
|
|
117
|
-
return t4;
|
|
75
|
+
const AppleSignInButton = (t0) => {
|
|
76
|
+
const $ = c(7);
|
|
77
|
+
const {
|
|
78
|
+
onPress,
|
|
79
|
+
className
|
|
80
|
+
} = t0;
|
|
81
|
+
let t1;
|
|
82
|
+
if ($[0] !== className) {
|
|
83
|
+
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);
|
|
84
|
+
$[0] = className;
|
|
85
|
+
$[1] = t1;
|
|
86
|
+
} else {
|
|
87
|
+
t1 = $[1];
|
|
88
|
+
}
|
|
89
|
+
let t2;
|
|
90
|
+
let t3;
|
|
91
|
+
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
92
|
+
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" }) });
|
|
93
|
+
t3 = /* @__PURE__ */ jsx("span", { children: "Continue with Apple" });
|
|
94
|
+
$[2] = t2;
|
|
95
|
+
$[3] = t3;
|
|
96
|
+
} else {
|
|
97
|
+
t2 = $[2];
|
|
98
|
+
t3 = $[3];
|
|
99
|
+
}
|
|
100
|
+
let t4;
|
|
101
|
+
if ($[4] !== onPress || $[5] !== t1) {
|
|
102
|
+
t4 = /* @__PURE__ */ jsxs("button", { onClick: onPress, className: t1, children: [
|
|
103
|
+
t2,
|
|
104
|
+
t3
|
|
105
|
+
] });
|
|
106
|
+
$[4] = onPress;
|
|
107
|
+
$[5] = t1;
|
|
108
|
+
$[6] = t4;
|
|
109
|
+
} else {
|
|
110
|
+
t4 = $[6];
|
|
111
|
+
}
|
|
112
|
+
return t4;
|
|
118
113
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
114
|
+
const EmailInput = (t0) => {
|
|
115
|
+
const $ = c(12);
|
|
116
|
+
const {
|
|
117
|
+
id,
|
|
118
|
+
className,
|
|
119
|
+
placeholder
|
|
120
|
+
} = t0;
|
|
121
|
+
const {
|
|
122
|
+
register,
|
|
123
|
+
formState
|
|
124
|
+
} = useFormContext();
|
|
125
|
+
const error = formState.errors.email;
|
|
126
|
+
let errorMessage;
|
|
127
|
+
if (typeof error === "string") {
|
|
128
|
+
errorMessage = error;
|
|
129
|
+
} else {
|
|
130
|
+
if (error && typeof error.message === "string") {
|
|
131
|
+
errorMessage = error.message;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
let t1;
|
|
135
|
+
if ($[0] !== register) {
|
|
136
|
+
t1 = register("email");
|
|
137
|
+
$[0] = register;
|
|
138
|
+
$[1] = t1;
|
|
139
|
+
} else {
|
|
140
|
+
t1 = $[1];
|
|
141
|
+
}
|
|
142
|
+
let t2;
|
|
143
|
+
if ($[2] !== className || $[3] !== id || $[4] !== placeholder || $[5] !== t1) {
|
|
144
|
+
t2 = /* @__PURE__ */ jsx("input", { id, type: "email", required: true, autoComplete: "email", className, placeholder, ...t1 });
|
|
145
|
+
$[2] = className;
|
|
146
|
+
$[3] = id;
|
|
147
|
+
$[4] = placeholder;
|
|
148
|
+
$[5] = t1;
|
|
149
|
+
$[6] = t2;
|
|
150
|
+
} else {
|
|
151
|
+
t2 = $[6];
|
|
152
|
+
}
|
|
153
|
+
let t3;
|
|
154
|
+
if ($[7] !== errorMessage) {
|
|
155
|
+
t3 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
|
|
156
|
+
$[7] = errorMessage;
|
|
157
|
+
$[8] = t3;
|
|
158
|
+
} else {
|
|
159
|
+
t3 = $[8];
|
|
160
|
+
}
|
|
161
|
+
let t4;
|
|
162
|
+
if ($[9] !== t2 || $[10] !== t3) {
|
|
163
|
+
t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
164
|
+
t2,
|
|
165
|
+
t3
|
|
166
|
+
] });
|
|
167
|
+
$[9] = t2;
|
|
168
|
+
$[10] = t3;
|
|
169
|
+
$[11] = t4;
|
|
170
|
+
} else {
|
|
171
|
+
t4 = $[11];
|
|
172
|
+
}
|
|
173
|
+
return t4;
|
|
169
174
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
return false;
|
|
175
|
+
const hasUnsafeNextPathChars = (value) => {
|
|
176
|
+
for (let i = 0; i < value.length; i++) {
|
|
177
|
+
const code = value.charCodeAt(i);
|
|
178
|
+
if (code === 92 || code <= 31 || code === 127) return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
178
181
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
182
|
+
const sanitizeNextPath = (raw) => {
|
|
183
|
+
if (!raw) return null;
|
|
184
|
+
const nextPath = raw.trim();
|
|
185
|
+
if (!nextPath) return null;
|
|
186
|
+
if (!nextPath.startsWith("/") || nextPath.startsWith("//")) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
if (hasUnsafeNextPathChars(nextPath)) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const base = new URL("http://localhost");
|
|
194
|
+
const url = new URL(nextPath, base);
|
|
195
|
+
if (url.origin !== base.origin) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
199
|
+
} catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
193
202
|
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
children: methods.formState.errors.root.message
|
|
245
|
-
})]
|
|
246
|
-
})
|
|
247
|
-
});
|
|
203
|
+
const SignInForm = ({
|
|
204
|
+
children,
|
|
205
|
+
className
|
|
206
|
+
}) => {
|
|
207
|
+
const navigate = useNavigate();
|
|
208
|
+
const [searchParams] = useSearchParams();
|
|
209
|
+
const methods = useForm({
|
|
210
|
+
defaultValues: {
|
|
211
|
+
email: "",
|
|
212
|
+
password: "",
|
|
213
|
+
rememberMe: true
|
|
214
|
+
},
|
|
215
|
+
navigationGuard: false,
|
|
216
|
+
resolver: zodResolver(requestSchema)
|
|
217
|
+
});
|
|
218
|
+
const onSubmit = async (data) => {
|
|
219
|
+
methods.clearErrors("root");
|
|
220
|
+
try {
|
|
221
|
+
const res = await fetch("/api/rb/auth/sign-in", {
|
|
222
|
+
method: "POST",
|
|
223
|
+
headers: {
|
|
224
|
+
"Content-Type": "application/json"
|
|
225
|
+
},
|
|
226
|
+
body: JSON.stringify(data),
|
|
227
|
+
credentials: "include"
|
|
228
|
+
});
|
|
229
|
+
const json = await res.json().catch(() => null);
|
|
230
|
+
if (!res.ok || !json?.success) {
|
|
231
|
+
const message = json?.error === "invalid_credentials" ? "Invalid email or password." : "Sign-in failed. Please try again.";
|
|
232
|
+
methods.setError("root", {
|
|
233
|
+
type: "server",
|
|
234
|
+
message
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const nextPath = sanitizeNextPath(searchParams.get("next")) ?? "/";
|
|
239
|
+
navigate(nextPath, {
|
|
240
|
+
replace: true
|
|
241
|
+
});
|
|
242
|
+
} catch (err) {
|
|
243
|
+
methods.setError("root", {
|
|
244
|
+
type: "server",
|
|
245
|
+
message: "Network error. Please try again."
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
|
|
250
|
+
children,
|
|
251
|
+
methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-red-600", role: "alert", children: methods.formState.errors.root.message })
|
|
252
|
+
] }) });
|
|
248
253
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}),
|
|
314
|
-
serverMessage && /* @__PURE__ */ jsx("p", {
|
|
315
|
-
className: "mt-2 text-sm text-green-700",
|
|
316
|
-
role: "status",
|
|
317
|
-
children: serverMessage
|
|
318
|
-
})
|
|
319
|
-
]
|
|
320
|
-
})
|
|
321
|
-
});
|
|
254
|
+
const SignUpForm = ({
|
|
255
|
+
children,
|
|
256
|
+
className,
|
|
257
|
+
otpNextPath
|
|
258
|
+
}) => {
|
|
259
|
+
const navigate = useNavigate();
|
|
260
|
+
const [serverMessage, setServerMessage] = useState(null);
|
|
261
|
+
const methods = useForm({
|
|
262
|
+
defaultValues: {
|
|
263
|
+
email: "",
|
|
264
|
+
password: "",
|
|
265
|
+
rememberMe: true
|
|
266
|
+
},
|
|
267
|
+
navigationGuard: false,
|
|
268
|
+
resolver: zodResolver(requestSchema$1)
|
|
269
|
+
});
|
|
270
|
+
const onSubmit = async (data) => {
|
|
271
|
+
setServerMessage(null);
|
|
272
|
+
methods.clearErrors("root");
|
|
273
|
+
try {
|
|
274
|
+
const res = await fetch("/api/rb/auth/sign-up", {
|
|
275
|
+
method: "POST",
|
|
276
|
+
headers: {
|
|
277
|
+
"Content-Type": "application/json"
|
|
278
|
+
},
|
|
279
|
+
body: JSON.stringify(data),
|
|
280
|
+
credentials: "include"
|
|
281
|
+
});
|
|
282
|
+
const json = await res.json();
|
|
283
|
+
if (!res.ok) {
|
|
284
|
+
const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
|
|
285
|
+
methods.setError("root", {
|
|
286
|
+
type: "server",
|
|
287
|
+
message
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (!json.success) {
|
|
292
|
+
methods.setError("root", {
|
|
293
|
+
type: "server",
|
|
294
|
+
message: "Sign-up failed. Please try again."
|
|
295
|
+
});
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const search = new URLSearchParams({
|
|
299
|
+
email: data.email
|
|
300
|
+
});
|
|
301
|
+
if (otpNextPath) {
|
|
302
|
+
search.set("next", otpNextPath);
|
|
303
|
+
}
|
|
304
|
+
navigate(`/auth/sign-up-otp?${search.toString()}`);
|
|
305
|
+
setServerMessage("Account created. Check your inbox to verify your email.");
|
|
306
|
+
} catch (err) {
|
|
307
|
+
methods.setError("root", {
|
|
308
|
+
type: "server",
|
|
309
|
+
message: "Network error. Please try again."
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs("form", { method: "post", noValidate: true, className, onSubmit: methods.handleSubmit(onSubmit), children: [
|
|
314
|
+
children,
|
|
315
|
+
methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-red-600", role: "alert", children: methods.formState.errors.root.message }),
|
|
316
|
+
serverMessage && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-green-700", role: "status", children: serverMessage })
|
|
317
|
+
] }) });
|
|
322
318
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
319
|
+
const RememberMeCheckbox = (t0) => {
|
|
320
|
+
const $ = c(10);
|
|
321
|
+
const {
|
|
322
|
+
label,
|
|
323
|
+
as: t1
|
|
324
|
+
} = t0;
|
|
325
|
+
const Component = t1 === void 0 ? "input" : t1;
|
|
326
|
+
const {
|
|
327
|
+
register
|
|
328
|
+
} = useFormContext();
|
|
329
|
+
let t2;
|
|
330
|
+
if ($[0] !== register) {
|
|
331
|
+
t2 = register("rememberMe");
|
|
332
|
+
$[0] = register;
|
|
333
|
+
$[1] = t2;
|
|
334
|
+
} else {
|
|
335
|
+
t2 = $[1];
|
|
336
|
+
}
|
|
337
|
+
let t3;
|
|
338
|
+
if ($[2] !== Component || $[3] !== t2) {
|
|
339
|
+
t3 = /* @__PURE__ */ jsx(Component, { id: "rememberMe", ...t2 });
|
|
340
|
+
$[2] = Component;
|
|
341
|
+
$[3] = t2;
|
|
342
|
+
$[4] = t3;
|
|
343
|
+
} else {
|
|
344
|
+
t3 = $[4];
|
|
345
|
+
}
|
|
346
|
+
let t4;
|
|
347
|
+
if ($[5] !== label) {
|
|
348
|
+
t4 = /* @__PURE__ */ jsx("label", { htmlFor: "rememberMe", className: "pl-2 block text-sm/6 text-gray-900", children: label });
|
|
349
|
+
$[5] = label;
|
|
350
|
+
$[6] = t4;
|
|
351
|
+
} else {
|
|
352
|
+
t4 = $[6];
|
|
353
|
+
}
|
|
354
|
+
let t5;
|
|
355
|
+
if ($[7] !== t3 || $[8] !== t4) {
|
|
356
|
+
t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
357
|
+
t3,
|
|
358
|
+
t4
|
|
359
|
+
] });
|
|
360
|
+
$[7] = t3;
|
|
361
|
+
$[8] = t4;
|
|
362
|
+
$[9] = t5;
|
|
363
|
+
} else {
|
|
364
|
+
t5 = $[9];
|
|
365
|
+
}
|
|
366
|
+
return t5;
|
|
364
367
|
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
368
|
+
const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
369
|
+
const toCamelCase = (string) => string.replace(
|
|
370
|
+
/^([A-Z])|[\s-_]+(\w)/g,
|
|
371
|
+
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
|
|
372
|
+
);
|
|
373
|
+
const toPascalCase = (string) => {
|
|
374
|
+
const camelCase = toCamelCase(string);
|
|
375
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
376
|
+
};
|
|
377
|
+
const mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
378
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
375
379
|
}).join(" ").trim();
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
383
|
-
*/
|
|
384
|
-
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.js
|
|
387
|
-
/**
|
|
388
|
-
* @license lucide-react v1.7.0 - ISC
|
|
389
|
-
*
|
|
390
|
-
* This source code is licensed under the ISC license.
|
|
391
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
392
|
-
*/
|
|
393
|
-
var toCamelCase = (string) => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
|
|
394
|
-
//#endregion
|
|
395
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.js
|
|
396
|
-
/**
|
|
397
|
-
* @license lucide-react v1.7.0 - ISC
|
|
398
|
-
*
|
|
399
|
-
* This source code is licensed under the ISC license.
|
|
400
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
401
|
-
*/
|
|
402
|
-
var toPascalCase = (string) => {
|
|
403
|
-
const camelCase = toCamelCase(string);
|
|
404
|
-
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
380
|
+
const hasA11yProp = (props) => {
|
|
381
|
+
for (const prop in props) {
|
|
382
|
+
if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
405
386
|
};
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
408
|
-
/**
|
|
409
|
-
* @license lucide-react v1.7.0 - ISC
|
|
410
|
-
*
|
|
411
|
-
* This source code is licensed under the ISC license.
|
|
412
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
413
|
-
*/
|
|
414
387
|
var defaultAttributes = {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
};
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.js
|
|
427
|
-
/**
|
|
428
|
-
* @license lucide-react v1.7.0 - ISC
|
|
429
|
-
*
|
|
430
|
-
* This source code is licensed under the ISC license.
|
|
431
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
432
|
-
*/
|
|
433
|
-
var hasA11yProp = (props) => {
|
|
434
|
-
for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
|
|
435
|
-
return false;
|
|
388
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
389
|
+
width: 24,
|
|
390
|
+
height: 24,
|
|
391
|
+
viewBox: "0 0 24 24",
|
|
392
|
+
fill: "none",
|
|
393
|
+
stroke: "currentColor",
|
|
394
|
+
strokeWidth: 2,
|
|
395
|
+
strokeLinecap: "round",
|
|
396
|
+
strokeLinejoin: "round"
|
|
436
397
|
};
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
iconNode,
|
|
482
|
-
className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
|
|
483
|
-
...props
|
|
484
|
-
}));
|
|
485
|
-
Component.displayName = toPascalCase(iconName);
|
|
486
|
-
return Component;
|
|
398
|
+
const Icon = forwardRef(
|
|
399
|
+
({
|
|
400
|
+
color = "currentColor",
|
|
401
|
+
size = 24,
|
|
402
|
+
strokeWidth = 2,
|
|
403
|
+
absoluteStrokeWidth,
|
|
404
|
+
className = "",
|
|
405
|
+
children,
|
|
406
|
+
iconNode,
|
|
407
|
+
...rest
|
|
408
|
+
}, ref) => createElement(
|
|
409
|
+
"svg",
|
|
410
|
+
{
|
|
411
|
+
ref,
|
|
412
|
+
...defaultAttributes,
|
|
413
|
+
width: size,
|
|
414
|
+
height: size,
|
|
415
|
+
stroke: color,
|
|
416
|
+
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
417
|
+
className: mergeClasses("lucide", className),
|
|
418
|
+
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
419
|
+
...rest
|
|
420
|
+
},
|
|
421
|
+
[
|
|
422
|
+
...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
|
|
423
|
+
...Array.isArray(children) ? children : [children]
|
|
424
|
+
]
|
|
425
|
+
)
|
|
426
|
+
);
|
|
427
|
+
const createLucideIcon = (iconName, iconNode) => {
|
|
428
|
+
const Component = forwardRef(
|
|
429
|
+
({ className, ...props }, ref) => createElement(Icon, {
|
|
430
|
+
ref,
|
|
431
|
+
iconNode,
|
|
432
|
+
className: mergeClasses(
|
|
433
|
+
`lucide-${toKebabCase(toPascalCase(iconName))}`,
|
|
434
|
+
`lucide-${iconName}`,
|
|
435
|
+
className
|
|
436
|
+
),
|
|
437
|
+
...props
|
|
438
|
+
})
|
|
439
|
+
);
|
|
440
|
+
Component.displayName = toPascalCase(iconName);
|
|
441
|
+
return Component;
|
|
487
442
|
};
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
]
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
443
|
+
const __iconNode$1 = [
|
|
444
|
+
[
|
|
445
|
+
"path",
|
|
446
|
+
{
|
|
447
|
+
d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
|
|
448
|
+
key: "ct8e1f"
|
|
449
|
+
}
|
|
450
|
+
],
|
|
451
|
+
["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
|
|
452
|
+
[
|
|
453
|
+
"path",
|
|
454
|
+
{
|
|
455
|
+
d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
|
|
456
|
+
key: "13bj9a"
|
|
457
|
+
}
|
|
458
|
+
],
|
|
459
|
+
["path", { d: "m2 2 20 20", key: "1ooewy" }]
|
|
460
|
+
];
|
|
461
|
+
const EyeOff = createLucideIcon("eye-off", __iconNode$1);
|
|
462
|
+
const __iconNode = [
|
|
463
|
+
[
|
|
464
|
+
"path",
|
|
465
|
+
{
|
|
466
|
+
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
|
|
467
|
+
key: "1nclc0"
|
|
468
|
+
}
|
|
469
|
+
],
|
|
470
|
+
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
471
|
+
];
|
|
472
|
+
const Eye = createLucideIcon("eye", __iconNode);
|
|
473
|
+
const PasswordInput = (t0) => {
|
|
474
|
+
const $ = c(24);
|
|
475
|
+
const {
|
|
476
|
+
id,
|
|
477
|
+
name: t1,
|
|
478
|
+
className,
|
|
479
|
+
placeholder,
|
|
480
|
+
autoComplete: t2
|
|
481
|
+
} = t0;
|
|
482
|
+
const name = t1 === void 0 ? "password" : t1;
|
|
483
|
+
const autoComplete = t2 === void 0 ? "current-password" : t2;
|
|
484
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
485
|
+
const {
|
|
486
|
+
register,
|
|
487
|
+
formState
|
|
488
|
+
} = useFormContext();
|
|
489
|
+
const fieldError = formState.errors[name];
|
|
490
|
+
const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
|
|
491
|
+
const inputClassName = className ? `${className} pr-11` : "pr-11";
|
|
492
|
+
const t3 = showPassword ? "text" : "password";
|
|
493
|
+
const t4 = name;
|
|
494
|
+
let t5;
|
|
495
|
+
if ($[0] !== register || $[1] !== t4) {
|
|
496
|
+
t5 = register(t4);
|
|
497
|
+
$[0] = register;
|
|
498
|
+
$[1] = t4;
|
|
499
|
+
$[2] = t5;
|
|
500
|
+
} else {
|
|
501
|
+
t5 = $[2];
|
|
502
|
+
}
|
|
503
|
+
let t6;
|
|
504
|
+
if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
|
|
505
|
+
t6 = /* @__PURE__ */ jsx("input", { id, type: t3, autoComplete, className: inputClassName, placeholder, ...t5 });
|
|
506
|
+
$[3] = autoComplete;
|
|
507
|
+
$[4] = id;
|
|
508
|
+
$[5] = inputClassName;
|
|
509
|
+
$[6] = placeholder;
|
|
510
|
+
$[7] = t3;
|
|
511
|
+
$[8] = t5;
|
|
512
|
+
$[9] = t6;
|
|
513
|
+
} else {
|
|
514
|
+
t6 = $[9];
|
|
515
|
+
}
|
|
516
|
+
let t7;
|
|
517
|
+
if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
518
|
+
t7 = () => setShowPassword(_temp);
|
|
519
|
+
$[10] = t7;
|
|
520
|
+
} else {
|
|
521
|
+
t7 = $[10];
|
|
522
|
+
}
|
|
523
|
+
const t8 = showPassword ? "Hide characters" : "Show characters";
|
|
524
|
+
let t9;
|
|
525
|
+
if ($[11] !== showPassword) {
|
|
526
|
+
t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, { className: "h-5 w-5", "aria-hidden": true }) : /* @__PURE__ */ jsx(Eye, { className: "h-5 w-5", "aria-hidden": true });
|
|
527
|
+
$[11] = showPassword;
|
|
528
|
+
$[12] = t9;
|
|
529
|
+
} else {
|
|
530
|
+
t9 = $[12];
|
|
531
|
+
}
|
|
532
|
+
let t10;
|
|
533
|
+
if ($[13] !== t8 || $[14] !== t9) {
|
|
534
|
+
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 });
|
|
535
|
+
$[13] = t8;
|
|
536
|
+
$[14] = t9;
|
|
537
|
+
$[15] = t10;
|
|
538
|
+
} else {
|
|
539
|
+
t10 = $[15];
|
|
540
|
+
}
|
|
541
|
+
let t11;
|
|
542
|
+
if ($[16] !== t10 || $[17] !== t6) {
|
|
543
|
+
t11 = /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
544
|
+
t6,
|
|
545
|
+
t10
|
|
546
|
+
] });
|
|
547
|
+
$[16] = t10;
|
|
548
|
+
$[17] = t6;
|
|
549
|
+
$[18] = t11;
|
|
550
|
+
} else {
|
|
551
|
+
t11 = $[18];
|
|
552
|
+
}
|
|
553
|
+
let t12;
|
|
554
|
+
if ($[19] !== errorMessage) {
|
|
555
|
+
t12 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
|
|
556
|
+
$[19] = errorMessage;
|
|
557
|
+
$[20] = t12;
|
|
558
|
+
} else {
|
|
559
|
+
t12 = $[20];
|
|
560
|
+
}
|
|
561
|
+
let t13;
|
|
562
|
+
if ($[21] !== t11 || $[22] !== t12) {
|
|
563
|
+
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
564
|
+
t11,
|
|
565
|
+
t12
|
|
566
|
+
] });
|
|
567
|
+
$[21] = t11;
|
|
568
|
+
$[22] = t12;
|
|
569
|
+
$[23] = t13;
|
|
570
|
+
} else {
|
|
571
|
+
t13 = $[23];
|
|
572
|
+
}
|
|
573
|
+
return t13;
|
|
612
574
|
};
|
|
613
575
|
function _temp(prev) {
|
|
614
|
-
|
|
576
|
+
return !prev;
|
|
615
577
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
578
|
+
const useResendCountdown = (t0) => {
|
|
579
|
+
const $ = c(14);
|
|
580
|
+
const seconds = t0 === void 0 ? 60 : t0;
|
|
581
|
+
const [remaining, setRemaining] = useState(seconds);
|
|
582
|
+
const [isCountingDown, setIsCountingDown] = useState(true);
|
|
583
|
+
let t1;
|
|
584
|
+
let t2;
|
|
585
|
+
if ($[0] !== isCountingDown || $[1] !== seconds) {
|
|
586
|
+
t1 = () => {
|
|
587
|
+
if (!isCountingDown) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const timer = setInterval(() => {
|
|
591
|
+
setRemaining((prev) => {
|
|
592
|
+
if (prev <= 1) {
|
|
593
|
+
setIsCountingDown(false);
|
|
594
|
+
return seconds;
|
|
595
|
+
}
|
|
596
|
+
return prev - 1;
|
|
597
|
+
});
|
|
598
|
+
}, 1e3);
|
|
599
|
+
return () => clearInterval(timer);
|
|
600
|
+
};
|
|
601
|
+
t2 = [isCountingDown, seconds];
|
|
602
|
+
$[0] = isCountingDown;
|
|
603
|
+
$[1] = seconds;
|
|
604
|
+
$[2] = t1;
|
|
605
|
+
$[3] = t2;
|
|
606
|
+
} else {
|
|
607
|
+
t1 = $[2];
|
|
608
|
+
t2 = $[3];
|
|
609
|
+
}
|
|
610
|
+
useEffect(t1, t2);
|
|
611
|
+
let t3;
|
|
612
|
+
if ($[4] !== seconds) {
|
|
613
|
+
t3 = (nextSeconds) => {
|
|
614
|
+
const value = typeof nextSeconds === "number" ? nextSeconds : seconds;
|
|
615
|
+
setRemaining(value);
|
|
616
|
+
setIsCountingDown(true);
|
|
617
|
+
};
|
|
618
|
+
$[4] = seconds;
|
|
619
|
+
$[5] = t3;
|
|
620
|
+
} else {
|
|
621
|
+
t3 = $[5];
|
|
622
|
+
}
|
|
623
|
+
const restart = t3;
|
|
624
|
+
const minutes = Math.floor(remaining / 60);
|
|
625
|
+
const secs = remaining % 60;
|
|
626
|
+
let t4;
|
|
627
|
+
if ($[6] !== secs) {
|
|
628
|
+
t4 = secs.toString().padStart(2, "0");
|
|
629
|
+
$[6] = secs;
|
|
630
|
+
$[7] = t4;
|
|
631
|
+
} else {
|
|
632
|
+
t4 = $[7];
|
|
633
|
+
}
|
|
634
|
+
const formatted = `${minutes}:${t4}`;
|
|
635
|
+
const canResend = !isCountingDown;
|
|
636
|
+
let t5;
|
|
637
|
+
if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
|
|
638
|
+
t5 = {
|
|
639
|
+
remaining,
|
|
640
|
+
formatted,
|
|
641
|
+
isCountingDown,
|
|
642
|
+
canResend,
|
|
643
|
+
restart
|
|
644
|
+
};
|
|
645
|
+
$[8] = canResend;
|
|
646
|
+
$[9] = formatted;
|
|
647
|
+
$[10] = isCountingDown;
|
|
648
|
+
$[11] = remaining;
|
|
649
|
+
$[12] = restart;
|
|
650
|
+
$[13] = t5;
|
|
651
|
+
} else {
|
|
652
|
+
t5 = $[13];
|
|
653
|
+
}
|
|
654
|
+
return t5;
|
|
655
|
+
};
|
|
656
|
+
const ResendCodeButton = ({
|
|
657
|
+
seconds = 60,
|
|
658
|
+
onResend,
|
|
659
|
+
className,
|
|
660
|
+
disabled
|
|
661
|
+
}) => {
|
|
662
|
+
const [isSending, setIsSending] = useState(false);
|
|
663
|
+
const {
|
|
664
|
+
formatted,
|
|
665
|
+
isCountingDown,
|
|
666
|
+
restart,
|
|
667
|
+
canResend
|
|
668
|
+
} = useResendCountdown(seconds);
|
|
669
|
+
const handleClick = async () => {
|
|
670
|
+
if (!canResend || isSending || disabled) return;
|
|
671
|
+
try {
|
|
672
|
+
setIsSending(true);
|
|
673
|
+
if (onResend) {
|
|
674
|
+
await onResend();
|
|
675
|
+
}
|
|
676
|
+
} finally {
|
|
677
|
+
restart();
|
|
678
|
+
setIsSending(false);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
const isDisabled = disabled || isCountingDown || isSending;
|
|
682
|
+
const showCountdown = isDisabled && (isCountingDown || isSending);
|
|
683
|
+
return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
684
|
+
/* @__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" }),
|
|
685
|
+
showCountdown ? /* @__PURE__ */ jsxs("span", { "data-testid": "resend-countdown", className: "text-sm text-gray-500", "aria-live": "polite", children: [
|
|
686
|
+
"(",
|
|
687
|
+
formatted,
|
|
688
|
+
")"
|
|
689
|
+
] }) : null
|
|
690
|
+
] });
|
|
686
691
|
};
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
const isDisabled = disabled || isCountingDown || isSending;
|
|
701
|
-
const showCountdown = isDisabled && (isCountingDown || isSending);
|
|
702
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
703
|
-
className: "inline-flex items-center gap-2",
|
|
704
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
705
|
-
type: "button",
|
|
706
|
-
onClick: handleClick,
|
|
707
|
-
disabled: isDisabled,
|
|
708
|
-
"aria-label": "Resend code",
|
|
709
|
-
className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className),
|
|
710
|
-
children: "Resend code"
|
|
711
|
-
}), showCountdown ? /* @__PURE__ */ jsxs("span", {
|
|
712
|
-
"data-testid": "resend-countdown",
|
|
713
|
-
className: "text-sm text-gray-500",
|
|
714
|
-
"aria-live": "polite",
|
|
715
|
-
children: [
|
|
716
|
-
"(",
|
|
717
|
-
formatted,
|
|
718
|
-
")"
|
|
719
|
-
]
|
|
720
|
-
}) : null]
|
|
721
|
-
});
|
|
692
|
+
export {
|
|
693
|
+
AppleSignInButton,
|
|
694
|
+
AuthLayout,
|
|
695
|
+
EmailInput,
|
|
696
|
+
PasswordInput,
|
|
697
|
+
RememberMeCheckbox,
|
|
698
|
+
ResendCodeButton,
|
|
699
|
+
SignInForm,
|
|
700
|
+
SignUpForm,
|
|
701
|
+
r as redirectAuthMiddleware,
|
|
702
|
+
a as requireSession,
|
|
703
|
+
b as restrictSessionMiddleware,
|
|
704
|
+
useResendCountdown
|
|
722
705
|
};
|
|
723
|
-
//#
|
|
724
|
-
export { AppleSignInButton, AuthLayout, EmailInput, PasswordInput, RememberMeCheckbox, ResendCodeButton, SignInForm, SignUpForm, redirectAuthMiddleware, requireSession, restrictSessionMiddleware, useResendCountdown };
|
|
725
|
-
|
|
726
|
-
//# sourceMappingURL=index.js.map
|
|
706
|
+
//# sourceMappingURL=index.js.map
|