summaryrefslogtreecommitdiffhomepage
path: root/src/helpers/decodeAttestationObject.ts
diff options
context:
space:
mode:
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;
+}