diff options
author | Jonathan Stewmon <jstewmon@gmail.com> | 2020-11-16 12:27:05 -0600 |
---|---|---|
committer | Jonathan Stewmon <jstewmon@gmail.com> | 2020-11-18 10:59:00 -0600 |
commit | b5a6681ee08a1c75662eea332fbec02725331118 (patch) | |
tree | 415b110ae65478fc1328de0e6954934a498efca4 /packages/server/src/helpers/parseAuthenticatorData.ts | |
parent | 3375ac37a88a4227b76f092853748a5edb134eac (diff) |
chore(deps): update cbor and wrap decodeFirstSync with recovery
Since cbor 5.1, decodeFirstSync behaves consistently with the async
method, which throws an error if there are extra bytes after the first
object.
see: https://github.com/hildjj/node-cbor/commit/dc4f76445c42dc45dd5750ee53851159622795de
Diffstat (limited to 'packages/server/src/helpers/parseAuthenticatorData.ts')
-rw-r--r-- | packages/server/src/helpers/parseAuthenticatorData.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/packages/server/src/helpers/parseAuthenticatorData.ts b/packages/server/src/helpers/parseAuthenticatorData.ts index 6fea0bd..67f0e1a 100644 --- a/packages/server/src/helpers/parseAuthenticatorData.ts +++ b/packages/server/src/helpers/parseAuthenticatorData.ts @@ -1,4 +1,5 @@ import cbor from 'cbor'; +import { decodeCborFirst } from './decodeCbor'; /** * Make sense of the authData buffer contained in an Attestation @@ -50,7 +51,7 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti intBuffer = intBuffer.slice(credIDLen); // Decode the next CBOR item in the buffer, then re-encode it back to a Buffer - const firstDecoded = cbor.decodeFirstSync(intBuffer); + const firstDecoded = decodeCborFirst(intBuffer); const firstEncoded = Buffer.from(cbor.encode(firstDecoded)); credentialPublicKey = firstEncoded; intBuffer = intBuffer.slice(firstEncoded.byteLength); @@ -58,7 +59,7 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti let extensionsDataBuffer: Buffer | undefined = undefined; if (flags.ed) { - const firstDecoded = cbor.decodeFirstSync(intBuffer); + const firstDecoded = decodeCborFirst(intBuffer); const firstEncoded = Buffer.from(cbor.encode(firstDecoded)); extensionsDataBuffer = firstEncoded; intBuffer = intBuffer.slice(firstEncoded.byteLength); |