@absolutejs/auth 0.56.18 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/agents/index.js +44 -37
  2. package/dist/agents/index.js.map +7 -7
  3. package/dist/audit/postgresAuditStore.d.ts +1 -1
  4. package/dist/audit/types.d.ts +2 -0
  5. package/dist/audit/wrap.d.ts +4 -2
  6. package/dist/cli/import/auth0.d.ts +1 -1
  7. package/dist/cli/import/clerk.d.ts +1 -1
  8. package/dist/cli/import/lucia.d.ts +1 -1
  9. package/dist/cli/import/nextauth.d.ts +1 -1
  10. package/dist/cli/import/types.d.ts +1 -0
  11. package/dist/cli/migrate.js +91 -47
  12. package/dist/cli/migrate.js.map +14 -13
  13. package/dist/client/createAuthClient.d.ts +3 -2
  14. package/dist/client/index.js +9 -498
  15. package/dist/client/index.js.map +5 -20
  16. package/dist/client/react.d.ts +21 -21
  17. package/dist/client/react.js +40 -531
  18. package/dist/client/react.js.map +8 -23
  19. package/dist/client/solid.d.ts +21 -21
  20. package/dist/client/solid.js +29 -518
  21. package/dist/client/solid.js.map +5 -20
  22. package/dist/client/svelte.d.ts +21 -21
  23. package/dist/client/svelte.js +30 -519
  24. package/dist/client/svelte.js.map +5 -20
  25. package/dist/client/vue.d.ts +21 -21
  26. package/dist/client/vue.js +37 -526
  27. package/dist/client/vue.js.map +5 -20
  28. package/dist/credentials/import.d.ts +16 -1
  29. package/dist/credentials/register.d.ts +1 -1
  30. package/dist/credentials/routes.d.ts +1 -1
  31. package/dist/fingerprint-client/index.js +4 -3
  32. package/dist/fingerprint-client/index.js.map +3 -3
  33. package/dist/index.d.ts +3 -3
  34. package/dist/index.js +6416 -262
  35. package/dist/index.js.map +166 -26
  36. package/dist/manifest.js +343 -2674
  37. package/dist/manifest.js.map +57 -31
  38. package/dist/manifest.json +3 -2
  39. package/dist/oidc/clientIdMetadata.d.ts +1 -5
  40. package/dist/oidc/index.js.map +2 -2
  41. package/dist/oidc/vci.d.ts +1 -1
  42. package/dist/routes/callback.d.ts +1 -1
  43. package/dist/server.js +6412 -261
  44. package/dist/server.js.map +166 -26
  45. package/dist/session/neonStore.d.ts +2 -2
  46. package/dist/session/redisStore.d.ts +2 -2
  47. package/dist/session/types.d.ts +2 -0
  48. package/dist/stores/postgres.d.ts +2 -2
  49. package/dist/types.d.ts +2 -1
  50. package/dist/vault/index.js.map +2 -2
  51. package/dist/webauthn.js +27 -1
  52. package/dist/webauthn.js.map +3 -3
  53. package/docs/MIGRATE-FROM-LUCIA.md +19 -2
  54. package/package.json +15 -6
@@ -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/svelte.ts
536
50
  import { writable } from "svelte/store";
537
51
 
538
52
  // src/client/passkeyHelpers.ts
539
- var loadBrowser = async () => {
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: startAuthentication3 } = await loadBrowser();
560
- const credential = await startAuthentication3({
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: startRegistration3 } = await loadBrowser();
581
- const credential = await startRegistration3({
91
+ const { startRegistration } = await loadBrowser();
92
+ const credential = await startRegistration({
582
93
  optionsJSON: options.data
583
94
  });
584
95
  return client.passkeys.registerVerify(credential);
@@ -609,6 +120,7 @@ var useMutation = (run) => {
609
120
  return { data, error, isPending, mutate, reset };
610
121
  };
611
122
  var useMagicLink = (client) => useMutation(client.passwordless.requestMagicLink);
123
+ var useMfaChallenge = (client) => useMutation(client.mfa.challenge);
612
124
  var usePasskeyAutofill = (client) => {
613
125
  const data = writable(null);
614
126
  const error = writable(null);
@@ -626,56 +138,55 @@ var usePasskeyAutofill = (client) => {
626
138
  };
627
139
  return { cancel, data, error, isPending, start };
628
140
  };
629
- var useUpgradeToPasskey = (client) => {
630
- const passkeys = writable(null);
141
+ var usePasswordReset = (client) => useMutation(client.passwordReset.request);
142
+ var useSessions = (client) => {
143
+ const data = writable(null);
631
144
  const error = writable(null);
632
145
  const isPending = writable(true);
633
- const shouldPrompt = writable(false);
634
- const recompute = (list) => {
635
- shouldPrompt.set(list !== null && list.length === 0);
636
- };
637
146
  const refetch = async () => {
638
147
  isPending.set(true);
639
- const result = await client.passkeys.list();
640
- passkeys.set(result.data);
148
+ const result = await client.sessions.list();
149
+ data.set(result.data);
641
150
  error.set(result.error);
642
151
  isPending.set(false);
643
- recompute(result.data);
644
152
  };
645
- const register = async () => {
646
- const result = await runPasskeyRegistration(client);
153
+ const revoke = async (sessionId) => {
154
+ const result = await client.sessions.revoke(sessionId);
647
155
  if (result.error === null)
648
156
  await refetch();
649
157
  return result;
650
158
  };
651
159
  refetch();
652
- return { error, isPending, passkeys, refetch, register, shouldPrompt };
160
+ return { data, error, isPending, refetch, revoke };
653
161
  };
654
- var useMfaChallenge = (client) => useMutation(client.mfa.challenge);
655
- var usePasswordReset = (client) => useMutation(client.passwordReset.request);
656
- var useSessions = (client) => {
657
- const data = writable(null);
162
+ var useSignIn = (client) => useMutation(client.signIn.email);
163
+ var useSignOut = (client) => useMutation(client.signOut);
164
+ var useSignUp = (client) => useMutation(client.signUp.email);
165
+ var useUpgradeToPasskey = (client) => {
166
+ const passkeys = writable(null);
658
167
  const error = writable(null);
659
168
  const isPending = writable(true);
169
+ const shouldPrompt = writable(false);
170
+ const recompute = (list) => {
171
+ shouldPrompt.set(list !== null && list.length === 0);
172
+ };
660
173
  const refetch = async () => {
661
174
  isPending.set(true);
662
- const result = await client.sessions.list();
663
- data.set(result.data);
175
+ const result = await client.passkeys.list();
176
+ passkeys.set(result.data);
664
177
  error.set(result.error);
665
178
  isPending.set(false);
179
+ recompute(result.data);
666
180
  };
667
- const revoke = async (sessionId) => {
668
- const result = await client.sessions.revoke(sessionId);
181
+ const register = async () => {
182
+ const result = await runPasskeyRegistration(client);
669
183
  if (result.error === null)
670
184
  await refetch();
671
185
  return result;
672
186
  };
673
187
  refetch();
674
- return { data, error, isPending, refetch, revoke };
188
+ return { error, isPending, passkeys, refetch, register, shouldPrompt };
675
189
  };
676
- var useSignIn = (client) => useMutation(client.signIn.email);
677
- var useSignOut = (client) => useMutation(client.signOut);
678
- var useSignUp = (client) => useMutation(client.signUp.email);
679
190
  export {
680
191
  useUpgradeToPasskey,
681
192
  useSignUp,
@@ -688,5 +199,5 @@ export {
688
199
  useMagicLink
689
200
  };
690
201
 
691
- //# debugId=D1D3E2E0E04ECF6A64756E2164756E21
202
+ //# debugId=0DCC16C45A0B9F4D64756E2164756E21
692
203
  //# sourceMappingURL=svelte.js.map