|
@ -30,10 +30,6 @@ export interface JWK { |
|
|
x: string; |
|
|
x: string; |
|
|
y: string; |
|
|
y: string; |
|
|
} |
|
|
} |
|
|
export interface PublicKeyCredential { |
|
|
|
|
|
rawId: Uint8Array; |
|
|
|
|
|
jwt: JWK; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function toBase64Url(anythingB64: string) { |
|
|
function toBase64Url(anythingB64: string) { |
|
|
return anythingB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); |
|
|
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
|
|
|
// https://chatgpt.com/share/3c13f061-6031-45bc-a2d7-3347c1e7a2d7
|
|
|
|
|
|
|
|
|
const credIdBase64Url = verification.registrationInfo?.credentialID as string; |
|
|
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( |
|
|
const credIdHex = Buffer.from( |
|
|
base64URLStringToArrayBuffer(credIdBase64Url), |
|
|
base64URLStringToArrayBuffer(credIdBase64Url), |
|
|
).toString("hex"); |
|
|
).toString("hex"); |
|
@ -86,7 +85,6 @@ export async function registerCredential(passkeyName?: string) { |
|
|
return { |
|
|
return { |
|
|
authData: verification.registrationInfo?.attestationObject, |
|
|
authData: verification.registrationInfo?.attestationObject, |
|
|
credIdHex: credIdHex, |
|
|
credIdHex: credIdHex, |
|
|
rawId: new Uint8Array(new Buffer(attResp.rawId, "base64")), |
|
|
|
|
|
publicKeyJwk: publicKeyJwk, |
|
|
publicKeyJwk: publicKeyJwk, |
|
|
publicKeyBytes: verification.registrationInfo |
|
|
publicKeyBytes: verification.registrationInfo |
|
|
?.credentialPublicKey as Uint8Array, |
|
|
?.credentialPublicKey as Uint8Array, |
|
@ -286,7 +284,6 @@ export class PeerSetup { |
|
|
// import { p256 } from "@noble/curves/p256";
|
|
|
// import { p256 } from "@noble/curves/p256";
|
|
|
export async function verifyJwtP256( |
|
|
export async function verifyJwtP256( |
|
|
credIdHex: string, |
|
|
credIdHex: string, |
|
|
rawId: Uint8Array, |
|
|
|
|
|
did: string, |
|
|
did: string, |
|
|
authenticatorData: ArrayBuffer, |
|
|
authenticatorData: ArrayBuffer, |
|
|
challenge: Uint8Array, |
|
|
challenge: Uint8Array, |
|
@ -315,7 +312,6 @@ export async function verifyJwtP256( |
|
|
|
|
|
|
|
|
export async function verifyJwtSimplewebauthn( |
|
|
export async function verifyJwtSimplewebauthn( |
|
|
credIdHex: string, |
|
|
credIdHex: string, |
|
|
rawId: Uint8Array, |
|
|
|
|
|
did: string, |
|
|
did: string, |
|
|
authenticatorData: ArrayBuffer, |
|
|
authenticatorData: ArrayBuffer, |
|
|
challenge: Uint8Array, |
|
|
challenge: Uint8Array, |
|
@ -340,7 +336,7 @@ export async function verifyJwtSimplewebauthn( |
|
|
authenticatorAttachment: "platform", |
|
|
authenticatorAttachment: "platform", |
|
|
clientExtensionResults: {}, |
|
|
clientExtensionResults: {}, |
|
|
id: credId, |
|
|
id: credId, |
|
|
rawId: arrayToBase64Url(rawId), |
|
|
rawId: credId, |
|
|
response: { |
|
|
response: { |
|
|
authenticatorData: authData, |
|
|
authenticatorData: authData, |
|
|
clientDataJSON: clientDataJsonBase64Url, |
|
|
clientDataJSON: clientDataJsonBase64Url, |
|
@ -355,7 +351,6 @@ export async function verifyJwtSimplewebauthn( |
|
|
|
|
|
|
|
|
export async function verifyJwtWebCrypto( |
|
|
export async function verifyJwtWebCrypto( |
|
|
credId: Base64URLString, |
|
|
credId: Base64URLString, |
|
|
rawId: Uint8Array, |
|
|
|
|
|
did: string, |
|
|
did: string, |
|
|
authenticatorData: ArrayBuffer, |
|
|
authenticatorData: ArrayBuffer, |
|
|
challenge: Uint8Array, |
|
|
challenge: Uint8Array, |
|
|