nlcurl 0.7.0 → 0.8.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 +143 -140
- package/dist/cache/groups.d.ts +75 -0
- package/dist/cache/groups.d.ts.map +1 -0
- package/dist/cache/groups.js +118 -0
- package/dist/cache/groups.js.map +1 -0
- package/dist/cache/no-vary-search.d.ts +33 -0
- package/dist/cache/no-vary-search.d.ts.map +1 -0
- package/dist/cache/no-vary-search.js +148 -0
- package/dist/cache/no-vary-search.js.map +1 -0
- package/dist/cache/range.d.ts +120 -0
- package/dist/cache/range.d.ts.map +1 -0
- package/dist/cache/range.js +193 -0
- package/dist/cache/range.js.map +1 -0
- package/dist/cache/store.d.ts +58 -36
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +58 -46
- package/dist/cache/store.js.map +1 -1
- package/dist/cache/types.d.ts +7 -39
- package/dist/cache/types.d.ts.map +1 -1
- package/dist/cli/args.d.ts +4 -37
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +3 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/index.d.ts +0 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/output.d.ts +14 -20
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +14 -20
- package/dist/cli/output.js.map +1 -1
- package/dist/cookies/jar.d.ts +30 -39
- package/dist/cookies/jar.d.ts.map +1 -1
- package/dist/cookies/jar.js +27 -37
- package/dist/cookies/jar.js.map +1 -1
- package/dist/cookies/parser.d.ts +13 -17
- package/dist/cookies/parser.d.ts.map +1 -1
- package/dist/cookies/parser.js +17 -14
- package/dist/cookies/parser.js.map +1 -1
- package/dist/cookies/psl-data.d.ts +1 -1
- package/dist/cookies/psl-data.js +1 -1
- package/dist/cookies/public-suffix.d.ts +5 -27
- package/dist/cookies/public-suffix.d.ts.map +1 -1
- package/dist/cookies/public-suffix.js +5 -37
- package/dist/cookies/public-suffix.js.map +1 -1
- package/dist/core/auth.d.ts +30 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +34 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/client.d.ts +28 -40
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +31 -41
- package/dist/core/client.js.map +1 -1
- package/dist/core/errors.d.ts +64 -88
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +64 -88
- package/dist/core/errors.js.map +1 -1
- package/dist/core/request.d.ts +23 -111
- package/dist/core/request.d.ts.map +1 -1
- package/dist/core/response.d.ts +49 -66
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +45 -59
- package/dist/core/response.js.map +1 -1
- package/dist/core/session.d.ts +66 -78
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +105 -76
- package/dist/core/session.js.map +1 -1
- package/dist/core/validation.d.ts +44 -43
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +44 -56
- package/dist/core/validation.js.map +1 -1
- package/dist/dns/cache.d.ts +59 -0
- package/dist/dns/cache.d.ts.map +1 -0
- package/dist/dns/cache.js +99 -0
- package/dist/dns/cache.js.map +1 -0
- package/dist/dns/codec.d.ts +20 -18
- package/dist/dns/codec.d.ts.map +1 -1
- package/dist/dns/codec.js +20 -36
- package/dist/dns/codec.js.map +1 -1
- package/dist/dns/doh-resolver.d.ts +17 -31
- package/dist/dns/doh-resolver.d.ts.map +1 -1
- package/dist/dns/doh-resolver.js +46 -47
- package/dist/dns/doh-resolver.js.map +1 -1
- package/dist/dns/dot-resolver.d.ts +89 -0
- package/dist/dns/dot-resolver.d.ts.map +1 -0
- package/dist/dns/dot-resolver.js +158 -0
- package/dist/dns/dot-resolver.js.map +1 -0
- package/dist/dns/https-rr.d.ts +19 -30
- package/dist/dns/https-rr.d.ts.map +1 -1
- package/dist/dns/https-rr.js +22 -40
- package/dist/dns/https-rr.js.map +1 -1
- package/dist/dns/types.d.ts +31 -59
- package/dist/dns/types.d.ts.map +1 -1
- package/dist/dns/types.js +3 -14
- package/dist/dns/types.js.map +1 -1
- package/dist/fingerprints/akamai.d.ts +3 -11
- package/dist/fingerprints/akamai.d.ts.map +1 -1
- package/dist/fingerprints/akamai.js +3 -11
- package/dist/fingerprints/akamai.js.map +1 -1
- package/dist/fingerprints/database.d.ts +6 -14
- package/dist/fingerprints/database.d.ts.map +1 -1
- package/dist/fingerprints/database.js +6 -14
- package/dist/fingerprints/database.js.map +1 -1
- package/dist/fingerprints/extensions.d.ts +56 -71
- package/dist/fingerprints/extensions.d.ts.map +1 -1
- package/dist/fingerprints/extensions.js +58 -71
- package/dist/fingerprints/extensions.js.map +1 -1
- package/dist/fingerprints/ja3.d.ts +12 -30
- package/dist/fingerprints/ja3.d.ts.map +1 -1
- package/dist/fingerprints/ja3.js +12 -30
- package/dist/fingerprints/ja3.js.map +1 -1
- package/dist/fingerprints/ja4.d.ts +18 -0
- package/dist/fingerprints/ja4.d.ts.map +1 -0
- package/dist/fingerprints/ja4.js +83 -0
- package/dist/fingerprints/ja4.js.map +1 -0
- package/dist/fingerprints/profiles/chrome.d.ts +18 -21
- package/dist/fingerprints/profiles/chrome.d.ts.map +1 -1
- package/dist/fingerprints/profiles/chrome.js +35 -31
- package/dist/fingerprints/profiles/chrome.js.map +1 -1
- package/dist/fingerprints/profiles/edge.d.ts +7 -10
- package/dist/fingerprints/profiles/edge.d.ts.map +1 -1
- package/dist/fingerprints/profiles/edge.js +7 -10
- package/dist/fingerprints/profiles/edge.js.map +1 -1
- package/dist/fingerprints/profiles/firefox.d.ts +8 -11
- package/dist/fingerprints/profiles/firefox.d.ts.map +1 -1
- package/dist/fingerprints/profiles/firefox.js +8 -11
- package/dist/fingerprints/profiles/firefox.js.map +1 -1
- package/dist/fingerprints/profiles/safari.d.ts +11 -14
- package/dist/fingerprints/profiles/safari.d.ts.map +1 -1
- package/dist/fingerprints/profiles/safari.js +11 -14
- package/dist/fingerprints/profiles/safari.js.map +1 -1
- package/dist/fingerprints/profiles/tor.d.ts +5 -8
- package/dist/fingerprints/profiles/tor.d.ts.map +1 -1
- package/dist/fingerprints/profiles/tor.js +5 -8
- package/dist/fingerprints/profiles/tor.js.map +1 -1
- package/dist/fingerprints/types.d.ts +42 -73
- package/dist/fingerprints/types.d.ts.map +1 -1
- package/dist/hsts/store.d.ts +19 -21
- package/dist/hsts/store.d.ts.map +1 -1
- package/dist/hsts/store.js +20 -28
- package/dist/hsts/store.js.map +1 -1
- package/dist/hsts/types.d.ts +10 -14
- package/dist/hsts/types.d.ts.map +1 -1
- package/dist/http/alt-svc.d.ts +31 -49
- package/dist/http/alt-svc.d.ts.map +1 -1
- package/dist/http/alt-svc.js +21 -55
- package/dist/http/alt-svc.js.map +1 -1
- package/dist/http/early-hints.d.ts +23 -0
- package/dist/http/early-hints.d.ts.map +1 -0
- package/dist/http/early-hints.js +33 -0
- package/dist/http/early-hints.js.map +1 -0
- package/dist/http/form-data.d.ts +17 -35
- package/dist/http/form-data.d.ts.map +1 -1
- package/dist/http/form-data.js +12 -34
- package/dist/http/form-data.js.map +1 -1
- package/dist/http/h1/client.d.ts +14 -26
- package/dist/http/h1/client.d.ts.map +1 -1
- package/dist/http/h1/client.js +14 -23
- package/dist/http/h1/client.js.map +1 -1
- package/dist/http/h1/encoder.d.ts +10 -17
- package/dist/http/h1/encoder.d.ts.map +1 -1
- package/dist/http/h1/encoder.js +10 -17
- package/dist/http/h1/encoder.js.map +1 -1
- package/dist/http/h1/parser.d.ts +22 -59
- package/dist/http/h1/parser.d.ts.map +1 -1
- package/dist/http/h1/parser.js +15 -47
- package/dist/http/h1/parser.js.map +1 -1
- package/dist/http/h2/client.d.ts +18 -59
- package/dist/http/h2/client.d.ts.map +1 -1
- package/dist/http/h2/client.js +29 -64
- package/dist/http/h2/client.js.map +1 -1
- package/dist/http/h2/frames.d.ts +53 -84
- package/dist/http/h2/frames.d.ts.map +1 -1
- package/dist/http/h2/frames.js +48 -76
- package/dist/http/h2/frames.js.map +1 -1
- package/dist/http/h2/hpack.d.ts +16 -35
- package/dist/http/h2/hpack.d.ts.map +1 -1
- package/dist/http/h2/hpack.js +16 -35
- package/dist/http/h2/hpack.js.map +1 -1
- package/dist/http/h3/detection.d.ts +5 -7
- package/dist/http/h3/detection.d.ts.map +1 -1
- package/dist/http/h3/detection.js +5 -23
- package/dist/http/h3/detection.js.map +1 -1
- package/dist/http/negotiator.d.ts +25 -38
- package/dist/http/negotiator.d.ts.map +1 -1
- package/dist/http/negotiator.js +16 -28
- package/dist/http/negotiator.js.map +1 -1
- package/dist/http/pool.d.ts +32 -62
- package/dist/http/pool.d.ts.map +1 -1
- package/dist/http/pool.js +22 -41
- package/dist/http/pool.js.map +1 -1
- package/dist/http/resumable-upload.d.ts +76 -0
- package/dist/http/resumable-upload.d.ts.map +1 -0
- package/dist/http/resumable-upload.js +104 -0
- package/dist/http/resumable-upload.js.map +1 -0
- package/dist/http/trailers.d.ts +29 -0
- package/dist/http/trailers.d.ts.map +1 -0
- package/dist/http/trailers.js +57 -0
- package/dist/http/trailers.js.map +1 -0
- package/dist/index.d.ts +21 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/interceptor.d.ts +13 -32
- package/dist/middleware/interceptor.d.ts.map +1 -1
- package/dist/middleware/interceptor.js +11 -16
- package/dist/middleware/interceptor.js.map +1 -1
- package/dist/middleware/rate-limiter.d.ts +8 -17
- package/dist/middleware/rate-limiter.d.ts.map +1 -1
- package/dist/middleware/rate-limiter.js +11 -12
- package/dist/middleware/rate-limiter.js.map +1 -1
- package/dist/middleware/retry-after.d.ts +15 -0
- package/dist/middleware/retry-after.d.ts.map +1 -0
- package/dist/middleware/retry-after.js +36 -0
- package/dist/middleware/retry-after.js.map +1 -0
- package/dist/middleware/retry.d.ts +9 -18
- package/dist/middleware/retry.d.ts.map +1 -1
- package/dist/middleware/retry.js +12 -9
- package/dist/middleware/retry.js.map +1 -1
- package/dist/proxy/auth.d.ts +73 -0
- package/dist/proxy/auth.d.ts.map +1 -0
- package/dist/proxy/auth.js +128 -0
- package/dist/proxy/auth.js.map +1 -0
- package/dist/proxy/env-proxy.d.ts +5 -15
- package/dist/proxy/env-proxy.d.ts.map +1 -1
- package/dist/proxy/env-proxy.js +5 -23
- package/dist/proxy/env-proxy.js.map +1 -1
- package/dist/proxy/http-proxy.d.ts +12 -19
- package/dist/proxy/http-proxy.d.ts.map +1 -1
- package/dist/proxy/http-proxy.js +5 -8
- package/dist/proxy/http-proxy.js.map +1 -1
- package/dist/proxy/socks.d.ts +13 -20
- package/dist/proxy/socks.d.ts.map +1 -1
- package/dist/proxy/socks.js +5 -8
- package/dist/proxy/socks.js.map +1 -1
- package/dist/sse/parser.d.ts +14 -37
- package/dist/sse/parser.d.ts.map +1 -1
- package/dist/sse/parser.js +14 -28
- package/dist/sse/parser.js.map +1 -1
- package/dist/tls/constants.d.ts +15 -74
- package/dist/tls/constants.d.ts.map +1 -1
- package/dist/tls/constants.js +15 -74
- package/dist/tls/constants.js.map +1 -1
- package/dist/tls/ct.d.ts +78 -0
- package/dist/tls/ct.d.ts.map +1 -0
- package/dist/tls/ct.js +175 -0
- package/dist/tls/ct.js.map +1 -0
- package/dist/tls/early-data.d.ts +45 -0
- package/dist/tls/early-data.d.ts.map +1 -0
- package/dist/tls/early-data.js +46 -0
- package/dist/tls/early-data.js.map +1 -0
- package/dist/tls/ech.d.ts +68 -85
- package/dist/tls/ech.d.ts.map +1 -1
- package/dist/tls/ech.js +54 -102
- package/dist/tls/ech.js.map +1 -1
- package/dist/tls/keylog.d.ts +34 -0
- package/dist/tls/keylog.d.ts.map +1 -0
- package/dist/tls/keylog.js +64 -0
- package/dist/tls/keylog.js.map +1 -0
- package/dist/tls/node-engine.d.ts +10 -17
- package/dist/tls/node-engine.d.ts.map +1 -1
- package/dist/tls/node-engine.js +20 -18
- package/dist/tls/node-engine.js.map +1 -1
- package/dist/tls/ocsp.d.ts +55 -0
- package/dist/tls/ocsp.d.ts.map +1 -0
- package/dist/tls/ocsp.js +131 -0
- package/dist/tls/ocsp.js.map +1 -0
- package/dist/tls/pin-verification.d.ts +5 -4
- package/dist/tls/pin-verification.d.ts.map +1 -1
- package/dist/tls/pin-verification.js +5 -11
- package/dist/tls/pin-verification.js.map +1 -1
- package/dist/tls/session-cache.d.ts +27 -39
- package/dist/tls/session-cache.d.ts.map +1 -1
- package/dist/tls/session-cache.js +20 -24
- package/dist/tls/session-cache.js.map +1 -1
- package/dist/tls/stealth/client-hello.d.ts +25 -44
- package/dist/tls/stealth/client-hello.d.ts.map +1 -1
- package/dist/tls/stealth/client-hello.js +17 -28
- package/dist/tls/stealth/client-hello.js.map +1 -1
- package/dist/tls/stealth/engine.d.ts +5 -15
- package/dist/tls/stealth/engine.d.ts.map +1 -1
- package/dist/tls/stealth/engine.js +11 -17
- package/dist/tls/stealth/engine.js.map +1 -1
- package/dist/tls/stealth/handshake.d.ts +21 -31
- package/dist/tls/stealth/handshake.d.ts.map +1 -1
- package/dist/tls/stealth/handshake.js +15 -43
- package/dist/tls/stealth/handshake.js.map +1 -1
- package/dist/tls/stealth/key-schedule.d.ts +59 -86
- package/dist/tls/stealth/key-schedule.d.ts.map +1 -1
- package/dist/tls/stealth/key-schedule.js +46 -58
- package/dist/tls/stealth/key-schedule.js.map +1 -1
- package/dist/tls/stealth/record-layer.d.ts +52 -75
- package/dist/tls/stealth/record-layer.d.ts.map +1 -1
- package/dist/tls/stealth/record-layer.js +47 -63
- package/dist/tls/stealth/record-layer.js.map +1 -1
- package/dist/tls/stealth/tls12-handshake.d.ts +16 -0
- package/dist/tls/stealth/tls12-handshake.d.ts.map +1 -1
- package/dist/tls/stealth/tls12-handshake.js +8 -0
- package/dist/tls/stealth/tls12-handshake.js.map +1 -1
- package/dist/tls/types.d.ts +42 -60
- package/dist/tls/types.d.ts.map +1 -1
- package/dist/utils/buffer-reader.d.ts +26 -81
- package/dist/utils/buffer-reader.d.ts.map +1 -1
- package/dist/utils/buffer-reader.js +26 -81
- package/dist/utils/buffer-reader.js.map +1 -1
- package/dist/utils/buffer-writer.d.ts +30 -66
- package/dist/utils/buffer-writer.d.ts.map +1 -1
- package/dist/utils/buffer-writer.js +30 -66
- package/dist/utils/buffer-writer.js.map +1 -1
- package/dist/utils/compression.d.ts +18 -0
- package/dist/utils/compression.d.ts.map +1 -0
- package/dist/utils/compression.js +34 -0
- package/dist/utils/compression.js.map +1 -0
- package/dist/utils/dictionary-transport.d.ts +97 -0
- package/dist/utils/dictionary-transport.d.ts.map +1 -0
- package/dist/utils/dictionary-transport.js +171 -0
- package/dist/utils/dictionary-transport.js.map +1 -0
- package/dist/utils/encoding.d.ts +12 -30
- package/dist/utils/encoding.d.ts.map +1 -1
- package/dist/utils/encoding.js +15 -46
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/happy-eyeballs.d.ts +18 -8
- package/dist/utils/happy-eyeballs.d.ts.map +1 -1
- package/dist/utils/happy-eyeballs.js +19 -27
- package/dist/utils/happy-eyeballs.js.map +1 -1
- package/dist/utils/logger.d.ts +54 -81
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +92 -64
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/tcp-fast-open.d.ts +30 -0
- package/dist/utils/tcp-fast-open.d.ts.map +1 -0
- package/dist/utils/tcp-fast-open.js +36 -0
- package/dist/utils/tcp-fast-open.js.map +1 -0
- package/dist/utils/url.d.ts +18 -25
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +18 -25
- package/dist/utils/url.js.map +1 -1
- package/dist/ws/client.d.ts +33 -53
- package/dist/ws/client.d.ts.map +1 -1
- package/dist/ws/client.js +29 -30
- package/dist/ws/client.js.map +1 -1
- package/dist/ws/frame.d.ts +24 -41
- package/dist/ws/frame.d.ts.map +1 -1
- package/dist/ws/frame.js +18 -33
- package/dist/ws/frame.js.map +1 -1
- package/dist/ws/permessage-deflate.d.ts +23 -28
- package/dist/ws/permessage-deflate.d.ts.map +1 -1
- package/dist/ws/permessage-deflate.js +18 -26
- package/dist/ws/permessage-deflate.js.map +1 -1
- package/package.json +62 -62
|
@@ -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":"AAgBA;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IACzB,4BAA4B;IACZ,MAAM,CAAS;IAC/B,8BAA8B;IACd,UAAU,CAAS;IACnC,4DAA4D;IAC5C,OAAO,CAAyB;IAChD,kEAAkE;IAClD,UAAU,CAA0B;IACpD,0CAA0C;IAC1B,OAAO,CAAS;IAChC,mFAAmF;IACnE,IAAI,CAAkB;IACtC,qDAAqD;IACrC,WAAW,CAAS;IACpC,yCAAyC;IACzB,GAAG,CAAS;IAC5B,+DAA+D;IAC/C,aAAa,CAAS;IACtC,kDAAkD;IAClC,OAAO,CAAiB;IACxC,8CAA8C;IAC9B,OAAO,CAAe;IAE9B,KAAK,CAAgB;IACrB,KAAK,CAAqB;IAElC;;;;OAIG;IACH,YAAY,IAAqQ;QAC/Q,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,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
import { CacheStore } from "../cache/store.js";
|
|
7
7
|
import { HSTSStore } from "../hsts/store.js";
|
|
8
8
|
/**
|
|
9
|
-
* Request options
|
|
10
|
-
* fields from {@link NLcURLRequest} except `url`, `method`, and `body`.
|
|
11
|
-
*
|
|
12
|
-
* @typedef {Omit<NLcURLRequest, 'url'|'method'|'body'>} RequestOptions
|
|
9
|
+
* Request options excluding URL, method, and body — used for convenience method signatures.
|
|
13
10
|
*/
|
|
14
11
|
export type RequestOptions = Omit<NLcURLRequest, "url" | "method" | "body">;
|
|
15
12
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* many requests to the same origin, or when you need shared cookie state.
|
|
13
|
+
* Manages a persistent HTTP session with connection pooling, cookie storage,
|
|
14
|
+
* caching, HSTS enforcement, interceptors, rate limiting, and retry logic.
|
|
19
15
|
*
|
|
20
|
-
* @
|
|
21
|
-
* const session = new NLcURLSession({ impersonate: 'chrome136' });
|
|
22
|
-
* const response = await session.get('https://example.com');
|
|
23
|
-
* session.close();
|
|
16
|
+
* @class
|
|
24
17
|
*/
|
|
25
18
|
export declare class NLcURLSession {
|
|
26
19
|
private readonly config;
|
|
@@ -33,143 +26,138 @@ export declare class NLcURLSession {
|
|
|
33
26
|
private readonly hstsStore;
|
|
34
27
|
private closed;
|
|
35
28
|
/**
|
|
36
|
-
* Creates a new
|
|
29
|
+
* Creates a new session with the given configuration.
|
|
37
30
|
*
|
|
38
|
-
* @param {NLcURLSessionConfig} [config={}] - Session-level defaults
|
|
31
|
+
* @param {NLcURLSessionConfig} [config={}] - Session-level defaults and feature toggles.
|
|
32
|
+
* @throws {NLcURLError} If configuration values are invalid.
|
|
39
33
|
*/
|
|
40
34
|
constructor(config?: NLcURLSessionConfig);
|
|
41
35
|
/**
|
|
42
|
-
* Registers a request interceptor
|
|
43
|
-
* before each request is dispatched. The interceptor may return a modified
|
|
44
|
-
* request object or a `Promise` that resolves to one.
|
|
36
|
+
* Registers a request interceptor invoked before each outgoing request.
|
|
45
37
|
*
|
|
46
|
-
* @param {RequestInterceptor} fn - The interceptor function
|
|
47
|
-
* @returns {this} The session instance
|
|
38
|
+
* @param {RequestInterceptor} fn - The interceptor function.
|
|
39
|
+
* @returns {this} The session instance for chaining.
|
|
48
40
|
*/
|
|
49
41
|
onRequest(fn: RequestInterceptor): this;
|
|
50
42
|
/**
|
|
51
|
-
* Registers a response interceptor
|
|
52
|
-
* after each response is received. The interceptor may return a modified
|
|
53
|
-
* response object or a `Promise` that resolves to one.
|
|
43
|
+
* Registers a response interceptor invoked after each incoming response.
|
|
54
44
|
*
|
|
55
|
-
* @param {ResponseInterceptor} fn - The interceptor function
|
|
56
|
-
* @returns {this} The session instance
|
|
45
|
+
* @param {ResponseInterceptor} fn - The interceptor function.
|
|
46
|
+
* @returns {this} The session instance for chaining.
|
|
57
47
|
*/
|
|
58
48
|
onResponse(fn: ResponseInterceptor): this;
|
|
59
49
|
/**
|
|
60
|
-
*
|
|
61
|
-
* Requests that exceed the configured rate will wait until a token becomes
|
|
62
|
-
* available before proceeding.
|
|
50
|
+
* Configures a token-bucket rate limiter for this session.
|
|
63
51
|
*
|
|
64
|
-
* @param {RateLimitConfig} config - Rate limit parameters
|
|
65
|
-
* @returns {this} The session instance
|
|
52
|
+
* @param {RateLimitConfig} config - Rate limit parameters.
|
|
53
|
+
* @returns {this} The session instance for chaining.
|
|
54
|
+
* @throws {NLcURLError} If the rate limit config is invalid.
|
|
66
55
|
*/
|
|
67
56
|
setRateLimit(config: RateLimitConfig): this;
|
|
68
57
|
/**
|
|
69
|
-
*
|
|
58
|
+
* Sends an HTTP GET request.
|
|
70
59
|
*
|
|
71
|
-
* @param {string}
|
|
72
|
-
* @param {RequestOptions}
|
|
60
|
+
* @param {string} url - The target URL.
|
|
61
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
73
62
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
74
63
|
*/
|
|
75
64
|
get(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
76
65
|
/**
|
|
77
|
-
*
|
|
66
|
+
* Sends an HTTP POST request.
|
|
78
67
|
*
|
|
79
|
-
* @param {string}
|
|
80
|
-
* @param {RequestBody}
|
|
81
|
-
* @param {RequestOptions} [options] -
|
|
68
|
+
* @param {string} url - The target URL.
|
|
69
|
+
* @param {RequestBody} [body] - The request body.
|
|
70
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
82
71
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
83
72
|
*/
|
|
84
73
|
post(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
85
74
|
/**
|
|
86
|
-
*
|
|
75
|
+
* Sends an HTTP PUT request.
|
|
87
76
|
*
|
|
88
|
-
* @param {string}
|
|
89
|
-
* @param {RequestBody}
|
|
90
|
-
* @param {RequestOptions} [options] -
|
|
77
|
+
* @param {string} url - The target URL.
|
|
78
|
+
* @param {RequestBody} [body] - The request body.
|
|
79
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
91
80
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
92
81
|
*/
|
|
93
82
|
put(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
94
83
|
/**
|
|
95
|
-
*
|
|
84
|
+
* Sends an HTTP PATCH request.
|
|
96
85
|
*
|
|
97
|
-
* @param {string}
|
|
98
|
-
* @param {RequestBody}
|
|
99
|
-
* @param {RequestOptions} [options] -
|
|
86
|
+
* @param {string} url - The target URL.
|
|
87
|
+
* @param {RequestBody} [body] - The request body.
|
|
88
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
100
89
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
101
90
|
*/
|
|
102
91
|
patch(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
103
92
|
/**
|
|
104
|
-
*
|
|
93
|
+
* Sends an HTTP DELETE request.
|
|
105
94
|
*
|
|
106
|
-
* @param {string}
|
|
107
|
-
* @param {RequestOptions} [options] -
|
|
95
|
+
* @param {string} url - The target URL.
|
|
96
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
108
97
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
109
98
|
*/
|
|
110
99
|
delete(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
111
100
|
/**
|
|
112
|
-
*
|
|
101
|
+
* Sends an HTTP HEAD request.
|
|
113
102
|
*
|
|
114
|
-
* @param {string}
|
|
115
|
-
* @param {RequestOptions} [options] -
|
|
103
|
+
* @param {string} url - The target URL.
|
|
104
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
116
105
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
117
106
|
*/
|
|
118
107
|
head(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
119
108
|
/**
|
|
120
|
-
*
|
|
109
|
+
* Sends an HTTP OPTIONS request.
|
|
121
110
|
*
|
|
122
|
-
* @param {string}
|
|
123
|
-
* @param {RequestOptions} [options] -
|
|
111
|
+
* @param {string} url - The target URL.
|
|
112
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
124
113
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
125
114
|
*/
|
|
126
115
|
options(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
127
116
|
/**
|
|
128
|
-
*
|
|
129
|
-
* interceptors, redirect following, cookie management, and response
|
|
130
|
-
* interceptors in sequence.
|
|
117
|
+
* Sends an HTTP QUERY request (RFC 9110).
|
|
131
118
|
*
|
|
132
|
-
* @param {
|
|
133
|
-
* @
|
|
134
|
-
* @
|
|
135
|
-
* @
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*
|
|
140
|
-
*
|
|
119
|
+
* @param {string} url - The target URL.
|
|
120
|
+
* @param {RequestBody} [body] - The query body.
|
|
121
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
122
|
+
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
123
|
+
*/
|
|
124
|
+
query(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Sends an HTTP request with full session features including caching,
|
|
127
|
+
* HSTS upgrade, cookie handling, compression, retry, and interceptors.
|
|
128
|
+
*
|
|
129
|
+
* @param {NLcURLRequest} input - The complete request descriptor.
|
|
130
|
+
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
131
|
+
* @throws {NLcURLError} If the session is closed.
|
|
132
|
+
* @throws {HTTPError} If `throwOnError` is enabled and the response is non-2xx.
|
|
141
133
|
*/
|
|
142
134
|
request(input: NLcURLRequest): Promise<NLcURLResponse>;
|
|
143
135
|
/**
|
|
144
|
-
* Returns the
|
|
145
|
-
* cookie management was disabled via `cookieJar: false`.
|
|
136
|
+
* Returns the session's cookie jar, or `null` if cookies are disabled.
|
|
146
137
|
*
|
|
147
|
-
* @returns {CookieJar|null} The
|
|
138
|
+
* @returns {CookieJar|null} The cookie jar instance.
|
|
148
139
|
*/
|
|
149
140
|
getCookies(): CookieJar | null;
|
|
150
141
|
/**
|
|
151
|
-
* Returns the
|
|
152
|
-
* caching was not enabled.
|
|
142
|
+
* Returns the session's cache store, or `null` if caching is disabled.
|
|
153
143
|
*
|
|
154
|
-
* @returns {CacheStore|null} The cache store
|
|
144
|
+
* @returns {CacheStore|null} The cache store instance.
|
|
155
145
|
*/
|
|
156
146
|
getCache(): CacheStore | null;
|
|
157
147
|
/**
|
|
158
|
-
* Returns the
|
|
159
|
-
* HSTS was not enabled.
|
|
148
|
+
* Returns the session's HSTS store, or `null` if HSTS is disabled.
|
|
160
149
|
*
|
|
161
|
-
* @returns {HSTSStore|null} The HSTS store
|
|
150
|
+
* @returns {HSTSStore|null} The HSTS store instance.
|
|
162
151
|
*/
|
|
163
152
|
getHSTS(): HSTSStore | null;
|
|
164
153
|
/**
|
|
165
|
-
* Returns the Alt-Svc store
|
|
166
|
-
*
|
|
154
|
+
* Returns the session's Alt-Svc store for HTTP alternative service lookups.
|
|
155
|
+
*
|
|
156
|
+
* @returns {import("../http/alt-svc.js").AltSvcStore} The Alt-Svc store instance.
|
|
167
157
|
*/
|
|
168
158
|
getAltSvc(): import("../http/alt-svc.js").AltSvcStore;
|
|
169
159
|
/**
|
|
170
|
-
* Closes the session
|
|
171
|
-
* method, issuing further requests will throw an `NLcURLError` with code
|
|
172
|
-
* `ERR_SESSION_CLOSED`. Subsequent calls are no-ops.
|
|
160
|
+
* Closes the session and releases all pooled connections.
|
|
173
161
|
*/
|
|
174
162
|
close(): void;
|
|
175
163
|
private mergeDefaults;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpF,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;AACnH,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAOlF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAO7C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB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,cAAc,CAAC;IAItE;;;;;;OAMG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAIpE;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAIvE;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAIzF;;;;;;;;OAQG;IACG,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA0I5D;;;;OAIG;IACH,UAAU,IAAI,SAAS,GAAG,IAAI;IAI9B;;;;OAIG;IACH,QAAQ,IAAI,UAAU,GAAG,IAAI;IAI7B;;;;OAIG;IACH,OAAO,IAAI,SAAS,GAAG,IAAI;IAI3B;;;;OAIG;IACH,SAAS,IAAI,OAAO,oBAAoB,EAAE,WAAW;IAIrD;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,aAAa;IAoFrB,OAAO,CAAC,cAAc;YASR,oBAAoB;CA6HnC"}
|
package/dist/core/session.js
CHANGED
|
@@ -12,16 +12,14 @@ import { validateSessionConfig, validateRequest, validateRateLimitConfig, valida
|
|
|
12
12
|
import { resolveEnvProxy } from "../proxy/env-proxy.js";
|
|
13
13
|
import { CacheStore } from "../cache/store.js";
|
|
14
14
|
import { HSTSStore } from "../hsts/store.js";
|
|
15
|
+
import { buildAuthHeader } from "./auth.js";
|
|
16
|
+
import { compressBody, shouldCompress } from "../utils/compression.js";
|
|
15
17
|
const MAX_REDIRECTS = 20;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* many requests to the same origin, or when you need shared cookie state.
|
|
19
|
+
* Manages a persistent HTTP session with connection pooling, cookie storage,
|
|
20
|
+
* caching, HSTS enforcement, interceptors, rate limiting, and retry logic.
|
|
20
21
|
*
|
|
21
|
-
* @
|
|
22
|
-
* const session = new NLcURLSession({ impersonate: 'chrome136' });
|
|
23
|
-
* const response = await session.get('https://example.com');
|
|
24
|
-
* session.close();
|
|
22
|
+
* @class
|
|
25
23
|
*/
|
|
26
24
|
export class NLcURLSession {
|
|
27
25
|
config;
|
|
@@ -34,9 +32,10 @@ export class NLcURLSession {
|
|
|
34
32
|
hstsStore;
|
|
35
33
|
closed = false;
|
|
36
34
|
/**
|
|
37
|
-
* Creates a new
|
|
35
|
+
* Creates a new session with the given configuration.
|
|
38
36
|
*
|
|
39
|
-
* @param {NLcURLSessionConfig} [config={}] - Session-level defaults
|
|
37
|
+
* @param {NLcURLSessionConfig} [config={}] - Session-level defaults and feature toggles.
|
|
38
|
+
* @throws {NLcURLError} If configuration values are invalid.
|
|
40
39
|
*/
|
|
41
40
|
constructor(config = {}) {
|
|
42
41
|
validateSessionConfig(config);
|
|
@@ -70,36 +69,31 @@ export class NLcURLSession {
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
73
|
-
* Registers a request interceptor
|
|
74
|
-
* before each request is dispatched. The interceptor may return a modified
|
|
75
|
-
* request object or a `Promise` that resolves to one.
|
|
72
|
+
* Registers a request interceptor invoked before each outgoing request.
|
|
76
73
|
*
|
|
77
|
-
* @param {RequestInterceptor} fn - The interceptor function
|
|
78
|
-
* @returns {this} The session instance
|
|
74
|
+
* @param {RequestInterceptor} fn - The interceptor function.
|
|
75
|
+
* @returns {this} The session instance for chaining.
|
|
79
76
|
*/
|
|
80
77
|
onRequest(fn) {
|
|
81
78
|
this.interceptors.addRequestInterceptor(fn);
|
|
82
79
|
return this;
|
|
83
80
|
}
|
|
84
81
|
/**
|
|
85
|
-
* Registers a response interceptor
|
|
86
|
-
* after each response is received. The interceptor may return a modified
|
|
87
|
-
* response object or a `Promise` that resolves to one.
|
|
82
|
+
* Registers a response interceptor invoked after each incoming response.
|
|
88
83
|
*
|
|
89
|
-
* @param {ResponseInterceptor} fn - The interceptor function
|
|
90
|
-
* @returns {this} The session instance
|
|
84
|
+
* @param {ResponseInterceptor} fn - The interceptor function.
|
|
85
|
+
* @returns {this} The session instance for chaining.
|
|
91
86
|
*/
|
|
92
87
|
onResponse(fn) {
|
|
93
88
|
this.interceptors.addResponseInterceptor(fn);
|
|
94
89
|
return this;
|
|
95
90
|
}
|
|
96
91
|
/**
|
|
97
|
-
*
|
|
98
|
-
* Requests that exceed the configured rate will wait until a token becomes
|
|
99
|
-
* available before proceeding.
|
|
92
|
+
* Configures a token-bucket rate limiter for this session.
|
|
100
93
|
*
|
|
101
|
-
* @param {RateLimitConfig} config - Rate limit parameters
|
|
102
|
-
* @returns {this} The session instance
|
|
94
|
+
* @param {RateLimitConfig} config - Rate limit parameters.
|
|
95
|
+
* @returns {this} The session instance for chaining.
|
|
96
|
+
* @throws {NLcURLError} If the rate limit config is invalid.
|
|
103
97
|
*/
|
|
104
98
|
setRateLimit(config) {
|
|
105
99
|
validateRateLimitConfig(config);
|
|
@@ -107,92 +101,97 @@ export class NLcURLSession {
|
|
|
107
101
|
return this;
|
|
108
102
|
}
|
|
109
103
|
/**
|
|
110
|
-
*
|
|
104
|
+
* Sends an HTTP GET request.
|
|
111
105
|
*
|
|
112
|
-
* @param {string}
|
|
113
|
-
* @param {RequestOptions}
|
|
106
|
+
* @param {string} url - The target URL.
|
|
107
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
114
108
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
115
109
|
*/
|
|
116
110
|
get(url, options) {
|
|
117
111
|
return this.request({ ...options, url, method: "GET" });
|
|
118
112
|
}
|
|
119
113
|
/**
|
|
120
|
-
*
|
|
114
|
+
* Sends an HTTP POST request.
|
|
121
115
|
*
|
|
122
|
-
* @param {string}
|
|
123
|
-
* @param {RequestBody}
|
|
124
|
-
* @param {RequestOptions} [options] -
|
|
116
|
+
* @param {string} url - The target URL.
|
|
117
|
+
* @param {RequestBody} [body] - The request body.
|
|
118
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
125
119
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
126
120
|
*/
|
|
127
121
|
post(url, body, options) {
|
|
128
122
|
return this.request({ ...options, url, method: "POST", body });
|
|
129
123
|
}
|
|
130
124
|
/**
|
|
131
|
-
*
|
|
125
|
+
* Sends an HTTP PUT request.
|
|
132
126
|
*
|
|
133
|
-
* @param {string}
|
|
134
|
-
* @param {RequestBody}
|
|
135
|
-
* @param {RequestOptions} [options] -
|
|
127
|
+
* @param {string} url - The target URL.
|
|
128
|
+
* @param {RequestBody} [body] - The request body.
|
|
129
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
136
130
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
137
131
|
*/
|
|
138
132
|
put(url, body, options) {
|
|
139
133
|
return this.request({ ...options, url, method: "PUT", body });
|
|
140
134
|
}
|
|
141
135
|
/**
|
|
142
|
-
*
|
|
136
|
+
* Sends an HTTP PATCH request.
|
|
143
137
|
*
|
|
144
|
-
* @param {string}
|
|
145
|
-
* @param {RequestBody}
|
|
146
|
-
* @param {RequestOptions} [options] -
|
|
138
|
+
* @param {string} url - The target URL.
|
|
139
|
+
* @param {RequestBody} [body] - The request body.
|
|
140
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
147
141
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
148
142
|
*/
|
|
149
143
|
patch(url, body, options) {
|
|
150
144
|
return this.request({ ...options, url, method: "PATCH", body });
|
|
151
145
|
}
|
|
152
146
|
/**
|
|
153
|
-
*
|
|
147
|
+
* Sends an HTTP DELETE request.
|
|
154
148
|
*
|
|
155
|
-
* @param {string}
|
|
156
|
-
* @param {RequestOptions} [options] -
|
|
149
|
+
* @param {string} url - The target URL.
|
|
150
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
157
151
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
158
152
|
*/
|
|
159
153
|
delete(url, options) {
|
|
160
154
|
return this.request({ ...options, url, method: "DELETE" });
|
|
161
155
|
}
|
|
162
156
|
/**
|
|
163
|
-
*
|
|
157
|
+
* Sends an HTTP HEAD request.
|
|
164
158
|
*
|
|
165
|
-
* @param {string}
|
|
166
|
-
* @param {RequestOptions} [options] -
|
|
159
|
+
* @param {string} url - The target URL.
|
|
160
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
167
161
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
168
162
|
*/
|
|
169
163
|
head(url, options) {
|
|
170
164
|
return this.request({ ...options, url, method: "HEAD" });
|
|
171
165
|
}
|
|
172
166
|
/**
|
|
173
|
-
*
|
|
167
|
+
* Sends an HTTP OPTIONS request.
|
|
174
168
|
*
|
|
175
|
-
* @param {string}
|
|
176
|
-
* @param {RequestOptions} [options] -
|
|
169
|
+
* @param {string} url - The target URL.
|
|
170
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
177
171
|
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
178
172
|
*/
|
|
179
173
|
options(url, options) {
|
|
180
174
|
return this.request({ ...options, url, method: "OPTIONS" });
|
|
181
175
|
}
|
|
182
176
|
/**
|
|
183
|
-
*
|
|
184
|
-
* interceptors, redirect following, cookie management, and response
|
|
185
|
-
* interceptors in sequence.
|
|
177
|
+
* Sends an HTTP QUERY request (RFC 9110).
|
|
186
178
|
*
|
|
187
|
-
* @param {
|
|
188
|
-
* @
|
|
189
|
-
* @
|
|
190
|
-
* @
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
* @param {string} url - The target URL.
|
|
180
|
+
* @param {RequestBody} [body] - The query body.
|
|
181
|
+
* @param {RequestOptions} [options] - Additional request options.
|
|
182
|
+
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
183
|
+
*/
|
|
184
|
+
query(url, body, options) {
|
|
185
|
+
return this.request({ ...options, url, method: "QUERY", body });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Sends an HTTP request with full session features including caching,
|
|
189
|
+
* HSTS upgrade, cookie handling, compression, retry, and interceptors.
|
|
190
|
+
*
|
|
191
|
+
* @param {NLcURLRequest} input - The complete request descriptor.
|
|
192
|
+
* @returns {Promise<NLcURLResponse>} Resolves with the server response.
|
|
193
|
+
* @throws {NLcURLError} If the session is closed.
|
|
194
|
+
* @throws {HTTPError} If `throwOnError` is enabled and the response is non-2xx.
|
|
196
195
|
*/
|
|
197
196
|
async request(input) {
|
|
198
197
|
if (this.closed) {
|
|
@@ -204,6 +203,28 @@ export class NLcURLSession {
|
|
|
204
203
|
}
|
|
205
204
|
let req = this.mergeDefaults(input);
|
|
206
205
|
req = await this.interceptors.processRequest(req);
|
|
206
|
+
const compressionEncoding = req.compressBody ?? this.config.compressBody;
|
|
207
|
+
if (compressionEncoding && req.body) {
|
|
208
|
+
let bodyBuf = null;
|
|
209
|
+
if (Buffer.isBuffer(req.body)) {
|
|
210
|
+
bodyBuf = req.body;
|
|
211
|
+
}
|
|
212
|
+
else if (typeof req.body === "string") {
|
|
213
|
+
bodyBuf = Buffer.from(req.body, "utf-8");
|
|
214
|
+
}
|
|
215
|
+
if (bodyBuf && shouldCompress(bodyBuf.length)) {
|
|
216
|
+
const compressed = await compressBody(bodyBuf, compressionEncoding);
|
|
217
|
+
const headers = { ...req.headers };
|
|
218
|
+
headers["content-encoding"] = compressionEncoding === "br" ? "br" : compressionEncoding;
|
|
219
|
+
headers["content-length"] = String(compressed.length);
|
|
220
|
+
req = { ...req, body: compressed, headers };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (req.methodOverride === "QUERY") {
|
|
224
|
+
const headers = { ...req.headers };
|
|
225
|
+
headers["x-http-method-override"] = "QUERY";
|
|
226
|
+
req = { ...req, method: "POST", headers };
|
|
227
|
+
}
|
|
207
228
|
const profile = this.resolveProfile(req);
|
|
208
229
|
const negotiatorOptions = {
|
|
209
230
|
stealth: req.stealth,
|
|
@@ -285,43 +306,39 @@ export class NLcURLSession {
|
|
|
285
306
|
return response;
|
|
286
307
|
}
|
|
287
308
|
/**
|
|
288
|
-
* Returns the
|
|
289
|
-
* cookie management was disabled via `cookieJar: false`.
|
|
309
|
+
* Returns the session's cookie jar, or `null` if cookies are disabled.
|
|
290
310
|
*
|
|
291
|
-
* @returns {CookieJar|null} The
|
|
311
|
+
* @returns {CookieJar|null} The cookie jar instance.
|
|
292
312
|
*/
|
|
293
313
|
getCookies() {
|
|
294
314
|
return this.cookieJar;
|
|
295
315
|
}
|
|
296
316
|
/**
|
|
297
|
-
* Returns the
|
|
298
|
-
* caching was not enabled.
|
|
317
|
+
* Returns the session's cache store, or `null` if caching is disabled.
|
|
299
318
|
*
|
|
300
|
-
* @returns {CacheStore|null} The cache store
|
|
319
|
+
* @returns {CacheStore|null} The cache store instance.
|
|
301
320
|
*/
|
|
302
321
|
getCache() {
|
|
303
322
|
return this.cacheStore;
|
|
304
323
|
}
|
|
305
324
|
/**
|
|
306
|
-
* Returns the
|
|
307
|
-
* HSTS was not enabled.
|
|
325
|
+
* Returns the session's HSTS store, or `null` if HSTS is disabled.
|
|
308
326
|
*
|
|
309
|
-
* @returns {HSTSStore|null} The HSTS store
|
|
327
|
+
* @returns {HSTSStore|null} The HSTS store instance.
|
|
310
328
|
*/
|
|
311
329
|
getHSTS() {
|
|
312
330
|
return this.hstsStore;
|
|
313
331
|
}
|
|
314
332
|
/**
|
|
315
|
-
* Returns the Alt-Svc store
|
|
316
|
-
*
|
|
333
|
+
* Returns the session's Alt-Svc store for HTTP alternative service lookups.
|
|
334
|
+
*
|
|
335
|
+
* @returns {import("../http/alt-svc.js").AltSvcStore} The Alt-Svc store instance.
|
|
317
336
|
*/
|
|
318
337
|
getAltSvc() {
|
|
319
338
|
return this.negotiator.altSvcStore;
|
|
320
339
|
}
|
|
321
340
|
/**
|
|
322
|
-
* Closes the session
|
|
323
|
-
* method, issuing further requests will throw an `NLcURLError` with code
|
|
324
|
-
* `ERR_SESSION_CLOSED`. Subsequent calls are no-ops.
|
|
341
|
+
* Closes the session and releases all pooled connections.
|
|
325
342
|
*/
|
|
326
343
|
close() {
|
|
327
344
|
if (this.closed)
|
|
@@ -362,6 +379,16 @@ export class NLcURLSession {
|
|
|
362
379
|
if (input.range && !headers["range"]) {
|
|
363
380
|
headers["range"] = input.range;
|
|
364
381
|
}
|
|
382
|
+
const authConfig = input.auth ?? cfg.auth;
|
|
383
|
+
if (authConfig && !headers["authorization"]) {
|
|
384
|
+
const authHeader = buildAuthHeader(authConfig);
|
|
385
|
+
if (authHeader) {
|
|
386
|
+
headers["authorization"] = authHeader;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (input.expect100Continue && input.body && !headers["expect"]) {
|
|
390
|
+
headers["expect"] = "100-continue";
|
|
391
|
+
}
|
|
365
392
|
if (this.cookieJar) {
|
|
366
393
|
const parsedUrl = new URL(url);
|
|
367
394
|
const cookieHeader = this.cookieJar.getCookieHeader(parsedUrl);
|
|
@@ -416,14 +443,16 @@ export class NLcURLSession {
|
|
|
416
443
|
if (currentReq.signal) {
|
|
417
444
|
const sig = currentReq.signal;
|
|
418
445
|
response = await new Promise((resolve, reject) => {
|
|
419
|
-
const onAbort = () =>
|
|
446
|
+
const onAbort = () => {
|
|
447
|
+
reject(new AbortError());
|
|
448
|
+
};
|
|
420
449
|
sig.addEventListener("abort", onAbort, { once: true });
|
|
421
450
|
this.negotiator.send(currentReq, options).then((res) => {
|
|
422
451
|
sig.removeEventListener("abort", onAbort);
|
|
423
452
|
resolve(res);
|
|
424
453
|
}, (err) => {
|
|
425
454
|
sig.removeEventListener("abort", onAbort);
|
|
426
|
-
reject(err);
|
|
455
|
+
reject(err instanceof Error ? err : new NLcURLError(String(err), "ERR_UNKNOWN"));
|
|
427
456
|
});
|
|
428
457
|
});
|
|
429
458
|
}
|