diff options
author | Matthew Miller <matthew@millerti.me> | 2022-11-12 19:51:29 -0800 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2022-11-12 19:51:29 -0800 |
commit | 6e3db9655c6aa2aef590c66295df500271bfdd17 (patch) | |
tree | 03ac98e1da17f97c4f7da151868a16ca445e0ec2 /packages/server/src/helpers/parseAuthenticatorData.ts | |
parent | 6a4ced11ee7d1e872af4215f9aba82c7b64119c2 (diff) |
Figure out a better pattern for exposing iso funcs
Diffstat (limited to 'packages/server/src/helpers/parseAuthenticatorData.ts')
-rw-r--r-- | packages/server/src/helpers/parseAuthenticatorData.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/packages/server/src/helpers/parseAuthenticatorData.ts b/packages/server/src/helpers/parseAuthenticatorData.ts index f45e717..bcc552d 100644 --- a/packages/server/src/helpers/parseAuthenticatorData.ts +++ b/packages/server/src/helpers/parseAuthenticatorData.ts @@ -1,9 +1,8 @@ -import * as isoCBOR from './isoCBOR'; import { decodeAuthenticatorExtensions, AuthenticationExtensionsAuthenticatorOutputs, } from './decodeAuthenticatorExtensions'; -import * as isoUint8Array from './isoUint8Array'; +import { isoCBOR, isoUint8Array } from './iso'; import { COSEPublicKey } from './convertCOSEtoPKCS'; /** @@ -17,7 +16,7 @@ export function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticato } let pointer = 0; - const dataView = uint8Array.toDataView(authData); + const dataView = isoUint8Array.toDataView(authData); const rpIdHash = authData.slice(pointer, (pointer += 32)); @@ -53,8 +52,8 @@ export function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticato credentialID = authData.slice(pointer, (pointer += credIDLen)); // Decode the next CBOR item in the buffer, then re-encode it back to a Buffer - const firstDecoded = cbor.decodeFirst<COSEPublicKey>(authData.slice(pointer)); - const firstEncoded = Uint8Array.from(cbor.encode(firstDecoded)); + const firstDecoded = isoCBOR.decodeFirst<COSEPublicKey>(authData.slice(pointer)); + const firstEncoded = Uint8Array.from(isoCBOR.encode(firstDecoded)); credentialPublicKey = firstEncoded; pointer += firstEncoded.byteLength; @@ -64,8 +63,8 @@ export function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticato let extensionsDataBuffer: Uint8Array | undefined = undefined; if (flags.ed) { - const firstDecoded = cbor.decodeFirst(authData.slice(pointer)); - extensionsDataBuffer = Uint8Array.from(cbor.encode(firstDecoded)); + const firstDecoded = isoCBOR.decodeFirst(authData.slice(pointer)); + extensionsDataBuffer = Uint8Array.from(isoCBOR.encode(firstDecoded)); extensionsData = decodeAuthenticatorExtensions(extensionsDataBuffer); pointer += extensionsDataBuffer.byteLength; } |