|
|
@ -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, |
|
|
|