forked from passwordless-id/webauthn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
93 lines (77 loc) · 2.05 KB
/
types.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
// 'extern' is deprecated in favor of 'roaming' but kept for compatibility purposes
export type AuthType = 'auto' | 'local' | 'extern' | 'roaming' | 'both'
// TODO: although algo "-8" is currently only used optionally by a few security keys,
// it would not harm to support it for the sake of completeness
export type NumAlgo = -7 | -257
export type NamedAlgo = 'RS256' | 'ES256'
export interface AuthenticateOptions {
userVerification ?:UserVerificationRequirement
authenticatorType ?:AuthType
timeout ?:number
debug ?:boolean
}
export interface AuthenticationEncoded {
credentialId: string
//userHash: string, // unreliable, optional for authenticators
authenticatorData: string
clientData: string
signature: string
}
export interface AuthenticationParsed {
credentialId: string
//userHash: string, // unreliable, optional for authenticators
authenticator: AuthenticatorInfo
client: ClientInfo,
signature: string
}
export interface RegisterOptions extends AuthenticateOptions {
attestation?: boolean
}
export interface CredentialKey {
id: string
publicKey: string
algorithm: 'RS256' | 'ES256'
}
export interface RegistrationEncoded {
username: string
credential: CredentialKey
authenticatorData: string
clientData: string
attestationData?: string
}
export interface RegistrationParsed {
username: string
credential: {
id: string
publicKey: string
algorithm: 'RS256' | 'ES256'
}
authenticator: AuthenticatorInfo
client: ClientInfo
attestation?: any
}
export interface ClientInfo {
type: "webauthn.create" | "webauthn.get"
challenge: string
origin: string
crossOrigin: boolean
tokenBindingId?: {
id: string
status: string
}
extensions?: any
}
export interface AuthenticatorInfo {
rpIdHash: string,
flags: {
userPresent: boolean
userVerified: boolean
backupEligibility: boolean
backupState: boolean
attestedData: boolean
extensionsIncluded: boolean
}
counter: number
aaguid: string
name: string
}