-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
58 lines (47 loc) · 1.41 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
import net from "node:net";
import tls from "node:net";
import { EventEmitter } from "node:events";
declare const interceptor: NetInterceptor;
export default interceptor;
declare class NetInterceptor extends EventEmitter {
/**
* Start intercepting net/tls socket connections.
* No-op if already recording.
*/
start: () => this;
/**
* Stop intercepting net/tls socket connections.
* No-op if not recording.
*/
stop: () => this;
/**
* Subscribe to the "connect" event, emitted each time a net/tls socket connets
*/
addListener(event: "connect", listener: ConnectEventListener): this;
addListener(event: "connection", listener: ConnectionEventListener): this;
/**
* Unsubscribe from an event using the same listener function
* that was used when subscribing.
*/
removeListener(event: NetInterceptorEvents, listener: () => void): this;
/**
* Remove all listeners from all events
*/
removeAllListeners(): this;
/**
* Remove all listeners from an events
*/
removeAllListeners(event: NetInterceptorEvents): this;
}
type NetInterceptorEvents = "connect" | "connection";
type NetConnectOptions = net.TcpNetConnectOpts;
interface ConnectEventListener {
(
socket: net.Socket | tls.Socket,
options: NetConnectOptions,
bypass: () => void
): void;
}
interface ConnectionEventListener {
(socket: net.Socket | tls.Socket, options: NetConnectOptions): void;
}