nlcurl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/cli/args.d.ts +42 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +262 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +114 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +22 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +105 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cookies/jar.d.ts +41 -0
- package/dist/cookies/jar.d.ts.map +1 -0
- package/dist/cookies/jar.js +148 -0
- package/dist/cookies/jar.js.map +1 -0
- package/dist/cookies/parser.d.ts +24 -0
- package/dist/cookies/parser.d.ts.map +1 -0
- package/dist/cookies/parser.js +93 -0
- package/dist/cookies/parser.js.map +1 -0
- package/dist/core/client.d.ts +79 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +106 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/errors.d.ts +36 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +65 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/request.d.ts +96 -0
- package/dist/core/request.d.ts.map +1 -0
- package/dist/core/request.js +5 -0
- package/dist/core/request.js.map +1 -0
- package/dist/core/response.d.ts +48 -0
- package/dist/core/response.d.ts.map +1 -0
- package/dist/core/response.js +65 -0
- package/dist/core/response.js.map +1 -0
- package/dist/core/session.d.ts +60 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +305 -0
- package/dist/core/session.js.map +1 -0
- package/dist/fingerprints/akamai.d.ts +17 -0
- package/dist/fingerprints/akamai.d.ts.map +1 -0
- package/dist/fingerprints/akamai.js +30 -0
- package/dist/fingerprints/akamai.js.map +1 -0
- package/dist/fingerprints/database.d.ts +33 -0
- package/dist/fingerprints/database.d.ts.map +1 -0
- package/dist/fingerprints/database.js +68 -0
- package/dist/fingerprints/database.js.map +1 -0
- package/dist/fingerprints/extensions.d.ts +49 -0
- package/dist/fingerprints/extensions.d.ts.map +1 -0
- package/dist/fingerprints/extensions.js +178 -0
- package/dist/fingerprints/extensions.js.map +1 -0
- package/dist/fingerprints/ja3.d.ts +32 -0
- package/dist/fingerprints/ja3.d.ts.map +1 -0
- package/dist/fingerprints/ja3.js +64 -0
- package/dist/fingerprints/ja3.js.map +1 -0
- package/dist/fingerprints/profiles/chrome.d.ts +30 -0
- package/dist/fingerprints/profiles/chrome.d.ts.map +1 -0
- package/dist/fingerprints/profiles/chrome.js +202 -0
- package/dist/fingerprints/profiles/chrome.js.map +1 -0
- package/dist/fingerprints/profiles/edge.d.ts +16 -0
- package/dist/fingerprints/profiles/edge.d.ts.map +1 -0
- package/dist/fingerprints/profiles/edge.js +61 -0
- package/dist/fingerprints/profiles/edge.js.map +1 -0
- package/dist/fingerprints/profiles/firefox.d.ts +13 -0
- package/dist/fingerprints/profiles/firefox.d.ts.map +1 -0
- package/dist/fingerprints/profiles/firefox.js +160 -0
- package/dist/fingerprints/profiles/firefox.js.map +1 -0
- package/dist/fingerprints/profiles/safari.d.ts +16 -0
- package/dist/fingerprints/profiles/safari.d.ts.map +1 -0
- package/dist/fingerprints/profiles/safari.js +140 -0
- package/dist/fingerprints/profiles/safari.js.map +1 -0
- package/dist/fingerprints/profiles/tor.d.ts +14 -0
- package/dist/fingerprints/profiles/tor.d.ts.map +1 -0
- package/dist/fingerprints/profiles/tor.js +136 -0
- package/dist/fingerprints/profiles/tor.js.map +1 -0
- package/dist/fingerprints/types.d.ts +104 -0
- package/dist/fingerprints/types.d.ts.map +1 -0
- package/dist/fingerprints/types.js +9 -0
- package/dist/fingerprints/types.js.map +1 -0
- package/dist/http/h1/client.d.ts +21 -0
- package/dist/http/h1/client.d.ts.map +1 -0
- package/dist/http/h1/client.js +136 -0
- package/dist/http/h1/client.js.map +1 -0
- package/dist/http/h1/encoder.d.ts +11 -0
- package/dist/http/h1/encoder.d.ts.map +1 -0
- package/dist/http/h1/encoder.js +75 -0
- package/dist/http/h1/encoder.js.map +1 -0
- package/dist/http/h1/parser.d.ts +61 -0
- package/dist/http/h1/parser.d.ts.map +1 -0
- package/dist/http/h1/parser.js +258 -0
- package/dist/http/h1/parser.js.map +1 -0
- package/dist/http/h2/client.d.ts +48 -0
- package/dist/http/h2/client.d.ts.map +1 -0
- package/dist/http/h2/client.js +376 -0
- package/dist/http/h2/client.js.map +1 -0
- package/dist/http/h2/frames.d.ts +65 -0
- package/dist/http/h2/frames.d.ts.map +1 -0
- package/dist/http/h2/frames.js +184 -0
- package/dist/http/h2/frames.js.map +1 -0
- package/dist/http/h2/hpack.d.ts +27 -0
- package/dist/http/h2/hpack.d.ts.map +1 -0
- package/dist/http/h2/hpack.js +423 -0
- package/dist/http/h2/hpack.js.map +1 -0
- package/dist/http/negotiator.d.ts +36 -0
- package/dist/http/negotiator.d.ts.map +1 -0
- package/dist/http/negotiator.js +101 -0
- package/dist/http/negotiator.js.map +1 -0
- package/dist/http/pool.d.ts +63 -0
- package/dist/http/pool.d.ts.map +1 -0
- package/dist/http/pool.js +177 -0
- package/dist/http/pool.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/interceptor.d.ts +27 -0
- package/dist/middleware/interceptor.d.ts.map +1 -0
- package/dist/middleware/interceptor.js +35 -0
- package/dist/middleware/interceptor.js.map +1 -0
- package/dist/middleware/rate-limiter.d.ts +26 -0
- package/dist/middleware/rate-limiter.d.ts.map +1 -0
- package/dist/middleware/rate-limiter.js +59 -0
- package/dist/middleware/rate-limiter.js.map +1 -0
- package/dist/middleware/retry.d.ts +17 -0
- package/dist/middleware/retry.d.ts.map +1 -0
- package/dist/middleware/retry.js +64 -0
- package/dist/middleware/retry.js.map +1 -0
- package/dist/proxy/http-proxy.d.ts +23 -0
- package/dist/proxy/http-proxy.d.ts.map +1 -0
- package/dist/proxy/http-proxy.js +93 -0
- package/dist/proxy/http-proxy.js.map +1 -0
- package/dist/proxy/socks.d.ts +24 -0
- package/dist/proxy/socks.d.ts.map +1 -0
- package/dist/proxy/socks.js +196 -0
- package/dist/proxy/socks.js.map +1 -0
- package/dist/tls/constants.d.ts +142 -0
- package/dist/tls/constants.d.ts.map +1 -0
- package/dist/tls/constants.js +163 -0
- package/dist/tls/constants.js.map +1 -0
- package/dist/tls/node-engine.d.ts +22 -0
- package/dist/tls/node-engine.d.ts.map +1 -0
- package/dist/tls/node-engine.js +190 -0
- package/dist/tls/node-engine.js.map +1 -0
- package/dist/tls/stealth/client-hello.d.ts +38 -0
- package/dist/tls/stealth/client-hello.d.ts.map +1 -0
- package/dist/tls/stealth/client-hello.js +197 -0
- package/dist/tls/stealth/client-hello.js.map +1 -0
- package/dist/tls/stealth/engine.d.ts +16 -0
- package/dist/tls/stealth/engine.d.ts.map +1 -0
- package/dist/tls/stealth/engine.js +196 -0
- package/dist/tls/stealth/engine.js.map +1 -0
- package/dist/tls/stealth/handshake.d.ts +45 -0
- package/dist/tls/stealth/handshake.d.ts.map +1 -0
- package/dist/tls/stealth/handshake.js +403 -0
- package/dist/tls/stealth/handshake.js.map +1 -0
- package/dist/tls/stealth/key-schedule.d.ts +85 -0
- package/dist/tls/stealth/key-schedule.d.ts.map +1 -0
- package/dist/tls/stealth/key-schedule.js +141 -0
- package/dist/tls/stealth/key-schedule.js.map +1 -0
- package/dist/tls/stealth/record-layer.d.ts +74 -0
- package/dist/tls/stealth/record-layer.d.ts.map +1 -0
- package/dist/tls/stealth/record-layer.js +167 -0
- package/dist/tls/stealth/record-layer.js.map +1 -0
- package/dist/tls/types.d.ts +58 -0
- package/dist/tls/types.d.ts.map +1 -0
- package/dist/tls/types.js +6 -0
- package/dist/tls/types.js.map +1 -0
- package/dist/utils/buffer-reader.d.ts +32 -0
- package/dist/utils/buffer-reader.d.ts.map +1 -0
- package/dist/utils/buffer-reader.js +99 -0
- package/dist/utils/buffer-reader.js.map +1 -0
- package/dist/utils/buffer-writer.d.ts +35 -0
- package/dist/utils/buffer-writer.d.ts.map +1 -0
- package/dist/utils/buffer-writer.js +121 -0
- package/dist/utils/buffer-writer.js.map +1 -0
- package/dist/utils/encoding.d.ts +19 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +63 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +56 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/url.d.ts +22 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +56 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/ws/client.d.ts +63 -0
- package/dist/ws/client.d.ts.map +1 -0
- package/dist/ws/client.js +273 -0
- package/dist/ws/client.js.map +1 -0
- package/dist/ws/frame.d.ts +44 -0
- package/dist/ws/frame.d.ts.map +1 -0
- package/dist/ws/frame.js +146 -0
- package/dist/ws/frame.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP CONNECT proxy tunneling.
|
|
3
|
+
*
|
|
4
|
+
* Establishes a TCP tunnel through an HTTP proxy using the CONNECT
|
|
5
|
+
* method, then returns the raw socket for TLS negotiation.
|
|
6
|
+
*/
|
|
7
|
+
import * as net from 'node:net';
|
|
8
|
+
import { ProxyError } from '../core/errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Connect to a target host:port through an HTTP CONNECT proxy.
|
|
11
|
+
*
|
|
12
|
+
* Returns a raw TCP socket with the tunnel established, ready for
|
|
13
|
+
* TLS handshake.
|
|
14
|
+
*/
|
|
15
|
+
export async function httpProxyConnect(proxy, targetHost, targetPort) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
let settled = false;
|
|
18
|
+
const socket = net.createConnection({
|
|
19
|
+
host: proxy.host,
|
|
20
|
+
port: proxy.port,
|
|
21
|
+
});
|
|
22
|
+
const timeoutMs = proxy.timeout ?? 30_000;
|
|
23
|
+
let timer;
|
|
24
|
+
if (timeoutMs > 0) {
|
|
25
|
+
timer = setTimeout(() => {
|
|
26
|
+
if (!settled) {
|
|
27
|
+
settled = true;
|
|
28
|
+
socket.destroy();
|
|
29
|
+
reject(new ProxyError('Proxy connection timed out'));
|
|
30
|
+
}
|
|
31
|
+
}, timeoutMs);
|
|
32
|
+
}
|
|
33
|
+
socket.once('connect', () => {
|
|
34
|
+
// Send CONNECT request
|
|
35
|
+
let connectReq = `CONNECT ${targetHost}:${targetPort} HTTP/1.1\r\n`;
|
|
36
|
+
connectReq += `Host: ${targetHost}:${targetPort}\r\n`;
|
|
37
|
+
if (proxy.auth) {
|
|
38
|
+
const encoded = Buffer.from(proxy.auth).toString('base64');
|
|
39
|
+
connectReq += `Proxy-Authorization: Basic ${encoded}\r\n`;
|
|
40
|
+
}
|
|
41
|
+
connectReq += '\r\n';
|
|
42
|
+
socket.write(connectReq);
|
|
43
|
+
// Read proxy response
|
|
44
|
+
let buffer = '';
|
|
45
|
+
const onData = (chunk) => {
|
|
46
|
+
buffer += chunk.toString('latin1');
|
|
47
|
+
const headerEnd = buffer.indexOf('\r\n\r\n');
|
|
48
|
+
if (headerEnd >= 0) {
|
|
49
|
+
socket.removeListener('data', onData);
|
|
50
|
+
// Parse status line
|
|
51
|
+
const statusLine = buffer.substring(0, buffer.indexOf('\r\n'));
|
|
52
|
+
const match = /^HTTP\/\d\.\d\s+(\d{3})/.exec(statusLine);
|
|
53
|
+
if (!match) {
|
|
54
|
+
settled = true;
|
|
55
|
+
if (timer)
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
socket.destroy();
|
|
58
|
+
reject(new ProxyError(`Invalid proxy response: ${statusLine.substring(0, 100)}`));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const statusCode = parseInt(match[1], 10);
|
|
62
|
+
if (statusCode !== 200) {
|
|
63
|
+
settled = true;
|
|
64
|
+
if (timer)
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
socket.destroy();
|
|
67
|
+
reject(new ProxyError(`Proxy CONNECT failed with status ${statusCode}`));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
settled = true;
|
|
71
|
+
if (timer)
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
// Push any remaining data back
|
|
74
|
+
const remaining = buffer.substring(headerEnd + 4);
|
|
75
|
+
if (remaining.length > 0) {
|
|
76
|
+
socket.unshift(Buffer.from(remaining, 'latin1'));
|
|
77
|
+
}
|
|
78
|
+
resolve(socket);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
socket.on('data', onData);
|
|
82
|
+
});
|
|
83
|
+
socket.once('error', (err) => {
|
|
84
|
+
if (!settled) {
|
|
85
|
+
settled = true;
|
|
86
|
+
if (timer)
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
reject(new ProxyError(`Proxy connection failed: ${err.message}`));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=http-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-proxy.js","sourceRoot":"","sources":["../../src/proxy/http-proxy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAW/C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAuB,EACvB,UAAkB,EAClB,UAAkB;IAElB,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,IAAI,OAAO,GAAG,KAAK,C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AM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;oBACnD,CAAC;oBAED,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC;YAEF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;gBACf,IAAI,KAAK;oBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC/B,MAAM,CAAC,IAAI,UAAU,CAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOCKS proxy support (SOCKS4, SOCKS4a, SOCKS5).
|
|
3
|
+
*
|
|
4
|
+
* Implements the SOCKS protocol for tunneling TCP connections through
|
|
5
|
+
* SOCKS proxies. Zero dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import * as net from 'node:net';
|
|
8
|
+
export interface SocksProxyOptions {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
/** SOCKS version: 4, 4 (with 4a extension), or 5. */
|
|
12
|
+
version: 4 | 5;
|
|
13
|
+
/** Username for SOCKS5 authentication. */
|
|
14
|
+
username?: string;
|
|
15
|
+
/** Password for SOCKS5 authentication. */
|
|
16
|
+
password?: string;
|
|
17
|
+
/** Timeout in milliseconds. */
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Connect to a target through a SOCKS proxy.
|
|
22
|
+
*/
|
|
23
|
+
export declare function socksConnect(proxy: SocksProxyOptions, targetHost: string, targetPort: number): Promise<net.Socket>;
|
|
24
|
+
//# sourceMappingURL=socks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socks.d.ts","sourceRoot":"","sources":["../../src/proxy/socks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAGhC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,iBAAiB,EACxB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAcrB"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SOCKS proxy support (SOCKS4, SOCKS4a, SOCKS5).
|
|
3
|
+
*
|
|
4
|
+
* Implements the SOCKS protocol for tunneling TCP connections through
|
|
5
|
+
* SOCKS proxies. Zero dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import * as net from 'node:net';
|
|
8
|
+
import { ProxyError } from '../core/errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Connect to a target through a SOCKS proxy.
|
|
11
|
+
*/
|
|
12
|
+
export async function socksConnect(proxy, targetHost, targetPort) {
|
|
13
|
+
const socket = await tcpConnect(proxy.host, proxy.port, proxy.timeout);
|
|
14
|
+
try {
|
|
15
|
+
if (proxy.version === 5) {
|
|
16
|
+
await socks5Handshake(socket, proxy, targetHost, targetPort);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
await socks4Connect(socket, targetHost, targetPort);
|
|
20
|
+
}
|
|
21
|
+
return socket;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
socket.destroy();
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// ---- SOCKS5 ----
|
|
29
|
+
async function socks5Handshake(socket, proxy, host, port) {
|
|
30
|
+
// 1. Authentication negotiation
|
|
31
|
+
const hasAuth = proxy.username && proxy.password;
|
|
32
|
+
const methods = hasAuth ? Buffer.from([0x05, 0x02, 0x00, 0x02]) : Buffer.from([0x05, 0x01, 0x00]);
|
|
33
|
+
await socketWrite(socket, methods);
|
|
34
|
+
const authResponse = await socketRead(socket, 2);
|
|
35
|
+
if (authResponse[0] !== 0x05) {
|
|
36
|
+
throw new ProxyError('Invalid SOCKS5 response');
|
|
37
|
+
}
|
|
38
|
+
const selectedMethod = authResponse[1];
|
|
39
|
+
if (selectedMethod === 0x02 && hasAuth) {
|
|
40
|
+
// Username/password authentication (RFC 1929)
|
|
41
|
+
const user = Buffer.from(proxy.username, 'utf-8');
|
|
42
|
+
const pass = Buffer.from(proxy.password, 'utf-8');
|
|
43
|
+
const authReq = Buffer.alloc(3 + user.length + pass.length);
|
|
44
|
+
authReq[0] = 0x01; // version
|
|
45
|
+
authReq[1] = user.length;
|
|
46
|
+
user.copy(authReq, 2);
|
|
47
|
+
authReq[2 + user.length] = pass.length;
|
|
48
|
+
pass.copy(authReq, 3 + user.length);
|
|
49
|
+
await socketWrite(socket, authReq);
|
|
50
|
+
const authResult = await socketRead(socket, 2);
|
|
51
|
+
if (authResult[1] !== 0x00) {
|
|
52
|
+
throw new ProxyError('SOCKS5 authentication failed');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (selectedMethod === 0xff) {
|
|
56
|
+
throw new ProxyError('SOCKS5 proxy rejected all authentication methods');
|
|
57
|
+
}
|
|
58
|
+
// 2. Connection request
|
|
59
|
+
const hostBuf = Buffer.from(host, 'utf-8');
|
|
60
|
+
const req = Buffer.alloc(4 + 1 + hostBuf.length + 2);
|
|
61
|
+
req[0] = 0x05; // version
|
|
62
|
+
req[1] = 0x01; // CONNECT
|
|
63
|
+
req[2] = 0x00; // reserved
|
|
64
|
+
req[3] = 0x03; // DOMAINNAME
|
|
65
|
+
req[4] = hostBuf.length;
|
|
66
|
+
hostBuf.copy(req, 5);
|
|
67
|
+
req.writeUInt16BE(port, 5 + hostBuf.length);
|
|
68
|
+
await socketWrite(socket, req);
|
|
69
|
+
// 3. Read response
|
|
70
|
+
const resp = await socketRead(socket, 4);
|
|
71
|
+
if (resp[0] !== 0x05) {
|
|
72
|
+
throw new ProxyError('Invalid SOCKS5 response');
|
|
73
|
+
}
|
|
74
|
+
if (resp[1] !== 0x00) {
|
|
75
|
+
const codes = {
|
|
76
|
+
0x01: 'general SOCKS server failure',
|
|
77
|
+
0x02: 'connection not allowed by ruleset',
|
|
78
|
+
0x03: 'network unreachable',
|
|
79
|
+
0x04: 'host unreachable',
|
|
80
|
+
0x05: 'connection refused',
|
|
81
|
+
0x06: 'TTL expired',
|
|
82
|
+
0x07: 'command not supported',
|
|
83
|
+
0x08: 'address type not supported',
|
|
84
|
+
};
|
|
85
|
+
throw new ProxyError(`SOCKS5 connect failed: ${codes[resp[1]] ?? 'unknown error'}`);
|
|
86
|
+
}
|
|
87
|
+
// Read bound address (we don't use it, but must consume the bytes)
|
|
88
|
+
const addrType = resp[3];
|
|
89
|
+
if (addrType === 0x01) {
|
|
90
|
+
// IPv4
|
|
91
|
+
await socketRead(socket, 4 + 2);
|
|
92
|
+
}
|
|
93
|
+
else if (addrType === 0x03) {
|
|
94
|
+
// Domain
|
|
95
|
+
const lenBuf = await socketRead(socket, 1);
|
|
96
|
+
await socketRead(socket, lenBuf[0] + 2);
|
|
97
|
+
}
|
|
98
|
+
else if (addrType === 0x04) {
|
|
99
|
+
// IPv6
|
|
100
|
+
await socketRead(socket, 16 + 2);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ---- SOCKS4/4a ----
|
|
104
|
+
async function socks4Connect(socket, host, port) {
|
|
105
|
+
// SOCKS4a: use 0.0.0.1 as IP and append hostname
|
|
106
|
+
const hostBuf = Buffer.from(host + '\0', 'utf-8');
|
|
107
|
+
const req = Buffer.alloc(9 + hostBuf.length);
|
|
108
|
+
req[0] = 0x04; // version
|
|
109
|
+
req[1] = 0x01; // CONNECT
|
|
110
|
+
req.writeUInt16BE(port, 2);
|
|
111
|
+
// IP = 0.0.0.1 (triggers SOCKS4a)
|
|
112
|
+
req[4] = 0;
|
|
113
|
+
req[5] = 0;
|
|
114
|
+
req[6] = 0;
|
|
115
|
+
req[7] = 1;
|
|
116
|
+
req[8] = 0; // user ID null terminator
|
|
117
|
+
hostBuf.copy(req, 9);
|
|
118
|
+
await socketWrite(socket, req);
|
|
119
|
+
const resp = await socketRead(socket, 8);
|
|
120
|
+
if (resp[1] !== 0x5a) {
|
|
121
|
+
throw new ProxyError(`SOCKS4 connect failed: status 0x${resp[1].toString(16)}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// ---- Helpers ----
|
|
125
|
+
function tcpConnect(host, port, timeout) {
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
let settled = false;
|
|
128
|
+
const socket = net.createConnection({ host, port });
|
|
129
|
+
const timeoutMs = timeout ?? 30_000;
|
|
130
|
+
let timer;
|
|
131
|
+
if (timeoutMs > 0) {
|
|
132
|
+
timer = setTimeout(() => {
|
|
133
|
+
if (!settled) {
|
|
134
|
+
settled = true;
|
|
135
|
+
socket.destroy();
|
|
136
|
+
reject(new ProxyError('SOCKS proxy connection timed out'));
|
|
137
|
+
}
|
|
138
|
+
}, timeoutMs);
|
|
139
|
+
}
|
|
140
|
+
socket.once('connect', () => {
|
|
141
|
+
if (!settled) {
|
|
142
|
+
settled = true;
|
|
143
|
+
if (timer)
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
resolve(socket);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
socket.once('error', (err) => {
|
|
149
|
+
if (!settled) {
|
|
150
|
+
settled = true;
|
|
151
|
+
if (timer)
|
|
152
|
+
clearTimeout(timer);
|
|
153
|
+
reject(new ProxyError(`SOCKS proxy: ${err.message}`));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function socketWrite(socket, data) {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
socket.write(data, (err) => {
|
|
161
|
+
if (err)
|
|
162
|
+
reject(new ProxyError(err.message));
|
|
163
|
+
else
|
|
164
|
+
resolve();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function socketRead(socket, length) {
|
|
169
|
+
return new Promise((resolve, reject) => {
|
|
170
|
+
let buffer = Buffer.alloc(0);
|
|
171
|
+
let settled = false;
|
|
172
|
+
const onData = (chunk) => {
|
|
173
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
174
|
+
if (buffer.length >= length) {
|
|
175
|
+
settled = true;
|
|
176
|
+
socket.removeListener('data', onData);
|
|
177
|
+
socket.removeListener('error', onError);
|
|
178
|
+
const result = buffer.subarray(0, length);
|
|
179
|
+
if (buffer.length > length) {
|
|
180
|
+
socket.unshift(buffer.subarray(length));
|
|
181
|
+
}
|
|
182
|
+
resolve(result);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const onError = (err) => {
|
|
186
|
+
if (!settled) {
|
|
187
|
+
settled = true;
|
|
188
|
+
socket.removeListener('data', onData);
|
|
189
|
+
reject(new ProxyError(err.message));
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
socket.on('data', onData);
|
|
193
|
+
socket.once('error', onError);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=socks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socks.js","source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for TLS 1.3, RFC 5246 for TLS 1.2).
|
|
6
|
+
*/
|
|
7
|
+
export declare const RecordType: {
|
|
8
|
+
readonly CHANGE_CIPHER_SPEC: 20;
|
|
9
|
+
readonly ALERT: 21;
|
|
10
|
+
readonly HANDSHAKE: 22;
|
|
11
|
+
readonly APPLICATION_DATA: 23;
|
|
12
|
+
};
|
|
13
|
+
export declare const ProtocolVersion: {
|
|
14
|
+
readonly TLS_1_0: 769;
|
|
15
|
+
readonly TLS_1_1: 770;
|
|
16
|
+
readonly TLS_1_2: 771;
|
|
17
|
+
readonly TLS_1_3: 772;
|
|
18
|
+
};
|
|
19
|
+
export declare const HandshakeType: {
|
|
20
|
+
readonly CLIENT_HELLO: 1;
|
|
21
|
+
readonly SERVER_HELLO: 2;
|
|
22
|
+
readonly NEW_SESSION_TICKET: 4;
|
|
23
|
+
readonly END_OF_EARLY_DATA: 5;
|
|
24
|
+
readonly ENCRYPTED_EXTENSIONS: 8;
|
|
25
|
+
readonly CERTIFICATE: 11;
|
|
26
|
+
readonly CERTIFICATE_REQUEST: 13;
|
|
27
|
+
readonly CERTIFICATE_VERIFY: 15;
|
|
28
|
+
readonly FINISHED: 20;
|
|
29
|
+
readonly KEY_UPDATE: 24;
|
|
30
|
+
readonly MESSAGE_HASH: 254;
|
|
31
|
+
};
|
|
32
|
+
export declare const CipherSuite: {
|
|
33
|
+
readonly TLS_AES_128_GCM_SHA256: 4865;
|
|
34
|
+
readonly TLS_AES_256_GCM_SHA384: 4866;
|
|
35
|
+
readonly TLS_CHACHA20_POLY1305_SHA256: 4867;
|
|
36
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: 49195;
|
|
37
|
+
readonly TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: 49199;
|
|
38
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: 49196;
|
|
39
|
+
readonly TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: 49200;
|
|
40
|
+
readonly TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: 52393;
|
|
41
|
+
readonly TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: 52392;
|
|
42
|
+
readonly TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: 49171;
|
|
43
|
+
readonly TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 49172;
|
|
44
|
+
readonly TLS_RSA_WITH_AES_128_GCM_SHA256: 156;
|
|
45
|
+
readonly TLS_RSA_WITH_AES_256_GCM_SHA384: 157;
|
|
46
|
+
readonly TLS_RSA_WITH_AES_128_CBC_SHA: 47;
|
|
47
|
+
readonly TLS_RSA_WITH_AES_256_CBC_SHA: 53;
|
|
48
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: 49161;
|
|
49
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: 49162;
|
|
50
|
+
};
|
|
51
|
+
export declare const ExtensionType: {
|
|
52
|
+
readonly SERVER_NAME: 0;
|
|
53
|
+
readonly EC_POINT_FORMATS: 11;
|
|
54
|
+
readonly SUPPORTED_GROUPS: 10;
|
|
55
|
+
readonly SESSION_TICKET: 35;
|
|
56
|
+
readonly ENCRYPT_THEN_MAC: 22;
|
|
57
|
+
readonly EXTENDED_MASTER_SECRET: 23;
|
|
58
|
+
readonly SIGNATURE_ALGORITHMS: 13;
|
|
59
|
+
readonly SUPPORTED_VERSIONS: 43;
|
|
60
|
+
readonly PSK_KEY_EXCHANGE_MODES: 45;
|
|
61
|
+
readonly KEY_SHARE: 51;
|
|
62
|
+
readonly RENEGOTIATION_INFO: 65281;
|
|
63
|
+
readonly STATUS_REQUEST: 5;
|
|
64
|
+
readonly SIGNED_CERTIFICATE_TIMESTAMP: 18;
|
|
65
|
+
readonly APPLICATION_LAYER_PROTOCOL_NEGOTIATION: 16;
|
|
66
|
+
readonly COMPRESS_CERTIFICATE: 27;
|
|
67
|
+
readonly TOKEN_BINDING: 24;
|
|
68
|
+
readonly APPLICATION_SETTINGS: 17513;
|
|
69
|
+
readonly DELEGATED_CREDENTIALS: 34;
|
|
70
|
+
readonly RECORD_SIZE_LIMIT: 28;
|
|
71
|
+
readonly PADDING: 21;
|
|
72
|
+
readonly PRE_SHARED_KEY: 41;
|
|
73
|
+
readonly EARLY_DATA: 42;
|
|
74
|
+
readonly ENCRYPTED_CLIENT_HELLO: 65037;
|
|
75
|
+
readonly POST_HANDSHAKE_AUTH: 49;
|
|
76
|
+
};
|
|
77
|
+
export declare const NamedGroup: {
|
|
78
|
+
readonly X25519: 29;
|
|
79
|
+
readonly SECP256R1: 23;
|
|
80
|
+
readonly SECP384R1: 24;
|
|
81
|
+
readonly SECP521R1: 25;
|
|
82
|
+
readonly X448: 30;
|
|
83
|
+
readonly FFDHE2048: 256;
|
|
84
|
+
readonly FFDHE3072: 257;
|
|
85
|
+
readonly X25519_KYBER768: 25497;
|
|
86
|
+
readonly X25519_MLKEM768: 17800;
|
|
87
|
+
};
|
|
88
|
+
export declare const SignatureScheme: {
|
|
89
|
+
readonly ECDSA_SECP256R1_SHA256: 1027;
|
|
90
|
+
readonly ECDSA_SECP384R1_SHA384: 1283;
|
|
91
|
+
readonly ECDSA_SECP521R1_SHA512: 1539;
|
|
92
|
+
readonly RSA_PSS_RSAE_SHA256: 2052;
|
|
93
|
+
readonly RSA_PSS_RSAE_SHA384: 2053;
|
|
94
|
+
readonly RSA_PSS_RSAE_SHA512: 2054;
|
|
95
|
+
readonly RSA_PKCS1_SHA256: 1025;
|
|
96
|
+
readonly RSA_PKCS1_SHA384: 1281;
|
|
97
|
+
readonly RSA_PKCS1_SHA512: 1537;
|
|
98
|
+
readonly ED25519: 2055;
|
|
99
|
+
readonly ED448: 2056;
|
|
100
|
+
readonly RSA_PSS_PSS_SHA256: 2057;
|
|
101
|
+
readonly RSA_PSS_PSS_SHA384: 2058;
|
|
102
|
+
readonly RSA_PSS_PSS_SHA512: 2059;
|
|
103
|
+
readonly RSA_PKCS1_SHA1: 513;
|
|
104
|
+
readonly ECDSA_SHA1: 515;
|
|
105
|
+
};
|
|
106
|
+
export declare const ECPointFormat: {
|
|
107
|
+
readonly UNCOMPRESSED: 0;
|
|
108
|
+
};
|
|
109
|
+
export declare const PskKeyExchangeMode: {
|
|
110
|
+
readonly PSK_KE: 0;
|
|
111
|
+
readonly PSK_DHE_KE: 1;
|
|
112
|
+
};
|
|
113
|
+
export declare const CertCompressAlg: {
|
|
114
|
+
readonly ZLIB: 1;
|
|
115
|
+
readonly BROTLI: 2;
|
|
116
|
+
readonly ZSTD: 3;
|
|
117
|
+
};
|
|
118
|
+
export declare const GREASE_VALUES: readonly number[];
|
|
119
|
+
/** Pick a deterministic but varied GREASE value seeded by an index. */
|
|
120
|
+
export declare function greaseValue(seed: number): number;
|
|
121
|
+
export declare const AlertDescription: {
|
|
122
|
+
readonly CLOSE_NOTIFY: 0;
|
|
123
|
+
readonly UNEXPECTED_MESSAGE: 10;
|
|
124
|
+
readonly BAD_RECORD_MAC: 20;
|
|
125
|
+
readonly RECORD_OVERFLOW: 22;
|
|
126
|
+
readonly HANDSHAKE_FAILURE: 40;
|
|
127
|
+
readonly BAD_CERTIFICATE: 42;
|
|
128
|
+
readonly CERTIFICATE_EXPIRED: 45;
|
|
129
|
+
readonly CERTIFICATE_UNKNOWN: 46;
|
|
130
|
+
readonly ILLEGAL_PARAMETER: 47;
|
|
131
|
+
readonly UNKNOWN_CA: 48;
|
|
132
|
+
readonly DECODE_ERROR: 50;
|
|
133
|
+
readonly DECRYPT_ERROR: 51;
|
|
134
|
+
readonly PROTOCOL_VERSION: 70;
|
|
135
|
+
readonly INSUFFICIENT_SECURITY: 71;
|
|
136
|
+
readonly INTERNAL_ERROR: 80;
|
|
137
|
+
readonly NO_RENEGOTIATION: 100;
|
|
138
|
+
readonly MISSING_EXTENSION: 109;
|
|
139
|
+
readonly UNRECOGNIZED_NAME: 112;
|
|
140
|
+
readonly CERTIFICATE_REQUIRED: 116;
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/tls/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAIX,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAIX,eAAO,MAAM,aAAa;;;;;;;;;;;;CAYhB,CAAC;AAKX,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;CAuBd,CAAC;AAIX,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;CAyBhB,CAAC;AAIX,eAAO,MAAM,UAAU;;;;;;;;;;CAUb,CAAC;AAIX,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAiBlB,CAAC;AAIX,eAAO,MAAM,aAAa;;CAEhB,CAAC;AAIX,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAIX,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAIX,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAG1C,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAID,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;CAoBnB,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS protocol constants.
|
|
3
|
+
*
|
|
4
|
+
* Values taken directly from the IANA TLS registry and relevant RFCs
|
|
5
|
+
* (RFC 8446 for TLS 1.3, RFC 5246 for TLS 1.2).
|
|
6
|
+
*/
|
|
7
|
+
// ---- Record types ----
|
|
8
|
+
export const RecordType = {
|
|
9
|
+
CHANGE_CIPHER_SPEC: 20,
|
|
10
|
+
ALERT: 21,
|
|
11
|
+
HANDSHAKE: 22,
|
|
12
|
+
APPLICATION_DATA: 23,
|
|
13
|
+
};
|
|
14
|
+
// ---- Protocol versions ----
|
|
15
|
+
export const ProtocolVersion = {
|
|
16
|
+
TLS_1_0: 0x0301,
|
|
17
|
+
TLS_1_1: 0x0302,
|
|
18
|
+
TLS_1_2: 0x0303,
|
|
19
|
+
TLS_1_3: 0x0304,
|
|
20
|
+
};
|
|
21
|
+
// ---- Handshake message types ----
|
|
22
|
+
export const HandshakeType = {
|
|
23
|
+
CLIENT_HELLO: 1,
|
|
24
|
+
SERVER_HELLO: 2,
|
|
25
|
+
NEW_SESSION_TICKET: 4,
|
|
26
|
+
END_OF_EARLY_DATA: 5,
|
|
27
|
+
ENCRYPTED_EXTENSIONS: 8,
|
|
28
|
+
CERTIFICATE: 11,
|
|
29
|
+
CERTIFICATE_REQUEST: 13,
|
|
30
|
+
CERTIFICATE_VERIFY: 15,
|
|
31
|
+
FINISHED: 20,
|
|
32
|
+
KEY_UPDATE: 24,
|
|
33
|
+
MESSAGE_HASH: 254,
|
|
34
|
+
};
|
|
35
|
+
// ---- Cipher suites (hex values) ----
|
|
36
|
+
// Only suites used in modern browser fingerprints are listed.
|
|
37
|
+
export const CipherSuite = {
|
|
38
|
+
// TLS 1.3
|
|
39
|
+
TLS_AES_128_GCM_SHA256: 0x1301,
|
|
40
|
+
TLS_AES_256_GCM_SHA384: 0x1302,
|
|
41
|
+
TLS_CHACHA20_POLY1305_SHA256: 0x1303,
|
|
42
|
+
// TLS 1.2 (Chrome / Edge)
|
|
43
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: 0xc02b,
|
|
44
|
+
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: 0xc02f,
|
|
45
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: 0xc02c,
|
|
46
|
+
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: 0xc030,
|
|
47
|
+
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: 0xcca9,
|
|
48
|
+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: 0xcca8,
|
|
49
|
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: 0xc013,
|
|
50
|
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 0xc014,
|
|
51
|
+
TLS_RSA_WITH_AES_128_GCM_SHA256: 0x009c,
|
|
52
|
+
TLS_RSA_WITH_AES_256_GCM_SHA384: 0x009d,
|
|
53
|
+
TLS_RSA_WITH_AES_128_CBC_SHA: 0x002f,
|
|
54
|
+
TLS_RSA_WITH_AES_256_CBC_SHA: 0x0035,
|
|
55
|
+
// Firefox additional
|
|
56
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: 0xc009,
|
|
57
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: 0xc00a,
|
|
58
|
+
};
|
|
59
|
+
// ---- TLS Extensions ----
|
|
60
|
+
export const ExtensionType = {
|
|
61
|
+
SERVER_NAME: 0x0000,
|
|
62
|
+
EC_POINT_FORMATS: 0x000b,
|
|
63
|
+
SUPPORTED_GROUPS: 0x000a,
|
|
64
|
+
SESSION_TICKET: 0x0023,
|
|
65
|
+
ENCRYPT_THEN_MAC: 0x0016,
|
|
66
|
+
EXTENDED_MASTER_SECRET: 0x0017,
|
|
67
|
+
SIGNATURE_ALGORITHMS: 0x000d,
|
|
68
|
+
SUPPORTED_VERSIONS: 0x002b,
|
|
69
|
+
PSK_KEY_EXCHANGE_MODES: 0x002d,
|
|
70
|
+
KEY_SHARE: 0x0033,
|
|
71
|
+
RENEGOTIATION_INFO: 0xff01,
|
|
72
|
+
STATUS_REQUEST: 0x0005,
|
|
73
|
+
SIGNED_CERTIFICATE_TIMESTAMP: 0x0012,
|
|
74
|
+
APPLICATION_LAYER_PROTOCOL_NEGOTIATION: 0x0010,
|
|
75
|
+
COMPRESS_CERTIFICATE: 0x001b,
|
|
76
|
+
TOKEN_BINDING: 0x0018,
|
|
77
|
+
APPLICATION_SETTINGS: 0x4469, // ALPS
|
|
78
|
+
DELEGATED_CREDENTIALS: 0x0022,
|
|
79
|
+
RECORD_SIZE_LIMIT: 0x001c,
|
|
80
|
+
PADDING: 0x0015,
|
|
81
|
+
PRE_SHARED_KEY: 0x0029,
|
|
82
|
+
EARLY_DATA: 0x002a,
|
|
83
|
+
ENCRYPTED_CLIENT_HELLO: 0xfe0d,
|
|
84
|
+
POST_HANDSHAKE_AUTH: 0x0031,
|
|
85
|
+
};
|
|
86
|
+
// ---- Supported groups (named curves) ----
|
|
87
|
+
export const NamedGroup = {
|
|
88
|
+
X25519: 0x001d,
|
|
89
|
+
SECP256R1: 0x0017,
|
|
90
|
+
SECP384R1: 0x0018,
|
|
91
|
+
SECP521R1: 0x0019,
|
|
92
|
+
X448: 0x001e,
|
|
93
|
+
FFDHE2048: 0x0100,
|
|
94
|
+
FFDHE3072: 0x0101,
|
|
95
|
+
X25519_KYBER768: 0x6399,
|
|
96
|
+
X25519_MLKEM768: 0x4588,
|
|
97
|
+
};
|
|
98
|
+
// ---- Signature algorithms ----
|
|
99
|
+
export const SignatureScheme = {
|
|
100
|
+
ECDSA_SECP256R1_SHA256: 0x0403,
|
|
101
|
+
ECDSA_SECP384R1_SHA384: 0x0503,
|
|
102
|
+
ECDSA_SECP521R1_SHA512: 0x0603,
|
|
103
|
+
RSA_PSS_RSAE_SHA256: 0x0804,
|
|
104
|
+
RSA_PSS_RSAE_SHA384: 0x0805,
|
|
105
|
+
RSA_PSS_RSAE_SHA512: 0x0806,
|
|
106
|
+
RSA_PKCS1_SHA256: 0x0401,
|
|
107
|
+
RSA_PKCS1_SHA384: 0x0501,
|
|
108
|
+
RSA_PKCS1_SHA512: 0x0601,
|
|
109
|
+
ED25519: 0x0807,
|
|
110
|
+
ED448: 0x0808,
|
|
111
|
+
RSA_PSS_PSS_SHA256: 0x0809,
|
|
112
|
+
RSA_PSS_PSS_SHA384: 0x080a,
|
|
113
|
+
RSA_PSS_PSS_SHA512: 0x080b,
|
|
114
|
+
RSA_PKCS1_SHA1: 0x0201,
|
|
115
|
+
ECDSA_SHA1: 0x0203,
|
|
116
|
+
};
|
|
117
|
+
// ---- EC point formats ----
|
|
118
|
+
export const ECPointFormat = {
|
|
119
|
+
UNCOMPRESSED: 0,
|
|
120
|
+
};
|
|
121
|
+
// ---- PSK key exchange modes ----
|
|
122
|
+
export const PskKeyExchangeMode = {
|
|
123
|
+
PSK_KE: 0,
|
|
124
|
+
PSK_DHE_KE: 1,
|
|
125
|
+
};
|
|
126
|
+
// ---- Compress-certificate algorithms ----
|
|
127
|
+
export const CertCompressAlg = {
|
|
128
|
+
ZLIB: 1,
|
|
129
|
+
BROTLI: 2,
|
|
130
|
+
ZSTD: 3,
|
|
131
|
+
};
|
|
132
|
+
// ---- GREASE values (RFC 8701) ----
|
|
133
|
+
export const GREASE_VALUES = [
|
|
134
|
+
0x0a0a, 0x1a1a, 0x2a2a, 0x3a3a, 0x4a4a, 0x5a5a, 0x6a6a, 0x7a7a,
|
|
135
|
+
0x8a8a, 0x9a9a, 0xaaaa, 0xbaba, 0xcaca, 0xdada, 0xeaea, 0xfafa,
|
|
136
|
+
];
|
|
137
|
+
/** Pick a deterministic but varied GREASE value seeded by an index. */
|
|
138
|
+
export function greaseValue(seed) {
|
|
139
|
+
return GREASE_VALUES[seed % GREASE_VALUES.length];
|
|
140
|
+
}
|
|
141
|
+
// ---- Alert descriptions ----
|
|
142
|
+
export const AlertDescription = {
|
|
143
|
+
CLOSE_NOTIFY: 0,
|
|
144
|
+
UNEXPECTED_MESSAGE: 10,
|
|
145
|
+
BAD_RECORD_MAC: 20,
|
|
146
|
+
RECORD_OVERFLOW: 22,
|
|
147
|
+
HANDSHAKE_FAILURE: 40,
|
|
148
|
+
BAD_CERTIFICATE: 42,
|
|
149
|
+
CERTIFICATE_EXPIRED: 45,
|
|
150
|
+
CERTIFICATE_UNKNOWN: 46,
|
|
151
|
+
ILLEGAL_PARAMETER: 47,
|
|
152
|
+
UNKNOWN_CA: 48,
|
|
153
|
+
DECODE_ERROR: 50,
|
|
154
|
+
DECRYPT_ERROR: 51,
|
|
155
|
+
PROTOCOL_VERSION: 70,
|
|
156
|
+
INSUFFICIENT_SECURITY: 71,
|
|
157
|
+
INTERNAL_ERROR: 80,
|
|
158
|
+
NO_RENEGOTIATION: 100,
|
|
159
|
+
MISSING_EXTENSION: 109,
|
|
160
|
+
UNRECOGNIZED_NAME: 112,
|
|
161
|
+
CERTIFICATE_REQUIRED: 116,
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/tls/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yBAAyB;AAEzB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,kBAAkB,EAAE,EAAE;IACtB,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;IACb,gBAAgB,EAAE,EAAE;CACZ,CAAC;AAEX,8BAA8B;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;CACP,CAAC;AAEX,oCAAoC;AAEpC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,kBAAkB,EAAE,CAAC;IACrB,iBAAiB,EAAE,CAAC;IACpB,oBAAoB,EAAE,CAAC;IACvB,WAAW,EAAE,EAAE;IACf,mBAAmB,EAAE,EAAE;IACvB,kBAAkB,EAAE,EAAE;IACtB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,GAAG;CACT,CAAC;AAEX,uCAAuC;AACvC,8DAA8D;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU;IACV,sBAAsB,EAAE,MAAM;IAC9B,sBAAsB,EAAE,MAAM;IAC9B,4BAA4B,E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AAM,EAAE,MAAM;CAC/D,CAAC;AAEF,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,MAAM,CAAE,CAAC;AACrD,CAAC;AAED,+BAA+B;AAE/B,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY,EAAE,CAAC;IACf,kBAAkB,EAAE,EAAE;IACtB,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,EAAE;IACrB,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,mBAAmB,EAAE,EAAE;IACvB,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;IACjB,gBAAgB,EAAE,EAAE;IACpB,qBAAqB,EAAE,EAAE;IACzB,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,GAAG;IACrB,iBAAiB,EAAE,GAAG;IACtB,iBAAiB,EAAE,GAAG;IACtB,oBAAoB,EAAE,GAAG;CACjB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard TLS engine.
|
|
3
|
+
*
|
|
4
|
+
* Uses Node.js built-in `node:tls` module with maximum configuration
|
|
5
|
+
* from browser profiles. This engine controls:
|
|
6
|
+
* - Cipher suite order (via the `ciphers` option)
|
|
7
|
+
* - Named groups / ECDH curves (via `ecdhCurve`)
|
|
8
|
+
* - Signature algorithms (via `sigalgs`)
|
|
9
|
+
* - ALPN protocols
|
|
10
|
+
* - Min/max protocol version
|
|
11
|
+
* - Session tickets, SNI
|
|
12
|
+
*
|
|
13
|
+
* Limitations: `node:tls` does not expose extension ordering, GREASE
|
|
14
|
+
* injection, or padding extension control. For full JA3 fingerprint
|
|
15
|
+
* matching use the Stealth engine instead.
|
|
16
|
+
*/
|
|
17
|
+
import type { ITLSEngine, TLSConnectOptions, TLSSocket } from './types.js';
|
|
18
|
+
import type { BrowserProfile } from '../fingerprints/types.js';
|
|
19
|
+
export declare class NodeTLSEngine implements ITLSEngine {
|
|
20
|
+
connect(options: TLSConnectOptions, profile?: BrowserProfile): Promise<TLSSocket>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=node-engine.d.ts.map
|