From: Ardis Lu Date: Sun, 19 Jul 2026 06:25:59 +0000 (-0700) Subject: Wrap prf output in Uint8Array X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;ds=sidebyside;p=static-encrypt-passkey Wrap prf output in Uint8Array Non-standard passkey implementations (e.g., 1Password) return `Array` instead of `BufferSource`. --- diff --git a/index.html b/index.html index b6c3b4b..fa592dc 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ - + static-encrypt-passkey diff --git a/script.js b/script.js index 093f5d6..29850fb 100644 --- a/script.js +++ b/script.js @@ -93,7 +93,9 @@ export async function encrypt(plaintext) { paddedPlaintext.set([p]); // Offset to discard on decode paddedPlaintext.set(encodedPlaintext, p); // Gap filled with zero bytes, e.g. [3, 0, 0, ...encodedPlaintext] - const prf = await createPrf(); + // As per the specification, the PRF extension *should* already return a BufferSource which can be directly + // passed to Web Crypto API, however non-standard passkey implementations (e.g., 1Password) return Array. + const prf = new Uint8Array(await createPrf()); const key = await getKey(prf, salt, info); const ciphertext = new Uint8Array(await crypto.subtle.encrypt( { name: 'AES-GCM', iv }, @@ -126,7 +128,9 @@ export async function decrypt(content) { // Prepare non-crypto inputs const info = new TextEncoder().encode('https://github.com/ardislu/static-encrypt-passkey'); - const prf = await getPrf(); + // As per the specification, the PRF extension *should* already return a BufferSource which can be directly + // passed to Web Crypto API, however non-standard passkey implementations (e.g., 1Password) return Array. + const prf = new Uint8Array(await getPrf()); const key = await getKey(prf, salt, info); const encodedPlaintext = new Uint8Array(await crypto.subtle.decrypt( { name: 'AES-GCM', iv },