blob: e5accdd2f410aa587696dc51d3d6296e551f626e (
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
|
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',
NONE = 'none',
}
export type AttestationObject = {
fmt: ATTESTATION_FORMATS;
attStmt: AttestationStatement;
authData: Buffer;
};
export type AttestationStatement = {
sig?: Buffer;
x5c?: Buffer[];
response?: Buffer;
};
|