SPB Git

Repository Public

verify-passkey.ts 3.5 KB 66 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : SP Vault8 * File             : apple/SharedVaultKit/Tests/Tools/verify-passkey.ts9 * Module           : Tools10 * Repository       : https://git.spboucher.ai/sp-vault11 * Project Website  : https://vault.spboucher.ai12 * Created          : 2026-11-1913 * Last Modified    : 2026-11-1914 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// Independent check of PasskeyCrypto (Swift) with @simplewebauthn/server — the library the API server uses.44// Reads one JSON object on stdin: { rpId, origin, challenge, registration: RegistrationResponseJSON,45// assertionChallenge, assertion: AuthenticationResponseJSON } and prints { registration: {...}, assertion: {...} }.46// Run from the repository root:  node --import tsx apple/SharedVaultKit/Tests/Tools/verify-passkey.ts < input.json47import { verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server";4849let text = "";50for await (const chunk of process.stdin) text += chunk;51const input = JSON.parse(text);5253const reg = await verifyRegistrationResponse({ response: input.registration, expectedChallenge: input.challenge, expectedOrigin: input.origin, expectedRPID: input.rpId, requireUserVerification: true });54if (!reg.verified || !reg.registrationInfo) throw new Error("registration not verified");55const info = reg.registrationInfo;56const auth = await verifyAuthenticationResponse({57  response: input.assertion, expectedChallenge: input.assertionChallenge, expectedOrigin: input.origin, expectedRPID: input.rpId, requireUserVerification: true,58  credential: { id: info.credential.id, publicKey: info.credential.publicKey, counter: info.credential.counter },59});60process.stdout.write(JSON.stringify({61  registration: { verified: reg.verified, fmt: info.fmt, credentialId: info.credential.id, counter: info.credential.counter, aaguid: info.aaguid,62    userVerified: info.userVerified, deviceType: info.credentialDeviceType, backedUp: info.credentialBackedUp },63  assertion: { verified: auth.verified, newCounter: auth.authenticationInfo.newCounter, userVerified: auth.authenticationInfo.userVerified,64    deviceType: auth.authenticationInfo.credentialDeviceType, backedUp: auth.authenticationInfo.credentialBackedUp },65}));66
Files main
Menu

Theme