@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.
Files changed (197) hide show
  1. package/dist/commands/author-loop.d.ts.map +1 -1
  2. package/dist/commands/author-loop.js +2 -2
  3. package/dist/commands/author-loop.js.map +1 -1
  4. package/dist/commands/catalog-dispatch.d.ts.map +1 -1
  5. package/dist/commands/catalog-dispatch.js +21 -2
  6. package/dist/commands/catalog-dispatch.js.map +1 -1
  7. package/dist/commands/deploy-ops.d.ts.map +1 -1
  8. package/dist/commands/deploy-ops.js +28 -11
  9. package/dist/commands/deploy-ops.js.map +1 -1
  10. package/dist/first-run.d.ts +11 -0
  11. package/dist/first-run.d.ts.map +1 -1
  12. package/dist/first-run.js +19 -4
  13. package/dist/first-run.js.map +1 -1
  14. package/dist/project-scaffold-templates.d.ts +11 -0
  15. package/dist/project-scaffold-templates.d.ts.map +1 -0
  16. package/dist/project-scaffold-templates.js +359 -0
  17. package/dist/project-scaffold-templates.js.map +1 -0
  18. package/dist/project.d.ts.map +1 -1
  19. package/dist/project.js +1 -323
  20. package/dist/project.js.map +1 -1
  21. package/dist/react.d.ts +2 -2
  22. package/dist/react.d.ts.map +1 -1
  23. package/dist/react.js +1 -1
  24. package/dist/react.js.map +1 -1
  25. package/dist/validate.d.ts +12 -0
  26. package/dist/validate.d.ts.map +1 -1
  27. package/dist/validate.js +11 -0
  28. package/dist/validate.js.map +1 -1
  29. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
  30. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
  31. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
  32. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  33. package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
  34. package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
  35. package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
  36. package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
  37. package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
  38. package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
  39. package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
  40. package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
  41. package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
  42. package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
  43. package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
  44. package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
  45. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
  46. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
  47. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
  48. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
  49. package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
  50. package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
  51. package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
  52. package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
  53. package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
  54. package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
  55. package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
  56. package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
  57. package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
  58. package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
  59. package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
  60. package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
  61. package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
  62. package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
  63. package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
  64. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
  65. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
  66. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
  67. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
  68. package/node_modules/@noodle-borg/connector-http/package.json +1 -1
  69. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
  70. package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
  71. package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
  72. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
  73. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  74. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
  75. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
  76. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  77. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
  78. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
  79. package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
  80. package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
  81. package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
  82. package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
  83. package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
  84. package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
  85. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
  86. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  87. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  88. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  89. package/node_modules/hono/dist/helper/css/common.js +3 -1
  90. package/node_modules/hono/dist/helper/css/index.js +9 -1
  91. package/node_modules/hono/dist/jsx/base.js +15 -15
  92. package/node_modules/hono/dist/jsx/components.js +42 -22
  93. package/node_modules/hono/dist/jsx/context.js +129 -5
  94. package/node_modules/hono/dist/jsx/streaming.js +10 -8
  95. package/node_modules/hono/dist/middleware/cors/index.js +2 -5
  96. package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
  97. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
  98. package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
  99. package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
  100. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  101. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  102. package/node_modules/hono/dist/utils/body.js +12 -4
  103. package/node_modules/hono/dist/utils/buffer.js +2 -1
  104. package/node_modules/hono/dist/validator/validator.js +3 -3
  105. package/node_modules/hono/package.json +9 -10
  106. package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
  107. package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
  108. package/node_modules/tailwindcss/dist/lib.js +13 -13
  109. package/node_modules/tailwindcss/dist/lib.mjs +18 -18
  110. package/node_modules/tailwindcss/package.json +2 -2
  111. package/node_modules/undici/README.md +3 -2
  112. package/node_modules/undici/docs/docs/api/Agent.md +248 -44
  113. package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
  114. package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
  115. package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
  116. package/node_modules/undici/docs/docs/api/Client.md +365 -178
  117. package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
  118. package/node_modules/undici/docs/docs/api/Connector.md +118 -36
  119. package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
  120. package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
  121. package/node_modules/undici/docs/docs/api/Debug.md +34 -18
  122. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
  123. package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
  124. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
  125. package/node_modules/undici/docs/docs/api/Errors.md +503 -40
  126. package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
  127. package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
  128. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
  129. package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
  130. package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
  131. package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
  132. package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
  133. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
  134. package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
  135. package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
  136. package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
  137. package/node_modules/undici/docs/docs/api/Pool.md +235 -43
  138. package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
  139. package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
  140. package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
  141. package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
  142. package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
  143. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
  144. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
  145. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
  146. package/node_modules/undici/docs/docs/api/Util.md +68 -11
  147. package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
  148. package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
  149. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
  150. package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
  151. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
  152. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
  153. package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
  154. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
  155. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
  156. package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
  157. package/node_modules/undici/docs/docs/index.md +779 -0
  158. package/node_modules/undici/docs/docs/site.json +125 -0
  159. package/node_modules/undici/docs/docs/type-map.json +79 -0
  160. package/node_modules/undici/lib/api/api-request.js +7 -1
  161. package/node_modules/undici/lib/api/readable.js +47 -2
  162. package/node_modules/undici/lib/core/errors.js +20 -0
  163. package/node_modules/undici/lib/core/request.js +1 -1
  164. package/node_modules/undici/lib/core/util.js +24 -1
  165. package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
  166. package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
  167. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  168. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
  169. package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
  170. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
  171. package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
  172. package/node_modules/undici/lib/handler/retry-handler.js +57 -19
  173. package/node_modules/undici/lib/util/cache.js +8 -2
  174. package/node_modules/undici/lib/web/cookies/parse.js +20 -27
  175. package/node_modules/undici/lib/web/cookies/util.js +1 -1
  176. package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
  177. package/node_modules/undici/lib/web/eventsource/util.js +32 -1
  178. package/node_modules/undici/lib/web/fetch/body.js +43 -0
  179. package/node_modules/undici/lib/web/fetch/constants.js +1 -1
  180. package/node_modules/undici/lib/web/fetch/index.js +11 -2
  181. package/node_modules/undici/lib/web/fetch/request.js +1 -0
  182. package/node_modules/undici/lib/web/fetch/util.js +4 -1
  183. package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
  184. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
  185. package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
  186. package/node_modules/undici/package.json +1 -1
  187. package/node_modules/undici/types/client.d.ts +6 -1
  188. package/node_modules/undici/types/cookies.d.ts +1 -1
  189. package/node_modules/undici/types/errors.d.ts +10 -0
  190. package/node_modules/undici/types/fetch.d.ts +1 -0
  191. package/node_modules/undici/types/handlers.d.ts +2 -0
  192. package/node_modules/undici/types/proxy-agent.d.ts +7 -0
  193. package/package.json +4 -4
  194. package/react/styles.css +510 -5
  195. package/react/styles.source.css +850 -0
  196. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  197. package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
@@ -1,229 +1,248 @@
1
- # Class: ProxyAgent
1
+ # ProxyAgent
2
2
 
3
- Extends: `undici.Dispatcher`
3
+ <!--introduced_in=v4.8.2-->
4
+ <!--type=module-->
5
+ <!-- source_link=lib/dispatcher/proxy-agent.js -->
4
6
 
5
- A Proxy Agent class that implements the Agent API. It allows the connection through proxy in a simple way.
7
+ > Stability: 2 - Stable
6
8
 
7
- ## `new ProxyAgent([options])`
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
- Arguments:
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
- * **options** `ProxyAgentOptions` (required) - It extends the `Agent` options.
12
-
13
- Returns: `ProxyAgent`
14
-
15
- ### Parameter: `ProxyAgentOptions`
18
+ ```mjs
19
+ import { ProxyAgent, setGlobalDispatcher } from 'undici'
16
20
 
17
- Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
18
- > It ommits `AgentOptions#connect`.
21
+ const proxyAgent = new ProxyAgent('http://localhost:8000')
22
+ setGlobalDispatcher(proxyAgent)
23
+ ```
19
24
 
20
- > **Note:** When `AgentOptions#connections` is set, and different from `0`, the non-standard [`proxy-connection` header](https://udger.com/resources/http-request-headers-detail?header=Proxy-Connection) will be set to `keep-alive` in the request.
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
- * **uri** `string | URL` (required) - The URI of the proxy server. This can be provided as a string, as an instance of the URL class, or as an object with a `uri` property of type string.
23
- If the `uri` is provided as a string or `uri` is an object with an `uri` property of type string, then it will be parsed into a `URL` object according to the [WHATWG URL Specification](https://url.spec.whatwg.org).
24
- For detailed information on the parsing process and potential validation errors, please refer to the ["Writing" section](https://url.spec.whatwg.org/#writing) of the WHATWG URL Specification.
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
- Examples:
100
+ // An options object requires a `uri`.
101
+ const c = new ProxyAgent({ uri: 'http://localhost:8000' })
33
102
 
34
- ```js
35
- import { ProxyAgent } from 'undici'
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 - Basic ProxyAgent instantiation
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
- ```js
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('my.proxy.server')
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) // response received 200
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 - Basic Proxy Request with local agent dispatcher
126
+ #### Example - proxy request with a local dispatcher
79
127
 
80
- ```js
128
+ ```mjs
81
129
  import { ProxyAgent, request } from 'undici'
82
130
 
83
- const proxyAgent = new ProxyAgent('my.proxy.server')
131
+ const proxyAgent = new ProxyAgent('http://localhost:8000')
84
132
 
85
- const {
86
- statusCode,
87
- body
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
- for await (const data of body) {
93
- console.log('data', data.toString('utf8')) // data foo
94
- }
137
+ console.log('response received', statusCode)
138
+ console.log('data', await body.text())
95
139
  ```
96
140
 
97
- #### Example - Basic Proxy Request with authentication
141
+ #### Example - proxy request with authentication
98
142
 
99
- ```js
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: 'my.proxy.server',
104
- // token: 'Bearer xxxx'
105
- token: `Basic ${Buffer.from('username:password').toString('base64')}`
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 proxyAgent.close()
152
+ const { statusCode } = await request('http://localhost:3000/foo')
153
+
154
+ console.log('response received', statusCode)
133
155
  ```
134
156
 
135
- ### `ProxyAgent.dispatch(options, handlers)`
157
+ ### `proxyAgent.dispatch(options, handler)`
136
158
 
137
- Implements [`Agent.dispatch(options, handlers)`](/docs/docs/api/Agent.md#parameter-agentdispatchoptions).
159
+ <!-- YAML
160
+ added: v4.8.2
161
+ -->
138
162
 
139
- ### `ProxyAgent.request(options[, callback])`
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
- See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
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
- #### Example - ProxyAgent with Fetch
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
- This example demonstrates how to use `fetch` with a proxy via `ProxyAgent`. It is particularly useful for scenarios requiring proxy tunneling.
185
+ * Returns: {Promise<void>}
147
186
 
148
- ```javascript
149
- import { ProxyAgent, fetch } from 'undici';
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
- // Define the ProxyAgent
152
- const proxyAgent = new ProxyAgent('http://localhost:8000');
190
+ ```mjs
191
+ import { ProxyAgent, setGlobalDispatcher } from 'undici'
153
192
 
154
- // Make a GET request through the proxy
155
- const response = await fetch('http://localhost:3000/foo', {
156
- dispatcher: proxyAgent,
157
- method: 'GET',
158
- });
193
+ const proxyAgent = new ProxyAgent('http://localhost:8000')
194
+ setGlobalDispatcher(proxyAgent)
159
195
 
160
- console.log('Response status:', response.status);
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
- #### Example - ProxyAgent with a Custom Proxy Server
201
+ <!-- YAML
202
+ added: v5.0.0
203
+ -->
167
204
 
168
- This example shows how to create a custom proxy server and use it with `ProxyAgent`.
205
+ See [`Dispatcher.request()`][]. The request is routed through the proxy.
169
206
 
170
- ```javascript
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
- // Create a proxy server
176
- const proxyServer = createProxy(http.createServer());
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
- // Define and use the ProxyAgent
182
- const proxyAgent = new ProxyAgent('http://localhost:8000');
212
+ const proxyAgent = new ProxyAgent('http://localhost:8000')
183
213
 
184
- const response = await fetch('http://example.com', {
214
+ const response = await fetch('http://localhost:3000/foo', {
185
215
  dispatcher: proxyAgent,
186
216
  method: 'GET',
187
- });
217
+ })
188
218
 
189
- console.log('Response status:', response.status);
190
- console.log('Response data:', await response.text());
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
- This example demonstrates how to perform HTTPS tunneling using a proxy.
225
+ ```mjs
226
+ import { ProxyAgent, fetch } from 'undici'
198
227
 
199
- ```javascript
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('Response status:', response.status);
212
- console.log('Response data:', await response.json());
235
+ console.log('response status', response.status)
236
+ console.log('response data', await response.json())
213
237
  ```
214
238
 
215
- #### Example - ProxyAgent as a Global Dispatcher
216
-
217
- `ProxyAgent` can be configured as a global dispatcher, making it available for all requests without explicitly passing it. This simplifies code and is useful when a single proxy configuration applies to all requests.
218
-
219
- ```javascript
220
- import { ProxyAgent, setGlobalDispatcher, fetch } from 'undici';
221
-
222
- // Define and configure the ProxyAgent
223
- const proxyAgent = new ProxyAgent('http://localhost:8000');
224
- setGlobalDispatcher(proxyAgent);
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