From cf1137737abe0950c9b05134388909fca3b2a868 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 16 Jun 2024 10:12:56 -0600 Subject: [PATCH] allow switching to did:peer ID, remove another unnecessary data point --- src/libs/didPeer.ts | 13 ++++--------- src/views/IdentitySwitcherView.vue | 2 +- src/views/TestView.vue | 7 +------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/libs/didPeer.ts b/src/libs/didPeer.ts index a395765..a9ee6fc 100644 --- a/src/libs/didPeer.ts +++ b/src/libs/didPeer.ts @@ -30,10 +30,6 @@ export interface JWK { x: string; y: string; } -export interface PublicKeyCredential { - rawId: Uint8Array; - jwt: JWK; -} function toBase64Url(anythingB64: string) { return anythingB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); @@ -76,6 +72,9 @@ export async function registerCredential(passkeyName?: string) { // https://chatgpt.com/share/3c13f061-6031-45bc-a2d7-3347c1e7a2d7 const credIdBase64Url = verification.registrationInfo?.credentialID as string; + if (attResp.rawId !== credIdBase64Url) { + console.log("Warning! The raw ID does not match the credential ID.") + } const credIdHex = Buffer.from( base64URLStringToArrayBuffer(credIdBase64Url), ).toString("hex"); @@ -86,7 +85,6 @@ export async function registerCredential(passkeyName?: string) { return { authData: verification.registrationInfo?.attestationObject, credIdHex: credIdHex, - rawId: new Uint8Array(new Buffer(attResp.rawId, "base64")), publicKeyJwk: publicKeyJwk, publicKeyBytes: verification.registrationInfo ?.credentialPublicKey as Uint8Array, @@ -286,7 +284,6 @@ export class PeerSetup { // import { p256 } from "@noble/curves/p256"; export async function verifyJwtP256( credIdHex: string, - rawId: Uint8Array, did: string, authenticatorData: ArrayBuffer, challenge: Uint8Array, @@ -315,7 +312,6 @@ export async function verifyJwtP256( export async function verifyJwtSimplewebauthn( credIdHex: string, - rawId: Uint8Array, did: string, authenticatorData: ArrayBuffer, challenge: Uint8Array, @@ -340,7 +336,7 @@ export async function verifyJwtSimplewebauthn( authenticatorAttachment: "platform", clientExtensionResults: {}, id: credId, - rawId: arrayToBase64Url(rawId), + rawId: credId, response: { authenticatorData: authData, clientDataJSON: clientDataJsonBase64Url, @@ -355,7 +351,6 @@ export async function verifyJwtSimplewebauthn( export async function verifyJwtWebCrypto( credId: Base64URLString, - rawId: Uint8Array, did: string, authenticatorData: ArrayBuffer, challenge: Uint8Array, diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index 0bdfb9e..0c05b81 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -112,7 +112,7 @@ export default class IdentitySwitcherView extends Vue { await accountsDB.open(); const accounts = await accountsDB.accounts.toArray(); for (let n = 0; n < accounts.length; n++) { - const did = JSON.parse(accounts[n].identity)["did"]; + const did = accounts[n]["did"]; this.otherIdentities.push({ did: did }); if (did && this.activeDid === did) { this.activeDidInIdentities = true; diff --git a/src/views/TestView.vue b/src/views/TestView.vue index e8bc171..3ced12e 100644 --- a/src/views/TestView.vue +++ b/src/views/TestView.vue @@ -200,7 +200,7 @@ Navigator -
+
Verify