@glyphteck/veyl 0.63.7 → 0.65.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.
- package/dist/account.js +3677 -308
- package/dist/accountprofiles.js +1362 -0
- package/dist/auth.js +26 -10
- package/dist/cli.js +4740 -773
- package/dist/index.js +4729 -768
- package/docs/api.md +12 -7
- package/docs/cli.md +1 -1
- package/package.json +3 -2
package/dist/auth.js
CHANGED
|
@@ -458,6 +458,19 @@ function openAuth(options = {}) {
|
|
|
458
458
|
const source = cleanText(operation.origin) || cleanText(configured) || cleanText(operation.webUrl) || cleanText(options.webUrl) || links.veyl;
|
|
459
459
|
return new URL(source).origin;
|
|
460
460
|
}
|
|
461
|
+
async function requireAuthenticatedUid(expectedUid = null) {
|
|
462
|
+
const uid = cleanText(transport.user?.uid);
|
|
463
|
+
const expected = cleanText(expectedUid);
|
|
464
|
+
if (uid && (!expected || uid === expected))
|
|
465
|
+
return uid;
|
|
466
|
+
const error = new Error(uid ? "account authentication mismatch" : "account authentication failed");
|
|
467
|
+
try {
|
|
468
|
+
await requireMethod(transport.logout, "account logout")();
|
|
469
|
+
} catch (cleanupError) {
|
|
470
|
+
error.cause = cleanupError;
|
|
471
|
+
}
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
461
474
|
async function createCredential(publicKeyOptions, operation = {}) {
|
|
462
475
|
operation.onPrompt?.();
|
|
463
476
|
const result = await requireMethod(ceremony.create, "passkey creation")(publicKeyOptions, operation);
|
|
@@ -488,8 +501,9 @@ function openAuth(options = {}) {
|
|
|
488
501
|
return transport.register.token({ attestation });
|
|
489
502
|
}
|
|
490
503
|
await transport.register.finish({ attestation });
|
|
491
|
-
await
|
|
492
|
-
|
|
504
|
+
const uid = await requireAuthenticatedUid(start?.uid);
|
|
505
|
+
await operation.onVerified?.({ uid });
|
|
506
|
+
return { success: true, uid };
|
|
493
507
|
} catch (error) {
|
|
494
508
|
throw normalizePasskeyRegisterError(error, options.registerErrorOptions);
|
|
495
509
|
}
|
|
@@ -507,8 +521,10 @@ function openAuth(options = {}) {
|
|
|
507
521
|
if (tokenOnly) {
|
|
508
522
|
return transport.login.token({ assertion });
|
|
509
523
|
}
|
|
510
|
-
await transport.login.finish({ assertion }
|
|
511
|
-
|
|
524
|
+
await transport.login.finish({ assertion });
|
|
525
|
+
const uid = await requireAuthenticatedUid(operation.uid);
|
|
526
|
+
await operation.onVerified?.({ uid });
|
|
527
|
+
return { success: true, uid };
|
|
512
528
|
} catch (error) {
|
|
513
529
|
throw normalizePasskeyLoginError(error, options.loginErrorOptions);
|
|
514
530
|
}
|
|
@@ -642,6 +658,12 @@ function openAuth(options = {}) {
|
|
|
642
658
|
return transport.user || null;
|
|
643
659
|
},
|
|
644
660
|
subscribe: (listener) => transport.watch(listener),
|
|
661
|
+
activateToken: async (token) => {
|
|
662
|
+
if (!cleanText(token))
|
|
663
|
+
throw new Error("account session token required");
|
|
664
|
+
await requireMethod(transport.activateToken, "account session activation")(token);
|
|
665
|
+
return true;
|
|
666
|
+
},
|
|
645
667
|
register: (operation) => register(operation),
|
|
646
668
|
registerToken: (operation) => register(operation, true),
|
|
647
669
|
login: (operation) => login(operation),
|
|
@@ -655,12 +677,6 @@ function openAuth(options = {}) {
|
|
|
655
677
|
origin: operationOrigin(operation)
|
|
656
678
|
}),
|
|
657
679
|
add: addLink,
|
|
658
|
-
activate: async (sessionToken) => {
|
|
659
|
-
if (!cleanText(sessionToken))
|
|
660
|
-
throw new Error("passkey link session required");
|
|
661
|
-
await transport.passkeyLinks.activate(sessionToken);
|
|
662
|
-
return true;
|
|
663
|
-
},
|
|
664
680
|
create: createLink
|
|
665
681
|
}),
|
|
666
682
|
passkeys: Object.freeze({
|