From e5f0187693cb1521eb7f032adac2ca1005d4e406 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 11 Nov 2022 15:50:45 -0800 Subject: Refactor more to handle CBOR maps --- .../server/src/helpers/decodeAttestationObject.ts | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'packages/server/src/helpers/decodeAttestationObject.ts') diff --git a/packages/server/src/helpers/decodeAttestationObject.ts b/packages/server/src/helpers/decodeAttestationObject.ts index bab6ced..9d08e33 100644 --- a/packages/server/src/helpers/decodeAttestationObject.ts +++ b/packages/server/src/helpers/decodeAttestationObject.ts @@ -1,13 +1,12 @@ -import { decodeCborFirst } from './decodeCbor'; +import * as cbor from './cbor'; /** * Convert an AttestationObject buffer to a proper object * * @param base64AttestationObject Attestation Object buffer */ -export function decodeAttestationObject(attestationObject: Buffer): AttestationObject { - const toCBOR: AttestationObject = decodeCborFirst(attestationObject); - return toCBOR; +export function decodeAttestationObject(attestationObject: Uint8Array): AttestationObject { + return cbor.decodeFirst(attestationObject); } export type AttestationFormat = @@ -20,17 +19,17 @@ export type AttestationFormat = | 'none'; export type AttestationObject = { - fmt: AttestationFormat; - attStmt: AttestationStatement; - authData: Buffer; + get(key: 'fmt'): AttestationFormat; + get(key: 'attStmt'): AttestationStatement; + get(key: 'authData'): Uint8Array; }; export type AttestationStatement = { - sig?: Buffer; - x5c?: Buffer[]; - response?: Buffer; - alg?: number; - ver?: string; - certInfo?: Buffer; - pubArea?: Buffer; + get(key: 'sig'): Uint8Array | undefined; + get(key: 'x5c'): Uint8Array[] | undefined; + get(key: 'response'): Uint8Array | undefined; + get(key: 'alg'): number | undefined; + get(key: 'ver'): string | undefined; + get(key: 'certInfo'): Uint8Array | undefined; + get(key: 'pubArea'): Uint8Array | undefined; }; -- cgit v1.2.3