]> git.ardis.lu - static-encrypt-passkey/commitdiff
Make user handle a non-zero value
authorArdis Lu <ardisglu@gmail.com>
Thu, 24 Jul 2025 04:56:34 +0000 (21:56 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 24 Jul 2025 04:56:34 +0000 (21:56 -0700)
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.

script.js

index 75c442c5c03bef7040ab99cf7ea5e8329183937d..b2cc09ed86a3bd29e8a37ee5e1b338e26caa0fb9 100644 (file)
--- 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)
This page took 0.044346 seconds and 4 git commands to generate.