-
Notifications
You must be signed in to change notification settings - Fork 116
/
main.d.ts
146 lines (129 loc) · 3.67 KB
/
main.d.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/// <reference types="node" />
declare module "fido2-lib" {
class Fido2Lib {
constructor(opts?: Fido2LibOptions);
attestationOptions(
opts?: AttestationOptions
): Promise<PublicKeyCredentialCreationOptions>;
attestationResult(
res: AttestationResult,
expected: ExpectedAttestationResult
): Promise<Fido2AttestationResult>;
assertionOptions(
opts?: AssertionOptions
): Promise<PublicKeyCredentialRequestOptions>;
assertionResult(
res: AssertionResult,
expected: ExpectedAssertionResult
): Promise<Fido2AssertionResult>;
}
interface Fido2LibOptions {
timeout?: number;
rpId?: string;
rpName?: string;
rpIcon?: string;
challengeSize?: number;
authenticatorAttachment?: Attachment;
authenticatorRequireResidentKey?: boolean;
authenticatorUserVerification?: UserVerification;
attestation?: Attestation;
cryptoParams?: Array<number>;
}
interface AuthenticatorSelectionCriteria {
attachment?: Attachment;
requireResidentKey?: boolean;
userVerification?: UserVerification;
}
interface AttestationOptions {
extensionOptions?: any;
extraData?: string;
}
interface AssertionOptions {
extensionOptions?: any;
extraData?: string;
}
interface PublicKeyCredentialCreationOptions {
rp: { name: string; id: string; icon?: string };
user: { id: string, name: string, displayName: string };
challenge: ArrayBuffer;
pubKeyCredParams: Array<{ type: "public-key"; alg: number }>;
timeout?: number;
attestation?: Attestation;
authenticatorSelectionCriteria?: AuthenticatorSelectionCriteria;
rawChallenge?: ArrayBuffer;
extensions?: any;
}
type Attestation = "direct" | "indirect" | "none";
type Attachment = "platform" | "cross-platform";
type UserVerification = "required" | "preferred" | "discouraged";
type Factor = "first" | "second" | "either";
interface AttestationResult {
id?: ArrayBuffer;
rawId?: ArrayBuffer;
transports?: string[];
response: { clientDataJSON: string; attestationObject: string };
}
interface ExpectedAttestationResult {
rpId?: string;
origin: string;
challenge: string;
factor: Factor;
}
interface Fido2AttestationResult {
authnrData: Map<string, any>;
clientData: Map<string, any>;
expectations: Map<string, string>;
request: AttestationResult;
audit: Audit;
}
interface Audit {
validExpectations: boolean;
validRequest: boolean;
complete: boolean;
journal: Set<string>;
warning: Map<string, string>;
info: Map<string, string>;
}
interface PublicKeyCredentialRequestOptions {
challenge: ArrayBuffer;
timeout?: number;
rpId?: string;
attestation?: Attestation;
userVerification?: UserVerification;
rawChallenge?: ArrayBuffer;
extensions?: any;
allowCredentials?: PublicKeyCredentialDescriptor[];
}
interface PublicKeyCredentialDescriptor {
type: "public-key";
id: ArrayBuffer;
transports?: string[];
}
interface AssertionResult {
id?: ArrayBuffer;
rawId?: ArrayBuffer;
response: {
clientDataJSON: string;
authenticatorData: ArrayBuffer;
signature: string;
userHandle?: string;
};
}
interface ExpectedAssertionResult {
rpId?: string;
challenge: string;
origin: string;
factor: Factor;
publicKey: string;
prevCounter: number;
userHandle: string | null;
allowCredentials?: PublicKeyCredentialDescriptor[];
}
interface Fido2AssertionResult {
authnrData: Map<string, any>;
clientData: Map<string, any>;
expectations: Map<string, string>;
request: AttestationResult;
audit: Audit;
}
}