From: Ardis Lu Date: Thu, 24 Jul 2025 04:56:34 +0000 (-0700) Subject: Make user handle a non-zero value X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=323f3c589eb68d452730709d9fafaa2e3582c226;p=static-encrypt-passkey Make user handle a non-zero value The specification says: > The user handle MUST NOT be empty, though it MAY be null. Source: https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialuserentity-id Some authenticators (e.g., Windows Hello) consider `new ArrayBuffer(0)` to be invalid, others (e.g., 1Password) consider it to be valid. Setting `id` to a non-zero value enables wider compatibility. --- diff --git a/script.js b/script.js index 75c442c..b2cc09e 100644 --- a/script.js +++ b/script.js @@ -8,7 +8,7 @@ async function createPrf() { return navigator.credentials.create({ publicKey: { rp: { name: '' }, - user: { id: new ArrayBuffer(0), name: '', displayName: '' }, + user: { id: new ArrayBuffer(1), name: '', displayName: '' }, pubKeyCredParams: [{ type: 'public-key', alg: -8 }, { type: 'public-key', alg: -7 }, { type: 'public-key', alg: -257 }], extensions: { prf: { eval: { first: new ArrayBuffer(0) } } }, challenge: new ArrayBuffer(0)