@noodleseed/one 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +2 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-dispatch.d.ts.map +1 -1
- package/dist/commands/catalog-dispatch.js +21 -2
- package/dist/commands/catalog-dispatch.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +28 -11
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/first-run.d.ts +11 -0
- package/dist/first-run.d.ts.map +1 -1
- package/dist/first-run.js +19 -4
- package/dist/first-run.js.map +1 -1
- package/dist/project-scaffold-templates.d.ts +11 -0
- package/dist/project-scaffold-templates.d.ts.map +1 -0
- package/dist/project-scaffold-templates.js +359 -0
- package/dist/project-scaffold-templates.js.map +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -323
- package/dist/project.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -0
- package/dist/validate.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/package.json +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +9 -10
- package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
- package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
- package/node_modules/tailwindcss/dist/lib.js +13 -13
- package/node_modules/tailwindcss/dist/lib.mjs +18 -18
- package/node_modules/tailwindcss/package.json +2 -2
- package/node_modules/undici/README.md +3 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +365 -178
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +779 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +47 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +1 -1
- package/node_modules/undici/lib/core/util.js +24 -1
- package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
- package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
- package/node_modules/undici/lib/handler/retry-handler.js +57 -19
- package/node_modules/undici/lib/util/cache.js +8 -2
- package/node_modules/undici/lib/web/cookies/parse.js +20 -27
- package/node_modules/undici/lib/web/cookies/util.js +1 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
- package/node_modules/undici/lib/web/eventsource/util.js +32 -1
- package/node_modules/undici/lib/web/fetch/body.js +43 -0
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +11 -2
- package/node_modules/undici/lib/web/fetch/request.js +1 -0
- package/node_modules/undici/lib/web/fetch/util.js +4 -1
- package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
- package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +6 -1
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/fetch.d.ts +1 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/package.json +4 -4
- package/react/styles.css +510 -5
- package/react/styles.source.css +850 -0
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
|
@@ -1,229 +1,248 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ProxyAgent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!--introduced_in=v4.8.2-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/dispatcher/proxy-agent.js -->
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
> Stability: 2 - Stable
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
A `ProxyAgent` routes every request through an HTTP, HTTPS, or SOCKS5 proxy
|
|
10
|
+
server. It implements the [`Agent`][] API, so it can be used wherever a
|
|
11
|
+
dispatcher is accepted, for example with [`request`][] or [`fetch`][], or
|
|
12
|
+
installed globally with [`setGlobalDispatcher`][].
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
For secure (`https:`) endpoints the proxy connection is established through an
|
|
15
|
+
HTTP `CONNECT` tunnel. SOCKS5 proxies (`socks5:` or `socks:` URIs) are handled
|
|
16
|
+
by delegating to a [`Socks5ProxyAgent`][].
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Returns: `ProxyAgent`
|
|
14
|
-
|
|
15
|
-
### Parameter: `ProxyAgentOptions`
|
|
18
|
+
```mjs
|
|
19
|
+
import { ProxyAgent, setGlobalDispatcher } from 'undici'
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
const proxyAgent = new ProxyAgent('http://localhost:8000')
|
|
22
|
+
setGlobalDispatcher(proxyAgent)
|
|
23
|
+
```
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
## Class: `ProxyAgent`
|
|
26
|
+
|
|
27
|
+
<!-- YAML
|
|
28
|
+
added: v4.8.2
|
|
29
|
+
-->
|
|
30
|
+
|
|
31
|
+
* Extends: {Dispatcher}
|
|
32
|
+
|
|
33
|
+
`ProxyAgent` keeps an internal [`Agent`][] that creates per-origin dispatchers
|
|
34
|
+
on demand. The proxy connection is set up lazily when the first request to an
|
|
35
|
+
origin is dispatched, then reused for subsequent requests to the same origin.
|
|
36
|
+
|
|
37
|
+
### `new ProxyAgent(options)`
|
|
38
|
+
|
|
39
|
+
<!-- YAML
|
|
40
|
+
added: v4.8.2
|
|
41
|
+
-->
|
|
42
|
+
|
|
43
|
+
* `options` {ProxyAgentOptions|string|URL} The proxy URI, or an options object.
|
|
44
|
+
Required. When a `string` or {URL} is passed it is used as the proxy `uri`.
|
|
45
|
+
The options object extends {AgentOptions} (omitting `connect`).
|
|
46
|
+
* `uri` {string} The URI of the proxy server. Required when `options` is an
|
|
47
|
+
object. Parsed into a {URL} according to the
|
|
48
|
+
[WHATWG URL Specification][].
|
|
49
|
+
* `token` {string} A pre-formatted `proxy-authorization` header value sent to
|
|
50
|
+
the proxy on every request, for example `` `Bearer ${apiKey}` ``.
|
|
51
|
+
* `auth` {string} A base64-encoded `username:password` credential sent as a
|
|
52
|
+
`Basic` `proxy-authorization` header. Cannot be combined with `token`.
|
|
53
|
+
* `headers` {Object} Additional headers sent to the proxy server on the
|
|
54
|
+
`CONNECT` request (or on every request for an untunneled HTTP proxy).
|
|
55
|
+
**Default:** `{}`.
|
|
56
|
+
* `requestTls` {BuildOptions} TLS options for the connection to the request
|
|
57
|
+
endpoint, passed to the connector builder.
|
|
58
|
+
* `proxyTls` {BuildOptions} TLS options for the connection to the proxy
|
|
59
|
+
server, passed to the connector builder.
|
|
60
|
+
* `clientFactory` {Function} Builds the {Dispatcher} used to talk to the proxy
|
|
61
|
+
server itself. **Default:** `(origin, opts) => new Pool(origin, opts)`.
|
|
62
|
+
* `origin` {URL} The proxy origin.
|
|
63
|
+
* `opts` {Object} The resolved options for the dispatcher.
|
|
64
|
+
* Returns: {Dispatcher}
|
|
65
|
+
* `proxyTunnel` {boolean} Forces tunneling through the proxy. By default,
|
|
66
|
+
Undici detects tunneling based on the request protocol. If the target
|
|
67
|
+
endpoint uses HTTPS, Undici establishes a `CONNECT` tunnel through the proxy
|
|
68
|
+
(after the TLS handshake to the proxy itself when the proxy URL is HTTPS).
|
|
69
|
+
If the target endpoint uses plain HTTP, Undici forwards the request to the
|
|
70
|
+
proxy using an HTTP/1.1 absolute-form request target (over TLS when the
|
|
71
|
+
proxy URL is HTTPS), as required by
|
|
72
|
+
[RFC 9112 §3.2.2](https://www.rfc-editor.org/rfc/rfc9112.html#name-absolute-form).
|
|
73
|
+
This non-tunneled forwarding path does not negotiate HTTP/2 with the proxy.
|
|
74
|
+
Set `proxyTunnel` to `true` to force tunneling for plain HTTP requests as
|
|
75
|
+
well. Currently, there is no way to facilitate HTTP/1.1 IP tunneling as
|
|
76
|
+
described in
|
|
77
|
+
[RFC 9484](https://www.rfc-editor.org/rfc/rfc9484.html#name-http-11-request).
|
|
78
|
+
|
|
79
|
+
Throws an {InvalidArgumentError} when no proxy URI is provided, when
|
|
80
|
+
`clientFactory` is not a function, or when both `auth` and `token` are supplied.
|
|
81
|
+
|
|
82
|
+
The `proxy-authorization` header is derived, in order of precedence, from
|
|
83
|
+
`token`, then `auth`, then the `username` and `password` embedded in the proxy
|
|
84
|
+
`uri`. Credentials in the URI are URL-decoded before being base64-encoded.
|
|
85
|
+
|
|
86
|
+
> [!NOTE]
|
|
87
|
+
> Unless {AgentOptions} `connections` is set to `0`, the non-standard
|
|
88
|
+
> `proxy-connection: keep-alive` header is added to the tunnel `CONNECT`
|
|
89
|
+
> request. This includes the default case where `connections` is unset.
|
|
90
|
+
|
|
91
|
+
The `auth` option is deprecated; use `token` instead.
|
|
92
|
+
|
|
93
|
+
```mjs
|
|
94
|
+
import { ProxyAgent } from 'undici'
|
|
21
95
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* **token** `string` (optional) - It can be passed by a string of token for authentication.
|
|
26
|
-
* **auth** `string` (**deprecated**) - Use token.
|
|
27
|
-
* **clientFactory** `(origin: URL, opts: Object) => Dispatcher` (optional) - Default: `(origin, opts) => new Pool(origin, opts)`
|
|
28
|
-
* **requestTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
|
|
29
|
-
* **proxyTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
|
|
30
|
-
* **proxyTunnel** `boolean` (optional) - For connections involving secure protocols, Undici will always establish a tunnel via the HTTP2 CONNECT extension. If proxyTunnel is set to true, this will occur for unsecured proxy/endpoint connections as well. Currently, there is no way to facilitate HTTP1 IP tunneling as described in https://www.rfc-editor.org/rfc/rfc9484.html#name-http-11-request. If proxyTunnel is set to false (the default), ProxyAgent connections where both the Proxy and Endpoint are unsecured will issue all requests to the Proxy, and prefix the endpoint request path with the endpoint origin address.
|
|
96
|
+
// A string or URL is treated as the proxy uri.
|
|
97
|
+
const a = new ProxyAgent('http://localhost:8000')
|
|
98
|
+
const b = new ProxyAgent(new URL('http://localhost:8000'))
|
|
31
99
|
|
|
32
|
-
|
|
100
|
+
// An options object requires a `uri`.
|
|
101
|
+
const c = new ProxyAgent({ uri: 'http://localhost:8000' })
|
|
33
102
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const proxyAgent = new ProxyAgent('my.proxy.server')
|
|
38
|
-
// or
|
|
39
|
-
const proxyAgent = new ProxyAgent(new URL('my.proxy.server'))
|
|
40
|
-
// or
|
|
41
|
-
const proxyAgent = new ProxyAgent({ uri: 'my.proxy.server' })
|
|
42
|
-
// or
|
|
43
|
-
const proxyAgent = new ProxyAgent({
|
|
44
|
-
uri: new URL('my.proxy.server'),
|
|
103
|
+
// With proxy TLS settings.
|
|
104
|
+
const d = new ProxyAgent({
|
|
105
|
+
uri: 'https://secure.proxy.server',
|
|
45
106
|
proxyTls: {
|
|
46
|
-
signal: AbortSignal.timeout(1000)
|
|
47
|
-
}
|
|
107
|
+
signal: AbortSignal.timeout(1000),
|
|
108
|
+
},
|
|
48
109
|
})
|
|
49
110
|
```
|
|
50
111
|
|
|
51
|
-
#### Example -
|
|
52
|
-
|
|
53
|
-
This will instantiate the ProxyAgent. It will not do anything until registered as the agent to use with requests.
|
|
112
|
+
#### Example - proxy request with the global dispatcher
|
|
54
113
|
|
|
55
|
-
```
|
|
56
|
-
import { ProxyAgent } from 'undici'
|
|
57
|
-
|
|
58
|
-
const proxyAgent = new ProxyAgent('my.proxy.server')
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
#### Example - Basic Proxy Request with global agent dispatcher
|
|
62
|
-
|
|
63
|
-
```js
|
|
114
|
+
```mjs
|
|
64
115
|
import { setGlobalDispatcher, request, ProxyAgent } from 'undici'
|
|
65
116
|
|
|
66
|
-
const proxyAgent = new ProxyAgent('
|
|
117
|
+
const proxyAgent = new ProxyAgent('http://localhost:8000')
|
|
67
118
|
setGlobalDispatcher(proxyAgent)
|
|
68
119
|
|
|
69
120
|
const { statusCode, body } = await request('http://localhost:3000/foo')
|
|
70
121
|
|
|
71
|
-
console.log('response received', statusCode)
|
|
72
|
-
|
|
73
|
-
for await (const data of body) {
|
|
74
|
-
console.log('data', data.toString('utf8')) // data foo
|
|
75
|
-
}
|
|
122
|
+
console.log('response received', statusCode)
|
|
123
|
+
console.log('data', await body.text())
|
|
76
124
|
```
|
|
77
125
|
|
|
78
|
-
#### Example -
|
|
126
|
+
#### Example - proxy request with a local dispatcher
|
|
79
127
|
|
|
80
|
-
```
|
|
128
|
+
```mjs
|
|
81
129
|
import { ProxyAgent, request } from 'undici'
|
|
82
130
|
|
|
83
|
-
const proxyAgent = new ProxyAgent('
|
|
131
|
+
const proxyAgent = new ProxyAgent('http://localhost:8000')
|
|
84
132
|
|
|
85
|
-
const {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} = await request('http://localhost:3000/foo', { dispatcher: proxyAgent })
|
|
89
|
-
|
|
90
|
-
console.log('response received', statusCode) // response received 200
|
|
133
|
+
const { statusCode, body } = await request('http://localhost:3000/foo', {
|
|
134
|
+
dispatcher: proxyAgent,
|
|
135
|
+
})
|
|
91
136
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
137
|
+
console.log('response received', statusCode)
|
|
138
|
+
console.log('data', await body.text())
|
|
95
139
|
```
|
|
96
140
|
|
|
97
|
-
#### Example -
|
|
141
|
+
#### Example - proxy request with authentication
|
|
98
142
|
|
|
99
|
-
```
|
|
100
|
-
import { setGlobalDispatcher, request, ProxyAgent } from 'undici'
|
|
143
|
+
```mjs
|
|
144
|
+
import { setGlobalDispatcher, request, ProxyAgent } from 'undici'
|
|
101
145
|
|
|
102
146
|
const proxyAgent = new ProxyAgent({
|
|
103
|
-
uri: '
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
setGlobalDispatcher(proxyAgent);
|
|
108
|
-
|
|
109
|
-
const { statusCode, body } = await request('http://localhost:3000/foo');
|
|
110
|
-
|
|
111
|
-
console.log('response received', statusCode); // response received 200
|
|
112
|
-
|
|
113
|
-
for await (const data of body) {
|
|
114
|
-
console.log('data', data.toString('utf8')); // data foo
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### `ProxyAgent.close()`
|
|
119
|
-
|
|
120
|
-
Closes the proxy agent and waits for registered pools and clients to also close before resolving.
|
|
121
|
-
|
|
122
|
-
Returns: `Promise<void>`
|
|
123
|
-
|
|
124
|
-
#### Example - clean up after tests are complete
|
|
125
|
-
|
|
126
|
-
```js
|
|
127
|
-
import { ProxyAgent, setGlobalDispatcher } from 'undici'
|
|
128
|
-
|
|
129
|
-
const proxyAgent = new ProxyAgent('my.proxy.server')
|
|
147
|
+
uri: 'http://localhost:8000',
|
|
148
|
+
token: `Basic ${Buffer.from('username:password').toString('base64')}`,
|
|
149
|
+
})
|
|
130
150
|
setGlobalDispatcher(proxyAgent)
|
|
131
151
|
|
|
132
|
-
await
|
|
152
|
+
const { statusCode } = await request('http://localhost:3000/foo')
|
|
153
|
+
|
|
154
|
+
console.log('response received', statusCode)
|
|
133
155
|
```
|
|
134
156
|
|
|
135
|
-
### `
|
|
157
|
+
### `proxyAgent.dispatch(options, handler)`
|
|
136
158
|
|
|
137
|
-
|
|
159
|
+
<!-- YAML
|
|
160
|
+
added: v4.8.2
|
|
161
|
+
-->
|
|
138
162
|
|
|
139
|
-
|
|
163
|
+
* `options` {AgentDispatchOptions} Extends {DispatchOptions}.
|
|
164
|
+
* `origin` {string|URL} The origin to dispatch the request against. Required.
|
|
165
|
+
* `handler` {DispatchHandler}
|
|
166
|
+
* Returns: {boolean} `false` if the dispatcher is busy and the caller should
|
|
167
|
+
wait for the [`'drain'`][] event before dispatching again.
|
|
140
168
|
|
|
141
|
-
|
|
169
|
+
Dispatches the request through the proxy. Throws an {InvalidArgumentError} if
|
|
170
|
+
the request headers contain a `proxy-authorization` header, which must instead
|
|
171
|
+
be supplied through the constructor's `token` or `auth` option. A `host` header
|
|
172
|
+
is derived from `options.origin` when one is not already present. Implements
|
|
173
|
+
[`Dispatcher.dispatch()`][].
|
|
142
174
|
|
|
175
|
+
### `proxyAgent.close()`
|
|
143
176
|
|
|
144
|
-
|
|
177
|
+
<!-- YAML
|
|
178
|
+
added: v4.8.2
|
|
179
|
+
changes:
|
|
180
|
+
- version: v7.10.0
|
|
181
|
+
pr-url: https://github.com/nodejs/undici/pull/4180
|
|
182
|
+
description: Untunneled HTTP-to-HTTP proxy connections match `curl` behavior.
|
|
183
|
+
-->
|
|
145
184
|
|
|
146
|
-
|
|
185
|
+
* Returns: {Promise<void>}
|
|
147
186
|
|
|
148
|
-
|
|
149
|
-
|
|
187
|
+
Closes the proxy agent and waits for its internal agent and proxy client (when
|
|
188
|
+
present) to close before resolving. Implements [`Dispatcher.close()`][].
|
|
150
189
|
|
|
151
|
-
|
|
152
|
-
|
|
190
|
+
```mjs
|
|
191
|
+
import { ProxyAgent, setGlobalDispatcher } from 'undici'
|
|
153
192
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
dispatcher: proxyAgent,
|
|
157
|
-
method: 'GET',
|
|
158
|
-
});
|
|
193
|
+
const proxyAgent = new ProxyAgent('http://localhost:8000')
|
|
194
|
+
setGlobalDispatcher(proxyAgent)
|
|
159
195
|
|
|
160
|
-
|
|
161
|
-
console.log('Response data:', await response.text());
|
|
196
|
+
await proxyAgent.close()
|
|
162
197
|
```
|
|
163
198
|
|
|
164
|
-
|
|
199
|
+
### `proxyAgent.request(options[, callback])`
|
|
165
200
|
|
|
166
|
-
|
|
201
|
+
<!-- YAML
|
|
202
|
+
added: v5.0.0
|
|
203
|
+
-->
|
|
167
204
|
|
|
168
|
-
|
|
205
|
+
See [`Dispatcher.request()`][]. The request is routed through the proxy.
|
|
169
206
|
|
|
170
|
-
|
|
171
|
-
import * as http from 'node:http';
|
|
172
|
-
import { createProxy } from 'proxy';
|
|
173
|
-
import { ProxyAgent, fetch } from 'undici';
|
|
207
|
+
#### Example - proxy request with `fetch`
|
|
174
208
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
proxyServer.listen(8000, () => {
|
|
178
|
-
console.log('Proxy server running on port 8000');
|
|
179
|
-
});
|
|
209
|
+
```mjs
|
|
210
|
+
import { ProxyAgent, fetch } from 'undici'
|
|
180
211
|
|
|
181
|
-
|
|
182
|
-
const proxyAgent = new ProxyAgent('http://localhost:8000');
|
|
212
|
+
const proxyAgent = new ProxyAgent('http://localhost:8000')
|
|
183
213
|
|
|
184
|
-
const response = await fetch('http://
|
|
214
|
+
const response = await fetch('http://localhost:3000/foo', {
|
|
185
215
|
dispatcher: proxyAgent,
|
|
186
216
|
method: 'GET',
|
|
187
|
-
})
|
|
217
|
+
})
|
|
188
218
|
|
|
189
|
-
console.log('
|
|
190
|
-
console.log('
|
|
219
|
+
console.log('response status', response.status)
|
|
220
|
+
console.log('response data', await response.text())
|
|
191
221
|
```
|
|
192
222
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
#### Example - ProxyAgent with HTTPS Tunneling
|
|
223
|
+
#### Example - HTTPS tunneling
|
|
196
224
|
|
|
197
|
-
|
|
225
|
+
```mjs
|
|
226
|
+
import { ProxyAgent, fetch } from 'undici'
|
|
198
227
|
|
|
199
|
-
|
|
200
|
-
import { ProxyAgent, fetch } from 'undici';
|
|
228
|
+
const proxyAgent = new ProxyAgent('https://secure.proxy.server')
|
|
201
229
|
|
|
202
|
-
// Define a ProxyAgent for HTTPS proxy
|
|
203
|
-
const proxyAgent = new ProxyAgent('https://secure.proxy.server');
|
|
204
|
-
|
|
205
|
-
// Make a request to an HTTPS endpoint via the proxy
|
|
206
230
|
const response = await fetch('https://secure.endpoint.com/api/data', {
|
|
207
231
|
dispatcher: proxyAgent,
|
|
208
232
|
method: 'GET',
|
|
209
|
-
})
|
|
233
|
+
})
|
|
210
234
|
|
|
211
|
-
console.log('
|
|
212
|
-
console.log('
|
|
235
|
+
console.log('response status', response.status)
|
|
236
|
+
console.log('response data', await response.json())
|
|
213
237
|
```
|
|
214
238
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
`
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
setGlobalDispatcher
|
|
225
|
-
|
|
226
|
-
// Make requests without specifying the dispatcher
|
|
227
|
-
const response = await fetch('http://example.com');
|
|
228
|
-
console.log('Response status:', response.status);
|
|
229
|
-
console.log('Response data:', await response.text());
|
|
239
|
+
[WHATWG URL Specification]: https://url.spec.whatwg.org
|
|
240
|
+
[`'drain'`]: Dispatcher.md#event-drain
|
|
241
|
+
[`Agent`]: Agent.md#class-agent
|
|
242
|
+
[`Dispatcher.close()`]: Dispatcher.md#dispatcherclosecallback-promise
|
|
243
|
+
[`Dispatcher.dispatch()`]: Dispatcher.md#dispatcherdispatchoptions-handler
|
|
244
|
+
[`Dispatcher.request()`]: Dispatcher.md#dispatcherrequestoptions-callback
|
|
245
|
+
[`Socks5ProxyAgent`]: Socks5ProxyAgent.md#class-socks5proxyagent
|
|
246
|
+
[`fetch`]: Fetch.md
|
|
247
|
+
[`request`]: Dispatcher.md#dispatcherrequestoptions-callback
|
|
248
|
+
[`setGlobalDispatcher`]: Dispatcher.md#setglobaldispatcherdispatcher
|