nlcurl 0.3.1 → 0.4.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/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +84 -90
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/index.js +25 -25
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/output.d.ts +2 -2
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +55 -55
- package/dist/cli/output.js.map +1 -1
- package/dist/cookies/jar.d.ts +1 -1
- package/dist/cookies/jar.d.ts.map +1 -1
- package/dist/cookies/jar.js +20 -22
- package/dist/cookies/jar.js.map +1 -1
- package/dist/cookies/parser.d.ts +1 -1
- package/dist/cookies/parser.d.ts.map +1 -1
- package/dist/cookies/parser.js +20 -22
- package/dist/cookies/parser.js.map +1 -1
- package/dist/core/client.d.ts +3 -3
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +9 -8
- package/dist/core/client.js.map +1 -1
- package/dist/core/errors.d.ts +64 -21
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +112 -36
- package/dist/core/errors.js.map +1 -1
- package/dist/core/request.d.ts +10 -5
- package/dist/core/request.d.ts.map +1 -1
- package/dist/core/response.d.ts +2 -2
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +6 -8
- package/dist/core/response.js.map +1 -1
- package/dist/core/session.d.ts +7 -6
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +58 -43
- package/dist/core/session.js.map +1 -1
- package/dist/core/validation.d.ts +96 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +246 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/fingerprints/akamai.d.ts +1 -1
- package/dist/fingerprints/akamai.d.ts.map +1 -1
- package/dist/fingerprints/akamai.js +3 -7
- package/dist/fingerprints/akamai.js.map +1 -1
- package/dist/fingerprints/database.d.ts +7 -7
- package/dist/fingerprints/database.d.ts.map +1 -1
- package/dist/fingerprints/database.js +12 -18
- package/dist/fingerprints/database.js.map +1 -1
- package/dist/fingerprints/extensions.d.ts.map +1 -1
- package/dist/fingerprints/extensions.js +4 -4
- package/dist/fingerprints/extensions.js.map +1 -1
- package/dist/fingerprints/ja3.d.ts +1 -1
- package/dist/fingerprints/ja3.d.ts.map +1 -1
- package/dist/fingerprints/ja3.js +12 -12
- package/dist/fingerprints/ja3.js.map +1 -1
- package/dist/fingerprints/profiles/chrome.d.ts +1 -1
- package/dist/fingerprints/profiles/chrome.d.ts.map +1 -1
- package/dist/fingerprints/profiles/chrome.js +59 -100
- package/dist/fingerprints/profiles/chrome.js.map +1 -1
- package/dist/fingerprints/profiles/edge.d.ts +1 -1
- package/dist/fingerprints/profiles/edge.d.ts.map +1 -1
- package/dist/fingerprints/profiles/edge.js +26 -26
- package/dist/fingerprints/profiles/edge.js.map +1 -1
- package/dist/fingerprints/profiles/firefox.d.ts +1 -1
- package/dist/fingerprints/profiles/firefox.d.ts.map +1 -1
- package/dist/fingerprints/profiles/firefox.js +35 -85
- package/dist/fingerprints/profiles/firefox.js.map +1 -1
- package/dist/fingerprints/profiles/safari.d.ts +1 -1
- package/dist/fingerprints/profiles/safari.d.ts.map +1 -1
- package/dist/fingerprints/profiles/safari.js +35 -68
- package/dist/fingerprints/profiles/safari.js.map +1 -1
- package/dist/fingerprints/profiles/tor.d.ts +1 -1
- package/dist/fingerprints/profiles/tor.d.ts.map +1 -1
- package/dist/fingerprints/profiles/tor.js +24 -57
- package/dist/fingerprints/profiles/tor.js.map +1 -1
- package/dist/fingerprints/types.d.ts +1 -1
- package/dist/fingerprints/types.d.ts.map +1 -1
- package/dist/http/h1/client.d.ts +4 -4
- package/dist/http/h1/client.d.ts.map +1 -1
- package/dist/http/h1/client.js +31 -31
- package/dist/http/h1/client.js.map +1 -1
- package/dist/http/h1/encoder.d.ts +1 -1
- package/dist/http/h1/encoder.d.ts.map +1 -1
- package/dist/http/h1/encoder.js +17 -19
- package/dist/http/h1/encoder.js.map +1 -1
- package/dist/http/h1/parser.d.ts +1 -1
- package/dist/http/h1/parser.d.ts.map +1 -1
- package/dist/http/h1/parser.js +29 -33
- package/dist/http/h1/parser.js.map +1 -1
- package/dist/http/h2/client.d.ts +5 -4
- package/dist/http/h2/client.d.ts.map +1 -1
- package/dist/http/h2/client.js +59 -71
- package/dist/http/h2/client.js.map +1 -1
- package/dist/http/h2/frames.d.ts +7 -3
- package/dist/http/h2/frames.d.ts.map +1 -1
- package/dist/http/h2/frames.js +16 -12
- package/dist/http/h2/frames.js.map +1 -1
- package/dist/http/h2/hpack.d.ts.map +1 -1
- package/dist/http/h2/hpack.js +328 -130
- package/dist/http/h2/hpack.js.map +1 -1
- package/dist/http/negotiator.d.ts +4 -4
- package/dist/http/negotiator.d.ts.map +1 -1
- package/dist/http/negotiator.js +26 -39
- package/dist/http/negotiator.js.map +1 -1
- package/dist/http/pool.d.ts +5 -5
- package/dist/http/pool.d.ts.map +1 -1
- package/dist/http/pool.js +5 -5
- package/dist/http/pool.js.map +1 -1
- package/dist/index.d.ts +16 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/middleware/interceptor.d.ts +2 -2
- package/dist/middleware/interceptor.d.ts.map +1 -1
- package/dist/middleware/interceptor.js.map +1 -1
- package/dist/middleware/rate-limiter.d.ts.map +1 -1
- package/dist/middleware/rate-limiter.js +2 -0
- package/dist/middleware/rate-limiter.js.map +1 -1
- package/dist/middleware/retry.d.ts +6 -4
- package/dist/middleware/retry.d.ts.map +1 -1
- package/dist/middleware/retry.js +9 -7
- package/dist/middleware/retry.js.map +1 -1
- package/dist/proxy/http-proxy.d.ts +1 -1
- package/dist/proxy/http-proxy.d.ts.map +1 -1
- package/dist/proxy/http-proxy.js +14 -14
- package/dist/proxy/http-proxy.js.map +1 -1
- package/dist/proxy/socks.d.ts +1 -1
- package/dist/proxy/socks.d.ts.map +1 -1
- package/dist/proxy/socks.js +31 -27
- package/dist/proxy/socks.js.map +1 -1
- package/dist/tls/constants.d.ts.map +1 -1
- package/dist/tls/constants.js +1 -4
- package/dist/tls/constants.js.map +1 -1
- package/dist/tls/node-engine.d.ts +2 -2
- package/dist/tls/node-engine.d.ts.map +1 -1
- package/dist/tls/node-engine.js +58 -58
- package/dist/tls/node-engine.js.map +1 -1
- package/dist/tls/stealth/client-hello.d.ts +1 -1
- package/dist/tls/stealth/client-hello.d.ts.map +1 -1
- package/dist/tls/stealth/client-hello.js +8 -14
- package/dist/tls/stealth/client-hello.js.map +1 -1
- package/dist/tls/stealth/engine.d.ts +2 -2
- package/dist/tls/stealth/engine.d.ts.map +1 -1
- package/dist/tls/stealth/engine.js +23 -26
- package/dist/tls/stealth/engine.js.map +1 -1
- package/dist/tls/stealth/handshake.d.ts +3 -3
- package/dist/tls/stealth/handshake.d.ts.map +1 -1
- package/dist/tls/stealth/handshake.js +62 -74
- package/dist/tls/stealth/handshake.js.map +1 -1
- package/dist/tls/stealth/key-schedule.d.ts +2 -2
- package/dist/tls/stealth/key-schedule.d.ts.map +1 -1
- package/dist/tls/stealth/key-schedule.js +20 -20
- package/dist/tls/stealth/key-schedule.js.map +1 -1
- package/dist/tls/stealth/record-layer.d.ts +1 -1
- package/dist/tls/stealth/record-layer.d.ts.map +1 -1
- package/dist/tls/stealth/record-layer.js +13 -13
- package/dist/tls/stealth/record-layer.js.map +1 -1
- package/dist/tls/types.d.ts +4 -4
- package/dist/tls/types.d.ts.map +1 -1
- package/dist/utils/buffer-reader.d.ts.map +1 -1
- package/dist/utils/buffer-reader.js.map +1 -1
- package/dist/utils/buffer-writer.d.ts.map +1 -1
- package/dist/utils/buffer-writer.js +6 -0
- package/dist/utils/buffer-writer.js.map +1 -1
- package/dist/utils/encoding.d.ts +1 -1
- package/dist/utils/encoding.d.ts.map +1 -1
- package/dist/utils/encoding.js +23 -25
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/logger.d.ts +48 -7
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +61 -13
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +2 -2
- package/dist/utils/url.js.map +1 -1
- package/dist/ws/client.d.ts +2 -2
- package/dist/ws/client.d.ts.map +1 -1
- package/dist/ws/client.js +67 -71
- package/dist/ws/client.js.map +1 -1
- package/dist/ws/frame.d.ts.map +1 -1
- package/dist/ws/frame.js +8 -8
- package/dist/ws/frame.js.map +1 -1
- package/package.json +60 -57
package/dist/core/errors.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Base error class for all NLcURL library errors. All library-specific
|
|
3
3
|
* errors extend this class, allowing callers to distinguish NLcURL failures
|
|
4
4
|
* from native Node.js or third-party errors via `instanceof NLcURLError`.
|
|
5
|
+
*
|
|
6
|
+
* Supports ES2022 error chaining through the standard `cause` property.
|
|
7
|
+
* When wrapping a lower-level error, pass it as the `cause` parameter to
|
|
8
|
+
* preserve the full error chain for diagnostics.
|
|
5
9
|
*/
|
|
6
10
|
export class NLcURLError extends Error {
|
|
7
11
|
/** Machine-readable error code string (e.g. `"ERR_TLS"`, `"ERR_TIMEOUT"`). */
|
|
@@ -11,13 +15,34 @@ export class NLcURLError extends Error {
|
|
|
11
15
|
*
|
|
12
16
|
* @param {string} message - Human-readable description of the error.
|
|
13
17
|
* @param {string} code - Machine-readable error code identifying the failure category.
|
|
18
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
14
19
|
*/
|
|
15
|
-
constructor(message, code) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name =
|
|
20
|
+
constructor(message, code, cause) {
|
|
21
|
+
super(message, cause ? { cause } : undefined);
|
|
22
|
+
this.name = "NLcURLError";
|
|
18
23
|
this.code = code;
|
|
19
24
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Serializes the error into a plain object suitable for structured logging
|
|
28
|
+
* or JSON API responses. Recursively serializes the `cause` chain.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
31
|
+
*/
|
|
32
|
+
toJSON() {
|
|
33
|
+
const obj = {
|
|
34
|
+
name: this.name,
|
|
35
|
+
code: this.code,
|
|
36
|
+
message: this.message,
|
|
37
|
+
};
|
|
38
|
+
if (this.stack) {
|
|
39
|
+
obj["stack"] = this.stack;
|
|
40
|
+
}
|
|
41
|
+
if (this.cause instanceof Error) {
|
|
42
|
+
obj["cause"] = this.cause instanceof NLcURLError ? this.cause.toJSON() : { name: this.cause.name, message: this.cause.message, stack: this.cause.stack };
|
|
43
|
+
}
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
21
46
|
}
|
|
22
47
|
/**
|
|
23
48
|
* Raised when a TLS handshake fails, a certificate is invalid, or any other
|
|
@@ -29,14 +54,27 @@ export class TLSError extends NLcURLError {
|
|
|
29
54
|
/**
|
|
30
55
|
* Creates a new TLSError instance.
|
|
31
56
|
*
|
|
32
|
-
* @param {string} message
|
|
33
|
-
* @param {number} [alertCode]
|
|
57
|
+
* @param {string} message - Human-readable description of the TLS failure.
|
|
58
|
+
* @param {number} [alertCode] - Optional TLS alert description code (RFC 8446 section 6).
|
|
59
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
34
60
|
*/
|
|
35
|
-
constructor(message, alertCode) {
|
|
36
|
-
super(message,
|
|
37
|
-
this.name =
|
|
61
|
+
constructor(message, alertCode, cause) {
|
|
62
|
+
super(message, "ERR_TLS", cause);
|
|
63
|
+
this.name = "TLSError";
|
|
38
64
|
this.alertCode = alertCode;
|
|
39
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Serializes the error including the TLS alert code.
|
|
68
|
+
*
|
|
69
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
70
|
+
*/
|
|
71
|
+
toJSON() {
|
|
72
|
+
const obj = super.toJSON();
|
|
73
|
+
if (this.alertCode !== undefined) {
|
|
74
|
+
obj["alertCode"] = this.alertCode;
|
|
75
|
+
}
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
40
78
|
}
|
|
41
79
|
/**
|
|
42
80
|
* Raised when an HTTP-level error occurs, such as a protocol violation or a
|
|
@@ -51,12 +89,23 @@ export class HTTPError extends NLcURLError {
|
|
|
51
89
|
*
|
|
52
90
|
* @param {string} message - Human-readable description of the HTTP error.
|
|
53
91
|
* @param {number} statusCode - The HTTP status code, or `0` if none applies.
|
|
92
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
54
93
|
*/
|
|
55
|
-
constructor(message, statusCode) {
|
|
56
|
-
super(message,
|
|
57
|
-
this.name =
|
|
94
|
+
constructor(message, statusCode, cause) {
|
|
95
|
+
super(message, "ERR_HTTP", cause);
|
|
96
|
+
this.name = "HTTPError";
|
|
58
97
|
this.statusCode = statusCode;
|
|
59
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Serializes the error including the HTTP status code.
|
|
101
|
+
*
|
|
102
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
103
|
+
*/
|
|
104
|
+
toJSON() {
|
|
105
|
+
const obj = super.toJSON();
|
|
106
|
+
obj["statusCode"] = this.statusCode;
|
|
107
|
+
return obj;
|
|
108
|
+
}
|
|
60
109
|
}
|
|
61
110
|
/**
|
|
62
111
|
* Raised when a request exceeds a configured timeout limit. The `phase`
|
|
@@ -66,23 +115,34 @@ export class TimeoutError extends NLcURLError {
|
|
|
66
115
|
/**
|
|
67
116
|
* The lifecycle phase in which the timeout occurred.
|
|
68
117
|
*
|
|
69
|
-
* - `"connect"`
|
|
70
|
-
* - `"tls"`
|
|
71
|
-
* - `"response"`
|
|
72
|
-
* - `"total"`
|
|
118
|
+
* - `"connect"` -- TCP connection establishment exceeded the limit.
|
|
119
|
+
* - `"tls"` -- TLS handshake exceeded the limit.
|
|
120
|
+
* - `"response"` -- Waiting for the first response byte exceeded the limit.
|
|
121
|
+
* - `"total"` -- The overall wall-clock duration exceeded the limit.
|
|
73
122
|
*/
|
|
74
123
|
phase;
|
|
75
124
|
/**
|
|
76
125
|
* Creates a new TimeoutError instance.
|
|
77
126
|
*
|
|
78
|
-
* @param {string}
|
|
79
|
-
* @param {'connect'|'tls'|'response'|'total'} phase
|
|
127
|
+
* @param {string} message - Human-readable description.
|
|
128
|
+
* @param {'connect'|'tls'|'response'|'total'} phase - The phase that timed out.
|
|
129
|
+
* @param {Error} [cause] - Optional underlying error.
|
|
80
130
|
*/
|
|
81
|
-
constructor(message, phase) {
|
|
82
|
-
super(message,
|
|
83
|
-
this.name =
|
|
131
|
+
constructor(message, phase, cause) {
|
|
132
|
+
super(message, "ERR_TIMEOUT", cause);
|
|
133
|
+
this.name = "TimeoutError";
|
|
84
134
|
this.phase = phase;
|
|
85
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Serializes the error including the timeout phase.
|
|
138
|
+
*
|
|
139
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
140
|
+
*/
|
|
141
|
+
toJSON() {
|
|
142
|
+
const obj = super.toJSON();
|
|
143
|
+
obj["phase"] = this.phase;
|
|
144
|
+
return obj;
|
|
145
|
+
}
|
|
86
146
|
}
|
|
87
147
|
/**
|
|
88
148
|
* Raised when a proxy connection fails, including CONNECT tunnel failures,
|
|
@@ -94,25 +154,27 @@ export class ProxyError extends NLcURLError {
|
|
|
94
154
|
* Creates a new ProxyError instance.
|
|
95
155
|
*
|
|
96
156
|
* @param {string} message - Human-readable description of the proxy failure.
|
|
157
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
97
158
|
*/
|
|
98
|
-
constructor(message) {
|
|
99
|
-
super(message,
|
|
100
|
-
this.name =
|
|
159
|
+
constructor(message, cause) {
|
|
160
|
+
super(message, "ERR_PROXY", cause);
|
|
161
|
+
this.name = "ProxyError";
|
|
101
162
|
}
|
|
102
163
|
}
|
|
103
164
|
/**
|
|
104
165
|
* Raised when a request is cancelled via an `AbortSignal`. Unlike other
|
|
105
|
-
* errors, an `AbortError` is never retried
|
|
166
|
+
* errors, an `AbortError` is never retried -- it propagates immediately.
|
|
106
167
|
*/
|
|
107
168
|
export class AbortError extends NLcURLError {
|
|
108
169
|
/**
|
|
109
170
|
* Creates a new AbortError instance.
|
|
110
171
|
*
|
|
111
172
|
* @param {string} [message='Request aborted'] - Human-readable description.
|
|
173
|
+
* @param {Error} [cause] - Optional underlying error.
|
|
112
174
|
*/
|
|
113
|
-
constructor(message =
|
|
114
|
-
super(message,
|
|
115
|
-
this.name =
|
|
175
|
+
constructor(message = "Request aborted", cause) {
|
|
176
|
+
super(message, "ERR_ABORTED", cause);
|
|
177
|
+
this.name = "AbortError";
|
|
116
178
|
}
|
|
117
179
|
}
|
|
118
180
|
/**
|
|
@@ -125,10 +187,11 @@ export class ConnectionError extends NLcURLError {
|
|
|
125
187
|
* Creates a new ConnectionError instance.
|
|
126
188
|
*
|
|
127
189
|
* @param {string} message - Human-readable description of the connection failure.
|
|
190
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
128
191
|
*/
|
|
129
|
-
constructor(message) {
|
|
130
|
-
super(message,
|
|
131
|
-
this.name =
|
|
192
|
+
constructor(message, cause) {
|
|
193
|
+
super(message, "ERR_CONNECTION", cause);
|
|
194
|
+
this.name = "ConnectionError";
|
|
132
195
|
}
|
|
133
196
|
}
|
|
134
197
|
/**
|
|
@@ -137,18 +200,31 @@ export class ConnectionError extends NLcURLError {
|
|
|
137
200
|
* Certain HTTP/2 error codes (e.g. `REFUSED_STREAM`) are retryable.
|
|
138
201
|
*/
|
|
139
202
|
export class ProtocolError extends NLcURLError {
|
|
140
|
-
/** The HTTP/2 error code (RFC 9113
|
|
203
|
+
/** The HTTP/2 error code (RFC 9113 section 7), if this error originates from an H2 frame. */
|
|
141
204
|
errorCode;
|
|
142
205
|
/**
|
|
143
206
|
* Creates a new ProtocolError instance.
|
|
144
207
|
*
|
|
145
|
-
* @param {string} message
|
|
146
|
-
* @param {number} [errorCode]
|
|
208
|
+
* @param {string} message - Human-readable description of the protocol error.
|
|
209
|
+
* @param {number} [errorCode] - Optional HTTP/2 protocol error code (RFC 9113 section 7).
|
|
210
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
147
211
|
*/
|
|
148
|
-
constructor(message, errorCode) {
|
|
149
|
-
super(message,
|
|
150
|
-
this.name =
|
|
212
|
+
constructor(message, errorCode, cause) {
|
|
213
|
+
super(message, "ERR_PROTOCOL", cause);
|
|
214
|
+
this.name = "ProtocolError";
|
|
151
215
|
this.errorCode = errorCode;
|
|
152
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Serializes the error including the protocol error code.
|
|
219
|
+
*
|
|
220
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
221
|
+
*/
|
|
222
|
+
toJSON() {
|
|
223
|
+
const obj = super.toJSON();
|
|
224
|
+
if (this.errorCode !== undefined) {
|
|
225
|
+
obj["errorCode"] = this.errorCode;
|
|
226
|
+
}
|
|
227
|
+
return obj;
|
|
228
|
+
}
|
|
153
229
|
}
|
|
154
230
|
//# 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":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,8EAA8E;IAC9D,IAAI,CAAS;IAE7B;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,IAAY,EAAE,KAAa;QACtD,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAA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I,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC;;;;;OAKG;IACH,YAAY,UAAkB,iBAAiB,EAAE,KAAa;QAC5D,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C;;;;;OAKG;IACH,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,6FAA6F;IAC7E,SAAS,CAAU;IAEnC;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,SAAkB,EAAE,KAAa;QAC5D,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACM,MAAM;QACb,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,GAAG,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
package/dist/core/request.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { CookieJar } from
|
|
1
|
+
import type { CookieJar } from "../cookies/jar.js";
|
|
2
|
+
import type { Logger } from "../utils/logger.js";
|
|
2
3
|
/**
|
|
3
4
|
* Union of all HTTP method strings accepted by the library.
|
|
4
5
|
*
|
|
5
6
|
* @typedef {'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'HEAD'|'OPTIONS'} HttpMethod
|
|
6
7
|
*/
|
|
7
|
-
export type HttpMethod =
|
|
8
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
8
9
|
/**
|
|
9
10
|
* Granular timing measurements recorded during a single request, in
|
|
10
11
|
* milliseconds elapsed from request initiation.
|
|
@@ -75,6 +76,7 @@ export type RequestBody = string | Buffer | URLSearchParams | Record<string, unk
|
|
|
75
76
|
* @property {string[]} [headerOrder] - Explicit header ordering for fingerprinting.
|
|
76
77
|
* @property {4|6} [dnsFamily] - Force IPv4 (`4`) or IPv6 (`6`) DNS resolution.
|
|
77
78
|
* @property {boolean} [stream] - Return a streaming response body.
|
|
79
|
+
* @property {Logger} [logger] - Logger instance for request-scoped diagnostics.
|
|
78
80
|
*/
|
|
79
81
|
export interface NLcURLRequest {
|
|
80
82
|
url: string;
|
|
@@ -92,7 +94,7 @@ export interface NLcURLRequest {
|
|
|
92
94
|
insecure?: boolean;
|
|
93
95
|
proxy?: string;
|
|
94
96
|
proxyAuth?: [string, string];
|
|
95
|
-
httpVersion?:
|
|
97
|
+
httpVersion?: "1.1" | "2";
|
|
96
98
|
baseURL?: string;
|
|
97
99
|
params?: Record<string, string | number | boolean>;
|
|
98
100
|
cookieJar?: boolean | string | CookieJar;
|
|
@@ -100,6 +102,7 @@ export interface NLcURLRequest {
|
|
|
100
102
|
headerOrder?: string[];
|
|
101
103
|
dnsFamily?: 4 | 6;
|
|
102
104
|
stream?: boolean;
|
|
105
|
+
logger?: Logger;
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
105
108
|
* Configuration for automatic request retry with backoff.
|
|
@@ -114,7 +117,7 @@ export interface NLcURLRequest {
|
|
|
114
117
|
export interface RetryConfig {
|
|
115
118
|
count: number;
|
|
116
119
|
delay: number;
|
|
117
|
-
backoff:
|
|
120
|
+
backoff: "linear" | "exponential";
|
|
118
121
|
jitter: number;
|
|
119
122
|
retryOn?: (error: Error | null, statusCode?: number) => boolean;
|
|
120
123
|
}
|
|
@@ -140,6 +143,7 @@ export interface RetryConfig {
|
|
|
140
143
|
* @property {Partial<RetryConfig>} [retry] - Automatic retry configuration.
|
|
141
144
|
* @property {string} [acceptEncoding] - Default `Accept-Encoding` header value.
|
|
142
145
|
* @property {4|6} [dnsFamily] - Force IPv4 or IPv6 for DNS resolution.
|
|
146
|
+
* @property {Logger} [logger] - Logger instance for session-scoped diagnostics.
|
|
143
147
|
*/
|
|
144
148
|
export interface NLcURLSessionConfig {
|
|
145
149
|
baseURL?: string;
|
|
@@ -154,10 +158,11 @@ export interface NLcURLSessionConfig {
|
|
|
154
158
|
followRedirects?: boolean;
|
|
155
159
|
maxRedirects?: number;
|
|
156
160
|
insecure?: boolean;
|
|
157
|
-
httpVersion?:
|
|
161
|
+
httpVersion?: "1.1" | "2";
|
|
158
162
|
cookieJar?: boolean | string | CookieJar;
|
|
159
163
|
retry?: Partial<RetryConfig>;
|
|
160
164
|
acceptEncoding?: string;
|
|
161
165
|
dnsFamily?: 4 | 6;
|
|
166
|
+
logger?: Logger;
|
|
162
167
|
}
|
|
163
168
|
//# 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":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AA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1B,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,GAAG,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/core/response.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RequestTimings, HttpMethod } from
|
|
2
|
-
import type { Readable } from
|
|
1
|
+
import type { RequestTimings, HttpMethod } from "./request.js";
|
|
2
|
+
import type { Readable } from "node:stream";
|
|
3
3
|
/**
|
|
4
4
|
* Metadata about the originating request that produced a response.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,cAAc,CAAC,CAAC,GAAG,OAAO;IACrC,4CAA4C;IAC5C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,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AAI,MAAM;IAYd;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAUhB;;;;;OAKG;IACH,IAAI,aAAa,IAAI,MAAM,CAO1B;IAED;;;;;OAKG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;CAI/B"}
|
package/dist/core/response.js
CHANGED
|
@@ -77,11 +77,11 @@ export class NLcURLResponse {
|
|
|
77
77
|
*/
|
|
78
78
|
text() {
|
|
79
79
|
if (this.body) {
|
|
80
|
-
throw new Error(
|
|
80
|
+
throw new Error("Cannot read text from a streaming response. Consume the .body stream instead.");
|
|
81
81
|
}
|
|
82
82
|
let cached = this._text;
|
|
83
83
|
if (cached === undefined) {
|
|
84
|
-
cached = this.rawBody.toString(
|
|
84
|
+
cached = this.rawBody.toString("utf8");
|
|
85
85
|
this._text = cached;
|
|
86
86
|
}
|
|
87
87
|
return cached;
|
|
@@ -101,7 +101,7 @@ export class NLcURLResponse {
|
|
|
101
101
|
*/
|
|
102
102
|
json() {
|
|
103
103
|
if (this.body) {
|
|
104
|
-
throw new Error(
|
|
104
|
+
throw new Error("Cannot read JSON from a streaming response. Consume the .body stream instead.");
|
|
105
105
|
}
|
|
106
106
|
if (this._json === undefined) {
|
|
107
107
|
this._json = JSON.parse(this.text());
|
|
@@ -115,7 +115,7 @@ export class NLcURLResponse {
|
|
|
115
115
|
* @returns {number} The content length in bytes.
|
|
116
116
|
*/
|
|
117
117
|
get contentLength() {
|
|
118
|
-
const cl = this.headers[
|
|
118
|
+
const cl = this.headers["content-length"];
|
|
119
119
|
if (cl !== undefined) {
|
|
120
120
|
const n = parseInt(cl, 10);
|
|
121
121
|
if (!Number.isNaN(n))
|
|
@@ -130,7 +130,7 @@ export class NLcURLResponse {
|
|
|
130
130
|
* @returns {string} The `Content-Type` header value.
|
|
131
131
|
*/
|
|
132
132
|
get contentType() {
|
|
133
|
-
return this.headers[
|
|
133
|
+
return this.headers["content-type"] ?? "";
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Returns all values for a response header, in transmission order,
|
|
@@ -142,9 +142,7 @@ export class NLcURLResponse {
|
|
|
142
142
|
*/
|
|
143
143
|
getAll(name) {
|
|
144
144
|
const lower = name.toLowerCase();
|
|
145
|
-
return this.rawHeaders
|
|
146
|
-
.filter(([k]) => k.toLowerCase() === lower)
|
|
147
|
-
.map(([, v]) => v);
|
|
145
|
+
return this.rawHeaders.filter(([k]) => k.toLowerCase() === lower).map(([, v]) => v);
|
|
148
146
|
}
|
|
149
147
|
}
|
|
150
148
|
//# sourceMappingURL=response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IACzB,4CAA4C;IAC5B,MAAM,CAAS;IAC/B,qDAAqD;IACrC,UAAU,CAAS;IACnC,mFAAmF;IACnE,OAAO,CAAyB;IAChD,uFAAuF;IACvE,UAAU,CAA0B;IACpD,0FAA0F;IAC1E,OAAO,CAAS;IAChC,8EAA8E;IAC9D,IAAI,CAAkB;IACtC,sEAAsE;IACtD,WAAW,CAAS;IACpC,qDAAqD;IACrC,GAAG,CAAS;IAC5B,sEAAsE;IACtD,aAAa,CAAS;IACtC,4EAA4E;IAC5D,OAAO,CAAiB;IACxC,8CAA8C;IAC9B,OAAO,CAAe;IAE9B,KAAK,CAAgB;IACrB,KAAK,CAAqB;IAElC;;;;;;;;;;;;;;;OAeG;IACH,YAAY,IAAqQ;QAC/Q,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI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AAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,CAAC,KAAU,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,IAAI,aAAa;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC1C,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC5C,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAY;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CACF"}
|
package/dist/core/session.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { NLcURLRequest, NLcURLSessionConfig, RequestBody } from
|
|
2
|
-
import { NLcURLResponse } from
|
|
3
|
-
import { CookieJar } from
|
|
4
|
-
import { type RequestInterceptor, type ResponseInterceptor } from
|
|
5
|
-
import { type RateLimitConfig } from
|
|
1
|
+
import type { NLcURLRequest, NLcURLSessionConfig, RequestBody } from "./request.js";
|
|
2
|
+
import { NLcURLResponse } from "./response.js";
|
|
3
|
+
import { CookieJar } from "../cookies/jar.js";
|
|
4
|
+
import { type RequestInterceptor, type ResponseInterceptor } from "../middleware/interceptor.js";
|
|
5
|
+
import { type RateLimitConfig } from "../middleware/rate-limiter.js";
|
|
6
6
|
/**
|
|
7
7
|
* Request options that can be passed alongside a URL and HTTP method. All
|
|
8
8
|
* fields from {@link NLcURLRequest} except `url`, `method`, and `body`.
|
|
9
9
|
*
|
|
10
10
|
* @typedef {Omit<NLcURLRequest, 'url'|'method'|'body'>} RequestOptions
|
|
11
11
|
*/
|
|
12
|
-
export type RequestOptions = Omit<NLcURLRequest,
|
|
12
|
+
export type RequestOptions = Omit<NLcURLRequest, "url" | "method" | "body">;
|
|
13
13
|
/**
|
|
14
14
|
* Stateful HTTP client session that persists connections, cookies, interceptors,
|
|
15
15
|
* and configuration across multiple requests. Prefer using a session when making
|
|
@@ -25,6 +25,7 @@ export declare class NLcURLSession {
|
|
|
25
25
|
private readonly negotiator;
|
|
26
26
|
private readonly cookieJar;
|
|
27
27
|
private readonly interceptors;
|
|
28
|
+
private readonly logger;
|
|
28
29
|
private rateLimiter;
|
|
29
30
|
private closed;
|
|
30
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAA2B,WAAW,EAAiC,MAAM,cAAc,CAAC;AAC5I,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAoB,KAAK,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC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