nlcurl 0.6.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 +111 -0
- package/dist/cache/store.d.ts.map +1 -0
- package/dist/cache/store.js +414 -0
- package/dist/cache/store.js.map +1 -0
- package/dist/cache/types.d.ts +69 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +2 -0
- package/dist/cache/types.js.map +1 -0
- 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 +33 -31
- package/dist/cookies/jar.d.ts.map +1 -1
- package/dist/cookies/jar.js +69 -33
- package/dist/cookies/jar.js.map +1 -1
- package/dist/cookies/parser.d.ts +14 -16
- package/dist/cookies/parser.d.ts.map +1 -1
- package/dist/cookies/parser.js +30 -13
- 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 +34 -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 +63 -85
- package/dist/core/request.d.ts.map +1 -1
- package/dist/core/response.d.ts +64 -59
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +70 -52
- package/dist/core/response.js.map +1 -1
- package/dist/core/session.d.ts +81 -70
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +198 -71
- package/dist/core/session.js.map +1 -1
- package/dist/core/validation.d.ts +44 -42
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +47 -58
- 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 +39 -0
- package/dist/dns/codec.d.ts.map +1 -0
- package/dist/dns/codec.js +238 -0
- package/dist/dns/codec.js.map +1 -0
- package/dist/dns/doh-resolver.d.ts +38 -0
- package/dist/dns/doh-resolver.d.ts.map +1 -0
- package/dist/dns/doh-resolver.js +191 -0
- package/dist/dns/doh-resolver.js.map +1 -0
- 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 +40 -0
- package/dist/dns/https-rr.d.ts.map +1 -0
- package/dist/dns/https-rr.js +109 -0
- package/dist/dns/https-rr.js.map +1 -0
- package/dist/dns/types.d.ts +82 -0
- package/dist/dns/types.d.ts.map +1 -0
- package/dist/dns/types.js +23 -0
- package/dist/dns/types.js.map +1 -0
- 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 +39 -0
- package/dist/hsts/store.d.ts.map +1 -0
- package/dist/hsts/store.js +163 -0
- package/dist/hsts/store.js.map +1 -0
- package/dist/hsts/types.d.ts +24 -0
- package/dist/hsts/types.d.ts.map +1 -0
- package/dist/hsts/types.js +2 -0
- package/dist/hsts/types.js.map +1 -0
- package/dist/http/alt-svc.d.ts +67 -0
- package/dist/http/alt-svc.d.ts.map +1 -0
- package/dist/http/alt-svc.js +186 -0
- package/dist/http/alt-svc.js.map +1 -0
- 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 +29 -22
- 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 +15 -0
- package/dist/http/h3/detection.d.ts.map +1 -0
- package/dist/http/h3/detection.js +41 -0
- package/dist/http/h3/detection.js.map +1 -0
- package/dist/http/negotiator.d.ts +43 -33
- package/dist/http/negotiator.d.ts.map +1 -1
- package/dist/http/negotiator.js +99 -41
- package/dist/http/negotiator.js.map +1 -1
- package/dist/http/pool.d.ts +34 -64
- 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 +36 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -1
- 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 +15 -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 +11 -0
- package/dist/proxy/env-proxy.d.ts.map +1 -0
- package/dist/proxy/env-proxy.js +56 -0
- package/dist/proxy/env-proxy.js.map +1 -0
- package/dist/proxy/http-proxy.d.ts +13 -18
- package/dist/proxy/http-proxy.d.ts.map +1 -1
- package/dist/proxy/http-proxy.js +24 -14
- 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 +6 -9
- package/dist/proxy/socks.js.map +1 -1
- package/dist/sse/parser.d.ts +47 -0
- package/dist/sse/parser.d.ts.map +1 -0
- package/dist/sse/parser.js +139 -0
- package/dist/sse/parser.js.map +1 -0
- 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 +130 -0
- package/dist/tls/ech.d.ts.map +1 -0
- package/dist/tls/ech.js +353 -0
- package/dist/tls/ech.js.map +1 -0
- 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 +15 -14
- package/dist/tls/node-engine.d.ts.map +1 -1
- package/dist/tls/node-engine.js +54 -14
- 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 +10 -0
- package/dist/tls/pin-verification.d.ts.map +1 -0
- package/dist/tls/pin-verification.js +28 -0
- package/dist/tls/pin-verification.js.map +1 -0
- package/dist/tls/session-cache.d.ts +58 -0
- package/dist/tls/session-cache.d.ts.map +1 -0
- package/dist/tls/session-cache.js +76 -0
- package/dist/tls/session-cache.js.map +1 -0
- package/dist/tls/stealth/client-hello.d.ts +34 -32
- package/dist/tls/stealth/client-hello.d.ts.map +1 -1
- package/dist/tls/stealth/client-hello.js +116 -11
- 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 +163 -47
- package/dist/tls/stealth/engine.js.map +1 -1
- package/dist/tls/stealth/handshake.d.ts +23 -32
- package/dist/tls/stealth/handshake.d.ts.map +1 -1
- package/dist/tls/stealth/handshake.js +112 -27
- 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 +30 -0
- package/dist/tls/stealth/tls12-handshake.d.ts.map +1 -0
- package/dist/tls/stealth/tls12-handshake.js +470 -0
- package/dist/tls/stealth/tls12-handshake.js.map +1 -0
- package/dist/tls/types.d.ts +46 -48
- 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 -28
- package/dist/utils/encoding.d.ts.map +1 -1
- package/dist/utils/encoding.js +77 -40
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/happy-eyeballs.d.ts +20 -7
- package/dist/utils/happy-eyeballs.d.ts.map +1 -1
- package/dist/utils/happy-eyeballs.js +57 -25
- 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 +35 -52
- package/dist/ws/client.d.ts.map +1 -1
- package/dist/ws/client.js +92 -37
- package/dist/ws/client.js.map +1 -1
- package/dist/ws/frame.d.ts +27 -42
- package/dist/ws/frame.d.ts.map +1 -1
- package/dist/ws/frame.js +25 -37
- package/dist/ws/frame.js.map +1 -1
- package/dist/ws/permessage-deflate.d.ts +53 -0
- package/dist/ws/permessage-deflate.d.ts.map +1 -0
- package/dist/ws/permessage-deflate.js +140 -0
- package/dist/ws/permessage-deflate.js.map +1 -0
- package/package.json +62 -62
|
@@ -1,106 +1,108 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validates a
|
|
3
|
-
*
|
|
2
|
+
* Validates that a header name conforms to RFC 7230 token syntax.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name - The header name to validate.
|
|
5
|
+
* @throws {NLcURLError} If the name contains invalid characters.
|
|
4
6
|
*/
|
|
5
7
|
export declare function validateHeaderName(name: string): void;
|
|
6
8
|
/**
|
|
7
|
-
* Validates a
|
|
8
|
-
*
|
|
9
|
+
* Validates that a header value does not contain forbidden control characters.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} name - The header name (used in the error message).
|
|
12
|
+
* @param {string} value - The header value to validate.
|
|
13
|
+
* @throws {NLcURLError} If the value contains CR, LF, NUL, or other forbidden characters.
|
|
9
14
|
*/
|
|
10
15
|
export declare function validateHeaderValue(name: string, value: string): void;
|
|
11
16
|
/**
|
|
12
|
-
* Asserts that
|
|
17
|
+
* Asserts that the value is a non-empty string.
|
|
13
18
|
*
|
|
14
19
|
* @param {unknown} value - The value to check.
|
|
15
|
-
* @param {string}
|
|
20
|
+
* @param {string} label - A human-readable label for error messages.
|
|
16
21
|
* @throws {NLcURLError} If the value is not a non-empty string.
|
|
17
22
|
*/
|
|
18
23
|
export declare function assertNonEmptyString(value: unknown, label: string): asserts value is string;
|
|
19
24
|
/**
|
|
20
|
-
* Asserts that
|
|
25
|
+
* Asserts that the value is a positive finite number.
|
|
21
26
|
*
|
|
22
27
|
* @param {unknown} value - The value to check.
|
|
23
|
-
* @param {string}
|
|
28
|
+
* @param {string} label - A human-readable label for error messages.
|
|
24
29
|
* @throws {NLcURLError} If the value is not a positive finite number.
|
|
25
30
|
*/
|
|
26
31
|
export declare function assertPositiveNumber(value: unknown, label: string): asserts value is number;
|
|
27
32
|
/**
|
|
28
|
-
* Asserts that
|
|
33
|
+
* Asserts that the value is a non-negative integer.
|
|
29
34
|
*
|
|
30
35
|
* @param {unknown} value - The value to check.
|
|
31
|
-
* @param {string}
|
|
36
|
+
* @param {string} label - A human-readable label for error messages.
|
|
32
37
|
* @throws {NLcURLError} If the value is not a non-negative integer.
|
|
33
38
|
*/
|
|
34
39
|
export declare function assertNonNegativeInt(value: unknown, label: string): asserts value is number;
|
|
35
40
|
/**
|
|
36
|
-
* Asserts that
|
|
41
|
+
* Asserts that the value belongs to a predefined set of allowed values.
|
|
37
42
|
*
|
|
38
|
-
* @
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
43
|
+
* @template T
|
|
44
|
+
* @param {unknown} value - The value to check.
|
|
45
|
+
* @param {Set<T>} allowed - The set of allowed values.
|
|
46
|
+
* @param {string} label - A human-readable label for error messages.
|
|
41
47
|
* @throws {NLcURLError} If the value is not in the allowed set.
|
|
42
48
|
*/
|
|
43
49
|
export declare function assertEnum<T>(value: unknown, allowed: Set<T>, label: string): asserts value is T;
|
|
44
50
|
/**
|
|
45
|
-
* Asserts that
|
|
46
|
-
* class instance other than `Object`).
|
|
51
|
+
* Asserts that the value is a plain object (not null, not an array).
|
|
47
52
|
*
|
|
48
53
|
* @param {unknown} value - The value to check.
|
|
49
|
-
* @param {string}
|
|
54
|
+
* @param {string} label - A human-readable label for error messages.
|
|
50
55
|
* @throws {NLcURLError} If the value is not a plain object.
|
|
51
56
|
*/
|
|
52
57
|
export declare function assertPlainObject(value: unknown, label: string): asserts value is Record<string, unknown>;
|
|
53
58
|
/**
|
|
54
|
-
* Validates
|
|
59
|
+
* Validates that a URL string is well-formed and uses one of the allowed schemes.
|
|
55
60
|
*
|
|
56
|
-
* @param {string}
|
|
57
|
-
* @param {Set<string>} [allowedSchemes] - Permitted
|
|
58
|
-
* @throws {NLcURLError} If the URL is invalid or uses
|
|
61
|
+
* @param {string} url - The URL to validate.
|
|
62
|
+
* @param {Set<string>} [allowedSchemes] - Permitted URL schemes. Defaults to `http:` and `https:`.
|
|
63
|
+
* @throws {NLcURLError} If the URL is invalid or uses a disallowed scheme.
|
|
59
64
|
*/
|
|
60
65
|
export declare function validateUrl(url: string, allowedSchemes?: Set<string>): void;
|
|
61
66
|
/**
|
|
62
|
-
* Validates
|
|
63
|
-
* finite number when present.
|
|
67
|
+
* Validates a timeout value, accepting either a positive number or a TimeoutConfig object.
|
|
64
68
|
*
|
|
65
|
-
* @param {unknown} timeout -
|
|
66
|
-
* @throws {NLcURLError} If
|
|
69
|
+
* @param {unknown} timeout - The timeout value to validate.
|
|
70
|
+
* @throws {NLcURLError} If the timeout is not a valid number or TimeoutConfig.
|
|
67
71
|
*/
|
|
68
72
|
export declare function validateTimeout(timeout: unknown): void;
|
|
69
73
|
/**
|
|
70
|
-
* Validates all
|
|
71
|
-
* Called at the entry of every public request function before any processing.
|
|
74
|
+
* Validates all fields of a request descriptor.
|
|
72
75
|
*
|
|
73
|
-
* @param {Record<string, unknown>} input - The
|
|
74
|
-
* @throws {NLcURLError} If any field
|
|
76
|
+
* @param {Record<string, unknown>} input - The request fields to validate.
|
|
77
|
+
* @throws {NLcURLError} If any field value is invalid.
|
|
75
78
|
*/
|
|
76
79
|
export declare function validateRequest(input: Record<string, unknown>): void;
|
|
77
80
|
/**
|
|
78
|
-
* Validates
|
|
79
|
-
* {@link NLcURLSession} constructor.
|
|
81
|
+
* Validates all fields of a session configuration object.
|
|
80
82
|
*
|
|
81
|
-
* @param {Record<string, unknown>} config - The
|
|
82
|
-
* @throws {NLcURLError} If any field
|
|
83
|
+
* @param {Record<string, unknown>} config - The session config fields to validate.
|
|
84
|
+
* @throws {NLcURLError} If any field value is invalid.
|
|
83
85
|
*/
|
|
84
86
|
export declare function validateSessionConfig(config: Record<string, unknown>): void;
|
|
85
87
|
/**
|
|
86
|
-
* Validates
|
|
88
|
+
* Validates retry configuration fields.
|
|
87
89
|
*
|
|
88
|
-
* @param {Record<string, unknown>} config - The
|
|
89
|
-
* @throws {NLcURLError} If any
|
|
90
|
+
* @param {Record<string, unknown>} config - The retry config fields to validate.
|
|
91
|
+
* @throws {NLcURLError} If any field value is invalid.
|
|
90
92
|
*/
|
|
91
93
|
export declare function validateRetryConfig(config: Record<string, unknown>): void;
|
|
92
94
|
/**
|
|
93
|
-
* Validates rate limit configuration.
|
|
95
|
+
* Validates rate limit configuration fields.
|
|
94
96
|
*
|
|
95
|
-
* @param {Record<string, unknown>} config - The
|
|
96
|
-
* @throws {NLcURLError} If
|
|
97
|
+
* @param {Record<string, unknown>} config - The rate limit config fields to validate.
|
|
98
|
+
* @throws {NLcURLError} If maxRequests or windowMs is invalid.
|
|
97
99
|
*/
|
|
98
100
|
export declare function validateRateLimitConfig(config: Record<string, unknown>): void;
|
|
99
101
|
/**
|
|
100
|
-
* Validates a
|
|
102
|
+
* Validates that a URL uses the `ws:` or `wss:` scheme for WebSocket connections.
|
|
101
103
|
*
|
|
102
|
-
* @param {string} url - The
|
|
103
|
-
* @throws {NLcURLError} If the URL is invalid or uses a non-WebSocket
|
|
104
|
+
* @param {string} url - The URL to validate.
|
|
105
|
+
* @throws {NLcURLError} If the URL is invalid or uses a non-WebSocket scheme.
|
|
104
106
|
*/
|
|
105
107
|
export declare function validateWebSocketUrl(url: string): void;
|
|
106
108
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED;;;;;;GAMG;AACH,wBAAgB,mB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AgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAezE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtD"}
|
package/dist/core/validation.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module validation
|
|
3
|
-
* @description Provides reusable runtime validation helpers for all public API
|
|
4
|
-
* entry points. Functions throw {@link NLcURLError} with code `ERR_VALIDATION`
|
|
5
|
-
* when an input fails a check. These guards protect every trust boundary
|
|
6
|
-
* between caller-supplied data and internal library logic.
|
|
7
|
-
*/
|
|
8
1
|
import { NLcURLError } from "./errors.js";
|
|
9
2
|
const VALID_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
10
|
-
const VALID_HTTP_VERSIONS = new Set(["1.1", "2"]);
|
|
3
|
+
const VALID_HTTP_VERSIONS = new Set(["1.1", "2", "3"]);
|
|
11
4
|
const VALID_DNS_FAMILIES = new Set([4, 6]);
|
|
12
5
|
const VALID_BACKOFF = new Set(["linear", "exponential"]);
|
|
13
6
|
const HEADER_NAME_RE = /^[!#$%&'*+\-.0-9A-Za-z^_`|~]+$/;
|
|
14
|
-
const HEADER_VALUE_FORBIDDEN_RE = /[\
|
|
7
|
+
const HEADER_VALUE_FORBIDDEN_RE = /[\x00-\x08\x0a-\x1f\x7f]/;
|
|
15
8
|
/**
|
|
16
|
-
* Validates a
|
|
17
|
-
*
|
|
9
|
+
* Validates that a header name conforms to RFC 7230 token syntax.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} name - The header name to validate.
|
|
12
|
+
* @throws {NLcURLError} If the name contains invalid characters.
|
|
18
13
|
*/
|
|
19
14
|
export function validateHeaderName(name) {
|
|
20
15
|
if (!name || !HEADER_NAME_RE.test(name)) {
|
|
@@ -22,28 +17,25 @@ export function validateHeaderName(name) {
|
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
19
|
/**
|
|
25
|
-
* Validates a
|
|
26
|
-
*
|
|
20
|
+
* Validates that a header value does not contain forbidden control characters.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} name - The header name (used in the error message).
|
|
23
|
+
* @param {string} value - The header value to validate.
|
|
24
|
+
* @throws {NLcURLError} If the value contains CR, LF, NUL, or other forbidden characters.
|
|
27
25
|
*/
|
|
28
26
|
export function validateHeaderValue(name, value) {
|
|
29
27
|
if (HEADER_VALUE_FORBIDDEN_RE.test(value)) {
|
|
30
|
-
fail(`HTTP header "${name}" contains forbidden characters
|
|
28
|
+
fail(`HTTP header "${name}" contains forbidden control characters`);
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Throws an `ERR_VALIDATION` error with the supplied message.
|
|
35
|
-
*
|
|
36
|
-
* @param {string} message - Description of the validation failure.
|
|
37
|
-
* @throws {NLcURLError} Always.
|
|
38
|
-
*/
|
|
39
31
|
function fail(message) {
|
|
40
32
|
throw new NLcURLError(message, "ERR_VALIDATION");
|
|
41
33
|
}
|
|
42
34
|
/**
|
|
43
|
-
* Asserts that
|
|
35
|
+
* Asserts that the value is a non-empty string.
|
|
44
36
|
*
|
|
45
37
|
* @param {unknown} value - The value to check.
|
|
46
|
-
* @param {string}
|
|
38
|
+
* @param {string} label - A human-readable label for error messages.
|
|
47
39
|
* @throws {NLcURLError} If the value is not a non-empty string.
|
|
48
40
|
*/
|
|
49
41
|
export function assertNonEmptyString(value, label) {
|
|
@@ -52,10 +44,10 @@ export function assertNonEmptyString(value, label) {
|
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
46
|
/**
|
|
55
|
-
* Asserts that
|
|
47
|
+
* Asserts that the value is a positive finite number.
|
|
56
48
|
*
|
|
57
49
|
* @param {unknown} value - The value to check.
|
|
58
|
-
* @param {string}
|
|
50
|
+
* @param {string} label - A human-readable label for error messages.
|
|
59
51
|
* @throws {NLcURLError} If the value is not a positive finite number.
|
|
60
52
|
*/
|
|
61
53
|
export function assertPositiveNumber(value, label) {
|
|
@@ -64,10 +56,10 @@ export function assertPositiveNumber(value, label) {
|
|
|
64
56
|
}
|
|
65
57
|
}
|
|
66
58
|
/**
|
|
67
|
-
* Asserts that
|
|
59
|
+
* Asserts that the value is a non-negative integer.
|
|
68
60
|
*
|
|
69
61
|
* @param {unknown} value - The value to check.
|
|
70
|
-
* @param {string}
|
|
62
|
+
* @param {string} label - A human-readable label for error messages.
|
|
71
63
|
* @throws {NLcURLError} If the value is not a non-negative integer.
|
|
72
64
|
*/
|
|
73
65
|
export function assertNonNegativeInt(value, label) {
|
|
@@ -76,11 +68,12 @@ export function assertNonNegativeInt(value, label) {
|
|
|
76
68
|
}
|
|
77
69
|
}
|
|
78
70
|
/**
|
|
79
|
-
* Asserts that
|
|
71
|
+
* Asserts that the value belongs to a predefined set of allowed values.
|
|
80
72
|
*
|
|
81
|
-
* @
|
|
82
|
-
* @param {
|
|
83
|
-
* @param {
|
|
73
|
+
* @template T
|
|
74
|
+
* @param {unknown} value - The value to check.
|
|
75
|
+
* @param {Set<T>} allowed - The set of allowed values.
|
|
76
|
+
* @param {string} label - A human-readable label for error messages.
|
|
84
77
|
* @throws {NLcURLError} If the value is not in the allowed set.
|
|
85
78
|
*/
|
|
86
79
|
export function assertEnum(value, allowed, label) {
|
|
@@ -90,11 +83,10 @@ export function assertEnum(value, allowed, label) {
|
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
93
|
-
* Asserts that
|
|
94
|
-
* class instance other than `Object`).
|
|
86
|
+
* Asserts that the value is a plain object (not null, not an array).
|
|
95
87
|
*
|
|
96
88
|
* @param {unknown} value - The value to check.
|
|
97
|
-
* @param {string}
|
|
89
|
+
* @param {string} label - A human-readable label for error messages.
|
|
98
90
|
* @throws {NLcURLError} If the value is not a plain object.
|
|
99
91
|
*/
|
|
100
92
|
export function assertPlainObject(value, label) {
|
|
@@ -103,11 +95,11 @@ export function assertPlainObject(value, label) {
|
|
|
103
95
|
}
|
|
104
96
|
}
|
|
105
97
|
/**
|
|
106
|
-
* Validates
|
|
98
|
+
* Validates that a URL string is well-formed and uses one of the allowed schemes.
|
|
107
99
|
*
|
|
108
|
-
* @param {string}
|
|
109
|
-
* @param {Set<string>} [allowedSchemes] - Permitted
|
|
110
|
-
* @throws {NLcURLError} If the URL is invalid or uses
|
|
100
|
+
* @param {string} url - The URL to validate.
|
|
101
|
+
* @param {Set<string>} [allowedSchemes] - Permitted URL schemes. Defaults to `http:` and `https:`.
|
|
102
|
+
* @throws {NLcURLError} If the URL is invalid or uses a disallowed scheme.
|
|
111
103
|
*/
|
|
112
104
|
export function validateUrl(url, allowedSchemes = new Set(["http:", "https:"])) {
|
|
113
105
|
if (typeof url !== "string" || url.length === 0) {
|
|
@@ -126,11 +118,10 @@ export function validateUrl(url, allowedSchemes = new Set(["http:", "https:"]))
|
|
|
126
118
|
}
|
|
127
119
|
}
|
|
128
120
|
/**
|
|
129
|
-
* Validates
|
|
130
|
-
* finite number when present.
|
|
121
|
+
* Validates a timeout value, accepting either a positive number or a TimeoutConfig object.
|
|
131
122
|
*
|
|
132
|
-
* @param {unknown} timeout -
|
|
133
|
-
* @throws {NLcURLError} If
|
|
123
|
+
* @param {unknown} timeout - The timeout value to validate.
|
|
124
|
+
* @throws {NLcURLError} If the timeout is not a valid number or TimeoutConfig.
|
|
134
125
|
*/
|
|
135
126
|
export function validateTimeout(timeout) {
|
|
136
127
|
if (timeout === undefined || timeout === null)
|
|
@@ -155,11 +146,10 @@ export function validateTimeout(timeout) {
|
|
|
155
146
|
fail("timeout must be a number or a TimeoutConfig object");
|
|
156
147
|
}
|
|
157
148
|
/**
|
|
158
|
-
* Validates all
|
|
159
|
-
* Called at the entry of every public request function before any processing.
|
|
149
|
+
* Validates all fields of a request descriptor.
|
|
160
150
|
*
|
|
161
|
-
* @param {Record<string, unknown>} input - The
|
|
162
|
-
* @throws {NLcURLError} If any field
|
|
151
|
+
* @param {Record<string, unknown>} input - The request fields to validate.
|
|
152
|
+
* @throws {NLcURLError} If any field value is invalid.
|
|
163
153
|
*/
|
|
164
154
|
export function validateRequest(input) {
|
|
165
155
|
if (input["method"] !== undefined) {
|
|
@@ -186,11 +176,10 @@ export function validateRequest(input) {
|
|
|
186
176
|
}
|
|
187
177
|
}
|
|
188
178
|
/**
|
|
189
|
-
* Validates
|
|
190
|
-
* {@link NLcURLSession} constructor.
|
|
179
|
+
* Validates all fields of a session configuration object.
|
|
191
180
|
*
|
|
192
|
-
* @param {Record<string, unknown>} config - The
|
|
193
|
-
* @throws {NLcURLError} If any field
|
|
181
|
+
* @param {Record<string, unknown>} config - The session config fields to validate.
|
|
182
|
+
* @throws {NLcURLError} If any field value is invalid.
|
|
194
183
|
*/
|
|
195
184
|
export function validateSessionConfig(config) {
|
|
196
185
|
if (config["baseURL"] !== undefined && config["baseURL"] !== null) {
|
|
@@ -220,10 +209,10 @@ export function validateSessionConfig(config) {
|
|
|
220
209
|
}
|
|
221
210
|
}
|
|
222
211
|
/**
|
|
223
|
-
* Validates
|
|
212
|
+
* Validates retry configuration fields.
|
|
224
213
|
*
|
|
225
|
-
* @param {Record<string, unknown>} config - The
|
|
226
|
-
* @throws {NLcURLError} If any
|
|
214
|
+
* @param {Record<string, unknown>} config - The retry config fields to validate.
|
|
215
|
+
* @throws {NLcURLError} If any field value is invalid.
|
|
227
216
|
*/
|
|
228
217
|
export function validateRetryConfig(config) {
|
|
229
218
|
if (config["count"] !== undefined) {
|
|
@@ -242,10 +231,10 @@ export function validateRetryConfig(config) {
|
|
|
242
231
|
}
|
|
243
232
|
}
|
|
244
233
|
/**
|
|
245
|
-
* Validates rate limit configuration.
|
|
234
|
+
* Validates rate limit configuration fields.
|
|
246
235
|
*
|
|
247
|
-
* @param {Record<string, unknown>} config - The
|
|
248
|
-
* @throws {NLcURLError} If
|
|
236
|
+
* @param {Record<string, unknown>} config - The rate limit config fields to validate.
|
|
237
|
+
* @throws {NLcURLError} If maxRequests or windowMs is invalid.
|
|
249
238
|
*/
|
|
250
239
|
export function validateRateLimitConfig(config) {
|
|
251
240
|
assertPositiveNumber(config["maxRequests"], "maxRequests");
|
|
@@ -255,10 +244,10 @@ export function validateRateLimitConfig(config) {
|
|
|
255
244
|
}
|
|
256
245
|
}
|
|
257
246
|
/**
|
|
258
|
-
* Validates a
|
|
247
|
+
* Validates that a URL uses the `ws:` or `wss:` scheme for WebSocket connections.
|
|
259
248
|
*
|
|
260
|
-
* @param {string} url - The
|
|
261
|
-
* @throws {NLcURLError} If the URL is invalid or uses a non-WebSocket
|
|
249
|
+
* @param {string} url - The URL to validate.
|
|
250
|
+
* @throws {NLcURLError} If the URL is invalid or uses a non-WebSocket scheme.
|
|
262
251
|
*/
|
|
263
252
|
export function validateWebSocketUrl(url) {
|
|
264
253
|
validateUrl(url, new Set(["ws:", "wss:"]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5F,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACvD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAM,aA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AI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,WAAW,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { DNSRecord } from "./types.js";
|
|
2
|
+
/** Stored DNS cache entry with TTL and access tracking. */
|
|
3
|
+
export interface DNSCacheEntry {
|
|
4
|
+
/** Cached DNS records. */
|
|
5
|
+
records: DNSRecord[];
|
|
6
|
+
/** Timestamp when the entry was stored. */
|
|
7
|
+
storedAt: number;
|
|
8
|
+
/** Effective time-to-live in seconds. */
|
|
9
|
+
ttl: number;
|
|
10
|
+
/** Monotonic counter value of the last access (for LRU eviction). */
|
|
11
|
+
lastAccessedAt: number;
|
|
12
|
+
}
|
|
13
|
+
/** Configuration options for {@link DNSCache}. */
|
|
14
|
+
export interface DNSCacheConfig {
|
|
15
|
+
/** Maximum number of entries before LRU eviction. */
|
|
16
|
+
maxEntries?: number;
|
|
17
|
+
/** Minimum TTL in seconds applied to any cached record. */
|
|
18
|
+
minTTL?: number;
|
|
19
|
+
/** Maximum TTL in seconds applied to any cached record. */
|
|
20
|
+
maxTTL?: number;
|
|
21
|
+
}
|
|
22
|
+
/** LRU cache for DNS records with configurable TTL bounds. */
|
|
23
|
+
export declare class DNSCache {
|
|
24
|
+
private readonly entries;
|
|
25
|
+
private readonly maxEntries;
|
|
26
|
+
private readonly minTTL;
|
|
27
|
+
private readonly maxTTL;
|
|
28
|
+
private accessCounter;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new DNS cache.
|
|
31
|
+
*
|
|
32
|
+
* @param {DNSCacheConfig} [config] - Cache configuration options.
|
|
33
|
+
*/
|
|
34
|
+
constructor(config?: DNSCacheConfig);
|
|
35
|
+
private cacheKey;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve cached records for a name and type.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} name - Domain name to look up.
|
|
40
|
+
* @param {string} type - Record type string.
|
|
41
|
+
* @returns {DNSRecord[]|undefined} Cached records, or `undefined` if absent or expired.
|
|
42
|
+
*/
|
|
43
|
+
get(name: string, type: string): DNSRecord[] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Store DNS records in the cache.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} name - Domain name.
|
|
48
|
+
* @param {string} type - Record type string.
|
|
49
|
+
* @param {DNSRecord[]} records - DNS records to cache.
|
|
50
|
+
*/
|
|
51
|
+
set(name: string, type: string, records: DNSRecord[]): void;
|
|
52
|
+
private computeTTL;
|
|
53
|
+
private evictLRU;
|
|
54
|
+
/** Remove all entries from the cache. */
|
|
55
|
+
clear(): void;
|
|
56
|
+
/** Number of entries currently in the cache. */
|
|
57
|
+
get size(): number;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/dns/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;CACxB;AAMD,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,aAAa,CAAK;IAE1B;;;;OAIG;gBACS,MAAM,CAAC,EAAE,cAAc;IAMnC,OAAO,CAAC,QAAQ;IAIhB;;;;;;OAMG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS;IAexD;;;;;;OAMG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI;IAkB3D,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,QAAQ;IAchB,yCAAyC;IACzC,KAAK,IAAI,IAAI;IAIb,gDAAgD;IAChD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const DEFAULT_MAX_ENTRIES = 500;
|
|
2
|
+
const DEFAULT_MIN_TTL = 30;
|
|
3
|
+
const DEFAULT_MAX_TTL = 86400;
|
|
4
|
+
/** LRU cache for DNS records with configurable TTL bounds. */
|
|
5
|
+
export class DNSCache {
|
|
6
|
+
entries = new Map();
|
|
7
|
+
maxEntries;
|
|
8
|
+
minTTL;
|
|
9
|
+
maxTTL;
|
|
10
|
+
accessCounter = 0;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new DNS cache.
|
|
13
|
+
*
|
|
14
|
+
* @param {DNSCacheConfig} [config] - Cache configuration options.
|
|
15
|
+
*/
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.maxEntries = config?.maxEntries ?? DEFAULT_MAX_ENTRIES;
|
|
18
|
+
this.minTTL = config?.minTTL ?? DEFAULT_MIN_TTL;
|
|
19
|
+
this.maxTTL = config?.maxTTL ?? DEFAULT_MAX_TTL;
|
|
20
|
+
}
|
|
21
|
+
cacheKey(name, type) {
|
|
22
|
+
return `${type}:${name.toLowerCase()}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieve cached records for a name and type.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} name - Domain name to look up.
|
|
28
|
+
* @param {string} type - Record type string.
|
|
29
|
+
* @returns {DNSRecord[]|undefined} Cached records, or `undefined` if absent or expired.
|
|
30
|
+
*/
|
|
31
|
+
get(name, type) {
|
|
32
|
+
const key = this.cacheKey(name, type);
|
|
33
|
+
const entry = this.entries.get(key);
|
|
34
|
+
if (!entry)
|
|
35
|
+
return undefined;
|
|
36
|
+
const age = (Date.now() - entry.storedAt) / 1000;
|
|
37
|
+
if (age >= entry.ttl) {
|
|
38
|
+
this.entries.delete(key);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
entry.lastAccessedAt = ++this.accessCounter;
|
|
42
|
+
return entry.records;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Store DNS records in the cache.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} name - Domain name.
|
|
48
|
+
* @param {string} type - Record type string.
|
|
49
|
+
* @param {DNSRecord[]} records - DNS records to cache.
|
|
50
|
+
*/
|
|
51
|
+
set(name, type, records) {
|
|
52
|
+
if (records.length === 0)
|
|
53
|
+
return;
|
|
54
|
+
const ttl = this.computeTTL(records);
|
|
55
|
+
const key = this.cacheKey(name, type);
|
|
56
|
+
if (this.entries.size >= this.maxEntries && !this.entries.has(key)) {
|
|
57
|
+
this.evictLRU();
|
|
58
|
+
}
|
|
59
|
+
this.entries.set(key, {
|
|
60
|
+
records,
|
|
61
|
+
storedAt: Date.now(),
|
|
62
|
+
ttl,
|
|
63
|
+
lastAccessedAt: ++this.accessCounter,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
computeTTL(records) {
|
|
67
|
+
let minRecordTTL = Infinity;
|
|
68
|
+
for (const record of records) {
|
|
69
|
+
if (record.ttl < minRecordTTL) {
|
|
70
|
+
minRecordTTL = record.ttl;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (minRecordTTL === Infinity)
|
|
74
|
+
minRecordTTL = this.minTTL;
|
|
75
|
+
return Math.max(this.minTTL, Math.min(this.maxTTL, minRecordTTL));
|
|
76
|
+
}
|
|
77
|
+
evictLRU() {
|
|
78
|
+
let oldestKey;
|
|
79
|
+
let oldestAccess = Infinity;
|
|
80
|
+
for (const [key, entry] of this.entries) {
|
|
81
|
+
if (entry.lastAccessedAt < oldestAccess) {
|
|
82
|
+
oldestAccess = entry.lastAccessedAt;
|
|
83
|
+
oldestKey = key;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (oldestKey) {
|
|
87
|
+
this.entries.delete(oldestKey);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Remove all entries from the cache. */
|
|
91
|
+
clear() {
|
|
92
|
+
this.entries.clear();
|
|
93
|
+
}
|
|
94
|
+
/** Number of entries currently in the cache. */
|
|
95
|
+
get size() {
|
|
96
|
+
return this.entries.size;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/dns/cache.ts"],"names":[],"mappings":"AAcA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,eAAe,GAAG,KAAK,CAAC;AAY9B,8DAA8D;AAC9D,MAAM,OAAO,QAAQ;IACF,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC3C,UAAU,CAAS;IACnB,MAAM,CAAS;I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CAAC;YACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,yCAAyC;IACzC,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,gDAAgD;IAChD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type DNSRecord, type SVCBRecord } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build a raw DNS query packet.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name - Domain name to query.
|
|
6
|
+
* @param {number} type - Numeric record type.
|
|
7
|
+
* @param {number} [id] - Query identifier (defaults to 0).
|
|
8
|
+
* @returns {Buffer} Wire-format DNS query buffer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildDNSQuery(name: string, type: number, id?: number): Buffer;
|
|
11
|
+
/**
|
|
12
|
+
* Parse a wire-format DNS response packet into records.
|
|
13
|
+
*
|
|
14
|
+
* @param {Buffer} packet - Raw DNS response data.
|
|
15
|
+
* @returns {DNSRecord[]} Array of parsed DNS records from the answer section.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseDNSResponse(packet: Buffer): DNSRecord[];
|
|
18
|
+
/**
|
|
19
|
+
* Parse a 4-byte buffer into a dotted-decimal IPv4 address string.
|
|
20
|
+
*
|
|
21
|
+
* @param {Buffer} data - Raw A record data.
|
|
22
|
+
* @returns {string} IPv4 address string.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseARecord(data: Buffer): string;
|
|
25
|
+
/**
|
|
26
|
+
* Parse a 16-byte buffer into a colon-hex IPv6 address string.
|
|
27
|
+
*
|
|
28
|
+
* @param {Buffer} data - Raw AAAA record data.
|
|
29
|
+
* @returns {string} IPv6 address string.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseAAAARecord(data: Buffer): string;
|
|
32
|
+
/**
|
|
33
|
+
* Parse raw SVCB/HTTPS record data into a structured record.
|
|
34
|
+
*
|
|
35
|
+
* @param {Buffer} data - Raw SVCB record data.
|
|
36
|
+
* @returns {SVCBRecord} Parsed SVCB record with service parameters.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseSVCBRecord(data: Buffer): SVCBRecord;
|
|
39
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/dns/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAElF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAE,MAAU,GAAG,MAAM,CAgBhF;AAcD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CA4C5D;AA8CD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAuDxD"}
|