@openclaw/proxyline 0.2.0 → 0.3.1
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/CHANGELOG.md +11 -1
- package/LICENSE +1 -0
- package/README.md +15 -15
- package/dist/dispatcher-brand.d.ts +3 -0
- package/dist/dispatcher-brand.d.ts.map +1 -0
- package/dist/dispatcher-brand.js +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/node-http.d.ts +2 -2
- package/dist/node-http.d.ts.map +1 -1
- package/dist/node-http.js +17 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +171 -33
- package/dist/types.d.ts +18 -1
- package/dist/types.d.ts.map +1 -1
- package/docs/CNAME +1 -0
- package/docs/README.md +34 -0
- package/docs/api-reference.md +280 -0
- package/docs/environment-variables.md +70 -0
- package/docs/getting-started.md +82 -0
- package/docs/index.md +46 -0
- package/docs/modes.md +68 -0
- package/docs/observability.md +98 -0
- package/docs/proxy-tls.md +66 -0
- package/docs/security.md +83 -0
- package/docs/surfaces.md +116 -0
- package/docs/testing.md +78 -0
- package/docs/troubleshooting.md +71 -0
- package/package.json +17 -5
- package/scripts/prepack-build.mjs +32 -0
- package/src/connect.ts +222 -0
- package/src/dispatcher-brand.ts +13 -0
- package/src/env.ts +250 -0
- package/src/index.ts +27 -0
- package/src/node-http.ts +901 -0
- package/src/runtime.ts +906 -0
- package/src/shared.ts +42 -0
- package/src/types.ts +98 -0
- package/tsconfig.build.json +8 -0
- package/tsconfig.json +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.3.1 - 2026-05-16
|
|
4
|
+
|
|
5
|
+
- Fixed `withBypass()` to scope temporary bypasses to the calling async context instead of process-wide state.
|
|
6
|
+
- Fixed HTTPS SNI preservation when Node request options override a URL hostname.
|
|
7
|
+
- Hardened package and docs release output by preserving declaration-map sources, shipping product docs, rejecting duplicate docs pages, avoiding lockfile-bypassing prepack installs, and keeping package artifact checks portable on Windows.
|
|
8
|
+
|
|
9
|
+
## 0.3.0 - 2026-05-15
|
|
10
|
+
|
|
11
|
+
- Added branded Proxyline dispatcher detection, reusable active-runtime installs, scoped dynamic bypass registration, first-class undici dispatcher tuning options, and a side-effect-light dispatcher detection subpath.
|
|
12
|
+
- Fixed async scoped bypass lifetimes, ambient runtime reuse compatibility checks, WebSocket surface matching, and zero-valued undici timeout handling.
|
|
13
|
+
- Moved `undici` to a peer dependency so host applications share one global dispatcher runtime with Proxyline.
|
|
4
14
|
|
|
5
15
|
## 0.2.0 - 2026-05-14
|
|
6
16
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Proxyline
|
|
1
|
+
# 🌐 Proxyline
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@openclaw/proxyline)
|
|
4
4
|
[](https://nodejs.org/)
|
|
@@ -17,9 +17,11 @@ Website: [proxyline.dev](https://proxyline.dev)
|
|
|
17
17
|
- **Two modes.** `managed` forces traffic through a configured proxy and fails closed on bad config. `ambient` reads `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY` for tooling that needs environment compatibility.
|
|
18
18
|
- **Covers the surfaces that matter.** `http.request`, `http.get`, `https.request`, `https.get`, both global agents, the undici global dispatcher, and helpers for WebSocket agents and HTTP CONNECT sockets.
|
|
19
19
|
- **Replaces caller agents.** In managed mode and active ambient mode, a per-request `http.Agent` passed by a library does not bypass the proxy. TLS options on the caller agent (`ca`, `cert`, `key`, `rejectUnauthorized`, …) are preserved so destination TLS still validates.
|
|
20
|
+
- **Intentional bypasses only.** Managed mode can accept a `bypassPolicy` callback, process-wide `registerBypass()`, or async-scoped `withBypass()` calls for trusted loopback or control-plane traffic that must stay direct; every bypass is visible through `explain()`.
|
|
21
|
+
- **Embeddable runtime controls.** `ifActive` handles process singleton reuse/replacement, `undici` options tune dispatcher defaults, and `isProxylineDispatcher()` identifies Proxyline-owned dispatchers without constructor-name checks.
|
|
20
22
|
- **Scoped proxy CA trust.** `proxyTls.ca` / `proxyTls.caFile` trust a private CA for the proxy endpoint only — no `NODE_EXTRA_CA_CERTS` and no `NODE_TLS_REJECT_UNAUTHORIZED=0`.
|
|
21
23
|
- **Observable.** `proxy.explain(url)` returns a structured decision (`proxied` / `direct` with a `reason`), and an `onEvent` callback receives `runtime.installed`, `runtime.stopped`, and per-decision events. Proxy URLs are credential-redacted.
|
|
22
|
-
- **Restoreable.** `proxy.stop()` restores the captured Node HTTP(S) methods, global agents, undici dispatcher, and fetch globals. The runtime is a process-wide singleton
|
|
24
|
+
- **Restoreable.** `proxy.stop()` restores the captured Node HTTP(S) methods, global agents, undici dispatcher, and fetch globals. The runtime is a process-wide singleton; by default a second active install throws `RUNTIME_ALREADY_ACTIVE`, while `ifActive` can reuse or replace intentionally.
|
|
23
25
|
|
|
24
26
|
## Install
|
|
25
27
|
|
|
@@ -29,7 +31,7 @@ pnpm add @openclaw/proxyline
|
|
|
29
31
|
npm install @openclaw/proxyline
|
|
30
32
|
```
|
|
31
33
|
|
|
32
|
-
Requires Node 20.18.1
|
|
34
|
+
Requires Node 20.18.1+ and a host `undici` dependency compatible with `>=7.25.0 <9`.
|
|
33
35
|
|
|
34
36
|
## Quick start
|
|
35
37
|
|
|
@@ -97,18 +99,16 @@ const agent = createAmbientNodeProxyAgent({
|
|
|
97
99
|
The helper returns `undefined` when ambient proxy env is not configured, so callers can pass an agent only when needed.
|
|
98
100
|
It uses Proxyline's built-in HTTP/HTTPS Node agent, and `proxyTls` applies only to HTTPS proxy endpoints. SOCKS and PAC proxy schemes remain unsupported.
|
|
99
101
|
|
|
100
|
-
##
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| Raw `net.connect` / `tls.connect` | no | out of scope, see [Security](./docs/security.md) |
|
|
111
|
-
| Native or private transport stacks | no | out of scope, see [Security](./docs/security.md) |
|
|
102
|
+
## Product coverage
|
|
103
|
+
|
|
104
|
+
- `http.request` / `http.get`: covered by global method patching and global agent replacement.
|
|
105
|
+
- `https.request` / `https.get`: covered by global method patching and global agent replacement.
|
|
106
|
+
- `fetch` / undici global dispatcher: covered by the `globalThis.fetch` patch and `setGlobalDispatcher`.
|
|
107
|
+
- WebSocket clients accepting a Node `agent`: covered with `proxy.createWebSocketAgent()`.
|
|
108
|
+
- Caller-built `http.Agent` / `https.Agent`: overridden in managed and active ambient mode, with TLS options preserved.
|
|
109
|
+
- Explicit HTTP CONNECT sockets: covered with `openProxyConnectTunnel()`.
|
|
110
|
+
- Raw `net.connect` / `tls.connect`: out of scope; see [Security](./docs/security.md).
|
|
111
|
+
- Native or private transport stacks: out of scope; see [Security](./docs/security.md).
|
|
112
112
|
|
|
113
113
|
## Why not just env vars?
|
|
114
114
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher-brand.d.ts","sourceRoot":"","sources":["../src/dispatcher-brand.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,eAA+C,CAAC;AAMvF,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAIlE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { openProxyConnectTunnel, type OpenProxyConnectTunnelOptions } from "./connect.js";
|
|
2
2
|
export { createAmbientNodeProxyAgent, hasAmbientNodeProxyConfigured, type AmbientNodeProxyAgentOptions, } from "./node-http.js";
|
|
3
3
|
export { installGlobalProxy, installProxyline } from "./runtime.js";
|
|
4
|
+
export { isProxylineDispatcher, PROXYLINE_DISPATCHER_BRAND } from "./dispatcher-brand.js";
|
|
4
5
|
export { ProxylineError, redactProxyUrl, resolveProxyTlsCa, type ProxylineTlsOptions, } from "./shared.js";
|
|
5
|
-
export type { ExplainOptions, ProxylineBypassPolicy, ProxylineBypassRequest, ProxylineDecision, ProxylineEvent, ProxylineHandle, ProxylineMode, ProxylineOptions, ProxylineSurface, } from "./types.js";
|
|
6
|
+
export type { ExplainOptions, ProxylineBypassRegistration, ProxylineBypassPolicy, ProxylineBypassRequest, ProxylineDecision, ProxylineEvent, ProxylineHandle, ProxylineMode, ProxylineOptions, ProxylineSurface, ProxylineUndiciOptions, } from "./types.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { openProxyConnectTunnel } from "./connect.js";
|
|
2
2
|
export { createAmbientNodeProxyAgent, hasAmbientNodeProxyConfigured, } from "./node-http.js";
|
|
3
3
|
export { installGlobalProxy, installProxyline } from "./runtime.js";
|
|
4
|
+
export { isProxylineDispatcher, PROXYLINE_DISPATCHER_BRAND } from "./dispatcher-brand.js";
|
|
4
5
|
export { ProxylineError, redactProxyUrl, resolveProxyTlsCa, } from "./shared.js";
|
package/dist/node-http.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import http from "node:http";
|
|
|
2
2
|
import https from "node:https";
|
|
3
3
|
import { type ProxyEnvSnapshot } from "./env.js";
|
|
4
4
|
import { type ProxylineTlsOptions } from "./shared.js";
|
|
5
|
-
import type { ProxyResolver } from "./types.js";
|
|
5
|
+
import type { ProxylineSurface, ProxyResolver } from "./types.js";
|
|
6
6
|
export type NodeHttpRequestOptions = http.RequestOptions & https.RequestOptions & {
|
|
7
7
|
agent?: http.Agent | false;
|
|
8
8
|
};
|
|
@@ -14,7 +14,7 @@ type NodeAgentRequestOptions = http.RequestOptions & https.RequestOptions & {
|
|
|
14
14
|
};
|
|
15
15
|
type NodeProxyAgentOptions = NodeAgentOptions & {
|
|
16
16
|
defaultProtocol?: "http" | "https";
|
|
17
|
-
getProxyForUrl: (url: string, request?: http.ClientRequest) => string;
|
|
17
|
+
getProxyForUrl: (url: string, surface?: ProxylineSurface, request?: http.ClientRequest) => string;
|
|
18
18
|
proxyTls?: ProxylineTlsOptions;
|
|
19
19
|
};
|
|
20
20
|
export declare const CALLER_AGENT_TLS_OPTION_KEYS: readonly ["ca", "cert", "ciphers", "clientCertEngine", "crl", "dhparam", "ecdhCurve", "honorCipherOrder", "key", "maxVersion", "minVersion", "passphrase", "pfx", "rejectUnauthorized", "secureOptions", "secureProtocol", "sessionIdContext"];
|
package/dist/node-http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-http.d.ts","sourceRoot":"","sources":["../src/node-http.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAI/B,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAqC,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"node-http.d.ts","sourceRoot":"","sources":["../src/node-http.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAI/B,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAqC,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,GAAG;IAChF,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;CAC5B,CAAC;AAEF,KAAK,cAAc,GAAG,OAAO,IAAI,CAAC,OAAO,CAAC;AAC1C,KAAK,gBAAgB,GAAG,CAAC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nC;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,QAAQ,CAAC,MAAM,EAAE,MAAM,EAEjC;IAEM,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,GAAG,MAAM;IAsCjE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI;IA6BlE,OAAO,IAAI,IAAI;CAShC;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,eAAe,GAAE,MAAM,GAAG,OAAgB,GACzC,uBAAuB,CAMzB;AAED,wBAAgB,qBAAqB,IAAI,uBAAuB,CAI/D;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,CAAC;AAMF,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAIT;AAED,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,4BAAiC,GACzC,uBAAuB,GAAG,SAAS,CAWrC"}
|
package/dist/node-http.js
CHANGED
|
@@ -53,15 +53,18 @@ function preserveCallerAgentOptions(options) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
function unbracketHostname(hostname) {
|
|
57
|
+
return hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
58
|
+
}
|
|
56
59
|
function inferDestinationHostname(url, options) {
|
|
57
|
-
if (url !== undefined) {
|
|
58
|
-
return url instanceof URL ? url.hostname : new URL(url).hostname;
|
|
59
|
-
}
|
|
60
60
|
if (typeof options.hostname === "string") {
|
|
61
|
-
return options.hostname;
|
|
61
|
+
return unbracketHostname(options.hostname);
|
|
62
|
+
}
|
|
63
|
+
if (url !== undefined) {
|
|
64
|
+
return unbracketHostname(url instanceof URL ? url.hostname : new URL(url).hostname);
|
|
62
65
|
}
|
|
63
66
|
if (typeof options.host === "string") {
|
|
64
|
-
return options.host.
|
|
67
|
+
return unbracketHostname(splitHostPort(options.host).host);
|
|
65
68
|
}
|
|
66
69
|
return undefined;
|
|
67
70
|
}
|
|
@@ -227,6 +230,12 @@ function isSecureEndpoint(options, stackProtocol) {
|
|
|
227
230
|
function shouldTunnelRequest(req, options, stackProtocol) {
|
|
228
231
|
return isSecureEndpoint(options, stackProtocol) || isWebSocketRequest(req);
|
|
229
232
|
}
|
|
233
|
+
function requestSurface(req, options, stackProtocol) {
|
|
234
|
+
if (isWebSocketRequest(req)) {
|
|
235
|
+
return "websocket";
|
|
236
|
+
}
|
|
237
|
+
return isSecureEndpoint(options, stackProtocol) ? "node-https" : "node-http";
|
|
238
|
+
}
|
|
230
239
|
function splitHostPort(value) {
|
|
231
240
|
const bracketed = value.match(/^\[([^\]]+)\](?::(\d+))?$/);
|
|
232
241
|
if (bracketed) {
|
|
@@ -595,7 +604,7 @@ export class ProxylineNodeProxyAgent extends http.Agent {
|
|
|
595
604
|
// Node's http.Agent constructor assigns this, but this wrapper is dual-use.
|
|
596
605
|
}
|
|
597
606
|
getProxyForUrl(url, request) {
|
|
598
|
-
return this.#getProxyForUrl(url, request);
|
|
607
|
+
return this.#getProxyForUrl(url, undefined, request);
|
|
599
608
|
}
|
|
600
609
|
#callStackProtocol() {
|
|
601
610
|
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
@@ -638,7 +647,8 @@ export class ProxylineNodeProxyAgent extends http.Agent {
|
|
|
638
647
|
? { ...options, secureEndpoint: true }
|
|
639
648
|
: options;
|
|
640
649
|
const url = requestDestinationUrl(req, agentOptions, stackProtocol);
|
|
641
|
-
const
|
|
650
|
+
const surface = requestSurface(req, agentOptions, stackProtocol);
|
|
651
|
+
const proxy = this.#getProxyForUrl(url, surface, req);
|
|
642
652
|
if (!proxy) {
|
|
643
653
|
(isSecureEndpoint(agentOptions, stackProtocol) ? this.#httpsAgent : this.#httpAgent)
|
|
644
654
|
.addRequest(req, agentOptions);
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAIV,eAAe,EACf,gBAAgB,EAIjB,MAAM,YAAY,CAAC;AA0tBpB,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAgI3E;AAED,eAAO,MAAM,kBAAkB,yBAAmB,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import https from "node:https";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
4
|
import { Agent as UndiciAgent, Dispatcher, FormData as UndiciFormData, Headers as UndiciHeaders, Request as UndiciRequest, Response as UndiciResponse, errors as undiciErrors, fetch as undiciFetch, getGlobalDispatcher, ProxyAgent as UndiciProxyAgent, setGlobalDispatcher, } from "undici";
|
|
4
5
|
import { createAmbientProxyResolver, EMPTY_PROXY_ENV, resolveAmbientProxyForUrl, readProxyEnv, } from "./env.js";
|
|
5
6
|
import { bindNodeHttpMethod, createDirectNodeAgent, createNodeProxyAgent, } from "./node-http.js";
|
|
6
7
|
import { formatUrl, ProxylineError, redactProxyUrl, resolveProxyTlsCa, } from "./shared.js";
|
|
8
|
+
import { PROXYLINE_DISPATCHER_BRAND } from "./dispatcher-brand.js";
|
|
7
9
|
let activeRuntime;
|
|
10
|
+
let activeHandle;
|
|
8
11
|
// Node's global fetch types come from bundled undici-types, while the runtime
|
|
9
12
|
// implementation intentionally delegates to this package's undici dependency.
|
|
10
13
|
const proxylineHeaders = UndiciHeaders;
|
|
@@ -140,13 +143,60 @@ function isProxyableUrlProtocol(protocol) {
|
|
|
140
143
|
protocol === "ws:" ||
|
|
141
144
|
protocol === "wss:";
|
|
142
145
|
}
|
|
143
|
-
function shouldBypassManagedProxy(bypassPolicy, url, surface) {
|
|
146
|
+
function shouldBypassManagedProxy(bypassPolicy, bypasses, url, surface) {
|
|
147
|
+
if (bypasses.has(url, surface)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
144
150
|
if (bypassPolicy === undefined) {
|
|
145
151
|
return false;
|
|
146
152
|
}
|
|
147
153
|
return bypassPolicy({ surface, url: formatUrl(url) });
|
|
148
154
|
}
|
|
149
|
-
function
|
|
155
|
+
function bypassKey(url, surface) {
|
|
156
|
+
return `${surface ?? "*"}\n${formatUrl(url)}`;
|
|
157
|
+
}
|
|
158
|
+
function createDynamicBypassRegistry() {
|
|
159
|
+
const counts = new Map();
|
|
160
|
+
const scopedBypasses = new AsyncLocalStorage();
|
|
161
|
+
const hasScopedBypass = (url, surface) => {
|
|
162
|
+
const scoped = scopedBypasses.getStore();
|
|
163
|
+
return scoped !== undefined &&
|
|
164
|
+
(scoped.has(bypassKey(url, surface)) || scoped.has(bypassKey(url, undefined)));
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
add: (registration) => {
|
|
168
|
+
const key = bypassKey(registration.url, registration.surface);
|
|
169
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
170
|
+
let stopped = false;
|
|
171
|
+
return () => {
|
|
172
|
+
if (stopped) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
stopped = true;
|
|
176
|
+
const next = (counts.get(key) ?? 1) - 1;
|
|
177
|
+
if (next <= 0) {
|
|
178
|
+
counts.delete(key);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
counts.set(key, next);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
has: (url, surface) => hasScopedBypass(url, surface) ||
|
|
186
|
+
(counts.get(bypassKey(url, surface)) ?? 0) > 0 ||
|
|
187
|
+
(counts.get(bypassKey(url, undefined)) ?? 0) > 0,
|
|
188
|
+
runScoped: (registration, run) => {
|
|
189
|
+
const inherited = scopedBypasses.getStore();
|
|
190
|
+
const scoped = new Set(inherited);
|
|
191
|
+
scoped.add(bypassKey(registration.url, registration.surface));
|
|
192
|
+
return scopedBypasses.run(scoped, run);
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function proxyEnvSnapshotKey(env) {
|
|
197
|
+
return JSON.stringify(env ?? EMPTY_PROXY_ENV);
|
|
198
|
+
}
|
|
199
|
+
function createManagedProxyResolver(proxyUrl, bypassPolicy, bypasses) {
|
|
150
200
|
const redactedProxyUrl = redactProxyUrl(proxyUrl);
|
|
151
201
|
return {
|
|
152
202
|
active: true,
|
|
@@ -161,7 +211,7 @@ function createManagedProxyResolver(proxyUrl, bypassPolicy) {
|
|
|
161
211
|
url: formattedUrl,
|
|
162
212
|
};
|
|
163
213
|
}
|
|
164
|
-
if (shouldBypassManagedProxy(bypassPolicy, url, surface)) {
|
|
214
|
+
if (shouldBypassManagedProxy(bypassPolicy, bypasses, url, surface)) {
|
|
165
215
|
return {
|
|
166
216
|
kind: "direct",
|
|
167
217
|
reason: "managed-proxy-bypass-policy",
|
|
@@ -177,34 +227,79 @@ function createManagedProxyResolver(proxyUrl, bypassPolicy) {
|
|
|
177
227
|
proxyUrl: redactedProxyUrl,
|
|
178
228
|
};
|
|
179
229
|
},
|
|
180
|
-
getProxyForUrl: (url) => {
|
|
230
|
+
getProxyForUrl: (url, surface = "unknown") => {
|
|
181
231
|
const protocol = new URL(url).protocol;
|
|
182
232
|
return isProxyableUrlProtocol(protocol) &&
|
|
183
|
-
!shouldBypassManagedProxy(bypassPolicy, url,
|
|
233
|
+
!shouldBypassManagedProxy(bypassPolicy, bypasses, url, surface)
|
|
184
234
|
? proxyUrl.href
|
|
185
235
|
: "";
|
|
186
236
|
},
|
|
187
237
|
};
|
|
188
238
|
}
|
|
189
|
-
function
|
|
239
|
+
function finiteNonNegativeInteger(value) {
|
|
240
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0
|
|
241
|
+
? Math.floor(value)
|
|
242
|
+
: undefined;
|
|
243
|
+
}
|
|
244
|
+
function finitePositiveInteger(value) {
|
|
245
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0
|
|
246
|
+
? Math.floor(value)
|
|
247
|
+
: undefined;
|
|
248
|
+
}
|
|
249
|
+
function resolveUndiciBaseOptions(options) {
|
|
250
|
+
const bodyTimeout = finiteNonNegativeInteger(options?.bodyTimeout);
|
|
251
|
+
const headersTimeout = finiteNonNegativeInteger(options?.headersTimeout);
|
|
252
|
+
return {
|
|
253
|
+
...(options?.allowH2 !== undefined ? { allowH2: options.allowH2 } : {}),
|
|
254
|
+
...(bodyTimeout !== undefined ? { bodyTimeout } : {}),
|
|
255
|
+
...(headersTimeout !== undefined ? { headersTimeout } : {}),
|
|
256
|
+
...(options?.connect !== undefined
|
|
257
|
+
? {
|
|
258
|
+
connect: {
|
|
259
|
+
...(options.connect.autoSelectFamily !== undefined
|
|
260
|
+
? { autoSelectFamily: options.connect.autoSelectFamily }
|
|
261
|
+
: {}),
|
|
262
|
+
...(finitePositiveInteger(options.connect.autoSelectFamilyAttemptTimeout) !== undefined
|
|
263
|
+
? {
|
|
264
|
+
autoSelectFamilyAttemptTimeout: finitePositiveInteger(options.connect.autoSelectFamilyAttemptTimeout),
|
|
265
|
+
}
|
|
266
|
+
: {}),
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
: {}),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function createUndiciAgent(options) {
|
|
273
|
+
return new UndiciAgent(resolveUndiciBaseOptions(options));
|
|
274
|
+
}
|
|
275
|
+
function createUndiciProxyAgent(proxyUrl, options) {
|
|
276
|
+
return new UndiciProxyAgent({
|
|
277
|
+
...resolveUndiciBaseOptions(options.undici),
|
|
278
|
+
uri: proxyUrl,
|
|
279
|
+
...(options.proxyCa !== undefined ? { proxyTls: { ca: options.proxyCa } } : {}),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function createUndiciProxyDispatcher(options, dispatcherOptions) {
|
|
190
283
|
if (options.mode === "ambient") {
|
|
191
284
|
if (!options.active) {
|
|
192
|
-
return
|
|
285
|
+
return createUndiciAgent(dispatcherOptions.undici);
|
|
193
286
|
}
|
|
194
|
-
return new AmbientUndiciDispatcher(options.env,
|
|
287
|
+
return new AmbientUndiciDispatcher(options.env, dispatcherOptions);
|
|
195
288
|
}
|
|
196
|
-
return new ManagedUndiciDispatcher(options.resolver,
|
|
289
|
+
return new ManagedUndiciDispatcher(options.resolver, dispatcherOptions);
|
|
197
290
|
}
|
|
198
291
|
class ManagedUndiciDispatcher extends Dispatcher {
|
|
199
|
-
|
|
200
|
-
#
|
|
292
|
+
[PROXYLINE_DISPATCHER_BRAND] = true;
|
|
293
|
+
#directDispatcher;
|
|
294
|
+
#dispatcherOptions;
|
|
201
295
|
#proxyDispatchers = new Map();
|
|
202
296
|
#resolver;
|
|
203
297
|
#closedError;
|
|
204
|
-
constructor(resolver,
|
|
298
|
+
constructor(resolver, dispatcherOptions) {
|
|
205
299
|
super();
|
|
206
300
|
this.#resolver = resolver;
|
|
207
|
-
this.#
|
|
301
|
+
this.#dispatcherOptions = dispatcherOptions;
|
|
302
|
+
this.#directDispatcher = createUndiciAgent(dispatcherOptions.undici);
|
|
208
303
|
}
|
|
209
304
|
dispatch(options, handler) {
|
|
210
305
|
if (this.#closedError !== undefined) {
|
|
@@ -215,7 +310,7 @@ class ManagedUndiciDispatcher extends Dispatcher {
|
|
|
215
310
|
return false;
|
|
216
311
|
}
|
|
217
312
|
const url = resolveUndiciDispatchUrl(options);
|
|
218
|
-
const proxyUrl = url === undefined ? "" : this.#resolver.getProxyForUrl(url);
|
|
313
|
+
const proxyUrl = url === undefined ? "" : this.#resolver.getProxyForUrl(url, "undici");
|
|
219
314
|
const dispatcher = proxyUrl === "" ? this.#directDispatcher : this.#proxyDispatcher(proxyUrl);
|
|
220
315
|
return dispatcher.dispatch(options, handler);
|
|
221
316
|
}
|
|
@@ -240,10 +335,7 @@ class ManagedUndiciDispatcher extends Dispatcher {
|
|
|
240
335
|
if (existing !== undefined) {
|
|
241
336
|
return existing;
|
|
242
337
|
}
|
|
243
|
-
const dispatcher =
|
|
244
|
-
uri: proxyUrl,
|
|
245
|
-
...(this.#proxyCa !== undefined ? { proxyTls: { ca: this.#proxyCa } } : {}),
|
|
246
|
-
});
|
|
338
|
+
const dispatcher = createUndiciProxyAgent(proxyUrl, this.#dispatcherOptions);
|
|
247
339
|
this.#proxyDispatchers.set(proxyUrl, dispatcher);
|
|
248
340
|
return dispatcher;
|
|
249
341
|
}
|
|
@@ -267,15 +359,17 @@ class ManagedUndiciDispatcher extends Dispatcher {
|
|
|
267
359
|
}
|
|
268
360
|
}
|
|
269
361
|
class AmbientUndiciDispatcher extends Dispatcher {
|
|
270
|
-
|
|
362
|
+
[PROXYLINE_DISPATCHER_BRAND] = true;
|
|
363
|
+
#directDispatcher;
|
|
364
|
+
#dispatcherOptions;
|
|
271
365
|
#env;
|
|
272
|
-
#proxyCa;
|
|
273
366
|
#proxyDispatchers = new Map();
|
|
274
367
|
#closedError;
|
|
275
|
-
constructor(env,
|
|
368
|
+
constructor(env, dispatcherOptions) {
|
|
276
369
|
super();
|
|
277
370
|
this.#env = env;
|
|
278
|
-
this.#
|
|
371
|
+
this.#dispatcherOptions = dispatcherOptions;
|
|
372
|
+
this.#directDispatcher = createUndiciAgent(dispatcherOptions.undici);
|
|
279
373
|
}
|
|
280
374
|
dispatch(options, handler) {
|
|
281
375
|
if (this.#closedError !== undefined) {
|
|
@@ -311,10 +405,7 @@ class AmbientUndiciDispatcher extends Dispatcher {
|
|
|
311
405
|
if (existing !== undefined) {
|
|
312
406
|
return existing;
|
|
313
407
|
}
|
|
314
|
-
const dispatcher =
|
|
315
|
-
uri: proxyUrl,
|
|
316
|
-
...(this.#proxyCa !== undefined ? { proxyTls: { ca: this.#proxyCa } } : {}),
|
|
317
|
-
});
|
|
408
|
+
const dispatcher = createUndiciProxyAgent(proxyUrl, this.#dispatcherOptions);
|
|
318
409
|
this.#proxyDispatchers.set(proxyUrl, dispatcher);
|
|
319
410
|
return dispatcher;
|
|
320
411
|
}
|
|
@@ -358,7 +449,7 @@ function restoreNodeHttpSnapshot(snapshot) {
|
|
|
358
449
|
https.get = snapshot.httpsGet;
|
|
359
450
|
https.globalAgent = snapshot.httpsGlobalAgent;
|
|
360
451
|
}
|
|
361
|
-
function installRuntime(resolver, dispatcherOptions, proxyCa) {
|
|
452
|
+
function installRuntime(resolver, dispatcherOptions, proxyCa, options) {
|
|
362
453
|
if (activeRuntime !== undefined) {
|
|
363
454
|
throw new ProxylineError("RUNTIME_ALREADY_ACTIVE", "Proxyline already has an active runtime.");
|
|
364
455
|
}
|
|
@@ -378,8 +469,13 @@ function installRuntime(resolver, dispatcherOptions, proxyCa) {
|
|
|
378
469
|
const originalHeaders = globalThis.Headers;
|
|
379
470
|
const originalRequest = globalThis.Request;
|
|
380
471
|
const originalResponse = globalThis.Response;
|
|
381
|
-
const installedDispatcher = createUndiciProxyDispatcher(dispatcherOptions,
|
|
472
|
+
const installedDispatcher = createUndiciProxyDispatcher(dispatcherOptions, {
|
|
473
|
+
proxyCa,
|
|
474
|
+
undici: options.undici,
|
|
475
|
+
});
|
|
382
476
|
const runtime = {
|
|
477
|
+
ambientEnv: options.ambientEnv,
|
|
478
|
+
bypassPolicy: options.bypassPolicy,
|
|
383
479
|
installedDispatcher,
|
|
384
480
|
mode: dispatcherOptions.mode,
|
|
385
481
|
nodeHttpAgent,
|
|
@@ -390,7 +486,10 @@ function installRuntime(resolver, dispatcherOptions, proxyCa) {
|
|
|
390
486
|
originalHeaders,
|
|
391
487
|
originalRequest,
|
|
392
488
|
originalResponse,
|
|
489
|
+
proxyCa,
|
|
490
|
+
proxyUrl: options.proxyUrl?.href,
|
|
393
491
|
snapshot,
|
|
492
|
+
undiciOptions: options.undici,
|
|
394
493
|
};
|
|
395
494
|
activeRuntime = runtime;
|
|
396
495
|
try {
|
|
@@ -438,24 +537,50 @@ function stopRuntime(runtime) {
|
|
|
438
537
|
runtime.nodeHttpAgent.destroy();
|
|
439
538
|
runtime.nodeHttpsAgent.destroy();
|
|
440
539
|
activeRuntime = undefined;
|
|
540
|
+
activeHandle = undefined;
|
|
441
541
|
}
|
|
442
542
|
export function installProxyline(options) {
|
|
443
543
|
const proxyUrl = options.mode === "managed" ? normalizeProxyUrl(options.proxyUrl) : undefined;
|
|
544
|
+
const ambientEnv = proxyUrl === undefined ? readProxyEnv() : undefined;
|
|
444
545
|
if (options.mode === "managed" && proxyUrl === undefined) {
|
|
445
546
|
throw new ProxylineError("MANAGED_PROXY_URL_REQUIRED", "Proxyline managed mode requires an explicit proxyUrl.");
|
|
446
547
|
}
|
|
548
|
+
const activePolicy = options.ifActive ?? "error";
|
|
549
|
+
if (activeRuntime !== undefined) {
|
|
550
|
+
if (activePolicy === "replace") {
|
|
551
|
+
activeHandle?.stop();
|
|
552
|
+
}
|
|
553
|
+
else if (activePolicy === "reuse-compatible" &&
|
|
554
|
+
activeHandle !== undefined &&
|
|
555
|
+
activeRuntime.mode === options.mode &&
|
|
556
|
+
activeRuntime.proxyUrl === proxyUrl?.href &&
|
|
557
|
+
proxyEnvSnapshotKey(activeRuntime.ambientEnv) === proxyEnvSnapshotKey(ambientEnv) &&
|
|
558
|
+
activeRuntime.proxyCa === resolveProxyTlsCa(options.proxyTls) &&
|
|
559
|
+
activeRuntime.bypassPolicy === options.bypassPolicy &&
|
|
560
|
+
JSON.stringify(activeRuntime.undiciOptions ?? {}) === JSON.stringify(options.undici ?? {})) {
|
|
561
|
+
return activeHandle;
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
throw new ProxylineError("RUNTIME_ALREADY_ACTIVE", "Proxyline already has an active runtime.");
|
|
565
|
+
}
|
|
566
|
+
}
|
|
447
567
|
let stopped = false;
|
|
448
568
|
const proxyCa = resolveProxyTlsCa(options.proxyTls);
|
|
449
|
-
const
|
|
569
|
+
const dynamicBypasses = createDynamicBypassRegistry();
|
|
450
570
|
const resolver = proxyUrl !== undefined
|
|
451
|
-
? createManagedProxyResolver(proxyUrl, options.bypassPolicy)
|
|
571
|
+
? createManagedProxyResolver(proxyUrl, options.bypassPolicy, dynamicBypasses)
|
|
452
572
|
: createAmbientProxyResolver(ambientEnv ?? EMPTY_PROXY_ENV);
|
|
453
573
|
const redactedProxyUrl = resolver.describeProxy();
|
|
454
574
|
const hasActiveProxy = resolver.active;
|
|
455
575
|
const runtime = hasActiveProxy
|
|
456
576
|
? installRuntime(resolver, proxyUrl !== undefined
|
|
457
577
|
? { mode: "managed", resolver }
|
|
458
|
-
: { mode: "ambient", env: ambientEnv ?? EMPTY_PROXY_ENV, active: hasActiveProxy }, proxyCa
|
|
578
|
+
: { mode: "ambient", env: ambientEnv ?? EMPTY_PROXY_ENV, active: hasActiveProxy }, proxyCa, {
|
|
579
|
+
ambientEnv,
|
|
580
|
+
bypassPolicy: options.bypassPolicy,
|
|
581
|
+
proxyUrl,
|
|
582
|
+
undici: options.undici,
|
|
583
|
+
})
|
|
459
584
|
: undefined;
|
|
460
585
|
emit(options.onEvent, {
|
|
461
586
|
type: "runtime.installed",
|
|
@@ -474,10 +599,10 @@ export function installProxyline(options) {
|
|
|
474
599
|
return createNodeProxyAgent(resolver, proxyCa);
|
|
475
600
|
},
|
|
476
601
|
createUndiciDispatcher: () => stopped
|
|
477
|
-
?
|
|
602
|
+
? createUndiciAgent(options.undici)
|
|
478
603
|
: createUndiciProxyDispatcher(proxyUrl !== undefined
|
|
479
604
|
? { mode: "managed", resolver }
|
|
480
|
-
: { mode: "ambient", env: ambientEnv ?? EMPTY_PROXY_ENV, active: hasActiveProxy }, proxyCa),
|
|
605
|
+
: { mode: "ambient", env: ambientEnv ?? EMPTY_PROXY_ENV, active: hasActiveProxy }, { proxyCa, undici: options.undici }),
|
|
481
606
|
createWebSocketAgent: () => {
|
|
482
607
|
if (!hasActiveProxy || stopped) {
|
|
483
608
|
return createDirectNodeAgent();
|
|
@@ -496,6 +621,12 @@ export function installProxyline(options) {
|
|
|
496
621
|
emit(options.onEvent, { type: "decision", decision });
|
|
497
622
|
return decision;
|
|
498
623
|
},
|
|
624
|
+
registerBypass: (registration) => {
|
|
625
|
+
if (stopped || proxyUrl === undefined) {
|
|
626
|
+
return () => { };
|
|
627
|
+
}
|
|
628
|
+
return dynamicBypasses.add(registration);
|
|
629
|
+
},
|
|
499
630
|
stop: () => {
|
|
500
631
|
if (stopped) {
|
|
501
632
|
return;
|
|
@@ -506,7 +637,14 @@ export function installProxyline(options) {
|
|
|
506
637
|
}
|
|
507
638
|
emit(options.onEvent, { type: "runtime.stopped", mode: options.mode });
|
|
508
639
|
},
|
|
640
|
+
withBypass: (registration, run) => {
|
|
641
|
+
if (stopped || proxyUrl === undefined) {
|
|
642
|
+
return run();
|
|
643
|
+
}
|
|
644
|
+
return dynamicBypasses.runScoped(registration, run);
|
|
645
|
+
},
|
|
509
646
|
};
|
|
647
|
+
activeHandle = hasActiveProxy ? handle : activeHandle;
|
|
510
648
|
return handle;
|
|
511
649
|
}
|
|
512
650
|
export const installGlobalProxy = installProxyline;
|
package/dist/types.d.ts
CHANGED
|
@@ -8,7 +8,9 @@ export type ProxylineOptions = Readonly<{
|
|
|
8
8
|
proxyUrl?: string | URL;
|
|
9
9
|
proxyTls?: ProxylineTlsOptions;
|
|
10
10
|
bypassPolicy?: ProxylineBypassPolicy;
|
|
11
|
+
ifActive?: "error" | "reuse-compatible" | "replace";
|
|
11
12
|
onEvent?: (event: ProxylineEvent) => void;
|
|
13
|
+
undici?: ProxylineUndiciOptions;
|
|
12
14
|
}>;
|
|
13
15
|
export type ProxylineDecision = Readonly<{
|
|
14
16
|
kind: "proxied" | "direct" | "blocked";
|
|
@@ -41,6 +43,19 @@ export type ProxylineEvent = Readonly<{
|
|
|
41
43
|
export type ExplainOptions = Readonly<{
|
|
42
44
|
surface?: ProxylineSurface;
|
|
43
45
|
}>;
|
|
46
|
+
export type ProxylineBypassRegistration = Readonly<{
|
|
47
|
+
surface?: ProxylineSurface;
|
|
48
|
+
url: string | URL;
|
|
49
|
+
}>;
|
|
50
|
+
export type ProxylineUndiciOptions = Readonly<{
|
|
51
|
+
allowH2?: boolean;
|
|
52
|
+
bodyTimeout?: number;
|
|
53
|
+
headersTimeout?: number;
|
|
54
|
+
connect?: Readonly<{
|
|
55
|
+
autoSelectFamily?: boolean;
|
|
56
|
+
autoSelectFamilyAttemptTimeout?: number;
|
|
57
|
+
}>;
|
|
58
|
+
}>;
|
|
44
59
|
export type ProxylineHandle = Readonly<{
|
|
45
60
|
mode: ProxylineMode;
|
|
46
61
|
active: boolean;
|
|
@@ -49,12 +64,14 @@ export type ProxylineHandle = Readonly<{
|
|
|
49
64
|
createUndiciDispatcher: () => Dispatcher;
|
|
50
65
|
createWebSocketAgent: () => HttpAgent;
|
|
51
66
|
explain: (url: string | URL, options?: ExplainOptions) => ProxylineDecision;
|
|
67
|
+
registerBypass: (registration: ProxylineBypassRegistration) => () => void;
|
|
52
68
|
stop: () => void;
|
|
69
|
+
withBypass: <T>(registration: ProxylineBypassRegistration, run: () => T) => T;
|
|
53
70
|
}>;
|
|
54
71
|
export type ProxyResolver = Readonly<{
|
|
55
72
|
active: boolean;
|
|
56
73
|
describeProxy: () => string | undefined;
|
|
57
74
|
explain: (url: string | URL, surface: ProxylineSurface) => ProxylineDecision;
|
|
58
|
-
getProxyForUrl: (url: string) => string;
|
|
75
|
+
getProxyForUrl: (url: string, surface?: ProxylineSurface) => string;
|
|
59
76
|
}>;
|
|
60
77
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types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