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
package/dist/core/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAuB,MAAM,cAAc,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,MAA4B;IACxD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAAoB;IAChD,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,oBAAoB,CAAC,KAAK,CA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ate library faults from generic exceptions with a single
|
|
6
|
-
* instanceof check.
|
|
2
|
+
* Base error class for all NLcURL library errors. All library-specific
|
|
3
|
+
* errors extend this class, allowing callers to distinguish NLcURL failures
|
|
4
|
+
* from native Node.js or third-party errors via `instanceof NLcURLError`.
|
|
7
5
|
*/
|
|
8
6
|
export declare class NLcURLError extends Error {
|
|
7
|
+
/** Machine-readable error code string (e.g. `"ERR_TLS"`, `"ERR_TIMEOUT"`). */
|
|
9
8
|
readonly code: string;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new NLcURLError instance.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} message - Human-readable description of the error.
|
|
13
|
+
* @param {string} code - Machine-readable error code identifying the failure category.
|
|
14
|
+
*/
|
|
10
15
|
constructor(message: string, code: string);
|
|
11
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Raised when a TLS handshake fails, a certificate is invalid, or any other
|
|
19
|
+
* TLS-layer error occurs during connection establishment or data transfer.
|
|
20
|
+
*/
|
|
12
21
|
export declare class TLSError extends NLcURLError {
|
|
22
|
+
/** TLS alert description code from RFC 8446, if the server sent an Alert record. */
|
|
13
23
|
readonly alertCode?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new TLSError instance.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} message - Human-readable description of the TLS failure.
|
|
28
|
+
* @param {number} [alertCode] - Optional TLS alert description code (RFC 8446 §6).
|
|
29
|
+
*/
|
|
14
30
|
constructor(message: string, alertCode?: number);
|
|
15
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Raised when an HTTP-level error occurs, such as a protocol violation or a
|
|
34
|
+
* connection close before the response is complete. This is distinct from
|
|
35
|
+
* non-2xx responses, which are returned as successful `NLcURLResponse` objects.
|
|
36
|
+
*/
|
|
16
37
|
export declare class HTTPError extends NLcURLError {
|
|
38
|
+
/** The HTTP status code associated with the error, or `0` if unavailable. */
|
|
17
39
|
readonly statusCode: number;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new HTTPError instance.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} message - Human-readable description of the HTTP error.
|
|
44
|
+
* @param {number} statusCode - The HTTP status code, or `0` if none applies.
|
|
45
|
+
*/
|
|
18
46
|
constructor(message: string, statusCode: number);
|
|
19
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Raised when a request exceeds a configured timeout limit. The `phase`
|
|
50
|
+
* property identifies which stage of the request lifecycle timed out.
|
|
51
|
+
*/
|
|
20
52
|
export declare class TimeoutError extends NLcURLError {
|
|
53
|
+
/**
|
|
54
|
+
* The lifecycle phase in which the timeout occurred.
|
|
55
|
+
*
|
|
56
|
+
* - `"connect"` — TCP connection establishment exceeded the limit.
|
|
57
|
+
* - `"tls"` — TLS handshake exceeded the limit.
|
|
58
|
+
* - `"response"` — Waiting for the first response byte exceeded the limit.
|
|
59
|
+
* - `"total"` — The overall wall-clock duration exceeded the limit.
|
|
60
|
+
*/
|
|
21
61
|
readonly phase: 'connect' | 'tls' | 'response' | 'total';
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new TimeoutError instance.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} message - Human-readable description.
|
|
66
|
+
* @param {'connect'|'tls'|'response'|'total'} phase - The phase that timed out.
|
|
67
|
+
*/
|
|
22
68
|
constructor(message: string, phase: 'connect' | 'tls' | 'response' | 'total');
|
|
23
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Raised when a proxy connection fails, including CONNECT tunnel failures,
|
|
72
|
+
* authentication rejections, SOCKS negotiation errors, and TCP-level timeouts
|
|
73
|
+
* while reaching the proxy server.
|
|
74
|
+
*/
|
|
24
75
|
export declare class ProxyError extends NLcURLError {
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new ProxyError instance.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} message - Human-readable description of the proxy failure.
|
|
80
|
+
*/
|
|
25
81
|
constructor(message: string);
|
|
26
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Raised when a request is cancelled via an `AbortSignal`. Unlike other
|
|
85
|
+
* errors, an `AbortError` is never retried — it propagates immediately.
|
|
86
|
+
*/
|
|
27
87
|
export declare class AbortError extends NLcURLError {
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new AbortError instance.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} [message='Request aborted'] - Human-readable description.
|
|
92
|
+
*/
|
|
28
93
|
constructor(message?: string);
|
|
29
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Raised when a TCP connection cannot be established or is unexpectedly reset
|
|
97
|
+
* before a response is received. This error is retryable according to the
|
|
98
|
+
* default retry policy.
|
|
99
|
+
*/
|
|
30
100
|
export declare class ConnectionError extends NLcURLError {
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new ConnectionError instance.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} message - Human-readable description of the connection failure.
|
|
105
|
+
*/
|
|
31
106
|
constructor(message: string);
|
|
32
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Raised when an HTTP/2 or HTTP/1.1 protocol violation is detected, such as
|
|
110
|
+
* an invalid frame, an unexpected stream state, or a GOAWAY from the server.
|
|
111
|
+
* Certain HTTP/2 error codes (e.g. `REFUSED_STREAM`) are retryable.
|
|
112
|
+
*/
|
|
33
113
|
export declare class ProtocolError extends NLcURLError {
|
|
34
|
-
|
|
114
|
+
/** The HTTP/2 error code (RFC 9113 §7), if this error originates from an H2 frame. */
|
|
115
|
+
readonly errorCode?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a new ProtocolError instance.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} message - Human-readable description of the protocol error.
|
|
120
|
+
* @param {number} [errorCode] - Optional HTTP/2 protocol error code (RFC 9113 §7).
|
|
121
|
+
*/
|
|
122
|
+
constructor(message: string, errorCode?: number);
|
|
35
123
|
}
|
|
36
124
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,8EAA8E;IAC9E,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAM1C;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,WAAW;IACvC,oFAAoF;IACpF,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAKhD;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,6EAA6E;IAC7E,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAKhD;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C;;;;;;;OAOG;IACH,SAAgB,KAAK,EAAE,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,CAAC;IAEhE;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO;CAK7E;AAED;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC;;;;OAIG;gBACS,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC;;;;OAIG;gBACS,OAAO,GAAE,MAA0B;CAIhD;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C;;;;OAIG;gBACS,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,sFAAsF;IACtF,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAKhD"}
|
package/dist/core/errors.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* discriminate library faults from generic exceptions with a single
|
|
6
|
-
* instanceof check.
|
|
2
|
+
* Base error class for all NLcURL library errors. All library-specific
|
|
3
|
+
* errors extend this class, allowing callers to distinguish NLcURL failures
|
|
4
|
+
* from native Node.js or third-party errors via `instanceof NLcURLError`.
|
|
7
5
|
*/
|
|
8
6
|
export class NLcURLError extends Error {
|
|
7
|
+
/** Machine-readable error code string (e.g. `"ERR_TLS"`, `"ERR_TIMEOUT"`). */
|
|
9
8
|
code;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new NLcURLError instance.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} message - Human-readable description of the error.
|
|
13
|
+
* @param {string} code - Machine-readable error code identifying the failure category.
|
|
14
|
+
*/
|
|
10
15
|
constructor(message, code) {
|
|
11
16
|
super(message);
|
|
12
17
|
this.name = 'NLcURLError';
|
|
@@ -14,52 +19,136 @@ export class NLcURLError extends Error {
|
|
|
14
19
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
15
20
|
}
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Raised when a TLS handshake fails, a certificate is invalid, or any other
|
|
24
|
+
* TLS-layer error occurs during connection establishment or data transfer.
|
|
25
|
+
*/
|
|
17
26
|
export class TLSError extends NLcURLError {
|
|
27
|
+
/** TLS alert description code from RFC 8446, if the server sent an Alert record. */
|
|
18
28
|
alertCode;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new TLSError instance.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} message - Human-readable description of the TLS failure.
|
|
33
|
+
* @param {number} [alertCode] - Optional TLS alert description code (RFC 8446 §6).
|
|
34
|
+
*/
|
|
19
35
|
constructor(message, alertCode) {
|
|
20
36
|
super(message, 'ERR_TLS');
|
|
21
37
|
this.name = 'TLSError';
|
|
22
38
|
this.alertCode = alertCode;
|
|
23
39
|
}
|
|
24
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Raised when an HTTP-level error occurs, such as a protocol violation or a
|
|
43
|
+
* connection close before the response is complete. This is distinct from
|
|
44
|
+
* non-2xx responses, which are returned as successful `NLcURLResponse` objects.
|
|
45
|
+
*/
|
|
25
46
|
export class HTTPError extends NLcURLError {
|
|
47
|
+
/** The HTTP status code associated with the error, or `0` if unavailable. */
|
|
26
48
|
statusCode;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new HTTPError instance.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} message - Human-readable description of the HTTP error.
|
|
53
|
+
* @param {number} statusCode - The HTTP status code, or `0` if none applies.
|
|
54
|
+
*/
|
|
27
55
|
constructor(message, statusCode) {
|
|
28
56
|
super(message, 'ERR_HTTP');
|
|
29
57
|
this.name = 'HTTPError';
|
|
30
58
|
this.statusCode = statusCode;
|
|
31
59
|
}
|
|
32
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Raised when a request exceeds a configured timeout limit. The `phase`
|
|
63
|
+
* property identifies which stage of the request lifecycle timed out.
|
|
64
|
+
*/
|
|
33
65
|
export class TimeoutError extends NLcURLError {
|
|
66
|
+
/**
|
|
67
|
+
* The lifecycle phase in which the timeout occurred.
|
|
68
|
+
*
|
|
69
|
+
* - `"connect"` — TCP connection establishment exceeded the limit.
|
|
70
|
+
* - `"tls"` — TLS handshake exceeded the limit.
|
|
71
|
+
* - `"response"` — Waiting for the first response byte exceeded the limit.
|
|
72
|
+
* - `"total"` — The overall wall-clock duration exceeded the limit.
|
|
73
|
+
*/
|
|
34
74
|
phase;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new TimeoutError instance.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} message - Human-readable description.
|
|
79
|
+
* @param {'connect'|'tls'|'response'|'total'} phase - The phase that timed out.
|
|
80
|
+
*/
|
|
35
81
|
constructor(message, phase) {
|
|
36
82
|
super(message, 'ERR_TIMEOUT');
|
|
37
83
|
this.name = 'TimeoutError';
|
|
38
84
|
this.phase = phase;
|
|
39
85
|
}
|
|
40
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Raised when a proxy connection fails, including CONNECT tunnel failures,
|
|
89
|
+
* authentication rejections, SOCKS negotiation errors, and TCP-level timeouts
|
|
90
|
+
* while reaching the proxy server.
|
|
91
|
+
*/
|
|
41
92
|
export class ProxyError extends NLcURLError {
|
|
93
|
+
/**
|
|
94
|
+
* Creates a new ProxyError instance.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} message - Human-readable description of the proxy failure.
|
|
97
|
+
*/
|
|
42
98
|
constructor(message) {
|
|
43
99
|
super(message, 'ERR_PROXY');
|
|
44
100
|
this.name = 'ProxyError';
|
|
45
101
|
}
|
|
46
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Raised when a request is cancelled via an `AbortSignal`. Unlike other
|
|
105
|
+
* errors, an `AbortError` is never retried — it propagates immediately.
|
|
106
|
+
*/
|
|
47
107
|
export class AbortError extends NLcURLError {
|
|
108
|
+
/**
|
|
109
|
+
* Creates a new AbortError instance.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} [message='Request aborted'] - Human-readable description.
|
|
112
|
+
*/
|
|
48
113
|
constructor(message = 'Request aborted') {
|
|
49
114
|
super(message, 'ERR_ABORTED');
|
|
50
115
|
this.name = 'AbortError';
|
|
51
116
|
}
|
|
52
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Raised when a TCP connection cannot be established or is unexpectedly reset
|
|
120
|
+
* before a response is received. This error is retryable according to the
|
|
121
|
+
* default retry policy.
|
|
122
|
+
*/
|
|
53
123
|
export class ConnectionError extends NLcURLError {
|
|
124
|
+
/**
|
|
125
|
+
* Creates a new ConnectionError instance.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} message - Human-readable description of the connection failure.
|
|
128
|
+
*/
|
|
54
129
|
constructor(message) {
|
|
55
130
|
super(message, 'ERR_CONNECTION');
|
|
56
131
|
this.name = 'ConnectionError';
|
|
57
132
|
}
|
|
58
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Raised when an HTTP/2 or HTTP/1.1 protocol violation is detected, such as
|
|
136
|
+
* an invalid frame, an unexpected stream state, or a GOAWAY from the server.
|
|
137
|
+
* Certain HTTP/2 error codes (e.g. `REFUSED_STREAM`) are retryable.
|
|
138
|
+
*/
|
|
59
139
|
export class ProtocolError extends NLcURLError {
|
|
60
|
-
|
|
140
|
+
/** The HTTP/2 error code (RFC 9113 §7), if this error originates from an H2 frame. */
|
|
141
|
+
errorCode;
|
|
142
|
+
/**
|
|
143
|
+
* Creates a new ProtocolError instance.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} message - Human-readable description of the protocol error.
|
|
146
|
+
* @param {number} [errorCode] - Optional HTTP/2 protocol error code (RFC 9113 §7).
|
|
147
|
+
*/
|
|
148
|
+
constructor(message, errorCode) {
|
|
61
149
|
super(message, 'ERR_PROTOCOL');
|
|
62
150
|
this.name = 'ProtocolError';
|
|
151
|
+
this.errorCode = errorCode;
|
|
63
152
|
}
|
|
64
153
|
}
|
|
65
154
|
//# sourceMappingURL=errors.js.map
|
package/dist/core/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,8EAA8E;IAC9D,IAAI,CAAS;IAE7B;;;;;OAKG;IACH,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,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AGG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC;;;;OAIG;IACH,YAAY,UAAkB,iBAAiB;QAC7C,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C;;;;OAIG;IACH,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,sFAAsF;IACtE,SAAS,CAAU;IAEnC;;;;;OAKG;IACH,YAAY,OAAe,EAAE,SAAkB;QAC7C,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/core/request.d.ts
CHANGED
|
@@ -1,30 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Union of all HTTP method strings accepted by the library.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'HEAD'|'OPTIONS'} HttpMethod
|
|
3
5
|
*/
|
|
4
6
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
7
|
+
/**
|
|
8
|
+
* Granular timing measurements recorded during a single request, in
|
|
9
|
+
* milliseconds elapsed from request initiation.
|
|
10
|
+
*
|
|
11
|
+
* @typedef {Object} RequestTimings
|
|
12
|
+
* @property {number} dns - Time spent resolving the hostname via DNS.
|
|
13
|
+
* @property {number} connect - Time spent establishing the TCP connection.
|
|
14
|
+
* @property {number} tls - Time spent completing the TLS handshake.
|
|
15
|
+
* @property {number} firstByte - Time from connection open to the first response byte received.
|
|
16
|
+
* @property {number} total - Total wall-clock time for the entire request.
|
|
17
|
+
*/
|
|
5
18
|
export interface RequestTimings {
|
|
6
|
-
/** Milliseconds from start to DNS lookup completion. */
|
|
7
19
|
dns: number;
|
|
8
|
-
/** Milliseconds from start to TCP connection established. */
|
|
9
20
|
connect: number;
|
|
10
|
-
/** Milliseconds from start to TLS handshake completed. */
|
|
11
21
|
tls: number;
|
|
12
|
-
/** Milliseconds from start to first byte received. */
|
|
13
22
|
firstByte: number;
|
|
14
|
-
/** Milliseconds total. */
|
|
15
23
|
total: number;
|
|
16
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Per-phase timeout limits for a single request, in milliseconds. Omitting
|
|
27
|
+
* a field means no limit is applied for that phase.
|
|
28
|
+
*
|
|
29
|
+
* @typedef {Object} TimeoutConfig
|
|
30
|
+
* @property {number} [connect] - Maximum milliseconds to establish the TCP connection.
|
|
31
|
+
* @property {number} [tls] - Maximum milliseconds to complete the TLS handshake.
|
|
32
|
+
* @property {number} [response] - Maximum milliseconds to receive the first response byte.
|
|
33
|
+
* @property {number} [total] - Maximum total milliseconds for the whole request.
|
|
34
|
+
*/
|
|
17
35
|
export interface TimeoutConfig {
|
|
18
|
-
/** TCP connect timeout in milliseconds. */
|
|
19
36
|
connect?: number;
|
|
20
|
-
/** TLS handshake timeout in milliseconds. */
|
|
21
37
|
tls?: number;
|
|
22
|
-
/** Time to first byte timeout in milliseconds. */
|
|
23
38
|
response?: number;
|
|
24
|
-
/** Total request timeout in milliseconds. */
|
|
25
39
|
total?: number;
|
|
26
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Accepted body types for an outgoing request. Arrays, plain objects, and
|
|
43
|
+
* plain strings are serialized automatically; raw `Buffer`s and
|
|
44
|
+
* `URLSearchParams` are used verbatim.
|
|
45
|
+
*
|
|
46
|
+
* @typedef {string|Buffer|URLSearchParams|Record<string,unknown>|ReadableStream<Uint8Array>|null} RequestBody
|
|
47
|
+
*/
|
|
27
48
|
export type RequestBody = string | Buffer | URLSearchParams | Record<string, unknown> | ReadableStream<Uint8Array> | null;
|
|
49
|
+
/**
|
|
50
|
+
* Describes a single HTTP request. All options at the request level override
|
|
51
|
+
* any matching session-level defaults set on {@link NLcURLSessionConfig}.
|
|
52
|
+
*
|
|
53
|
+
* @typedef {Object} NLcURLRequest
|
|
54
|
+
* @property {string} url - Absolute or relative URL to request.
|
|
55
|
+
* @property {HttpMethod} [method='GET'] - HTTP method.
|
|
56
|
+
* @property {Record<string,string>} [headers] - Request headers to merge with session defaults.
|
|
57
|
+
* @property {RequestBody} [body] - Request body payload.
|
|
58
|
+
* @property {number|TimeoutConfig} [timeout] - Timeout in ms (flat) or per-phase config object.
|
|
59
|
+
* @property {AbortSignal} [signal] - Signal used to cancel the request early.
|
|
60
|
+
* @property {string} [impersonate] - Browser profile name (e.g. `"chrome136"`).
|
|
61
|
+
* @property {string} [ja3] - Custom JA3 fingerprint string override.
|
|
62
|
+
* @property {string} [akamai] - Custom Akamai HTTP/2 fingerprint override.
|
|
63
|
+
* @property {boolean} [stealth] - Use the custom stealth TLS engine.
|
|
64
|
+
* @property {boolean} [followRedirects=true] - Follow HTTP redirects automatically.
|
|
65
|
+
* @property {number} [maxRedirects=20] - Maximum number of redirects to follow.
|
|
66
|
+
* @property {boolean} [insecure] - Skip TLS certificate verification.
|
|
67
|
+
* @property {string} [proxy] - Proxy URL (`http://`, `socks4://`, `socks5://`).
|
|
68
|
+
* @property {[string,string]} [proxyAuth] - Proxy credentials as `[username, password]`.
|
|
69
|
+
* @property {'1.1'|'2'} [httpVersion] - Force a specific HTTP protocol version.
|
|
70
|
+
* @property {string} [baseURL] - Base URL prepended to relative `url` values.
|
|
71
|
+
* @property {Record<string,string|number|boolean>} [params] - Query parameters appended to the URL.
|
|
72
|
+
* @property {boolean|string} [cookieJar] - Enable a per-request cookie jar.
|
|
73
|
+
* @property {string} [acceptEncoding] - Override the `Accept-Encoding` header value.
|
|
74
|
+
* @property {string[]} [headerOrder] - Explicit header ordering for fingerprinting.
|
|
75
|
+
* @property {4|6} [dnsFamily] - Force IPv4 (`4`) or IPv6 (`6`) DNS resolution.
|
|
76
|
+
* @property {boolean} [stream] - Return a streaming response body.
|
|
77
|
+
*/
|
|
28
78
|
export interface NLcURLRequest {
|
|
29
79
|
url: string;
|
|
30
80
|
method?: HttpMethod;
|
|
@@ -32,49 +82,64 @@ export interface NLcURLRequest {
|
|
|
32
82
|
body?: RequestBody;
|
|
33
83
|
timeout?: number | TimeoutConfig;
|
|
34
84
|
signal?: AbortSignal;
|
|
35
|
-
/** Browser profile name to impersonate, e.g. "chrome136", "firefox135". */
|
|
36
85
|
impersonate?: string;
|
|
37
|
-
/** Custom JA3 fingerprint string. Overrides profile TLS settings. */
|
|
38
86
|
ja3?: string;
|
|
39
|
-
/** Custom Akamai HTTP/2 fingerprint string. Overrides profile h2 settings. */
|
|
40
87
|
akamai?: string;
|
|
41
|
-
/** Use stealth TLS engine for byte-level ClientHello control. */
|
|
42
88
|
stealth?: boolean;
|
|
43
|
-
/** Follow redirects. Default: true. */
|
|
44
89
|
followRedirects?: boolean;
|
|
45
|
-
/** Maximum number of redirects to follow. Default: 20. */
|
|
46
90
|
maxRedirects?: number;
|
|
47
|
-
/** Skip TLS certificate verification. Default: false. */
|
|
48
91
|
insecure?: boolean;
|
|
49
|
-
/** Proxy URL (http, https, socks4, socks5). */
|
|
50
92
|
proxy?: string;
|
|
51
|
-
/** Proxy authentication as [username, password]. */
|
|
52
93
|
proxyAuth?: [string, string];
|
|
53
|
-
/** Force HTTP version: "1.1" or "2". */
|
|
54
94
|
httpVersion?: '1.1' | '2';
|
|
55
|
-
/** Base URL prepended to relative URLs. */
|
|
56
95
|
baseURL?: string;
|
|
57
|
-
/** Query parameters merged into the URL. */
|
|
58
96
|
params?: Record<string, string | number | boolean>;
|
|
59
|
-
/** Cookie jar instance or boolean to enable automatic cookie management. */
|
|
60
97
|
cookieJar?: boolean | string;
|
|
61
|
-
/** Accept-Encoding. Default: "gzip, deflate, br". */
|
|
62
98
|
acceptEncoding?: string;
|
|
63
|
-
/** Extra header ordering hint, if the profile needs headers in exact order. */
|
|
64
99
|
headerOrder?: string[];
|
|
100
|
+
dnsFamily?: 4 | 6;
|
|
101
|
+
stream?: boolean;
|
|
65
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Configuration for automatic request retry with backoff.
|
|
105
|
+
*
|
|
106
|
+
* @typedef {Object} RetryConfig
|
|
107
|
+
* @property {number} count - Maximum number of retry attempts after the initial request.
|
|
108
|
+
* @property {number} delay - Base delay in milliseconds between attempts.
|
|
109
|
+
* @property {'linear'|'exponential'} backoff - Strategy for increasing the delay on repeated failures.
|
|
110
|
+
* @property {number} jitter - Maximum random jitter in milliseconds added to each delay.
|
|
111
|
+
* @property {Function} [retryOn] - Optional predicate; return `true` to allow a retry.
|
|
112
|
+
*/
|
|
66
113
|
export interface RetryConfig {
|
|
67
|
-
/** Number of retry attempts. Default: 0. */
|
|
68
114
|
count: number;
|
|
69
|
-
/** Base delay in milliseconds between retries. Default: 1000. */
|
|
70
115
|
delay: number;
|
|
71
|
-
/** Backoff strategy. Default: "exponential". */
|
|
72
116
|
backoff: 'linear' | 'exponential';
|
|
73
|
-
/** Maximum random jitter in milliseconds added to each delay. Default: 200. */
|
|
74
117
|
jitter: number;
|
|
75
|
-
/** Predicate to decide whether to retry. */
|
|
76
118
|
retryOn?: (error: Error | null, statusCode?: number) => boolean;
|
|
77
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Session-level defaults applied to every request issued through an
|
|
122
|
+
* {@link NLcURLSession}. Individual request options always take precedence.
|
|
123
|
+
*
|
|
124
|
+
* @typedef {Object} NLcURLSessionConfig
|
|
125
|
+
* @property {string} [baseURL] - Base URL prepended to relative request URLs.
|
|
126
|
+
* @property {Record<string,string>} [headers] - Headers merged into every request.
|
|
127
|
+
* @property {number|TimeoutConfig} [timeout] - Default timeout applied to all requests.
|
|
128
|
+
* @property {string} [impersonate] - Default browser profile for fingerprinting.
|
|
129
|
+
* @property {string} [ja3] - Default JA3 fingerprint string.
|
|
130
|
+
* @property {string} [akamai] - Default Akamai HTTP/2 fingerprint.
|
|
131
|
+
* @property {boolean} [stealth] - Use the stealth TLS engine by default.
|
|
132
|
+
* @property {string} [proxy] - Default proxy URL.
|
|
133
|
+
* @property {[string,string]} [proxyAuth] - Default proxy credentials.
|
|
134
|
+
* @property {boolean} [followRedirects=true] - Follow redirects by default.
|
|
135
|
+
* @property {number} [maxRedirects=20] - Default maximum redirect count.
|
|
136
|
+
* @property {boolean} [insecure] - Skip TLS verification by default.
|
|
137
|
+
* @property {'1.1'|'2'} [httpVersion] - Force an HTTP protocol version for all requests.
|
|
138
|
+
* @property {boolean|string} [cookieJar] - Persistent cookie jar for the session.
|
|
139
|
+
* @property {Partial<RetryConfig>} [retry] - Automatic retry configuration.
|
|
140
|
+
* @property {string} [acceptEncoding] - Default `Accept-Encoding` header value.
|
|
141
|
+
* @property {4|6} [dnsFamily] - Force IPv4 or IPv6 for DNS resolution.
|
|
142
|
+
*/
|
|
78
143
|
export interface NLcURLSessionConfig {
|
|
79
144
|
baseURL?: string;
|
|
80
145
|
headers?: Record<string, string>;
|
|
@@ -92,5 +157,6 @@ export interface NLcURLSessionConfig {
|
|
|
92
157
|
cookieJar?: boolean | string;
|
|
93
158
|
retry?: Partial<RetryConfig>;
|
|
94
159
|
acceptEncoding?: string;
|
|
160
|
+
dnsFamily?: 4 | 6;
|
|
95
161
|
}
|
|
96
162
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,G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C,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACnB"}
|
package/dist/core/request.js
CHANGED
package/dist/core/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":""}
|