Changeset 6cbd014 in Klonkt for src/services/PasskeyService.js
- Timestamp:
- 07/21/2026 01:32:23 AM (7 weeks ago)
- Branches:
- main
- Children:
- d48ea02
- Parents:
- d43230f
- git-author:
- Robin <roboburr@…> (07/21/2026 01:30:40 AM)
- git-committer:
- Robin <roboburr@…> (07/21/2026 01:32:23 AM)
- File:
-
- 1 edited
-
src/services/PasskeyService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/PasskeyService.js
rd43230f r6cbd014 63 63 } 64 64 65 // Authentication (assertion) options for the unlock. Discoverable credentials, 66 // so allowCredentials is empty and the browser offers the site's passkeys. 67 export async function authenticationOptions(base) { 68 const { rpID } = rpFor(base); 69 const { generateAuthenticationOptions } = await lib(); 70 return generateAuthenticationOptions({ rpID, userVerification: 'preferred', allowCredentials: [] }); 71 } 72 73 // Verify an assertion against a stored entitlement row. Returns { newCounter } 74 // or null. Challenge is read from the signed blob by the caller. 75 export async function verifyAssertion(base, response, expectedChallenge, ent) { 76 const { rpID, origin } = rpFor(base); 77 let v; 78 try { 79 const { verifyAuthenticationResponse } = await lib(); 80 v = await verifyAuthenticationResponse({ 81 response, 82 expectedChallenge, 83 expectedOrigin: origin, 84 expectedRPID: rpID, 85 requireUserVerification: false, 86 credential: { 87 id: ent.credential_id, 88 publicKey: Buffer.from(ent.public_key, 'base64url'), 89 counter: ent.counter || 0, 90 transports: ent.transports ? JSON.parse(ent.transports) : undefined, 91 }, 92 }); 93 } catch { return null; } 94 if (!v || !v.verified) return null; 95 return { newCounter: v.authenticationInfo.newCounter }; 96 } 97 98 // Bump the signature counter after a successful assertion (clone detection). 99 export function bumpCounter(credentialId, newCounter) { 100 db.prepare('UPDATE paid_entitlements SET counter = ? WHERE credential_id = ?').run(newCounter || 0, credentialId); 101 } 102 65 103 // Store (or refresh) a pseudonymous entitlement for this passkey. 66 104 export function storeEntitlement({ credentialId, siteId, publicKey, counter, transports, minCents, ttlDays = DEFAULT_TTL_DAYS }) { … … 96 134 rpFor, registrationOptions, verifyRegistration, storeEntitlement, 97 135 getEntitlement, deleteEntitlement, pruneExpired, 136 authenticationOptions, verifyAssertion, bumpCounter, 98 137 };
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)