@cedros/login-react 0.0.1 → 0.0.2
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/README.md +142 -2
- package/dist/AuthenticationSettings-CMQhep61.js +9 -0
- package/dist/AuthenticationSettings-CMQhep61.js.map +1 -0
- package/dist/AuthenticationSettings-Cro76kIC.cjs +1 -0
- package/dist/AuthenticationSettings-Cro76kIC.cjs.map +1 -0
- package/dist/CreditSystemSettings-AM7qDk1E.js +9 -0
- package/dist/CreditSystemSettings-AM7qDk1E.js.map +1 -0
- package/dist/CreditSystemSettings-CGR-uzuh.cjs +1 -0
- package/dist/CreditSystemSettings-CGR-uzuh.cjs.map +1 -0
- package/dist/DepositsSection-BVNd63B7.js +47 -0
- package/dist/DepositsSection-BVNd63B7.js.map +1 -0
- package/dist/DepositsSection-Ct1gjgIg.cjs +1 -0
- package/dist/DepositsSection-Ct1gjgIg.cjs.map +1 -0
- package/dist/EmailRegisterForm-B-ys4E3C.cjs +1 -0
- package/dist/EmailRegisterForm-B-ys4E3C.cjs.map +1 -0
- package/dist/EmailRegisterForm-BChCiZ5B.js +961 -0
- package/dist/EmailRegisterForm-BChCiZ5B.js.map +1 -0
- package/dist/EmailSettings-DFZ13JbX.cjs +1 -0
- package/dist/EmailSettings-DFZ13JbX.cjs.map +1 -0
- package/dist/EmailSettings-Di4GSWgb.js +9 -0
- package/dist/EmailSettings-Di4GSWgb.js.map +1 -0
- package/dist/EmbeddedWalletSettings-Cmn_aVL7.js +9 -0
- package/dist/EmbeddedWalletSettings-Cmn_aVL7.js.map +1 -0
- package/dist/EmbeddedWalletSettings-DRWeIJKb.cjs +1 -0
- package/dist/EmbeddedWalletSettings-DRWeIJKb.cjs.map +1 -0
- package/dist/{ErrorMessage-Bm1j5mBT.js → ErrorMessage-C8vKB0JG.js} +9 -9
- package/dist/ErrorMessage-C8vKB0JG.js.map +1 -0
- package/dist/ErrorMessage-CntMyn93.cjs.map +1 -1
- package/dist/{GoogleLoginButton-CvDoOc-0.js → GoogleLoginButton-Ceo2sYvX.js} +1 -1
- package/dist/{GoogleLoginButton-CvDoOc-0.js.map → GoogleLoginButton-Ceo2sYvX.js.map} +1 -1
- package/dist/ServerSettings-D8w8EpoE.cjs +1 -0
- package/dist/ServerSettings-D8w8EpoE.cjs.map +1 -0
- package/dist/ServerSettings-Wg_odW46.js +9 -0
- package/dist/ServerSettings-Wg_odW46.js.map +1 -0
- package/dist/{SolanaLoginButton-h32xN2PQ.js → SolanaLoginButton-CqVOcPa7.js} +1 -1
- package/dist/{SolanaLoginButton-h32xN2PQ.js.map → SolanaLoginButton-CqVOcPa7.js.map} +1 -1
- package/dist/TeamSection-Bj89WSC0.js +128 -0
- package/dist/TeamSection-Bj89WSC0.js.map +1 -0
- package/dist/TeamSection-DQ4nfUHN.cjs +1 -0
- package/dist/TeamSection-DQ4nfUHN.cjs.map +1 -0
- package/dist/UsersSection-BiZceDV3.cjs +1 -0
- package/dist/UsersSection-BiZceDV3.cjs.map +1 -0
- package/dist/UsersSection-W19ddPsw.js +81 -0
- package/dist/UsersSection-W19ddPsw.js.map +1 -0
- package/dist/WebhookSettings-a1c4iMvr.js +9 -0
- package/dist/WebhookSettings-a1c4iMvr.js.map +1 -0
- package/dist/WebhookSettings-onJWLytD.cjs +1 -0
- package/dist/WebhookSettings-onJWLytD.cjs.map +1 -0
- package/dist/WithdrawalsSection-BBw9gWMR.js +20 -0
- package/dist/WithdrawalsSection-BBw9gWMR.js.map +1 -0
- package/dist/WithdrawalsSection-Cws8inf6.cjs +1 -0
- package/dist/WithdrawalsSection-Cws8inf6.cjs.map +1 -0
- package/dist/admin/AdminShell.d.ts +38 -0
- package/dist/admin/icons.d.ts +2 -0
- package/dist/admin/index.d.ts +10 -0
- package/dist/admin/plugin.d.ts +3 -0
- package/dist/admin/sections/AuthenticationSettings.d.ts +3 -0
- package/dist/admin/sections/CreditSystemSettings.d.ts +3 -0
- package/dist/admin/sections/DepositsSection.d.ts +3 -0
- package/dist/admin/sections/EmailSettings.d.ts +3 -0
- package/dist/admin/sections/EmbeddedWalletSettings.d.ts +3 -0
- package/dist/admin/sections/FeatureSettings.d.ts +3 -0
- package/dist/admin/sections/InvitesSection.d.ts +3 -0
- package/dist/admin/sections/MembersSection.d.ts +3 -0
- package/dist/admin/sections/ServerSettings.d.ts +3 -0
- package/dist/admin/sections/SettingsSections.d.ts +7 -0
- package/dist/admin/sections/TeamSection.d.ts +3 -0
- package/dist/admin/sections/UsersSection.d.ts +3 -0
- package/dist/admin/sections/WebhookSettings.d.ts +3 -0
- package/dist/admin/sections/WithdrawalsSection.d.ts +3 -0
- package/dist/admin/types.d.ts +167 -0
- package/dist/components/admin/AdminUserDetail.d.ts +3 -1
- package/dist/components/admin/AdminUserList.d.ts +3 -7
- package/dist/components/admin/CedrosAdminDashboard.d.ts +7 -3
- package/dist/components/admin/PermissionsSection.d.ts +7 -0
- package/dist/components/admin/ProfileDropdown.d.ts +34 -0
- package/dist/components/admin/SetupWizard.d.ts +30 -0
- package/dist/components/admin/StatsBar.d.ts +17 -0
- package/dist/components/admin/settings/AuthenticationSettings.d.ts +4 -0
- package/dist/components/admin/settings/AutosaveStatus.d.ts +6 -0
- package/dist/components/admin/settings/CreditSystemSettings.d.ts +6 -0
- package/dist/components/admin/settings/EmailSettings.d.ts +4 -0
- package/dist/components/admin/settings/EmbeddedWalletSettings.d.ts +4 -0
- package/dist/components/admin/settings/FeatureSettings.d.ts +4 -0
- package/dist/components/admin/settings/MessagingSettings.d.ts +4 -0
- package/dist/components/admin/settings/SecuritySettings.d.ts +4 -0
- package/dist/components/admin/settings/ServerSettings.d.ts +4 -0
- package/dist/components/admin/settings/SettingsPageLayout.d.ts +16 -0
- package/dist/components/admin/settings/SsoProvidersSettings.d.ts +4 -0
- package/dist/components/admin/settings/WebhookSettings.d.ts +4 -0
- package/dist/components/admin/settings/index.d.ts +31 -0
- package/dist/components/admin/settings/settingsInputs.d.ts +79 -0
- package/dist/components/admin/settings/settingsMetadata.d.ts +18 -0
- package/dist/components/deposit/admin/AdminWithdrawalStats.d.ts +10 -0
- package/dist/components/deposit/admin/FeatureDisabledMessage.d.ts +15 -0
- package/dist/components/deposit/admin/featureDisabled.d.ts +9 -0
- package/dist/components/deposit/admin/index.d.ts +5 -0
- package/dist/components/invites/InviteForm.d.ts +1 -1
- package/dist/components/org/OrgSelector.d.ts +2 -1
- package/dist/components/profile/UserProfileSettings.d.ts +35 -0
- package/dist/components/profile/index.d.ts +2 -0
- package/dist/crypto/secureWipe.d.ts +0 -19
- package/dist/crypto/webauthnPrf.d.ts +0 -10
- package/dist/email-only.cjs +1 -1
- package/dist/email-only.js +2 -2
- package/dist/google-only.js +2 -2
- package/dist/hooks/useDashboardPermissions.d.ts +45 -0
- package/dist/hooks/useProfile.d.ts +35 -0
- package/dist/hooks/useServerFeatures.d.ts +55 -0
- package/dist/hooks/useSettingsAutosave.d.ts +29 -0
- package/dist/hooks/useSetup.d.ts +25 -0
- package/dist/hooks/useSsoProviders.d.ts +52 -0
- package/dist/index-BHR_WTP2.js +19636 -0
- package/dist/index-BHR_WTP2.js.map +1 -0
- package/dist/index-JsIJkPin.cjs +2061 -0
- package/dist/index-JsIJkPin.cjs.map +1 -0
- package/dist/index.cjs +1 -2061
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +21 -3
- package/dist/index.js +117 -14908
- package/dist/index.js.map +1 -1
- package/dist/login-react.css +1 -1
- package/dist/silentWalletEnroll-CQK5i65l.js +42 -0
- package/dist/silentWalletEnroll-CQK5i65l.js.map +1 -0
- package/dist/silentWalletEnroll-DBfS2sLe.cjs +1 -0
- package/dist/silentWalletEnroll-DBfS2sLe.cjs.map +1 -0
- package/dist/solana-only.js +2 -2
- package/dist/solanaKeypair-BD7Kq1Mw.js +1932 -0
- package/dist/solanaKeypair-BD7Kq1Mw.js.map +1 -0
- package/dist/solanaKeypair-CBQxm2hw.cjs +1 -0
- package/dist/solanaKeypair-CBQxm2hw.cjs.map +1 -0
- package/dist/types/adminUser.d.ts +56 -0
- package/dist/types/deposit.d.ts +2 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/org.d.ts +34 -2
- package/dist/types/profile.d.ts +56 -0
- package/dist/types/setup.d.ts +45 -0
- package/dist/types/systemSettings.d.ts +5 -1
- package/dist/utils/adminUserApi.d.ts +10 -1
- package/dist/utils/profileApi.d.ts +26 -0
- package/dist/utils/setupApi.d.ts +21 -0
- package/package.json +1 -1
- package/dist/EmailRegisterForm-D_uCEdX9.cjs +0 -1
- package/dist/EmailRegisterForm-D_uCEdX9.cjs.map +0 -1
- package/dist/EmailRegisterForm-m3rX3A6X.js +0 -2923
- package/dist/EmailRegisterForm-m3rX3A6X.js.map +0 -1
- package/dist/ErrorMessage-Bm1j5mBT.js.map +0 -1
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import { jsxs as p, jsx as e, Fragment as U } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Y, useState as v, useCallback as N, useEffect as B, useMemo as z, useId as J } from "react";
|
|
3
|
+
import { u as V, A as H, h as M, L as K, E as Q } from "./ErrorMessage-C8vKB0JG.js";
|
|
4
|
+
import { b as j, v as ie } from "./validation-BebL7hMF.js";
|
|
5
|
+
const le = ["https:"], X = ["javascript:", "data:", "vbscript:", "file:"];
|
|
6
|
+
function Ee(r) {
|
|
7
|
+
if (!r || typeof r != "string")
|
|
8
|
+
return;
|
|
9
|
+
const i = r.trim();
|
|
10
|
+
if (!i)
|
|
11
|
+
return;
|
|
12
|
+
const w = i.toLowerCase();
|
|
13
|
+
for (const s of X)
|
|
14
|
+
if (w.startsWith(s))
|
|
15
|
+
return;
|
|
16
|
+
try {
|
|
17
|
+
const s = new URL(i);
|
|
18
|
+
return le.includes(s.protocol) ? i : void 0;
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function de(r) {
|
|
24
|
+
if (!r || typeof r != "string")
|
|
25
|
+
return;
|
|
26
|
+
const i = r.trim();
|
|
27
|
+
if (!i)
|
|
28
|
+
return;
|
|
29
|
+
const w = i.toLowerCase();
|
|
30
|
+
for (const s of X)
|
|
31
|
+
if (w.startsWith(s))
|
|
32
|
+
return;
|
|
33
|
+
try {
|
|
34
|
+
const s = new URL(i);
|
|
35
|
+
return s.protocol !== "https:" && s.protocol !== "http:" ? void 0 : i;
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function Z(r = {}) {
|
|
41
|
+
const { maxAttempts: i = 5, windowMs: w = 6e4 } = r, s = Y([]), [k, l] = v(!1), [, b] = v(0), d = N(() => {
|
|
42
|
+
b((c) => c + 1);
|
|
43
|
+
}, []), h = N(() => {
|
|
44
|
+
const c = Date.now();
|
|
45
|
+
s.current = s.current.filter((m) => c - m < w);
|
|
46
|
+
}, [w]), f = N(() => {
|
|
47
|
+
h(), l((c) => s.current.length === 0 && c ? !1 : c);
|
|
48
|
+
}, [h]), y = N(() => (h(), Math.max(0, i - s.current.length)), [h, i]), u = N(() => {
|
|
49
|
+
if (h(), s.current.length === 0)
|
|
50
|
+
return 0;
|
|
51
|
+
const m = s.current[0] + w;
|
|
52
|
+
return Math.max(0, m - Date.now());
|
|
53
|
+
}, [h, w]), g = N(() => (h(), s.current.length < i), [h, i]), E = N(() => {
|
|
54
|
+
if (f(), s.current.length >= i) {
|
|
55
|
+
const c = u(), m = Math.ceil(c / 1e3);
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Too many attempts. Please wait ${m} second${m === 1 ? "" : "s"} before trying again.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
s.current.push(Date.now()), l((c) => c || !0), d();
|
|
61
|
+
}, [f, i, u, d]), C = N(() => {
|
|
62
|
+
s.current = [], l((c) => c && !1), d();
|
|
63
|
+
}, [d]);
|
|
64
|
+
return B(() => {
|
|
65
|
+
if (!k) return;
|
|
66
|
+
const c = window.setInterval(() => {
|
|
67
|
+
f(), d();
|
|
68
|
+
}, 1e3);
|
|
69
|
+
return () => {
|
|
70
|
+
window.clearInterval(c);
|
|
71
|
+
};
|
|
72
|
+
}, [k, d, f]), {
|
|
73
|
+
checkLimit: E,
|
|
74
|
+
isAllowed: g,
|
|
75
|
+
getRemainingAttempts: y,
|
|
76
|
+
getTimeUntilReset: u,
|
|
77
|
+
reset: C
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function ue(r) {
|
|
81
|
+
return "mfaRequired" in r && r.mfaRequired === !0;
|
|
82
|
+
}
|
|
83
|
+
function ee() {
|
|
84
|
+
const { config: r, _internal: i } = V(), [w, s] = v(!1), [k, l] = v(null), {
|
|
85
|
+
checkLimit: b,
|
|
86
|
+
getRemainingAttempts: d,
|
|
87
|
+
getTimeUntilReset: h,
|
|
88
|
+
reset: f
|
|
89
|
+
} = Z({ maxAttempts: 5, windowMs: 6e4 }), y = z(
|
|
90
|
+
() => new H({
|
|
91
|
+
baseUrl: r.serverUrl,
|
|
92
|
+
timeoutMs: r.requestTimeout,
|
|
93
|
+
retryAttempts: r.retryAttempts
|
|
94
|
+
}),
|
|
95
|
+
[r.serverUrl, r.requestTimeout, r.retryAttempts]
|
|
96
|
+
), u = r.callbacks, g = r.features?.walletEnrollment !== !1, E = r.serverUrl, C = N(
|
|
97
|
+
async (t, o) => {
|
|
98
|
+
if (!j(t)) {
|
|
99
|
+
const a = {
|
|
100
|
+
code: "VALIDATION_ERROR",
|
|
101
|
+
message: "Please enter a valid email address"
|
|
102
|
+
};
|
|
103
|
+
throw l(a), a;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
b();
|
|
107
|
+
} catch (a) {
|
|
108
|
+
const n = {
|
|
109
|
+
code: "RATE_LIMITED",
|
|
110
|
+
message: a instanceof Error ? a.message : "Too many attempts"
|
|
111
|
+
};
|
|
112
|
+
throw l(n), n;
|
|
113
|
+
}
|
|
114
|
+
s(!0), l(null);
|
|
115
|
+
try {
|
|
116
|
+
const a = await y.post("/login", {
|
|
117
|
+
email: t,
|
|
118
|
+
password: o
|
|
119
|
+
});
|
|
120
|
+
if (ue(a))
|
|
121
|
+
return {
|
|
122
|
+
mfaRequired: !0,
|
|
123
|
+
mfaToken: a.mfaToken,
|
|
124
|
+
email: t,
|
|
125
|
+
userId: a.userId
|
|
126
|
+
};
|
|
127
|
+
const n = a;
|
|
128
|
+
return u?.onLoginSuccess?.(n.user, "email"), i?.handleLoginSuccess(n.user, n.tokens), f(), {
|
|
129
|
+
mfaRequired: !1,
|
|
130
|
+
response: n
|
|
131
|
+
};
|
|
132
|
+
} catch (a) {
|
|
133
|
+
const n = M(a, "Login failed");
|
|
134
|
+
throw l(n), n;
|
|
135
|
+
} finally {
|
|
136
|
+
s(!1);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
[y, u, i, b, f]
|
|
140
|
+
), c = N(
|
|
141
|
+
async (t, o, a) => {
|
|
142
|
+
if (!j(t)) {
|
|
143
|
+
const n = {
|
|
144
|
+
code: "VALIDATION_ERROR",
|
|
145
|
+
message: "Please enter a valid email address"
|
|
146
|
+
};
|
|
147
|
+
throw l(n), n;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
b();
|
|
151
|
+
} catch (n) {
|
|
152
|
+
const L = {
|
|
153
|
+
code: "RATE_LIMITED",
|
|
154
|
+
message: n instanceof Error ? n.message : "Too many attempts"
|
|
155
|
+
};
|
|
156
|
+
throw l(L), L;
|
|
157
|
+
}
|
|
158
|
+
s(!0), l(null);
|
|
159
|
+
try {
|
|
160
|
+
const n = await y.post("/register", { email: t, password: o, name: a });
|
|
161
|
+
if (u?.onLoginSuccess?.(n.user, "email"), i?.handleLoginSuccess(n.user, n.tokens), f(), g) {
|
|
162
|
+
const L = n.tokens?.accessToken ?? "";
|
|
163
|
+
import("./silentWalletEnroll-CQK5i65l.js").then(
|
|
164
|
+
({ silentWalletEnroll: A }) => A({
|
|
165
|
+
password: o,
|
|
166
|
+
serverUrl: E,
|
|
167
|
+
accessToken: L
|
|
168
|
+
})
|
|
169
|
+
).then((A) => {
|
|
170
|
+
A.success || console.warn("[useEmailAuth] Wallet auto-enrollment failed:", A.error);
|
|
171
|
+
}).catch((A) => {
|
|
172
|
+
const I = A instanceof Error ? A.message : "Unknown error";
|
|
173
|
+
console.warn("[useEmailAuth] Wallet auto-enrollment unavailable:", I);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return n;
|
|
177
|
+
} catch (n) {
|
|
178
|
+
const L = M(n, "Registration failed");
|
|
179
|
+
throw l(L), L;
|
|
180
|
+
} finally {
|
|
181
|
+
s(!1);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
[
|
|
185
|
+
y,
|
|
186
|
+
u,
|
|
187
|
+
i,
|
|
188
|
+
b,
|
|
189
|
+
f,
|
|
190
|
+
E,
|
|
191
|
+
g
|
|
192
|
+
]
|
|
193
|
+
), m = N(() => l(null), []);
|
|
194
|
+
return {
|
|
195
|
+
login: C,
|
|
196
|
+
register: c,
|
|
197
|
+
isLoading: w,
|
|
198
|
+
error: k,
|
|
199
|
+
clearError: m,
|
|
200
|
+
// M-10: Point-in-time snapshots for UI display (see interface JSDoc)
|
|
201
|
+
remainingAttempts: d(),
|
|
202
|
+
timeUntilReset: h()
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function me(r) {
|
|
206
|
+
return typeof r == "object" && r !== null && "mfaRequired" in r && r.mfaRequired === !0;
|
|
207
|
+
}
|
|
208
|
+
function he() {
|
|
209
|
+
const { config: r, _internal: i } = V(), [w, s] = v(!1), [k, l] = v(!1), [b, d] = v(null), h = z(
|
|
210
|
+
() => new H({
|
|
211
|
+
baseUrl: r.serverUrl,
|
|
212
|
+
timeoutMs: r.requestTimeout,
|
|
213
|
+
retryAttempts: r.retryAttempts
|
|
214
|
+
}),
|
|
215
|
+
[r.serverUrl, r.requestTimeout, r.retryAttempts]
|
|
216
|
+
), { checkLimit: f, getRemainingAttempts: y } = Z({
|
|
217
|
+
maxAttempts: 3,
|
|
218
|
+
windowMs: 3e5
|
|
219
|
+
}), u = N(
|
|
220
|
+
async (c) => {
|
|
221
|
+
if (!j(c)) {
|
|
222
|
+
const m = {
|
|
223
|
+
code: "VALIDATION_ERROR",
|
|
224
|
+
message: "Please enter a valid email address"
|
|
225
|
+
};
|
|
226
|
+
throw d(m), m;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
f();
|
|
230
|
+
} catch (m) {
|
|
231
|
+
const t = {
|
|
232
|
+
code: "RATE_LIMITED",
|
|
233
|
+
message: m instanceof Error ? m.message : "Too many attempts"
|
|
234
|
+
};
|
|
235
|
+
throw d(t), t;
|
|
236
|
+
}
|
|
237
|
+
s(!0), d(null), l(!1);
|
|
238
|
+
try {
|
|
239
|
+
await h.post("/instant-link", { email: c }), l(!0);
|
|
240
|
+
} catch (m) {
|
|
241
|
+
const t = M(m, "Failed to send sign-in link");
|
|
242
|
+
throw d(t), t;
|
|
243
|
+
} finally {
|
|
244
|
+
s(!1);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
[h, f]
|
|
248
|
+
), g = N(
|
|
249
|
+
async (c) => {
|
|
250
|
+
if (!c || c.trim().length === 0) {
|
|
251
|
+
const m = {
|
|
252
|
+
code: "VALIDATION_ERROR",
|
|
253
|
+
message: "Invalid or missing sign-in link token"
|
|
254
|
+
};
|
|
255
|
+
throw d(m), m;
|
|
256
|
+
}
|
|
257
|
+
s(!0), d(null), l(!1);
|
|
258
|
+
try {
|
|
259
|
+
const m = await h.post(
|
|
260
|
+
"/instant-link/verify",
|
|
261
|
+
{
|
|
262
|
+
token: c
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
return me(m) || (r.callbacks?.onLoginSuccess?.(m.user, "email"), i?.handleLoginSuccess(m.user, m.tokens)), m;
|
|
266
|
+
} catch (m) {
|
|
267
|
+
const t = M(m, "Failed to verify sign-in link");
|
|
268
|
+
throw d(t), t;
|
|
269
|
+
} finally {
|
|
270
|
+
s(!1);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
[h, r.callbacks, i]
|
|
274
|
+
), E = N(() => d(null), []), C = N(() => {
|
|
275
|
+
d(null), l(!1), s(!1);
|
|
276
|
+
}, []);
|
|
277
|
+
return {
|
|
278
|
+
sendInstantLink: u,
|
|
279
|
+
verifyInstantLink: g,
|
|
280
|
+
isLoading: w,
|
|
281
|
+
isSuccess: k,
|
|
282
|
+
error: b,
|
|
283
|
+
clearError: E,
|
|
284
|
+
reset: C,
|
|
285
|
+
remainingAttempts: y()
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function te({
|
|
289
|
+
label: r = "Password",
|
|
290
|
+
labelAction: i,
|
|
291
|
+
showStrengthMeter: w = !1,
|
|
292
|
+
onValidationChange: s,
|
|
293
|
+
error: k,
|
|
294
|
+
className: l = "",
|
|
295
|
+
onChange: b,
|
|
296
|
+
value: d,
|
|
297
|
+
...h
|
|
298
|
+
}) {
|
|
299
|
+
const [f, y] = v(!1), [u, g] = v(null), E = J(), C = (m) => {
|
|
300
|
+
const t = m.target.value;
|
|
301
|
+
if (w || s) {
|
|
302
|
+
const o = ie(t);
|
|
303
|
+
g(o), s?.(o);
|
|
304
|
+
}
|
|
305
|
+
b?.(m);
|
|
306
|
+
}, c = {
|
|
307
|
+
weak: "var(--cedros-destructive, #ef4444)",
|
|
308
|
+
fair: "var(--cedros-warning, #f59e0b)",
|
|
309
|
+
good: "var(--cedros-success, #22c55e)",
|
|
310
|
+
strong: "var(--cedros-success, #22c55e)"
|
|
311
|
+
};
|
|
312
|
+
return /* @__PURE__ */ p("div", { className: `cedros-password-input ${l}`, children: [
|
|
313
|
+
/* @__PURE__ */ p("div", { className: "cedros-label-row", children: [
|
|
314
|
+
/* @__PURE__ */ e("label", { htmlFor: E, className: "cedros-label", children: r }),
|
|
315
|
+
i
|
|
316
|
+
] }),
|
|
317
|
+
/* @__PURE__ */ p("div", { className: "cedros-password-wrapper", children: [
|
|
318
|
+
/* @__PURE__ */ e(
|
|
319
|
+
"input",
|
|
320
|
+
{
|
|
321
|
+
id: E,
|
|
322
|
+
type: f ? "text" : "password",
|
|
323
|
+
className: "cedros-input",
|
|
324
|
+
onChange: C,
|
|
325
|
+
value: d,
|
|
326
|
+
"aria-invalid": k ? "true" : void 0,
|
|
327
|
+
"aria-describedby": k ? `${E}-error` : void 0,
|
|
328
|
+
...h
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
/* @__PURE__ */ e(
|
|
332
|
+
"button",
|
|
333
|
+
{
|
|
334
|
+
type: "button",
|
|
335
|
+
className: "cedros-password-toggle",
|
|
336
|
+
onClick: () => y(!f),
|
|
337
|
+
"aria-label": f ? "Hide password" : "Show password",
|
|
338
|
+
"aria-pressed": f,
|
|
339
|
+
children: f ? /* @__PURE__ */ p("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
340
|
+
/* @__PURE__ */ e(
|
|
341
|
+
"path",
|
|
342
|
+
{
|
|
343
|
+
d: "M2.5 10s3-6 7.5-6 7.5 6 7.5 6-3 6-7.5 6-7.5-6-7.5-6z",
|
|
344
|
+
stroke: "currentColor",
|
|
345
|
+
strokeWidth: "1.5"
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
/* @__PURE__ */ e("circle", { cx: "10", cy: "10", r: "2.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
349
|
+
/* @__PURE__ */ e("path", { d: "M3 17L17 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
350
|
+
] }) : /* @__PURE__ */ p("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
351
|
+
/* @__PURE__ */ e(
|
|
352
|
+
"path",
|
|
353
|
+
{
|
|
354
|
+
d: "M2.5 10s3-6 7.5-6 7.5 6 7.5 6-3 6-7.5 6-7.5-6-7.5-6z",
|
|
355
|
+
stroke: "currentColor",
|
|
356
|
+
strokeWidth: "1.5"
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
/* @__PURE__ */ e("circle", { cx: "10", cy: "10", r: "2.5", stroke: "currentColor", strokeWidth: "1.5" })
|
|
360
|
+
] })
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
] }),
|
|
364
|
+
k && /* @__PURE__ */ e("p", { id: `${E}-error`, className: "cedros-input-error", children: k }),
|
|
365
|
+
w && u && d?.length > 0 && /* @__PURE__ */ p("div", { className: "cedros-password-strength", children: [
|
|
366
|
+
/* @__PURE__ */ e("div", { className: "cedros-strength-bar", children: /* @__PURE__ */ e(
|
|
367
|
+
"div",
|
|
368
|
+
{
|
|
369
|
+
className: "cedros-strength-fill",
|
|
370
|
+
style: {
|
|
371
|
+
width: `${u.strength === "weak" ? 25 : u.strength === "fair" ? 50 : u.strength === "good" ? 75 : 100}%`,
|
|
372
|
+
backgroundColor: c[u.strength]
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
) }),
|
|
376
|
+
/* @__PURE__ */ e("span", { className: "cedros-strength-label", children: u.strength })
|
|
377
|
+
] })
|
|
378
|
+
] });
|
|
379
|
+
}
|
|
380
|
+
function pe() {
|
|
381
|
+
const { config: r, _internal: i } = V(), [w, s] = v("idle"), [k, l] = v(!1), [b, d] = v(null), {
|
|
382
|
+
checkLimit: h,
|
|
383
|
+
getRemainingAttempts: f,
|
|
384
|
+
getTimeUntilReset: y,
|
|
385
|
+
reset: u
|
|
386
|
+
} = Z({ maxAttempts: 5, windowMs: 12e4 }), g = z(
|
|
387
|
+
() => new H({
|
|
388
|
+
baseUrl: r.serverUrl,
|
|
389
|
+
timeoutMs: r.requestTimeout,
|
|
390
|
+
retryAttempts: r.retryAttempts
|
|
391
|
+
}),
|
|
392
|
+
[r.serverUrl, r.requestTimeout, r.retryAttempts]
|
|
393
|
+
), E = N(
|
|
394
|
+
async (m, t) => {
|
|
395
|
+
const o = /^[A-Z0-9]{16}$/i.test(t) || /^[A-Z0-9]{4}(-[A-Z0-9]{4}){3}$/i.test(t);
|
|
396
|
+
if (!(/^\d{6}$/.test(t) || o)) {
|
|
397
|
+
const n = {
|
|
398
|
+
code: "VALIDATION_ERROR",
|
|
399
|
+
message: "Please enter a valid 6-digit code or recovery code"
|
|
400
|
+
};
|
|
401
|
+
throw d(n), n;
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
h();
|
|
405
|
+
} catch (n) {
|
|
406
|
+
const L = {
|
|
407
|
+
code: "RATE_LIMITED",
|
|
408
|
+
message: n instanceof Error ? n.message : "Too many attempts"
|
|
409
|
+
};
|
|
410
|
+
throw d(L), L;
|
|
411
|
+
}
|
|
412
|
+
l(!0), d(null), s("verifying");
|
|
413
|
+
try {
|
|
414
|
+
const n = await g.post("/login/mfa", { mfaToken: m, code: t });
|
|
415
|
+
return s("success"), u(), i && n.user && n.tokens && i.handleLoginSuccess(n.user, n.tokens), n;
|
|
416
|
+
} catch (n) {
|
|
417
|
+
const L = M(n, "Invalid verification code");
|
|
418
|
+
throw d(L), s("error"), L;
|
|
419
|
+
} finally {
|
|
420
|
+
l(!1);
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
[g, i, h, u]
|
|
424
|
+
), C = N(() => d(null), []), c = N(() => {
|
|
425
|
+
d(null), s("idle"), l(!1);
|
|
426
|
+
}, []);
|
|
427
|
+
return {
|
|
428
|
+
state: w,
|
|
429
|
+
isLoading: k,
|
|
430
|
+
error: b,
|
|
431
|
+
verifyTotp: E,
|
|
432
|
+
clearError: C,
|
|
433
|
+
reset: c,
|
|
434
|
+
// Point-in-time snapshots for UI display
|
|
435
|
+
remainingAttempts: f(),
|
|
436
|
+
timeUntilReset: y()
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
const T = 6;
|
|
440
|
+
function fe({
|
|
441
|
+
value: r = "",
|
|
442
|
+
onChange: i,
|
|
443
|
+
onComplete: w,
|
|
444
|
+
disabled: s = !1,
|
|
445
|
+
error: k,
|
|
446
|
+
autoFocus: l = !1,
|
|
447
|
+
className: b = ""
|
|
448
|
+
}) {
|
|
449
|
+
const d = Y([]), [h, f] = v(r.padEnd(T, "")), y = J();
|
|
450
|
+
B(() => {
|
|
451
|
+
f(r.padEnd(T, ""));
|
|
452
|
+
}, [r]);
|
|
453
|
+
const u = N((t) => {
|
|
454
|
+
t >= 0 && t < T && d.current[t]?.focus();
|
|
455
|
+
}, []), g = N(
|
|
456
|
+
(t) => {
|
|
457
|
+
const o = t.replace(/\D/g, "").slice(0, T);
|
|
458
|
+
f(o.padEnd(T, "")), i?.(o), o.length === T && w?.(o);
|
|
459
|
+
},
|
|
460
|
+
[i, w]
|
|
461
|
+
), E = N(
|
|
462
|
+
(t, o) => {
|
|
463
|
+
if (!/^\d?$/.test(o)) return;
|
|
464
|
+
const a = h.split("");
|
|
465
|
+
a[t] = o;
|
|
466
|
+
const n = a.join("").replace(/ /g, "");
|
|
467
|
+
g(n), o && t < T - 1 && u(t + 1);
|
|
468
|
+
},
|
|
469
|
+
[h, g, u]
|
|
470
|
+
), C = N(
|
|
471
|
+
(t, o) => {
|
|
472
|
+
if (o.key === "Backspace") {
|
|
473
|
+
o.preventDefault();
|
|
474
|
+
const a = h.split("");
|
|
475
|
+
a[t] && a[t] !== " " ? (a[t] = " ", g(a.join("").replace(/ /g, ""))) : t > 0 && (a[t - 1] = " ", g(a.join("").replace(/ /g, "")), u(t - 1));
|
|
476
|
+
} else o.key === "ArrowLeft" && t > 0 ? (o.preventDefault(), u(t - 1)) : o.key === "ArrowRight" && t < T - 1 && (o.preventDefault(), u(t + 1));
|
|
477
|
+
},
|
|
478
|
+
[h, g, u]
|
|
479
|
+
), c = N(
|
|
480
|
+
(t) => {
|
|
481
|
+
t.preventDefault();
|
|
482
|
+
const a = t.clipboardData.getData("text").replace(/\D/g, "").slice(0, T);
|
|
483
|
+
a && (g(a), u(Math.min(a.length, T - 1)));
|
|
484
|
+
},
|
|
485
|
+
[g, u]
|
|
486
|
+
), m = N((t) => {
|
|
487
|
+
t.target.select();
|
|
488
|
+
}, []);
|
|
489
|
+
return B(() => {
|
|
490
|
+
l && !s && d.current[0]?.focus();
|
|
491
|
+
}, [l, s]), /* @__PURE__ */ p("div", { className: `cedros-otp-input ${b}`, children: [
|
|
492
|
+
/* @__PURE__ */ e("div", { className: "cedros-otp-slots", role: "group", "aria-label": "One-time password", children: Array.from({ length: T }).map((t, o) => /* @__PURE__ */ e(
|
|
493
|
+
"input",
|
|
494
|
+
{
|
|
495
|
+
ref: (a) => {
|
|
496
|
+
d.current[o] = a;
|
|
497
|
+
},
|
|
498
|
+
id: `${y}-${o}`,
|
|
499
|
+
type: "text",
|
|
500
|
+
inputMode: "numeric",
|
|
501
|
+
pattern: "[0-9]*",
|
|
502
|
+
maxLength: 1,
|
|
503
|
+
className: `cedros-otp-slot ${k ? "cedros-otp-slot-error" : ""}`,
|
|
504
|
+
value: h[o] === " " ? "" : h[o] || "",
|
|
505
|
+
onChange: (a) => E(o, a.target.value),
|
|
506
|
+
onKeyDown: (a) => C(o, a),
|
|
507
|
+
onPaste: c,
|
|
508
|
+
onFocus: m,
|
|
509
|
+
disabled: s,
|
|
510
|
+
autoComplete: "one-time-code",
|
|
511
|
+
"aria-label": `Digit ${o + 1}`,
|
|
512
|
+
"aria-invalid": k ? "true" : void 0
|
|
513
|
+
},
|
|
514
|
+
o
|
|
515
|
+
)) }),
|
|
516
|
+
k && /* @__PURE__ */ e("p", { className: "cedros-otp-error", role: "alert", children: k })
|
|
517
|
+
] });
|
|
518
|
+
}
|
|
519
|
+
function ge({
|
|
520
|
+
mfaToken: r,
|
|
521
|
+
email: i,
|
|
522
|
+
onSuccess: w,
|
|
523
|
+
onBack: s,
|
|
524
|
+
className: k = ""
|
|
525
|
+
}) {
|
|
526
|
+
const { verifyTotp: l, isLoading: b, error: d, clearError: h } = pe(), [f, y] = v(""), [u, g] = v(!1), [E, C] = v(""), c = async (o) => {
|
|
527
|
+
const a = o || (u ? E : f);
|
|
528
|
+
if (a)
|
|
529
|
+
try {
|
|
530
|
+
await l(r, a), w?.();
|
|
531
|
+
} catch {
|
|
532
|
+
u ? C("") : y("");
|
|
533
|
+
}
|
|
534
|
+
}, m = (o) => {
|
|
535
|
+
c(o);
|
|
536
|
+
}, t = () => {
|
|
537
|
+
g(!u), h(), y(""), C("");
|
|
538
|
+
};
|
|
539
|
+
return /* @__PURE__ */ p("div", { className: `cedros-totp-verify ${k}`, children: [
|
|
540
|
+
/* @__PURE__ */ p("div", { className: "cedros-totp-verify-header", children: [
|
|
541
|
+
/* @__PURE__ */ p(
|
|
542
|
+
"svg",
|
|
543
|
+
{
|
|
544
|
+
className: "cedros-totp-verify-icon",
|
|
545
|
+
width: "48",
|
|
546
|
+
height: "48",
|
|
547
|
+
viewBox: "0 0 48 48",
|
|
548
|
+
fill: "none",
|
|
549
|
+
"aria-hidden": "true",
|
|
550
|
+
children: [
|
|
551
|
+
/* @__PURE__ */ e("rect", { x: "8", y: "20", width: "32", height: "24", rx: "4", stroke: "currentColor", strokeWidth: "2" }),
|
|
552
|
+
/* @__PURE__ */ e(
|
|
553
|
+
"path",
|
|
554
|
+
{
|
|
555
|
+
d: "M16 20V14a8 8 0 1 1 16 0v6",
|
|
556
|
+
stroke: "currentColor",
|
|
557
|
+
strokeWidth: "2",
|
|
558
|
+
strokeLinecap: "round"
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ e("circle", { cx: "24", cy: "32", r: "3", fill: "currentColor" })
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ e("h3", { className: "cedros-totp-title", children: "Two-factor authentication" }),
|
|
566
|
+
/* @__PURE__ */ e("p", { className: "cedros-totp-description", children: u ? "Enter one of your recovery codes to sign in." : "Enter the 6-digit code from your authenticator app." }),
|
|
567
|
+
i && /* @__PURE__ */ e("p", { className: "cedros-totp-email", children: i })
|
|
568
|
+
] }),
|
|
569
|
+
u ? /* @__PURE__ */ p("div", { className: "cedros-totp-backup-input", children: [
|
|
570
|
+
/* @__PURE__ */ e(
|
|
571
|
+
"input",
|
|
572
|
+
{
|
|
573
|
+
type: "text",
|
|
574
|
+
className: `cedros-input ${d ? "cedros-input-error" : ""}`,
|
|
575
|
+
placeholder: "Enter recovery code",
|
|
576
|
+
value: E,
|
|
577
|
+
onChange: (o) => {
|
|
578
|
+
C(o.target.value.toUpperCase()), h();
|
|
579
|
+
},
|
|
580
|
+
onKeyDown: (o) => {
|
|
581
|
+
o.key === "Enter" && E && c();
|
|
582
|
+
},
|
|
583
|
+
disabled: b,
|
|
584
|
+
autoFocus: !0,
|
|
585
|
+
autoComplete: "one-time-code"
|
|
586
|
+
}
|
|
587
|
+
),
|
|
588
|
+
d && /* @__PURE__ */ e("p", { className: "cedros-input-error", role: "alert", children: d.message })
|
|
589
|
+
] }) : /* @__PURE__ */ e(
|
|
590
|
+
fe,
|
|
591
|
+
{
|
|
592
|
+
value: f,
|
|
593
|
+
onChange: (o) => {
|
|
594
|
+
y(o), h();
|
|
595
|
+
},
|
|
596
|
+
onComplete: m,
|
|
597
|
+
disabled: b,
|
|
598
|
+
error: d?.message,
|
|
599
|
+
autoFocus: !0
|
|
600
|
+
}
|
|
601
|
+
),
|
|
602
|
+
/* @__PURE__ */ e(
|
|
603
|
+
"button",
|
|
604
|
+
{
|
|
605
|
+
type: "button",
|
|
606
|
+
className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
|
|
607
|
+
onClick: () => c(),
|
|
608
|
+
disabled: b || (u ? !E : f.length !== 6),
|
|
609
|
+
children: b ? /* @__PURE__ */ p(U, { children: [
|
|
610
|
+
/* @__PURE__ */ e(K, { size: "sm" }),
|
|
611
|
+
/* @__PURE__ */ e("span", { children: "Verifying..." })
|
|
612
|
+
] }) : "Verify"
|
|
613
|
+
}
|
|
614
|
+
),
|
|
615
|
+
/* @__PURE__ */ p("div", { className: "cedros-totp-verify-footer", children: [
|
|
616
|
+
/* @__PURE__ */ e(
|
|
617
|
+
"button",
|
|
618
|
+
{
|
|
619
|
+
type: "button",
|
|
620
|
+
className: "cedros-link cedros-link-sm",
|
|
621
|
+
onClick: t,
|
|
622
|
+
disabled: b,
|
|
623
|
+
children: u ? "Use authenticator app" : "Use a recovery code"
|
|
624
|
+
}
|
|
625
|
+
),
|
|
626
|
+
s && /* @__PURE__ */ p(U, { children: [
|
|
627
|
+
/* @__PURE__ */ e("span", { className: "cedros-totp-verify-divider", children: "•" }),
|
|
628
|
+
/* @__PURE__ */ e(
|
|
629
|
+
"button",
|
|
630
|
+
{
|
|
631
|
+
type: "button",
|
|
632
|
+
className: "cedros-link cedros-link-sm",
|
|
633
|
+
onClick: s,
|
|
634
|
+
disabled: b,
|
|
635
|
+
children: "Back to login"
|
|
636
|
+
}
|
|
637
|
+
)
|
|
638
|
+
] })
|
|
639
|
+
] })
|
|
640
|
+
] });
|
|
641
|
+
}
|
|
642
|
+
function Ce({
|
|
643
|
+
onSuccess: r,
|
|
644
|
+
onSwitchToRegister: i,
|
|
645
|
+
onForgotPassword: w,
|
|
646
|
+
className: s = ""
|
|
647
|
+
}) {
|
|
648
|
+
const { config: k } = V(), { login: l, isLoading: b, error: d, clearError: h } = ee(), {
|
|
649
|
+
sendInstantLink: f,
|
|
650
|
+
isLoading: y,
|
|
651
|
+
isSuccess: u,
|
|
652
|
+
error: g,
|
|
653
|
+
clearError: E,
|
|
654
|
+
reset: C
|
|
655
|
+
} = he(), [c, m] = v(""), [t, o] = v(""), [a, n] = v(null), [L, A] = v(""), I = k.forms?.forgotPassword?.mode ?? "reset", $ = async (S) => {
|
|
656
|
+
S.preventDefault();
|
|
657
|
+
try {
|
|
658
|
+
const O = await l(c, t);
|
|
659
|
+
O.mfaRequired ? (n(O.mfaToken), A(O.email)) : r?.();
|
|
660
|
+
} catch {
|
|
661
|
+
}
|
|
662
|
+
}, q = () => {
|
|
663
|
+
n(null), A(""), r?.();
|
|
664
|
+
}, _ = () => {
|
|
665
|
+
n(null), A(""), o("");
|
|
666
|
+
}, P = async () => {
|
|
667
|
+
if (I === "instantLink")
|
|
668
|
+
try {
|
|
669
|
+
await f(c);
|
|
670
|
+
} catch {
|
|
671
|
+
}
|
|
672
|
+
else
|
|
673
|
+
w?.();
|
|
674
|
+
};
|
|
675
|
+
if (a)
|
|
676
|
+
return /* @__PURE__ */ e(
|
|
677
|
+
ge,
|
|
678
|
+
{
|
|
679
|
+
mfaToken: a,
|
|
680
|
+
email: L,
|
|
681
|
+
onSuccess: q,
|
|
682
|
+
onBack: _,
|
|
683
|
+
className: s
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
if (u)
|
|
687
|
+
return /* @__PURE__ */ p("div", { className: `cedros-instant-link-success ${s}`, children: [
|
|
688
|
+
/* @__PURE__ */ p(
|
|
689
|
+
"svg",
|
|
690
|
+
{
|
|
691
|
+
className: "cedros-success-icon",
|
|
692
|
+
width: "48",
|
|
693
|
+
height: "48",
|
|
694
|
+
viewBox: "0 0 48 48",
|
|
695
|
+
fill: "none",
|
|
696
|
+
"aria-hidden": "true",
|
|
697
|
+
children: [
|
|
698
|
+
/* @__PURE__ */ e("circle", { cx: "24", cy: "24", r: "22", stroke: "currentColor", strokeWidth: "2" }),
|
|
699
|
+
/* @__PURE__ */ e(
|
|
700
|
+
"path",
|
|
701
|
+
{
|
|
702
|
+
d: "M14 24l7 7 13-13",
|
|
703
|
+
stroke: "currentColor",
|
|
704
|
+
strokeWidth: "2",
|
|
705
|
+
strokeLinecap: "round",
|
|
706
|
+
strokeLinejoin: "round"
|
|
707
|
+
}
|
|
708
|
+
)
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
),
|
|
712
|
+
/* @__PURE__ */ e("h3", { className: "cedros-success-title", children: "Check your email" }),
|
|
713
|
+
/* @__PURE__ */ p("p", { className: "cedros-success-message", children: [
|
|
714
|
+
"We sent a sign-in link to ",
|
|
715
|
+
/* @__PURE__ */ e("strong", { children: c }),
|
|
716
|
+
". Click the link to sign in."
|
|
717
|
+
] }),
|
|
718
|
+
/* @__PURE__ */ e(
|
|
719
|
+
"button",
|
|
720
|
+
{
|
|
721
|
+
type: "button",
|
|
722
|
+
className: "cedros-button cedros-button-md cedros-button-outline",
|
|
723
|
+
onClick: C,
|
|
724
|
+
children: "Back to login"
|
|
725
|
+
}
|
|
726
|
+
)
|
|
727
|
+
] });
|
|
728
|
+
const F = d || g, W = () => {
|
|
729
|
+
h(), E();
|
|
730
|
+
}, D = b || y;
|
|
731
|
+
return /* @__PURE__ */ p("form", { onSubmit: $, className: `cedros-form ${s}`, children: [
|
|
732
|
+
/* @__PURE__ */ p("div", { className: "cedros-form-field", children: [
|
|
733
|
+
/* @__PURE__ */ e("label", { htmlFor: "email", className: "cedros-label", children: "Email" }),
|
|
734
|
+
/* @__PURE__ */ e(
|
|
735
|
+
"input",
|
|
736
|
+
{
|
|
737
|
+
id: "email",
|
|
738
|
+
type: "email",
|
|
739
|
+
className: "cedros-input",
|
|
740
|
+
value: c,
|
|
741
|
+
onChange: (S) => m(S.target.value),
|
|
742
|
+
placeholder: "you@example.com",
|
|
743
|
+
required: !0,
|
|
744
|
+
"aria-required": "true",
|
|
745
|
+
autoComplete: "email",
|
|
746
|
+
disabled: D
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
] }),
|
|
750
|
+
/* @__PURE__ */ e("div", { className: "cedros-form-field", children: /* @__PURE__ */ e(
|
|
751
|
+
te,
|
|
752
|
+
{
|
|
753
|
+
value: t,
|
|
754
|
+
onChange: (S) => o(S.target.value),
|
|
755
|
+
placeholder: "Enter your password",
|
|
756
|
+
required: !0,
|
|
757
|
+
autoComplete: "current-password",
|
|
758
|
+
disabled: D,
|
|
759
|
+
labelAction: w || I === "instantLink" ? /* @__PURE__ */ e(
|
|
760
|
+
"button",
|
|
761
|
+
{
|
|
762
|
+
type: "button",
|
|
763
|
+
className: "cedros-link cedros-link-sm",
|
|
764
|
+
onClick: P,
|
|
765
|
+
disabled: y,
|
|
766
|
+
children: y ? "Sending..." : "Forgot your password?"
|
|
767
|
+
}
|
|
768
|
+
) : void 0
|
|
769
|
+
}
|
|
770
|
+
) }),
|
|
771
|
+
/* @__PURE__ */ e(Q, { error: F, onDismiss: W }),
|
|
772
|
+
/* @__PURE__ */ e(
|
|
773
|
+
"button",
|
|
774
|
+
{
|
|
775
|
+
type: "submit",
|
|
776
|
+
className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
|
|
777
|
+
disabled: D || !c || !t,
|
|
778
|
+
"aria-busy": b,
|
|
779
|
+
children: b ? /* @__PURE__ */ p(U, { children: [
|
|
780
|
+
/* @__PURE__ */ e(K, { size: "sm", announce: !0, label: "Signing in" }),
|
|
781
|
+
/* @__PURE__ */ e("span", { children: "Signing in..." })
|
|
782
|
+
] }) : "Sign in"
|
|
783
|
+
}
|
|
784
|
+
),
|
|
785
|
+
i && /* @__PURE__ */ p("p", { className: "cedros-form-footer", children: [
|
|
786
|
+
"Don't have an account?",
|
|
787
|
+
" ",
|
|
788
|
+
/* @__PURE__ */ e("button", { type: "button", className: "cedros-link", onClick: i, children: "Sign up" })
|
|
789
|
+
] })
|
|
790
|
+
] });
|
|
791
|
+
}
|
|
792
|
+
function Ne({
|
|
793
|
+
onSuccess: r,
|
|
794
|
+
onSwitchToLogin: i,
|
|
795
|
+
className: w = ""
|
|
796
|
+
}) {
|
|
797
|
+
const { config: s } = V(), { register: k, isLoading: l, error: b, clearError: d } = ee(), [h, f] = v(""), [y, u] = v(""), [g, E] = v(""), [C, c] = v(""), [m, t] = v(null), [o, a] = v(null), n = s.forms?.termsOfService, L = s.forms?.emailOptIn, A = n?.show ?? !1, I = n?.required ?? !0, $ = n?.defaultChecked ?? !1, q = n?.label ?? "I agree to the Terms of Service", _ = n?.url, P = de(_), F = L?.show ?? !1, W = L?.defaultChecked ?? !1, D = L?.label ?? "Send me updates and news", [S, O] = v($), [re, se] = v(W), x = g === C, oe = m?.isValid ?? !1, G = y && g && C && x && oe && (!A || !I || S) && !l, ne = async (R) => {
|
|
798
|
+
if (R.preventDefault(), a(null), A && I && !S) {
|
|
799
|
+
a({
|
|
800
|
+
code: "VALIDATION_ERROR",
|
|
801
|
+
message: "You must agree to the Terms of Service to continue"
|
|
802
|
+
});
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
if (G)
|
|
806
|
+
try {
|
|
807
|
+
await k(y, g, h || void 0), r?.();
|
|
808
|
+
} catch {
|
|
809
|
+
}
|
|
810
|
+
}, ae = b || o, ce = () => {
|
|
811
|
+
d(), a(null);
|
|
812
|
+
};
|
|
813
|
+
return /* @__PURE__ */ p("form", { onSubmit: ne, className: `cedros-form ${w}`, children: [
|
|
814
|
+
/* @__PURE__ */ p("div", { className: "cedros-form-field", children: [
|
|
815
|
+
/* @__PURE__ */ p("label", { htmlFor: "name", className: "cedros-label", children: [
|
|
816
|
+
"Name ",
|
|
817
|
+
/* @__PURE__ */ e("span", { className: "cedros-optional", children: "(optional)" })
|
|
818
|
+
] }),
|
|
819
|
+
/* @__PURE__ */ e(
|
|
820
|
+
"input",
|
|
821
|
+
{
|
|
822
|
+
id: "name",
|
|
823
|
+
type: "text",
|
|
824
|
+
className: "cedros-input",
|
|
825
|
+
value: h,
|
|
826
|
+
onChange: (R) => f(R.target.value),
|
|
827
|
+
placeholder: "Your name",
|
|
828
|
+
autoComplete: "name",
|
|
829
|
+
disabled: l
|
|
830
|
+
}
|
|
831
|
+
)
|
|
832
|
+
] }),
|
|
833
|
+
/* @__PURE__ */ p("div", { className: "cedros-form-field", children: [
|
|
834
|
+
/* @__PURE__ */ e("label", { htmlFor: "register-email", className: "cedros-label", children: "Email" }),
|
|
835
|
+
/* @__PURE__ */ e(
|
|
836
|
+
"input",
|
|
837
|
+
{
|
|
838
|
+
id: "register-email",
|
|
839
|
+
type: "email",
|
|
840
|
+
className: "cedros-input",
|
|
841
|
+
value: y,
|
|
842
|
+
onChange: (R) => u(R.target.value),
|
|
843
|
+
placeholder: "you@example.com",
|
|
844
|
+
required: !0,
|
|
845
|
+
"aria-required": "true",
|
|
846
|
+
autoComplete: "email",
|
|
847
|
+
disabled: l
|
|
848
|
+
}
|
|
849
|
+
)
|
|
850
|
+
] }),
|
|
851
|
+
/* @__PURE__ */ e("div", { className: "cedros-form-field", children: /* @__PURE__ */ e(
|
|
852
|
+
te,
|
|
853
|
+
{
|
|
854
|
+
value: g,
|
|
855
|
+
onChange: (R) => E(R.target.value),
|
|
856
|
+
placeholder: "Create a password",
|
|
857
|
+
required: !0,
|
|
858
|
+
autoComplete: "new-password",
|
|
859
|
+
disabled: l,
|
|
860
|
+
showStrengthMeter: !0,
|
|
861
|
+
onValidationChange: t
|
|
862
|
+
}
|
|
863
|
+
) }),
|
|
864
|
+
/* @__PURE__ */ p("div", { className: "cedros-form-field", children: [
|
|
865
|
+
/* @__PURE__ */ e("label", { htmlFor: "confirm-password", className: "cedros-label", children: "Confirm Password" }),
|
|
866
|
+
/* @__PURE__ */ e(
|
|
867
|
+
"input",
|
|
868
|
+
{
|
|
869
|
+
id: "confirm-password",
|
|
870
|
+
type: "password",
|
|
871
|
+
className: "cedros-input",
|
|
872
|
+
value: C,
|
|
873
|
+
onChange: (R) => c(R.target.value),
|
|
874
|
+
placeholder: "Confirm your password",
|
|
875
|
+
required: !0,
|
|
876
|
+
"aria-required": "true",
|
|
877
|
+
autoComplete: "new-password",
|
|
878
|
+
disabled: l,
|
|
879
|
+
"aria-invalid": C && !x ? "true" : void 0,
|
|
880
|
+
"aria-describedby": C && !x ? "confirm-password-error" : void 0
|
|
881
|
+
}
|
|
882
|
+
),
|
|
883
|
+
C && !x && /* @__PURE__ */ e("p", { id: "confirm-password-error", className: "cedros-input-error", role: "alert", children: "Passwords do not match" })
|
|
884
|
+
] }),
|
|
885
|
+
A && /* @__PURE__ */ e("div", { className: "cedros-form-field cedros-checkbox-field", children: /* @__PURE__ */ p("label", { className: "cedros-checkbox-label", children: [
|
|
886
|
+
/* @__PURE__ */ e(
|
|
887
|
+
"input",
|
|
888
|
+
{
|
|
889
|
+
type: "checkbox",
|
|
890
|
+
className: "cedros-checkbox",
|
|
891
|
+
checked: S,
|
|
892
|
+
onChange: (R) => O(R.target.checked),
|
|
893
|
+
disabled: l,
|
|
894
|
+
"aria-required": I
|
|
895
|
+
}
|
|
896
|
+
),
|
|
897
|
+
/* @__PURE__ */ p("span", { className: "cedros-checkbox-text", children: [
|
|
898
|
+
P ? /* @__PURE__ */ p(U, { children: [
|
|
899
|
+
q.replace("Terms of Service", "").trim() || "I agree to the",
|
|
900
|
+
" ",
|
|
901
|
+
/* @__PURE__ */ e(
|
|
902
|
+
"a",
|
|
903
|
+
{
|
|
904
|
+
href: P,
|
|
905
|
+
target: "_blank",
|
|
906
|
+
rel: "noopener noreferrer",
|
|
907
|
+
className: "cedros-link",
|
|
908
|
+
children: "Terms of Service"
|
|
909
|
+
}
|
|
910
|
+
)
|
|
911
|
+
] }) : q,
|
|
912
|
+
I && /* @__PURE__ */ e("span", { className: "cedros-required", children: "*" })
|
|
913
|
+
] })
|
|
914
|
+
] }) }),
|
|
915
|
+
F && /* @__PURE__ */ e("div", { className: "cedros-form-field cedros-checkbox-field", children: /* @__PURE__ */ p("label", { className: "cedros-checkbox-label", children: [
|
|
916
|
+
/* @__PURE__ */ e(
|
|
917
|
+
"input",
|
|
918
|
+
{
|
|
919
|
+
type: "checkbox",
|
|
920
|
+
className: "cedros-checkbox",
|
|
921
|
+
checked: re,
|
|
922
|
+
onChange: (R) => se(R.target.checked),
|
|
923
|
+
disabled: l
|
|
924
|
+
}
|
|
925
|
+
),
|
|
926
|
+
/* @__PURE__ */ e("span", { className: "cedros-checkbox-text", children: D })
|
|
927
|
+
] }) }),
|
|
928
|
+
/* @__PURE__ */ e(Q, { error: ae, onDismiss: ce }),
|
|
929
|
+
/* @__PURE__ */ e(
|
|
930
|
+
"button",
|
|
931
|
+
{
|
|
932
|
+
type: "submit",
|
|
933
|
+
className: "cedros-button cedros-button-primary cedros-button-md cedros-button-full",
|
|
934
|
+
disabled: !G,
|
|
935
|
+
"aria-busy": l,
|
|
936
|
+
children: l ? /* @__PURE__ */ p(U, { children: [
|
|
937
|
+
/* @__PURE__ */ e(K, { size: "sm", announce: !0, label: "Creating account" }),
|
|
938
|
+
/* @__PURE__ */ e("span", { children: "Creating account..." })
|
|
939
|
+
] }) : "Create account"
|
|
940
|
+
}
|
|
941
|
+
),
|
|
942
|
+
i && /* @__PURE__ */ p("p", { className: "cedros-form-footer", children: [
|
|
943
|
+
"Already have an account?",
|
|
944
|
+
" ",
|
|
945
|
+
/* @__PURE__ */ e("button", { type: "button", className: "cedros-link", onClick: i, children: "Sign in" })
|
|
946
|
+
] })
|
|
947
|
+
] });
|
|
948
|
+
}
|
|
949
|
+
export {
|
|
950
|
+
Ce as E,
|
|
951
|
+
fe as O,
|
|
952
|
+
te as P,
|
|
953
|
+
ge as T,
|
|
954
|
+
Ne as a,
|
|
955
|
+
Z as b,
|
|
956
|
+
de as c,
|
|
957
|
+
he as d,
|
|
958
|
+
pe as e,
|
|
959
|
+
Ee as s,
|
|
960
|
+
ee as u
|
|
961
|
+
};
|