blob: a0dc5c2f55a115be9501dd35bfc59d781ce2056d (
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
|
import cbor from 'cbor';
/**
* Convert authenticator extension data buffer to a proper object
*
* @param extensionData Authenticator Extension Data buffer
*/
export function decodeAuthenticatorExtensions(
extensionData: Buffer
): AuthenticationExtensionsAuthenticatorOutputs | undefined {
let toCBOR: AuthenticationExtensionsAuthenticatorOutputs | undefined;
try {
toCBOR = cbor.decodeAllSync(extensionData)[0];
} catch (err) {
const _err = err as Error;
throw new Error(`Error decoding authenticator extensions: ${_err.message}`);
}
return toCBOR;
}
export type AuthenticationExtensionsAuthenticatorOutputs = {
devicePublicKey?: DevicePublicKeyAuthenticatorOutput;
uvm?: UVMAuthenticatorOutput;
}
export type DevicePublicKeyAuthenticatorOutput = {
dpk?: Buffer;
scp?: Buffer;
sig?: string;
aaguid?: Buffer;
}
// TODO: Need to verify this format
// https://w3c.github.io/webauthn/#sctn-uvm-extension.
export type UVMAuthenticatorOutput = {
uvm?: Buffer[]
}
|