forked from pokusew/node-pcsclite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
111 lines (85 loc) · 2.48 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
import { EventEmitter } from "events";
type ConnectOptions = {
share_mode?: number;
protocol?: number;
};
type Status = {
atr?: Buffer;
state: number;
};
type AnyOrNothing = any | undefined | null;
interface PCSCLite extends EventEmitter {
on(type: "error", listener: (error: any) => void): this;
once(type: "error", listener: (error: any) => void): this;
on(type: "reader", listener: (reader: CardReader) => void): this;
once(type: "reader", listener: (reader: CardReader) => void): this;
close(): void;
}
interface CardReader extends EventEmitter {
// Share Mode
SCARD_SHARE_SHARED: number;
SCARD_SHARE_EXCLUSIVE: number;
SCARD_SHARE_DIRECT: number;
// Protocol
SCARD_PROTOCOL_T0: number;
SCARD_PROTOCOL_T1: number;
SCARD_PROTOCOL_RAW: number;
// State
SCARD_STATE_UNAWARE: number;
SCARD_STATE_IGNORE: number;
SCARD_STATE_CHANGED: number;
SCARD_STATE_UNKNOWN: number;
SCARD_STATE_UNAVAILABLE: number;
SCARD_STATE_EMPTY: number;
SCARD_STATE_PRESENT: number;
SCARD_STATE_ATRMATCH: number;
SCARD_STATE_EXCLUSIVE: number;
SCARD_STATE_INUSE: number;
SCARD_STATE_MUTE: number;
// Disconnect disposition
SCARD_LEAVE_CARD: number;
SCARD_RESET_CARD: number;
SCARD_UNPOWER_CARD: number;
SCARD_EJECT_CARD: number;
name: string;
state: number;
connected: boolean;
on(type: "error", listener: (this: CardReader, error: any) => void): this;
once(type: "error", listener: (this: CardReader, error: any) => void): this;
on(type: "end", listener: (this: CardReader) => void): this;
once(type: "end", listener: (this: CardReader) => void): this;
on(
type: "status",
listener: (this: CardReader, status: Status) => void
): this;
once(
type: "status",
listener: (this: CardReader, status: Status) => void
): this;
SCARD_CTL_CODE(code: number): number;
get_status(
cb: (err: AnyOrNothing, state: number, atr?: Buffer) => void
): void;
connect(callback: (err: AnyOrNothing, protocol: number) => void): void;
connect(
options: ConnectOptions,
callback: (err: AnyOrNothing, protocol: number) => void
): void;
disconnect(callback: (err: AnyOrNothing) => void): void;
disconnect(disposition: number, callback: (err: AnyOrNothing) => void): void;
transmit(
data: Buffer,
res_len: number,
protocol: number,
cb: (err: AnyOrNothing, response: Buffer) => void
): void;
control(
data: Buffer,
control_code: number,
res_len: number,
cb: (err: AnyOrNothing, response: Buffer) => void
): void;
close(): void;
}
declare function pcsc(): PCSCLite;
export = pcsc;