@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.
Files changed (66) hide show
  1. package/dist/handler-0nKR-P5B.js +84 -0
  2. package/dist/handler-0nKR-P5B.js.map +1 -0
  3. package/dist/handler-B8jPw9zh.js +74 -0
  4. package/dist/handler-B8jPw9zh.js.map +1 -0
  5. package/dist/handler-BGNM_dz1.js +19 -0
  6. package/dist/handler-BGNM_dz1.js.map +1 -0
  7. package/dist/handler-BoWTfKWi.js +56 -0
  8. package/dist/handler-BoWTfKWi.js.map +1 -0
  9. package/dist/handler-ClyVm_Us.js +92 -0
  10. package/dist/handler-ClyVm_Us.js.map +1 -0
  11. package/dist/handler-DNxEmrtP.js +67 -0
  12. package/dist/{handler-B_lItxOC.js.map → handler-DNxEmrtP.js.map} +1 -1
  13. package/dist/handler-DsPS6JXV.js +70 -0
  14. package/dist/handler-DsPS6JXV.js.map +1 -0
  15. package/dist/handler-GKdEwnBO.js +75 -0
  16. package/dist/handler-GKdEwnBO.js.map +1 -0
  17. package/dist/handler-IBGVDW5w.js +125 -0
  18. package/dist/handler-IBGVDW5w.js.map +1 -0
  19. package/dist/handler-J2OwFTyf.js +51 -0
  20. package/dist/handler-J2OwFTyf.js.map +1 -0
  21. package/dist/index.js +770 -756
  22. package/dist/index.js.map +1 -1
  23. package/dist/middleware-BT3Uput1.js +18 -0
  24. package/dist/middleware-BT3Uput1.js.map +1 -0
  25. package/dist/oauth/index.js +636 -761
  26. package/dist/oauth/index.js.map +1 -1
  27. package/dist/routes.js +19 -9
  28. package/dist/routes.js.map +1 -1
  29. package/dist/schemas-BgOpQqUv.js +3988 -0
  30. package/dist/schemas-BgOpQqUv.js.map +1 -0
  31. package/dist/session-BQ06Yo3C.js +20 -0
  32. package/dist/session-BQ06Yo3C.js.map +1 -0
  33. package/dist/sign-in-BG2ND3cO.js +18 -0
  34. package/dist/sign-in-BG2ND3cO.js.map +1 -0
  35. package/dist/sign-up-BCVi8UC9.js +18 -0
  36. package/dist/sign-up-BCVi8UC9.js.map +1 -0
  37. package/package.json +1 -1
  38. package/dist/handler-BBSeVt7x.js +0 -153
  39. package/dist/handler-BBSeVt7x.js.map +0 -1
  40. package/dist/handler-BKSik1j0.js +0 -83
  41. package/dist/handler-BKSik1j0.js.map +0 -1
  42. package/dist/handler-BXvh_Nx4.js +0 -95
  43. package/dist/handler-BXvh_Nx4.js.map +0 -1
  44. package/dist/handler-B_lItxOC.js +0 -66
  45. package/dist/handler-BuwKXMOu.js +0 -24
  46. package/dist/handler-BuwKXMOu.js.map +0 -1
  47. package/dist/handler-C-hPxnHG.js +0 -68
  48. package/dist/handler-C-hPxnHG.js.map +0 -1
  49. package/dist/handler-CoHpAhui.js +0 -81
  50. package/dist/handler-CoHpAhui.js.map +0 -1
  51. package/dist/handler-DfZwgoA4.js +0 -94
  52. package/dist/handler-DfZwgoA4.js.map +0 -1
  53. package/dist/handler-Eyjkxj9l.js +0 -58
  54. package/dist/handler-Eyjkxj9l.js.map +0 -1
  55. package/dist/handler-U3df_2Al.js +0 -59
  56. package/dist/handler-U3df_2Al.js.map +0 -1
  57. package/dist/index-1_ZKABa_.js +0 -20
  58. package/dist/index-1_ZKABa_.js.map +0 -1
  59. package/dist/index-D94-1Zwh.js +0 -20
  60. package/dist/index-D94-1Zwh.js.map +0 -1
  61. package/dist/middleware-8IfSkEEy.js +0 -25
  62. package/dist/middleware-8IfSkEEy.js.map +0 -1
  63. package/dist/schemas--f80aXK7.js +0 -4329
  64. package/dist/schemas--f80aXK7.js.map +0 -1
  65. package/dist/session-DoTNxRRA.js +0 -20
  66. package/dist/session-DoTNxRRA.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,782 +1,796 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
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 { useLocation, Link, useNavigate, useSearchParams } from "@rpcbase/router";
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 { useFormContext, useForm, zodResolver, FormProvider } from "@rpcbase/form";
6
- import { r as requestSchema } from "./index-D94-1Zwh.js";
7
- import { useState, useContext, createContext, forwardRef, createElement, useEffect, useRef } from "react";
8
- import { r as requestSchema$1 } from "./index-1_ZKABa_.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
- }
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
- 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 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", 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;
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
- 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;
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
- 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;
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
- 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;
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
- 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
- }
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
- 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
- ] }) });
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
- 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
- ] }) });
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
- 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;
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
- const mergeClasses = (...classes) => classes.filter((className, index, array) => {
369
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
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
- const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
372
- const toCamelCase = (string) => string.replace(
373
- /^([A-Z])|[\s-_]+(\w)/g,
374
- (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
375
- );
376
- const toPascalCase = (string) => {
377
- const camelCase = toCamelCase(string);
378
- return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
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
- xmlns: "http://www.w3.org/2000/svg",
382
- width: 24,
383
- height: 24,
384
- viewBox: "0 0 24 24",
385
- fill: "none",
386
- stroke: "currentColor",
387
- strokeWidth: 2,
388
- strokeLinecap: "round",
389
- strokeLinejoin: "round"
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
- const hasA11yProp = (props) => {
392
- for (const prop in props) {
393
- if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
394
- return true;
395
- }
396
- }
397
- return false;
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
- const LucideContext = createContext({});
400
- const useLucideContext = () => useContext(LucideContext);
401
- const Icon = forwardRef(
402
- ({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => {
403
- const {
404
- size: contextSize = 24,
405
- strokeWidth: contextStrokeWidth = 2,
406
- absoluteStrokeWidth: contextAbsoluteStrokeWidth = false,
407
- color: contextColor = "currentColor",
408
- className: contextClass = ""
409
- } = useLucideContext() ?? {};
410
- const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
411
- return createElement(
412
- "svg",
413
- {
414
- ref,
415
- ...defaultAttributes,
416
- width: size ?? contextSize ?? defaultAttributes.width,
417
- height: size ?? contextSize ?? defaultAttributes.height,
418
- stroke: color ?? contextColor,
419
- strokeWidth: calculatedStrokeWidth,
420
- className: mergeClasses("lucide", contextClass, className),
421
- ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
422
- ...rest
423
- },
424
- [
425
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
426
- ...Array.isArray(children) ? children : [children]
427
- ]
428
- );
429
- }
430
- );
431
- const createLucideIcon = (iconName, iconNode) => {
432
- const Component = forwardRef(
433
- ({ className, ...props }, ref) => createElement(Icon, {
434
- ref,
435
- iconNode,
436
- className: mergeClasses(
437
- `lucide-${toKebabCase(toPascalCase(iconName))}`,
438
- `lucide-${iconName}`,
439
- className
440
- ),
441
- ...props
442
- })
443
- );
444
- Component.displayName = toPascalCase(iconName);
445
- return Component;
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
- const __iconNode$1 = [
448
- [
449
- "path",
450
- {
451
- 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",
452
- key: "ct8e1f"
453
- }
454
- ],
455
- ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
456
- [
457
- "path",
458
- {
459
- 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",
460
- key: "13bj9a"
461
- }
462
- ],
463
- ["path", { d: "m2 2 20 20", key: "1ooewy" }]
464
- ];
465
- const EyeOff = createLucideIcon("eye-off", __iconNode$1);
466
- const __iconNode = [
467
- [
468
- "path",
469
- {
470
- 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",
471
- key: "1nclc0"
472
- }
473
- ],
474
- ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
475
- ];
476
- const Eye = createLucideIcon("eye", __iconNode);
477
- const PasswordInput = (t0) => {
478
- const $ = c(24);
479
- const {
480
- id,
481
- name: t1,
482
- className,
483
- placeholder,
484
- autoComplete: t2
485
- } = t0;
486
- const name = t1 === void 0 ? "password" : t1;
487
- const autoComplete = t2 === void 0 ? "current-password" : t2;
488
- const [showPassword, setShowPassword] = useState(false);
489
- const {
490
- register,
491
- formState
492
- } = useFormContext();
493
- const fieldError = formState.errors[name];
494
- const errorMessage = typeof fieldError === "string" ? fieldError : typeof fieldError?.message === "string" ? fieldError.message : void 0;
495
- const inputClassName = className ? `${className} pr-11` : "pr-11";
496
- const t3 = showPassword ? "text" : "password";
497
- const t4 = name;
498
- let t5;
499
- if ($[0] !== register || $[1] !== t4) {
500
- t5 = register(t4);
501
- $[0] = register;
502
- $[1] = t4;
503
- $[2] = t5;
504
- } else {
505
- t5 = $[2];
506
- }
507
- let t6;
508
- if ($[3] !== autoComplete || $[4] !== id || $[5] !== inputClassName || $[6] !== placeholder || $[7] !== t3 || $[8] !== t5) {
509
- t6 = /* @__PURE__ */ jsx("input", { id, type: t3, autoComplete, className: inputClassName, placeholder, ...t5 });
510
- $[3] = autoComplete;
511
- $[4] = id;
512
- $[5] = inputClassName;
513
- $[6] = placeholder;
514
- $[7] = t3;
515
- $[8] = t5;
516
- $[9] = t6;
517
- } else {
518
- t6 = $[9];
519
- }
520
- let t7;
521
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
522
- t7 = () => setShowPassword(_temp);
523
- $[10] = t7;
524
- } else {
525
- t7 = $[10];
526
- }
527
- const t8 = showPassword ? "Hide characters" : "Show characters";
528
- let t9;
529
- if ($[11] !== showPassword) {
530
- t9 = showPassword ? /* @__PURE__ */ jsx(EyeOff, { className: "h-5 w-5", "aria-hidden": true }) : /* @__PURE__ */ jsx(Eye, { className: "h-5 w-5", "aria-hidden": true });
531
- $[11] = showPassword;
532
- $[12] = t9;
533
- } else {
534
- t9 = $[12];
535
- }
536
- let t10;
537
- if ($[13] !== t8 || $[14] !== t9) {
538
- t10 = /* @__PURE__ */ jsx("button", { type: "button", className: "absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500", onClick: t7, "aria-label": t8, children: t9 });
539
- $[13] = t8;
540
- $[14] = t9;
541
- $[15] = t10;
542
- } else {
543
- t10 = $[15];
544
- }
545
- let t11;
546
- if ($[16] !== t10 || $[17] !== t6) {
547
- t11 = /* @__PURE__ */ jsxs("div", { className: "relative", children: [
548
- t6,
549
- t10
550
- ] });
551
- $[16] = t10;
552
- $[17] = t6;
553
- $[18] = t11;
554
- } else {
555
- t11 = $[18];
556
- }
557
- let t12;
558
- if ($[19] !== errorMessage) {
559
- t12 = errorMessage ? /* @__PURE__ */ jsx("p", { className: "mt-1 -mb-2 text-sm/6 text-red-500", children: errorMessage }) : null;
560
- $[19] = errorMessage;
561
- $[20] = t12;
562
- } else {
563
- t12 = $[20];
564
- }
565
- let t13;
566
- if ($[21] !== t11 || $[22] !== t12) {
567
- t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
568
- t11,
569
- t12
570
- ] });
571
- $[21] = t11;
572
- $[22] = t12;
573
- $[23] = t13;
574
- } else {
575
- t13 = $[23];
576
- }
577
- return t13;
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
- return !prev;
627
+ return !prev;
581
628
  }
582
- const useResendCountdown = (t0, t1) => {
583
- const $ = c(14);
584
- const seconds = t0 === void 0 ? 60 : t0;
585
- const initiallyCountingDown = t1 === void 0 ? true : t1;
586
- const [remaining, setRemaining] = useState(seconds);
587
- const [isCountingDown, setIsCountingDown] = useState(initiallyCountingDown);
588
- let t2;
589
- let t3;
590
- if ($[0] !== isCountingDown || $[1] !== seconds) {
591
- t2 = () => {
592
- if (!isCountingDown) {
593
- return;
594
- }
595
- const timer = setInterval(() => {
596
- setRemaining((prev) => {
597
- if (prev <= 1) {
598
- setIsCountingDown(false);
599
- return seconds;
600
- }
601
- return prev - 1;
602
- });
603
- }, 1e3);
604
- return () => clearInterval(timer);
605
- };
606
- t3 = [isCountingDown, seconds];
607
- $[0] = isCountingDown;
608
- $[1] = seconds;
609
- $[2] = t2;
610
- $[3] = t3;
611
- } else {
612
- t2 = $[2];
613
- t3 = $[3];
614
- }
615
- useEffect(t2, t3);
616
- let t4;
617
- if ($[4] !== seconds) {
618
- t4 = (nextSeconds) => {
619
- const value = typeof nextSeconds === "number" ? nextSeconds : seconds;
620
- setRemaining(value);
621
- setIsCountingDown(true);
622
- };
623
- $[4] = seconds;
624
- $[5] = t4;
625
- } else {
626
- t4 = $[5];
627
- }
628
- const restart = t4;
629
- const minutes = Math.floor(remaining / 60);
630
- const secs = remaining % 60;
631
- let t5;
632
- if ($[6] !== secs) {
633
- t5 = secs.toString().padStart(2, "0");
634
- $[6] = secs;
635
- $[7] = t5;
636
- } else {
637
- t5 = $[7];
638
- }
639
- const formatted = `${minutes}:${t5}`;
640
- const canResend = !isCountingDown;
641
- let t6;
642
- if ($[8] !== canResend || $[9] !== formatted || $[10] !== isCountingDown || $[11] !== remaining || $[12] !== restart) {
643
- t6 = {
644
- remaining,
645
- formatted,
646
- isCountingDown,
647
- canResend,
648
- restart
649
- };
650
- $[8] = canResend;
651
- $[9] = formatted;
652
- $[10] = isCountingDown;
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
- const ResendCodeButton = ({
662
- seconds = 60,
663
- onResend,
664
- className,
665
- disabled
666
- }) => {
667
- const [isSending, setIsSending] = useState(false);
668
- const {
669
- formatted,
670
- isCountingDown,
671
- restart,
672
- canResend
673
- } = useResendCountdown(seconds);
674
- const handleClick = async () => {
675
- if (!canResend || isSending || disabled) return;
676
- try {
677
- setIsSending(true);
678
- if (onResend) {
679
- await onResend();
680
- }
681
- } finally {
682
- restart();
683
- setIsSending(false);
684
- }
685
- };
686
- const isDisabled = disabled || isCountingDown || isSending;
687
- const showCountdown = isDisabled && (isCountingDown || isSending);
688
- return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
689
- /* @__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" }),
690
- showCountdown ? /* @__PURE__ */ jsxs("span", { "data-testid": "resend-countdown", className: "text-sm text-gray-500", "aria-live": "polite", children: [
691
- "(",
692
- formatted,
693
- ")"
694
- ] }) : null
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
- const DEFAULT_PASSWORD_RESET_COOLDOWN_SECONDS = 60;
698
- class PasswordResetCodeRequestError extends Error {
699
- retryAfterSeconds;
700
- constructor(retryAfterSeconds) {
701
- super("Unable to request a password reset code");
702
- this.name = "PasswordResetCodeRequestError";
703
- this.retryAfterSeconds = retryAfterSeconds;
704
- }
705
- }
706
- const parseRetryAfterSeconds = (value) => {
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
- const requestPasswordResetCode = async (email) => {
712
- const response = await fetch("/api/rb/auth/request-password-reset", {
713
- method: "POST",
714
- headers: {
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
- const usePasswordResetResend = ({
731
- email,
732
- cooldownSeconds = DEFAULT_PASSWORD_RESET_COOLDOWN_SECONDS
733
- }) => {
734
- const countdown = useResendCountdown(cooldownSeconds);
735
- const [isResending, setIsResending] = useState(false);
736
- const isResendingRef = useRef(false);
737
- const resend = async () => {
738
- if (!email || !countdown.canResend || isResendingRef.current) return null;
739
- isResendingRef.current = true;
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
- export {
765
- AppleSignInButton,
766
- AuthLayout,
767
- DEFAULT_PASSWORD_RESET_COOLDOWN_SECONDS,
768
- EmailInput,
769
- PasswordInput,
770
- PasswordResetCodeRequestError,
771
- RememberMeCheckbox,
772
- ResendCodeButton,
773
- SignInForm,
774
- SignUpForm,
775
- r as redirectAuthMiddleware,
776
- requestPasswordResetCode,
777
- a as requireSession,
778
- b as restrictSessionMiddleware,
779
- usePasswordResetResend,
780
- useResendCountdown
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
- //# sourceMappingURL=index.js.map
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