summaryrefslogtreecommitdiffhomepage
path: root/src/helpers/decodeAttestationObject.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-05-17 23:20:00 -0700
committerMatthew Miller <matthew@millerti.me>2020-05-17 23:20:00 -0700
commit23e320bf7133a90ae4dfcec7c65249c1dde7e321 (patch)
tree44d4823b72f4f5c1cd6603db520077405b62dc96 /src/helpers/decodeAttestationObject.ts
parent3b26d1c8322f13178377467e438884621a75e284 (diff)
Add some helpers
Diffstat (limited to 'src/helpers/decodeAttestationObject.ts')
-rw-r--r--src/helpers/decodeAttestationObject.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/helpers/decodeAttestationObject.ts b/src/helpers/decodeAttestationObject.ts
new file mode 100644
index 0000000..a03fefd
--- /dev/null
+++ b/src/helpers/decodeAttestationObject.ts
@@ -0,0 +1,23 @@
+import base64url from 'base64url';
+import cbor from 'cbor';
+
+import { ATTESTATION_FORMATS } from './constants';
+
+type AttestationObject = {
+ fmt: ATTESTATION_FORMATS,
+ attStmt: {
+ sig?: Buffer,
+ x5c?: Buffer,
+ },
+ authData: Buffer,
+};
+
+/**
+ *
+ * @param obj
+ */
+export default function decodeAttestationObject(obj: string): AttestationObject {
+ const toBuffer = base64url.toBuffer(obj);
+ const toCBOR = cbor.decodeAllSync(toBuffer)[0];
+ return toCBOR;
+}