@rpcbase/auth 0.165.0 → 0.166.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-0nKR-P5B.js +84 -0
- package/dist/handler-0nKR-P5B.js.map +1 -0
- package/dist/handler-B8jPw9zh.js +74 -0
- package/dist/handler-B8jPw9zh.js.map +1 -0
- package/dist/handler-BGNM_dz1.js +19 -0
- package/dist/handler-BGNM_dz1.js.map +1 -0
- package/dist/handler-BoWTfKWi.js +56 -0
- package/dist/handler-BoWTfKWi.js.map +1 -0
- package/dist/handler-ClyVm_Us.js +92 -0
- package/dist/handler-ClyVm_Us.js.map +1 -0
- package/dist/handler-DNxEmrtP.js +67 -0
- package/dist/{handler-B_lItxOC.js.map → handler-DNxEmrtP.js.map} +1 -1
- package/dist/handler-DsPS6JXV.js +70 -0
- package/dist/handler-DsPS6JXV.js.map +1 -0
- package/dist/handler-GKdEwnBO.js +75 -0
- package/dist/handler-GKdEwnBO.js.map +1 -0
- package/dist/handler-IBGVDW5w.js +125 -0
- package/dist/handler-IBGVDW5w.js.map +1 -0
- package/dist/handler-J2OwFTyf.js +51 -0
- package/dist/handler-J2OwFTyf.js.map +1 -0
- package/dist/index.js +770 -756
- package/dist/index.js.map +1 -1
- package/dist/middleware-BT3Uput1.js +18 -0
- package/dist/middleware-BT3Uput1.js.map +1 -0
- package/dist/oauth/index.js +636 -761
- package/dist/oauth/index.js.map +1 -1
- package/dist/routes.js +19 -9
- package/dist/routes.js.map +1 -1
- package/dist/schemas-BgOpQqUv.js +3988 -0
- package/dist/schemas-BgOpQqUv.js.map +1 -0
- package/dist/session-BQ06Yo3C.js +20 -0
- package/dist/session-BQ06Yo3C.js.map +1 -0
- package/dist/sign-in-BG2ND3cO.js +18 -0
- package/dist/sign-in-BG2ND3cO.js.map +1 -0
- package/dist/sign-up-BCVi8UC9.js +18 -0
- package/dist/sign-up-BCVi8UC9.js.map +1 -0
- package/package.json +1 -1
- package/dist/handler-BBSeVt7x.js +0 -153
- package/dist/handler-BBSeVt7x.js.map +0 -1
- package/dist/handler-BKSik1j0.js +0 -83
- package/dist/handler-BKSik1j0.js.map +0 -1
- package/dist/handler-BXvh_Nx4.js +0 -95
- package/dist/handler-BXvh_Nx4.js.map +0 -1
- package/dist/handler-B_lItxOC.js +0 -66
- package/dist/handler-BuwKXMOu.js +0 -24
- package/dist/handler-BuwKXMOu.js.map +0 -1
- package/dist/handler-C-hPxnHG.js +0 -68
- package/dist/handler-C-hPxnHG.js.map +0 -1
- package/dist/handler-CoHpAhui.js +0 -81
- package/dist/handler-CoHpAhui.js.map +0 -1
- package/dist/handler-DfZwgoA4.js +0 -94
- package/dist/handler-DfZwgoA4.js.map +0 -1
- package/dist/handler-Eyjkxj9l.js +0 -58
- package/dist/handler-Eyjkxj9l.js.map +0 -1
- package/dist/handler-U3df_2Al.js +0 -59
- package/dist/handler-U3df_2Al.js.map +0 -1
- package/dist/index-1_ZKABa_.js +0 -20
- package/dist/index-1_ZKABa_.js.map +0 -1
- package/dist/index-D94-1Zwh.js +0 -20
- package/dist/index-D94-1Zwh.js.map +0 -1
- package/dist/middleware-8IfSkEEy.js +0 -25
- package/dist/middleware-8IfSkEEy.js.map +0 -1
- package/dist/schemas--f80aXK7.js +0 -4329
- package/dist/schemas--f80aXK7.js.map +0 -1
- package/dist/session-DoTNxRRA.js +0 -20
- package/dist/session-DoTNxRRA.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,782 +1,796 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as requestSchema } from "./sign-in-BG2ND3cO.js";
|
|
2
|
+
import { n as requestSchema$1 } from "./sign-up-BCVi8UC9.js";
|
|
3
|
+
import { n as requireSession, r as restrictSessionMiddleware, t as redirectAuthMiddleware } from "./middleware-BT3Uput1.js";
|
|
2
4
|
import { c } from "react/compiler-runtime";
|
|
3
|
-
import {
|
|
5
|
+
import { createContext, createElement, forwardRef, useContext, useEffect, useRef, 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 flex min-h-dvh flex-col items-center justify-center px-4 py-20 sm:px-6 md:px-8 lg:grid lg:h-dvh lg:w-full lg:max-w-none lg:grid-cols-2 lg:px-0 lg:py-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
|
+
const nextPath = sanitizeNextPath(searchParams.get("next")) ?? "/";
|
|
227
|
+
navigate(nextPath, { replace: true });
|
|
228
|
+
} catch (err) {
|
|
229
|
+
methods.setError("root", {
|
|
230
|
+
type: "server",
|
|
231
|
+
message: "Network error. Please try again."
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return /* @__PURE__ */ jsx(FormProvider, {
|
|
236
|
+
...methods,
|
|
237
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
238
|
+
method: "post",
|
|
239
|
+
noValidate: true,
|
|
240
|
+
className,
|
|
241
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
242
|
+
children: [children, methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", {
|
|
243
|
+
className: "mt-2 text-sm text-red-600",
|
|
244
|
+
role: "alert",
|
|
245
|
+
children: methods.formState.errors.root.message
|
|
246
|
+
})]
|
|
247
|
+
})
|
|
248
|
+
});
|
|
253
249
|
};
|
|
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
|
-
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/components/SignUpForm/index.tsx
|
|
252
|
+
var SignUpForm = ({ children, className, otpNextPath }) => {
|
|
253
|
+
const navigate = useNavigate();
|
|
254
|
+
const [serverMessage, setServerMessage] = useState(null);
|
|
255
|
+
const methods = useForm({
|
|
256
|
+
defaultValues: {
|
|
257
|
+
email: "",
|
|
258
|
+
password: "",
|
|
259
|
+
rememberMe: true
|
|
260
|
+
},
|
|
261
|
+
navigationGuard: false,
|
|
262
|
+
resolver: zodResolver(requestSchema$1)
|
|
263
|
+
});
|
|
264
|
+
const onSubmit = async (data) => {
|
|
265
|
+
setServerMessage(null);
|
|
266
|
+
methods.clearErrors("root");
|
|
267
|
+
try {
|
|
268
|
+
const res = await fetch("/api/rb/auth/sign-up", {
|
|
269
|
+
method: "POST",
|
|
270
|
+
headers: { "Content-Type": "application/json" },
|
|
271
|
+
body: JSON.stringify(data),
|
|
272
|
+
credentials: "include"
|
|
273
|
+
});
|
|
274
|
+
const json = await res.json();
|
|
275
|
+
if (!res.ok) {
|
|
276
|
+
const message = json.error === "user_exists" ? "An account already exists with this email." : "Sign-up failed. Please try again.";
|
|
277
|
+
methods.setError("root", {
|
|
278
|
+
type: "server",
|
|
279
|
+
message
|
|
280
|
+
});
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (!json.success) {
|
|
284
|
+
methods.setError("root", {
|
|
285
|
+
type: "server",
|
|
286
|
+
message: "Sign-up failed. Please try again."
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const search = new URLSearchParams({ email: data.email });
|
|
291
|
+
if (otpNextPath) search.set("next", otpNextPath);
|
|
292
|
+
navigate(`/auth/sign-up-otp?${search.toString()}`);
|
|
293
|
+
setServerMessage("Account created. Check your inbox to verify your email.");
|
|
294
|
+
} catch (err) {
|
|
295
|
+
methods.setError("root", {
|
|
296
|
+
type: "server",
|
|
297
|
+
message: "Network error. Please try again."
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
return /* @__PURE__ */ jsx(FormProvider, {
|
|
302
|
+
...methods,
|
|
303
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
304
|
+
method: "post",
|
|
305
|
+
noValidate: true,
|
|
306
|
+
className,
|
|
307
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
308
|
+
children: [
|
|
309
|
+
children,
|
|
310
|
+
methods.formState.errors.root?.message && /* @__PURE__ */ jsx("p", {
|
|
311
|
+
className: "mt-2 text-sm text-red-600",
|
|
312
|
+
role: "alert",
|
|
313
|
+
children: methods.formState.errors.root.message
|
|
314
|
+
}),
|
|
315
|
+
serverMessage && /* @__PURE__ */ jsx("p", {
|
|
316
|
+
className: "mt-2 text-sm text-green-700",
|
|
317
|
+
role: "status",
|
|
318
|
+
children: serverMessage
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
322
|
+
});
|
|
318
323
|
};
|
|
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;
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/components/RememberMeCheckbox/index.tsx
|
|
326
|
+
var RememberMeCheckbox = (t0) => {
|
|
327
|
+
const $ = c(10);
|
|
328
|
+
const { label, as: t1 } = t0;
|
|
329
|
+
const Component = t1 === void 0 ? "input" : t1;
|
|
330
|
+
const { register } = useFormContext();
|
|
331
|
+
let t2;
|
|
332
|
+
if ($[0] !== register) {
|
|
333
|
+
t2 = register("rememberMe");
|
|
334
|
+
$[0] = register;
|
|
335
|
+
$[1] = t2;
|
|
336
|
+
} else t2 = $[1];
|
|
337
|
+
let t3;
|
|
338
|
+
if ($[2] !== Component || $[3] !== t2) {
|
|
339
|
+
t3 = /* @__PURE__ */ jsx(Component, {
|
|
340
|
+
id: "rememberMe",
|
|
341
|
+
...t2
|
|
342
|
+
});
|
|
343
|
+
$[2] = Component;
|
|
344
|
+
$[3] = t2;
|
|
345
|
+
$[4] = t3;
|
|
346
|
+
} else t3 = $[4];
|
|
347
|
+
let t4;
|
|
348
|
+
if ($[5] !== label) {
|
|
349
|
+
t4 = /* @__PURE__ */ jsx("label", {
|
|
350
|
+
htmlFor: "rememberMe",
|
|
351
|
+
className: "pl-2 block text-sm/6 text-gray-900",
|
|
352
|
+
children: label
|
|
353
|
+
});
|
|
354
|
+
$[5] = label;
|
|
355
|
+
$[6] = t4;
|
|
356
|
+
} else t4 = $[6];
|
|
357
|
+
let t5;
|
|
358
|
+
if ($[7] !== t3 || $[8] !== t4) {
|
|
359
|
+
t5 = /* @__PURE__ */ jsxs(Fragment, { children: [t3, t4] });
|
|
360
|
+
$[7] = t3;
|
|
361
|
+
$[8] = t4;
|
|
362
|
+
$[9] = t5;
|
|
363
|
+
} else t5 = $[9];
|
|
364
|
+
return t5;
|
|
367
365
|
};
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
368
|
+
/**
|
|
369
|
+
* @license lucide-react v1.22.0 - ISC
|
|
370
|
+
*
|
|
371
|
+
* This source code is licensed under the ISC license.
|
|
372
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
373
|
+
*/
|
|
374
|
+
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
375
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
370
376
|
}).join(" ").trim();
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
|
|
379
|
+
/**
|
|
380
|
+
* @license lucide-react v1.22.0 - ISC
|
|
381
|
+
*
|
|
382
|
+
* This source code is licensed under the ISC license.
|
|
383
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
384
|
+
*/
|
|
385
|
+
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
|
|
388
|
+
/**
|
|
389
|
+
* @license lucide-react v1.22.0 - ISC
|
|
390
|
+
*
|
|
391
|
+
* This source code is licensed under the ISC license.
|
|
392
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
393
|
+
*/
|
|
394
|
+
var toCamelCase = (string) => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
|
|
397
|
+
/**
|
|
398
|
+
* @license lucide-react v1.22.0 - ISC
|
|
399
|
+
*
|
|
400
|
+
* This source code is licensed under the ISC license.
|
|
401
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
402
|
+
*/
|
|
403
|
+
var toPascalCase = (string) => {
|
|
404
|
+
const camelCase = toCamelCase(string);
|
|
405
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
379
406
|
};
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region ../../node_modules/lucide-react/dist/esm/defaultAttributes.mjs
|
|
409
|
+
/**
|
|
410
|
+
* @license lucide-react v1.22.0 - ISC
|
|
411
|
+
*
|
|
412
|
+
* This source code is licensed under the ISC license.
|
|
413
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
414
|
+
*/
|
|
380
415
|
var defaultAttributes = {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
416
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
417
|
+
width: 24,
|
|
418
|
+
height: 24,
|
|
419
|
+
viewBox: "0 0 24 24",
|
|
420
|
+
fill: "none",
|
|
421
|
+
stroke: "currentColor",
|
|
422
|
+
strokeWidth: 2,
|
|
423
|
+
strokeLinecap: "round",
|
|
424
|
+
strokeLinejoin: "round"
|
|
390
425
|
};
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
|
|
428
|
+
/**
|
|
429
|
+
* @license lucide-react v1.22.0 - ISC
|
|
430
|
+
*
|
|
431
|
+
* This source code is licensed under the ISC license.
|
|
432
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
433
|
+
*/
|
|
434
|
+
var hasA11yProp = (props) => {
|
|
435
|
+
for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
|
|
436
|
+
return false;
|
|
398
437
|
};
|
|
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
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region ../../node_modules/lucide-react/dist/esm/context.mjs
|
|
440
|
+
/**
|
|
441
|
+
* @license lucide-react v1.22.0 - ISC
|
|
442
|
+
*
|
|
443
|
+
* This source code is licensed under the ISC license.
|
|
444
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
445
|
+
*/
|
|
446
|
+
var LucideContext = createContext({});
|
|
447
|
+
var useLucideContext = () => useContext(LucideContext);
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region ../../node_modules/lucide-react/dist/esm/Icon.mjs
|
|
450
|
+
/**
|
|
451
|
+
* @license lucide-react v1.22.0 - ISC
|
|
452
|
+
*
|
|
453
|
+
* This source code is licensed under the ISC license.
|
|
454
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
455
|
+
*/
|
|
456
|
+
var Icon = forwardRef(({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => {
|
|
457
|
+
const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, color: contextColor = "currentColor", className: contextClass = "" } = useLucideContext() ?? {};
|
|
458
|
+
const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
|
|
459
|
+
return createElement("svg", {
|
|
460
|
+
ref,
|
|
461
|
+
...defaultAttributes,
|
|
462
|
+
width: size ?? contextSize ?? defaultAttributes.width,
|
|
463
|
+
height: size ?? contextSize ?? defaultAttributes.height,
|
|
464
|
+
stroke: color ?? contextColor,
|
|
465
|
+
strokeWidth: calculatedStrokeWidth,
|
|
466
|
+
className: mergeClasses("lucide", contextClass, className),
|
|
467
|
+
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
468
|
+
...rest
|
|
469
|
+
}, [...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
|
|
470
|
+
});
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region ../../node_modules/lucide-react/dist/esm/createLucideIcon.mjs
|
|
473
|
+
/**
|
|
474
|
+
* @license lucide-react v1.22.0 - ISC
|
|
475
|
+
*
|
|
476
|
+
* This source code is licensed under the ISC license.
|
|
477
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
478
|
+
*/
|
|
479
|
+
var createLucideIcon = (iconName, iconNode) => {
|
|
480
|
+
const Component = forwardRef(({ className, ...props }, ref) => createElement(Icon, {
|
|
481
|
+
ref,
|
|
482
|
+
iconNode,
|
|
483
|
+
className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
|
|
484
|
+
...props
|
|
485
|
+
}));
|
|
486
|
+
Component.displayName = toPascalCase(iconName);
|
|
487
|
+
return Component;
|
|
446
488
|
};
|
|
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
|
-
|
|
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
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
489
|
+
/**
|
|
490
|
+
* @license lucide-react v1.22.0 - ISC
|
|
491
|
+
*
|
|
492
|
+
* This source code is licensed under the ISC license.
|
|
493
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
494
|
+
*/
|
|
495
|
+
var EyeOff = createLucideIcon("eye-off", [
|
|
496
|
+
["path", {
|
|
497
|
+
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",
|
|
498
|
+
key: "ct8e1f"
|
|
499
|
+
}],
|
|
500
|
+
["path", {
|
|
501
|
+
d: "M14.084 14.158a3 3 0 0 1-4.242-4.242",
|
|
502
|
+
key: "151rxh"
|
|
503
|
+
}],
|
|
504
|
+
["path", {
|
|
505
|
+
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",
|
|
506
|
+
key: "13bj9a"
|
|
507
|
+
}],
|
|
508
|
+
["path", {
|
|
509
|
+
d: "m2 2 20 20",
|
|
510
|
+
key: "1ooewy"
|
|
511
|
+
}]
|
|
512
|
+
]);
|
|
513
|
+
/**
|
|
514
|
+
* @license lucide-react v1.22.0 - ISC
|
|
515
|
+
*
|
|
516
|
+
* This source code is licensed under the ISC license.
|
|
517
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
518
|
+
*/
|
|
519
|
+
var Eye = createLucideIcon("eye", [["path", {
|
|
520
|
+
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",
|
|
521
|
+
key: "1nclc0"
|
|
522
|
+
}], ["circle", {
|
|
523
|
+
cx: "12",
|
|
524
|
+
cy: "12",
|
|
525
|
+
r: "3",
|
|
526
|
+
key: "1v7zrd"
|
|
527
|
+
}]]);
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/components/PasswordInput/index.tsx
|
|
530
|
+
var PasswordInput = (t0) => {
|
|
531
|
+
const $ = c(24);
|
|
532
|
+
const { id, name: t1, className, placeholder, autoComplete: t2 } = t0;
|
|
533
|
+
const name = t1 === void 0 ? "password" : t1;
|
|
534
|
+
const autoComplete = t2 === void 0 ? "current-password" : t2;
|
|
535
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
536
|
+
const { register, formState } = useFormContext();
|
|
537
|
+
const fieldError = formState.errors[name];
|
|
538
|
+
const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
|
|
539
|
+
const inputClassName = className ? `${className} pr-11` : "pr-11";
|
|
540
|
+
const t3 = showPassword ? "text" : "password";
|
|
541
|
+
const t4 = name;
|
|
542
|
+
let t5;
|
|
543
|
+
if ($[0] !== register || $[1] !== t4) {
|
|
544
|
+
t5 = register(t4);
|
|
545
|
+
$[0] = register;
|
|
546
|
+
$[1] = t4;
|
|
547
|
+
$[2] = t5;
|
|
548
|
+
} else t5 = $[2];
|
|
549
|
+
let t6;
|
|
550
|
+
if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
|
|
551
|
+
t6 = /* @__PURE__ */ jsx("input", {
|
|
552
|
+
id,
|
|
553
|
+
type: t3,
|
|
554
|
+
autoComplete,
|
|
555
|
+
className: inputClassName,
|
|
556
|
+
placeholder,
|
|
557
|
+
...t5
|
|
558
|
+
});
|
|
559
|
+
$[3] = autoComplete;
|
|
560
|
+
$[4] = id;
|
|
561
|
+
$[5] = inputClassName;
|
|
562
|
+
$[6] = placeholder;
|
|
563
|
+
$[7] = t3;
|
|
564
|
+
$[8] = t5;
|
|
565
|
+
$[9] = t6;
|
|
566
|
+
} else t6 = $[9];
|
|
567
|
+
let t7;
|
|
568
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
569
|
+
t7 = () => setShowPassword(_temp);
|
|
570
|
+
$[10] = t7;
|
|
571
|
+
} else t7 = $[10];
|
|
572
|
+
const t8 = showPassword ? "Hide characters" : "Show characters";
|
|
573
|
+
let t9;
|
|
574
|
+
if ($[11] !== showPassword) {
|
|
575
|
+
t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, {
|
|
576
|
+
className: "h-5 w-5",
|
|
577
|
+
"aria-hidden": true
|
|
578
|
+
}) : /* @__PURE__ */ jsx(Eye, {
|
|
579
|
+
className: "h-5 w-5",
|
|
580
|
+
"aria-hidden": true
|
|
581
|
+
});
|
|
582
|
+
$[11] = showPassword;
|
|
583
|
+
$[12] = t9;
|
|
584
|
+
} else t9 = $[12];
|
|
585
|
+
let t10;
|
|
586
|
+
if ($[13] !== t8 || $[14] !== t9) {
|
|
587
|
+
t10 = /* @__PURE__ */ jsx("button", {
|
|
588
|
+
type: "button",
|
|
589
|
+
className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500",
|
|
590
|
+
onClick: t7,
|
|
591
|
+
"aria-label": t8,
|
|
592
|
+
children: t9
|
|
593
|
+
});
|
|
594
|
+
$[13] = t8;
|
|
595
|
+
$[14] = t9;
|
|
596
|
+
$[15] = t10;
|
|
597
|
+
} else t10 = $[15];
|
|
598
|
+
let t11;
|
|
599
|
+
if ($[16] !== t10 || $[17] !== t6) {
|
|
600
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
601
|
+
className: "relative",
|
|
602
|
+
children: [t6, t10]
|
|
603
|
+
});
|
|
604
|
+
$[16] = t10;
|
|
605
|
+
$[17] = t6;
|
|
606
|
+
$[18] = t11;
|
|
607
|
+
} else t11 = $[18];
|
|
608
|
+
let t12;
|
|
609
|
+
if ($[19] !== errorMessage) {
|
|
610
|
+
t12 = errorMessage ? /* @__PURE__ */ jsx("p", {
|
|
611
|
+
className: "mt-1 -mb-2 text-sm/6 text-red-500",
|
|
612
|
+
children: errorMessage
|
|
613
|
+
}) : null;
|
|
614
|
+
$[19] = errorMessage;
|
|
615
|
+
$[20] = t12;
|
|
616
|
+
} else t12 = $[20];
|
|
617
|
+
let t13;
|
|
618
|
+
if ($[21] !== t11 || $[22] !== t12) {
|
|
619
|
+
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t12] });
|
|
620
|
+
$[21] = t11;
|
|
621
|
+
$[22] = t12;
|
|
622
|
+
$[23] = t13;
|
|
623
|
+
} else t13 = $[23];
|
|
624
|
+
return t13;
|
|
578
625
|
};
|
|
579
626
|
function _temp(prev) {
|
|
580
|
-
|
|
627
|
+
return !prev;
|
|
581
628
|
}
|
|
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
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
$[11] = remaining;
|
|
654
|
-
$[12] = restart;
|
|
655
|
-
$[13] = t6;
|
|
656
|
-
} else {
|
|
657
|
-
t6 = $[13];
|
|
658
|
-
}
|
|
659
|
-
return t6;
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/components/ResendCodeButton/index.tsx
|
|
631
|
+
var useResendCountdown = (t0, t1) => {
|
|
632
|
+
const $ = c(14);
|
|
633
|
+
const seconds = t0 === void 0 ? 60 : t0;
|
|
634
|
+
const initiallyCountingDown = t1 === void 0 ? true : t1;
|
|
635
|
+
const [remaining, setRemaining] = useState(seconds);
|
|
636
|
+
const [isCountingDown, setIsCountingDown] = useState(initiallyCountingDown);
|
|
637
|
+
let t2;
|
|
638
|
+
let t3;
|
|
639
|
+
if ($[0] !== isCountingDown || $[1] !== seconds) {
|
|
640
|
+
t2 = () => {
|
|
641
|
+
if (!isCountingDown) return;
|
|
642
|
+
const timer = setInterval(() => {
|
|
643
|
+
setRemaining((prev) => {
|
|
644
|
+
if (prev <= 1) {
|
|
645
|
+
setIsCountingDown(false);
|
|
646
|
+
return seconds;
|
|
647
|
+
}
|
|
648
|
+
return prev - 1;
|
|
649
|
+
});
|
|
650
|
+
}, 1e3);
|
|
651
|
+
return () => clearInterval(timer);
|
|
652
|
+
};
|
|
653
|
+
t3 = [isCountingDown, seconds];
|
|
654
|
+
$[0] = isCountingDown;
|
|
655
|
+
$[1] = seconds;
|
|
656
|
+
$[2] = t2;
|
|
657
|
+
$[3] = t3;
|
|
658
|
+
} else {
|
|
659
|
+
t2 = $[2];
|
|
660
|
+
t3 = $[3];
|
|
661
|
+
}
|
|
662
|
+
useEffect(t2, t3);
|
|
663
|
+
let t4;
|
|
664
|
+
if ($[4] !== seconds) {
|
|
665
|
+
t4 = (nextSeconds) => {
|
|
666
|
+
setRemaining(typeof nextSeconds === "number" ? nextSeconds : seconds);
|
|
667
|
+
setIsCountingDown(true);
|
|
668
|
+
};
|
|
669
|
+
$[4] = seconds;
|
|
670
|
+
$[5] = t4;
|
|
671
|
+
} else t4 = $[5];
|
|
672
|
+
const restart = t4;
|
|
673
|
+
const minutes = Math.floor(remaining / 60);
|
|
674
|
+
const secs = remaining % 60;
|
|
675
|
+
let t5;
|
|
676
|
+
if ($[6] !== secs) {
|
|
677
|
+
t5 = secs.toString().padStart(2, "0");
|
|
678
|
+
$[6] = secs;
|
|
679
|
+
$[7] = t5;
|
|
680
|
+
} else t5 = $[7];
|
|
681
|
+
const formatted = `${minutes}:${t5}`;
|
|
682
|
+
const canResend = !isCountingDown;
|
|
683
|
+
let t6;
|
|
684
|
+
if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
|
|
685
|
+
t6 = {
|
|
686
|
+
remaining,
|
|
687
|
+
formatted,
|
|
688
|
+
isCountingDown,
|
|
689
|
+
canResend,
|
|
690
|
+
restart
|
|
691
|
+
};
|
|
692
|
+
$[8] = canResend;
|
|
693
|
+
$[9] = formatted;
|
|
694
|
+
$[10] = isCountingDown;
|
|
695
|
+
$[11] = remaining;
|
|
696
|
+
$[12] = restart;
|
|
697
|
+
$[13] = t6;
|
|
698
|
+
} else t6 = $[13];
|
|
699
|
+
return t6;
|
|
660
700
|
};
|
|
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
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
701
|
+
var ResendCodeButton = ({ seconds = 60, onResend, className, disabled }) => {
|
|
702
|
+
const [isSending, setIsSending] = useState(false);
|
|
703
|
+
const { formatted, isCountingDown, restart, canResend } = useResendCountdown(seconds);
|
|
704
|
+
const handleClick = async () => {
|
|
705
|
+
if (!canResend || isSending || disabled) return;
|
|
706
|
+
try {
|
|
707
|
+
setIsSending(true);
|
|
708
|
+
if (onResend) await onResend();
|
|
709
|
+
} finally {
|
|
710
|
+
restart();
|
|
711
|
+
setIsSending(false);
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
const isDisabled = disabled || isCountingDown || isSending;
|
|
715
|
+
const showCountdown = isDisabled && (isCountingDown || isSending);
|
|
716
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
717
|
+
className: "inline-flex items-center gap-2",
|
|
718
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
719
|
+
type: "button",
|
|
720
|
+
onClick: handleClick,
|
|
721
|
+
disabled: isDisabled,
|
|
722
|
+
"aria-label": "Resend code",
|
|
723
|
+
className: clsx("text-sm font-semibold text-sky-600 hover:underline disabled:cursor-not-allowed disabled:text-gray-400", className),
|
|
724
|
+
children: "Resend code"
|
|
725
|
+
}), showCountdown ? /* @__PURE__ */ jsxs("span", {
|
|
726
|
+
"data-testid": "resend-countdown",
|
|
727
|
+
className: "text-sm text-gray-500",
|
|
728
|
+
"aria-live": "polite",
|
|
729
|
+
children: [
|
|
730
|
+
"(",
|
|
731
|
+
formatted,
|
|
732
|
+
")"
|
|
733
|
+
]
|
|
734
|
+
}) : null]
|
|
735
|
+
});
|
|
696
736
|
};
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
const seconds = typeof value === "number" ? value : Number(value);
|
|
708
|
-
if (!Number.isFinite(seconds) || seconds <= 0) return void 0;
|
|
709
|
-
return Math.ceil(seconds);
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/passwordReset.ts
|
|
739
|
+
var DEFAULT_PASSWORD_RESET_COOLDOWN_SECONDS = 60;
|
|
740
|
+
var PasswordResetCodeRequestError = class extends Error {
|
|
741
|
+
retryAfterSeconds;
|
|
742
|
+
constructor(retryAfterSeconds) {
|
|
743
|
+
super("Unable to request a password reset code");
|
|
744
|
+
this.name = "PasswordResetCodeRequestError";
|
|
745
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
746
|
+
}
|
|
710
747
|
};
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
"Content-Type": "application/json"
|
|
716
|
-
},
|
|
717
|
-
body: JSON.stringify({
|
|
718
|
-
email
|
|
719
|
-
})
|
|
720
|
-
});
|
|
721
|
-
const payload = await response.json().catch(() => null);
|
|
722
|
-
const retryAfterSeconds = parseRetryAfterSeconds(payload?.retryAfterSeconds) ?? parseRetryAfterSeconds(response.headers.get("Retry-After"));
|
|
723
|
-
if (!response.ok || payload?.success !== true) {
|
|
724
|
-
throw new PasswordResetCodeRequestError(retryAfterSeconds);
|
|
725
|
-
}
|
|
726
|
-
return {
|
|
727
|
-
retryAfterSeconds: retryAfterSeconds ?? DEFAULT_PASSWORD_RESET_COOLDOWN_SECONDS
|
|
728
|
-
};
|
|
748
|
+
var parseRetryAfterSeconds = (value) => {
|
|
749
|
+
const seconds = typeof value === "number" ? value : Number(value);
|
|
750
|
+
if (!Number.isFinite(seconds) || seconds <= 0) return void 0;
|
|
751
|
+
return Math.ceil(seconds);
|
|
729
752
|
};
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
setIsResending(true);
|
|
741
|
-
try {
|
|
742
|
-
const result = await requestPasswordResetCode(email);
|
|
743
|
-
countdown.restart(result.retryAfterSeconds);
|
|
744
|
-
return result;
|
|
745
|
-
} catch (error) {
|
|
746
|
-
if (error instanceof PasswordResetCodeRequestError && error.retryAfterSeconds) {
|
|
747
|
-
countdown.restart(error.retryAfterSeconds);
|
|
748
|
-
}
|
|
749
|
-
throw error;
|
|
750
|
-
} finally {
|
|
751
|
-
isResendingRef.current = false;
|
|
752
|
-
setIsResending(false);
|
|
753
|
-
}
|
|
754
|
-
};
|
|
755
|
-
return {
|
|
756
|
-
resend,
|
|
757
|
-
isResending,
|
|
758
|
-
remainingSeconds: countdown.remaining,
|
|
759
|
-
formatted: countdown.formatted,
|
|
760
|
-
isCountingDown: countdown.isCountingDown,
|
|
761
|
-
canResend: Boolean(email) && countdown.canResend && !isResending
|
|
762
|
-
};
|
|
753
|
+
var requestPasswordResetCode = async (email) => {
|
|
754
|
+
const response = await fetch("/api/rb/auth/request-password-reset", {
|
|
755
|
+
method: "POST",
|
|
756
|
+
headers: { "Content-Type": "application/json" },
|
|
757
|
+
body: JSON.stringify({ email })
|
|
758
|
+
});
|
|
759
|
+
const payload = await response.json().catch(() => null);
|
|
760
|
+
const retryAfterSeconds = parseRetryAfterSeconds(payload?.retryAfterSeconds) ?? parseRetryAfterSeconds(response.headers.get("Retry-After"));
|
|
761
|
+
if (!response.ok || payload?.success !== true) throw new PasswordResetCodeRequestError(retryAfterSeconds);
|
|
762
|
+
return { retryAfterSeconds: retryAfterSeconds ?? 60 };
|
|
763
763
|
};
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
764
|
+
var usePasswordResetResend = ({ email, cooldownSeconds = 60 }) => {
|
|
765
|
+
const countdown = useResendCountdown(cooldownSeconds);
|
|
766
|
+
const [isResending, setIsResending] = useState(false);
|
|
767
|
+
const isResendingRef = useRef(false);
|
|
768
|
+
const resend = async () => {
|
|
769
|
+
if (!email || !countdown.canResend || isResendingRef.current) return null;
|
|
770
|
+
isResendingRef.current = true;
|
|
771
|
+
setIsResending(true);
|
|
772
|
+
try {
|
|
773
|
+
const result = await requestPasswordResetCode(email);
|
|
774
|
+
countdown.restart(result.retryAfterSeconds);
|
|
775
|
+
return result;
|
|
776
|
+
} catch (error) {
|
|
777
|
+
if (error instanceof PasswordResetCodeRequestError && error.retryAfterSeconds) countdown.restart(error.retryAfterSeconds);
|
|
778
|
+
throw error;
|
|
779
|
+
} finally {
|
|
780
|
+
isResendingRef.current = false;
|
|
781
|
+
setIsResending(false);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
return {
|
|
785
|
+
resend,
|
|
786
|
+
isResending,
|
|
787
|
+
remainingSeconds: countdown.remaining,
|
|
788
|
+
formatted: countdown.formatted,
|
|
789
|
+
isCountingDown: countdown.isCountingDown,
|
|
790
|
+
canResend: Boolean(email) && countdown.canResend && !isResending
|
|
791
|
+
};
|
|
781
792
|
};
|
|
782
|
-
//#
|
|
793
|
+
//#endregion
|
|
794
|
+
export { AppleSignInButton, AuthLayout, DEFAULT_PASSWORD_RESET_COOLDOWN_SECONDS, EmailInput, PasswordInput, PasswordResetCodeRequestError, RememberMeCheckbox, ResendCodeButton, SignInForm, SignUpForm, redirectAuthMiddleware, requestPasswordResetCode, requireSession, restrictSessionMiddleware, usePasswordResetResend, useResendCountdown };
|
|
795
|
+
|
|
796
|
+
//# sourceMappingURL=index.js.map
|