@camstack/addon-auth 1.2.146 → 1.2.148
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/{dist-DtqB-MTf.js → dist-C2ZA1nlf.js} +214 -7
- package/dist/{dist-BtJOajm3.mjs → dist-roKTj364.mjs} +209 -8
- package/dist/oidc/auth-oidc.addon.js +5 -3
- package/dist/oidc/auth-oidc.addon.mjs +5 -3
- package/dist/webauthn/_stub.js +290 -235
- package/dist/webauthn/{_virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-C3_j2tlC.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-DDuFEkrD.mjs} +3 -3
- package/dist/webauthn/_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Jb_VAQPj.mjs +26 -0
- package/dist/webauthn/auth-webauthn.addon.js +1 -1
- package/dist/webauthn/auth-webauthn.addon.mjs +1 -1
- package/dist/webauthn/{hostInit-H35G8h3o.mjs → hostInit-BnyCwNxS.mjs} +3 -3
- package/dist/webauthn/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/webauthn/_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C_j9tv24.mjs +0 -26
package/dist/webauthn/_stub.js
CHANGED
|
@@ -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 {
|
|
4
|
-
import { n as
|
|
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-Jb_VAQPj.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";
|
|
5
5
|
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
|
|
6
|
-
var
|
|
7
|
-
let t =
|
|
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);
|
|
8
8
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
9
|
-
},
|
|
9
|
+
}, m = {
|
|
10
10
|
xmlns: "http://www.w3.org/2000/svg",
|
|
11
11
|
width: 24,
|
|
12
12
|
height: 24,
|
|
@@ -16,28 +16,28 @@ var l = (...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
|
-
},
|
|
19
|
+
}, h = (e) => {
|
|
20
20
|
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
21
21
|
return !1;
|
|
22
|
-
},
|
|
23
|
-
ref:
|
|
24
|
-
...
|
|
22
|
+
}, g = e(({ color: e = "currentColor", size: t = 24, strokeWidth: r = 2, absoluteStrokeWidth: i, className: a = "", children: o, iconNode: s, ...c }, l) => n("svg", {
|
|
23
|
+
ref: l,
|
|
24
|
+
...m,
|
|
25
25
|
width: t,
|
|
26
26
|
height: t,
|
|
27
27
|
stroke: e,
|
|
28
28
|
strokeWidth: i ? Number(r) * 24 / Number(t) : r,
|
|
29
|
-
className:
|
|
30
|
-
...!o && !
|
|
29
|
+
className: u("lucide", a),
|
|
30
|
+
...!o && !h(c) && { "aria-hidden": "true" },
|
|
31
31
|
...c
|
|
32
|
-
}, [...s.map(([e, t]) => n(e, t)), ...Array.isArray(o) ? o : [o]])),
|
|
33
|
-
let i = e(({ className: e, ...i }, a) => n(
|
|
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, {
|
|
34
34
|
ref: a,
|
|
35
35
|
iconNode: r,
|
|
36
|
-
className:
|
|
36
|
+
className: u(`lucide-${d(p(t))}`, `lucide-${t}`, e),
|
|
37
37
|
...i
|
|
38
38
|
}));
|
|
39
|
-
return i.displayName =
|
|
40
|
-
},
|
|
39
|
+
return i.displayName = p(t), i;
|
|
40
|
+
}, v = _("circle-alert", [
|
|
41
41
|
["circle", {
|
|
42
42
|
cx: "12",
|
|
43
43
|
cy: "12",
|
|
@@ -58,7 +58,7 @@ var l = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
58
58
|
y2: "16",
|
|
59
59
|
key: "4dfq90"
|
|
60
60
|
}]
|
|
61
|
-
]),
|
|
61
|
+
]), 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 l = (...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
|
-
]),
|
|
98
|
+
]), b = _("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 l = (...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
|
-
}]]),
|
|
107
|
+
}]]), x = _("loader-circle", [["path", {
|
|
108
108
|
d: "M21 12a9 9 0 1 1-6.219-8.56",
|
|
109
109
|
key: "13zald"
|
|
110
|
-
}]]),
|
|
110
|
+
}]]), S = _("trash-2", [
|
|
111
111
|
["path", {
|
|
112
112
|
d: "M10 11v6",
|
|
113
113
|
key: "nco0om"
|
|
@@ -131,105 +131,105 @@ var l = (...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
|
|
134
|
+
function C(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
|
|
139
|
+
function w(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
|
|
144
|
+
function T() {
|
|
145
145
|
return window?.PublicKeyCredential !== void 0 && typeof window.PublicKeyCredential == "function";
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function E(e) {
|
|
148
148
|
let { id: t } = e;
|
|
149
149
|
return {
|
|
150
150
|
...e,
|
|
151
|
-
id:
|
|
151
|
+
id: w(t),
|
|
152
152
|
transports: e.transports
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function D(e) {
|
|
156
156
|
return e === "localhost" || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e);
|
|
157
157
|
}
|
|
158
|
-
var
|
|
158
|
+
var O = 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
|
|
163
|
+
function k({ 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
|
|
167
|
+
if (t.signal instanceof AbortSignal) return new O({
|
|
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
|
|
173
|
+
if (n.authenticatorSelection?.requireResidentKey === !0) return new O({
|
|
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
|
|
178
|
+
if (t.mediation === "conditional" && n.authenticatorSelection?.userVerification === "required") return new O({
|
|
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
|
|
183
|
+
if (n.authenticatorSelection?.userVerification === "required") return new O({
|
|
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
|
|
188
|
+
} else if (e.name === "InvalidStateError") return new O({
|
|
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
|
|
193
|
+
else if (e.name === "NotAllowedError") return new O({
|
|
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
|
|
198
|
+
else if (e.name === "NotSupportedError") return n.pubKeyCredParams.filter((e) => e.type === "public-key").length === 0 ? new O({
|
|
199
199
|
message: "No entry in pubKeyCredParams was of type \"public-key\"",
|
|
200
200
|
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
201
201
|
cause: e
|
|
202
|
-
}) : new
|
|
202
|
+
}) : new O({
|
|
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 (!
|
|
209
|
+
if (!D(t)) return new O({
|
|
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
|
|
214
|
+
if (n.rp.id !== t) return new O({
|
|
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
|
|
220
|
+
if (n.user.id.byteLength < 1 || n.user.id.byteLength > 64) return new O({
|
|
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
|
|
225
|
+
} else if (e.name === "UnknownError") return new O({
|
|
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
|
|
232
|
+
var A = 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 k = new class {
|
|
|
244
244
|
e.name = "AbortError", this.controller.abort(e), this.controller = void 0;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
}(),
|
|
248
|
-
function
|
|
249
|
-
if (e && !(
|
|
247
|
+
}(), j = ["cross-platform", "platform"];
|
|
248
|
+
function M(e) {
|
|
249
|
+
if (e && !(j.indexOf(e) < 0)) return e;
|
|
250
250
|
}
|
|
251
|
-
async function
|
|
251
|
+
async function N(e) {
|
|
252
252
|
let { optionsJSON: t, useAutoRegister: n = !1 } = e;
|
|
253
|
-
if (!
|
|
253
|
+
if (!T()) throw Error("WebAuthn is not supported in this browser");
|
|
254
254
|
let r = {
|
|
255
255
|
...t,
|
|
256
|
-
challenge:
|
|
256
|
+
challenge: w(t.challenge),
|
|
257
257
|
user: {
|
|
258
258
|
...t.user,
|
|
259
|
-
id:
|
|
259
|
+
id: w(t.user.id)
|
|
260
260
|
},
|
|
261
|
-
excludeCredentials: t.excludeCredentials?.map(
|
|
261
|
+
excludeCredentials: t.excludeCredentials?.map(E)
|
|
262
262
|
}, i = {};
|
|
263
|
-
n && (i.mediation = "conditional"), i.publicKey = r, i.signal =
|
|
263
|
+
n && (i.mediation = "conditional"), i.publicKey = r, i.signal = A.createNewAbortSignal();
|
|
264
264
|
let a;
|
|
265
265
|
try {
|
|
266
266
|
a = await navigator.credentials.create(i);
|
|
267
267
|
} catch (e) {
|
|
268
|
-
throw
|
|
268
|
+
throw k({
|
|
269
269
|
error: e,
|
|
270
270
|
options: i
|
|
271
271
|
});
|
|
@@ -277,27 +277,27 @@ async function M(e) {
|
|
|
277
277
|
if (typeof c.getPublicKeyAlgorithm == "function") try {
|
|
278
278
|
d = c.getPublicKeyAlgorithm();
|
|
279
279
|
} catch (e) {
|
|
280
|
-
|
|
280
|
+
P("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 =
|
|
285
|
+
e !== null && (f = C(e));
|
|
286
286
|
} catch (e) {
|
|
287
|
-
|
|
287
|
+
P("getPublicKey()", e);
|
|
288
288
|
}
|
|
289
289
|
let p;
|
|
290
290
|
if (typeof c.getAuthenticatorData == "function") try {
|
|
291
|
-
p =
|
|
291
|
+
p = C(c.getAuthenticatorData());
|
|
292
292
|
} catch (e) {
|
|
293
|
-
|
|
293
|
+
P("getAuthenticatorData()", e);
|
|
294
294
|
}
|
|
295
295
|
return {
|
|
296
296
|
id: o,
|
|
297
|
-
rawId:
|
|
297
|
+
rawId: C(s),
|
|
298
298
|
response: {
|
|
299
|
-
attestationObject:
|
|
300
|
-
clientDataJSON:
|
|
299
|
+
attestationObject: C(c.attestationObject),
|
|
300
|
+
clientDataJSON: C(c.clientDataJSON),
|
|
301
301
|
transports: u,
|
|
302
302
|
publicKeyAlgorithm: d,
|
|
303
303
|
publicKey: f,
|
|
@@ -305,139 +305,217 @@ async function M(e) {
|
|
|
305
305
|
},
|
|
306
306
|
type: l,
|
|
307
307
|
clientExtensionResults: a.getClientExtensionResults(),
|
|
308
|
-
authenticatorAttachment:
|
|
308
|
+
authenticatorAttachment: M(a.authenticatorAttachment)
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function P(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
|
|
315
|
-
if (!
|
|
314
|
+
function F() {
|
|
315
|
+
if (!T()) 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
|
|
319
|
+
function I({ 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
|
|
323
|
+
if (t.signal instanceof AbortSignal) return new O({
|
|
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
|
|
328
|
+
} else if (e.name === "NotAllowedError") return new O({
|
|
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 (!
|
|
335
|
+
if (!D(t)) return new O({
|
|
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
|
|
340
|
+
if (n.rpId !== t) return new O({
|
|
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
|
|
345
|
+
} else if (e.name === "UnknownError") return new O({
|
|
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
|
|
352
|
+
async function L(e) {
|
|
353
353
|
let { optionsJSON: t, useBrowserAutofill: n = !1, verifyBrowserAutofillInput: r = !0 } = e;
|
|
354
|
-
if (!
|
|
354
|
+
if (!T()) throw Error("WebAuthn is not supported in this browser");
|
|
355
355
|
let i;
|
|
356
|
-
t.allowCredentials?.length !== 0 && (i = t.allowCredentials?.map(
|
|
356
|
+
t.allowCredentials?.length !== 0 && (i = t.allowCredentials?.map(E));
|
|
357
357
|
let a = {
|
|
358
358
|
...t,
|
|
359
|
-
challenge:
|
|
359
|
+
challenge: w(t.challenge),
|
|
360
360
|
allowCredentials: i
|
|
361
361
|
}, o = {};
|
|
362
362
|
if (n) {
|
|
363
|
-
if (!await
|
|
363
|
+
if (!await F()) 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 =
|
|
367
|
+
o.publicKey = a, o.signal = A.createNewAbortSignal();
|
|
368
368
|
let s;
|
|
369
369
|
try {
|
|
370
370
|
s = await navigator.credentials.get(o);
|
|
371
371
|
} catch (e) {
|
|
372
|
-
throw
|
|
372
|
+
throw I({
|
|
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 =
|
|
379
|
+
return u.userHandle && (f = C(u.userHandle)), {
|
|
380
380
|
id: c,
|
|
381
|
-
rawId:
|
|
381
|
+
rawId: C(l),
|
|
382
382
|
response: {
|
|
383
|
-
authenticatorData:
|
|
384
|
-
clientDataJSON:
|
|
385
|
-
signature:
|
|
383
|
+
authenticatorData: C(u.authenticatorData),
|
|
384
|
+
clientDataJSON: C(u.clientDataJSON),
|
|
385
|
+
signature: C(u.signature),
|
|
386
386
|
userHandle: f
|
|
387
387
|
},
|
|
388
388
|
type: d,
|
|
389
389
|
clientExtensionResults: s.getClientExtensionResults(),
|
|
390
|
-
authenticatorAttachment:
|
|
390
|
+
authenticatorAttachment: M(s.authenticatorAttachment)
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
//#endregion
|
|
394
394
|
//#region src/webauthn/widgets/passkey-ceremony.ts
|
|
395
|
-
function
|
|
396
|
-
return
|
|
395
|
+
function R() {
|
|
396
|
+
return T();
|
|
397
397
|
}
|
|
398
|
-
async function
|
|
399
|
-
let t = await
|
|
398
|
+
async function z(e) {
|
|
399
|
+
let t = await L({ optionsJSON: e });
|
|
400
400
|
return Object.fromEntries(Object.entries(t));
|
|
401
401
|
}
|
|
402
|
-
async function
|
|
403
|
-
let t = await
|
|
402
|
+
async function B(e) {
|
|
403
|
+
let t = await N({ optionsJSON: e });
|
|
404
404
|
return Object.fromEntries(Object.entries(t));
|
|
405
405
|
}
|
|
406
406
|
//#endregion
|
|
407
|
+
//#region src/i18n/index.ts
|
|
408
|
+
var { useT: V } = a("auth-webauthn", {
|
|
409
|
+
en: {
|
|
410
|
+
directLogin: {
|
|
411
|
+
requiresCallback: "Passkey direct-login widget requires an onComplete callback.",
|
|
412
|
+
signInWithPasskey: "Sign in with a passkey",
|
|
413
|
+
unsupported: "This browser does not support passkeys.",
|
|
414
|
+
failed: "Passkey sign-in failed",
|
|
415
|
+
secondFactorRequired: "Additional verification is required — sign in with your password to continue."
|
|
416
|
+
},
|
|
417
|
+
login: {
|
|
418
|
+
requiresChallenge: "Passkey login widget requires a challengeToken + onComplete callback.",
|
|
419
|
+
unsupported: "This browser does not support passkeys.",
|
|
420
|
+
verificationFailed: "Passkey verification failed",
|
|
421
|
+
usePasskey: "Use a passkey"
|
|
422
|
+
},
|
|
423
|
+
enrollment: {
|
|
424
|
+
title: "Passkeys",
|
|
425
|
+
intro: "Add a passkey (Touch ID, Windows Hello, or a security key) to sign in directly — fast and phishing-resistant, no password needed.",
|
|
426
|
+
loading: "Loading passkeys…",
|
|
427
|
+
addedUsed: "Added {{added}} · last used {{used}}",
|
|
428
|
+
addedNever: "Added {{added}} · never used",
|
|
429
|
+
currentPassword: "Current password",
|
|
430
|
+
passwordToConfirm: "Password to confirm",
|
|
431
|
+
remove: "Remove",
|
|
432
|
+
usePasskey: "Use a passkey",
|
|
433
|
+
none: "No passkeys enrolled yet.",
|
|
434
|
+
secondFactorTitle: "Require passkey as second factor",
|
|
435
|
+
secondFactorHint: "Also ask for a passkey after every password sign-in. Off by default — enrolling a passkey on its own only enables direct passkey sign-in.",
|
|
436
|
+
passkeyName: "Passkey name",
|
|
437
|
+
namePlaceholder: "e.g. MacBook Touch ID",
|
|
438
|
+
enrolling: "Enrolling…",
|
|
439
|
+
addPasskey: "Add passkey",
|
|
440
|
+
unnamedDevice: "Unnamed device",
|
|
441
|
+
preferenceFailed: "Could not update the preference",
|
|
442
|
+
enrollFailed: "Passkey enrollment failed",
|
|
443
|
+
removeFailed: "Remove failed"
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
it: {
|
|
447
|
+
directLogin: {
|
|
448
|
+
requiresCallback: "Il widget di accesso diretto con passkey richiede una callback onComplete.",
|
|
449
|
+
signInWithPasskey: "Accedi con una passkey",
|
|
450
|
+
unsupported: "Questo browser non supporta le passkey.",
|
|
451
|
+
failed: "Accesso con passkey non riuscito",
|
|
452
|
+
secondFactorRequired: "È richiesta una verifica aggiuntiva — accedi con la password per continuare."
|
|
453
|
+
},
|
|
454
|
+
login: {
|
|
455
|
+
requiresChallenge: "Il widget di accesso con passkey richiede un challengeToken e una callback onComplete.",
|
|
456
|
+
unsupported: "Questo browser non supporta le passkey.",
|
|
457
|
+
verificationFailed: "Verifica della passkey non riuscita",
|
|
458
|
+
usePasskey: "Usa una passkey"
|
|
459
|
+
},
|
|
460
|
+
enrollment: {
|
|
461
|
+
title: "Passkey",
|
|
462
|
+
intro: "Aggiungi una passkey (Touch ID, Windows Hello o una chiave di sicurezza) per accedere direttamente: veloce, resistente al phishing e senza password.",
|
|
463
|
+
loading: "Caricamento passkey…",
|
|
464
|
+
addedUsed: "Aggiunta il {{added}} · ultimo utilizzo {{used}}",
|
|
465
|
+
addedNever: "Aggiunta il {{added}} · mai utilizzata",
|
|
466
|
+
currentPassword: "Password attuale",
|
|
467
|
+
passwordToConfirm: "Password per confermare",
|
|
468
|
+
remove: "Rimuovi",
|
|
469
|
+
usePasskey: "Usa una passkey",
|
|
470
|
+
none: "Nessuna passkey registrata.",
|
|
471
|
+
secondFactorTitle: "Richiedi la passkey come secondo fattore",
|
|
472
|
+
secondFactorHint: "Chiedi una passkey anche dopo ogni accesso con password. Disattivato per impostazione predefinita: registrare una passkey abilita soltanto l'accesso diretto con passkey.",
|
|
473
|
+
passkeyName: "Nome della passkey",
|
|
474
|
+
namePlaceholder: "es. MacBook Touch ID",
|
|
475
|
+
enrolling: "Registrazione…",
|
|
476
|
+
addPasskey: "Aggiungi passkey",
|
|
477
|
+
unnamedDevice: "Dispositivo senza nome",
|
|
478
|
+
preferenceFailed: "Impossibile aggiornare la preferenza",
|
|
479
|
+
enrollFailed: "Registrazione della passkey non riuscita",
|
|
480
|
+
removeFailed: "Rimozione non riuscita"
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
//#endregion
|
|
407
485
|
//#region src/webauthn/widgets/PasskeyEnrollment.tsx
|
|
408
|
-
function
|
|
409
|
-
let n = a(),
|
|
486
|
+
function H(e) {
|
|
487
|
+
let n = o(), { t: a, lang: u } = V(), d = r({
|
|
410
488
|
queryKey: ["auth", "listOwnPasskeys"],
|
|
411
489
|
queryFn: () => n.listOwnPasskeys()
|
|
412
|
-
}),
|
|
490
|
+
}), f = d.data ?? [], [p, m] = t(""), [h, g] = t(!1), [_, C] = t(null), w = r({
|
|
413
491
|
queryKey: ["auth", "getOwnPasskeySecondFactorPreference"],
|
|
414
492
|
queryFn: () => n.getOwnPasskeySecondFactorPreference(),
|
|
415
|
-
enabled:
|
|
416
|
-
}),
|
|
493
|
+
enabled: f.length > 0
|
|
494
|
+
}), T = w.data?.enabled ?? !1, E = i({
|
|
417
495
|
mutationFn: (e) => n.setOwnPasskeySecondFactorPreference({ enabled: e }),
|
|
418
496
|
onSuccess: () => {
|
|
419
|
-
|
|
497
|
+
C(null), w.refetch();
|
|
420
498
|
},
|
|
421
|
-
onError: (e) =>
|
|
422
|
-
}),
|
|
423
|
-
|
|
499
|
+
onError: (e) => C(e instanceof Error ? e.message : a("enrollment.preferenceFailed"))
|
|
500
|
+
}), D = async () => {
|
|
501
|
+
C(null), g(!0);
|
|
424
502
|
try {
|
|
425
|
-
let e = await
|
|
503
|
+
let e = await B((await n.beginOwnPasskeyRegistration()).optionsJSON);
|
|
426
504
|
await n.finishOwnPasskeyRegistration({
|
|
427
505
|
response: e,
|
|
428
|
-
label:
|
|
429
|
-
}),
|
|
506
|
+
label: p.trim() || a("enrollment.unnamedDevice")
|
|
507
|
+
}), m(""), d.refetch();
|
|
430
508
|
} catch (e) {
|
|
431
|
-
|
|
509
|
+
C(e instanceof Error ? e.message : a("enrollment.enrollFailed"));
|
|
432
510
|
} finally {
|
|
433
|
-
|
|
511
|
+
g(!1);
|
|
434
512
|
}
|
|
435
|
-
}, [
|
|
513
|
+
}, [O, k] = t(null), [A, j] = t(""), M = i({
|
|
436
514
|
mutationFn: async (e) => {
|
|
437
515
|
let t;
|
|
438
516
|
if ("password" in e.proof) t = (await n.reauthenticate({ password: e.proof.password })).reauthToken;
|
|
439
517
|
else {
|
|
440
|
-
let { optionsJSON: e } = await n.reauthBeginPasskey(), r = await
|
|
518
|
+
let { optionsJSON: e } = await n.reauthBeginPasskey(), r = await z(e);
|
|
441
519
|
t = (await n.reauthenticate({ passkeyResponse: r })).reauthToken;
|
|
442
520
|
}
|
|
443
521
|
return n.removeOwnPasskey({
|
|
@@ -446,142 +524,141 @@ function B(e) {
|
|
|
446
524
|
});
|
|
447
525
|
},
|
|
448
526
|
onSuccess: () => {
|
|
449
|
-
|
|
527
|
+
C(null), k(null), j(""), d.refetch();
|
|
450
528
|
},
|
|
451
|
-
onError: (e) =>
|
|
529
|
+
onError: (e) => C(e instanceof Error ? e.message : a("enrollment.removeFailed"))
|
|
452
530
|
});
|
|
453
|
-
return /* @__PURE__ */
|
|
531
|
+
return /* @__PURE__ */ c("div", {
|
|
454
532
|
className: "rounded-lg border border-border bg-surface overflow-hidden",
|
|
455
|
-
children: [/* @__PURE__ */
|
|
533
|
+
children: [/* @__PURE__ */ c("div", {
|
|
456
534
|
className: "px-4 py-2.5 border-b border-border flex items-center gap-2",
|
|
457
|
-
children: [/* @__PURE__ */
|
|
535
|
+
children: [/* @__PURE__ */ s(y, { className: "h-3.5 w-3.5 text-foreground-subtle" }), /* @__PURE__ */ s("div", {
|
|
458
536
|
className: "text-xs font-semibold text-foreground",
|
|
459
|
-
children: "
|
|
537
|
+
children: a("enrollment.title")
|
|
460
538
|
})]
|
|
461
|
-
}), /* @__PURE__ */
|
|
539
|
+
}), /* @__PURE__ */ c("div", {
|
|
462
540
|
className: "p-4 space-y-3",
|
|
463
541
|
children: [
|
|
464
|
-
/* @__PURE__ */
|
|
542
|
+
/* @__PURE__ */ s("div", {
|
|
465
543
|
className: "text-xs text-foreground-subtle",
|
|
466
|
-
children:
|
|
544
|
+
children: a("enrollment.intro")
|
|
467
545
|
}),
|
|
468
|
-
|
|
546
|
+
d.isLoading ? /* @__PURE__ */ c("div", {
|
|
469
547
|
className: "flex items-center gap-2 text-xs text-foreground-subtle",
|
|
470
|
-
children: [/* @__PURE__ */
|
|
471
|
-
}) :
|
|
548
|
+
children: [/* @__PURE__ */ s(x, { className: "h-3.5 w-3.5 animate-spin" }), a("enrollment.loading")]
|
|
549
|
+
}) : f.length > 0 ? /* @__PURE__ */ s("ul", {
|
|
472
550
|
className: "divide-y divide-border rounded-md border border-border",
|
|
473
|
-
children:
|
|
551
|
+
children: f.map((e) => /* @__PURE__ */ c("li", {
|
|
474
552
|
className: "flex items-center gap-3 px-3 py-2 text-xs",
|
|
475
553
|
children: [
|
|
476
|
-
/* @__PURE__ */
|
|
477
|
-
/* @__PURE__ */
|
|
554
|
+
/* @__PURE__ */ s(b, { className: "h-3.5 w-3.5 text-foreground-subtle shrink-0" }),
|
|
555
|
+
/* @__PURE__ */ c("div", {
|
|
478
556
|
className: "flex-1 min-w-0",
|
|
479
|
-
children: [/* @__PURE__ */
|
|
557
|
+
children: [/* @__PURE__ */ s("div", {
|
|
480
558
|
className: "font-medium text-foreground truncate",
|
|
481
559
|
children: e.label
|
|
482
560
|
}), /* @__PURE__ */ s("div", {
|
|
483
561
|
className: "text-[10px] text-foreground-subtle",
|
|
484
|
-
children:
|
|
485
|
-
|
|
486
|
-
new Date(e.
|
|
487
|
-
|
|
488
|
-
]
|
|
562
|
+
children: e.lastUsedAt ? a("enrollment.addedUsed", {
|
|
563
|
+
added: new Date(e.createdAt).toLocaleDateString(u),
|
|
564
|
+
used: new Date(e.lastUsedAt).toLocaleDateString(u)
|
|
565
|
+
}) : a("enrollment.addedNever", { added: new Date(e.createdAt).toLocaleDateString(u) })
|
|
489
566
|
})]
|
|
490
567
|
}),
|
|
491
|
-
|
|
568
|
+
O === e.credentialId ? /* @__PURE__ */ c("form", {
|
|
492
569
|
className: "flex items-center gap-1.5",
|
|
493
570
|
onSubmit: (t) => {
|
|
494
|
-
t.preventDefault(),
|
|
571
|
+
t.preventDefault(), A.length > 0 && M.mutate({
|
|
495
572
|
credentialId: e.credentialId,
|
|
496
|
-
proof: { password:
|
|
573
|
+
proof: { password: A }
|
|
497
574
|
});
|
|
498
575
|
},
|
|
499
576
|
children: [
|
|
500
|
-
/* @__PURE__ */
|
|
577
|
+
/* @__PURE__ */ s("input", {
|
|
501
578
|
type: "password",
|
|
502
579
|
autoComplete: "current-password",
|
|
503
|
-
"aria-label": "
|
|
504
|
-
placeholder: "
|
|
505
|
-
value:
|
|
506
|
-
onChange: (e) =>
|
|
580
|
+
"aria-label": a("enrollment.currentPassword"),
|
|
581
|
+
placeholder: a("enrollment.passwordToConfirm"),
|
|
582
|
+
value: A,
|
|
583
|
+
onChange: (e) => j(e.target.value),
|
|
507
584
|
className: "w-36 rounded border border-border bg-background px-2 py-1 text-[11px]"
|
|
508
585
|
}),
|
|
509
|
-
/* @__PURE__ */
|
|
586
|
+
/* @__PURE__ */ s("button", {
|
|
510
587
|
type: "submit",
|
|
511
|
-
disabled:
|
|
588
|
+
disabled: A.length === 0 || M.isPending,
|
|
512
589
|
className: "rounded px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50",
|
|
513
|
-
children: "
|
|
590
|
+
children: a("enrollment.remove")
|
|
514
591
|
}),
|
|
515
|
-
/* @__PURE__ */
|
|
592
|
+
/* @__PURE__ */ s("button", {
|
|
516
593
|
type: "button",
|
|
517
|
-
disabled:
|
|
518
|
-
onClick: () =>
|
|
594
|
+
disabled: M.isPending,
|
|
595
|
+
onClick: () => M.mutate({
|
|
519
596
|
credentialId: e.credentialId,
|
|
520
597
|
proof: { passkey: !0 }
|
|
521
598
|
}),
|
|
522
599
|
className: "rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-50",
|
|
523
|
-
children:
|
|
600
|
+
children: a("enrollment.usePasskey")
|
|
524
601
|
})
|
|
525
602
|
]
|
|
526
|
-
}) : /* @__PURE__ */
|
|
603
|
+
}) : /* @__PURE__ */ c("button", {
|
|
527
604
|
onClick: () => {
|
|
528
|
-
|
|
605
|
+
C(null), j(""), k(e.credentialId);
|
|
529
606
|
},
|
|
530
|
-
disabled:
|
|
607
|
+
disabled: M.isPending,
|
|
531
608
|
className: "inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50",
|
|
532
|
-
children: [/* @__PURE__ */
|
|
609
|
+
children: [/* @__PURE__ */ s(S, { className: "h-3 w-3" }), a("enrollment.remove")]
|
|
533
610
|
})
|
|
534
611
|
]
|
|
535
612
|
}, e.credentialId))
|
|
536
|
-
}) : /* @__PURE__ */
|
|
613
|
+
}) : /* @__PURE__ */ s("div", {
|
|
537
614
|
className: "text-[11px] text-foreground-subtle",
|
|
538
|
-
children: "
|
|
615
|
+
children: a("enrollment.none")
|
|
539
616
|
}),
|
|
540
|
-
|
|
617
|
+
f.length > 0 && /* @__PURE__ */ c("div", {
|
|
541
618
|
className: "flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2.5",
|
|
542
|
-
children: [/* @__PURE__ */
|
|
619
|
+
children: [/* @__PURE__ */ c("div", {
|
|
543
620
|
className: "min-w-0",
|
|
544
|
-
children: [/* @__PURE__ */
|
|
621
|
+
children: [/* @__PURE__ */ s("div", {
|
|
545
622
|
className: "text-xs font-medium text-foreground",
|
|
546
|
-
children: "
|
|
547
|
-
}), /* @__PURE__ */
|
|
623
|
+
children: a("enrollment.secondFactorTitle")
|
|
624
|
+
}), /* @__PURE__ */ s("div", {
|
|
548
625
|
className: "text-[10px] text-foreground-subtle mt-0.5",
|
|
549
|
-
children: "
|
|
626
|
+
children: a("enrollment.secondFactorHint")
|
|
550
627
|
})]
|
|
551
|
-
}), /* @__PURE__ */
|
|
628
|
+
}), /* @__PURE__ */ s("button", {
|
|
552
629
|
type: "button",
|
|
553
630
|
role: "switch",
|
|
554
|
-
"aria-checked":
|
|
555
|
-
"aria-label": "
|
|
556
|
-
onClick: () =>
|
|
557
|
-
disabled:
|
|
558
|
-
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:opacity-50 ${
|
|
559
|
-
children: /* @__PURE__ */
|
|
631
|
+
"aria-checked": T,
|
|
632
|
+
"aria-label": a("enrollment.secondFactorTitle"),
|
|
633
|
+
onClick: () => E.mutate(!T),
|
|
634
|
+
disabled: w.isLoading || E.isPending,
|
|
635
|
+
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"}`,
|
|
636
|
+
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]"}` })
|
|
560
637
|
})]
|
|
561
638
|
}),
|
|
562
|
-
|
|
639
|
+
_ && /* @__PURE__ */ c("div", {
|
|
563
640
|
className: "text-[11px] text-danger flex items-center gap-1",
|
|
564
|
-
children: [/* @__PURE__ */
|
|
641
|
+
children: [/* @__PURE__ */ s(v, { className: "h-3 w-3" }), _]
|
|
565
642
|
}),
|
|
566
|
-
/* @__PURE__ */
|
|
643
|
+
/* @__PURE__ */ c("div", {
|
|
567
644
|
className: "flex items-end gap-2",
|
|
568
|
-
children: [/* @__PURE__ */
|
|
645
|
+
children: [/* @__PURE__ */ c("div", {
|
|
569
646
|
className: "flex-1 space-y-1",
|
|
570
|
-
children: [/* @__PURE__ */
|
|
647
|
+
children: [/* @__PURE__ */ s("label", {
|
|
571
648
|
className: "text-[10px] uppercase tracking-wide text-foreground-subtle",
|
|
572
|
-
children: "
|
|
573
|
-
}), /* @__PURE__ */
|
|
649
|
+
children: a("enrollment.passkeyName")
|
|
650
|
+
}), /* @__PURE__ */ s("input", {
|
|
574
651
|
type: "text",
|
|
575
|
-
value:
|
|
576
|
-
onChange: (e) =>
|
|
577
|
-
placeholder: "
|
|
652
|
+
value: p,
|
|
653
|
+
onChange: (e) => m(e.target.value),
|
|
654
|
+
placeholder: a("enrollment.namePlaceholder"),
|
|
578
655
|
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"
|
|
579
656
|
})]
|
|
580
|
-
}), /* @__PURE__ */
|
|
581
|
-
onClick:
|
|
582
|
-
disabled:
|
|
657
|
+
}), /* @__PURE__ */ s("button", {
|
|
658
|
+
onClick: D,
|
|
659
|
+
disabled: h,
|
|
583
660
|
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",
|
|
584
|
-
children:
|
|
661
|
+
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")] })
|
|
585
662
|
})]
|
|
586
663
|
})
|
|
587
664
|
]
|
|
@@ -590,7 +667,7 @@ function B(e) {
|
|
|
590
667
|
}
|
|
591
668
|
//#endregion
|
|
592
669
|
//#region src/webauthn/widgets/PasskeyLogin.tsx
|
|
593
|
-
function
|
|
670
|
+
function U(e) {
|
|
594
671
|
if (!e) return null;
|
|
595
672
|
let t = e.challengeToken, n = e.onComplete, r = e.onError;
|
|
596
673
|
return typeof t != "string" || typeof n != "function" ? null : {
|
|
@@ -599,65 +676,43 @@ function V(e) {
|
|
|
599
676
|
onError: typeof r == "function" ? r : void 0
|
|
600
677
|
};
|
|
601
678
|
}
|
|
602
|
-
function
|
|
603
|
-
let n =
|
|
604
|
-
return
|
|
679
|
+
function W(e) {
|
|
680
|
+
let n = o(), { t: r } = V(), i = U(e.config), [a, l] = t(!1), [u, d] = t(null);
|
|
681
|
+
return i ? R() ? /* @__PURE__ */ c("div", {
|
|
605
682
|
className: "space-y-2",
|
|
606
|
-
children: [/* @__PURE__ */
|
|
683
|
+
children: [/* @__PURE__ */ c("button", {
|
|
607
684
|
type: "button",
|
|
608
685
|
"data-testid": "login-passkey",
|
|
609
686
|
onClick: async () => {
|
|
610
|
-
|
|
687
|
+
d(null), l(!0);
|
|
611
688
|
try {
|
|
612
|
-
let e = await
|
|
613
|
-
|
|
689
|
+
let e = await z((await n.loginBeginPasskey(i.challengeToken)).optionsJSON), t = await n.loginVerifyPasskey(i.challengeToken, e);
|
|
690
|
+
i.onComplete(t.token);
|
|
614
691
|
} catch (e) {
|
|
615
|
-
let t = e instanceof Error ? e.message : "
|
|
616
|
-
|
|
692
|
+
let t = e instanceof Error ? e.message : r("login.verificationFailed");
|
|
693
|
+
d(t), i.onError?.(t);
|
|
617
694
|
} finally {
|
|
618
|
-
|
|
695
|
+
l(!1);
|
|
619
696
|
}
|
|
620
697
|
},
|
|
621
|
-
disabled:
|
|
698
|
+
disabled: a,
|
|
622
699
|
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",
|
|
623
|
-
children: [
|
|
624
|
-
}),
|
|
700
|
+
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")]
|
|
701
|
+
}), u && /* @__PURE__ */ s("div", {
|
|
625
702
|
className: "rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",
|
|
626
|
-
children:
|
|
703
|
+
children: u
|
|
627
704
|
})]
|
|
628
|
-
}) : /* @__PURE__ */
|
|
705
|
+
}) : /* @__PURE__ */ s("div", {
|
|
629
706
|
className: "rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle",
|
|
630
|
-
children: "
|
|
631
|
-
}) : /* @__PURE__ */
|
|
707
|
+
children: r("login.unsupported")
|
|
708
|
+
}) : /* @__PURE__ */ s("div", {
|
|
632
709
|
className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
|
|
633
|
-
children: "
|
|
710
|
+
children: r("login.requiresChallenge")
|
|
634
711
|
});
|
|
635
712
|
}
|
|
636
713
|
//#endregion
|
|
637
|
-
//#region src/webauthn/widgets/direct-login-i18n.ts
|
|
638
|
-
var U = {
|
|
639
|
-
en: {
|
|
640
|
-
signInWithPasskey: "Sign in with a passkey",
|
|
641
|
-
unsupported: "This browser does not support passkeys.",
|
|
642
|
-
failed: "Passkey sign-in failed",
|
|
643
|
-
secondFactorRequired: "Additional verification is required — sign in with your password to continue."
|
|
644
|
-
},
|
|
645
|
-
it: {
|
|
646
|
-
signInWithPasskey: "Accedi con una passkey",
|
|
647
|
-
unsupported: "Questo browser non supporta le passkey.",
|
|
648
|
-
failed: "Accesso con passkey non riuscito",
|
|
649
|
-
secondFactorRequired: "È richiesta una verifica aggiuntiva — accedi con la password per continuare."
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
function W(e) {
|
|
653
|
-
return (e ?? globalThis.navigator?.language ?? "en").toLowerCase().split("-")[0] === "it" ? "it" : "en";
|
|
654
|
-
}
|
|
655
|
-
function G(e, t) {
|
|
656
|
-
return U[e][t];
|
|
657
|
-
}
|
|
658
|
-
//#endregion
|
|
659
714
|
//#region src/webauthn/widgets/PasskeyDirectLogin.tsx
|
|
660
|
-
function
|
|
715
|
+
function G(e) {
|
|
661
716
|
if (!e) return null;
|
|
662
717
|
let t = e.onComplete, n = e.onSecondFactor, r = e.onError, i = e.locale;
|
|
663
718
|
return typeof t == "function" ? {
|
|
@@ -667,57 +722,57 @@ function K(e) {
|
|
|
667
722
|
locale: typeof i == "string" ? i : void 0
|
|
668
723
|
} : null;
|
|
669
724
|
}
|
|
670
|
-
function
|
|
671
|
-
let n =
|
|
672
|
-
return r ?
|
|
725
|
+
function K(e) {
|
|
726
|
+
let n = o(), r = G(e.config), [i, a] = t(!1), [l, u] = t(null), { t: d } = V(r?.locale);
|
|
727
|
+
return r ? R() ? /* @__PURE__ */ c("div", {
|
|
673
728
|
className: "space-y-2",
|
|
674
|
-
children: [/* @__PURE__ */
|
|
729
|
+
children: [/* @__PURE__ */ c("button", {
|
|
675
730
|
type: "button",
|
|
676
731
|
"data-testid": "login-passkey-direct",
|
|
677
732
|
onClick: async () => {
|
|
678
|
-
u(null),
|
|
733
|
+
u(null), a(!0);
|
|
679
734
|
try {
|
|
680
|
-
let e = await
|
|
735
|
+
let e = await z((await n.passkeyLoginBegin()).optionsJSON), t = await n.passkeyLoginFinish(e), i = t.secondFactors ?? (t.requiresTotp === !0 ? ["totp"] : []);
|
|
681
736
|
if (i.length > 0) {
|
|
682
737
|
if (r.onSecondFactor) r.onSecondFactor({
|
|
683
738
|
challengeToken: t.token,
|
|
684
739
|
factors: i
|
|
685
740
|
});
|
|
686
741
|
else {
|
|
687
|
-
let e =
|
|
742
|
+
let e = d("directLogin.secondFactorRequired");
|
|
688
743
|
u(e), r.onError?.(e);
|
|
689
744
|
}
|
|
690
745
|
return;
|
|
691
746
|
}
|
|
692
747
|
r.onComplete(t.token);
|
|
693
748
|
} catch (e) {
|
|
694
|
-
let t = e instanceof Error ? e.message :
|
|
749
|
+
let t = e instanceof Error ? e.message : d("directLogin.failed");
|
|
695
750
|
u(t), r.onError?.(t);
|
|
696
751
|
} finally {
|
|
697
|
-
|
|
752
|
+
a(!1);
|
|
698
753
|
}
|
|
699
754
|
},
|
|
700
755
|
disabled: i,
|
|
701
756
|
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",
|
|
702
|
-
children: [i ? /* @__PURE__ */
|
|
703
|
-
}), l && /* @__PURE__ */
|
|
757
|
+
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")]
|
|
758
|
+
}), l && /* @__PURE__ */ s("div", {
|
|
704
759
|
className: "rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",
|
|
705
760
|
children: l
|
|
706
761
|
})]
|
|
707
|
-
}) : /* @__PURE__ */
|
|
762
|
+
}) : /* @__PURE__ */ s("div", {
|
|
708
763
|
className: "rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle",
|
|
709
|
-
children:
|
|
710
|
-
}) : /* @__PURE__ */
|
|
764
|
+
children: d("directLogin.unsupported")
|
|
765
|
+
}) : /* @__PURE__ */ s("div", {
|
|
711
766
|
className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
|
|
712
|
-
children: "
|
|
767
|
+
children: d("directLogin.requiresCallback")
|
|
713
768
|
});
|
|
714
769
|
}
|
|
715
770
|
//#endregion
|
|
716
771
|
//#region src/webauthn/widgets/index.tsx
|
|
717
|
-
var
|
|
718
|
-
"passkey-enrollment":
|
|
719
|
-
"passkey-login":
|
|
720
|
-
"passkey-direct-login":
|
|
772
|
+
var q = {
|
|
773
|
+
"passkey-enrollment": H,
|
|
774
|
+
"passkey-login": W,
|
|
775
|
+
"passkey-direct-login": K
|
|
721
776
|
};
|
|
722
777
|
//#endregion
|
|
723
|
-
export {
|
|
778
|
+
export { q as default };
|