summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/decodeAttestationObject.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-11-11 15:50:45 -0800
committerMatthew Miller <matthew@millerti.me>2022-11-11 15:50:45 -0800
commite5f0187693cb1521eb7f032adac2ca1005d4e406 (patch)
tree97b667439dfd8d87d4921e7af6b171391fab543d /packages/server/src/helpers/decodeAttestationObject.ts
parentb522a24a229d031ea0286f111179ac3bf30cfeca (diff)
Refactor more to handle CBOR maps
Diffstat (limited to 'packages/server/src/helpers/decodeAttestationObject.ts')
-rw-r--r--packages/server/src/helpers/decodeAttestationObject.ts27
1 files changed, 13 insertions, 14 deletions
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>(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;
};