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,17 +1,29 @@
|
|
|
1
|
+
import type { RetryConfig } from '../core/request.js';
|
|
2
|
+
import { NLcURLResponse } from '../core/response.js';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Carries context about the current retry attempt that is passed to the
|
|
5
|
+
* `execute` callback on each invocation.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
7
|
+
* @typedef {Object} RetryContext
|
|
8
|
+
* @property {number} attempt - Zero-based attempt index (0 = first try).
|
|
9
|
+
* @property {Error} [lastError] - The error thrown by the previous attempt, if any.
|
|
10
|
+
* @property {NLcURLResponse} [lastResponse] - The response from the previous attempt, if any.
|
|
5
11
|
*/
|
|
6
|
-
import type { RetryConfig } from '../core/request.js';
|
|
7
|
-
import { NLcURLResponse } from '../core/response.js';
|
|
8
12
|
export interface RetryContext {
|
|
9
13
|
attempt: number;
|
|
10
14
|
lastError?: Error;
|
|
11
15
|
lastResponse?: NLcURLResponse;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* Executes `execute` up to `config.count + 1` times with configurable
|
|
19
|
+
* back-off and jitter between attempts. Transparent to `AbortError` — those
|
|
20
|
+
* propagate immediately without retry.
|
|
21
|
+
*
|
|
22
|
+
* @param {RetryConfig | undefined} config - Retry parameters; `undefined` uses library defaults.
|
|
23
|
+
* @param {(ctx: RetryContext) => Promise<NLcURLResponse>} execute - The operation to attempt.
|
|
24
|
+
* @returns {Promise<NLcURLResponse>} The first successful response.
|
|
25
|
+
* @throws {AbortError} Immediately if the operation is aborted.
|
|
26
|
+
* @throws {Error} Re-throws the last error if all attempts are exhausted.
|
|
15
27
|
*/
|
|
16
28
|
export declare function withRetry(config: RetryConfig | undefined, execute: (ctx: RetryContext) => Promise<NLcURLResponse>): Promise<NLcURLResponse>;
|
|
17
29
|
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/middleware/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/middleware/retry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,YAAY,CAAC,EAAE,cAAc,CAAC;CAC/B;AASD;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GACtD,OAAO,CAAC,cAAc,CAAC,CA4CzB"}
|
package/dist/middleware/retry.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Implements configurable retry logic with exponential backoff.
|
|
5
|
-
*/
|
|
6
|
-
import { AbortError, TimeoutError, ConnectionError } from '../core/errors.js';
|
|
1
|
+
import { AbortError, TimeoutError, ConnectionError, ProtocolError } from '../core/errors.js';
|
|
2
|
+
const RETRYABLE_H2_ERROR_CODES = new Set([1, 2, 7, 11]);
|
|
7
3
|
function shouldRetryDefault(error, statusCode) {
|
|
8
4
|
if (error instanceof ConnectionError || error instanceof TimeoutError)
|
|
9
5
|
return true;
|
|
6
|
+
if (error instanceof ProtocolError && error.errorCode !== undefined && RETRYABLE_H2_ERROR_CODES.has(error.errorCode))
|
|
7
|
+
return true;
|
|
10
8
|
if (statusCode !== undefined && [429, 500, 502, 503, 504].includes(statusCode))
|
|
11
9
|
return true;
|
|
12
10
|
return false;
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
13
|
+
* Executes `execute` up to `config.count + 1` times with configurable
|
|
14
|
+
* back-off and jitter between attempts. Transparent to `AbortError` — those
|
|
15
|
+
* propagate immediately without retry.
|
|
16
|
+
*
|
|
17
|
+
* @param {RetryConfig | undefined} config - Retry parameters; `undefined` uses library defaults.
|
|
18
|
+
* @param {(ctx: RetryContext) => Promise<NLcURLResponse>} execute - The operation to attempt.
|
|
19
|
+
* @returns {Promise<NLcURLResponse>} The first successful response.
|
|
20
|
+
* @throws {AbortError} Immediately if the operation is aborted.
|
|
21
|
+
* @throws {Error} Re-throws the last error if all attempts are exhausted.
|
|
16
22
|
*/
|
|
17
23
|
export async function withRetry(config, execute) {
|
|
18
24
|
const count = config?.count ?? 3;
|
|
@@ -23,7 +29,6 @@ export async function withRetry(config, execute) {
|
|
|
23
29
|
let lastError;
|
|
24
30
|
let lastResponse;
|
|
25
31
|
for (let attempt = 0; attempt <= count; attempt++) {
|
|
26
|
-
// Wait before retry (skip first attempt)
|
|
27
32
|
if (attempt > 0) {
|
|
28
33
|
const factor = backoff === 'exponential'
|
|
29
34
|
? Math.pow(2, attempt - 1)
|
|
@@ -34,7 +39,6 @@ export async function withRetry(config, execute) {
|
|
|
34
39
|
}
|
|
35
40
|
try {
|
|
36
41
|
const response = await execute({ attempt, lastError, lastResponse });
|
|
37
|
-
// Check if response status warrants retry
|
|
38
42
|
if (attempt < count && retryOn(null, response.status)) {
|
|
39
43
|
lastResponse = response;
|
|
40
44
|
continue;
|
|
@@ -42,7 +46,6 @@ export async function withRetry(config, execute) {
|
|
|
42
46
|
return response;
|
|
43
47
|
}
|
|
44
48
|
catch (err) {
|
|
45
|
-
// Never retry aborted requests
|
|
46
49
|
if (err instanceof AbortError)
|
|
47
50
|
throw err;
|
|
48
51
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
@@ -53,7 +56,6 @@ export async function withRetry(config, execute) {
|
|
|
53
56
|
throw err;
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
// Should not reach here, but if it does, throw the last error
|
|
57
59
|
if (lastError)
|
|
58
60
|
throw lastError;
|
|
59
61
|
return lastResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/middleware/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/middleware/retry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE7F,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAiBxD,SAAS,kBAAkB,CAAC,KAAmB,EAAE,UAAmB;IAClE,IAAI,KAAK,YAAY,eAAe,IA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zC,MAAM,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;YAErE,IAAI,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtD,YAAY,GAAG,QAAQ,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,UAAU;gBAAE,MAAM,GAAG,CAAC;YAEzC,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAClE,IAAI,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtC,SAAS,GAAG,KAAK,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,IAAI,SAAS;QAAE,MAAM,SAAS,CAAC;IAC/B,OAAO,YAAa,CAAC;AACvB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
+
import * as net from 'node:net';
|
|
1
2
|
/**
|
|
2
|
-
* HTTP CONNECT proxy
|
|
3
|
+
* Options for establishing a connection through an HTTP CONNECT proxy.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* @typedef {Object} HttpProxyOptions
|
|
6
|
+
* @property {string} host - Proxy server hostname or IP address.
|
|
7
|
+
* @property {number} port - Proxy server port.
|
|
8
|
+
* @property {string} [auth] - Proxy credentials in `username:password` format (used for Basic auth).
|
|
9
|
+
* @property {number} [timeout] - Connection timeout in milliseconds (default: 30 000).
|
|
10
|
+
* @property {4 | 6} [family] - IP address family to use when resolving the proxy host.
|
|
6
11
|
*/
|
|
7
|
-
import * as net from 'node:net';
|
|
8
12
|
export interface HttpProxyOptions {
|
|
9
13
|
host: string;
|
|
10
14
|
port: number;
|
|
11
|
-
/** Proxy authentication (user:pass). */
|
|
12
15
|
auth?: string;
|
|
13
|
-
/** Timeout in milliseconds. */
|
|
14
16
|
timeout?: number;
|
|
17
|
+
family?: 4 | 6;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Opens a TCP connection to an HTTP CONNECT proxy and tunnels through it to
|
|
21
|
+
* `targetHost:targetPort`. Resolves with the raw socket once the tunnel is
|
|
22
|
+
* established.
|
|
18
23
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* @param {HttpProxyOptions} proxy - Proxy server connection details.
|
|
25
|
+
* @param {string} targetHost - Destination hostname or IP to tunnel to.
|
|
26
|
+
* @param {number} targetPort - Destination port to tunnel to.
|
|
27
|
+
* @returns {Promise<net.Socket>} Plain TCP socket connected through the proxy tunnel.
|
|
28
|
+
* @throws {ProxyError} If the connection times out or the proxy rejects the CONNECT request.
|
|
21
29
|
*/
|
|
22
30
|
export declare function httpProxyConnect(proxy: HttpProxyOptions, targetHost: string, targetPort: number): Promise<net.Socket>;
|
|
23
31
|
//# sourceMappingURL=http-proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/http-proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/http-proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAGhC;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAqFrB"}
|
package/dist/proxy/http-proxy.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
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
1
|
import * as net from 'node:net';
|
|
8
2
|
import { ProxyError } from '../core/errors.js';
|
|
9
3
|
/**
|
|
10
|
-
*
|
|
4
|
+
* Opens a TCP connection to an HTTP CONNECT proxy and tunnels through it to
|
|
5
|
+
* `targetHost:targetPort`. Resolves with the raw socket once the tunnel is
|
|
6
|
+
* established.
|
|
11
7
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* @param {HttpProxyOptions} proxy - Proxy server connection details.
|
|
9
|
+
* @param {string} targetHost - Destination hostname or IP to tunnel to.
|
|
10
|
+
* @param {number} targetPort - Destination port to tunnel to.
|
|
11
|
+
* @returns {Promise<net.Socket>} Plain TCP socket connected through the proxy tunnel.
|
|
12
|
+
* @throws {ProxyError} If the connection times out or the proxy rejects the CONNECT request.
|
|
14
13
|
*/
|
|
15
14
|
export async function httpProxyConnect(proxy, targetHost, targetPort) {
|
|
16
15
|
return new Promise((resolve, reject) => {
|
|
@@ -18,6 +17,7 @@ export async function httpProxyConnect(proxy, targetHost, targetPort) {
|
|
|
18
17
|
const socket = net.createConnection({
|
|
19
18
|
host: proxy.host,
|
|
20
19
|
port: proxy.port,
|
|
20
|
+
family: proxy.family,
|
|
21
21
|
});
|
|
22
22
|
const timeoutMs = proxy.timeout ?? 30_000;
|
|
23
23
|
let timer;
|
|
@@ -31,7 +31,6 @@ export async function httpProxyConnect(proxy, targetHost, targetPort) {
|
|
|
31
31
|
}, timeoutMs);
|
|
32
32
|
}
|
|
33
33
|
socket.once('connect', () => {
|
|
34
|
-
// Send CONNECT request
|
|
35
34
|
let connectReq = `CONNECT ${targetHost}:${targetPort} HTTP/1.1\r\n`;
|
|
36
35
|
connectReq += `Host: ${targetHost}:${targetPort}\r\n`;
|
|
37
36
|
if (proxy.auth) {
|
|
@@ -40,14 +39,12 @@ export async function httpProxyConnect(proxy, targetHost, targetPort) {
|
|
|
40
39
|
}
|
|
41
40
|
connectReq += '\r\n';
|
|
42
41
|
socket.write(connectReq);
|
|
43
|
-
// Read proxy response
|
|
44
42
|
let buffer = '';
|
|
45
43
|
const onData = (chunk) => {
|
|
46
44
|
buffer += chunk.toString('latin1');
|
|
47
45
|
const headerEnd = buffer.indexOf('\r\n\r\n');
|
|
48
46
|
if (headerEnd >= 0) {
|
|
49
47
|
socket.removeListener('data', onData);
|
|
50
|
-
// Parse status line
|
|
51
48
|
const statusLine = buffer.substring(0, buffer.indexOf('\r\n'));
|
|
52
49
|
const match = /^HTTP\/\d\.\d\s+(\d{3})/.exec(statusLine);
|
|
53
50
|
if (!match) {
|
|
@@ -70,7 +67,6 @@ export async function httpProxyConnect(proxy, targetHost, targetPort) {
|
|
|
70
67
|
settled = true;
|
|
71
68
|
if (timer)
|
|
72
69
|
clearTimeout(timer);
|
|
73
|
-
// Push any remaining data back
|
|
74
70
|
const remaining = buffer.substring(headerEnd + 4);
|
|
75
71
|
if (remaining.length > 0) {
|
|
76
72
|
socket.unshift(Buffer.from(remaining, 'latin1'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-proxy.js","sourceRoot":"","sources":["../../src/proxy/http-proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-proxy.js","sourceRoot":"","sources":["../../src/proxy/http-proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAoB/C;;;;;;;;;;GAUG;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,CAAC;QACpB,MAAM,MAAM,GAAG,GAAG,CAAC,gBAAgB,CAAC;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC;QAC1C,IAAI,KAAgD,CAAC;QAErD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBACtB,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,OAAO,GAAG,IAAI,CAAC;oBACf,MAAM,CAAC,OAAO,EAAE,CAAC;oBACjB,MAAM,CAAC,IAAI,UAAU,CAAC,4BAA4B,CAAC,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC,EAAE,SAAS,CAAC,CAAC;QAChB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC1B,IAAI,UAAU,GAAG,WAAW,UAAU,IAAI,UAAU,eAAe,CAAC;YACpE,UAAU,IAAI,SAAS,UAAU,IAAI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y.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* @typedef {Object} SocksProxyOptions
|
|
6
|
+
* @property {string} host - Proxy server hostname or IP address.
|
|
7
|
+
* @property {number} port - Proxy server port.
|
|
8
|
+
* @property {4 | 5} version - SOCKS protocol version.
|
|
9
|
+
* @property {string} [username] - Username for SOCKS5 username/password authentication.
|
|
10
|
+
* @property {string} [password] - Password for SOCKS5 username/password authentication.
|
|
11
|
+
* @property {number} [timeout] - Connection timeout in milliseconds.
|
|
12
|
+
* @property {4 | 6} [family] - IP address family used when resolving the proxy host.
|
|
6
13
|
*/
|
|
7
|
-
import * as net from 'node:net';
|
|
8
14
|
export interface SocksProxyOptions {
|
|
9
15
|
host: string;
|
|
10
16
|
port: number;
|
|
11
|
-
/** SOCKS version: 4, 4 (with 4a extension), or 5. */
|
|
12
17
|
version: 4 | 5;
|
|
13
|
-
/** Username for SOCKS5 authentication. */
|
|
14
18
|
username?: string;
|
|
15
|
-
/** Password for SOCKS5 authentication. */
|
|
16
19
|
password?: string;
|
|
17
|
-
/** Timeout in milliseconds. */
|
|
18
20
|
timeout?: number;
|
|
21
|
+
family?: 4 | 6;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* Opens a TCP connection to a SOCKS4 or SOCKS5 proxy and negotiates a tunnel
|
|
25
|
+
* to `targetHost:targetPort`. Resolves with the raw socket once the tunnel is
|
|
26
|
+
* established.
|
|
27
|
+
*
|
|
28
|
+
* @param {SocksProxyOptions} proxy - Proxy server connection details.
|
|
29
|
+
* @param {string} targetHost - Destination hostname.
|
|
30
|
+
* @param {number} targetPort - Destination port.
|
|
31
|
+
* @returns {Promise<net.Socket>} Plain TCP socket connected through the SOCKS tunnel.
|
|
32
|
+
* @throws {ProxyError} If authentication fails or the proxy rejects the connection request.
|
|
22
33
|
*/
|
|
23
34
|
export declare function socksConnect(proxy: SocksProxyOptions, targetHost: string, targetPort: number): Promise<net.Socket>;
|
|
24
35
|
//# sourceMappingURL=socks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socks.d.ts","sourceRoot":"","sources":["../../src/proxy/socks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socks.d.ts","sourceRoot":"","sources":["../../src/proxy/socks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAGhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,iBAAiB,EACxB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAcrB"}
|
package/dist/proxy/socks.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
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
1
|
import * as net from 'node:net';
|
|
8
2
|
import { ProxyError } from '../core/errors.js';
|
|
9
3
|
/**
|
|
10
|
-
*
|
|
4
|
+
* Opens a TCP connection to a SOCKS4 or SOCKS5 proxy and negotiates a tunnel
|
|
5
|
+
* to `targetHost:targetPort`. Resolves with the raw socket once the tunnel is
|
|
6
|
+
* established.
|
|
7
|
+
*
|
|
8
|
+
* @param {SocksProxyOptions} proxy - Proxy server connection details.
|
|
9
|
+
* @param {string} targetHost - Destination hostname.
|
|
10
|
+
* @param {number} targetPort - Destination port.
|
|
11
|
+
* @returns {Promise<net.Socket>} Plain TCP socket connected through the SOCKS tunnel.
|
|
12
|
+
* @throws {ProxyError} If authentication fails or the proxy rejects the connection request.
|
|
11
13
|
*/
|
|
12
14
|
export async function socksConnect(proxy, targetHost, targetPort) {
|
|
13
|
-
const socket = await tcpConnect(proxy.host, proxy.port, proxy.timeout);
|
|
15
|
+
const socket = await tcpConnect(proxy.host, proxy.port, proxy.timeout, proxy.family);
|
|
14
16
|
try {
|
|
15
17
|
if (proxy.version === 5) {
|
|
16
18
|
await socks5Handshake(socket, proxy, targetHost, targetPort);
|
|
@@ -25,9 +27,7 @@ export async function socksConnect(proxy, targetHost, targetPort) {
|
|
|
25
27
|
throw err;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
// ---- SOCKS5 ----
|
|
29
30
|
async function socks5Handshake(socket, proxy, host, port) {
|
|
30
|
-
// 1. Authentication negotiation
|
|
31
31
|
const hasAuth = proxy.username && proxy.password;
|
|
32
32
|
const methods = hasAuth ? Buffer.from([0x05, 0x02, 0x00, 0x02]) : Buffer.from([0x05, 0x01, 0x00]);
|
|
33
33
|
await socketWrite(socket, methods);
|
|
@@ -37,11 +37,10 @@ async function socks5Handshake(socket, proxy, host, port) {
|
|
|
37
37
|
}
|
|
38
38
|
const selectedMethod = authResponse[1];
|
|
39
39
|
if (selectedMethod === 0x02 && hasAuth) {
|
|
40
|
-
// Username/password authentication (RFC 1929)
|
|
41
40
|
const user = Buffer.from(proxy.username, 'utf-8');
|
|
42
41
|
const pass = Buffer.from(proxy.password, 'utf-8');
|
|
43
42
|
const authReq = Buffer.alloc(3 + user.length + pass.length);
|
|
44
|
-
authReq[0] = 0x01;
|
|
43
|
+
authReq[0] = 0x01;
|
|
45
44
|
authReq[1] = user.length;
|
|
46
45
|
user.copy(authReq, 2);
|
|
47
46
|
authReq[2 + user.length] = pass.length;
|
|
@@ -55,18 +54,16 @@ async function socks5Handshake(socket, proxy, host, port) {
|
|
|
55
54
|
else if (selectedMethod === 0xff) {
|
|
56
55
|
throw new ProxyError('SOCKS5 proxy rejected all authentication methods');
|
|
57
56
|
}
|
|
58
|
-
// 2. Connection request
|
|
59
57
|
const hostBuf = Buffer.from(host, 'utf-8');
|
|
60
58
|
const req = Buffer.alloc(4 + 1 + hostBuf.length + 2);
|
|
61
|
-
req[0] = 0x05;
|
|
62
|
-
req[1] = 0x01;
|
|
63
|
-
req[2] = 0x00;
|
|
64
|
-
req[3] = 0x03;
|
|
59
|
+
req[0] = 0x05;
|
|
60
|
+
req[1] = 0x01;
|
|
61
|
+
req[2] = 0x00;
|
|
62
|
+
req[3] = 0x03;
|
|
65
63
|
req[4] = hostBuf.length;
|
|
66
64
|
hostBuf.copy(req, 5);
|
|
67
65
|
req.writeUInt16BE(port, 5 + hostBuf.length);
|
|
68
66
|
await socketWrite(socket, req);
|
|
69
|
-
// 3. Read response
|
|
70
67
|
const resp = await socketRead(socket, 4);
|
|
71
68
|
if (resp[0] !== 0x05) {
|
|
72
69
|
throw new ProxyError('Invalid SOCKS5 response');
|
|
@@ -84,36 +81,29 @@ async function socks5Handshake(socket, proxy, host, port) {
|
|
|
84
81
|
};
|
|
85
82
|
throw new ProxyError(`SOCKS5 connect failed: ${codes[resp[1]] ?? 'unknown error'}`);
|
|
86
83
|
}
|
|
87
|
-
// Read bound address (we don't use it, but must consume the bytes)
|
|
88
84
|
const addrType = resp[3];
|
|
89
85
|
if (addrType === 0x01) {
|
|
90
|
-
// IPv4
|
|
91
86
|
await socketRead(socket, 4 + 2);
|
|
92
87
|
}
|
|
93
88
|
else if (addrType === 0x03) {
|
|
94
|
-
// Domain
|
|
95
89
|
const lenBuf = await socketRead(socket, 1);
|
|
96
90
|
await socketRead(socket, lenBuf[0] + 2);
|
|
97
91
|
}
|
|
98
92
|
else if (addrType === 0x04) {
|
|
99
|
-
// IPv6
|
|
100
93
|
await socketRead(socket, 16 + 2);
|
|
101
94
|
}
|
|
102
95
|
}
|
|
103
|
-
// ---- SOCKS4/4a ----
|
|
104
96
|
async function socks4Connect(socket, host, port) {
|
|
105
|
-
// SOCKS4a: use 0.0.0.1 as IP and append hostname
|
|
106
97
|
const hostBuf = Buffer.from(host + '\0', 'utf-8');
|
|
107
98
|
const req = Buffer.alloc(9 + hostBuf.length);
|
|
108
|
-
req[0] = 0x04;
|
|
109
|
-
req[1] = 0x01;
|
|
99
|
+
req[0] = 0x04;
|
|
100
|
+
req[1] = 0x01;
|
|
110
101
|
req.writeUInt16BE(port, 2);
|
|
111
|
-
// IP = 0.0.0.1 (triggers SOCKS4a)
|
|
112
102
|
req[4] = 0;
|
|
113
103
|
req[5] = 0;
|
|
114
104
|
req[6] = 0;
|
|
115
105
|
req[7] = 1;
|
|
116
|
-
req[8] = 0;
|
|
106
|
+
req[8] = 0;
|
|
117
107
|
hostBuf.copy(req, 9);
|
|
118
108
|
await socketWrite(socket, req);
|
|
119
109
|
const resp = await socketRead(socket, 8);
|
|
@@ -121,11 +111,10 @@ async function socks4Connect(socket, host, port) {
|
|
|
121
111
|
throw new ProxyError(`SOCKS4 connect failed: status 0x${resp[1].toString(16)}`);
|
|
122
112
|
}
|
|
123
113
|
}
|
|
124
|
-
|
|
125
|
-
function tcpConnect(host, port, timeout) {
|
|
114
|
+
function tcpConnect(host, port, timeout, family) {
|
|
126
115
|
return new Promise((resolve, reject) => {
|
|
127
116
|
let settled = false;
|
|
128
|
-
const socket = net.createConnection({ host, port });
|
|
117
|
+
const socket = net.createConnection({ host, port, family });
|
|
129
118
|
const timeoutMs = timeout ?? 30_000;
|
|
130
119
|
let timer;
|
|
131
120
|
if (timeoutMs > 0) {
|
package/dist/proxy/socks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socks.js","sourceRoot":"","sources":["../../src/proxy/socks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socks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cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACtC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACxC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;gBAC1C,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;oBAC3B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC1C,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,GAAU,EAAE,EAAE;YAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;gBACf,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACtC,MAAM,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/tls/constants.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TLS
|
|
2
|
+
* TLS record content type codes (RFC 8446 §5.1).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* (RFC 8446 for TLS 1.3, RFC 5246 for TLS 1.2).
|
|
4
|
+
* @enum {number}
|
|
6
5
|
*/
|
|
7
6
|
export declare const RecordType: {
|
|
8
7
|
readonly CHANGE_CIPHER_SPEC: 20;
|
|
@@ -10,12 +9,23 @@ export declare const RecordType: {
|
|
|
10
9
|
readonly HANDSHAKE: 22;
|
|
11
10
|
readonly APPLICATION_DATA: 23;
|
|
12
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* TLS protocol version codes as used in the record layer and handshake
|
|
14
|
+
* (RFC 8446 Appendix B.3.1).
|
|
15
|
+
*
|
|
16
|
+
* @enum {number}
|
|
17
|
+
*/
|
|
13
18
|
export declare const ProtocolVersion: {
|
|
14
19
|
readonly TLS_1_0: 769;
|
|
15
20
|
readonly TLS_1_1: 770;
|
|
16
21
|
readonly TLS_1_2: 771;
|
|
17
22
|
readonly TLS_1_3: 772;
|
|
18
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* TLS handshake message type codes (RFC 8446 ¥4).
|
|
26
|
+
*
|
|
27
|
+
* @enum {number}
|
|
28
|
+
*/
|
|
19
29
|
export declare const HandshakeType: {
|
|
20
30
|
readonly CLIENT_HELLO: 1;
|
|
21
31
|
readonly SERVER_HELLO: 2;
|
|
@@ -29,6 +39,12 @@ export declare const HandshakeType: {
|
|
|
29
39
|
readonly KEY_UPDATE: 24;
|
|
30
40
|
readonly MESSAGE_HASH: 254;
|
|
31
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* IANA TLS cipher suite codes supported by the stealth engine and used to
|
|
44
|
+
* construct JA3 fingerprints (RFC 8446, RFC 5246).
|
|
45
|
+
*
|
|
46
|
+
* @enum {number}
|
|
47
|
+
*/
|
|
32
48
|
export declare const CipherSuite: {
|
|
33
49
|
readonly TLS_AES_128_GCM_SHA256: 4865;
|
|
34
50
|
readonly TLS_AES_256_GCM_SHA384: 4866;
|
|
@@ -48,6 +64,11 @@ export declare const CipherSuite: {
|
|
|
48
64
|
readonly TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: 49161;
|
|
49
65
|
readonly TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: 49162;
|
|
50
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* IANA TLS extension type codes (RFC 8446 Appendix B.3.1 and related RFCs).
|
|
69
|
+
*
|
|
70
|
+
* @enum {number}
|
|
71
|
+
*/
|
|
51
72
|
export declare const ExtensionType: {
|
|
52
73
|
readonly SERVER_NAME: 0;
|
|
53
74
|
readonly EC_POINT_FORMATS: 11;
|
|
@@ -74,6 +95,12 @@ export declare const ExtensionType: {
|
|
|
74
95
|
readonly ENCRYPTED_CLIENT_HELLO: 65037;
|
|
75
96
|
readonly POST_HANDSHAKE_AUTH: 49;
|
|
76
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* IANA named group codes for elliptic curves and finite-field DH groups
|
|
100
|
+
* used in TLS key exchange (RFC 8422, RFC 7748).
|
|
101
|
+
*
|
|
102
|
+
* @enum {number}
|
|
103
|
+
*/
|
|
77
104
|
export declare const NamedGroup: {
|
|
78
105
|
readonly X25519: 29;
|
|
79
106
|
readonly SECP256R1: 23;
|
|
@@ -85,6 +112,12 @@ export declare const NamedGroup: {
|
|
|
85
112
|
readonly X25519_KYBER768: 25497;
|
|
86
113
|
readonly X25519_MLKEM768: 17800;
|
|
87
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* IANA TLS signature scheme codes used in the `signature_algorithms` extension
|
|
117
|
+
* and in `CertificateVerify` messages (RFC 8446 Appendix B.3.1.3).
|
|
118
|
+
*
|
|
119
|
+
* @enum {number}
|
|
120
|
+
*/
|
|
88
121
|
export declare const SignatureScheme: {
|
|
89
122
|
readonly ECDSA_SECP256R1_SHA256: 1027;
|
|
90
123
|
readonly ECDSA_SECP384R1_SHA384: 1283;
|
|
@@ -103,21 +136,58 @@ export declare const SignatureScheme: {
|
|
|
103
136
|
readonly RSA_PKCS1_SHA1: 513;
|
|
104
137
|
readonly ECDSA_SHA1: 515;
|
|
105
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* EC point format codes used in the `ec_point_formats` TLS extension
|
|
141
|
+
* (RFC 8422 §5.1.2). Only `UNCOMPRESSED` (`0`) is used in practice.
|
|
142
|
+
*
|
|
143
|
+
* @enum {number}
|
|
144
|
+
*/
|
|
106
145
|
export declare const ECPointFormat: {
|
|
107
146
|
readonly UNCOMPRESSED: 0;
|
|
108
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* PSK key exchange mode codes used in the `psk_key_exchange_modes` extension
|
|
150
|
+
* (RFC 8446 ¥4.2.9).
|
|
151
|
+
*
|
|
152
|
+
* @enum {number}
|
|
153
|
+
*/
|
|
109
154
|
export declare const PskKeyExchangeMode: {
|
|
110
155
|
readonly PSK_KE: 0;
|
|
111
156
|
readonly PSK_DHE_KE: 1;
|
|
112
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* Certificate compression algorithm codes used in the `compress_certificate`
|
|
160
|
+
* extension (RFC 8879).
|
|
161
|
+
*
|
|
162
|
+
* @enum {number}
|
|
163
|
+
*/
|
|
113
164
|
export declare const CertCompressAlg: {
|
|
114
165
|
readonly ZLIB: 1;
|
|
115
166
|
readonly BROTLI: 2;
|
|
116
167
|
readonly ZSTD: 3;
|
|
117
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* The 16 GREASE values defined in RFC 8701. These are injected into cipher
|
|
171
|
+
* suite lists, extension type lists, and named group lists to encourage
|
|
172
|
+
* servers to be tolerant of unknown values.
|
|
173
|
+
*
|
|
174
|
+
* @type {readonly number[]}
|
|
175
|
+
*/
|
|
118
176
|
export declare const GREASE_VALUES: readonly number[];
|
|
119
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Returns a deterministic GREASE value selected by `seed`, cycling through
|
|
179
|
+
* the 16 GREASE values defined in RFC 8701.
|
|
180
|
+
*
|
|
181
|
+
* @param {number} seed - Arbitrary integer used to select the GREASE value.
|
|
182
|
+
* @returns {number} A GREASE value from the GREASE_VALUES array.
|
|
183
|
+
*/
|
|
120
184
|
export declare function greaseValue(seed: number): number;
|
|
185
|
+
/**
|
|
186
|
+
* TLS alert description codes (RFC 8446 Appendix B.2). Used to interpret
|
|
187
|
+
* alert records received from the server during or after the handshake.
|
|
188
|
+
*
|
|
189
|
+
* @enum {number}
|
|
190
|
+
*/
|
|
121
191
|
export declare const AlertDescription: {
|
|
122
192
|
readonly CLOSE_NOTIFY: 0;
|
|
123
193
|
readonly UNEXPECTED_MESSAGE: 10;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/tls/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/tls/constants.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;CAYhB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;CAoBd,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;CAyBhB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;CAUb,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAiBlB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;CAEhB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAG1C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;CAoBnB,CAAC"}
|