Skip to content

Commit 43d2710

Browse files
committed
webauthn: ensure allowCredentials[].id is an ArrayBuffer
closes gh-16439 Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
1 parent 60dbeba commit 43d2710

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

javascript/lib/webauthn-core.js

+9
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,17 @@ async function authenticate(headers, contextPath, useConditionalMediation) {
4141
}
4242

4343
// FIXME: Use https://www.w3.org/TR/webauthn-3/#sctn-parseRequestOptionsFromJSON
44+
const decodedAllowCredentials = !options.allowCredentials
45+
? []
46+
: options.allowCredentials.map((cred) => ({
47+
...cred,
48+
id: base64url.decode(cred.id),
49+
}));
50+
51+
4452
const decodedOptions = {
4553
...options,
54+
allowCredentials: decodedAllowCredentials,
4655
challenge: base64url.decode(options.challenge),
4756
};
4857

javascript/test/webauthn-core.test.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ describe("webauthn-core", () => {
8585
challenge: "nRbOrtNKTfJ1JaxfUDKs8j3B-JFqyGQw8DO4u6eV3JA",
8686
timeout: 300000,
8787
rpId: "localhost",
88-
allowCredentials: [],
88+
allowCredentials: [
89+
{
90+
id: "nOsjw8eaaqSwVdTBBYE1FqfGdHs",
91+
type: "public-key",
92+
transports: [],
93+
},
94+
],
8995
userVerification: "preferred",
9096
extensions: {},
9197
};
@@ -172,7 +178,13 @@ describe("webauthn-core", () => {
172178
challenge: base64url.decode("nRbOrtNKTfJ1JaxfUDKs8j3B-JFqyGQw8DO4u6eV3JA"),
173179
timeout: 300000,
174180
rpId: "localhost",
175-
allowCredentials: [],
181+
allowCredentials: [
182+
{
183+
id: base64url.decode("nOsjw8eaaqSwVdTBBYE1FqfGdHs"),
184+
type: "public-key",
185+
transports: [],
186+
},
187+
],
176188
userVerification: "preferred",
177189
extensions: {},
178190
},

0 commit comments

Comments
 (0)