blob: 09d95fb442a0cb728b0cc664f83697ff6ab1296a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import base64url from 'base64url';
import cbor from 'cbor';
/**
* Convert an AttestationObject from base64url string to a proper object
*
* @param base64AttestationObject Base64URL-encoded Attestation Object
*/
export default function decodeAttestationObject(
base64AttestationObject: string,
): AttestationObject {
const toBuffer = base64url.toBuffer(base64AttestationObject);
const toCBOR: AttestationObject = cbor.decodeAllSync(toBuffer)[0];
return toCBOR;
}
export enum ATTESTATION_FORMATS {
FIDO_U2F = 'fido-u2f',
PACKED = 'packed',
ANDROID_SAFETYNET = 'android-safetynet',
ANDROID_KEY = 'android-key',
TPM = 'tpm',
APPLE = 'apple',
NONE = 'none',
}
export type AttestationObject = {
fmt: ATTESTATION_FORMATS;
attStmt: AttestationStatement;
authData: Buffer;
};
export type AttestationStatement = {
sig?: Buffer;
x5c?: Buffer[];
response?: Buffer;
alg?: number;
ver?: string;
certInfo?: Buffer;
pubArea?: Buffer;
};
|