forked from moll/node-mitm
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
49 lines (40 loc) · 1.21 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
/**
* Based on code by @alejo90
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1d58999ab82c14bed518d0aec2ab2a5343e9f83b/types/mitm/index.d.ts
* @license MIT
*/
import * as http from "http";
import * as net from "net";
export default class Mitm {
disable(): void;
enable(): void;
on(event: Event, callback: Callback): void;
on(event: "connect", callback: SocketConnectCallback): void;
on(event: "connection", callback: SocketConnectionCallback): void;
on(event: "request", callback: HttpCallback): void;
}
interface SocketOptions {
port: number;
host?: string | undefined;
localAddress?: string | undefined;
localPort?: string | undefined;
family?: number | undefined;
allowHalfOpen?: boolean | undefined;
}
interface BypassableSocket extends net.Socket {
bypass(): void;
}
type SocketConnectCallback = (
socket: BypassableSocket,
opts: SocketOptions
) => void;
type SocketConnectionCallback = (
socket: net.Socket,
opts: SocketOptions
) => void;
type HttpCallback = (
request: http.IncomingMessage,
response: http.ServerResponse
) => void;
type Event = "connect" | "connection" | "request";
type Callback = SocketConnectCallback | SocketConnectionCallback | HttpCallback;