nlcurl 0.3.0 → 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 +27 -33
- 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 +10 -8
- 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 +60 -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 +27 -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/cli/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,QAAwB,EAAE,IAAgB;IACrE,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAwB;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,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{"version":3,"file":"jar.d.ts","sourceRoot":"","sources":["../../src/cookies/jar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jar.d.ts","sourceRoot":"","sources":["../../src/cookies/jar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAK5E;;;;GAIG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;;;;;OAQG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAWxG;;;;;;;;OAQG;IACH,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;IAajC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;;OAKG;IACH,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC;IAI5B;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,gBAAgB,IAAI,MAAM;IAkB1B;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAyBzC,OAAO,CAAC,KAAK;IAsBb,OAAO,CAAC,OAAO;IAgBf,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,sBAAsB;CAY/B"}
|
package/dist/cookies/jar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseSetCookie, serializeCookies } from
|
|
1
|
+
import { parseSetCookie, serializeCookies } from "./parser.js";
|
|
2
2
|
const MAX_COOKIES = 3000;
|
|
3
3
|
const MAX_COOKIES_PER_DOMAIN = 50;
|
|
4
4
|
/**
|
|
@@ -39,7 +39,7 @@ export class CookieJar {
|
|
|
39
39
|
const now = Date.now();
|
|
40
40
|
const matching = this.cookies.filter((c) => this.matches(c, url, now));
|
|
41
41
|
if (matching.length === 0)
|
|
42
|
-
return
|
|
42
|
+
return "";
|
|
43
43
|
matching.sort((a, b) => {
|
|
44
44
|
if (a.path.length !== b.path.length)
|
|
45
45
|
return b.path.length - a.path.length;
|
|
@@ -85,13 +85,13 @@ export class CookieJar {
|
|
|
85
85
|
* @returns {string} Netscape-format cookie file content (newline-terminated).
|
|
86
86
|
*/
|
|
87
87
|
toNetscapeString() {
|
|
88
|
-
const lines = [
|
|
88
|
+
const lines = ["# Netscape HTTP Cookie File"];
|
|
89
89
|
for (const c of this.cookies) {
|
|
90
|
-
const domain = c.domain.startsWith(
|
|
91
|
-
const includeSubdomains = domain.startsWith(
|
|
92
|
-
const path = c.path ||
|
|
93
|
-
const secure = c.secure ?
|
|
94
|
-
let expires =
|
|
90
|
+
const domain = c.domain.startsWith(".") ? c.domain : "." + c.domain;
|
|
91
|
+
const includeSubdomains = domain.startsWith(".") ? "TRUE" : "FALSE";
|
|
92
|
+
const path = c.path || "/";
|
|
93
|
+
const secure = c.secure ? "TRUE" : "FALSE";
|
|
94
|
+
let expires = "0";
|
|
95
95
|
if (c.maxAge !== undefined) {
|
|
96
96
|
expires = String(Math.floor((c.createdAt + c.maxAge * 1000) / 1000));
|
|
97
97
|
}
|
|
@@ -100,7 +100,7 @@ export class CookieJar {
|
|
|
100
100
|
}
|
|
101
101
|
lines.push(`${domain}\t${includeSubdomains}\t${path}\t${secure}\t${expires}\t${c.name}\t${c.value}`);
|
|
102
102
|
}
|
|
103
|
-
return lines.join(
|
|
103
|
+
return lines.join("\n") + "\n";
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Imports cookies from a Netscape cookie file string. Lines beginning with
|
|
@@ -110,20 +110,20 @@ export class CookieJar {
|
|
|
110
110
|
* @param {string} content - Netscape cookie file content.
|
|
111
111
|
*/
|
|
112
112
|
loadNetscapeString(content) {
|
|
113
|
-
for (const line of content.split(
|
|
113
|
+
for (const line of content.split("\n")) {
|
|
114
114
|
const trimmed = line.trim();
|
|
115
|
-
if (!trimmed || trimmed.startsWith(
|
|
115
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
116
116
|
continue;
|
|
117
|
-
const parts = trimmed.split(
|
|
117
|
+
const parts = trimmed.split("\t");
|
|
118
118
|
if (parts.length < 7)
|
|
119
119
|
continue;
|
|
120
120
|
const [domain, , path, secure, expires, name, value] = parts;
|
|
121
121
|
const cookie = {
|
|
122
122
|
name: name,
|
|
123
123
|
value: value,
|
|
124
|
-
domain: domain.startsWith(
|
|
124
|
+
domain: domain.startsWith(".") ? domain.slice(1) : domain,
|
|
125
125
|
path: path,
|
|
126
|
-
secure: secure ===
|
|
126
|
+
secure: secure === "TRUE",
|
|
127
127
|
httpOnly: false,
|
|
128
128
|
sameSite: undefined,
|
|
129
129
|
createdAt: Date.now(),
|
|
@@ -169,35 +169,33 @@ export class CookieJar {
|
|
|
169
169
|
return false;
|
|
170
170
|
if (!this.pathMatches(url.pathname, cookie.path))
|
|
171
171
|
return false;
|
|
172
|
-
if (cookie.secure && url.protocol !==
|
|
172
|
+
if (cookie.secure && url.protocol !== "https:")
|
|
173
173
|
return false;
|
|
174
174
|
return true;
|
|
175
175
|
}
|
|
176
176
|
domainMatches(host, domain) {
|
|
177
177
|
if (host === domain)
|
|
178
178
|
return true;
|
|
179
|
-
return host.endsWith(
|
|
179
|
+
return host.endsWith("." + domain);
|
|
180
180
|
}
|
|
181
181
|
pathMatches(requestPath, cookiePath) {
|
|
182
182
|
if (requestPath === cookiePath)
|
|
183
183
|
return true;
|
|
184
184
|
if (requestPath.startsWith(cookiePath)) {
|
|
185
|
-
if (cookiePath.endsWith(
|
|
185
|
+
if (cookiePath.endsWith("/"))
|
|
186
186
|
return true;
|
|
187
|
-
if (requestPath[cookiePath.length] ===
|
|
187
|
+
if (requestPath[cookiePath.length] === "/")
|
|
188
188
|
return true;
|
|
189
189
|
}
|
|
190
190
|
return false;
|
|
191
191
|
}
|
|
192
192
|
extractSetCookieValues(headers, rawHeaders) {
|
|
193
193
|
if (rawHeaders) {
|
|
194
|
-
return rawHeaders
|
|
195
|
-
.filter(([k]) => k.toLowerCase() === 'set-cookie')
|
|
196
|
-
.map(([, v]) => v);
|
|
194
|
+
return rawHeaders.filter(([k]) => k.toLowerCase() === "set-cookie").map(([, v]) => v);
|
|
197
195
|
}
|
|
198
196
|
const values = [];
|
|
199
197
|
for (const [key, value] of Object.entries(headers)) {
|
|
200
|
-
if (key.toLowerCase() ===
|
|
198
|
+
if (key.toLowerCase() === "set-cookie") {
|
|
201
199
|
values.push(value);
|
|
202
200
|
}
|
|
203
201
|
}
|
package/dist/cookies/jar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jar.js","sourceRoot":"","sources":["../../src/cookies/jar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jar.js","sourceRoot":"","sources":["../../src/cookies/jar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,aAAa,CAAC;AAE5E,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACZ,OAAO,GAAa,EAAE,CAAC;IAE/B;;;;;;;;OAQG;IACH,UAAU,CAAC,OAA+B,EAAE,UAAe,EAAE,UAAoC;QAC/F,MAAM,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAEzE,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YACjD,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QAC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;YAC1C,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG;gBAAE,OAAO,IAAI,CAAC;QAC1D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,sBAAsB,CAAC,OAA+B,EAAE,UAAoC;QAClG,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACxF,CAAC;QACD,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,YAAY,EAAE,CAAC;gBACvC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/dist/cookies/parser.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/cookies/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/cookies/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAsE7E;AASD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D"}
|
package/dist/cookies/parser.js
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* the domain attribute fails validation against the request origin.
|
|
10
10
|
*/
|
|
11
11
|
export function parseSetCookie(header, requestUrl) {
|
|
12
|
-
const parts = header.split(
|
|
12
|
+
const parts = header.split(";").map((s) => s.trim());
|
|
13
13
|
if (parts.length === 0)
|
|
14
14
|
return null;
|
|
15
15
|
const nameValue = parts[0];
|
|
16
|
-
const eqIdx = nameValue.indexOf(
|
|
16
|
+
const eqIdx = nameValue.indexOf("=");
|
|
17
17
|
if (eqIdx < 0)
|
|
18
18
|
return null;
|
|
19
19
|
const name = nameValue.substring(0, eqIdx).trim();
|
|
@@ -31,47 +31,45 @@ export function parseSetCookie(header, requestUrl) {
|
|
|
31
31
|
};
|
|
32
32
|
for (let i = 1; i < parts.length; i++) {
|
|
33
33
|
const attr = parts[i];
|
|
34
|
-
const attrEq = attr.indexOf(
|
|
35
|
-
const attrName = (attrEq >= 0 ? attr.substring(0, attrEq) : attr)
|
|
36
|
-
|
|
37
|
-
.toLowerCase();
|
|
38
|
-
const attrValue = attrEq >= 0 ? attr.substring(attrEq + 1).trim() : '';
|
|
34
|
+
const attrEq = attr.indexOf("=");
|
|
35
|
+
const attrName = (attrEq >= 0 ? attr.substring(0, attrEq) : attr).trim().toLowerCase();
|
|
36
|
+
const attrValue = attrEq >= 0 ? attr.substring(attrEq + 1).trim() : "";
|
|
39
37
|
switch (attrName) {
|
|
40
|
-
case
|
|
38
|
+
case "domain": {
|
|
41
39
|
let d = attrValue.toLowerCase();
|
|
42
|
-
if (d.startsWith(
|
|
40
|
+
if (d.startsWith("."))
|
|
43
41
|
d = d.substring(1);
|
|
44
42
|
const host = requestUrl.hostname.toLowerCase();
|
|
45
|
-
if (d !== host && !host.endsWith(
|
|
43
|
+
if (d !== host && !host.endsWith("." + d)) {
|
|
46
44
|
return null;
|
|
47
45
|
}
|
|
48
46
|
cookie.domain = d;
|
|
49
47
|
break;
|
|
50
48
|
}
|
|
51
|
-
case
|
|
52
|
-
cookie.path = attrValue ||
|
|
49
|
+
case "path":
|
|
50
|
+
cookie.path = attrValue || "/";
|
|
53
51
|
break;
|
|
54
|
-
case
|
|
52
|
+
case "expires": {
|
|
55
53
|
const date = new Date(attrValue);
|
|
56
54
|
if (!Number.isNaN(date.getTime())) {
|
|
57
55
|
cookie.expires = date;
|
|
58
56
|
}
|
|
59
57
|
break;
|
|
60
58
|
}
|
|
61
|
-
case
|
|
59
|
+
case "max-age": {
|
|
62
60
|
const secs = parseInt(attrValue, 10);
|
|
63
61
|
if (!Number.isNaN(secs)) {
|
|
64
62
|
cookie.maxAge = secs;
|
|
65
63
|
}
|
|
66
64
|
break;
|
|
67
65
|
}
|
|
68
|
-
case
|
|
66
|
+
case "secure":
|
|
69
67
|
cookie.secure = true;
|
|
70
68
|
break;
|
|
71
|
-
case
|
|
69
|
+
case "httponly":
|
|
72
70
|
cookie.httpOnly = true;
|
|
73
71
|
break;
|
|
74
|
-
case
|
|
72
|
+
case "samesite":
|
|
75
73
|
cookie.sameSite = attrValue.toLowerCase();
|
|
76
74
|
break;
|
|
77
75
|
}
|
|
@@ -79,11 +77,11 @@ export function parseSetCookie(header, requestUrl) {
|
|
|
79
77
|
return cookie;
|
|
80
78
|
}
|
|
81
79
|
function defaultPath(path) {
|
|
82
|
-
if (!path || !path.startsWith(
|
|
83
|
-
return
|
|
84
|
-
const lastSlash = path.lastIndexOf(
|
|
80
|
+
if (!path || !path.startsWith("/"))
|
|
81
|
+
return "/";
|
|
82
|
+
const lastSlash = path.lastIndexOf("/");
|
|
85
83
|
if (lastSlash === 0)
|
|
86
|
-
return
|
|
84
|
+
return "/";
|
|
87
85
|
return path.substring(0, lastSlash);
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
@@ -93,6 +91,6 @@ function defaultPath(path) {
|
|
|
93
91
|
* @returns {string} Semicolon-separated `name=value` string suitable for the `Cookie` header.
|
|
94
92
|
*/
|
|
95
93
|
export function serializeCookies(cookies) {
|
|
96
|
-
return cookies.map((c) => `${c.name}=${c.value}`).join(
|
|
94
|
+
return cookies.map((c) => `${c.name}=${c.value}`).join("; ");
|
|
97
95
|
}
|
|
98
96
|
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/cookies/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/cookies/parser.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,UAAe;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAE3B,MAAM,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,MAAM,KAAK,GAAG,SAAS,CAAC,SA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AAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAChC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAiB;IAChD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/core/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { NLcURLRequest, NLcURLSessionConfig, RequestBody } from
|
|
2
|
-
import { NLcURLResponse } from
|
|
3
|
-
import { NLcURLSession, type RequestOptions } from
|
|
1
|
+
import type { NLcURLRequest, NLcURLSessionConfig, RequestBody } from "./request.js";
|
|
2
|
+
import { NLcURLResponse } from "./response.js";
|
|
3
|
+
import { NLcURLSession, type RequestOptions } from "./session.js";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a new {@link NLcURLSession} with the given configuration. Use a
|
|
6
6
|
* session when you need to share cookies, connection pools, or interceptors
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa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WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAEpH"}
|
package/dist/core/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NLcURLSession } from
|
|
1
|
+
import { NLcURLSession } from "./session.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a new {@link NLcURLSession} with the given configuration. Use a
|
|
4
4
|
* session when you need to share cookies, connection pools, or interceptors
|
|
@@ -40,7 +40,7 @@ export async function request(input) {
|
|
|
40
40
|
throw err;
|
|
41
41
|
}
|
|
42
42
|
const cleanup = () => session.close();
|
|
43
|
-
response.body?.once(
|
|
43
|
+
response.body?.once("close", cleanup);
|
|
44
44
|
if (response.body === null)
|
|
45
45
|
session.close();
|
|
46
46
|
return response;
|
|
@@ -60,7 +60,7 @@ export async function request(input) {
|
|
|
60
60
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
61
61
|
*/
|
|
62
62
|
export async function get(url, options) {
|
|
63
|
-
return request({ ...options, url, method:
|
|
63
|
+
return request({ ...options, url, method: "GET" });
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Issues a one-shot `POST` request.
|
|
@@ -71,7 +71,7 @@ export async function get(url, options) {
|
|
|
71
71
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
72
72
|
*/
|
|
73
73
|
export async function post(url, body, options) {
|
|
74
|
-
return request({ ...options, url, method:
|
|
74
|
+
return request({ ...options, url, method: "POST", body });
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Issues a one-shot `PUT` request.
|
|
@@ -82,7 +82,7 @@ export async function post(url, body, options) {
|
|
|
82
82
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
83
83
|
*/
|
|
84
84
|
export async function put(url, body, options) {
|
|
85
|
-
return request({ ...options, url, method:
|
|
85
|
+
return request({ ...options, url, method: "PUT", body });
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Issues a one-shot `PATCH` request.
|
|
@@ -93,7 +93,7 @@ export async function put(url, body, options) {
|
|
|
93
93
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
94
94
|
*/
|
|
95
95
|
export async function patch(url, body, options) {
|
|
96
|
-
return request({ ...options, url, method:
|
|
96
|
+
return request({ ...options, url, method: "PATCH", body });
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* Issues a one-shot `DELETE` request.
|
|
@@ -103,7 +103,7 @@ export async function patch(url, body, options) {
|
|
|
103
103
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
104
104
|
*/
|
|
105
105
|
export async function del(url, options) {
|
|
106
|
-
return request({ ...options, url, method:
|
|
106
|
+
return request({ ...options, url, method: "DELETE" });
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Issues a one-shot `HEAD` request. The response body will be empty.
|
|
@@ -113,7 +113,7 @@ export async function del(url, options) {
|
|
|
113
113
|
* @returns {Promise<NLcURLResponse>} Resolves with the response (headers only, no body).
|
|
114
114
|
*/
|
|
115
115
|
export async function head(url, options) {
|
|
116
|
-
return request({ ...options, url, method:
|
|
116
|
+
return request({ ...options, url, method: "HEAD" });
|
|
117
117
|
}
|
|
118
118
|
function extractSessionConfig(req) {
|
|
119
119
|
return {
|
|
@@ -128,6 +128,7 @@ function extractSessionConfig(req) {
|
|
|
128
128
|
timeout: req.timeout,
|
|
129
129
|
acceptEncoding: req.acceptEncoding,
|
|
130
130
|
cookieJar: req.cookieJar,
|
|
131
|
+
logger: req.logger,
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
//# sourceMappingURL=client.js.map
|
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":"AAEA,OAAO,EAA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QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,MAAM,EAAE,GAAG,CAAC,MAAM;KACnB,CAAC;AACJ,CAAC"}
|
package/dist/core/errors.d.ts
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 declare class NLcURLError extends Error {
|
|
7
11
|
/** Machine-readable error code string (e.g. `"ERR_TLS"`, `"ERR_TIMEOUT"`). */
|
|
@@ -11,8 +15,16 @@ export declare 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: string, code: string);
|
|
20
|
+
constructor(message: string, code: string, cause?: Error);
|
|
21
|
+
/**
|
|
22
|
+
* Serializes the error into a plain object suitable for structured logging
|
|
23
|
+
* or JSON API responses. Recursively serializes the `cause` chain.
|
|
24
|
+
*
|
|
25
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
26
|
+
*/
|
|
27
|
+
toJSON(): Record<string, unknown>;
|
|
16
28
|
}
|
|
17
29
|
/**
|
|
18
30
|
* Raised when a TLS handshake fails, a certificate is invalid, or any other
|
|
@@ -24,10 +36,17 @@ export declare class TLSError extends NLcURLError {
|
|
|
24
36
|
/**
|
|
25
37
|
* Creates a new TLSError instance.
|
|
26
38
|
*
|
|
27
|
-
* @param {string} message
|
|
28
|
-
* @param {number} [alertCode]
|
|
39
|
+
* @param {string} message - Human-readable description of the TLS failure.
|
|
40
|
+
* @param {number} [alertCode] - Optional TLS alert description code (RFC 8446 section 6).
|
|
41
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
42
|
+
*/
|
|
43
|
+
constructor(message: string, alertCode?: number, cause?: Error);
|
|
44
|
+
/**
|
|
45
|
+
* Serializes the error including the TLS alert code.
|
|
46
|
+
*
|
|
47
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
29
48
|
*/
|
|
30
|
-
|
|
49
|
+
toJSON(): Record<string, unknown>;
|
|
31
50
|
}
|
|
32
51
|
/**
|
|
33
52
|
* Raised when an HTTP-level error occurs, such as a protocol violation or a
|
|
@@ -42,8 +61,15 @@ export declare class HTTPError extends NLcURLError {
|
|
|
42
61
|
*
|
|
43
62
|
* @param {string} message - Human-readable description of the HTTP error.
|
|
44
63
|
* @param {number} statusCode - The HTTP status code, or `0` if none applies.
|
|
64
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
45
65
|
*/
|
|
46
|
-
constructor(message: string, statusCode: number);
|
|
66
|
+
constructor(message: string, statusCode: number, cause?: Error);
|
|
67
|
+
/**
|
|
68
|
+
* Serializes the error including the HTTP status code.
|
|
69
|
+
*
|
|
70
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
71
|
+
*/
|
|
72
|
+
toJSON(): Record<string, unknown>;
|
|
47
73
|
}
|
|
48
74
|
/**
|
|
49
75
|
* Raised when a request exceeds a configured timeout limit. The `phase`
|
|
@@ -53,19 +79,26 @@ export declare class TimeoutError extends NLcURLError {
|
|
|
53
79
|
/**
|
|
54
80
|
* The lifecycle phase in which the timeout occurred.
|
|
55
81
|
*
|
|
56
|
-
* - `"connect"`
|
|
57
|
-
* - `"tls"`
|
|
58
|
-
* - `"response"`
|
|
59
|
-
* - `"total"`
|
|
82
|
+
* - `"connect"` -- TCP connection establishment exceeded the limit.
|
|
83
|
+
* - `"tls"` -- TLS handshake exceeded the limit.
|
|
84
|
+
* - `"response"` -- Waiting for the first response byte exceeded the limit.
|
|
85
|
+
* - `"total"` -- The overall wall-clock duration exceeded the limit.
|
|
60
86
|
*/
|
|
61
|
-
readonly phase:
|
|
87
|
+
readonly phase: "connect" | "tls" | "response" | "total";
|
|
62
88
|
/**
|
|
63
89
|
* Creates a new TimeoutError instance.
|
|
64
90
|
*
|
|
65
|
-
* @param {string}
|
|
66
|
-
* @param {'connect'|'tls'|'response'|'total'} phase
|
|
91
|
+
* @param {string} message - Human-readable description.
|
|
92
|
+
* @param {'connect'|'tls'|'response'|'total'} phase - The phase that timed out.
|
|
93
|
+
* @param {Error} [cause] - Optional underlying error.
|
|
94
|
+
*/
|
|
95
|
+
constructor(message: string, phase: "connect" | "tls" | "response" | "total", cause?: Error);
|
|
96
|
+
/**
|
|
97
|
+
* Serializes the error including the timeout phase.
|
|
98
|
+
*
|
|
99
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
67
100
|
*/
|
|
68
|
-
|
|
101
|
+
toJSON(): Record<string, unknown>;
|
|
69
102
|
}
|
|
70
103
|
/**
|
|
71
104
|
* Raised when a proxy connection fails, including CONNECT tunnel failures,
|
|
@@ -77,20 +110,22 @@ export declare class ProxyError extends NLcURLError {
|
|
|
77
110
|
* Creates a new ProxyError instance.
|
|
78
111
|
*
|
|
79
112
|
* @param {string} message - Human-readable description of the proxy failure.
|
|
113
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
80
114
|
*/
|
|
81
|
-
constructor(message: string);
|
|
115
|
+
constructor(message: string, cause?: Error);
|
|
82
116
|
}
|
|
83
117
|
/**
|
|
84
118
|
* Raised when a request is cancelled via an `AbortSignal`. Unlike other
|
|
85
|
-
* errors, an `AbortError` is never retried
|
|
119
|
+
* errors, an `AbortError` is never retried -- it propagates immediately.
|
|
86
120
|
*/
|
|
87
121
|
export declare class AbortError extends NLcURLError {
|
|
88
122
|
/**
|
|
89
123
|
* Creates a new AbortError instance.
|
|
90
124
|
*
|
|
91
125
|
* @param {string} [message='Request aborted'] - Human-readable description.
|
|
126
|
+
* @param {Error} [cause] - Optional underlying error.
|
|
92
127
|
*/
|
|
93
|
-
constructor(message?: string);
|
|
128
|
+
constructor(message?: string, cause?: Error);
|
|
94
129
|
}
|
|
95
130
|
/**
|
|
96
131
|
* Raised when a TCP connection cannot be established or is unexpectedly reset
|
|
@@ -102,8 +137,9 @@ export declare class ConnectionError extends NLcURLError {
|
|
|
102
137
|
* Creates a new ConnectionError instance.
|
|
103
138
|
*
|
|
104
139
|
* @param {string} message - Human-readable description of the connection failure.
|
|
140
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
105
141
|
*/
|
|
106
|
-
constructor(message: string);
|
|
142
|
+
constructor(message: string, cause?: Error);
|
|
107
143
|
}
|
|
108
144
|
/**
|
|
109
145
|
* Raised when an HTTP/2 or HTTP/1.1 protocol violation is detected, such as
|
|
@@ -111,14 +147,21 @@ export declare class ConnectionError extends NLcURLError {
|
|
|
111
147
|
* Certain HTTP/2 error codes (e.g. `REFUSED_STREAM`) are retryable.
|
|
112
148
|
*/
|
|
113
149
|
export declare class ProtocolError extends NLcURLError {
|
|
114
|
-
/** The HTTP/2 error code (RFC 9113
|
|
150
|
+
/** The HTTP/2 error code (RFC 9113 section 7), if this error originates from an H2 frame. */
|
|
115
151
|
readonly errorCode?: number;
|
|
116
152
|
/**
|
|
117
153
|
* Creates a new ProtocolError instance.
|
|
118
154
|
*
|
|
119
|
-
* @param {string} message
|
|
120
|
-
* @param {number} [errorCode]
|
|
155
|
+
* @param {string} message - Human-readable description of the protocol error.
|
|
156
|
+
* @param {number} [errorCode] - Optional HTTP/2 protocol error code (RFC 9113 section 7).
|
|
157
|
+
* @param {Error} [cause] - Optional underlying error that triggered this one.
|
|
158
|
+
*/
|
|
159
|
+
constructor(message: string, errorCode?: number, cause?: Error);
|
|
160
|
+
/**
|
|
161
|
+
* Serializes the error including the protocol error code.
|
|
162
|
+
*
|
|
163
|
+
* @returns {Object} A JSON-safe representation of the error.
|
|
121
164
|
*/
|
|
122
|
-
|
|
165
|
+
toJSON(): Record<string, unknown>;
|
|
123
166
|
}
|
|
124
167
|
//# 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":"AAAA;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,8EAA8E;IAC9E,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAOxD;;;;;OAKG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAclC;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,WAAW;IACvC,oFAAoF;IACpF,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAM9D;;;;OAIG;IACM,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAO3C;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,6EAA6E;IAC7E,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAM9D;;;;OAIG;IACM,MAAM,IAAI,MAAM,CAAC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