@camstack/addon-auth 1.2.147 → 1.2.149
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-DDdB_Mme.js → dist-Bo_LXyeR.js} +1549 -56
- package/dist/{dist-BGsjH-S3.mjs → dist-DqNfCE-z.mjs} +1520 -57
- package/dist/oidc/auth-oidc.addon.js +135 -13
- package/dist/oidc/auth-oidc.addon.mjs +135 -13
- package/dist/webauthn/_stub.js +304 -235
- package/dist/webauthn/{_virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-DiKn9eAB.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-SIs0w9js.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-BpOR-FRf.mjs +26 -0
- package/dist/webauthn/auth-webauthn.addon.js +160 -53
- package/dist/webauthn/auth-webauthn.addon.mjs +160 -53
- package/dist/webauthn/{hostInit-Cf9MrMyw.mjs → hostInit-DZMo0Gc_.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-BpOR-FRf.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,231 @@ 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
|
+
}
|
|
398
|
+
function z(e) {
|
|
399
|
+
return {
|
|
400
|
+
...e,
|
|
401
|
+
challenge: e.challenge
|
|
402
|
+
};
|
|
397
403
|
}
|
|
398
|
-
|
|
399
|
-
|
|
404
|
+
function B(e) {
|
|
405
|
+
return {
|
|
406
|
+
...e,
|
|
407
|
+
challenge: e.challenge
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
async function V(e) {
|
|
411
|
+
if (typeof e.challenge != "string") throw Error("passkey authentication options missing challenge");
|
|
412
|
+
let t = await L({ optionsJSON: z(e) });
|
|
400
413
|
return Object.fromEntries(Object.entries(t));
|
|
401
414
|
}
|
|
402
|
-
async function
|
|
403
|
-
|
|
415
|
+
async function H(e) {
|
|
416
|
+
if (typeof e.challenge != "string") throw Error("passkey registration options missing challenge");
|
|
417
|
+
let t = await N({ optionsJSON: B(e) });
|
|
404
418
|
return Object.fromEntries(Object.entries(t));
|
|
405
419
|
}
|
|
406
420
|
//#endregion
|
|
421
|
+
//#region src/i18n/index.ts
|
|
422
|
+
var { useT: U } = a("auth-webauthn", {
|
|
423
|
+
en: {
|
|
424
|
+
directLogin: {
|
|
425
|
+
requiresCallback: "Passkey direct-login widget requires an onComplete callback.",
|
|
426
|
+
signInWithPasskey: "Sign in with a passkey",
|
|
427
|
+
unsupported: "This browser does not support passkeys.",
|
|
428
|
+
failed: "Passkey sign-in failed",
|
|
429
|
+
secondFactorRequired: "Additional verification is required — sign in with your password to continue."
|
|
430
|
+
},
|
|
431
|
+
login: {
|
|
432
|
+
requiresChallenge: "Passkey login widget requires a challengeToken + onComplete callback.",
|
|
433
|
+
unsupported: "This browser does not support passkeys.",
|
|
434
|
+
verificationFailed: "Passkey verification failed",
|
|
435
|
+
usePasskey: "Use a passkey"
|
|
436
|
+
},
|
|
437
|
+
enrollment: {
|
|
438
|
+
title: "Passkeys",
|
|
439
|
+
intro: "Add a passkey (Touch ID, Windows Hello, or a security key) to sign in directly — fast and phishing-resistant, no password needed.",
|
|
440
|
+
loading: "Loading passkeys…",
|
|
441
|
+
addedUsed: "Added {{added}} · last used {{used}}",
|
|
442
|
+
addedNever: "Added {{added}} · never used",
|
|
443
|
+
currentPassword: "Current password",
|
|
444
|
+
passwordToConfirm: "Password to confirm",
|
|
445
|
+
remove: "Remove",
|
|
446
|
+
usePasskey: "Use a passkey",
|
|
447
|
+
none: "No passkeys enrolled yet.",
|
|
448
|
+
secondFactorTitle: "Require passkey as second factor",
|
|
449
|
+
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.",
|
|
450
|
+
passkeyName: "Passkey name",
|
|
451
|
+
namePlaceholder: "e.g. MacBook Touch ID",
|
|
452
|
+
enrolling: "Enrolling…",
|
|
453
|
+
addPasskey: "Add passkey",
|
|
454
|
+
unnamedDevice: "Unnamed device",
|
|
455
|
+
preferenceFailed: "Could not update the preference",
|
|
456
|
+
enrollFailed: "Passkey enrollment failed",
|
|
457
|
+
removeFailed: "Remove failed"
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
it: {
|
|
461
|
+
directLogin: {
|
|
462
|
+
requiresCallback: "Il widget di accesso diretto con passkey richiede una callback onComplete.",
|
|
463
|
+
signInWithPasskey: "Accedi con una passkey",
|
|
464
|
+
unsupported: "Questo browser non supporta le passkey.",
|
|
465
|
+
failed: "Accesso con passkey non riuscito",
|
|
466
|
+
secondFactorRequired: "È richiesta una verifica aggiuntiva — accedi con la password per continuare."
|
|
467
|
+
},
|
|
468
|
+
login: {
|
|
469
|
+
requiresChallenge: "Il widget di accesso con passkey richiede un challengeToken e una callback onComplete.",
|
|
470
|
+
unsupported: "Questo browser non supporta le passkey.",
|
|
471
|
+
verificationFailed: "Verifica della passkey non riuscita",
|
|
472
|
+
usePasskey: "Usa una passkey"
|
|
473
|
+
},
|
|
474
|
+
enrollment: {
|
|
475
|
+
title: "Passkey",
|
|
476
|
+
intro: "Aggiungi una passkey (Touch ID, Windows Hello o una chiave di sicurezza) per accedere direttamente: veloce, resistente al phishing e senza password.",
|
|
477
|
+
loading: "Caricamento passkey…",
|
|
478
|
+
addedUsed: "Aggiunta il {{added}} · ultimo utilizzo {{used}}",
|
|
479
|
+
addedNever: "Aggiunta il {{added}} · mai utilizzata",
|
|
480
|
+
currentPassword: "Password attuale",
|
|
481
|
+
passwordToConfirm: "Password per confermare",
|
|
482
|
+
remove: "Rimuovi",
|
|
483
|
+
usePasskey: "Usa una passkey",
|
|
484
|
+
none: "Nessuna passkey registrata.",
|
|
485
|
+
secondFactorTitle: "Richiedi la passkey come secondo fattore",
|
|
486
|
+
secondFactorHint: "Chiedi una passkey anche dopo ogni accesso con password. Disattivato per impostazione predefinita: registrare una passkey abilita soltanto l'accesso diretto con passkey.",
|
|
487
|
+
passkeyName: "Nome della passkey",
|
|
488
|
+
namePlaceholder: "es. MacBook Touch ID",
|
|
489
|
+
enrolling: "Registrazione…",
|
|
490
|
+
addPasskey: "Aggiungi passkey",
|
|
491
|
+
unnamedDevice: "Dispositivo senza nome",
|
|
492
|
+
preferenceFailed: "Impossibile aggiornare la preferenza",
|
|
493
|
+
enrollFailed: "Registrazione della passkey non riuscita",
|
|
494
|
+
removeFailed: "Rimozione non riuscita"
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
//#endregion
|
|
407
499
|
//#region src/webauthn/widgets/PasskeyEnrollment.tsx
|
|
408
|
-
function
|
|
409
|
-
let n = a(),
|
|
500
|
+
function W(e) {
|
|
501
|
+
let n = o(), { t: a, lang: u } = U(), d = r({
|
|
410
502
|
queryKey: ["auth", "listOwnPasskeys"],
|
|
411
503
|
queryFn: () => n.listOwnPasskeys()
|
|
412
|
-
}),
|
|
504
|
+
}), f = d.data ?? [], [p, m] = t(""), [h, g] = t(!1), [_, C] = t(null), w = r({
|
|
413
505
|
queryKey: ["auth", "getOwnPasskeySecondFactorPreference"],
|
|
414
506
|
queryFn: () => n.getOwnPasskeySecondFactorPreference(),
|
|
415
|
-
enabled:
|
|
416
|
-
}),
|
|
507
|
+
enabled: f.length > 0
|
|
508
|
+
}), T = w.data?.enabled ?? !1, E = i({
|
|
417
509
|
mutationFn: (e) => n.setOwnPasskeySecondFactorPreference({ enabled: e }),
|
|
418
510
|
onSuccess: () => {
|
|
419
|
-
|
|
511
|
+
C(null), w.refetch();
|
|
420
512
|
},
|
|
421
|
-
onError: (e) =>
|
|
422
|
-
}),
|
|
423
|
-
|
|
513
|
+
onError: (e) => C(e instanceof Error ? e.message : a("enrollment.preferenceFailed"))
|
|
514
|
+
}), D = async () => {
|
|
515
|
+
C(null), g(!0);
|
|
424
516
|
try {
|
|
425
|
-
let e = await
|
|
517
|
+
let e = await H((await n.beginOwnPasskeyRegistration()).optionsJSON);
|
|
426
518
|
await n.finishOwnPasskeyRegistration({
|
|
427
519
|
response: e,
|
|
428
|
-
label:
|
|
429
|
-
}),
|
|
520
|
+
label: p.trim() || a("enrollment.unnamedDevice")
|
|
521
|
+
}), m(""), d.refetch();
|
|
430
522
|
} catch (e) {
|
|
431
|
-
|
|
523
|
+
C(e instanceof Error ? e.message : a("enrollment.enrollFailed"));
|
|
432
524
|
} finally {
|
|
433
|
-
|
|
525
|
+
g(!1);
|
|
434
526
|
}
|
|
435
|
-
}, [
|
|
527
|
+
}, [O, k] = t(null), [A, j] = t(""), M = i({
|
|
436
528
|
mutationFn: async (e) => {
|
|
437
529
|
let t;
|
|
438
530
|
if ("password" in e.proof) t = (await n.reauthenticate({ password: e.proof.password })).reauthToken;
|
|
439
531
|
else {
|
|
440
|
-
let { optionsJSON: e } = await n.reauthBeginPasskey(), r = await
|
|
532
|
+
let { optionsJSON: e } = await n.reauthBeginPasskey(), r = await V(e);
|
|
441
533
|
t = (await n.reauthenticate({ passkeyResponse: r })).reauthToken;
|
|
442
534
|
}
|
|
443
535
|
return n.removeOwnPasskey({
|
|
@@ -446,142 +538,141 @@ function B(e) {
|
|
|
446
538
|
});
|
|
447
539
|
},
|
|
448
540
|
onSuccess: () => {
|
|
449
|
-
|
|
541
|
+
C(null), k(null), j(""), d.refetch();
|
|
450
542
|
},
|
|
451
|
-
onError: (e) =>
|
|
543
|
+
onError: (e) => C(e instanceof Error ? e.message : a("enrollment.removeFailed"))
|
|
452
544
|
});
|
|
453
|
-
return /* @__PURE__ */
|
|
545
|
+
return /* @__PURE__ */ c("div", {
|
|
454
546
|
className: "rounded-lg border border-border bg-surface overflow-hidden",
|
|
455
|
-
children: [/* @__PURE__ */
|
|
547
|
+
children: [/* @__PURE__ */ c("div", {
|
|
456
548
|
className: "px-4 py-2.5 border-b border-border flex items-center gap-2",
|
|
457
|
-
children: [/* @__PURE__ */
|
|
549
|
+
children: [/* @__PURE__ */ s(y, { className: "h-3.5 w-3.5 text-foreground-subtle" }), /* @__PURE__ */ s("div", {
|
|
458
550
|
className: "text-xs font-semibold text-foreground",
|
|
459
|
-
children: "
|
|
551
|
+
children: a("enrollment.title")
|
|
460
552
|
})]
|
|
461
|
-
}), /* @__PURE__ */
|
|
553
|
+
}), /* @__PURE__ */ c("div", {
|
|
462
554
|
className: "p-4 space-y-3",
|
|
463
555
|
children: [
|
|
464
|
-
/* @__PURE__ */
|
|
556
|
+
/* @__PURE__ */ s("div", {
|
|
465
557
|
className: "text-xs text-foreground-subtle",
|
|
466
|
-
children:
|
|
558
|
+
children: a("enrollment.intro")
|
|
467
559
|
}),
|
|
468
|
-
|
|
560
|
+
d.isLoading ? /* @__PURE__ */ c("div", {
|
|
469
561
|
className: "flex items-center gap-2 text-xs text-foreground-subtle",
|
|
470
|
-
children: [/* @__PURE__ */
|
|
471
|
-
}) :
|
|
562
|
+
children: [/* @__PURE__ */ s(x, { className: "h-3.5 w-3.5 animate-spin" }), a("enrollment.loading")]
|
|
563
|
+
}) : f.length > 0 ? /* @__PURE__ */ s("ul", {
|
|
472
564
|
className: "divide-y divide-border rounded-md border border-border",
|
|
473
|
-
children:
|
|
565
|
+
children: f.map((e) => /* @__PURE__ */ c("li", {
|
|
474
566
|
className: "flex items-center gap-3 px-3 py-2 text-xs",
|
|
475
567
|
children: [
|
|
476
|
-
/* @__PURE__ */
|
|
477
|
-
/* @__PURE__ */
|
|
568
|
+
/* @__PURE__ */ s(b, { className: "h-3.5 w-3.5 text-foreground-subtle shrink-0" }),
|
|
569
|
+
/* @__PURE__ */ c("div", {
|
|
478
570
|
className: "flex-1 min-w-0",
|
|
479
|
-
children: [/* @__PURE__ */
|
|
571
|
+
children: [/* @__PURE__ */ s("div", {
|
|
480
572
|
className: "font-medium text-foreground truncate",
|
|
481
573
|
children: e.label
|
|
482
574
|
}), /* @__PURE__ */ s("div", {
|
|
483
575
|
className: "text-[10px] text-foreground-subtle",
|
|
484
|
-
children:
|
|
485
|
-
|
|
486
|
-
new Date(e.
|
|
487
|
-
|
|
488
|
-
]
|
|
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) })
|
|
489
580
|
})]
|
|
490
581
|
}),
|
|
491
|
-
|
|
582
|
+
O === e.credentialId ? /* @__PURE__ */ c("form", {
|
|
492
583
|
className: "flex items-center gap-1.5",
|
|
493
584
|
onSubmit: (t) => {
|
|
494
|
-
t.preventDefault(),
|
|
585
|
+
t.preventDefault(), A.length > 0 && M.mutate({
|
|
495
586
|
credentialId: e.credentialId,
|
|
496
|
-
proof: { password:
|
|
587
|
+
proof: { password: A }
|
|
497
588
|
});
|
|
498
589
|
},
|
|
499
590
|
children: [
|
|
500
|
-
/* @__PURE__ */
|
|
591
|
+
/* @__PURE__ */ s("input", {
|
|
501
592
|
type: "password",
|
|
502
593
|
autoComplete: "current-password",
|
|
503
|
-
"aria-label": "
|
|
504
|
-
placeholder: "
|
|
505
|
-
value:
|
|
506
|
-
onChange: (e) =>
|
|
594
|
+
"aria-label": a("enrollment.currentPassword"),
|
|
595
|
+
placeholder: a("enrollment.passwordToConfirm"),
|
|
596
|
+
value: A,
|
|
597
|
+
onChange: (e) => j(e.target.value),
|
|
507
598
|
className: "w-36 rounded border border-border bg-background px-2 py-1 text-[11px]"
|
|
508
599
|
}),
|
|
509
|
-
/* @__PURE__ */
|
|
600
|
+
/* @__PURE__ */ s("button", {
|
|
510
601
|
type: "submit",
|
|
511
|
-
disabled:
|
|
602
|
+
disabled: A.length === 0 || M.isPending,
|
|
512
603
|
className: "rounded px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50",
|
|
513
|
-
children: "
|
|
604
|
+
children: a("enrollment.remove")
|
|
514
605
|
}),
|
|
515
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ s("button", {
|
|
516
607
|
type: "button",
|
|
517
|
-
disabled:
|
|
518
|
-
onClick: () =>
|
|
608
|
+
disabled: M.isPending,
|
|
609
|
+
onClick: () => M.mutate({
|
|
519
610
|
credentialId: e.credentialId,
|
|
520
611
|
proof: { passkey: !0 }
|
|
521
612
|
}),
|
|
522
613
|
className: "rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-50",
|
|
523
|
-
children:
|
|
614
|
+
children: a("enrollment.usePasskey")
|
|
524
615
|
})
|
|
525
616
|
]
|
|
526
|
-
}) : /* @__PURE__ */
|
|
617
|
+
}) : /* @__PURE__ */ c("button", {
|
|
527
618
|
onClick: () => {
|
|
528
|
-
|
|
619
|
+
C(null), j(""), k(e.credentialId);
|
|
529
620
|
},
|
|
530
|
-
disabled:
|
|
621
|
+
disabled: M.isPending,
|
|
531
622
|
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__ */
|
|
623
|
+
children: [/* @__PURE__ */ s(S, { className: "h-3 w-3" }), a("enrollment.remove")]
|
|
533
624
|
})
|
|
534
625
|
]
|
|
535
626
|
}, e.credentialId))
|
|
536
|
-
}) : /* @__PURE__ */
|
|
627
|
+
}) : /* @__PURE__ */ s("div", {
|
|
537
628
|
className: "text-[11px] text-foreground-subtle",
|
|
538
|
-
children: "
|
|
629
|
+
children: a("enrollment.none")
|
|
539
630
|
}),
|
|
540
|
-
|
|
631
|
+
f.length > 0 && /* @__PURE__ */ c("div", {
|
|
541
632
|
className: "flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2.5",
|
|
542
|
-
children: [/* @__PURE__ */
|
|
633
|
+
children: [/* @__PURE__ */ c("div", {
|
|
543
634
|
className: "min-w-0",
|
|
544
|
-
children: [/* @__PURE__ */
|
|
635
|
+
children: [/* @__PURE__ */ s("div", {
|
|
545
636
|
className: "text-xs font-medium text-foreground",
|
|
546
|
-
children: "
|
|
547
|
-
}), /* @__PURE__ */
|
|
637
|
+
children: a("enrollment.secondFactorTitle")
|
|
638
|
+
}), /* @__PURE__ */ s("div", {
|
|
548
639
|
className: "text-[10px] text-foreground-subtle mt-0.5",
|
|
549
|
-
children: "
|
|
640
|
+
children: a("enrollment.secondFactorHint")
|
|
550
641
|
})]
|
|
551
|
-
}), /* @__PURE__ */
|
|
642
|
+
}), /* @__PURE__ */ s("button", {
|
|
552
643
|
type: "button",
|
|
553
644
|
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__ */
|
|
645
|
+
"aria-checked": T,
|
|
646
|
+
"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]"}` })
|
|
560
651
|
})]
|
|
561
652
|
}),
|
|
562
|
-
|
|
653
|
+
_ && /* @__PURE__ */ c("div", {
|
|
563
654
|
className: "text-[11px] text-danger flex items-center gap-1",
|
|
564
|
-
children: [/* @__PURE__ */
|
|
655
|
+
children: [/* @__PURE__ */ s(v, { className: "h-3 w-3" }), _]
|
|
565
656
|
}),
|
|
566
|
-
/* @__PURE__ */
|
|
657
|
+
/* @__PURE__ */ c("div", {
|
|
567
658
|
className: "flex items-end gap-2",
|
|
568
|
-
children: [/* @__PURE__ */
|
|
659
|
+
children: [/* @__PURE__ */ c("div", {
|
|
569
660
|
className: "flex-1 space-y-1",
|
|
570
|
-
children: [/* @__PURE__ */
|
|
661
|
+
children: [/* @__PURE__ */ s("label", {
|
|
571
662
|
className: "text-[10px] uppercase tracking-wide text-foreground-subtle",
|
|
572
|
-
children: "
|
|
573
|
-
}), /* @__PURE__ */
|
|
663
|
+
children: a("enrollment.passkeyName")
|
|
664
|
+
}), /* @__PURE__ */ s("input", {
|
|
574
665
|
type: "text",
|
|
575
|
-
value:
|
|
576
|
-
onChange: (e) =>
|
|
577
|
-
placeholder: "
|
|
666
|
+
value: p,
|
|
667
|
+
onChange: (e) => m(e.target.value),
|
|
668
|
+
placeholder: a("enrollment.namePlaceholder"),
|
|
578
669
|
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
670
|
})]
|
|
580
|
-
}), /* @__PURE__ */
|
|
581
|
-
onClick:
|
|
582
|
-
disabled:
|
|
671
|
+
}), /* @__PURE__ */ s("button", {
|
|
672
|
+
onClick: D,
|
|
673
|
+
disabled: h,
|
|
583
674
|
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:
|
|
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")] })
|
|
585
676
|
})]
|
|
586
677
|
})
|
|
587
678
|
]
|
|
@@ -590,7 +681,7 @@ function B(e) {
|
|
|
590
681
|
}
|
|
591
682
|
//#endregion
|
|
592
683
|
//#region src/webauthn/widgets/PasskeyLogin.tsx
|
|
593
|
-
function
|
|
684
|
+
function G(e) {
|
|
594
685
|
if (!e) return null;
|
|
595
686
|
let t = e.challengeToken, n = e.onComplete, r = e.onError;
|
|
596
687
|
return typeof t != "string" || typeof n != "function" ? null : {
|
|
@@ -599,65 +690,43 @@ function V(e) {
|
|
|
599
690
|
onError: typeof r == "function" ? r : void 0
|
|
600
691
|
};
|
|
601
692
|
}
|
|
602
|
-
function
|
|
603
|
-
let n =
|
|
604
|
-
return
|
|
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", {
|
|
605
696
|
className: "space-y-2",
|
|
606
|
-
children: [/* @__PURE__ */
|
|
697
|
+
children: [/* @__PURE__ */ c("button", {
|
|
607
698
|
type: "button",
|
|
608
699
|
"data-testid": "login-passkey",
|
|
609
700
|
onClick: async () => {
|
|
610
|
-
|
|
701
|
+
d(null), l(!0);
|
|
611
702
|
try {
|
|
612
|
-
let e = await
|
|
613
|
-
|
|
703
|
+
let e = await V((await n.loginBeginPasskey(i.challengeToken)).optionsJSON), t = await n.loginVerifyPasskey(i.challengeToken, e);
|
|
704
|
+
i.onComplete(t.token);
|
|
614
705
|
} catch (e) {
|
|
615
|
-
let t = e instanceof Error ? e.message : "
|
|
616
|
-
|
|
706
|
+
let t = e instanceof Error ? e.message : r("login.verificationFailed");
|
|
707
|
+
d(t), i.onError?.(t);
|
|
617
708
|
} finally {
|
|
618
|
-
|
|
709
|
+
l(!1);
|
|
619
710
|
}
|
|
620
711
|
},
|
|
621
|
-
disabled:
|
|
712
|
+
disabled: a,
|
|
622
713
|
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
|
-
}),
|
|
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", {
|
|
625
716
|
className: "rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",
|
|
626
|
-
children:
|
|
717
|
+
children: u
|
|
627
718
|
})]
|
|
628
|
-
}) : /* @__PURE__ */
|
|
719
|
+
}) : /* @__PURE__ */ s("div", {
|
|
629
720
|
className: "rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle",
|
|
630
|
-
children: "
|
|
631
|
-
}) : /* @__PURE__ */
|
|
721
|
+
children: r("login.unsupported")
|
|
722
|
+
}) : /* @__PURE__ */ s("div", {
|
|
632
723
|
className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
|
|
633
|
-
children: "
|
|
724
|
+
children: r("login.requiresChallenge")
|
|
634
725
|
});
|
|
635
726
|
}
|
|
636
727
|
//#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
728
|
//#region src/webauthn/widgets/PasskeyDirectLogin.tsx
|
|
660
|
-
function
|
|
729
|
+
function q(e) {
|
|
661
730
|
if (!e) return null;
|
|
662
731
|
let t = e.onComplete, n = e.onSecondFactor, r = e.onError, i = e.locale;
|
|
663
732
|
return typeof t == "function" ? {
|
|
@@ -667,57 +736,57 @@ function K(e) {
|
|
|
667
736
|
locale: typeof i == "string" ? i : void 0
|
|
668
737
|
} : null;
|
|
669
738
|
}
|
|
670
|
-
function
|
|
671
|
-
let n =
|
|
672
|
-
return r ?
|
|
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", {
|
|
673
742
|
className: "space-y-2",
|
|
674
|
-
children: [/* @__PURE__ */
|
|
743
|
+
children: [/* @__PURE__ */ c("button", {
|
|
675
744
|
type: "button",
|
|
676
745
|
"data-testid": "login-passkey-direct",
|
|
677
746
|
onClick: async () => {
|
|
678
|
-
u(null),
|
|
747
|
+
u(null), a(!0);
|
|
679
748
|
try {
|
|
680
|
-
let e = await
|
|
749
|
+
let e = await V((await n.passkeyLoginBegin()).optionsJSON), t = await n.passkeyLoginFinish(e), i = t.secondFactors ?? (t.requiresTotp === !0 ? ["totp"] : []);
|
|
681
750
|
if (i.length > 0) {
|
|
682
751
|
if (r.onSecondFactor) r.onSecondFactor({
|
|
683
752
|
challengeToken: t.token,
|
|
684
753
|
factors: i
|
|
685
754
|
});
|
|
686
755
|
else {
|
|
687
|
-
let e =
|
|
756
|
+
let e = d("directLogin.secondFactorRequired");
|
|
688
757
|
u(e), r.onError?.(e);
|
|
689
758
|
}
|
|
690
759
|
return;
|
|
691
760
|
}
|
|
692
761
|
r.onComplete(t.token);
|
|
693
762
|
} catch (e) {
|
|
694
|
-
let t = e instanceof Error ? e.message :
|
|
763
|
+
let t = e instanceof Error ? e.message : d("directLogin.failed");
|
|
695
764
|
u(t), r.onError?.(t);
|
|
696
765
|
} finally {
|
|
697
|
-
|
|
766
|
+
a(!1);
|
|
698
767
|
}
|
|
699
768
|
},
|
|
700
769
|
disabled: i,
|
|
701
770
|
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__ */
|
|
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", {
|
|
704
773
|
className: "rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",
|
|
705
774
|
children: l
|
|
706
775
|
})]
|
|
707
|
-
}) : /* @__PURE__ */
|
|
776
|
+
}) : /* @__PURE__ */ s("div", {
|
|
708
777
|
className: "rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle",
|
|
709
|
-
children:
|
|
710
|
-
}) : /* @__PURE__ */
|
|
778
|
+
children: d("directLogin.unsupported")
|
|
779
|
+
}) : /* @__PURE__ */ s("div", {
|
|
711
780
|
className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
|
|
712
|
-
children: "
|
|
781
|
+
children: d("directLogin.requiresCallback")
|
|
713
782
|
});
|
|
714
783
|
}
|
|
715
784
|
//#endregion
|
|
716
785
|
//#region src/webauthn/widgets/index.tsx
|
|
717
|
-
var
|
|
718
|
-
"passkey-enrollment":
|
|
719
|
-
"passkey-login":
|
|
720
|
-
"passkey-direct-login":
|
|
786
|
+
var Y = {
|
|
787
|
+
"passkey-enrollment": W,
|
|
788
|
+
"passkey-login": K,
|
|
789
|
+
"passkey-direct-login": J
|
|
721
790
|
};
|
|
722
791
|
//#endregion
|
|
723
|
-
export {
|
|
792
|
+
export { Y as default };
|