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