-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
230 lines (201 loc) · 5.76 KB
/
index.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardreaderstatein
*/
declare interface SmartCardReaderStateIn {
readerName: string
currentState: SmartCardReaderStateFlagsIn
currentCount?: number
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcardreaderstateflagsin-dictionary
*/
declare interface SmartCardReaderStateFlagsIn {
unaware?: boolean
ignore?: boolean
unavailable?: boolean
empty?: boolean
present?: boolean
exclusive?: boolean
inuse?: boolean
mute?: boolean
unpowered?: boolean
}
/**
* The actual state of a smart card reader.
*
* @see https://wicg.github.io/web-smart-card/#dom-smartcardreaderstateout
*/
declare interface SmartCardReaderStateOut {
readerName: string
eventState: SmartCardReaderStateFlagsOut
eventCount: number
answerToReset?: ArrayBuffer
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcardreaderstateflagsout-dictionary
*/
declare interface SmartCardReaderStateFlagsOut {
ignore?: boolean
changed?: boolean
unavailable?: boolean
unknown?: boolean
empty?: boolean
present?: boolean
exclusive?: boolean
inuse?: boolean
mute?: boolean
unpowered?: boolean
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcardcontext-interface
*/
declare class SmartCardContext {
listReaders(): Promise<string[]>
getStatusChange(
readerStates: SmartCardReaderStateIn[],
options?: SmartCardGetStatusChangeOptions,
): Promise<SmartCardReaderStateOut[]>
connect(
readerName: string,
accessMode: SmartCardAccessMode,
options?: SmartCardConnectOptions,
): Promise<SmartCardConnectResult>
}
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardgetstatuschangeoptions
*/
declare interface SmartCardGetStatusChangeOptions {
timeout?: DOMHighResTimeStamp
signal?: AbortSignal
}
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardconnectresult
*/
declare interface SmartCardConnectResult {
connection: SmartCardConnection
activeProtocol?: SmartCardProtocol
}
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcarddisposition
*/
declare type SmartCardDisposition = 'leave' | 'reset' | 'unpower' | 'eject'
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardtransactionoptions
*/
declare interface SmartCardTransactionOptions {
signal?: AbortSignal
}
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardtransmitoptions
*/
declare interface SmartCardTransmitOptions {
protocol?: SmartCardProtocol
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcardconnection-interface
*/
declare class SmartCardConnection {
disconnect(disposition?: SmartCardDisposition): Promise<void>
transmit(sendBuffer: BufferSource, options?: SmartCardTransmitOptions): Promise<ArrayBuffer>
startTransaction(transaction: SmartCardTransactionCallback, options?: SmartCardTransactionOptions): Promise<void>
status(): Promise<SmartCardConnectionStatus>
control(controlCode: number, data: BufferSource): Promise<ArrayBuffer>
getAttribute(tag: number): Promise<ArrayBuffer>
setAttribute(tag: number, value: BufferSource): Promise<void>
}
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardtransactioncallback
*/
declare type SmartCardTransactionCallback = () => Promise<SmartCardDisposition | void>
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardprotocol
*/
declare type SmartCardProtocol = 'raw' | 't0' | 't1'
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardaccessmode
*/
declare type SmartCardAccessMode = 'shared' | 'exclusive' | 'direct'
/**
* @see https://wicg.github.io/web-smart-card/#smartcardconnectionstatus-dictionary
*/
declare interface SmartCardConnectionStatus {
readerName: string
state: SmartCardConnectionState
answerToReset?: ArrayBuffer
}
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardconnectionstate
*/
declare type SmartCardConnectionState =
| 'absent'
| 'present'
| 'swallowed'
| 'powered'
| 'negotiable'
| 't0'
| 't1'
| 'raw'
/**
* @see https://wicg.github.io/web-smart-card/#dom-smartcardconnectoptions
*/
declare interface SmartCardConnectOptions {
preferredProtocols: SmartCardProtocol[]
}
/**
* Methods on this interface complete asynchronously, queuing work on the smart card task source.
*
* @see https://wicg.github.io/web-smart-card/#smartcardresourcemanager-interface
*/
declare class SmartCardResourceManager {
/**
* Requests a PC/SC context from the platform's PC/SC stack.
*/
establishContext(): Promise<SmartCardContext>
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcarderror-interface
*/
declare class SmartCardError extends DOMException {
constructor()
constructor(options: SmartCardErrorOptions)
constructor(message: string, options: SmartCardErrorOptions)
readonly responseCode: SmartCardResponseCode
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcarderroroptions-dictionary
*/
declare interface SmartCardErrorOptions {
responseCode: SmartCardResponseCode
}
/**
* @see https://wicg.github.io/web-smart-card/#smartcardresponsecode-enum
*/
declare type SmartCardResponseCode =
| 'no-service'
| 'no-smartcard'
| 'not-ready'
| 'not-transacted'
| 'proto-mismatch'
| 'reader-unavailable'
| 'removed-card'
| 'reset-card'
| 'server-too-busy'
| 'sharing-violation'
| 'system-cancelled'
| 'unknown-reader'
| 'unpowered-card'
| 'unresponsive-card'
| 'unsupported-card'
| 'unsupported-feature'
declare interface Navigator {
/**
* @see https://wicg.github.io/web-smart-card/#extensions-to-the-navigator-interface
*/
readonly smartCard: SmartCardResourceManager
}
declare interface WorkerNavigator {
/**
* @see https://wicg.github.io/web-smart-card/#extensions-to-the-workernavigator-interface
*/
readonly smartCard: SmartCardResourceManager
}