kinetex 1.3.0 → 1.5.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 +413 -52
- package/dist/browser/kinetex.esm.js +38 -22
- package/dist/browser/kinetex.js +3134 -787
- package/dist/browser/kinetex.min.js +38 -22
- package/dist/cjs/aws-sigv4.js +140 -33
- package/dist/cjs/cache.js +58 -7
- package/dist/cjs/circuit-breaker.js +53 -4
- package/dist/cjs/client.js +726 -188
- package/dist/cjs/cookie-parser.js +131 -6
- package/dist/cjs/cookie-store.js +125 -28
- package/dist/cjs/core.js +691 -70
- package/dist/cjs/dedup.js +142 -21
- package/dist/cjs/digest.js +195 -38
- package/dist/cjs/graphql.js +166 -35
- package/dist/cjs/headers.js +327 -46
- package/dist/cjs/interceptors.js +227 -24
- package/dist/cjs/lifecycle.js +92 -59
- package/dist/cjs/logging.js +160 -24
- package/dist/cjs/mod.js +3 -2
- package/dist/cjs/pagination.js +247 -22
- package/dist/cjs/progress.js +178 -30
- package/dist/cjs/proxy.js +429 -0
- package/dist/cjs/response.js +506 -110
- package/dist/cjs/socks5.js +136 -15
- package/dist/cjs/sse.js +173 -43
- package/dist/cjs/url.js +191 -45
- package/dist/cjs/utils.js +335 -73
- package/dist/cjs/ws.js +62 -12
- package/dist/esm/aws-sigv4.js +140 -33
- package/dist/esm/aws-sigv4.js.map +1 -1
- package/dist/esm/cache.js +58 -7
- package/dist/esm/cache.js.map +1 -1
- package/dist/esm/circuit-breaker.js +53 -4
- package/dist/esm/circuit-breaker.js.map +1 -1
- package/dist/esm/client.js +726 -188
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/cookie-parser.js +131 -6
- package/dist/esm/cookie-parser.js.map +1 -1
- package/dist/esm/cookie-store.js +125 -28
- package/dist/esm/cookie-store.js.map +1 -1
- package/dist/esm/core.js +691 -70
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/dedup.js +142 -21
- package/dist/esm/dedup.js.map +1 -1
- package/dist/esm/digest.js +195 -38
- package/dist/esm/digest.js.map +1 -1
- package/dist/esm/graphql.js +166 -35
- package/dist/esm/graphql.js.map +1 -1
- package/dist/esm/headers.js +327 -46
- package/dist/esm/headers.js.map +1 -1
- package/dist/esm/interceptors.js +227 -24
- package/dist/esm/interceptors.js.map +1 -1
- package/dist/esm/lifecycle.js +92 -59
- package/dist/esm/lifecycle.js.map +1 -1
- package/dist/esm/logging.js +160 -24
- package/dist/esm/logging.js.map +1 -1
- package/dist/esm/mod.js +3 -2
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/pagination.js +247 -22
- package/dist/esm/pagination.js.map +1 -1
- package/dist/esm/progress.js +178 -30
- package/dist/esm/progress.js.map +1 -1
- package/dist/esm/proxy.js +430 -0
- package/dist/esm/proxy.js.map +1 -0
- package/dist/esm/response.js +506 -110
- package/dist/esm/response.js.map +1 -1
- package/dist/esm/socks5.js +136 -15
- package/dist/esm/socks5.js.map +1 -1
- package/dist/esm/sse.js +173 -43
- package/dist/esm/sse.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/url.js +191 -45
- package/dist/esm/url.js.map +1 -1
- package/dist/esm/utils.js +335 -73
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/ws.js +62 -12
- package/dist/esm/ws.js.map +1 -1
- package/dist/types/aws-sigv4.d.ts.map +1 -1
- package/dist/types/cache.d.ts +19 -1
- package/dist/types/cache.d.ts.map +1 -1
- package/dist/types/circuit-breaker.d.ts +15 -2
- package/dist/types/circuit-breaker.d.ts.map +1 -1
- package/dist/types/client.d.ts +69 -11
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/cookie-parser.d.ts +0 -17
- package/dist/types/cookie-parser.d.ts.map +1 -1
- package/dist/types/cookie-store.d.ts.map +1 -1
- package/dist/types/core.d.ts +216 -25
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/dedup.d.ts +38 -3
- package/dist/types/dedup.d.ts.map +1 -1
- package/dist/types/digest.d.ts +17 -37
- package/dist/types/digest.d.ts.map +1 -1
- package/dist/types/graphql.d.ts.map +1 -1
- package/dist/types/headers.d.ts +68 -31
- package/dist/types/headers.d.ts.map +1 -1
- package/dist/types/interceptors.d.ts +126 -38
- package/dist/types/interceptors.d.ts.map +1 -1
- package/dist/types/lifecycle.d.ts +19 -2
- package/dist/types/lifecycle.d.ts.map +1 -1
- package/dist/types/logging.d.ts +22 -3
- package/dist/types/logging.d.ts.map +1 -1
- package/dist/types/mod.d.ts +5 -3
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/pagination.d.ts +0 -25
- package/dist/types/pagination.d.ts.map +1 -1
- package/dist/types/progress.d.ts +1 -1
- package/dist/types/progress.d.ts.map +1 -1
- package/dist/types/proxy.d.ts +50 -0
- package/dist/types/proxy.d.ts.map +1 -0
- package/dist/types/response.d.ts +49 -2
- package/dist/types/response.d.ts.map +1 -1
- package/dist/types/socks5.d.ts.map +1 -1
- package/dist/types/sse.d.ts.map +1 -1
- package/dist/types/types.d.ts +219 -26
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/url.d.ts +0 -25
- package/dist/types/url.d.ts.map +1 -1
- package/dist/types/utils.d.ts +69 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/ws.d.ts +0 -1
- package/dist/types/ws.d.ts.map +1 -1
- package/package.json +10 -4
package/dist/types/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Wires all subsystems: transport, interceptors, lifecycle hooks,
|
|
4
4
|
* retry, auth, cache, cookie jar, HAR, logging, progress, and SSE/GraphQL/Pagination.
|
|
5
5
|
*/
|
|
6
|
-
import { type DedupOptions } from "./dedup.ts";
|
|
6
|
+
import { DedupMap, type DedupOptions } from "./dedup.ts";
|
|
7
7
|
import { type CircuitBreakerConfig, type CircuitBreakerState } from "./circuit-breaker.ts";
|
|
8
8
|
import { WSClient, type WSClientConfig } from "./ws.ts";
|
|
9
9
|
import type { KinetexConfig, KinetexRequest, KinetexResponse, SendOptions, HTTPMethod, ProxyConfig, RetryConfig, HARLog, HeadersInit, QueryParams, QueryValue, RequestInterceptor, ResponseInterceptor, ErrorInterceptor } from "./types.ts";
|
|
@@ -27,7 +27,27 @@ export interface OTelTracer {
|
|
|
27
27
|
startSpan(name: string, options?: {
|
|
28
28
|
kind?: number;
|
|
29
29
|
}): OTelSpan;
|
|
30
|
+
/**
|
|
31
|
+
* Record a value into a histogram. Optional — omit it and only spans are
|
|
32
|
+
* produced.
|
|
33
|
+
*
|
|
34
|
+
* @param name - Instrument name.
|
|
35
|
+
* @param value - Recorded value. For `http.client.request.duration` this is
|
|
36
|
+
* in **seconds**, matching OpenTelemetry semantic conventions.
|
|
37
|
+
* @param attributes - Low-cardinality dimensions (method, status, host).
|
|
38
|
+
*/
|
|
39
|
+
recordHistogram?(name: string, value: number, attributes?: MetricAttributes): void;
|
|
40
|
+
/**
|
|
41
|
+
* Increment a counter. Optional — omit it and only spans are produced.
|
|
42
|
+
*
|
|
43
|
+
* @param name - Instrument name.
|
|
44
|
+
* @param value - Amount to add (default 1).
|
|
45
|
+
* @param attributes - Low-cardinality dimensions.
|
|
46
|
+
*/
|
|
47
|
+
incrementCounter?(name: string, value?: number, attributes?: MetricAttributes): void;
|
|
30
48
|
}
|
|
49
|
+
/** Attribute values accepted by {@link OTelTracer}'s metric methods. */
|
|
50
|
+
export type MetricAttributes = Record<string, string | number | boolean>;
|
|
31
51
|
/**
|
|
32
52
|
* Minimal interface for an OpenTelemetry-compatible span.
|
|
33
53
|
* Kinetex does NOT take a hard dependency on \@opentelemetry/api.
|
|
@@ -109,6 +129,14 @@ export declare class Kinetex {
|
|
|
109
129
|
private _circuitBreakerKeyFn;
|
|
110
130
|
/** Active WebSocket connections tracked for cleanup on destroy(). */
|
|
111
131
|
private readonly _wsClients;
|
|
132
|
+
/**
|
|
133
|
+
* Optional bulkhead bounding in-flight requests. `null` when
|
|
134
|
+
* `concurrencyLimit` is not configured, which keeps the hot path free of a
|
|
135
|
+
* limiter check.
|
|
136
|
+
*/
|
|
137
|
+
private readonly _concurrencyLimiter;
|
|
138
|
+
/** SigV4 signer kept so a clock-skew correction survives across retries. */
|
|
139
|
+
private _awsSigner;
|
|
112
140
|
/**
|
|
113
141
|
* @param config - Global client configuration.
|
|
114
142
|
*/
|
|
@@ -238,17 +266,16 @@ export declare class Kinetex {
|
|
|
238
266
|
/**
|
|
239
267
|
* Returns deduplication metrics.
|
|
240
268
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
269
|
+
* The full `DedupMap.getStats()` snapshot, so a caller has to reach for one
|
|
270
|
+
* shape rather than two. The wrapper used to expose only `hits`, `misses`
|
|
271
|
+
* and `inFlightCount` — which meant the hit rate, the only figure anyone
|
|
272
|
+
* actually wants from a dedup map, was unavailable on the client even
|
|
273
|
+
* though the map computed it.
|
|
274
|
+
*
|
|
275
|
+
* @returns `{ hits, misses, totalRequests, hitRate, inFlightCount, trackedKeys }`,
|
|
276
|
+
* or `null` if dedup is not enabled.
|
|
243
277
|
*/
|
|
244
|
-
get dedupMetrics():
|
|
245
|
-
/** Number of requests that shared an in-flight or windowed response. */
|
|
246
|
-
hits: number;
|
|
247
|
-
/** Number of requests that triggered a real network call. */
|
|
248
|
-
misses: number;
|
|
249
|
-
/** Number of currently in-flight requests. */
|
|
250
|
-
inFlightCount: number;
|
|
251
|
-
} | null;
|
|
278
|
+
get dedupMetrics(): ReturnType<DedupMap["getStats"]> | null;
|
|
252
279
|
/**
|
|
253
280
|
* Enable circuit breaker protection.
|
|
254
281
|
*
|
|
@@ -326,6 +353,20 @@ export declare class Kinetex {
|
|
|
326
353
|
* and retries on failure per the retry config.
|
|
327
354
|
*/
|
|
328
355
|
private _executeWithRetry;
|
|
356
|
+
/**
|
|
357
|
+
* Emit request metrics to the configured tracer, if it supports them.
|
|
358
|
+
*
|
|
359
|
+
* Failures here are swallowed on purpose: telemetry must never be able to
|
|
360
|
+
* fail a request that otherwise succeeded.
|
|
361
|
+
*
|
|
362
|
+
* @param req - The originating request.
|
|
363
|
+
* @param status - Final HTTP status, or undefined if the request threw.
|
|
364
|
+
* @param errorCode - `KinetexError` code, or undefined on success.
|
|
365
|
+
* @param durationMs - Wall-clock duration of the logical request.
|
|
366
|
+
*/
|
|
367
|
+
private _recordMetrics;
|
|
368
|
+
/** Retry loop body. See {@link _executeWithRetry} for the concurrency gate. */
|
|
369
|
+
private _executeWithRetryInner;
|
|
329
370
|
/**
|
|
330
371
|
* Follow redirects manually, one hop at a time.
|
|
331
372
|
*
|
|
@@ -466,6 +507,23 @@ export declare class FluentRequest {
|
|
|
466
507
|
constructor(client: Kinetex, method: HTTPMethod, url: string);
|
|
467
508
|
/** Set or override a single header. */
|
|
468
509
|
header(name: string, value: string): this;
|
|
510
|
+
/**
|
|
511
|
+
* Attach an `Idempotency-Key`, generating one when none is given.
|
|
512
|
+
*
|
|
513
|
+
* Lets a retried `POST` be recognised as the same logical operation by the
|
|
514
|
+
* server instead of creating a duplicate. Because the header is set on the
|
|
515
|
+
* request options — not regenerated per attempt — every retry of this
|
|
516
|
+
* request carries the same key, which is the entire point.
|
|
517
|
+
*
|
|
518
|
+
* @param value - An explicit key, or `undefined` to generate a v4 UUID.
|
|
519
|
+
* @throws {TypeError} If `value` is not a valid key (see `isValidIdempotencyKey`).
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```ts
|
|
523
|
+
* await client.POST("/charges").withJSON(body).idempotencyKey().json();
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
idempotencyKey(value?: string): this;
|
|
469
527
|
/** Merge a headers map. */
|
|
470
528
|
headers(headers: HeadersInit): this;
|
|
471
529
|
/** Set a single query parameter. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":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@ -174,23 +174,6 @@ export declare function parseSetCookieHeader(header: string): ParsedCookie | nul
|
|
|
174
174
|
* formatSetCookieHeader(cookie); // "session=abc123; Path=/; Secure"
|
|
175
175
|
*/
|
|
176
176
|
export declare function formatSetCookieHeader(cookie: ParsedCookie): string;
|
|
177
|
-
/**
|
|
178
|
-
* Split a raw Set-Cookie header value (or collapsed multi-value string)
|
|
179
|
-
* into individual cookie strings.
|
|
180
|
-
*
|
|
181
|
-
* This is non-trivial because:
|
|
182
|
-
* - Expires values contain commas: "Expires=Thu, 01 Jan 2099 00:00:00 GMT"
|
|
183
|
-
* - Multiple Set-Cookie headers may be collapsed with ", " by some HTTP stacks
|
|
184
|
-
*
|
|
185
|
-
* Strategy: Token-based state machine that properly handles:
|
|
186
|
-
* - Quoted values with commas inside (e.g., `foo="bar,baz"`)
|
|
187
|
-
* - Escaped quotes inside quoted values (e.g., `foo="bar\"baz"`)
|
|
188
|
-
* - Attribute values that may contain commas
|
|
189
|
-
* - Only commits a cookie when we've seen both name and value
|
|
190
|
-
*
|
|
191
|
-
* @param raw - Raw Set-Cookie header string (possibly containing multiple cookies)
|
|
192
|
-
* @returns Array of individual Set-Cookie strings
|
|
193
|
-
*/
|
|
194
177
|
export declare function splitSetCookieHeaders(raw: string): string[];
|
|
195
178
|
/**
|
|
196
179
|
* Extract all Set-Cookie header values from a Headers object or plain record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-parser.d.ts","sourceRoot":"","sources":["../../src/cookie-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,0FAA0F;AAC1F,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,MAAM,EAAE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OAAO,CAAC,WAAW;CAkBpB;AAwBD;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,SAAS,CAEpE"}
|
package/dist/types/core.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* - Deno / Bun / Browser / Edge: native `fetch()` (handles HTTP/2 automatically)
|
|
7
7
|
* - SOCKS5 proxy: custom TCP tunnel (from socks5.ts)
|
|
8
8
|
*/
|
|
9
|
-
import type { KinetexRequest, HTTPVersion, Runtime } from "./types.ts";
|
|
9
|
+
import type { KinetexRequest, HTTPVersion, Runtime, SessionPoolConfig } from "./types.ts";
|
|
10
|
+
import { KinetexError } from "./types.ts";
|
|
10
11
|
/**
|
|
11
12
|
* Detect the current JavaScript runtime.
|
|
12
13
|
*
|
|
@@ -15,22 +16,6 @@ import type { KinetexRequest, HTTPVersion, Runtime } from "./types.ts";
|
|
|
15
16
|
export declare function detectRuntime(): Runtime;
|
|
16
17
|
/** Cached runtime value — detected once at module load. */
|
|
17
18
|
export declare const RUNTIME: Runtime;
|
|
18
|
-
/**
|
|
19
|
-
* Override the cached runtime value.
|
|
20
|
-
*
|
|
21
|
-
* Use this in test environments where the detected runtime may be incorrect
|
|
22
|
-
* (e.g., a Node.js test that should behave as a Cloudflare Worker), or when
|
|
23
|
-
* running inside a VM/isolate with dynamic globalThis behavior.
|
|
24
|
-
*
|
|
25
|
-
* Pass `null` to restore auto-detection.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { setRuntime } from "kinetex";
|
|
30
|
-
* setRuntime("cloudflare-workers"); // test CF behavior
|
|
31
|
-
* setRuntime(null); // restore detection
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
19
|
export declare function setRuntime(rt: Runtime | null): void;
|
|
35
20
|
/**
|
|
36
21
|
* Return the effective runtime — the override if set, otherwise the
|
|
@@ -88,6 +73,25 @@ export interface FetchTransportOptions {
|
|
|
88
73
|
* Defaults to `globalThis.fetch`.
|
|
89
74
|
*/
|
|
90
75
|
fetchFn?: typeof globalThis.fetch;
|
|
76
|
+
/**
|
|
77
|
+
* Permit connections to hosts that resolve into private, loopback or
|
|
78
|
+
* link-local space. Default: false.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link import("./types.ts").KinetexOptions.allowPrivateNetwork}
|
|
81
|
+
*/
|
|
82
|
+
allowPrivateNetwork?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Per-request timeout in milliseconds.
|
|
85
|
+
*
|
|
86
|
+
* `fetch()` has no timeout of its own, so without this a hung request waits
|
|
87
|
+
* forever. `NodeHTTP2Transport` set its own `requestTimeoutMs`, but the
|
|
88
|
+
* HTTP/1.1 fallback it delegates to did not pass anything down — so
|
|
89
|
+
* `new NodeHTTP2Transport({ requestTimeoutMs: 500 })` against a slow host
|
|
90
|
+
* waited the full response time while the HTTP/2 path gave up at 500 ms.
|
|
91
|
+
*
|
|
92
|
+
* Omit for no timeout (the previous behaviour on this path).
|
|
93
|
+
*/
|
|
94
|
+
requestTimeoutMs?: number;
|
|
91
95
|
/**
|
|
92
96
|
* When `true`, invalid headers cause a `KinetexError` instead of being
|
|
93
97
|
* silently dropped. Recommended for strict/production environments where
|
|
@@ -106,6 +110,19 @@ export interface FetchTransportOptions {
|
|
|
106
110
|
* @param value - The header value that was dropped.
|
|
107
111
|
*/
|
|
108
112
|
onDroppedHeader?: (name: string, value: string) => void;
|
|
113
|
+
/**
|
|
114
|
+
* A `fetch` implementation extension passed straight through to the runtime,
|
|
115
|
+
* most usefully an `undici` dispatcher (`Agent`, `ProxyAgent`, `MockAgent`).
|
|
116
|
+
*
|
|
117
|
+
* Typed as `unknown` so this stays dependency-free — kinetex never imports,
|
|
118
|
+
* constructs, or type-checks against `undici`, it only forwards the value.
|
|
119
|
+
* Whether the runtime honours it is up to that runtime: Node's `fetch` reads
|
|
120
|
+
* `init.dispatcher`, Deno and Bun ignore it.
|
|
121
|
+
*
|
|
122
|
+
* Supplying a dispatcher forces {@link FetchTransport}, because the Node
|
|
123
|
+
* HTTP/2 transport talks to `node:http2` directly and has no notion of one.
|
|
124
|
+
*/
|
|
125
|
+
dispatcher?: unknown;
|
|
109
126
|
}
|
|
110
127
|
/**
|
|
111
128
|
* The accept-encoding value client.ts injects when the caller did not set
|
|
@@ -121,10 +138,37 @@ export declare class FetchTransport implements Transport {
|
|
|
121
138
|
private readonly fetchFn;
|
|
122
139
|
private readonly strict;
|
|
123
140
|
private readonly onDroppedHeader;
|
|
141
|
+
private readonly dispatcher;
|
|
142
|
+
/** Per-request timeout; omitted means no timeout. */
|
|
143
|
+
private readonly requestTimeoutMs;
|
|
144
|
+
/**
|
|
145
|
+
* Permit connections to hosts resolving into private/loopback space.
|
|
146
|
+
* Default: false.
|
|
147
|
+
*/
|
|
148
|
+
private readonly _allowPrivateNetwork;
|
|
124
149
|
/**
|
|
125
150
|
* @param fetchFnOrOptions - Custom fetch function or options object
|
|
126
151
|
*/
|
|
127
152
|
constructor(fetchFnOrOptions?: typeof globalThis.fetch | FetchTransportOptions);
|
|
153
|
+
/**
|
|
154
|
+
* Refuse a host that resolves into blocked address space.
|
|
155
|
+
*
|
|
156
|
+
* The Node transports close DNS rebinding properly: they resolve once and
|
|
157
|
+
* pin the checked address to the socket (`createPinnedLookup`). `fetch` has no
|
|
158
|
+
* resolver hook — undici owns the connection and exposes no way to install
|
|
159
|
+
* one — so the only place to intervene is before the call.
|
|
160
|
+
*
|
|
161
|
+
* That closes the case that matters in practice: a name resolving to loopback
|
|
162
|
+
* or the cloud metadata address is refused outright, which is the vector
|
|
163
|
+
* behind the classic SSRF-through-DNS attacks. What it cannot close is a
|
|
164
|
+
* resolver that answers public on this lookup and private on the connect a
|
|
165
|
+
* moment later. Closing *that* needs a resolver hook `fetch` does not offer,
|
|
166
|
+
* and claiming otherwise would be worse than saying so.
|
|
167
|
+
*
|
|
168
|
+
* The host has already passed the lexical screen by this point, so this is a
|
|
169
|
+
* second line of defence rather than the first.
|
|
170
|
+
*/
|
|
171
|
+
private assertReachableHost;
|
|
128
172
|
/**
|
|
129
173
|
* Send a request via the native fetch() API.
|
|
130
174
|
*
|
|
@@ -163,6 +207,27 @@ export declare class NodeHTTP2Transport implements Transport {
|
|
|
163
207
|
private readonly _requestTimeoutMs;
|
|
164
208
|
/** Cached HTTP/1.1 fallback transport — reuse instead of creating fresh FetchTransport per call */
|
|
165
209
|
private _http1Fallback;
|
|
210
|
+
/**
|
|
211
|
+
* Dedicated keep-alive agent for the legacy `node:https` path.
|
|
212
|
+
*
|
|
213
|
+
* This path called `https.request(options)` with no `agent`, so behaviour was
|
|
214
|
+
* whatever the global agent happened to do — and that default is a moving
|
|
215
|
+
* target. Node 19 turned `keepAlive` on for `https.globalAgent`, so this path
|
|
216
|
+
* silently changed from a TCP + TLS handshake per request (Node 18 and
|
|
217
|
+
* earlier) to pooled connections, with no code change here to explain it.
|
|
218
|
+
*
|
|
219
|
+
* An explicit agent makes the behaviour identical on every supported Node
|
|
220
|
+
* version, bounds the idle-socket pool (the global agent keeps 256 free
|
|
221
|
+
* sockets, which is a lot to hold open for a legacy fallback), and gives
|
|
222
|
+
* callers a way to opt out.
|
|
223
|
+
*/
|
|
224
|
+
/** Whether to permit connections into private/loopback address space. */
|
|
225
|
+
private readonly _allowPrivateNetwork;
|
|
226
|
+
private readonly _http1KeepAlive;
|
|
227
|
+
private readonly _http1MaxSockets;
|
|
228
|
+
private _http1Agent;
|
|
229
|
+
/** HTTP(S) CONNECT proxy, or undefined for a direct connection. */
|
|
230
|
+
private readonly _proxy;
|
|
166
231
|
/**
|
|
167
232
|
* @param options - Session pool and transport configuration
|
|
168
233
|
*/
|
|
@@ -178,6 +243,32 @@ export declare class NodeHTTP2Transport implements Transport {
|
|
|
178
243
|
connectTimeoutMs?: number;
|
|
179
244
|
/** HTTP/2 per-stream request timeout in ms. Default: 30 000 */
|
|
180
245
|
requestTimeoutMs?: number;
|
|
246
|
+
/** Reuse TCP sockets on the legacy node:https path. Default: true */
|
|
247
|
+
http1KeepAlive?: boolean;
|
|
248
|
+
/** Max idle sockets retained by the legacy keep-alive agent. Default: 16 */
|
|
249
|
+
http1MaxSockets?: number;
|
|
250
|
+
/**
|
|
251
|
+
* Route every connection through this HTTP(S) proxy using `CONNECT`.
|
|
252
|
+
* Node.js only.
|
|
253
|
+
*/
|
|
254
|
+
proxy?: import("./types.ts").ProxyConfig;
|
|
255
|
+
/**
|
|
256
|
+
* Permit connections to hosts that resolve into private, loopback or
|
|
257
|
+
* link-local address space. Default: `false`.
|
|
258
|
+
*
|
|
259
|
+
* A hostname is screened as written, but the socket is dialled at whatever
|
|
260
|
+
* that name *resolves to*, and nothing between the two re-checked the
|
|
261
|
+
* answer. Without this, a name that answered with `127.0.0.1` reached a
|
|
262
|
+
* loopback service and one that answered with `169.254.169.254` reached a
|
|
263
|
+
* cloud metadata endpoint — DNS rebinding, needing only control of the
|
|
264
|
+
* domain being requested.
|
|
265
|
+
*
|
|
266
|
+
* Set this to reach a service on `localhost`, a private network, or a
|
|
267
|
+
* container network — which is most local development, and every test
|
|
268
|
+
* that stands up a local server. Leave it unset for anything processing
|
|
269
|
+
* untrusted URLs.
|
|
270
|
+
*/
|
|
271
|
+
allowPrivateNetwork?: boolean;
|
|
181
272
|
});
|
|
182
273
|
/**
|
|
183
274
|
* Get or create a session for the given origin, properly serialising concurrent
|
|
@@ -200,6 +291,16 @@ export declare class NodeHTTP2Transport implements Transport {
|
|
|
200
291
|
* @returns Raw response from the server
|
|
201
292
|
*/
|
|
202
293
|
send(req: KinetexRequest): Promise<RawResponse>;
|
|
294
|
+
/**
|
|
295
|
+
* Refuse one header on the HTTP/2 path. Strict mode raises `EVALIDATION`
|
|
296
|
+
* before anything is dialled; non-strict notifies the callback (if any) and
|
|
297
|
+
* warns, never dropping silently.
|
|
298
|
+
*
|
|
299
|
+
* Both the pseudo-header filter and the validation loop go through here so
|
|
300
|
+
* the two cannot drift apart, which is what let a caller-supplied `:path`
|
|
301
|
+
* reach the wire while `FetchTransport` dropped the identical header.
|
|
302
|
+
*/
|
|
303
|
+
private _rejectHeader;
|
|
203
304
|
/**
|
|
204
305
|
* Send a request over HTTP/2 with iterative redirect following.
|
|
205
306
|
* Each hop reuses or creates a session for the target origin.
|
|
@@ -213,6 +314,25 @@ export declare class NodeHTTP2Transport implements Transport {
|
|
|
213
314
|
* Legacy HTTP/1.1 via node:https for Node.js <18 (no global fetch).
|
|
214
315
|
*/
|
|
215
316
|
private _sendHTTP1Legacy;
|
|
317
|
+
/**
|
|
318
|
+
* Lazily create the keep-alive agent used by the legacy HTTP/1.1 path.
|
|
319
|
+
*
|
|
320
|
+
* @param https - The already-imported `node:https` module.
|
|
321
|
+
* @returns The shared agent, reused across requests.
|
|
322
|
+
*/
|
|
323
|
+
private _getHttp1Agent;
|
|
324
|
+
/**
|
|
325
|
+
* Open a socket to `origin` through the configured proxy.
|
|
326
|
+
*
|
|
327
|
+
* The returned socket is fully established — tunneled, and TLS-wrapped when
|
|
328
|
+
* the origin is `https:` — so it can be handed to a transport that requires
|
|
329
|
+
* its connection synchronously.
|
|
330
|
+
*
|
|
331
|
+
* @param origin - Target origin, e.g. `https://api.example.com:443`.
|
|
332
|
+
* @param req - Originating request, attached to any thrown error.
|
|
333
|
+
* @returns A socket connected to the target through the proxy.
|
|
334
|
+
*/
|
|
335
|
+
private _createProxiedSocket;
|
|
216
336
|
/** @internal Evict one session and its associated ping timer. */
|
|
217
337
|
private _evictSession;
|
|
218
338
|
/** Close all cached HTTP/2 sessions and their ping timers. */
|
|
@@ -227,12 +347,14 @@ export declare class NodeHTTP2Transport implements Transport {
|
|
|
227
347
|
* @param sessionOptions - HTTP/2 session pool options.
|
|
228
348
|
* @param transportOptions - Header validation options (strict mode, dropped-header callback).
|
|
229
349
|
*/
|
|
230
|
-
export declare function createTransport(fetchFn?: typeof globalThis.fetch, preferHTTP2?: boolean, sessionOptions?: {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
350
|
+
export declare function createTransport(fetchFn?: typeof globalThis.fetch, preferHTTP2?: boolean, sessionOptions?: SessionPoolConfig, transportOptions?: Pick<FetchTransportOptions, "strict" | "onDroppedHeader" | "dispatcher"> & {
|
|
351
|
+
/** CA certificate(s) trusted in addition to the system store. */
|
|
352
|
+
ca?: string | string[];
|
|
353
|
+
/** HTTP(S) CONNECT proxy (Node.js only). */
|
|
354
|
+
proxy?: import("./types.ts").ProxyConfig;
|
|
355
|
+
/** Permit connections to hosts resolving into private/loopback space. Default: false. */
|
|
356
|
+
allowPrivateNetwork?: boolean;
|
|
357
|
+
}): Transport;
|
|
236
358
|
/**
|
|
237
359
|
* Wrap a transport with a per-request timeout.
|
|
238
360
|
* Works by racing the transport promise against a timeout promise.
|
|
@@ -273,6 +395,52 @@ export declare function readRawBody(stream: ReadableStream<Uint8Array> | null, m
|
|
|
273
395
|
* @returns Parsed body value (T, string, or Uint8Array)
|
|
274
396
|
*/
|
|
275
397
|
export declare function parseBody<T>(raw: Uint8Array, contentType: string | null, customParser?: (raw: Uint8Array, headers: Record<string, string>, url: string) => T | Promise<T>, onParseFailure?: (raw: Uint8Array, error: Error) => void, headers?: Record<string, string>, url?: string): T | Promise<T>;
|
|
398
|
+
/**
|
|
399
|
+
* A `lookup` for node:http and node:http2 that closes the DNS-rebinding gap.
|
|
400
|
+
*
|
|
401
|
+
* `isSafeURL` reads the hostname the caller wrote. The socket, however, is
|
|
402
|
+
* dialled at whatever that hostname *resolves to*, and nothing between the two
|
|
403
|
+
* points re-checked the answer — so a name that resolves to a public address on
|
|
404
|
+
* the first lookup and to `127.0.0.1` on the second reached a private service.
|
|
405
|
+
* That is DNS rebinding, and it needs an attacker-controlled resolver, which is
|
|
406
|
+
* an ordinary capability for whoever controls the domain being requested.
|
|
407
|
+
*
|
|
408
|
+
* Resolving here and pinning the result closes it for the connection that
|
|
409
|
+
* follows: every address the resolver returns is checked against the same
|
|
410
|
+
* blocklist `isSafeURL` applies to a literal, and only a checked address is
|
|
411
|
+
* handed back for the dial. A name that resolves solely to private space fails
|
|
412
|
+
* instead of connecting.
|
|
413
|
+
*
|
|
414
|
+
* The alternative — checking the hostname again after connecting — is too late:
|
|
415
|
+
* the request is already on the wire.
|
|
416
|
+
*
|
|
417
|
+
* `dns.lookup` (not `resolve`) is used deliberately: it honours `/etc/hosts`,
|
|
418
|
+
* the resolver search list and `dns.setDefaultResultOrder`, so a host pinned in
|
|
419
|
+
* the system file resolves the way it would have without this, and the address
|
|
420
|
+
* handed back is the one the socket would have reached anyway.
|
|
421
|
+
*/
|
|
422
|
+
/**
|
|
423
|
+
* Drop every resolved address that falls in a blocked range.
|
|
424
|
+
*
|
|
425
|
+
* Exported separately from `createPinnedLookup` so the decision can be tested
|
|
426
|
+
* against addresses a resolver would have to be trusted to produce: a name
|
|
427
|
+
* that answers with a public address and a private one is the rebinding case,
|
|
428
|
+
* and it cannot be arranged offline through a real resolver.
|
|
429
|
+
*/
|
|
430
|
+
export declare function filterSafeAddresses<T extends {
|
|
431
|
+
address: string;
|
|
432
|
+
family?: number;
|
|
433
|
+
}>(addresses: readonly T[]): T[];
|
|
434
|
+
/**
|
|
435
|
+
* The refusal a host whose every resolved address is blocked earns.
|
|
436
|
+
*
|
|
437
|
+
* Split out from {@link FetchTransport} so the message and code can be
|
|
438
|
+
* asserted without arranging a resolver that answers with a blocked address.
|
|
439
|
+
*/
|
|
440
|
+
export declare function blockedHostError(url: string, addresses: ReadonlyArray<{
|
|
441
|
+
address: string;
|
|
442
|
+
}>): KinetexError;
|
|
443
|
+
export declare function createPinnedLookup(): import("node:net").LookupFunction;
|
|
276
444
|
/**
|
|
277
445
|
* Normalize a Headers object to a plain record.
|
|
278
446
|
*
|
|
@@ -281,13 +449,36 @@ export declare function parseBody<T>(raw: Uint8Array, contentType: string | null
|
|
|
281
449
|
* @returns Plain key-value record
|
|
282
450
|
*/
|
|
283
451
|
export declare function normalizeHeaders(headers: Headers): Record<string, string>;
|
|
452
|
+
/**
|
|
453
|
+
* Encode a `FormData` as `multipart/form-data` (RFC 7578).
|
|
454
|
+
*
|
|
455
|
+
* The function this lives in was written to stop the raw Node transports from
|
|
456
|
+
* sending an *empty* body for the types fetch would have serialized, and it
|
|
457
|
+
* covered `URLSearchParams` and `Blob`. `FormData` was missed, so on the
|
|
458
|
+
* default transport on Node — `NodeHTTP2Transport`, which bypasses fetch
|
|
459
|
+
* entirely — a form upload went out as a request with no body at all and no
|
|
460
|
+
* `Content-Type`, and the server recorded an empty form. The response was an
|
|
461
|
+
* ordinary 200, so nothing looked wrong.
|
|
462
|
+
*
|
|
463
|
+
* The boundary is generated per call and written into the body. The transports
|
|
464
|
+
* that call this only ever see bytes, so the header is set by the client from
|
|
465
|
+
* `options.headers`; a body encoded here without a matching header is
|
|
466
|
+
* unparseable, which is why the boundary is returned alongside the bytes for a
|
|
467
|
+
* caller that has to announce it. Passing one in makes the output
|
|
468
|
+
* deterministic, which is what the test suite pins.
|
|
469
|
+
*/
|
|
470
|
+
export declare function encodeMultipart(form: FormData, boundary?: string): Promise<{
|
|
471
|
+
bytes: Uint8Array;
|
|
472
|
+
boundary: string;
|
|
473
|
+
}>;
|
|
284
474
|
/**
|
|
285
475
|
* Apply content-encoding decompression to a raw body stream.
|
|
286
476
|
* Dynamically imports response.ts so that environments that don't use
|
|
287
477
|
* decompression don't pay the code cost. The import is cached by the runtime.
|
|
288
478
|
*
|
|
289
|
-
* Supported encodings: gzip, deflate, br (brotli)
|
|
290
|
-
* Unsupported encodings
|
|
479
|
+
* Supported encodings: gzip, deflate, br (brotli), zstd.
|
|
480
|
+
* Unsupported encodings are passed through compressed; the caller must handle
|
|
481
|
+
* them.
|
|
291
482
|
*
|
|
292
483
|
* @param body - Raw body stream (or null)
|
|
293
484
|
* @param headers - Response headers (content-encoding is read and stripped on success)
|
package/dist/types/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAgC,MAAM,YAAY,CAAC;AAgBxE;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAiCvC;AAED,2DAA2D;AAC3D,eAAO,MAAM,OAAO,EAAE,OAAyB,CAAC;AAoChD,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAanD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,SAAqB,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAA+D,CAAC;AAoB7F;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,sEAAsE;IACtE,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACxC,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,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M,EACX,SAAS,EAAE,aAAa,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAC5C,YAAY,CAOd;AAED,wBAAgB,kBAAkB,IAAI,OAAO,UAAU,EAAE,cAAc,CA4CtE;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzE;AAsSD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,QAAQ,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAsClD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAsC5C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA+DpD,CAAC"}
|
package/dist/types/dedup.d.ts
CHANGED
|
@@ -41,7 +41,36 @@ export interface DedupOptions {
|
|
|
41
41
|
* @experimental
|
|
42
42
|
*/
|
|
43
43
|
signal?: AbortSignal;
|
|
44
|
+
/**
|
|
45
|
+
* Timer functions used for the coalescing window.
|
|
46
|
+
*
|
|
47
|
+
* Defaults to the globals. Injecting them lets a test drive the window
|
|
48
|
+
* without replacing `globalThis.setTimeout` — which, when done at module
|
|
49
|
+
* scope, also captures every unrelated timer in the process. That is not
|
|
50
|
+
* hypothetical: undici's HTTP/1 parser calls `setTimeout` and then `.unref()`s
|
|
51
|
+
* the result, so a stub returning a plain number crashed a run outright as
|
|
52
|
+
* soon as any socket was open.
|
|
53
|
+
*/
|
|
54
|
+
timers?: {
|
|
55
|
+
setTimeout: (fn: () => void, ms: number) => ReturnType<typeof setTimeout>;
|
|
56
|
+
clearTimeout: (handle: ReturnType<typeof setTimeout>) => void;
|
|
57
|
+
};
|
|
44
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* A stable, opaque digest of everything that makes a request distinct.
|
|
61
|
+
*
|
|
62
|
+
* Hashing rather than concatenating keeps credentials out of the key: a dedup
|
|
63
|
+
* map is a long-lived map of strings, and its keys should not be a place where
|
|
64
|
+
* an `Authorization` header sits in plain text. Returns `""` when no header
|
|
65
|
+
* distinguishes the request, so the common unauthenticated case keys on method
|
|
66
|
+
* and URL alone.
|
|
67
|
+
*/
|
|
68
|
+
export declare function identityFingerprint(headers: Record<string, string> | undefined): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Build a dedup key from a method, URL and identity digest.
|
|
71
|
+
*/
|
|
72
|
+
export declare function dedupKeyFrom(method: string, url: string, fingerprint: string): string;
|
|
73
|
+
export declare function defaultDedupKey(method: string, url: string, headers?: Record<string, string>): string;
|
|
45
74
|
/**
|
|
46
75
|
* `DedupMap` manages in-flight promises keyed by a request fingerprint.
|
|
47
76
|
* It is transport-agnostic — pass any async factory function.
|
|
@@ -49,6 +78,9 @@ export interface DedupOptions {
|
|
|
49
78
|
export declare class DedupMap<T = unknown> {
|
|
50
79
|
private readonly inflight;
|
|
51
80
|
private readonly timeouts;
|
|
81
|
+
/** Window timers, overridable for tests. See {@link DedupOptions.timers}. */
|
|
82
|
+
private readonly _setTimeout;
|
|
83
|
+
private readonly _clearTimeout;
|
|
52
84
|
private readonly windowMs;
|
|
53
85
|
private readonly methods;
|
|
54
86
|
private readonly keyFn;
|
|
@@ -81,9 +113,12 @@ export declare class DedupMap<T = unknown> {
|
|
|
81
113
|
* entry and creating a new one. The first caller becomes the "leader" and all
|
|
82
114
|
* subsequent callers within the same tick share the same promise.
|
|
83
115
|
*
|
|
84
|
-
* Note:
|
|
85
|
-
*
|
|
86
|
-
*
|
|
116
|
+
* Note: the default key includes the request headers, so two requests to the
|
|
117
|
+
* same URL carrying different `Authorization` or `Cookie` are separate
|
|
118
|
+
* requests and are never coalesced. A key of method + URL alone was the
|
|
119
|
+
* default once, and it handed one caller's response to another: 50 callers
|
|
120
|
+
* aside, even two callers for different tenants shared a single response.
|
|
121
|
+
* See {@link defaultDedupKey}.
|
|
87
122
|
*/
|
|
88
123
|
execute(method: string, url: string, factory: () => Promise<T>, headers?: Record<string, string>, windowMs?: number, signal?: AbortSignal): Promise<T>;
|
|
89
124
|
/** Number of requests that shared an in-flight or windowed response. */
|