@yackey-labs/yauth-ui-solidjs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +909 -0
- package/package.json +35 -0
- package/src/components/change-password-form.tsx +140 -0
- package/src/components/consent-screen.tsx +152 -0
- package/src/components/forgot-password-form.tsx +83 -0
- package/src/components/login-form.tsx +128 -0
- package/src/components/magic-link-form.tsx +84 -0
- package/src/components/mfa-challenge.tsx +83 -0
- package/src/components/mfa-setup.tsx +158 -0
- package/src/components/oauth-buttons.tsx +30 -0
- package/src/components/passkey-button.tsx +98 -0
- package/src/components/profile-settings.tsx +406 -0
- package/src/components/register-form.tsx +119 -0
- package/src/components/reset-password-form.tsx +83 -0
- package/src/components/verify-email.tsx +54 -0
- package/src/index.ts +14 -0
- package/src/provider.test.tsx +159 -0
- package/src/provider.tsx +73 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
import { createComponent as g, delegateEvents as Y, insert as e, Show as w, effect as E, template as l, memo as ue, addEventListener as ne } from "solid-js/web";
|
|
2
|
+
import { createContext as pe, createResource as ie, createEffect as me, useContext as be, createSignal as d, For as X } from "solid-js";
|
|
3
|
+
import { startAuthentication as ve, startRegistration as he } from "@simplewebauthn/browser";
|
|
4
|
+
const ge = pe(), Ct = (r) => {
|
|
5
|
+
let v = null;
|
|
6
|
+
const [f, {
|
|
7
|
+
refetch: h
|
|
8
|
+
}] = ie(async () => {
|
|
9
|
+
try {
|
|
10
|
+
return (await r.client.getSession()).user;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
me(() => {
|
|
16
|
+
if (!f.loading && v) {
|
|
17
|
+
const S = v;
|
|
18
|
+
v = null, S(f() ?? null);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const $ = () => new Promise((p) => {
|
|
22
|
+
v = p, h();
|
|
23
|
+
});
|
|
24
|
+
return g(ge.Provider, {
|
|
25
|
+
get value() {
|
|
26
|
+
return {
|
|
27
|
+
client: r.client,
|
|
28
|
+
user: () => f(),
|
|
29
|
+
loading: () => f.loading,
|
|
30
|
+
refetch: $
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
get children() {
|
|
34
|
+
return r.children;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
function z() {
|
|
39
|
+
const r = be(ge);
|
|
40
|
+
if (!r)
|
|
41
|
+
throw new Error("useYAuth must be used within a <YAuthProvider>");
|
|
42
|
+
return r;
|
|
43
|
+
}
|
|
44
|
+
var ye = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), xe = /* @__PURE__ */ l('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">Password changed successfully.'), we = /* @__PURE__ */ l('<form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-current-password>Current password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-current-password name=current_password type=password required autocomplete=current-password></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-new-password>New password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-new-password name=new_password type=password required autocomplete=new-password></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-confirm-password>Confirm new password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-confirm-password name=confirm_password type=password required autocomplete=new-password></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
|
|
45
|
+
const Et = (r) => {
|
|
46
|
+
const {
|
|
47
|
+
client: v
|
|
48
|
+
} = z(), [f, h] = d(""), [$, p] = d(""), [S, _] = d(""), [u, n] = d(null), [m, i] = d(!1), [t, c] = d(!1), a = async (s) => {
|
|
49
|
+
s.preventDefault(), n(null), i(!1);
|
|
50
|
+
const o = s.currentTarget, k = new FormData(o), b = k.get("current_password") || f(), y = k.get("new_password") || $(), x = k.get("confirm_password") || S();
|
|
51
|
+
if (y !== x) {
|
|
52
|
+
n("Passwords do not match");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
c(!0);
|
|
56
|
+
try {
|
|
57
|
+
await v.emailPassword.changePassword(b, y), i(!0), h(""), p(""), _(""), r.onSuccess?.();
|
|
58
|
+
} catch (L) {
|
|
59
|
+
const M = L instanceof Error ? L : new Error(String(L));
|
|
60
|
+
n(M.message), r.onError?.(M);
|
|
61
|
+
} finally {
|
|
62
|
+
c(!1);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return (() => {
|
|
66
|
+
var s = we(), o = s.firstChild, k = o.firstChild, b = k.nextSibling, y = o.nextSibling, x = y.firstChild, L = x.nextSibling, M = y.nextSibling, N = M.firstChild, P = N.nextSibling, J = M.nextSibling;
|
|
67
|
+
return s.addEventListener("submit", a), e(s, g(w, {
|
|
68
|
+
get when() {
|
|
69
|
+
return u();
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
var C = ye();
|
|
73
|
+
return e(C, u), C;
|
|
74
|
+
}
|
|
75
|
+
}), o), e(s, g(w, {
|
|
76
|
+
get when() {
|
|
77
|
+
return m();
|
|
78
|
+
},
|
|
79
|
+
get children() {
|
|
80
|
+
return xe();
|
|
81
|
+
}
|
|
82
|
+
}), o), b.$$input = (C) => h(C.currentTarget.value), L.$$input = (C) => p(C.currentTarget.value), P.$$input = (C) => _(C.currentTarget.value), e(J, () => t() ? "Changing password..." : "Change password"), E((C) => {
|
|
83
|
+
var B = t(), U = t(), W = t(), H = t();
|
|
84
|
+
return B !== C.e && (b.disabled = C.e = B), U !== C.t && (L.disabled = C.t = U), W !== C.a && (P.disabled = C.a = W), H !== C.o && (J.disabled = C.o = H), C;
|
|
85
|
+
}, {
|
|
86
|
+
e: void 0,
|
|
87
|
+
t: void 0,
|
|
88
|
+
a: void 0,
|
|
89
|
+
o: void 0
|
|
90
|
+
}), E(() => b.value = f()), E(() => L.value = $()), E(() => P.value = S()), s;
|
|
91
|
+
})();
|
|
92
|
+
};
|
|
93
|
+
Y(["input"]);
|
|
94
|
+
var $e = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), _e = /* @__PURE__ */ l('<div class="rounded-md border p-4 space-y-3"><p class="text-sm font-medium">This application is requesting the following permissions:</p><ul class=space-y-2>'), Se = /* @__PURE__ */ l('<div class="mx-auto max-w-md space-y-6 p-6"><div class="space-y-2 text-center"><h2 class="text-2xl font-semibold tracking-tight">Authorize </h2><p class="text-sm text-muted-foreground"><strong></strong> is requesting access to your account.</p></div><div class="flex gap-3"><button class="inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>Deny</button><button class="inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button></button></div><p class="text-center text-xs text-muted-foreground">By authorizing, you allow this application to access your account with the permissions listed above.'), ke = /* @__PURE__ */ l('<li class="flex items-center gap-2 text-sm"><svg class="h-4 w-4 text-primary"fill=none stroke=currentColor viewBox="0 0 24 24"aria-label=Checkmark role=img><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><span>');
|
|
95
|
+
const Pt = (r) => {
|
|
96
|
+
const [v, f] = d(!1), [h, $] = d(null), p = async (_) => {
|
|
97
|
+
$(null), f(!0);
|
|
98
|
+
try {
|
|
99
|
+
const u = r.authBaseUrl ?? "/api/auth", n = await fetch(`${u}/authorize`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": "application/json"
|
|
103
|
+
},
|
|
104
|
+
credentials: "include",
|
|
105
|
+
body: JSON.stringify({
|
|
106
|
+
client_id: r.clientId,
|
|
107
|
+
redirect_uri: r.redirectUri,
|
|
108
|
+
response_type: r.responseType,
|
|
109
|
+
code_challenge: r.codeChallenge,
|
|
110
|
+
code_challenge_method: r.codeChallengeMethod,
|
|
111
|
+
scope: r.scopes?.join(" "),
|
|
112
|
+
state: r.state,
|
|
113
|
+
approved: _
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
if (n.redirected) {
|
|
117
|
+
window.location.href = n.url;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!n.ok) {
|
|
121
|
+
const i = await n.json().catch(() => null);
|
|
122
|
+
throw new Error(i?.error_description ?? i?.error ?? "Authorization failed");
|
|
123
|
+
}
|
|
124
|
+
const m = n.headers.get("Location");
|
|
125
|
+
if (m) {
|
|
126
|
+
window.location.href = m;
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
r.onSubmit?.(_);
|
|
130
|
+
} catch (u) {
|
|
131
|
+
const n = u instanceof Error ? u : new Error(String(u));
|
|
132
|
+
$(n.message), r.onError?.(n);
|
|
133
|
+
} finally {
|
|
134
|
+
f(!1);
|
|
135
|
+
}
|
|
136
|
+
}, S = () => r.clientName ?? r.clientId;
|
|
137
|
+
return (() => {
|
|
138
|
+
var _ = Se(), u = _.firstChild, n = u.firstChild;
|
|
139
|
+
n.firstChild;
|
|
140
|
+
var m = n.nextSibling, i = m.firstChild, t = u.nextSibling, c = t.firstChild, a = c.nextSibling;
|
|
141
|
+
return e(n, S, null), e(i, S), e(_, g(w, {
|
|
142
|
+
get when() {
|
|
143
|
+
return h();
|
|
144
|
+
},
|
|
145
|
+
get children() {
|
|
146
|
+
var s = $e();
|
|
147
|
+
return e(s, h), s;
|
|
148
|
+
}
|
|
149
|
+
}), t), e(_, g(w, {
|
|
150
|
+
get when() {
|
|
151
|
+
return ue(() => !!r.scopes)() && r.scopes.length > 0;
|
|
152
|
+
},
|
|
153
|
+
get children() {
|
|
154
|
+
var s = _e(), o = s.firstChild, k = o.nextSibling;
|
|
155
|
+
return e(k, g(X, {
|
|
156
|
+
get each() {
|
|
157
|
+
return r.scopes;
|
|
158
|
+
},
|
|
159
|
+
children: (b) => (() => {
|
|
160
|
+
var y = ke(), x = y.firstChild, L = x.nextSibling;
|
|
161
|
+
return e(L, b), y;
|
|
162
|
+
})()
|
|
163
|
+
})), s;
|
|
164
|
+
}
|
|
165
|
+
}), t), c.$$click = () => p(!1), a.$$click = () => p(!0), e(a, () => v() ? "Authorizing..." : "Authorize"), E((s) => {
|
|
166
|
+
var o = v(), k = v();
|
|
167
|
+
return o !== s.e && (c.disabled = s.e = o), k !== s.t && (a.disabled = s.t = k), s;
|
|
168
|
+
}, {
|
|
169
|
+
e: void 0,
|
|
170
|
+
t: void 0
|
|
171
|
+
}), _;
|
|
172
|
+
})();
|
|
173
|
+
};
|
|
174
|
+
Y(["click"]);
|
|
175
|
+
var Ce = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Ee = /* @__PURE__ */ l('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), Pe = /* @__PURE__ */ l('<form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-forgot-password-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-forgot-password-email name=email type=email required autocomplete=email></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
|
|
176
|
+
const Dt = (r) => {
|
|
177
|
+
const {
|
|
178
|
+
client: v
|
|
179
|
+
} = z(), [f, h] = d(""), [$, p] = d(null), [S, _] = d(null), [u, n] = d(!1), m = async (i) => {
|
|
180
|
+
i.preventDefault(), p(null), _(null), n(!0);
|
|
181
|
+
try {
|
|
182
|
+
const t = i.currentTarget, c = new FormData(t), a = await v.emailPassword.forgotPassword(c.get("email") || f());
|
|
183
|
+
_(a.message), r.onSuccess?.(a.message);
|
|
184
|
+
} catch (t) {
|
|
185
|
+
const c = t instanceof Error ? t : new Error(String(t));
|
|
186
|
+
p(c.message);
|
|
187
|
+
} finally {
|
|
188
|
+
n(!1);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
return (() => {
|
|
192
|
+
var i = Pe(), t = i.firstChild, c = t.firstChild, a = c.nextSibling, s = t.nextSibling;
|
|
193
|
+
return i.addEventListener("submit", m), e(i, g(w, {
|
|
194
|
+
get when() {
|
|
195
|
+
return $();
|
|
196
|
+
},
|
|
197
|
+
get children() {
|
|
198
|
+
var o = Ce();
|
|
199
|
+
return e(o, $), o;
|
|
200
|
+
}
|
|
201
|
+
}), t), e(i, g(w, {
|
|
202
|
+
get when() {
|
|
203
|
+
return S();
|
|
204
|
+
},
|
|
205
|
+
get children() {
|
|
206
|
+
var o = Ee();
|
|
207
|
+
return e(o, S), o;
|
|
208
|
+
}
|
|
209
|
+
}), t), a.$$input = (o) => h(o.currentTarget.value), e(s, () => u() ? "Sending..." : "Send reset link"), E((o) => {
|
|
210
|
+
var k = u(), b = u();
|
|
211
|
+
return k !== o.e && (a.disabled = o.e = k), b !== o.t && (s.disabled = o.t = b), o;
|
|
212
|
+
}, {
|
|
213
|
+
e: void 0,
|
|
214
|
+
t: void 0
|
|
215
|
+
}), E(() => a.value = f()), i;
|
|
216
|
+
})();
|
|
217
|
+
};
|
|
218
|
+
Y(["input"]);
|
|
219
|
+
var De = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Te = /* @__PURE__ */ l('<div class=space-y-2><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>');
|
|
220
|
+
const Le = (r) => {
|
|
221
|
+
const {
|
|
222
|
+
client: v
|
|
223
|
+
} = z(), [f, h] = d(null), [$, p] = d(!1), S = async () => {
|
|
224
|
+
const n = await v.passkey.loginBegin(r.email || void 0), m = n.options, i = await ve({
|
|
225
|
+
optionsJSON: m.publicKey
|
|
226
|
+
});
|
|
227
|
+
await v.passkey.loginFinish(n.challenge_id, i);
|
|
228
|
+
const t = await v.getSession();
|
|
229
|
+
r.onSuccess?.(t.user);
|
|
230
|
+
}, _ = async () => {
|
|
231
|
+
const n = await v.passkey.registerBegin(), m = await he({
|
|
232
|
+
optionsJSON: n.publicKey
|
|
233
|
+
});
|
|
234
|
+
await v.passkey.registerFinish(m, "Passkey"), r.onSuccess?.(void 0);
|
|
235
|
+
}, u = async () => {
|
|
236
|
+
h(null), p(!0);
|
|
237
|
+
try {
|
|
238
|
+
r.mode === "login" ? await S() : await _();
|
|
239
|
+
} catch (n) {
|
|
240
|
+
const m = n instanceof Error ? n : new Error(String(n));
|
|
241
|
+
console.error("[yauth] Passkey error:", m);
|
|
242
|
+
const i = m.name === "NotAllowedError" ? "Passkey authentication was cancelled or not available on this device." : m.message;
|
|
243
|
+
h(i), r.onError?.(m);
|
|
244
|
+
} finally {
|
|
245
|
+
p(!1);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
return (() => {
|
|
249
|
+
var n = Te(), m = n.firstChild;
|
|
250
|
+
return e(n, g(w, {
|
|
251
|
+
get when() {
|
|
252
|
+
return f();
|
|
253
|
+
},
|
|
254
|
+
get children() {
|
|
255
|
+
var i = De();
|
|
256
|
+
return e(i, f), i;
|
|
257
|
+
}
|
|
258
|
+
}), m), m.$$click = u, e(m, (() => {
|
|
259
|
+
var i = ue(() => !!$());
|
|
260
|
+
return () => i() ? r.mode === "login" ? "Authenticating..." : "Registering..." : r.mode === "login" ? "Sign in with passkey" : "Register passkey";
|
|
261
|
+
})()), E(() => m.disabled = $()), n;
|
|
262
|
+
})();
|
|
263
|
+
};
|
|
264
|
+
Y(["click"]);
|
|
265
|
+
var Ae = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), je = /* @__PURE__ */ l('<div class=relative><div class="absolute inset-0 flex items-center"style=pointer-events:none><span class="w-full border-t"></span></div><div class="relative flex justify-center text-xs uppercase"><span class="bg-background px-2 text-muted-foreground">or'), Fe = /* @__PURE__ */ l('<form class=space-y-6><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-login-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-login-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-login-password>Password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-login-password name=password type=password required autocomplete=current-password></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
|
|
266
|
+
const Tt = (r) => {
|
|
267
|
+
const {
|
|
268
|
+
client: v,
|
|
269
|
+
refetch: f
|
|
270
|
+
} = z(), [h, $] = d(""), [p, S] = d(""), [_, u] = d(null), [n, m] = d(!1), i = async (t) => {
|
|
271
|
+
t.preventDefault(), u(null), m(!0);
|
|
272
|
+
try {
|
|
273
|
+
const c = t.currentTarget, a = new FormData(c), s = await v.emailPassword.login({
|
|
274
|
+
email: a.get("email") || h(),
|
|
275
|
+
password: a.get("password") || p()
|
|
276
|
+
});
|
|
277
|
+
if ("mfa_required" in s && s.mfa_required)
|
|
278
|
+
r.onMfaRequired?.(s.pending_session_id);
|
|
279
|
+
else {
|
|
280
|
+
const o = await f();
|
|
281
|
+
r.onSuccess?.(o);
|
|
282
|
+
}
|
|
283
|
+
} catch (c) {
|
|
284
|
+
const a = c instanceof Error ? c : new Error(String(c));
|
|
285
|
+
u(a.message), r.onError?.(a);
|
|
286
|
+
} finally {
|
|
287
|
+
m(!1);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
return (() => {
|
|
291
|
+
var t = Fe(), c = t.firstChild, a = c.firstChild, s = a.nextSibling, o = c.nextSibling, k = o.firstChild, b = k.nextSibling, y = o.nextSibling;
|
|
292
|
+
return ne(t, "submit", i), e(t, g(w, {
|
|
293
|
+
get when() {
|
|
294
|
+
return _();
|
|
295
|
+
},
|
|
296
|
+
get children() {
|
|
297
|
+
var x = Ae();
|
|
298
|
+
return e(x, _), x;
|
|
299
|
+
}
|
|
300
|
+
}), c), ne(s, "input", (x) => $(x.currentTarget.value)), ne(b, "input", (x) => S(x.currentTarget.value)), e(y, () => n() ? "Signing in..." : "Sign in"), e(t, g(w, {
|
|
301
|
+
get when() {
|
|
302
|
+
return r.showPasskey;
|
|
303
|
+
},
|
|
304
|
+
get children() {
|
|
305
|
+
return [je(), g(Le, {
|
|
306
|
+
mode: "login",
|
|
307
|
+
get email() {
|
|
308
|
+
return h();
|
|
309
|
+
},
|
|
310
|
+
onSuccess: (x) => {
|
|
311
|
+
f(), r.onSuccess?.(x);
|
|
312
|
+
},
|
|
313
|
+
get onError() {
|
|
314
|
+
return r.onError;
|
|
315
|
+
}
|
|
316
|
+
})];
|
|
317
|
+
}
|
|
318
|
+
}), null), E((x) => {
|
|
319
|
+
var L = n(), M = n(), N = n();
|
|
320
|
+
return L !== x.e && (s.disabled = x.e = L), M !== x.t && (b.disabled = x.t = M), N !== x.a && (y.disabled = x.a = N), x;
|
|
321
|
+
}, {
|
|
322
|
+
e: void 0,
|
|
323
|
+
t: void 0,
|
|
324
|
+
a: void 0
|
|
325
|
+
}), E(() => s.value = h()), E(() => b.value = p()), t;
|
|
326
|
+
})();
|
|
327
|
+
};
|
|
328
|
+
var Me = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), qe = /* @__PURE__ */ l('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), Re = /* @__PURE__ */ l('<div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-magic-link-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-magic-link-email name=email type=email required autocomplete=email placeholder=you@example.com>'), Ne = /* @__PURE__ */ l('<button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>'), Be = /* @__PURE__ */ l("<form class=space-y-4>");
|
|
329
|
+
const Lt = (r) => {
|
|
330
|
+
const {
|
|
331
|
+
client: v
|
|
332
|
+
} = z(), [f, h] = d(""), [$, p] = d(null), [S, _] = d(null), [u, n] = d(!1), m = async (i) => {
|
|
333
|
+
i.preventDefault(), p(null), _(null), n(!0);
|
|
334
|
+
try {
|
|
335
|
+
const t = i.currentTarget, c = new FormData(t), a = await v.magicLink.send(c.get("email") || f());
|
|
336
|
+
_(a.message), r.onSuccess?.(a.message);
|
|
337
|
+
} catch (t) {
|
|
338
|
+
const c = t instanceof Error ? t : new Error(String(t));
|
|
339
|
+
p(c.message);
|
|
340
|
+
} finally {
|
|
341
|
+
n(!1);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
return (() => {
|
|
345
|
+
var i = Be();
|
|
346
|
+
return i.addEventListener("submit", m), e(i, g(w, {
|
|
347
|
+
get when() {
|
|
348
|
+
return $();
|
|
349
|
+
},
|
|
350
|
+
get children() {
|
|
351
|
+
var t = Me();
|
|
352
|
+
return e(t, $), t;
|
|
353
|
+
}
|
|
354
|
+
}), null), e(i, g(w, {
|
|
355
|
+
get when() {
|
|
356
|
+
return S();
|
|
357
|
+
},
|
|
358
|
+
get children() {
|
|
359
|
+
var t = qe();
|
|
360
|
+
return e(t, S), t;
|
|
361
|
+
}
|
|
362
|
+
}), null), e(i, g(w, {
|
|
363
|
+
get when() {
|
|
364
|
+
return !S();
|
|
365
|
+
},
|
|
366
|
+
get children() {
|
|
367
|
+
return [(() => {
|
|
368
|
+
var t = Re(), c = t.firstChild, a = c.nextSibling;
|
|
369
|
+
return a.$$input = (s) => h(s.currentTarget.value), E(() => a.disabled = u()), E(() => a.value = f()), t;
|
|
370
|
+
})(), (() => {
|
|
371
|
+
var t = Ne();
|
|
372
|
+
return e(t, () => u() ? "Sending..." : "Send magic link"), E(() => t.disabled = u()), t;
|
|
373
|
+
})()];
|
|
374
|
+
}
|
|
375
|
+
}), null), i;
|
|
376
|
+
})();
|
|
377
|
+
};
|
|
378
|
+
Y(["input"]);
|
|
379
|
+
var Oe = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Ue = /* @__PURE__ */ l('<form class=space-y-4><p class="text-sm text-muted-foreground">Enter the code from your authenticator app, or use a backup code.</p><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-mfa-challenge-code>Verification code</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-mfa-challenge-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
|
|
380
|
+
const At = (r) => {
|
|
381
|
+
const {
|
|
382
|
+
client: v
|
|
383
|
+
} = z(), [f, h] = d(""), [$, p] = d(null), [S, _] = d(!1), u = async (n) => {
|
|
384
|
+
n.preventDefault(), p(null), _(!0);
|
|
385
|
+
try {
|
|
386
|
+
const m = n.currentTarget, i = new FormData(m);
|
|
387
|
+
await v.mfa.verify(r.pendingSessionId, i.get("code") || f());
|
|
388
|
+
const t = await v.getSession();
|
|
389
|
+
r.onSuccess?.(t.user);
|
|
390
|
+
} catch (m) {
|
|
391
|
+
const i = m instanceof Error ? m : new Error(String(m));
|
|
392
|
+
p(i.message), r.onError?.(i);
|
|
393
|
+
} finally {
|
|
394
|
+
_(!1);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
return (() => {
|
|
398
|
+
var n = Ue(), m = n.firstChild, i = m.nextSibling, t = i.firstChild, c = t.nextSibling, a = i.nextSibling;
|
|
399
|
+
return n.addEventListener("submit", u), e(n, g(w, {
|
|
400
|
+
get when() {
|
|
401
|
+
return $();
|
|
402
|
+
},
|
|
403
|
+
get children() {
|
|
404
|
+
var s = Oe();
|
|
405
|
+
return e(s, $), s;
|
|
406
|
+
}
|
|
407
|
+
}), m), c.$$input = (s) => h(s.currentTarget.value), e(a, () => S() ? "Verifying..." : "Verify"), E((s) => {
|
|
408
|
+
var o = S(), k = S();
|
|
409
|
+
return o !== s.e && (c.disabled = s.e = o), k !== s.t && (a.disabled = s.t = k), s;
|
|
410
|
+
}, {
|
|
411
|
+
e: void 0,
|
|
412
|
+
t: void 0
|
|
413
|
+
}), E(() => c.value = f()), n;
|
|
414
|
+
})();
|
|
415
|
+
};
|
|
416
|
+
Y(["input"]);
|
|
417
|
+
var Ve = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), ze = /* @__PURE__ */ l('<div class=space-y-4><p class="text-sm text-muted-foreground">Set up two-factor authentication to secure your account.</p><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), Ie = /* @__PURE__ */ l('<div class=space-y-4><p class="text-sm text-muted-foreground">Add this account to your authenticator app using the URI below, then enter the verification code.</p><div class=space-y-1><span class="text-sm font-medium leading-none">OTP Auth URI</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs"></code></div><div class=space-y-1><span class="text-sm font-medium leading-none">Manual entry key</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider"></code></div><form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-mfa-setup-code>Verification code</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-mfa-setup-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>'), Ye = /* @__PURE__ */ l('<div class=space-y-4><div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">Two-factor authentication has been enabled. Save these backup codes in a safe place. Each code can only be used once.</div><ul class=space-y-1>'), Je = /* @__PURE__ */ l("<div class=space-y-4>"), Ke = /* @__PURE__ */ l('<li class="rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider">');
|
|
418
|
+
const jt = (r) => {
|
|
419
|
+
const {
|
|
420
|
+
client: v
|
|
421
|
+
} = z(), [f, h] = d("begin"), [$, p] = d(""), [S, _] = d(""), [u, n] = d(""), [m, i] = d([]), [t, c] = d(null), [a, s] = d(!1), o = async () => {
|
|
422
|
+
c(null), s(!0);
|
|
423
|
+
try {
|
|
424
|
+
const b = await v.mfa.setup();
|
|
425
|
+
p(b.otpauth_url), _(b.secret), i(b.backup_codes), h("confirm");
|
|
426
|
+
} catch (b) {
|
|
427
|
+
const y = b instanceof Error ? b : new Error(String(b));
|
|
428
|
+
c(y.message);
|
|
429
|
+
} finally {
|
|
430
|
+
s(!1);
|
|
431
|
+
}
|
|
432
|
+
}, k = async (b) => {
|
|
433
|
+
b.preventDefault(), c(null), s(!0);
|
|
434
|
+
try {
|
|
435
|
+
const y = b.currentTarget, x = new FormData(y);
|
|
436
|
+
await v.mfa.confirm(x.get("code") || u()), h("done"), r.onComplete?.(m());
|
|
437
|
+
} catch (y) {
|
|
438
|
+
const x = y instanceof Error ? y : new Error(String(y));
|
|
439
|
+
c(x.message);
|
|
440
|
+
} finally {
|
|
441
|
+
s(!1);
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
return (() => {
|
|
445
|
+
var b = Je();
|
|
446
|
+
return e(b, g(w, {
|
|
447
|
+
get when() {
|
|
448
|
+
return t();
|
|
449
|
+
},
|
|
450
|
+
get children() {
|
|
451
|
+
var y = Ve();
|
|
452
|
+
return e(y, t), y;
|
|
453
|
+
}
|
|
454
|
+
}), null), e(b, g(w, {
|
|
455
|
+
get when() {
|
|
456
|
+
return f() === "begin";
|
|
457
|
+
},
|
|
458
|
+
get children() {
|
|
459
|
+
var y = ze(), x = y.firstChild, L = x.nextSibling;
|
|
460
|
+
return L.$$click = o, e(L, () => a() ? "Setting up..." : "Set up 2FA"), E(() => L.disabled = a()), y;
|
|
461
|
+
}
|
|
462
|
+
}), null), e(b, g(w, {
|
|
463
|
+
get when() {
|
|
464
|
+
return f() === "confirm";
|
|
465
|
+
},
|
|
466
|
+
get children() {
|
|
467
|
+
var y = Ie(), x = y.firstChild, L = x.nextSibling, M = L.firstChild, N = M.nextSibling, P = L.nextSibling, J = P.firstChild, C = J.nextSibling, B = P.nextSibling, U = B.firstChild, W = U.firstChild, H = W.nextSibling, ee = U.nextSibling;
|
|
468
|
+
return e(N, $), e(C, S), B.addEventListener("submit", k), H.$$input = (K) => n(K.currentTarget.value), e(ee, () => a() ? "Verifying..." : "Verify and enable"), E((K) => {
|
|
469
|
+
var te = a(), T = a();
|
|
470
|
+
return te !== K.e && (H.disabled = K.e = te), T !== K.t && (ee.disabled = K.t = T), K;
|
|
471
|
+
}, {
|
|
472
|
+
e: void 0,
|
|
473
|
+
t: void 0
|
|
474
|
+
}), E(() => H.value = u()), y;
|
|
475
|
+
}
|
|
476
|
+
}), null), e(b, g(w, {
|
|
477
|
+
get when() {
|
|
478
|
+
return f() === "done";
|
|
479
|
+
},
|
|
480
|
+
get children() {
|
|
481
|
+
var y = Ye(), x = y.firstChild, L = x.nextSibling;
|
|
482
|
+
return e(L, g(X, {
|
|
483
|
+
get each() {
|
|
484
|
+
return m();
|
|
485
|
+
},
|
|
486
|
+
children: (M) => (() => {
|
|
487
|
+
var N = Ke();
|
|
488
|
+
return e(N, M), N;
|
|
489
|
+
})()
|
|
490
|
+
})), y;
|
|
491
|
+
}
|
|
492
|
+
}), null), b;
|
|
493
|
+
})();
|
|
494
|
+
};
|
|
495
|
+
Y(["click", "input"]);
|
|
496
|
+
var Ge = /* @__PURE__ */ l("<div class=space-y-2>"), He = /* @__PURE__ */ l('<button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>Sign in with ');
|
|
497
|
+
const Ft = (r) => {
|
|
498
|
+
const {
|
|
499
|
+
client: v
|
|
500
|
+
} = z(), f = (h) => {
|
|
501
|
+
v.oauth.authorize(h);
|
|
502
|
+
};
|
|
503
|
+
return (() => {
|
|
504
|
+
var h = Ge();
|
|
505
|
+
return e(h, g(X, {
|
|
506
|
+
get each() {
|
|
507
|
+
return r.providers;
|
|
508
|
+
},
|
|
509
|
+
children: ($) => (() => {
|
|
510
|
+
var p = He();
|
|
511
|
+
return p.firstChild, p.$$click = () => f($), e(p, () => $.charAt(0).toUpperCase() + $.slice(1), null), p;
|
|
512
|
+
})()
|
|
513
|
+
})), h;
|
|
514
|
+
})();
|
|
515
|
+
};
|
|
516
|
+
Y(["click"]);
|
|
517
|
+
var Qe = /* @__PURE__ */ l('<div class="text-sm text-muted-foreground">Loading profile...'), We = /* @__PURE__ */ l("<div class=space-y-8>"), Xe = /* @__PURE__ */ l('<dt class="font-medium text-muted-foreground">Display name'), Ze = /* @__PURE__ */ l("<dd>"), et = /* @__PURE__ */ l('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Profile</h2><dl class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm"><dt class="font-medium text-muted-foreground">Email</dt><dd></dd><dt class="font-medium text-muted-foreground">Email verified</dt><dd></dd><dt class="font-medium text-muted-foreground">Role</dt><dd>'), se = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), tt = /* @__PURE__ */ l('<div class="text-sm text-muted-foreground">Loading passkeys...'), rt = /* @__PURE__ */ l('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Passkeys'), nt = /* @__PURE__ */ l('<div class="text-sm text-muted-foreground">Loading accounts...'), st = /* @__PURE__ */ l('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Connected accounts'), it = /* @__PURE__ */ l('<div class="flex gap-2"><button class="inline-flex h-9 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button></button><button class="inline-flex h-9 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), lt = /* @__PURE__ */ l('<div class=space-y-4><p class="text-sm text-muted-foreground">Add this account to your authenticator app, then enter the verification code.</p><div class=space-y-1><span class="text-sm font-medium leading-none">OTP Auth URI</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs"></code></div><div class=space-y-1><span class="text-sm font-medium leading-none">Manual entry key</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider"></code></div><form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-profile-mfa-code>Verification code</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-profile-mfa-code name=mfa_code type=text inputmode=numeric autocomplete=one-time-code required></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>'), ot = /* @__PURE__ */ l('<div class=space-y-4><div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">Two-factor authentication is enabled. Save these backup codes in a safe place.</div><ul class=space-y-1>'), at = /* @__PURE__ */ l('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Two-factor authentication'), ce = /* @__PURE__ */ l("<ul class=space-y-2>"), dt = /* @__PURE__ */ l('<p class="text-sm text-muted-foreground">No passkeys registered.'), ct = /* @__PURE__ */ l('<li class="flex items-center justify-between rounded-md border border-input px-3 py-2"><div class=space-y-0.5><span class="text-sm font-medium"></span><span class="block text-xs text-muted-foreground">Added </span></div><button class="inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), ut = /* @__PURE__ */ l('<p class="text-sm text-muted-foreground">No connected accounts.'), mt = /* @__PURE__ */ l('<li class="flex items-center justify-between rounded-md border border-input px-3 py-2"><div class=space-y-0.5><span class="text-sm font-medium"></span><span class="block text-xs text-muted-foreground">Connected </span></div><button class="inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), gt = /* @__PURE__ */ l('<li class="rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider">');
|
|
518
|
+
const Mt = () => {
|
|
519
|
+
const {
|
|
520
|
+
client: r,
|
|
521
|
+
user: v,
|
|
522
|
+
loading: f
|
|
523
|
+
} = z(), [h, {
|
|
524
|
+
refetch: $
|
|
525
|
+
}] = ie(async () => {
|
|
526
|
+
try {
|
|
527
|
+
return await r.passkey.list();
|
|
528
|
+
} catch {
|
|
529
|
+
return [];
|
|
530
|
+
}
|
|
531
|
+
}), [p, S] = d(null), [_, u] = d(null), [n, {
|
|
532
|
+
refetch: m
|
|
533
|
+
}] = ie(async () => {
|
|
534
|
+
try {
|
|
535
|
+
return await r.oauth.accounts();
|
|
536
|
+
} catch {
|
|
537
|
+
return [];
|
|
538
|
+
}
|
|
539
|
+
}), [i, t] = d(null), [c, a] = d(null), [s, o] = d(""), [k, b] = d(""), [y, x] = d(""), [L, M] = d([]), [N, P] = d("idle"), [J, C] = d(null), [B, U] = d(!1), W = async (T) => {
|
|
540
|
+
S(null), u(T);
|
|
541
|
+
try {
|
|
542
|
+
await r.passkey.delete(T), $();
|
|
543
|
+
} catch (j) {
|
|
544
|
+
const D = j instanceof Error ? j : new Error(String(j));
|
|
545
|
+
S(D.message);
|
|
546
|
+
} finally {
|
|
547
|
+
u(null);
|
|
548
|
+
}
|
|
549
|
+
}, H = async (T) => {
|
|
550
|
+
t(null), a(T);
|
|
551
|
+
try {
|
|
552
|
+
await r.oauth.unlink(T), m();
|
|
553
|
+
} catch (j) {
|
|
554
|
+
const D = j instanceof Error ? j : new Error(String(j));
|
|
555
|
+
t(D.message);
|
|
556
|
+
} finally {
|
|
557
|
+
a(null);
|
|
558
|
+
}
|
|
559
|
+
}, ee = async () => {
|
|
560
|
+
C(null), U(!0);
|
|
561
|
+
try {
|
|
562
|
+
const T = await r.mfa.setup();
|
|
563
|
+
o(T.otpauth_url), b(T.secret), M(T.backup_codes), P("confirm");
|
|
564
|
+
} catch (T) {
|
|
565
|
+
const j = T instanceof Error ? T : new Error(String(T));
|
|
566
|
+
C(j.message);
|
|
567
|
+
} finally {
|
|
568
|
+
U(!1);
|
|
569
|
+
}
|
|
570
|
+
}, K = async (T) => {
|
|
571
|
+
T.preventDefault(), C(null), U(!0);
|
|
572
|
+
try {
|
|
573
|
+
const j = T.currentTarget, D = new FormData(j);
|
|
574
|
+
await r.mfa.confirm(D.get("mfa_code") || y()), P("done");
|
|
575
|
+
} catch (j) {
|
|
576
|
+
const D = j instanceof Error ? j : new Error(String(j));
|
|
577
|
+
C(D.message);
|
|
578
|
+
} finally {
|
|
579
|
+
U(!1);
|
|
580
|
+
}
|
|
581
|
+
}, te = async () => {
|
|
582
|
+
C(null), U(!0);
|
|
583
|
+
try {
|
|
584
|
+
await r.mfa.disable(), P("idle"), o(""), b(""), x(""), M([]);
|
|
585
|
+
} catch (T) {
|
|
586
|
+
const j = T instanceof Error ? T : new Error(String(T));
|
|
587
|
+
C(j.message);
|
|
588
|
+
} finally {
|
|
589
|
+
U(!1);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
return (() => {
|
|
593
|
+
var T = We();
|
|
594
|
+
return e(T, g(w, {
|
|
595
|
+
get when() {
|
|
596
|
+
return f();
|
|
597
|
+
},
|
|
598
|
+
get children() {
|
|
599
|
+
return Qe();
|
|
600
|
+
}
|
|
601
|
+
}), null), e(T, g(w, {
|
|
602
|
+
get when() {
|
|
603
|
+
return v();
|
|
604
|
+
},
|
|
605
|
+
children: (j) => [(() => {
|
|
606
|
+
var D = et(), A = D.firstChild, R = A.nextSibling, F = R.firstChild, q = F.nextSibling, O = q.nextSibling, V = O.nextSibling, G = V.nextSibling, I = G.nextSibling;
|
|
607
|
+
return e(q, () => j().email), e(R, g(w, {
|
|
608
|
+
get when() {
|
|
609
|
+
return j().display_name;
|
|
610
|
+
},
|
|
611
|
+
get children() {
|
|
612
|
+
return [Xe(), (() => {
|
|
613
|
+
var Z = Ze();
|
|
614
|
+
return e(Z, () => j().display_name), Z;
|
|
615
|
+
})()];
|
|
616
|
+
}
|
|
617
|
+
}), O), e(V, () => j().email_verified ? "Yes" : "No"), e(I, () => j().role), D;
|
|
618
|
+
})(), (() => {
|
|
619
|
+
var D = rt();
|
|
620
|
+
return D.firstChild, e(D, g(w, {
|
|
621
|
+
get when() {
|
|
622
|
+
return p();
|
|
623
|
+
},
|
|
624
|
+
get children() {
|
|
625
|
+
var A = se();
|
|
626
|
+
return e(A, p), A;
|
|
627
|
+
}
|
|
628
|
+
}), null), e(D, g(w, {
|
|
629
|
+
get when() {
|
|
630
|
+
return h.loading;
|
|
631
|
+
},
|
|
632
|
+
get children() {
|
|
633
|
+
return tt();
|
|
634
|
+
}
|
|
635
|
+
}), null), e(D, g(w, {
|
|
636
|
+
get when() {
|
|
637
|
+
return h();
|
|
638
|
+
},
|
|
639
|
+
children: (A) => g(w, {
|
|
640
|
+
get when() {
|
|
641
|
+
return A().length > 0;
|
|
642
|
+
},
|
|
643
|
+
get fallback() {
|
|
644
|
+
return dt();
|
|
645
|
+
},
|
|
646
|
+
get children() {
|
|
647
|
+
var R = ce();
|
|
648
|
+
return e(R, g(X, {
|
|
649
|
+
get each() {
|
|
650
|
+
return A();
|
|
651
|
+
},
|
|
652
|
+
children: (F) => (() => {
|
|
653
|
+
var q = ct(), O = q.firstChild, V = O.firstChild, G = V.nextSibling;
|
|
654
|
+
G.firstChild;
|
|
655
|
+
var I = O.nextSibling;
|
|
656
|
+
return e(V, () => F.name ?? "Unnamed passkey"), e(G, () => new Date(F.created_at).toLocaleDateString(), null), I.$$click = () => W(F.id), e(I, () => _() === F.id ? "Deleting..." : "Delete"), E(() => I.disabled = _() === F.id), q;
|
|
657
|
+
})()
|
|
658
|
+
})), R;
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
}), null), D;
|
|
662
|
+
})(), (() => {
|
|
663
|
+
var D = st();
|
|
664
|
+
return D.firstChild, e(D, g(w, {
|
|
665
|
+
get when() {
|
|
666
|
+
return i();
|
|
667
|
+
},
|
|
668
|
+
get children() {
|
|
669
|
+
var A = se();
|
|
670
|
+
return e(A, i), A;
|
|
671
|
+
}
|
|
672
|
+
}), null), e(D, g(w, {
|
|
673
|
+
get when() {
|
|
674
|
+
return n.loading;
|
|
675
|
+
},
|
|
676
|
+
get children() {
|
|
677
|
+
return nt();
|
|
678
|
+
}
|
|
679
|
+
}), null), e(D, g(w, {
|
|
680
|
+
get when() {
|
|
681
|
+
return n();
|
|
682
|
+
},
|
|
683
|
+
children: (A) => g(w, {
|
|
684
|
+
get when() {
|
|
685
|
+
return A().length > 0;
|
|
686
|
+
},
|
|
687
|
+
get fallback() {
|
|
688
|
+
return ut();
|
|
689
|
+
},
|
|
690
|
+
get children() {
|
|
691
|
+
var R = ce();
|
|
692
|
+
return e(R, g(X, {
|
|
693
|
+
get each() {
|
|
694
|
+
return A();
|
|
695
|
+
},
|
|
696
|
+
children: (F) => (() => {
|
|
697
|
+
var q = mt(), O = q.firstChild, V = O.firstChild, G = V.nextSibling;
|
|
698
|
+
G.firstChild;
|
|
699
|
+
var I = O.nextSibling;
|
|
700
|
+
return e(V, () => F.provider.charAt(0).toUpperCase() + F.provider.slice(1)), e(G, () => new Date(F.created_at).toLocaleDateString(), null), I.$$click = () => H(F.provider), e(I, () => c() === F.provider ? "Unlinking..." : "Unlink"), E(() => I.disabled = c() === F.provider), q;
|
|
701
|
+
})()
|
|
702
|
+
})), R;
|
|
703
|
+
}
|
|
704
|
+
})
|
|
705
|
+
}), null), D;
|
|
706
|
+
})(), (() => {
|
|
707
|
+
var D = at();
|
|
708
|
+
return D.firstChild, e(D, g(w, {
|
|
709
|
+
get when() {
|
|
710
|
+
return J();
|
|
711
|
+
},
|
|
712
|
+
get children() {
|
|
713
|
+
var A = se();
|
|
714
|
+
return e(A, J), A;
|
|
715
|
+
}
|
|
716
|
+
}), null), e(D, g(w, {
|
|
717
|
+
get when() {
|
|
718
|
+
return N() === "idle";
|
|
719
|
+
},
|
|
720
|
+
get children() {
|
|
721
|
+
var A = it(), R = A.firstChild, F = R.nextSibling;
|
|
722
|
+
return R.$$click = ee, e(R, () => B() ? "Setting up..." : "Set up 2FA"), F.$$click = te, e(F, () => B() ? "Disabling..." : "Disable 2FA"), E((q) => {
|
|
723
|
+
var O = B(), V = B();
|
|
724
|
+
return O !== q.e && (R.disabled = q.e = O), V !== q.t && (F.disabled = q.t = V), q;
|
|
725
|
+
}, {
|
|
726
|
+
e: void 0,
|
|
727
|
+
t: void 0
|
|
728
|
+
}), A;
|
|
729
|
+
}
|
|
730
|
+
}), null), e(D, g(w, {
|
|
731
|
+
get when() {
|
|
732
|
+
return N() === "confirm";
|
|
733
|
+
},
|
|
734
|
+
get children() {
|
|
735
|
+
var A = lt(), R = A.firstChild, F = R.nextSibling, q = F.firstChild, O = q.nextSibling, V = F.nextSibling, G = V.firstChild, I = G.nextSibling, Z = V.nextSibling, le = Z.firstChild, fe = le.firstChild, re = fe.nextSibling, oe = le.nextSibling;
|
|
736
|
+
return e(O, s), e(I, k), Z.addEventListener("submit", K), re.$$input = (Q) => x(Q.currentTarget.value), e(oe, () => B() ? "Verifying..." : "Verify and enable"), E((Q) => {
|
|
737
|
+
var ae = B(), de = B();
|
|
738
|
+
return ae !== Q.e && (re.disabled = Q.e = ae), de !== Q.t && (oe.disabled = Q.t = de), Q;
|
|
739
|
+
}, {
|
|
740
|
+
e: void 0,
|
|
741
|
+
t: void 0
|
|
742
|
+
}), E(() => re.value = y()), A;
|
|
743
|
+
}
|
|
744
|
+
}), null), e(D, g(w, {
|
|
745
|
+
get when() {
|
|
746
|
+
return N() === "done";
|
|
747
|
+
},
|
|
748
|
+
get children() {
|
|
749
|
+
var A = ot(), R = A.firstChild, F = R.nextSibling;
|
|
750
|
+
return e(F, g(X, {
|
|
751
|
+
get each() {
|
|
752
|
+
return L();
|
|
753
|
+
},
|
|
754
|
+
children: (q) => (() => {
|
|
755
|
+
var O = gt();
|
|
756
|
+
return e(O, q), O;
|
|
757
|
+
})()
|
|
758
|
+
})), A;
|
|
759
|
+
}
|
|
760
|
+
}), null), D;
|
|
761
|
+
})()]
|
|
762
|
+
}), null), T;
|
|
763
|
+
})();
|
|
764
|
+
};
|
|
765
|
+
Y(["click", "input"]);
|
|
766
|
+
var ft = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), pt = /* @__PURE__ */ l('<form class=space-y-6><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-register-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-register-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-register-password>Password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-register-password name=password type=password required autocomplete=new-password></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-register-display-name>Display name (optional)</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-register-display-name name=display_name type=text autocomplete=name></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
|
|
767
|
+
const qt = (r) => {
|
|
768
|
+
const {
|
|
769
|
+
client: v
|
|
770
|
+
} = z(), [f, h] = d(""), [$, p] = d(""), [S, _] = d(""), [u, n] = d(null), [m, i] = d(!1), t = async (c) => {
|
|
771
|
+
c.preventDefault(), n(null), i(!0);
|
|
772
|
+
try {
|
|
773
|
+
const a = c.currentTarget, s = new FormData(a), o = s.get("display_name") || S(), k = await v.emailPassword.register({
|
|
774
|
+
email: s.get("email") || f(),
|
|
775
|
+
password: s.get("password") || $(),
|
|
776
|
+
display_name: o || void 0
|
|
777
|
+
});
|
|
778
|
+
r.onSuccess?.(k.message);
|
|
779
|
+
} catch (a) {
|
|
780
|
+
const s = a instanceof Error ? a : new Error(String(a));
|
|
781
|
+
n(s.message), r.onError?.(s);
|
|
782
|
+
} finally {
|
|
783
|
+
i(!1);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
return (() => {
|
|
787
|
+
var c = pt(), a = c.firstChild, s = a.firstChild, o = s.nextSibling, k = a.nextSibling, b = k.firstChild, y = b.nextSibling, x = k.nextSibling, L = x.firstChild, M = L.nextSibling, N = x.nextSibling;
|
|
788
|
+
return c.addEventListener("submit", t), e(c, g(w, {
|
|
789
|
+
get when() {
|
|
790
|
+
return u();
|
|
791
|
+
},
|
|
792
|
+
get children() {
|
|
793
|
+
var P = ft();
|
|
794
|
+
return e(P, u), P;
|
|
795
|
+
}
|
|
796
|
+
}), a), o.$$input = (P) => h(P.currentTarget.value), y.$$input = (P) => p(P.currentTarget.value), M.$$input = (P) => _(P.currentTarget.value), e(N, () => m() ? "Creating account..." : "Create account"), E((P) => {
|
|
797
|
+
var J = m(), C = m(), B = m(), U = m();
|
|
798
|
+
return J !== P.e && (o.disabled = P.e = J), C !== P.t && (y.disabled = P.t = C), B !== P.a && (M.disabled = P.a = B), U !== P.o && (N.disabled = P.o = U), P;
|
|
799
|
+
}, {
|
|
800
|
+
e: void 0,
|
|
801
|
+
t: void 0,
|
|
802
|
+
a: void 0,
|
|
803
|
+
o: void 0
|
|
804
|
+
}), E(() => o.value = f()), E(() => y.value = $()), E(() => M.value = S()), c;
|
|
805
|
+
})();
|
|
806
|
+
};
|
|
807
|
+
Y(["input"]);
|
|
808
|
+
var bt = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), vt = /* @__PURE__ */ l('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), ht = /* @__PURE__ */ l('<form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-reset-password-input>New password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-reset-password-input name=password type=password required autocomplete=new-password></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
|
|
809
|
+
const Rt = (r) => {
|
|
810
|
+
const {
|
|
811
|
+
client: v
|
|
812
|
+
} = z(), [f, h] = d(""), [$, p] = d(null), [S, _] = d(null), [u, n] = d(!1), m = async (i) => {
|
|
813
|
+
i.preventDefault(), p(null), _(null), n(!0);
|
|
814
|
+
try {
|
|
815
|
+
const t = i.currentTarget, c = new FormData(t), a = await v.emailPassword.resetPassword(r.token, c.get("password") || f());
|
|
816
|
+
_(a.message), r.onSuccess?.(a.message);
|
|
817
|
+
} catch (t) {
|
|
818
|
+
const c = t instanceof Error ? t : new Error(String(t));
|
|
819
|
+
p(c.message);
|
|
820
|
+
} finally {
|
|
821
|
+
n(!1);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
return (() => {
|
|
825
|
+
var i = ht(), t = i.firstChild, c = t.firstChild, a = c.nextSibling, s = t.nextSibling;
|
|
826
|
+
return i.addEventListener("submit", m), e(i, g(w, {
|
|
827
|
+
get when() {
|
|
828
|
+
return $();
|
|
829
|
+
},
|
|
830
|
+
get children() {
|
|
831
|
+
var o = bt();
|
|
832
|
+
return e(o, $), o;
|
|
833
|
+
}
|
|
834
|
+
}), t), e(i, g(w, {
|
|
835
|
+
get when() {
|
|
836
|
+
return S();
|
|
837
|
+
},
|
|
838
|
+
get children() {
|
|
839
|
+
var o = vt();
|
|
840
|
+
return e(o, S), o;
|
|
841
|
+
}
|
|
842
|
+
}), t), a.$$input = (o) => h(o.currentTarget.value), e(s, () => u() ? "Resetting..." : "Reset password"), E((o) => {
|
|
843
|
+
var k = u(), b = u();
|
|
844
|
+
return k !== o.e && (a.disabled = o.e = k), b !== o.t && (s.disabled = o.t = b), o;
|
|
845
|
+
}, {
|
|
846
|
+
e: void 0,
|
|
847
|
+
t: void 0
|
|
848
|
+
}), E(() => a.value = f()), i;
|
|
849
|
+
})();
|
|
850
|
+
};
|
|
851
|
+
Y(["input"]);
|
|
852
|
+
var yt = /* @__PURE__ */ l('<div class="text-sm text-muted-foreground">Verifying your email address...'), xt = /* @__PURE__ */ l('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), wt = /* @__PURE__ */ l('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), $t = /* @__PURE__ */ l("<div class=space-y-4>");
|
|
853
|
+
const Nt = (r) => {
|
|
854
|
+
const {
|
|
855
|
+
client: v
|
|
856
|
+
} = z(), [f, h] = d("loading"), [$, p] = d(""), [S, _] = d("");
|
|
857
|
+
return me(async () => {
|
|
858
|
+
try {
|
|
859
|
+
const u = await v.emailPassword.verify(r.token);
|
|
860
|
+
p(u.message), h("success"), r.onSuccess?.();
|
|
861
|
+
} catch (u) {
|
|
862
|
+
const n = u instanceof Error ? u : new Error(String(u));
|
|
863
|
+
_(n.message), h("error"), r.onError?.(n);
|
|
864
|
+
}
|
|
865
|
+
}), (() => {
|
|
866
|
+
var u = $t();
|
|
867
|
+
return e(u, g(w, {
|
|
868
|
+
get when() {
|
|
869
|
+
return f() === "loading";
|
|
870
|
+
},
|
|
871
|
+
get children() {
|
|
872
|
+
return yt();
|
|
873
|
+
}
|
|
874
|
+
}), null), e(u, g(w, {
|
|
875
|
+
get when() {
|
|
876
|
+
return f() === "success";
|
|
877
|
+
},
|
|
878
|
+
get children() {
|
|
879
|
+
var n = xt();
|
|
880
|
+
return e(n, $), n;
|
|
881
|
+
}
|
|
882
|
+
}), null), e(u, g(w, {
|
|
883
|
+
get when() {
|
|
884
|
+
return f() === "error";
|
|
885
|
+
},
|
|
886
|
+
get children() {
|
|
887
|
+
var n = wt();
|
|
888
|
+
return e(n, S), n;
|
|
889
|
+
}
|
|
890
|
+
}), null), u;
|
|
891
|
+
})();
|
|
892
|
+
};
|
|
893
|
+
export {
|
|
894
|
+
Et as ChangePasswordForm,
|
|
895
|
+
Pt as ConsentScreen,
|
|
896
|
+
Dt as ForgotPasswordForm,
|
|
897
|
+
Tt as LoginForm,
|
|
898
|
+
Lt as MagicLinkForm,
|
|
899
|
+
At as MfaChallenge,
|
|
900
|
+
jt as MfaSetup,
|
|
901
|
+
Ft as OAuthButtons,
|
|
902
|
+
Le as PasskeyButton,
|
|
903
|
+
Mt as ProfileSettings,
|
|
904
|
+
qt as RegisterForm,
|
|
905
|
+
Rt as ResetPasswordForm,
|
|
906
|
+
Nt as VerifyEmail,
|
|
907
|
+
Ct as YAuthProvider,
|
|
908
|
+
z as useYAuth
|
|
909
|
+
};
|