@absolutejs/auth 0.56.18 → 0.56.19
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/client/createAuthClient.d.ts +3 -2
- package/dist/client/index.js +9 -498
- package/dist/client/index.js.map +5 -20
- package/dist/client/react.js +6 -495
- package/dist/client/react.js.map +4 -19
- package/dist/client/solid.js +6 -495
- package/dist/client/solid.js.map +4 -19
- package/dist/client/svelte.js +6 -495
- package/dist/client/svelte.js.map +4 -19
- package/dist/client/vue.js +6 -495
- package/dist/client/vue.js.map +4 -19
- package/dist/manifest.js +1183 -6956
- package/dist/manifest.js.map +30 -30
- package/package.json +15 -6
package/dist/client/react.js
CHANGED
|
@@ -46,500 +46,11 @@ var __export = (target, all) => {
|
|
|
46
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
47
|
var __require = import.meta.require;
|
|
48
48
|
|
|
49
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js
|
|
50
|
-
function bufferToBase64URLString(buffer) {
|
|
51
|
-
const bytes = new Uint8Array(buffer);
|
|
52
|
-
let str = "";
|
|
53
|
-
for (const charCode of bytes) {
|
|
54
|
-
str += String.fromCharCode(charCode);
|
|
55
|
-
}
|
|
56
|
-
const base64String = btoa(str);
|
|
57
|
-
return base64String.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js
|
|
61
|
-
function base64URLStringToBuffer(base64URLString) {
|
|
62
|
-
const base64 = base64URLString.replace(/-/g, "+").replace(/_/g, "/");
|
|
63
|
-
const padLength = (4 - base64.length % 4) % 4;
|
|
64
|
-
const padded = base64.padEnd(base64.length + padLength, "=");
|
|
65
|
-
const binary = atob(padded);
|
|
66
|
-
const buffer = new ArrayBuffer(binary.length);
|
|
67
|
-
const bytes = new Uint8Array(buffer);
|
|
68
|
-
for (let i = 0;i < binary.length; i++) {
|
|
69
|
-
bytes[i] = binary.charCodeAt(i);
|
|
70
|
-
}
|
|
71
|
-
return buffer;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js
|
|
75
|
-
function browserSupportsWebAuthn() {
|
|
76
|
-
return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined && typeof globalThis.PublicKeyCredential === "function");
|
|
77
|
-
}
|
|
78
|
-
var _browserSupportsWebAuthnInternals;
|
|
79
|
-
var init_browserSupportsWebAuthn = __esm(() => {
|
|
80
|
-
_browserSupportsWebAuthnInternals = {
|
|
81
|
-
stubThis: (value) => value
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js
|
|
86
|
-
function toPublicKeyCredentialDescriptor(descriptor) {
|
|
87
|
-
const { id } = descriptor;
|
|
88
|
-
return {
|
|
89
|
-
...descriptor,
|
|
90
|
-
id: base64URLStringToBuffer(id),
|
|
91
|
-
transports: descriptor.transports
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
var init_toPublicKeyCredentialDescriptor = () => {};
|
|
95
|
-
|
|
96
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js
|
|
97
|
-
function isValidDomain(hostname) {
|
|
98
|
-
return hostname === "localhost" || /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js
|
|
102
|
-
var WebAuthnError;
|
|
103
|
-
var init_webAuthnError = __esm(() => {
|
|
104
|
-
WebAuthnError = class WebAuthnError extends Error {
|
|
105
|
-
constructor({ message, code, cause, name }) {
|
|
106
|
-
super(message, { cause });
|
|
107
|
-
Object.defineProperty(this, "code", {
|
|
108
|
-
enumerable: true,
|
|
109
|
-
configurable: true,
|
|
110
|
-
writable: true,
|
|
111
|
-
value: undefined
|
|
112
|
-
});
|
|
113
|
-
this.name = name ?? cause.name;
|
|
114
|
-
this.code = code;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/identifyRegistrationError.js
|
|
120
|
-
function identifyRegistrationError({ error, options }) {
|
|
121
|
-
const { publicKey } = options;
|
|
122
|
-
if (!publicKey) {
|
|
123
|
-
throw Error("options was missing required publicKey property");
|
|
124
|
-
}
|
|
125
|
-
if (error.name === "AbortError") {
|
|
126
|
-
if (options.signal instanceof AbortSignal) {
|
|
127
|
-
return new WebAuthnError({
|
|
128
|
-
message: "Registration ceremony was sent an abort signal",
|
|
129
|
-
code: "ERROR_CEREMONY_ABORTED",
|
|
130
|
-
cause: error
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
} else if (error.name === "ConstraintError") {
|
|
134
|
-
if (publicKey.authenticatorSelection?.requireResidentKey === true) {
|
|
135
|
-
return new WebAuthnError({
|
|
136
|
-
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
137
|
-
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
138
|
-
cause: error
|
|
139
|
-
});
|
|
140
|
-
} else if (options.mediation === "conditional" && publicKey.authenticatorSelection?.userVerification === "required") {
|
|
141
|
-
return new WebAuthnError({
|
|
142
|
-
message: "User verification was required during automatic registration but it could not be performed",
|
|
143
|
-
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
144
|
-
cause: error
|
|
145
|
-
});
|
|
146
|
-
} else if (publicKey.authenticatorSelection?.userVerification === "required") {
|
|
147
|
-
return new WebAuthnError({
|
|
148
|
-
message: "User verification was required but no available authenticator supported it",
|
|
149
|
-
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
150
|
-
cause: error
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
} else if (error.name === "InvalidStateError") {
|
|
154
|
-
return new WebAuthnError({
|
|
155
|
-
message: "The authenticator was previously registered",
|
|
156
|
-
code: "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",
|
|
157
|
-
cause: error
|
|
158
|
-
});
|
|
159
|
-
} else if (error.name === "NotAllowedError") {
|
|
160
|
-
return new WebAuthnError({
|
|
161
|
-
message: error.message,
|
|
162
|
-
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
163
|
-
cause: error
|
|
164
|
-
});
|
|
165
|
-
} else if (error.name === "NotSupportedError") {
|
|
166
|
-
const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === "public-key");
|
|
167
|
-
if (validPubKeyCredParams.length === 0) {
|
|
168
|
-
return new WebAuthnError({
|
|
169
|
-
message: 'No entry in pubKeyCredParams was of type "public-key"',
|
|
170
|
-
code: "ERROR_MALFORMED_PUBKEYCREDPARAMS",
|
|
171
|
-
cause: error
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return new WebAuthnError({
|
|
175
|
-
message: "No available authenticator supported any of the specified pubKeyCredParams algorithms",
|
|
176
|
-
code: "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
177
|
-
cause: error
|
|
178
|
-
});
|
|
179
|
-
} else if (error.name === "SecurityError") {
|
|
180
|
-
const effectiveDomain = globalThis.location.hostname;
|
|
181
|
-
if (!isValidDomain(effectiveDomain)) {
|
|
182
|
-
return new WebAuthnError({
|
|
183
|
-
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
184
|
-
code: "ERROR_INVALID_DOMAIN",
|
|
185
|
-
cause: error
|
|
186
|
-
});
|
|
187
|
-
} else if (publicKey.rp.id !== effectiveDomain) {
|
|
188
|
-
return new WebAuthnError({
|
|
189
|
-
message: `The RP ID "${publicKey.rp.id}" is invalid for this domain`,
|
|
190
|
-
code: "ERROR_INVALID_RP_ID",
|
|
191
|
-
cause: error
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
} else if (error.name === "TypeError") {
|
|
195
|
-
if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {
|
|
196
|
-
return new WebAuthnError({
|
|
197
|
-
message: "User ID was not between 1 and 64 characters",
|
|
198
|
-
code: "ERROR_INVALID_USER_ID_LENGTH",
|
|
199
|
-
cause: error
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
} else if (error.name === "UnknownError") {
|
|
203
|
-
return new WebAuthnError({
|
|
204
|
-
message: "The authenticator was unable to process the specified options, or could not create a new credential",
|
|
205
|
-
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
206
|
-
cause: error
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return error;
|
|
210
|
-
}
|
|
211
|
-
var init_identifyRegistrationError = __esm(() => {
|
|
212
|
-
init_webAuthnError();
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js
|
|
216
|
-
class BaseWebAuthnAbortService {
|
|
217
|
-
constructor() {
|
|
218
|
-
Object.defineProperty(this, "controller", {
|
|
219
|
-
enumerable: true,
|
|
220
|
-
configurable: true,
|
|
221
|
-
writable: true,
|
|
222
|
-
value: undefined
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
createNewAbortSignal() {
|
|
226
|
-
if (this.controller) {
|
|
227
|
-
const abortError = new Error("Cancelling existing WebAuthn API call for new one");
|
|
228
|
-
abortError.name = "AbortError";
|
|
229
|
-
this.controller.abort(abortError);
|
|
230
|
-
}
|
|
231
|
-
const newController = new AbortController;
|
|
232
|
-
this.controller = newController;
|
|
233
|
-
return newController.signal;
|
|
234
|
-
}
|
|
235
|
-
cancelCeremony() {
|
|
236
|
-
if (this.controller) {
|
|
237
|
-
const abortError = new Error("Manually cancelling existing WebAuthn API call");
|
|
238
|
-
abortError.name = "AbortError";
|
|
239
|
-
this.controller.abort(abortError);
|
|
240
|
-
this.controller = undefined;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
var WebAuthnAbortService;
|
|
245
|
-
var init_webAuthnAbortService = __esm(() => {
|
|
246
|
-
WebAuthnAbortService = new BaseWebAuthnAbortService;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js
|
|
250
|
-
function toAuthenticatorAttachment(attachment) {
|
|
251
|
-
if (!attachment) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
if (attachments.indexOf(attachment) < 0) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
return attachment;
|
|
258
|
-
}
|
|
259
|
-
var attachments;
|
|
260
|
-
var init_toAuthenticatorAttachment = __esm(() => {
|
|
261
|
-
attachments = ["cross-platform", "platform"];
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// node_modules/@simplewebauthn/browser/esm/methods/startRegistration.js
|
|
265
|
-
async function startRegistration(options) {
|
|
266
|
-
if (!options.optionsJSON && options.challenge) {
|
|
267
|
-
console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.");
|
|
268
|
-
options = { optionsJSON: options };
|
|
269
|
-
}
|
|
270
|
-
const { optionsJSON, useAutoRegister = false } = options;
|
|
271
|
-
if (!browserSupportsWebAuthn()) {
|
|
272
|
-
throw new Error("WebAuthn is not supported in this browser");
|
|
273
|
-
}
|
|
274
|
-
const publicKey = {
|
|
275
|
-
...optionsJSON,
|
|
276
|
-
challenge: base64URLStringToBuffer(optionsJSON.challenge),
|
|
277
|
-
user: {
|
|
278
|
-
...optionsJSON.user,
|
|
279
|
-
id: base64URLStringToBuffer(optionsJSON.user.id)
|
|
280
|
-
},
|
|
281
|
-
excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor)
|
|
282
|
-
};
|
|
283
|
-
const createOptions = {};
|
|
284
|
-
if (useAutoRegister) {
|
|
285
|
-
createOptions.mediation = "conditional";
|
|
286
|
-
}
|
|
287
|
-
createOptions.publicKey = publicKey;
|
|
288
|
-
createOptions.signal = WebAuthnAbortService.createNewAbortSignal();
|
|
289
|
-
let credential;
|
|
290
|
-
try {
|
|
291
|
-
credential = await navigator.credentials.create(createOptions);
|
|
292
|
-
} catch (err) {
|
|
293
|
-
throw identifyRegistrationError({ error: err, options: createOptions });
|
|
294
|
-
}
|
|
295
|
-
if (!credential) {
|
|
296
|
-
throw new Error("Registration was not completed");
|
|
297
|
-
}
|
|
298
|
-
const { id, rawId, response, type } = credential;
|
|
299
|
-
let transports = undefined;
|
|
300
|
-
if (typeof response.getTransports === "function") {
|
|
301
|
-
transports = response.getTransports();
|
|
302
|
-
}
|
|
303
|
-
let responsePublicKeyAlgorithm = undefined;
|
|
304
|
-
if (typeof response.getPublicKeyAlgorithm === "function") {
|
|
305
|
-
try {
|
|
306
|
-
responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();
|
|
307
|
-
} catch (error) {
|
|
308
|
-
warnOnBrokenImplementation("getPublicKeyAlgorithm()", error);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
let responsePublicKey = undefined;
|
|
312
|
-
if (typeof response.getPublicKey === "function") {
|
|
313
|
-
try {
|
|
314
|
-
const _publicKey = response.getPublicKey();
|
|
315
|
-
if (_publicKey !== null) {
|
|
316
|
-
responsePublicKey = bufferToBase64URLString(_publicKey);
|
|
317
|
-
}
|
|
318
|
-
} catch (error) {
|
|
319
|
-
warnOnBrokenImplementation("getPublicKey()", error);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
let responseAuthenticatorData;
|
|
323
|
-
if (typeof response.getAuthenticatorData === "function") {
|
|
324
|
-
try {
|
|
325
|
-
responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());
|
|
326
|
-
} catch (error) {
|
|
327
|
-
warnOnBrokenImplementation("getAuthenticatorData()", error);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
id,
|
|
332
|
-
rawId: bufferToBase64URLString(rawId),
|
|
333
|
-
response: {
|
|
334
|
-
attestationObject: bufferToBase64URLString(response.attestationObject),
|
|
335
|
-
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
336
|
-
transports,
|
|
337
|
-
publicKeyAlgorithm: responsePublicKeyAlgorithm,
|
|
338
|
-
publicKey: responsePublicKey,
|
|
339
|
-
authenticatorData: responseAuthenticatorData
|
|
340
|
-
},
|
|
341
|
-
type,
|
|
342
|
-
clientExtensionResults: credential.getClientExtensionResults(),
|
|
343
|
-
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
function warnOnBrokenImplementation(methodName, cause) {
|
|
347
|
-
console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.
|
|
348
|
-
`, cause);
|
|
349
|
-
}
|
|
350
|
-
var init_startRegistration = __esm(() => {
|
|
351
|
-
init_browserSupportsWebAuthn();
|
|
352
|
-
init_toPublicKeyCredentialDescriptor();
|
|
353
|
-
init_identifyRegistrationError();
|
|
354
|
-
init_webAuthnAbortService();
|
|
355
|
-
init_toAuthenticatorAttachment();
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js
|
|
359
|
-
function browserSupportsWebAuthnAutofill() {
|
|
360
|
-
if (!browserSupportsWebAuthn()) {
|
|
361
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
362
|
-
}
|
|
363
|
-
const globalPublicKeyCredential = globalThis.PublicKeyCredential;
|
|
364
|
-
if (globalPublicKeyCredential?.isConditionalMediationAvailable === undefined) {
|
|
365
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
366
|
-
}
|
|
367
|
-
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
368
|
-
}
|
|
369
|
-
var _browserSupportsWebAuthnAutofillInternals;
|
|
370
|
-
var init_browserSupportsWebAuthnAutofill = __esm(() => {
|
|
371
|
-
init_browserSupportsWebAuthn();
|
|
372
|
-
_browserSupportsWebAuthnAutofillInternals = {
|
|
373
|
-
stubThis: (value) => value
|
|
374
|
-
};
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js
|
|
378
|
-
function identifyAuthenticationError({ error, options }) {
|
|
379
|
-
const { publicKey } = options;
|
|
380
|
-
if (!publicKey) {
|
|
381
|
-
throw Error("options was missing required publicKey property");
|
|
382
|
-
}
|
|
383
|
-
if (error.name === "AbortError") {
|
|
384
|
-
if (options.signal instanceof AbortSignal) {
|
|
385
|
-
return new WebAuthnError({
|
|
386
|
-
message: "Authentication ceremony was sent an abort signal",
|
|
387
|
-
code: "ERROR_CEREMONY_ABORTED",
|
|
388
|
-
cause: error
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
} else if (error.name === "NotAllowedError") {
|
|
392
|
-
return new WebAuthnError({
|
|
393
|
-
message: error.message,
|
|
394
|
-
code: "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",
|
|
395
|
-
cause: error
|
|
396
|
-
});
|
|
397
|
-
} else if (error.name === "SecurityError") {
|
|
398
|
-
const effectiveDomain = globalThis.location.hostname;
|
|
399
|
-
if (!isValidDomain(effectiveDomain)) {
|
|
400
|
-
return new WebAuthnError({
|
|
401
|
-
message: `${globalThis.location.hostname} is an invalid domain`,
|
|
402
|
-
code: "ERROR_INVALID_DOMAIN",
|
|
403
|
-
cause: error
|
|
404
|
-
});
|
|
405
|
-
} else if (publicKey.rpId !== effectiveDomain) {
|
|
406
|
-
return new WebAuthnError({
|
|
407
|
-
message: `The RP ID "${publicKey.rpId}" is invalid for this domain`,
|
|
408
|
-
code: "ERROR_INVALID_RP_ID",
|
|
409
|
-
cause: error
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
} else if (error.name === "UnknownError") {
|
|
413
|
-
return new WebAuthnError({
|
|
414
|
-
message: "The authenticator was unable to process the specified options, or could not create a new assertion signature",
|
|
415
|
-
code: "ERROR_AUTHENTICATOR_GENERAL_ERROR",
|
|
416
|
-
cause: error
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
return error;
|
|
420
|
-
}
|
|
421
|
-
var init_identifyAuthenticationError = __esm(() => {
|
|
422
|
-
init_webAuthnError();
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js
|
|
426
|
-
async function startAuthentication(options) {
|
|
427
|
-
if (!options.optionsJSON && options.challenge) {
|
|
428
|
-
console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.");
|
|
429
|
-
options = { optionsJSON: options };
|
|
430
|
-
}
|
|
431
|
-
const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true } = options;
|
|
432
|
-
if (!browserSupportsWebAuthn()) {
|
|
433
|
-
throw new Error("WebAuthn is not supported in this browser");
|
|
434
|
-
}
|
|
435
|
-
let allowCredentials;
|
|
436
|
-
if (optionsJSON.allowCredentials?.length !== 0) {
|
|
437
|
-
allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);
|
|
438
|
-
}
|
|
439
|
-
const publicKey = {
|
|
440
|
-
...optionsJSON,
|
|
441
|
-
challenge: base64URLStringToBuffer(optionsJSON.challenge),
|
|
442
|
-
allowCredentials
|
|
443
|
-
};
|
|
444
|
-
const getOptions = {};
|
|
445
|
-
if (useBrowserAutofill) {
|
|
446
|
-
if (!await browserSupportsWebAuthnAutofill()) {
|
|
447
|
-
throw Error("Browser does not support WebAuthn autofill");
|
|
448
|
-
}
|
|
449
|
-
const eligibleInputs = document.querySelectorAll("input[autocomplete$='webauthn']");
|
|
450
|
-
if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {
|
|
451
|
-
throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');
|
|
452
|
-
}
|
|
453
|
-
getOptions.mediation = "conditional";
|
|
454
|
-
publicKey.allowCredentials = [];
|
|
455
|
-
}
|
|
456
|
-
getOptions.publicKey = publicKey;
|
|
457
|
-
getOptions.signal = WebAuthnAbortService.createNewAbortSignal();
|
|
458
|
-
let credential;
|
|
459
|
-
try {
|
|
460
|
-
credential = await navigator.credentials.get(getOptions);
|
|
461
|
-
} catch (err) {
|
|
462
|
-
throw identifyAuthenticationError({ error: err, options: getOptions });
|
|
463
|
-
}
|
|
464
|
-
if (!credential) {
|
|
465
|
-
throw new Error("Authentication was not completed");
|
|
466
|
-
}
|
|
467
|
-
const { id, rawId, response, type } = credential;
|
|
468
|
-
let userHandle = undefined;
|
|
469
|
-
if (response.userHandle) {
|
|
470
|
-
userHandle = bufferToBase64URLString(response.userHandle);
|
|
471
|
-
}
|
|
472
|
-
return {
|
|
473
|
-
id,
|
|
474
|
-
rawId: bufferToBase64URLString(rawId),
|
|
475
|
-
response: {
|
|
476
|
-
authenticatorData: bufferToBase64URLString(response.authenticatorData),
|
|
477
|
-
clientDataJSON: bufferToBase64URLString(response.clientDataJSON),
|
|
478
|
-
signature: bufferToBase64URLString(response.signature),
|
|
479
|
-
userHandle
|
|
480
|
-
},
|
|
481
|
-
type,
|
|
482
|
-
clientExtensionResults: credential.getClientExtensionResults(),
|
|
483
|
-
authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment)
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
var init_startAuthentication = __esm(() => {
|
|
487
|
-
init_browserSupportsWebAuthn();
|
|
488
|
-
init_browserSupportsWebAuthnAutofill();
|
|
489
|
-
init_toPublicKeyCredentialDescriptor();
|
|
490
|
-
init_identifyAuthenticationError();
|
|
491
|
-
init_webAuthnAbortService();
|
|
492
|
-
init_toAuthenticatorAttachment();
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
// node_modules/@simplewebauthn/browser/esm/helpers/platformAuthenticatorIsAvailable.js
|
|
496
|
-
function platformAuthenticatorIsAvailable() {
|
|
497
|
-
if (!browserSupportsWebAuthn()) {
|
|
498
|
-
return new Promise((resolve) => resolve(false));
|
|
499
|
-
}
|
|
500
|
-
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
|
|
501
|
-
}
|
|
502
|
-
var init_platformAuthenticatorIsAvailable = __esm(() => {
|
|
503
|
-
init_browserSupportsWebAuthn();
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
// node_modules/@simplewebauthn/browser/esm/types/index.js
|
|
507
|
-
var init_types = () => {};
|
|
508
|
-
|
|
509
|
-
// node_modules/@simplewebauthn/browser/esm/index.js
|
|
510
|
-
var exports_esm = {};
|
|
511
|
-
__export(exports_esm, {
|
|
512
|
-
startRegistration: () => startRegistration,
|
|
513
|
-
startAuthentication: () => startAuthentication,
|
|
514
|
-
platformAuthenticatorIsAvailable: () => platformAuthenticatorIsAvailable,
|
|
515
|
-
bufferToBase64URLString: () => bufferToBase64URLString,
|
|
516
|
-
browserSupportsWebAuthnAutofill: () => browserSupportsWebAuthnAutofill,
|
|
517
|
-
browserSupportsWebAuthn: () => browserSupportsWebAuthn,
|
|
518
|
-
base64URLStringToBuffer: () => base64URLStringToBuffer,
|
|
519
|
-
_browserSupportsWebAuthnInternals: () => _browserSupportsWebAuthnInternals,
|
|
520
|
-
_browserSupportsWebAuthnAutofillInternals: () => _browserSupportsWebAuthnAutofillInternals,
|
|
521
|
-
WebAuthnError: () => WebAuthnError,
|
|
522
|
-
WebAuthnAbortService: () => WebAuthnAbortService
|
|
523
|
-
});
|
|
524
|
-
var init_esm = __esm(() => {
|
|
525
|
-
init_startRegistration();
|
|
526
|
-
init_startAuthentication();
|
|
527
|
-
init_browserSupportsWebAuthn();
|
|
528
|
-
init_platformAuthenticatorIsAvailable();
|
|
529
|
-
init_browserSupportsWebAuthnAutofill();
|
|
530
|
-
init_webAuthnAbortService();
|
|
531
|
-
init_webAuthnError();
|
|
532
|
-
init_types();
|
|
533
|
-
});
|
|
534
|
-
|
|
535
49
|
// src/client/react.ts
|
|
536
50
|
import { useCallback, useEffect, useRef, useState as useState4 } from "react";
|
|
537
51
|
|
|
538
52
|
// src/client/passkeyHelpers.ts
|
|
539
|
-
var loadBrowser =
|
|
540
|
-
const mod = await Promise.resolve().then(() => (init_esm(), exports_esm));
|
|
541
|
-
return mod;
|
|
542
|
-
};
|
|
53
|
+
var loadBrowser = () => import("@simplewebauthn/browser");
|
|
543
54
|
var errorFor = (caught) => ({
|
|
544
55
|
body: null,
|
|
545
56
|
message: caught instanceof Error ? caught.message : "webauthn_failed",
|
|
@@ -556,8 +67,8 @@ var runConditionalAuthentication = async (client) => {
|
|
|
556
67
|
if (options.error)
|
|
557
68
|
return { data: null, error: options.error };
|
|
558
69
|
try {
|
|
559
|
-
const { startAuthentication
|
|
560
|
-
const credential = await
|
|
70
|
+
const { startAuthentication } = await loadBrowser();
|
|
71
|
+
const credential = await startAuthentication({
|
|
561
72
|
optionsJSON: options.data,
|
|
562
73
|
useBrowserAutofill: true
|
|
563
74
|
});
|
|
@@ -577,8 +88,8 @@ var runPasskeyRegistration = async (client) => {
|
|
|
577
88
|
if (options.error)
|
|
578
89
|
return { data: null, error: options.error };
|
|
579
90
|
try {
|
|
580
|
-
const { startRegistration
|
|
581
|
-
const credential = await
|
|
91
|
+
const { startRegistration } = await loadBrowser();
|
|
92
|
+
const credential = await startRegistration({
|
|
582
93
|
optionsJSON: options.data
|
|
583
94
|
});
|
|
584
95
|
return client.passkeys.registerVerify(credential);
|
|
@@ -908,5 +419,5 @@ export {
|
|
|
908
419
|
SignIn
|
|
909
420
|
};
|
|
910
421
|
|
|
911
|
-
//# debugId=
|
|
422
|
+
//# debugId=348DC4D111BAE2D764756E2164756E21
|
|
912
423
|
//# sourceMappingURL=react.js.map
|