summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/parseAuthenticatorData.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-06-30 08:09:53 -0700
committerMatthew Miller <matthew@millerti.me>2020-06-30 08:09:53 -0700
commit6231a2af7340614dcbc1fdd8a839200a6939b8de (patch)
tree6518de9809a09ae86e8d953b6b19a871f4148e1c /packages/server/src/helpers/parseAuthenticatorData.ts
parentcdbb88a48d7c9d7985453a0dd552106db3742969 (diff)
Use CBOR decoder to extract pubKey from authData
Diffstat (limited to 'packages/server/src/helpers/parseAuthenticatorData.ts')
-rw-r--r--packages/server/src/helpers/parseAuthenticatorData.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/server/src/helpers/parseAuthenticatorData.ts b/packages/server/src/helpers/parseAuthenticatorData.ts
index 919c0aa..60bde01 100644
--- a/packages/server/src/helpers/parseAuthenticatorData.ts
+++ b/packages/server/src/helpers/parseAuthenticatorData.ts
@@ -1,3 +1,5 @@
+import cbor from 'cbor';
+
/**
* Make sense of the authData buffer contained in an Attestation
*/
@@ -47,7 +49,11 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti
credentialID = intBuffer.slice(0, credIDLen);
intBuffer = intBuffer.slice(credIDLen);
- credentialPublicKey = intBuffer;
+ // Decode the next CBOR item in the buffer, then re-encode it back to a Buffer
+ const firstDecoded = cbor.decodeFirstSync(intBuffer);
+ const firstEncoded = cbor.encode(firstDecoded);
+ credentialPublicKey = firstEncoded;
+ intBuffer = intBuffer.slice(firstEncoded.byteLength);
}
return {