nlcurl 0.1.0 → 0.2.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/README.md +5 -13
- package/dist/cli/args.d.ts +37 -5
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -17
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +25 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/output.d.ts +24 -7
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +24 -12
- package/dist/cli/output.js.map +1 -1
- package/dist/cookies/jar.d.ts +45 -13
- package/dist/cookies/jar.d.ts.map +1 -1
- package/dist/cookies/jar.js +88 -29
- package/dist/cookies/jar.js.map +1 -1
- package/dist/cookies/parser.d.ts +25 -3
- package/dist/cookies/parser.d.ts.map +1 -1
- package/dist/cookies/parser.js +12 -7
- package/dist/cookies/parser.js.map +1 -1
- package/dist/core/client.d.ts +49 -33
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +64 -38
- package/dist/core/client.js.map +1 -1
- package/dist/core/errors.d.ts +94 -6
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +95 -6
- package/dist/core/errors.js.map +1 -1
- package/dist/core/request.d.ts +96 -30
- package/dist/core/request.d.ts.map +1 -1
- package/dist/core/request.js +0 -3
- package/dist/core/request.js.map +1 -1
- package/dist/core/response.d.ts +92 -8
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +92 -7
- package/dist/core/response.js.map +1 -1
- package/dist/core/session.d.ts +109 -14
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +124 -46
- package/dist/core/session.js.map +1 -1
- package/dist/fingerprints/akamai.d.ts +11 -11
- package/dist/fingerprints/akamai.d.ts.map +1 -1
- package/dist/fingerprints/akamai.js +10 -14
- package/dist/fingerprints/akamai.js.map +1 -1
- package/dist/fingerprints/database.d.ts +14 -15
- package/dist/fingerprints/database.d.ts.map +1 -1
- package/dist/fingerprints/database.js +14 -19
- package/dist/fingerprints/database.js.map +1 -1
- package/dist/fingerprints/extensions.d.ts +121 -27
- package/dist/fingerprints/extensions.d.ts.map +1 -1
- package/dist/fingerprints/extensions.js +132 -49
- package/dist/fingerprints/extensions.js.map +1 -1
- package/dist/fingerprints/ja3.d.ts +34 -18
- package/dist/fingerprints/ja3.d.ts.map +1 -1
- package/dist/fingerprints/ja3.js +34 -18
- package/dist/fingerprints/ja3.js.map +1 -1
- package/dist/fingerprints/profiles/chrome.d.ts +21 -10
- package/dist/fingerprints/profiles/chrome.d.ts.map +1 -1
- package/dist/fingerprints/profiles/chrome.js +25 -22
- package/dist/fingerprints/profiles/chrome.js.map +1 -1
- package/dist/fingerprints/profiles/edge.d.ts +10 -7
- package/dist/fingerprints/profiles/edge.d.ts.map +1 -1
- package/dist/fingerprints/profiles/edge.js +10 -10
- package/dist/fingerprints/profiles/edge.js.map +1 -1
- package/dist/fingerprints/profiles/firefox.d.ts +11 -3
- package/dist/fingerprints/profiles/firefox.d.ts.map +1 -1
- package/dist/fingerprints/profiles/firefox.js +15 -14
- package/dist/fingerprints/profiles/firefox.js.map +1 -1
- package/dist/fingerprints/profiles/safari.d.ts +14 -3
- package/dist/fingerprints/profiles/safari.d.ts.map +1 -1
- package/dist/fingerprints/profiles/safari.js +16 -13
- package/dist/fingerprints/profiles/safari.js.map +1 -1
- package/dist/fingerprints/profiles/tor.d.ts +8 -7
- package/dist/fingerprints/profiles/tor.d.ts.map +1 -1
- package/dist/fingerprints/profiles/tor.js +8 -14
- package/dist/fingerprints/profiles/tor.js.map +1 -1
- package/dist/fingerprints/types.d.ts +70 -47
- package/dist/fingerprints/types.d.ts.map +1 -1
- package/dist/fingerprints/types.js +0 -7
- package/dist/fingerprints/types.js.map +1 -1
- package/dist/http/h1/client.d.ts +30 -9
- package/dist/http/h1/client.d.ts.map +1 -1
- package/dist/http/h1/client.js +152 -15
- package/dist/http/h1/client.js.map +1 -1
- package/dist/http/h1/encoder.d.ts +9 -6
- package/dist/http/h1/encoder.d.ts.map +1 -1
- package/dist/http/h1/encoder.js +8 -12
- package/dist/http/h1/encoder.js.map +1 -1
- package/dist/http/h1/parser.d.ts +68 -14
- package/dist/http/h1/parser.d.ts.map +1 -1
- package/dist/http/h1/parser.js +92 -37
- package/dist/http/h1/parser.js.map +1 -1
- package/dist/http/h2/client.d.ts +81 -14
- package/dist/http/h2/client.d.ts.map +1 -1
- package/dist/http/h2/client.js +465 -63
- package/dist/http/h2/client.js.map +1 -1
- package/dist/http/h2/frames.d.ts +103 -6
- package/dist/http/h2/frames.d.ts.map +1 -1
- package/dist/http/h2/frames.js +96 -17
- package/dist/http/h2/frames.js.map +1 -1
- package/dist/http/h2/hpack.d.ts +30 -5
- package/dist/http/h2/hpack.d.ts.map +1 -1
- package/dist/http/h2/hpack.js +39 -35
- package/dist/http/h2/hpack.js.map +1 -1
- package/dist/http/negotiator.d.ts +35 -12
- package/dist/http/negotiator.d.ts.map +1 -1
- package/dist/http/negotiator.js +89 -24
- package/dist/http/negotiator.js.map +1 -1
- package/dist/http/pool.d.ts +66 -17
- package/dist/http/pool.d.ts.map +1 -1
- package/dist/http/pool.js +47 -20
- package/dist/http/pool.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +1 -1
- package/dist/middleware/interceptor.d.ts +40 -8
- package/dist/middleware/interceptor.d.ts.map +1 -1
- package/dist/middleware/interceptor.js +28 -6
- package/dist/middleware/interceptor.js.map +1 -1
- package/dist/middleware/rate-limiter.d.ts +18 -5
- package/dist/middleware/rate-limiter.d.ts.map +1 -1
- package/dist/middleware/rate-limiter.js +12 -7
- package/dist/middleware/rate-limiter.js.map +1 -1
- package/dist/middleware/retry.d.ts +17 -5
- package/dist/middleware/retry.d.ts.map +1 -1
- package/dist/middleware/retry.js +13 -11
- package/dist/middleware/retry.js.map +1 -1
- package/dist/proxy/http-proxy.d.ts +17 -9
- package/dist/proxy/http-proxy.d.ts.map +1 -1
- package/dist/proxy/http-proxy.js +9 -13
- package/dist/proxy/http-proxy.js.map +1 -1
- package/dist/proxy/socks.d.ts +20 -9
- package/dist/proxy/socks.d.ts.map +1 -1
- package/dist/proxy/socks.js +20 -31
- package/dist/proxy/socks.js.map +1 -1
- package/dist/tls/constants.d.ts +74 -4
- package/dist/tls/constants.d.ts.map +1 -1
- package/dist/tls/constants.js +75 -21
- package/dist/tls/constants.js.map +1 -1
- package/dist/tls/node-engine.d.ts +17 -16
- package/dist/tls/node-engine.d.ts.map +1 -1
- package/dist/tls/node-engine.js +20 -27
- package/dist/tls/node-engine.js.map +1 -1
- package/dist/tls/stealth/client-hello.d.ts +32 -16
- package/dist/tls/stealth/client-hello.d.ts.map +1 -1
- package/dist/tls/stealth/client-hello.js +13 -37
- package/dist/tls/stealth/client-hello.js.map +1 -1
- package/dist/tls/stealth/engine.d.ts +18 -10
- package/dist/tls/stealth/engine.d.ts.map +1 -1
- package/dist/tls/stealth/engine.js +18 -24
- package/dist/tls/stealth/engine.js.map +1 -1
- package/dist/tls/stealth/handshake.d.ts +31 -17
- package/dist/tls/stealth/handshake.d.ts.map +1 -1
- package/dist/tls/stealth/handshake.js +173 -74
- package/dist/tls/stealth/handshake.js.map +1 -1
- package/dist/tls/stealth/key-schedule.d.ts +89 -32
- package/dist/tls/stealth/key-schedule.d.ts.map +1 -1
- package/dist/tls/stealth/key-schedule.js +62 -42
- package/dist/tls/stealth/key-schedule.js.map +1 -1
- package/dist/tls/stealth/record-layer.d.ts +76 -25
- package/dist/tls/stealth/record-layer.d.ts.map +1 -1
- package/dist/tls/stealth/record-layer.js +66 -36
- package/dist/tls/stealth/record-layer.js.map +1 -1
- package/dist/tls/types.d.ts +33 -25
- package/dist/tls/types.d.ts.map +1 -1
- package/dist/tls/types.js +0 -4
- package/dist/tls/types.js.map +1 -1
- package/dist/utils/buffer-reader.d.ts +99 -7
- package/dist/utils/buffer-reader.d.ts.map +1 -1
- package/dist/utils/buffer-reader.js +99 -7
- package/dist/utils/buffer-reader.js.map +1 -1
- package/dist/utils/buffer-writer.d.ts +99 -10
- package/dist/utils/buffer-writer.d.ts.map +1 -1
- package/dist/utils/buffer-writer.js +101 -12
- package/dist/utils/buffer-writer.js.map +1 -1
- package/dist/utils/encoding.d.ts +33 -8
- package/dist/utils/encoding.d.ts.map +1 -1
- package/dist/utils/encoding.js +58 -13
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/logger.d.ts +61 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +52 -4
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/url.d.ts +47 -7
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +47 -7
- package/dist/utils/url.js.map +1 -1
- package/dist/ws/client.d.ts +59 -15
- package/dist/ws/client.d.ts.map +1 -1
- package/dist/ws/client.js +34 -27
- package/dist/ws/client.js.map +1 -1
- package/dist/ws/frame.d.ts +43 -9
- package/dist/ws/frame.d.ts.map +1 -1
- package/dist/ws/frame.js +35 -19
- package/dist/ws/frame.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stealth TLS engine.
|
|
3
|
-
*
|
|
4
|
-
* Implements ITLSEngine using raw TCP sockets and manual TLS 1.3
|
|
5
|
-
* handshake construction. This gives 100% control over the
|
|
6
|
-
* ClientHello bytes, enabling perfect JA3 fingerprint matching.
|
|
7
|
-
*
|
|
8
|
-
* After the handshake completes, wraps the raw socket in a Duplex
|
|
9
|
-
* stream that transparently encrypts/decrypts application data.
|
|
10
|
-
*/
|
|
11
1
|
import type { ITLSEngine, TLSConnectOptions, TLSSocket } from '../types.js';
|
|
12
2
|
import type { BrowserProfile } from '../../fingerprints/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* TLS engine that performs a fully custom TLS 1.3 handshake at the byte
|
|
5
|
+
* level, producing ClientHello messages that exactly match the fingerprint
|
|
6
|
+
* of the given browser profile — including GREASE values, extension ordering,
|
|
7
|
+
* key share groups, and cipher suite ordering. Unlike {@link NodeTLSEngine},
|
|
8
|
+
* this engine bypasses Node.js’s native `tls` module entirely.
|
|
9
|
+
*/
|
|
13
10
|
export declare class StealthTLSEngine implements ITLSEngine {
|
|
11
|
+
/**
|
|
12
|
+
* Establishes a TLS 1.3 connection using the custom stealth handshake engine.
|
|
13
|
+
* Opens a raw TCP socket (or reuses a pre-connected socket from `options.socket`),
|
|
14
|
+
* performs the full TLS 1.3 handshake matching `profile`, and wraps the socket
|
|
15
|
+
* in an encrypted duplex stream.
|
|
16
|
+
*
|
|
17
|
+
* @param {TLSConnectOptions} options - Connection parameters (host, port, SNI, etc.).
|
|
18
|
+
* @param {BrowserProfile} [profile] - Browser profile to impersonate; falls back to `DEFAULT_PROFILE`.
|
|
19
|
+
* @returns {Promise<TLSSocket>} Resolves with the encrypted duplex stream.
|
|
20
|
+
* @throws {TLSError} If the handshake fails, times out, or the connection is rejected.
|
|
21
|
+
*/
|
|
14
22
|
connect(options: TLSConnectOptions, profile?: BrowserProfile): Promise<TLSSocket>;
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/tls/stealth/engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/tls/stealth/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAqB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AA8IlE;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,UAAU;IACjD;;;;;;;;;;OAUG;IACG,OAAO,CACX,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC;CAwBtB"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stealth TLS engine.
|
|
3
|
-
*
|
|
4
|
-
* Implements ITLSEngine using raw TCP sockets and manual TLS 1.3
|
|
5
|
-
* handshake construction. This gives 100% control over the
|
|
6
|
-
* ClientHello bytes, enabling perfect JA3 fingerprint matching.
|
|
7
|
-
*
|
|
8
|
-
* After the handshake completes, wraps the raw socket in a Duplex
|
|
9
|
-
* stream that transparently encrypts/decrypts application data.
|
|
10
|
-
*/
|
|
11
1
|
import * as net from 'node:net';
|
|
12
2
|
import { Duplex } from 'node:stream';
|
|
13
3
|
import { TLSError } from '../../core/errors.js';
|
|
@@ -15,10 +5,6 @@ import { performHandshake } from './handshake.js';
|
|
|
15
5
|
import { wrapEncryptedRecord, unwrapEncryptedRecord, readRecord, } from './record-layer.js';
|
|
16
6
|
import { RecordType } from '../constants.js';
|
|
17
7
|
import { DEFAULT_PROFILE } from '../../fingerprints/database.js';
|
|
18
|
-
/**
|
|
19
|
-
* A Duplex stream that wraps encrypted TLS 1.3 application data
|
|
20
|
-
* over a raw TCP socket.
|
|
21
|
-
*/
|
|
22
8
|
class StealthTLSStream extends Duplex {
|
|
23
9
|
rawSocket;
|
|
24
10
|
aead;
|
|
@@ -44,7 +30,6 @@ class StealthTLSStream extends Duplex {
|
|
|
44
30
|
alpnProtocol: handshake.alpnProtocol,
|
|
45
31
|
cipher: handshake.cipher,
|
|
46
32
|
};
|
|
47
|
-
// Wire up raw socket events
|
|
48
33
|
rawSocket.on('data', (chunk) => this.handleRawData(chunk));
|
|
49
34
|
rawSocket.on('error', (err) => this.destroy(err));
|
|
50
35
|
rawSocket.once('close', () => {
|
|
@@ -53,7 +38,6 @@ class StealthTLSStream extends Duplex {
|
|
|
53
38
|
});
|
|
54
39
|
}
|
|
55
40
|
_read() {
|
|
56
|
-
// Data is pushed from handleRawData; no action needed
|
|
57
41
|
}
|
|
58
42
|
_write(chunk, _encoding, callback) {
|
|
59
43
|
try {
|
|
@@ -93,14 +77,12 @@ class StealthTLSStream extends Duplex {
|
|
|
93
77
|
const level = decrypted.plaintext[0];
|
|
94
78
|
const desc = decrypted.plaintext[1];
|
|
95
79
|
if (desc === 0) {
|
|
96
|
-
// close_notify
|
|
97
80
|
this.push(null);
|
|
98
81
|
}
|
|
99
82
|
else {
|
|
100
83
|
this.destroy(new TLSError(`TLS alert: level=${level} desc=${desc}`, desc));
|
|
101
84
|
}
|
|
102
85
|
}
|
|
103
|
-
// Handshake messages (e.g. NewSessionTicket) are silently ignored
|
|
104
86
|
}
|
|
105
87
|
catch (err) {
|
|
106
88
|
this.destroy(err instanceof Error ? err : new Error(String(err)));
|
|
@@ -116,23 +98,36 @@ class StealthTLSStream extends Duplex {
|
|
|
116
98
|
this.destroy(new TLSError(`Unencrypted alert: desc=${desc}`, desc));
|
|
117
99
|
}
|
|
118
100
|
}
|
|
119
|
-
// Ignore other record types
|
|
120
101
|
}
|
|
121
102
|
}
|
|
122
103
|
}
|
|
123
|
-
|
|
104
|
+
/**
|
|
105
|
+
* TLS engine that performs a fully custom TLS 1.3 handshake at the byte
|
|
106
|
+
* level, producing ClientHello messages that exactly match the fingerprint
|
|
107
|
+
* of the given browser profile — including GREASE values, extension ordering,
|
|
108
|
+
* key share groups, and cipher suite ordering. Unlike {@link NodeTLSEngine},
|
|
109
|
+
* this engine bypasses Node.js’s native `tls` module entirely.
|
|
110
|
+
*/
|
|
124
111
|
export class StealthTLSEngine {
|
|
112
|
+
/**
|
|
113
|
+
* Establishes a TLS 1.3 connection using the custom stealth handshake engine.
|
|
114
|
+
* Opens a raw TCP socket (or reuses a pre-connected socket from `options.socket`),
|
|
115
|
+
* performs the full TLS 1.3 handshake matching `profile`, and wraps the socket
|
|
116
|
+
* in an encrypted duplex stream.
|
|
117
|
+
*
|
|
118
|
+
* @param {TLSConnectOptions} options - Connection parameters (host, port, SNI, etc.).
|
|
119
|
+
* @param {BrowserProfile} [profile] - Browser profile to impersonate; falls back to `DEFAULT_PROFILE`.
|
|
120
|
+
* @returns {Promise<TLSSocket>} Resolves with the encrypted duplex stream.
|
|
121
|
+
* @throws {TLSError} If the handshake fails, times out, or the connection is rejected.
|
|
122
|
+
*/
|
|
125
123
|
async connect(options, profile) {
|
|
126
124
|
const effectiveProfile = profile ?? DEFAULT_PROFILE;
|
|
127
125
|
const hostname = options.servername ?? options.host;
|
|
128
|
-
// Establish TCP connection (or use pre-connected socket)
|
|
129
126
|
const rawSocket = options.socket
|
|
130
127
|
? options.socket
|
|
131
128
|
: await tcpConnect(options.host, options.port, options.timeout, options.signal);
|
|
132
129
|
try {
|
|
133
|
-
// Perform TLS 1.3 handshake
|
|
134
130
|
const handshake = await performHandshake(rawSocket, effectiveProfile, hostname, options.insecure ?? false);
|
|
135
|
-
// Wrap in Duplex stream
|
|
136
131
|
const stream = new StealthTLSStream(rawSocket, handshake);
|
|
137
132
|
return stream;
|
|
138
133
|
}
|
|
@@ -142,7 +137,6 @@ export class StealthTLSEngine {
|
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
139
|
}
|
|
145
|
-
// ---- TCP connection helper ----
|
|
146
140
|
function tcpConnect(host, port, timeout, signal) {
|
|
147
141
|
return new Promise((resolve, reject) => {
|
|
148
142
|
let settled = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/tls/stealth/engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/tls/stealth/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAwB,MAAM,gBAAgB,CAAC;AACxE,OAAO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CAAC;gBACjB,MAAM,CAAC,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;gBAC3C,OAAO;YACT,CAAC;YACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC1B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;gBACf,IAAI,KAAK;oBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;QACH,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,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TLS 1.3 handshake state machine.
|
|
3
|
-
*
|
|
4
|
-
* Manages the full TLS 1.3 handshake flow:
|
|
5
|
-
* ClientHello -> ServerHello -> {EncryptedExtensions, Certificate,
|
|
6
|
-
* CertificateVerify, Finished} -> client Finished -> Application Data
|
|
7
|
-
*
|
|
8
|
-
* All crypto operations use `node:crypto`; no external dependencies.
|
|
9
|
-
*/
|
|
10
1
|
import * as net from 'node:net';
|
|
11
2
|
import type { BrowserProfile } from '../../fingerprints/types.js';
|
|
12
3
|
import { type AEADAlgorithm } from './record-layer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Tracks the sequential state of a TLS 1.3 handshake as messages are parsed.
|
|
6
|
+
* Used internally by {@link performHandshake} to enforce message ordering.
|
|
7
|
+
*
|
|
8
|
+
* @enum {number}
|
|
9
|
+
*/
|
|
13
10
|
export declare enum HandshakeState {
|
|
14
11
|
Initial = 0,
|
|
15
12
|
WaitingServerHello = 1,
|
|
@@ -20,26 +17,43 @@ export declare enum HandshakeState {
|
|
|
20
17
|
Connected = 6,
|
|
21
18
|
Failed = 7
|
|
22
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The derived key material and negotiated parameters produced by a successful
|
|
22
|
+
* TLS 1.3 handshake, passed to the record layer to enable encrypted communication.
|
|
23
|
+
*
|
|
24
|
+
* @typedef {Object} HandshakeResult
|
|
25
|
+
* @property {string|null} alpnProtocol - Negotiated ALPN protocol name, or `null` if not negotiated.
|
|
26
|
+
* @property {string} cipher - Negotiated cipher suite name string.
|
|
27
|
+
* @property {string} version - Negotiated TLS version string (e.g. `"TLSv1.3"`).
|
|
28
|
+
* @property {Buffer} clientKey - Derived client application traffic key.
|
|
29
|
+
* @property {Buffer} clientIV - Derived client application traffic IV.
|
|
30
|
+
* @property {Buffer} serverKey - Derived server application traffic key.
|
|
31
|
+
* @property {Buffer} serverIV - Derived server application traffic IV.
|
|
32
|
+
* @property {AEADAlgorithm} aead - AEAD algorithm identifier for the record layer.
|
|
33
|
+
*/
|
|
23
34
|
export interface HandshakeResult {
|
|
24
|
-
/** Negotiated ALPN protocol. */
|
|
25
35
|
alpnProtocol: string | null;
|
|
26
|
-
/** Negotiated cipher suite. */
|
|
27
36
|
cipher: string;
|
|
28
|
-
/** TLS version string. */
|
|
29
37
|
version: string;
|
|
30
|
-
/** Application traffic keys for the client. */
|
|
31
38
|
clientKey: Buffer;
|
|
32
39
|
clientIV: Buffer;
|
|
33
|
-
/** Application traffic keys for the server. */
|
|
34
40
|
serverKey: Buffer;
|
|
35
41
|
serverIV: Buffer;
|
|
36
|
-
/** AEAD algorithm. */
|
|
37
42
|
aead: AEADAlgorithm;
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
|
-
*
|
|
45
|
+
* Executes a full TLS 1.3 handshake over the provided raw TCP socket,
|
|
46
|
+
* matching the fingerprint of the given browser profile. Processes
|
|
47
|
+
* ServerHello, EncryptedExtensions, Certificate, CertificateVerify, and
|
|
48
|
+
* Finished messages, and sends the client Finished message to complete
|
|
49
|
+
* the handshake.
|
|
41
50
|
*
|
|
42
|
-
*
|
|
51
|
+
* @param {net.Socket} socket - Connected TCP socket to perform the handshake over.
|
|
52
|
+
* @param {BrowserProfile} profile - Browser profile that determines the ClientHello fingerprint.
|
|
53
|
+
* @param {string} hostname - SNI hostname used for certificate validation.
|
|
54
|
+
* @param {boolean} insecure - When `true`, skips certificate chain verification.
|
|
55
|
+
* @returns {Promise<HandshakeResult>} Resolves with derived keys and negotiated parameters on success.
|
|
56
|
+
* @throws {TLSError} If any handshake message is malformed, the certificate is invalid, or the server sends an alert.
|
|
43
57
|
*/
|
|
44
58
|
export declare function performHandshake(socket: net.Socket, profile: BrowserProfile, hostname: string, insecure: boolean): Promise<HandshakeResult>;
|
|
45
59
|
//# sourceMappingURL=handshake.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../../src/tls/stealth/handshake.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../../src/tls/stealth/handshake.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAahC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAOlE,OAAO,EAML,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AA8G3B;;;;;GAKG;AACH,oBAAY,cAAc;IACxB,OAAO,IAAA;IACP,kBAAkB,IAAA;IAClB,0BAA0B,IAAA;IAC1B,kBAAkB,IAAA;IAClB,wBAAwB,IAAA;IACxB,eAAe,IAAA;IACf,SAAS,IAAA;IACT,MAAM,IAAA;CACP;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,eAAe,CAAC,CA2O1B"}
|