@camstack/addon-auth 1.2.173 → 1.2.174

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.
@@ -1,12 +1,12 @@
1
1
  import { n as e, r as t, t as n } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare__react__loadShare__.js-BIIa6vDX.mjs";
2
2
  import { n as r, t as i } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CQ-aEQ9b.mjs";
3
- import { n as a, t as o } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DDAXLfIp.mjs";
4
- import { n as s, r as c, t as l } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-BL2etuqg.mjs";
3
+ import { i as a, n as o, r as s, t as c } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BF8PLF8n.mjs";
4
+ import { n as l, r as u, t as d } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-BL2etuqg.mjs";
5
5
  //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
6
- var u = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), d = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), f = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), p = (e) => {
7
- let t = f(e);
6
+ var f = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), p = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), m = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), h = (e) => {
7
+ let t = m(e);
8
8
  return t.charAt(0).toUpperCase() + t.slice(1);
9
- }, m = {
9
+ }, g = {
10
10
  xmlns: "http://www.w3.org/2000/svg",
11
11
  width: 24,
12
12
  height: 24,
@@ -16,28 +16,28 @@ var u = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
16
16
  strokeWidth: 2,
17
17
  strokeLinecap: "round",
18
18
  strokeLinejoin: "round"
19
- }, h = (e) => {
19
+ }, _ = (e) => {
20
20
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
21
21
  return !1;
22
- }, g = e(({ color: e = "currentColor", size: t = 24, strokeWidth: r = 2, absoluteStrokeWidth: i, className: a = "", children: o, iconNode: s, ...c }, l) => n("svg", {
22
+ }, v = e(({ color: e = "currentColor", size: t = 24, strokeWidth: r = 2, absoluteStrokeWidth: i, className: a = "", children: o, iconNode: s, ...c }, l) => n("svg", {
23
23
  ref: l,
24
- ...m,
24
+ ...g,
25
25
  width: t,
26
26
  height: t,
27
27
  stroke: e,
28
28
  strokeWidth: i ? Number(r) * 24 / Number(t) : r,
29
- className: u("lucide", a),
30
- ...!o && !h(c) && { "aria-hidden": "true" },
29
+ className: f("lucide", a),
30
+ ...!o && !_(c) && { "aria-hidden": "true" },
31
31
  ...c
32
- }, [...s.map(([e, t]) => n(e, t)), ...Array.isArray(o) ? o : [o]])), _ = (t, r) => {
33
- let i = e(({ className: e, ...i }, a) => n(g, {
32
+ }, [...s.map(([e, t]) => n(e, t)), ...Array.isArray(o) ? o : [o]])), y = (t, r) => {
33
+ let i = e(({ className: e, ...i }, a) => n(v, {
34
34
  ref: a,
35
35
  iconNode: r,
36
- className: u(`lucide-${d(p(t))}`, `lucide-${t}`, e),
36
+ className: f(`lucide-${p(h(t))}`, `lucide-${t}`, e),
37
37
  ...i
38
38
  }));
39
- return i.displayName = p(t), i;
40
- }, v = _("circle-alert", [
39
+ return i.displayName = h(t), i;
40
+ }, b = y("circle-alert", [
41
41
  ["circle", {
42
42
  cx: "12",
43
43
  cy: "12",
@@ -58,7 +58,7 @@ var u = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
58
58
  y2: "16",
59
59
  key: "4dfq90"
60
60
  }]
61
- ]), y = _("fingerprint-pattern", [
61
+ ]), x = y("fingerprint-pattern", [
62
62
  ["path", {
63
63
  d: "M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",
64
64
  key: "1nerag"
@@ -95,7 +95,7 @@ var u = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
95
95
  d: "M9 6.8a6 6 0 0 1 9 5.2v2",
96
96
  key: "1fr1j5"
97
97
  }]
98
- ]), b = _("key-round", [["path", {
98
+ ]), S = y("key-round", [["path", {
99
99
  d: "M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",
100
100
  key: "1s6t7t"
101
101
  }], ["circle", {
@@ -104,10 +104,10 @@ var u = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
104
104
  r: ".5",
105
105
  fill: "currentColor",
106
106
  key: "w0ekpg"
107
- }]]), x = _("loader-circle", [["path", {
107
+ }]]), C = y("loader-circle", [["path", {
108
108
  d: "M21 12a9 9 0 1 1-6.219-8.56",
109
109
  key: "13zald"
110
- }]]), S = _("trash-2", [
110
+ }]]), w = y("trash-2", [
111
111
  ["path", {
112
112
  d: "M10 11v6",
113
113
  key: "nco0om"
@@ -131,105 +131,105 @@ var u = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
131
131
  ]);
132
132
  //#endregion
133
133
  //#region ../../node_modules/@simplewebauthn/browser/dist/bundle/index.js
134
- function C(e) {
134
+ function T(e) {
135
135
  let t = new Uint8Array(e), n = "";
136
136
  for (let e of t) n += String.fromCharCode(e);
137
137
  return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
138
138
  }
139
- function w(e) {
139
+ function E(e) {
140
140
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = (4 - t.length % 4) % 4, r = t.padEnd(t.length + n, "="), i = atob(r), a = new ArrayBuffer(i.length), o = new Uint8Array(a);
141
141
  for (let e = 0; e < i.length; e++) o[e] = i.charCodeAt(e);
142
142
  return a;
143
143
  }
144
- function T() {
144
+ function D() {
145
145
  return window?.PublicKeyCredential !== void 0 && typeof window.PublicKeyCredential == "function";
146
146
  }
147
- function E(e) {
147
+ function O(e) {
148
148
  let { id: t } = e;
149
149
  return {
150
150
  ...e,
151
- id: w(t),
151
+ id: E(t),
152
152
  transports: e.transports
153
153
  };
154
154
  }
155
- function D(e) {
155
+ function k(e) {
156
156
  return e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e);
157
157
  }
158
- var O = class extends Error {
158
+ var A = class extends Error {
159
159
  constructor({ message: e, code: t, cause: n, name: r }) {
160
160
  super(e, { cause: n }), this.name = r ?? n.name, this.code = t;
161
161
  }
162
162
  };
163
- function k({ error: e, options: t }) {
163
+ function j({ error: e, options: t }) {
164
164
  let { publicKey: n } = t;
165
165
  if (!n) throw Error("options was missing required publicKey property");
166
166
  if (e.name === "AbortError") {
167
- if (t.signal instanceof AbortSignal) return new O({
167
+ if (t.signal instanceof AbortSignal) return new A({
168
168
  message: "Registration ceremony was sent an abort signal",
169
169
  code: "ERROR_CEREMONY_ABORTED",
170
170
  cause: e
171
171
  });
172
172
  } else if (e.name === "ConstraintError") {
173
- if (n.authenticatorSelection?.requireResidentKey === !0) return new O({
173
+ if (n.authenticatorSelection?.requireResidentKey === !0) return new A({
174
174
  message: "Discoverable credentials were required but no available authenticator supported it",
175
175
  code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
176
176
  cause: e
177
177
  });
178
- if (t.mediation === "conditional" && n.authenticatorSelection?.userVerification === "required") return new O({
178
+ if (t.mediation === "conditional" && n.authenticatorSelection?.userVerification === "required") return new A({
179
179
  message: "User verification was required during automatic registration but it could not be performed",
180
180
  code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
181
181
  cause: e
182
182
  });
183
- if (n.authenticatorSelection?.userVerification === "required") return new O({
183
+ if (n.authenticatorSelection?.userVerification === "required") return new A({
184
184
  message: "User verification was required but no available authenticator supported it",
185
185
  code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
186
186
  cause: e
187
187
  });
188
- } else if (e.name === "InvalidStateError") return new O({
188
+ } else if (e.name === "InvalidStateError") return new A({
189
189
  message: "The authenticator was previously registered",
190
190
  code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
191
191
  cause: e
192
192
  });
193
- else if (e.name === "NotAllowedError") return new O({
193
+ else if (e.name === "NotAllowedError") return new A({
194
194
  message: e.message,
195
195
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
196
196
  cause: e
197
197
  });
198
- else if (e.name === "NotSupportedError") return n.pubKeyCredParams.filter((e) => e.type === "public-key").length === 0 ? new O({
198
+ else if (e.name === "NotSupportedError") return n.pubKeyCredParams.filter((e) => e.type === "public-key").length === 0 ? new A({
199
199
  message: "No entry in pubKeyCredParams was of type \"public-key\"",
200
200
  code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
201
201
  cause: e
202
- }) : new O({
202
+ }) : new A({
203
203
  message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
204
204
  code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
205
205
  cause: e
206
206
  });
207
207
  else if (e.name === "SecurityError") {
208
208
  let t = window.location.hostname;
209
- if (!D(t)) return new O({
209
+ if (!k(t)) return new A({
210
210
  message: `${window.location.hostname} is an invalid domain`,
211
211
  code: "ERROR_INVALID_DOMAIN",
212
212
  cause: e
213
213
  });
214
- if (n.rp.id !== t) return new O({
214
+ if (n.rp.id !== t) return new A({
215
215
  message: `The RP ID "${n.rp.id}" is invalid for this domain`,
216
216
  code: "ERROR_INVALID_RP_ID",
217
217
  cause: e
218
218
  });
219
219
  } else if (e.name === "TypeError") {
220
- if (n.user.id.byteLength < 1 || n.user.id.byteLength > 64) return new O({
220
+ if (n.user.id.byteLength < 1 || n.user.id.byteLength > 64) return new A({
221
221
  message: "User ID was not between 1 and 64 characters",
222
222
  code: "ERROR_INVALID_USER_ID_LENGTH",
223
223
  cause: e
224
224
  });
225
- } else if (e.name === "UnknownError") return new O({
225
+ } else if (e.name === "UnknownError") return new A({
226
226
  message: "The authenticator was unable to process the specified options, or could not create a new credential",
227
227
  code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
228
228
  cause: e
229
229
  });
230
230
  return e;
231
231
  }
232
- var A = new class {
232
+ var M = new class {
233
233
  createNewAbortSignal() {
234
234
  if (this.controller) {
235
235
  let e = /* @__PURE__ */ Error("Cancelling existing WebAuthn API call for new one");
@@ -244,28 +244,28 @@ var A = new class {
244
244
  e.name = "AbortError", this.controller.abort(e), this.controller = void 0;
245
245
  }
246
246
  }
247
- }(), j = ["cross-platform", "platform"];
248
- function M(e) {
249
- if (e && !(j.indexOf(e) < 0)) return e;
247
+ }(), N = ["cross-platform", "platform"];
248
+ function P(e) {
249
+ if (e && !(N.indexOf(e) < 0)) return e;
250
250
  }
251
- async function N(e) {
251
+ async function F(e) {
252
252
  let { optionsJSON: t, useAutoRegister: n = !1 } = e;
253
- if (!T()) throw Error("WebAuthn is not supported in this browser");
253
+ if (!D()) throw Error("WebAuthn is not supported in this browser");
254
254
  let r = {
255
255
  ...t,
256
- challenge: w(t.challenge),
256
+ challenge: E(t.challenge),
257
257
  user: {
258
258
  ...t.user,
259
- id: w(t.user.id)
259
+ id: E(t.user.id)
260
260
  },
261
- excludeCredentials: t.excludeCredentials?.map(E)
261
+ excludeCredentials: t.excludeCredentials?.map(O)
262
262
  }, i = {};
263
- n && (i.mediation = "conditional"), i.publicKey = r, i.signal = A.createNewAbortSignal();
263
+ n && (i.mediation = "conditional"), i.publicKey = r, i.signal = M.createNewAbortSignal();
264
264
  let a;
265
265
  try {
266
266
  a = await navigator.credentials.create(i);
267
267
  } catch (e) {
268
- throw k({
268
+ throw j({
269
269
  error: e,
270
270
  options: i
271
271
  });
@@ -277,27 +277,27 @@ async function N(e) {
277
277
  if (typeof c.getPublicKeyAlgorithm == "function") try {
278
278
  d = c.getPublicKeyAlgorithm();
279
279
  } catch (e) {
280
- P("getPublicKeyAlgorithm()", e);
280
+ I("getPublicKeyAlgorithm()", e);
281
281
  }
282
282
  let f;
283
283
  if (typeof c.getPublicKey == "function") try {
284
284
  let e = c.getPublicKey();
285
- e !== null && (f = C(e));
285
+ e !== null && (f = T(e));
286
286
  } catch (e) {
287
- P("getPublicKey()", e);
287
+ I("getPublicKey()", e);
288
288
  }
289
289
  let p;
290
290
  if (typeof c.getAuthenticatorData == "function") try {
291
- p = C(c.getAuthenticatorData());
291
+ p = T(c.getAuthenticatorData());
292
292
  } catch (e) {
293
- P("getAuthenticatorData()", e);
293
+ I("getAuthenticatorData()", e);
294
294
  }
295
295
  return {
296
296
  id: o,
297
- rawId: C(s),
297
+ rawId: T(s),
298
298
  response: {
299
- attestationObject: C(c.attestationObject),
300
- clientDataJSON: C(c.clientDataJSON),
299
+ attestationObject: T(c.attestationObject),
300
+ clientDataJSON: T(c.clientDataJSON),
301
301
  transports: u,
302
302
  publicKeyAlgorithm: d,
303
303
  publicKey: f,
@@ -305,121 +305,121 @@ async function N(e) {
305
305
  },
306
306
  type: l,
307
307
  clientExtensionResults: a.getClientExtensionResults(),
308
- authenticatorAttachment: M(a.authenticatorAttachment)
308
+ authenticatorAttachment: P(a.authenticatorAttachment)
309
309
  };
310
310
  }
311
- function P(e, t) {
311
+ function I(e, t) {
312
312
  console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`, t);
313
313
  }
314
- function F() {
315
- if (!T()) return new Promise((e) => e(!1));
314
+ function L() {
315
+ if (!D()) return new Promise((e) => e(!1));
316
316
  let e = window.PublicKeyCredential;
317
317
  return e.isConditionalMediationAvailable === void 0 ? new Promise((e) => e(!1)) : e.isConditionalMediationAvailable();
318
318
  }
319
- function I({ error: e, options: t }) {
319
+ function R({ error: e, options: t }) {
320
320
  let { publicKey: n } = t;
321
321
  if (!n) throw Error("options was missing required publicKey property");
322
322
  if (e.name === "AbortError") {
323
- if (t.signal instanceof AbortSignal) return new O({
323
+ if (t.signal instanceof AbortSignal) return new A({
324
324
  message: "Authentication ceremony was sent an abort signal",
325
325
  code: "ERROR_CEREMONY_ABORTED",
326
326
  cause: e
327
327
  });
328
- } else if (e.name === "NotAllowedError") return new O({
328
+ } else if (e.name === "NotAllowedError") return new A({
329
329
  message: e.message,
330
330
  code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
331
331
  cause: e
332
332
  });
333
333
  else if (e.name === "SecurityError") {
334
334
  let t = window.location.hostname;
335
- if (!D(t)) return new O({
335
+ if (!k(t)) return new A({
336
336
  message: `${window.location.hostname} is an invalid domain`,
337
337
  code: "ERROR_INVALID_DOMAIN",
338
338
  cause: e
339
339
  });
340
- if (n.rpId !== t) return new O({
340
+ if (n.rpId !== t) return new A({
341
341
  message: `The RP ID "${n.rpId}" is invalid for this domain`,
342
342
  code: "ERROR_INVALID_RP_ID",
343
343
  cause: e
344
344
  });
345
- } else if (e.name === "UnknownError") return new O({
345
+ } else if (e.name === "UnknownError") return new A({
346
346
  message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
347
347
  code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
348
348
  cause: e
349
349
  });
350
350
  return e;
351
351
  }
352
- async function L(e) {
352
+ async function z(e) {
353
353
  let { optionsJSON: t, useBrowserAutofill: n = !1, verifyBrowserAutofillInput: r = !0 } = e;
354
- if (!T()) throw Error("WebAuthn is not supported in this browser");
354
+ if (!D()) throw Error("WebAuthn is not supported in this browser");
355
355
  let i;
356
- t.allowCredentials?.length !== 0 && (i = t.allowCredentials?.map(E));
356
+ t.allowCredentials?.length !== 0 && (i = t.allowCredentials?.map(O));
357
357
  let a = {
358
358
  ...t,
359
- challenge: w(t.challenge),
359
+ challenge: E(t.challenge),
360
360
  allowCredentials: i
361
361
  }, o = {};
362
362
  if (n) {
363
- if (!await F()) throw Error("Browser does not support WebAuthn autofill");
363
+ if (!await L()) throw Error("Browser does not support WebAuthn autofill");
364
364
  if (document.querySelectorAll("input[autocomplete$='webauthn']").length < 1 && r) throw Error("No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected");
365
365
  o.mediation = "conditional", a.allowCredentials = [];
366
366
  }
367
- o.publicKey = a, o.signal = A.createNewAbortSignal();
367
+ o.publicKey = a, o.signal = M.createNewAbortSignal();
368
368
  let s;
369
369
  try {
370
370
  s = await navigator.credentials.get(o);
371
371
  } catch (e) {
372
- throw I({
372
+ throw R({
373
373
  error: e,
374
374
  options: o
375
375
  });
376
376
  }
377
377
  if (!s) throw Error("Authentication was not completed");
378
378
  let { id: c, rawId: l, response: u, type: d } = s, f;
379
- return u.userHandle && (f = C(u.userHandle)), {
379
+ return u.userHandle && (f = T(u.userHandle)), {
380
380
  id: c,
381
- rawId: C(l),
381
+ rawId: T(l),
382
382
  response: {
383
- authenticatorData: C(u.authenticatorData),
384
- clientDataJSON: C(u.clientDataJSON),
385
- signature: C(u.signature),
383
+ authenticatorData: T(u.authenticatorData),
384
+ clientDataJSON: T(u.clientDataJSON),
385
+ signature: T(u.signature),
386
386
  userHandle: f
387
387
  },
388
388
  type: d,
389
389
  clientExtensionResults: s.getClientExtensionResults(),
390
- authenticatorAttachment: M(s.authenticatorAttachment)
390
+ authenticatorAttachment: P(s.authenticatorAttachment)
391
391
  };
392
392
  }
393
393
  //#endregion
394
394
  //#region src/webauthn/widgets/passkey-ceremony.ts
395
- function R() {
396
- return T();
395
+ function B() {
396
+ return D();
397
397
  }
398
- function z(e) {
398
+ function V(e) {
399
399
  return {
400
400
  ...e,
401
401
  challenge: e.challenge
402
402
  };
403
403
  }
404
- function B(e) {
404
+ function H(e) {
405
405
  return {
406
406
  ...e,
407
407
  challenge: e.challenge
408
408
  };
409
409
  }
410
- async function V(e) {
410
+ async function U(e) {
411
411
  if (typeof e.challenge != "string") throw Error("passkey authentication options missing challenge");
412
- let t = await L({ optionsJSON: z(e) });
412
+ let t = await z({ optionsJSON: V(e) });
413
413
  return Object.fromEntries(Object.entries(t));
414
414
  }
415
- async function H(e) {
415
+ async function W(e) {
416
416
  if (typeof e.challenge != "string") throw Error("passkey registration options missing challenge");
417
- let t = await N({ optionsJSON: B(e) });
417
+ let t = await F({ optionsJSON: H(e) });
418
418
  return Object.fromEntries(Object.entries(t));
419
419
  }
420
420
  //#endregion
421
421
  //#region src/i18n/index.ts
422
- var { useT: U } = a("auth-webauthn", {
422
+ var { useT: G } = a("auth-webauthn", {
423
423
  en: {
424
424
  directLogin: {
425
425
  requiresCallback: "Passkey direct-login widget requires an onComplete callback.",
@@ -497,39 +497,39 @@ var { useT: U } = a("auth-webauthn", {
497
497
  });
498
498
  //#endregion
499
499
  //#region src/webauthn/widgets/PasskeyEnrollment.tsx
500
- function W(e) {
501
- let n = o(), { t: a, lang: u } = U(), d = r({
500
+ function K(e) {
501
+ let n = c(), { t: a, lang: f } = G(), p = r({
502
502
  queryKey: ["auth", "listOwnPasskeys"],
503
503
  queryFn: () => n.listOwnPasskeys()
504
- }), f = d.data ?? [], [p, m] = t(""), [h, g] = t(!1), [_, C] = t(null), w = r({
504
+ }), m = p.data ?? [], [h, g] = t(""), [_, v] = t(!1), [y, T] = t(null), E = r({
505
505
  queryKey: ["auth", "getOwnPasskeySecondFactorPreference"],
506
506
  queryFn: () => n.getOwnPasskeySecondFactorPreference(),
507
- enabled: f.length > 0
508
- }), T = w.data?.enabled ?? !1, E = i({
507
+ enabled: m.length > 0
508
+ }), D = E.data?.enabled ?? !1, O = i({
509
509
  mutationFn: (e) => n.setOwnPasskeySecondFactorPreference({ enabled: e }),
510
510
  onSuccess: () => {
511
- C(null), w.refetch();
511
+ T(null), E.refetch();
512
512
  },
513
- onError: (e) => C(e instanceof Error ? e.message : a("enrollment.preferenceFailed"))
514
- }), D = async () => {
515
- C(null), g(!0);
513
+ onError: (e) => T(e instanceof Error ? e.message : a("enrollment.preferenceFailed"))
514
+ }), k = async () => {
515
+ T(null), v(!0);
516
516
  try {
517
- let e = await H((await n.beginOwnPasskeyRegistration()).optionsJSON);
517
+ let e = await W((await n.beginOwnPasskeyRegistration()).optionsJSON);
518
518
  await n.finishOwnPasskeyRegistration({
519
519
  response: e,
520
- label: p.trim() || a("enrollment.unnamedDevice")
521
- }), m(""), d.refetch();
520
+ label: h.trim() || a("enrollment.unnamedDevice")
521
+ }), g(""), p.refetch();
522
522
  } catch (e) {
523
- C(e instanceof Error ? e.message : a("enrollment.enrollFailed"));
523
+ T(e instanceof Error ? e.message : a("enrollment.enrollFailed"));
524
524
  } finally {
525
- g(!1);
525
+ v(!1);
526
526
  }
527
- }, [O, k] = t(null), [A, j] = t(""), M = i({
527
+ }, [A, j] = t(null), [M, N] = t(""), P = i({
528
528
  mutationFn: async (e) => {
529
529
  let t;
530
530
  if ("password" in e.proof) t = (await n.reauthenticate({ password: e.proof.password })).reauthToken;
531
531
  else {
532
- let { optionsJSON: e } = await n.reauthBeginPasskey(), r = await V(e);
532
+ let { optionsJSON: e } = await n.reauthBeginPasskey(), r = await U(e);
533
533
  t = (await n.reauthenticate({ passkeyResponse: r })).reauthToken;
534
534
  }
535
535
  return n.removeOwnPasskey({
@@ -538,75 +538,77 @@ function W(e) {
538
538
  });
539
539
  },
540
540
  onSuccess: () => {
541
- C(null), k(null), j(""), d.refetch();
541
+ T(null), j(null), N(""), p.refetch();
542
542
  },
543
- onError: (e) => C(e instanceof Error ? e.message : a("enrollment.removeFailed"))
543
+ onError: (e) => T(e instanceof Error ? e.message : a("enrollment.removeFailed"))
544
544
  });
545
- return /* @__PURE__ */ c("div", {
545
+ return /* @__PURE__ */ u("div", {
546
546
  className: "rounded-lg border border-border bg-surface overflow-hidden",
547
- children: [/* @__PURE__ */ c("div", {
547
+ children: [/* @__PURE__ */ u("div", {
548
548
  className: "px-4 py-2.5 border-b border-border flex items-center gap-2",
549
- children: [/* @__PURE__ */ s(y, { className: "h-3.5 w-3.5 text-foreground-subtle" }), /* @__PURE__ */ s("div", {
549
+ children: [/* @__PURE__ */ l(x, { className: "h-3.5 w-3.5 text-foreground-subtle" }), /* @__PURE__ */ l("div", {
550
550
  className: "text-xs font-semibold text-foreground",
551
551
  children: a("enrollment.title")
552
552
  })]
553
- }), /* @__PURE__ */ c("div", {
553
+ }), /* @__PURE__ */ u("div", {
554
554
  className: "p-4 space-y-3",
555
555
  children: [
556
- /* @__PURE__ */ s("div", {
556
+ /* @__PURE__ */ l("div", {
557
557
  className: "text-xs text-foreground-subtle",
558
558
  children: a("enrollment.intro")
559
559
  }),
560
- d.isLoading ? /* @__PURE__ */ c("div", {
560
+ p.isLoading ? /* @__PURE__ */ u("div", {
561
561
  className: "flex items-center gap-2 text-xs text-foreground-subtle",
562
- children: [/* @__PURE__ */ s(x, { className: "h-3.5 w-3.5 animate-spin" }), a("enrollment.loading")]
563
- }) : f.length > 0 ? /* @__PURE__ */ s("ul", {
562
+ children: [/* @__PURE__ */ l(C, { className: "h-3.5 w-3.5 animate-spin" }), a("enrollment.loading")]
563
+ }) : m.length > 0 ? /* @__PURE__ */ l("ul", {
564
564
  className: "divide-y divide-border rounded-md border border-border",
565
- children: f.map((e) => /* @__PURE__ */ c("li", {
565
+ children: m.map((e) => /* @__PURE__ */ u("li", {
566
566
  className: "flex items-center gap-3 px-3 py-2 text-xs",
567
567
  children: [
568
- /* @__PURE__ */ s(b, { className: "h-3.5 w-3.5 text-foreground-subtle shrink-0" }),
569
- /* @__PURE__ */ c("div", {
568
+ /* @__PURE__ */ l(S, { className: "h-3.5 w-3.5 text-foreground-subtle shrink-0" }),
569
+ /* @__PURE__ */ u("div", {
570
570
  className: "flex-1 min-w-0",
571
- children: [/* @__PURE__ */ s("div", {
571
+ children: [/* @__PURE__ */ l("div", {
572
572
  className: "font-medium text-foreground truncate",
573
573
  children: e.label
574
- }), /* @__PURE__ */ s("div", {
574
+ }), /* @__PURE__ */ l("div", {
575
575
  className: "text-[10px] text-foreground-subtle",
576
576
  children: e.lastUsedAt ? a("enrollment.addedUsed", {
577
- added: new Date(e.createdAt).toLocaleDateString(u),
578
- used: new Date(e.lastUsedAt).toLocaleDateString(u)
579
- }) : a("enrollment.addedNever", { added: new Date(e.createdAt).toLocaleDateString(u) })
577
+ added: new Date(e.createdAt).toLocaleDateString(f),
578
+ used: new Date(e.lastUsedAt).toLocaleDateString(f)
579
+ }) : a("enrollment.addedNever", { added: new Date(e.createdAt).toLocaleDateString(f) })
580
580
  })]
581
581
  }),
582
- O === e.credentialId ? /* @__PURE__ */ c("form", {
582
+ A === e.credentialId ? /* @__PURE__ */ u("form", {
583
583
  className: "flex items-center gap-1.5",
584
584
  onSubmit: (t) => {
585
- t.preventDefault(), A.length > 0 && M.mutate({
585
+ t.preventDefault(), M.length > 0 && P.mutate({
586
586
  credentialId: e.credentialId,
587
- proof: { password: A }
587
+ proof: { password: M }
588
588
  });
589
589
  },
590
590
  children: [
591
- /* @__PURE__ */ s("input", {
591
+ /* @__PURE__ */ l(o, {
592
592
  type: "password",
593
593
  autoComplete: "current-password",
594
594
  "aria-label": a("enrollment.currentPassword"),
595
595
  placeholder: a("enrollment.passwordToConfirm"),
596
- value: A,
597
- onChange: (e) => j(e.target.value),
596
+ value: M,
597
+ onChange: (e) => N(e.target.value),
598
598
  className: "w-36 rounded border border-border bg-background px-2 py-1 text-[11px]"
599
599
  }),
600
- /* @__PURE__ */ s("button", {
600
+ /* @__PURE__ */ l(s, {
601
+ variant: "unstyled",
601
602
  type: "submit",
602
- disabled: A.length === 0 || M.isPending,
603
+ disabled: M.length === 0 || P.isPending,
603
604
  className: "rounded px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50",
604
605
  children: a("enrollment.remove")
605
606
  }),
606
- /* @__PURE__ */ s("button", {
607
+ /* @__PURE__ */ l(s, {
608
+ variant: "unstyled",
607
609
  type: "button",
608
- disabled: M.isPending,
609
- onClick: () => M.mutate({
610
+ disabled: P.isPending,
611
+ onClick: () => P.mutate({
610
612
  credentialId: e.credentialId,
611
613
  proof: { passkey: !0 }
612
614
  }),
@@ -614,65 +616,68 @@ function W(e) {
614
616
  children: a("enrollment.usePasskey")
615
617
  })
616
618
  ]
617
- }) : /* @__PURE__ */ c("button", {
619
+ }) : /* @__PURE__ */ u(s, {
620
+ variant: "unstyled",
618
621
  onClick: () => {
619
- C(null), j(""), k(e.credentialId);
622
+ T(null), N(""), j(e.credentialId);
620
623
  },
621
- disabled: M.isPending,
624
+ disabled: P.isPending,
622
625
  className: "inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50",
623
- children: [/* @__PURE__ */ s(S, { className: "h-3 w-3" }), a("enrollment.remove")]
626
+ children: [/* @__PURE__ */ l(w, { className: "h-3 w-3" }), a("enrollment.remove")]
624
627
  })
625
628
  ]
626
629
  }, e.credentialId))
627
- }) : /* @__PURE__ */ s("div", {
630
+ }) : /* @__PURE__ */ l("div", {
628
631
  className: "text-[11px] text-foreground-subtle",
629
632
  children: a("enrollment.none")
630
633
  }),
631
- f.length > 0 && /* @__PURE__ */ c("div", {
634
+ m.length > 0 && /* @__PURE__ */ u("div", {
632
635
  className: "flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2.5",
633
- children: [/* @__PURE__ */ c("div", {
636
+ children: [/* @__PURE__ */ u("div", {
634
637
  className: "min-w-0",
635
- children: [/* @__PURE__ */ s("div", {
638
+ children: [/* @__PURE__ */ l("div", {
636
639
  className: "text-xs font-medium text-foreground",
637
640
  children: a("enrollment.secondFactorTitle")
638
- }), /* @__PURE__ */ s("div", {
641
+ }), /* @__PURE__ */ l("div", {
639
642
  className: "text-[10px] text-foreground-subtle mt-0.5",
640
643
  children: a("enrollment.secondFactorHint")
641
644
  })]
642
- }), /* @__PURE__ */ s("button", {
645
+ }), /* @__PURE__ */ l(s, {
646
+ variant: "unstyled",
643
647
  type: "button",
644
648
  role: "switch",
645
- "aria-checked": T,
649
+ "aria-checked": D,
646
650
  "aria-label": a("enrollment.secondFactorTitle"),
647
- onClick: () => E.mutate(!T),
648
- disabled: w.isLoading || E.isPending,
649
- className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:opacity-50 ${T ? "bg-primary" : "bg-foreground-subtle/30"}`,
650
- children: /* @__PURE__ */ s("span", { className: `inline-block h-3.5 w-3.5 rounded-full bg-white shadow transition-transform ${T ? "translate-x-[18px]" : "translate-x-[3px]"}` })
651
+ onClick: () => O.mutate(!D),
652
+ disabled: E.isLoading || O.isPending,
653
+ className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:opacity-50 ${D ? "bg-primary" : "bg-foreground-subtle/30"}`,
654
+ children: /* @__PURE__ */ l("span", { className: `inline-block h-3.5 w-3.5 rounded-full bg-white shadow transition-transform ${D ? "translate-x-[18px]" : "translate-x-[3px]"}` })
651
655
  })]
652
656
  }),
653
- _ && /* @__PURE__ */ c("div", {
657
+ y && /* @__PURE__ */ u("div", {
654
658
  className: "text-[11px] text-danger flex items-center gap-1",
655
- children: [/* @__PURE__ */ s(v, { className: "h-3 w-3" }), _]
659
+ children: [/* @__PURE__ */ l(b, { className: "h-3 w-3" }), y]
656
660
  }),
657
- /* @__PURE__ */ c("div", {
661
+ /* @__PURE__ */ u("div", {
658
662
  className: "flex items-end gap-2",
659
- children: [/* @__PURE__ */ c("div", {
663
+ children: [/* @__PURE__ */ u("div", {
660
664
  className: "flex-1 space-y-1",
661
- children: [/* @__PURE__ */ s("label", {
665
+ children: [/* @__PURE__ */ l("label", {
662
666
  className: "text-[10px] uppercase tracking-wide text-foreground-subtle",
663
667
  children: a("enrollment.passkeyName")
664
- }), /* @__PURE__ */ s("input", {
668
+ }), /* @__PURE__ */ l(o, {
665
669
  type: "text",
666
- value: p,
667
- onChange: (e) => m(e.target.value),
670
+ value: h,
671
+ onChange: (e) => g(e.target.value),
668
672
  placeholder: a("enrollment.namePlaceholder"),
669
673
  className: "w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"
670
674
  })]
671
- }), /* @__PURE__ */ s("button", {
672
- onClick: D,
673
- disabled: h,
675
+ }), /* @__PURE__ */ l(s, {
676
+ variant: "unstyled",
677
+ onClick: k,
678
+ disabled: _,
674
679
  className: "inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-2 text-xs font-semibold text-primary-foreground hover:opacity-90 disabled:opacity-50",
675
- children: h ? /* @__PURE__ */ c(l, { children: [/* @__PURE__ */ s(x, { className: "h-3.5 w-3.5 animate-spin" }), a("enrollment.enrolling")] }) : /* @__PURE__ */ c(l, { children: [/* @__PURE__ */ s(y, { className: "h-3.5 w-3.5" }), a("enrollment.addPasskey")] })
680
+ children: _ ? /* @__PURE__ */ u(d, { children: [/* @__PURE__ */ l(C, { className: "h-3.5 w-3.5 animate-spin" }), a("enrollment.enrolling")] }) : /* @__PURE__ */ u(d, { children: [/* @__PURE__ */ l(x, { className: "h-3.5 w-3.5" }), a("enrollment.addPasskey")] })
676
681
  })]
677
682
  })
678
683
  ]
@@ -681,7 +686,7 @@ function W(e) {
681
686
  }
682
687
  //#endregion
683
688
  //#region src/webauthn/widgets/PasskeyLogin.tsx
684
- function G(e) {
689
+ function q(e) {
685
690
  if (!e) return null;
686
691
  let t = e.challengeToken, n = e.onComplete, r = e.onError;
687
692
  return typeof t != "string" || typeof n != "function" ? null : {
@@ -690,43 +695,44 @@ function G(e) {
690
695
  onError: typeof r == "function" ? r : void 0
691
696
  };
692
697
  }
693
- function K(e) {
694
- let n = o(), { t: r } = U(), i = G(e.config), [a, l] = t(!1), [u, d] = t(null);
695
- return i ? R() ? /* @__PURE__ */ c("div", {
698
+ function J(e) {
699
+ let n = c(), { t: r } = G(), i = q(e.config), [a, o] = t(!1), [d, f] = t(null);
700
+ return i ? B() ? /* @__PURE__ */ u("div", {
696
701
  className: "space-y-2",
697
- children: [/* @__PURE__ */ c("button", {
702
+ children: [/* @__PURE__ */ u(s, {
703
+ variant: "unstyled",
698
704
  type: "button",
699
705
  "data-testid": "login-passkey",
700
706
  onClick: async () => {
701
- d(null), l(!0);
707
+ f(null), o(!0);
702
708
  try {
703
- let e = await V((await n.loginBeginPasskey(i.challengeToken)).optionsJSON), t = await n.loginVerifyPasskey(i.challengeToken, e);
709
+ let e = await U((await n.loginBeginPasskey(i.challengeToken)).optionsJSON), t = await n.loginVerifyPasskey(i.challengeToken, e);
704
710
  i.onComplete(t.token);
705
711
  } catch (e) {
706
712
  let t = e instanceof Error ? e.message : r("login.verificationFailed");
707
- d(t), i.onError?.(t);
713
+ f(t), i.onError?.(t);
708
714
  } finally {
709
- l(!1);
715
+ o(!1);
710
716
  }
711
717
  },
712
718
  disabled: a,
713
719
  className: "w-full flex items-center justify-center gap-2 rounded-lg border border-border bg-background px-4 py-2.5 text-sm font-semibold text-foreground hover:bg-surface-hover disabled:opacity-50 transition-all",
714
- children: [a ? /* @__PURE__ */ s(x, { className: "h-4 w-4 animate-spin text-primary" }) : /* @__PURE__ */ s(y, { className: "h-4 w-4 text-primary" }), r("login.usePasskey")]
715
- }), u && /* @__PURE__ */ s("div", {
720
+ children: [a ? /* @__PURE__ */ l(C, { className: "h-4 w-4 animate-spin text-primary" }) : /* @__PURE__ */ l(x, { className: "h-4 w-4 text-primary" }), r("login.usePasskey")]
721
+ }), d && /* @__PURE__ */ l("div", {
716
722
  className: "rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",
717
- children: u
723
+ children: d
718
724
  })]
719
- }) : /* @__PURE__ */ s("div", {
725
+ }) : /* @__PURE__ */ l("div", {
720
726
  className: "rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle",
721
727
  children: r("login.unsupported")
722
- }) : /* @__PURE__ */ s("div", {
728
+ }) : /* @__PURE__ */ l("div", {
723
729
  className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
724
730
  children: r("login.requiresChallenge")
725
731
  });
726
732
  }
727
733
  //#endregion
728
734
  //#region src/webauthn/widgets/PasskeyDirectLogin.tsx
729
- function q(e) {
735
+ function Y(e) {
730
736
  if (!e) return null;
731
737
  let t = e.onComplete, n = e.onSecondFactor, r = e.onError, i = e.locale;
732
738
  return typeof t == "function" ? {
@@ -736,57 +742,58 @@ function q(e) {
736
742
  locale: typeof i == "string" ? i : void 0
737
743
  } : null;
738
744
  }
739
- function J(e) {
740
- let n = o(), r = q(e.config), [i, a] = t(!1), [l, u] = t(null), { t: d } = U(r?.locale);
741
- return r ? R() ? /* @__PURE__ */ c("div", {
745
+ function X(e) {
746
+ let n = c(), r = Y(e.config), [i, a] = t(!1), [o, d] = t(null), { t: f } = G(r?.locale);
747
+ return r ? B() ? /* @__PURE__ */ u("div", {
742
748
  className: "space-y-2",
743
- children: [/* @__PURE__ */ c("button", {
749
+ children: [/* @__PURE__ */ u(s, {
750
+ variant: "unstyled",
744
751
  type: "button",
745
752
  "data-testid": "login-passkey-direct",
746
753
  onClick: async () => {
747
- u(null), a(!0);
754
+ d(null), a(!0);
748
755
  try {
749
- let e = await V((await n.passkeyLoginBegin()).optionsJSON), t = await n.passkeyLoginFinish(e), i = t.secondFactors ?? (t.requiresTotp === !0 ? ["totp"] : []);
756
+ let e = await U((await n.passkeyLoginBegin()).optionsJSON), t = await n.passkeyLoginFinish(e), i = t.secondFactors ?? (t.requiresTotp === !0 ? ["totp"] : []);
750
757
  if (i.length > 0) {
751
758
  if (r.onSecondFactor) r.onSecondFactor({
752
759
  challengeToken: t.token,
753
760
  factors: i
754
761
  });
755
762
  else {
756
- let e = d("directLogin.secondFactorRequired");
757
- u(e), r.onError?.(e);
763
+ let e = f("directLogin.secondFactorRequired");
764
+ d(e), r.onError?.(e);
758
765
  }
759
766
  return;
760
767
  }
761
768
  r.onComplete(t.token);
762
769
  } catch (e) {
763
- let t = e instanceof Error ? e.message : d("directLogin.failed");
764
- u(t), r.onError?.(t);
770
+ let t = e instanceof Error ? e.message : f("directLogin.failed");
771
+ d(t), r.onError?.(t);
765
772
  } finally {
766
773
  a(!1);
767
774
  }
768
775
  },
769
776
  disabled: i,
770
777
  className: "w-full flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover disabled:opacity-50 transition-colors",
771
- children: [i ? /* @__PURE__ */ s(x, { className: "h-4 w-4 animate-spin text-primary" }) : /* @__PURE__ */ s(y, { className: "h-4 w-4 text-primary" }), d("directLogin.signInWithPasskey")]
772
- }), l && /* @__PURE__ */ s("div", {
778
+ children: [i ? /* @__PURE__ */ l(C, { className: "h-4 w-4 animate-spin text-primary" }) : /* @__PURE__ */ l(x, { className: "h-4 w-4 text-primary" }), f("directLogin.signInWithPasskey")]
779
+ }), o && /* @__PURE__ */ l("div", {
773
780
  className: "rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",
774
- children: l
781
+ children: o
775
782
  })]
776
- }) : /* @__PURE__ */ s("div", {
783
+ }) : /* @__PURE__ */ l("div", {
777
784
  className: "rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle",
778
- children: d("directLogin.unsupported")
779
- }) : /* @__PURE__ */ s("div", {
785
+ children: f("directLogin.unsupported")
786
+ }) : /* @__PURE__ */ l("div", {
780
787
  className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
781
- children: d("directLogin.requiresCallback")
788
+ children: f("directLogin.requiresCallback")
782
789
  });
783
790
  }
784
791
  //#endregion
785
792
  //#region src/webauthn/widgets/index.tsx
786
- var Y = {
787
- "passkey-enrollment": W,
788
- "passkey-login": K,
789
- "passkey-direct-login": J
793
+ var Z = {
794
+ "passkey-enrollment": K,
795
+ "passkey-login": J,
796
+ "passkey-direct-login": X
790
797
  };
791
798
  //#endregion
792
- export { Y as default };
799
+ export { Z as default };