@noodleseed/one 0.21.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 (215) 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/curated/hook-notes.d.ts.map +1 -1
  30. package/node_modules/@noodle-borg/agent-kit/dist/curated/hook-notes.js +2 -1
  31. package/node_modules/@noodle-borg/agent-kit/dist/curated/hook-notes.js.map +1 -1
  32. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
  33. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
  34. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
  35. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
  36. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
  37. package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
  38. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  39. package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
  40. package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
  41. package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
  42. package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
  43. package/node_modules/@noodle-borg/authoring/dist/react/bridge.d.ts +9 -1
  44. package/node_modules/@noodle-borg/authoring/dist/react/bridge.d.ts.map +1 -1
  45. package/node_modules/@noodle-borg/authoring/dist/react/bridge.js +11 -1
  46. package/node_modules/@noodle-borg/authoring/dist/react/bridge.js.map +1 -1
  47. package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +306 -9
  48. package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
  49. package/node_modules/@noodle-borg/authoring/dist/react/components.js +63 -11
  50. package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
  51. package/node_modules/@noodle-borg/authoring/dist/react/hooks.d.ts +2 -0
  52. package/node_modules/@noodle-borg/authoring/dist/react/hooks.d.ts.map +1 -1
  53. package/node_modules/@noodle-borg/authoring/dist/react/hooks.js +11 -0
  54. package/node_modules/@noodle-borg/authoring/dist/react/hooks.js.map +1 -1
  55. package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +7 -3
  56. package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
  57. package/node_modules/@noodle-borg/authoring/dist/react/index.js +4 -2
  58. package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
  59. package/node_modules/@noodle-borg/authoring/dist/react/native-components.d.ts +1159 -0
  60. package/node_modules/@noodle-borg/authoring/dist/react/native-components.d.ts.map +1 -0
  61. package/node_modules/@noodle-borg/authoring/dist/react/native-components.js +66 -0
  62. package/node_modules/@noodle-borg/authoring/dist/react/native-components.js.map +1 -0
  63. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
  64. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
  65. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
  66. package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
  67. package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
  68. package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
  69. package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
  70. package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
  71. package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
  72. package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
  73. package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
  74. package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
  75. package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
  76. package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
  77. package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
  78. package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
  79. package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
  80. package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
  81. package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
  82. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
  83. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
  84. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
  85. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
  86. package/node_modules/@noodle-borg/connector-http/package.json +1 -1
  87. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
  88. package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
  89. package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
  90. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
  91. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  92. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
  93. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
  94. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  95. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
  96. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
  97. package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
  98. package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
  99. package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
  100. package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
  101. package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
  102. package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
  103. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
  104. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  105. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  106. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  107. package/node_modules/hono/dist/helper/css/common.js +3 -1
  108. package/node_modules/hono/dist/helper/css/index.js +9 -1
  109. package/node_modules/hono/dist/jsx/base.js +15 -15
  110. package/node_modules/hono/dist/jsx/components.js +42 -22
  111. package/node_modules/hono/dist/jsx/context.js +129 -5
  112. package/node_modules/hono/dist/jsx/streaming.js +10 -8
  113. package/node_modules/hono/dist/middleware/cors/index.js +2 -5
  114. package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
  115. package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
  116. package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
  117. package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
  118. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  119. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  120. package/node_modules/hono/dist/utils/body.js +12 -4
  121. package/node_modules/hono/dist/utils/buffer.js +2 -1
  122. package/node_modules/hono/dist/validator/validator.js +3 -3
  123. package/node_modules/hono/package.json +9 -10
  124. package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
  125. package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
  126. package/node_modules/tailwindcss/dist/lib.js +13 -13
  127. package/node_modules/tailwindcss/dist/lib.mjs +18 -18
  128. package/node_modules/tailwindcss/package.json +2 -2
  129. package/node_modules/undici/README.md +3 -2
  130. package/node_modules/undici/docs/docs/api/Agent.md +248 -44
  131. package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
  132. package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
  133. package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
  134. package/node_modules/undici/docs/docs/api/Client.md +365 -178
  135. package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
  136. package/node_modules/undici/docs/docs/api/Connector.md +118 -36
  137. package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
  138. package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
  139. package/node_modules/undici/docs/docs/api/Debug.md +34 -18
  140. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
  141. package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
  142. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
  143. package/node_modules/undici/docs/docs/api/Errors.md +503 -40
  144. package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
  145. package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
  146. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
  147. package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
  148. package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
  149. package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
  150. package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
  151. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
  152. package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
  153. package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
  154. package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
  155. package/node_modules/undici/docs/docs/api/Pool.md +235 -43
  156. package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
  157. package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
  158. package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
  159. package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
  160. package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
  161. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
  162. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
  163. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
  164. package/node_modules/undici/docs/docs/api/Util.md +68 -11
  165. package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
  166. package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
  167. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
  168. package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
  169. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
  170. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
  171. package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
  172. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
  173. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
  174. package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
  175. package/node_modules/undici/docs/docs/index.md +779 -0
  176. package/node_modules/undici/docs/docs/site.json +125 -0
  177. package/node_modules/undici/docs/docs/type-map.json +79 -0
  178. package/node_modules/undici/lib/api/api-request.js +7 -1
  179. package/node_modules/undici/lib/api/readable.js +47 -2
  180. package/node_modules/undici/lib/core/errors.js +20 -0
  181. package/node_modules/undici/lib/core/request.js +1 -1
  182. package/node_modules/undici/lib/core/util.js +24 -1
  183. package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
  184. package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
  185. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  186. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
  187. package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
  188. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
  189. package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
  190. package/node_modules/undici/lib/handler/retry-handler.js +57 -19
  191. package/node_modules/undici/lib/util/cache.js +8 -2
  192. package/node_modules/undici/lib/web/cookies/parse.js +20 -27
  193. package/node_modules/undici/lib/web/cookies/util.js +1 -1
  194. package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
  195. package/node_modules/undici/lib/web/eventsource/util.js +32 -1
  196. package/node_modules/undici/lib/web/fetch/body.js +43 -0
  197. package/node_modules/undici/lib/web/fetch/constants.js +1 -1
  198. package/node_modules/undici/lib/web/fetch/index.js +11 -2
  199. package/node_modules/undici/lib/web/fetch/request.js +1 -0
  200. package/node_modules/undici/lib/web/fetch/util.js +4 -1
  201. package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
  202. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
  203. package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
  204. package/node_modules/undici/package.json +1 -1
  205. package/node_modules/undici/types/client.d.ts +6 -1
  206. package/node_modules/undici/types/cookies.d.ts +1 -1
  207. package/node_modules/undici/types/errors.d.ts +10 -0
  208. package/node_modules/undici/types/fetch.d.ts +1 -0
  209. package/node_modules/undici/types/handlers.d.ts +2 -0
  210. package/node_modules/undici/types/proxy-agent.d.ts +7 -0
  211. package/package.json +8 -6
  212. package/react/styles.css +851 -0
  213. package/react/styles.source.css +850 -0
  214. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  215. package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
@@ -1,274 +1,250 @@
1
- # Class: Socks5ProxyAgent
1
+ # Socks5ProxyAgent
2
2
 
3
- Extends: `undici.Dispatcher`
3
+ <!--introduced_in=v7.23.0-->
4
+ <!--type=module-->
5
+ <!-- source_link=lib/dispatcher/socks5-proxy-agent.js -->
4
6
 
5
- A SOCKS5 proxy wrapper class that implements the Dispatcher API. It enables HTTP requests to be routed through a SOCKS5 proxy server, providing connection tunneling and authentication support.
7
+ > Stability: 1 - Experimental
6
8
 
7
- ## `new Socks5ProxyAgent(proxyUrl[, options])`
9
+ A [`Dispatcher`][] implementation that routes requests through a [SOCKS5][]
10
+ proxy server. It tunnels both HTTP and HTTPS traffic over the proxy, supports
11
+ optional username/password authentication, and pools connections per origin so
12
+ that subsequent requests to the same host reuse the established tunnel.
8
13
 
9
- Arguments:
14
+ DNS resolution is delegated to the proxy: target host names are sent to the
15
+ proxy as domain names rather than being resolved locally. For HTTPS targets the
16
+ TLS session is negotiated end-to-end through the tunnel, so the proxy only sees
17
+ encrypted bytes.
10
18
 
11
- * **proxyUrl** `string | URL` (required) - The SOCKS5 proxy server URL. Must use `socks5://` or `socks://` protocol.
12
- * **options** `Socks5ProxyAgent.Options` (optional) - Additional configuration options.
19
+ Import it from `'undici'`:
13
20
 
14
- Returns: `Socks5ProxyAgent`
15
-
16
- ### Parameter: `Socks5ProxyAgent.Options`
17
-
18
- Extends: [`PoolOptions`](/docs/docs/api/Pool.md#parameter-pooloptions)
19
-
20
- * **headers** `IncomingHttpHeaders` (optional) - Additional headers to send with proxy connections.
21
- * **username** `string` (optional) - SOCKS5 proxy username for authentication. Can also be provided in the proxy URL.
22
- * **password** `string` (optional) - SOCKS5 proxy password for authentication. Can also be provided in the proxy URL.
23
- * **connect** `Function` (optional) - Custom connector function for the proxy connection.
24
- * **proxyTls** `BuildOptions` (optional) - TLS options for the proxy connection (when using SOCKS5 over TLS).
25
-
26
- Examples:
27
-
28
- ```js
21
+ ```mjs
29
22
  import { Socks5ProxyAgent } from 'undici'
30
-
31
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
32
- // or with authentication
33
- const socks5ProxyWithAuth = new Socks5ProxyAgent('socks5://user:pass@localhost:1080')
34
- // or with options
35
- const socks5ProxyWithOptions = new Socks5ProxyAgent('socks5://localhost:1080', {
36
- username: 'user',
37
- password: 'pass',
38
- connections: 10
39
- })
40
23
  ```
41
24
 
42
- #### Example - Basic SOCKS5 Proxy instantiation
25
+ Constructing the agent emits a one-time `ExperimentalWarning`, reflecting the
26
+ experimental status of SOCKS5 support.
43
27
 
44
- This will instantiate the Socks5ProxyAgent. It will not do anything until registered as the dispatcher to use with requests.
28
+ ## Class: `Socks5ProxyAgent`
45
29
 
46
- ```js
47
- import { Socks5ProxyAgent } from 'undici'
30
+ <!-- YAML
31
+ added: v7.23.0
32
+ -->
48
33
 
49
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
50
- ```
34
+ > Stability: 1 - Experimental
51
35
 
52
- #### Example - Basic SOCKS5 Proxy Request with global dispatcher
36
+ * Extends: {Dispatcher}
53
37
 
54
- ```js
55
- import { setGlobalDispatcher, request, Socks5ProxyAgent } from 'undici'
38
+ Routes dispatched requests through a SOCKS5 proxy. Register an instance as the
39
+ global dispatcher with [`setGlobalDispatcher()`][], or pass it per request via
40
+ the `dispatcher` option.
56
41
 
57
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
58
- setGlobalDispatcher(socks5Proxy)
42
+ ### `new Socks5ProxyAgent(proxyUrl[, options])`
59
43
 
60
- const { statusCode, body } = await request('http://localhost:3000/foo')
44
+ <!-- YAML
45
+ added: v7.23.0
46
+ -->
61
47
 
62
- console.log('response received', statusCode) // response received 200
48
+ > Stability: 1 - Experimental
63
49
 
64
- for await (const data of body) {
65
- console.log('data', data.toString('utf8')) // data foo
66
- }
67
- ```
68
-
69
- #### Example - Basic SOCKS5 Proxy Request with local dispatcher
50
+ * `proxyUrl` {string|URL} The SOCKS5 proxy server URL. Must use the `socks5:` or
51
+ `socks:` protocol. Credentials may be embedded in the URL userinfo (for
52
+ example `socks5://user:pass@host:1080`).
53
+ * `options` {Object} (optional) Extends {PoolOptions}; the pool options are
54
+ applied to the per-origin pools created behind the tunnel.
55
+ * `headers` {Object} Additional headers to send with the proxy connection.
56
+ **Default:** `{}`.
57
+ * `username` {string} Username for SOCKS5 authentication. Takes precedence over
58
+ a username embedded in `proxyUrl`. **Default:** the URL username, if any.
59
+ * `password` {string} Password for SOCKS5 authentication. Takes precedence over
60
+ a password embedded in `proxyUrl`. **Default:** the URL password, if any.
61
+ * `connect` {Function} Custom connector used to open the socket to the proxy.
62
+ **Default:** a connector built from `proxyTls`.
63
+ * `proxyTls` {BuildOptions} TLS options for the connection to the proxy itself
64
+ (SOCKS5 over TLS). When set, the proxy connection is established over TLS and
65
+ `servername` defaults to the proxy host name.
66
+ * `requestTls` {BuildOptions} TLS options applied to the end-to-end connection
67
+ to an HTTPS target through the tunnel, such as `ca`, `cert`, `key`,
68
+ `rejectUnauthorized`, and `servername`. `servername` defaults to the target
69
+ host name.
70
70
 
71
- ```js
72
- import { Socks5ProxyAgent, request } from 'undici'
71
+ Throws an `InvalidArgumentError` if `proxyUrl` is missing or does not use the
72
+ `socks5:` or `socks:` protocol.
73
73
 
74
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
74
+ ```mjs
75
+ import { Socks5ProxyAgent } from 'undici'
75
76
 
76
- const {
77
- statusCode,
78
- body
79
- } = await request('http://localhost:3000/foo', { dispatcher: socks5Proxy })
77
+ // Without authentication.
78
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
80
79
 
81
- console.log('response received', statusCode) // response received 200
80
+ // With credentials in the URL.
81
+ const authAgent = new Socks5ProxyAgent('socks5://user:pass@localhost:1080')
82
82
 
83
- for await (const data of body) {
84
- console.log('data', data.toString('utf8')) // data foo
85
- }
83
+ // With credentials and pool options.
84
+ const configuredAgent = new Socks5ProxyAgent('socks5://localhost:1080', {
85
+ username: 'user',
86
+ password: 'pass',
87
+ connections: 10
88
+ })
86
89
  ```
87
90
 
88
- #### Example - SOCKS5 Proxy Request with authentication
91
+ Using the agent as the global dispatcher:
89
92
 
90
- ```js
93
+ ```mjs
91
94
  import { setGlobalDispatcher, request, Socks5ProxyAgent } from 'undici'
92
95
 
93
- // Authentication via URL
94
- const socks5Proxy = new Socks5ProxyAgent('socks5://username:password@localhost:1080')
95
-
96
- // Or authentication via options
97
- // const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080', {
98
- // username: 'username',
99
- // password: 'password'
100
- // })
101
-
102
- setGlobalDispatcher(socks5Proxy)
96
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
97
+ setGlobalDispatcher(agent)
103
98
 
104
99
  const { statusCode, body } = await request('http://localhost:3000/foo')
105
-
106
- console.log('response received', statusCode) // response received 200
100
+ console.log('response received', statusCode)
107
101
 
108
102
  for await (const data of body) {
109
- console.log('data', data.toString('utf8')) // data foo
103
+ console.log('data', data.toString('utf8'))
110
104
  }
111
105
  ```
112
106
 
113
- #### Example - SOCKS5 Proxy with HTTPS requests
114
-
115
- SOCKS5 proxy supports both HTTP and HTTPS requests through tunneling:
107
+ Using the agent per request:
116
108
 
117
- ```js
118
- import { Socks5ProxyAgent, request } from 'undici'
109
+ ```mjs
110
+ import { request, Socks5ProxyAgent } from 'undici'
119
111
 
120
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
112
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
121
113
 
122
- const response = await request('https://api.example.com/data', {
123
- dispatcher: socks5Proxy,
124
- method: 'GET'
114
+ const { statusCode, body } = await request('http://localhost:3000/foo', {
115
+ dispatcher: agent
125
116
  })
126
117
 
127
- console.log('Response status:', response.statusCode)
128
- console.log('Response data:', await response.body.json())
118
+ console.log('response received', statusCode)
129
119
  ```
130
120
 
131
- #### Example - SOCKS5 Proxy with Fetch
121
+ HTTPS targets are tunnelled and encrypted end-to-end:
132
122
 
133
- ```js
134
- import { Socks5ProxyAgent, fetch } from 'undici'
123
+ ```mjs
124
+ import { request, Socks5ProxyAgent } from 'undici'
135
125
 
136
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
126
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
137
127
 
138
- const response = await fetch('http://localhost:3000/api/users', {
139
- dispatcher: socks5Proxy,
140
- method: 'GET'
128
+ const { statusCode, body } = await request('https://api.example.com/data', {
129
+ dispatcher: agent
141
130
  })
142
131
 
143
- console.log('Response status:', response.status)
144
- console.log('Response data:', await response.text())
132
+ console.log('Response status:', statusCode)
133
+ console.log('Response data:', await body.json())
145
134
  ```
146
135
 
147
- #### Example - Connection Pooling
136
+ ### `socks5ProxyAgent.close()`
148
137
 
149
- SOCKS5ProxyWrapper automatically manages connection pooling for better performance:
138
+ <!-- YAML
139
+ added: v7.23.0
140
+ -->
150
141
 
151
- ```js
152
- import { Socks5ProxyAgent, request } from 'undici'
142
+ > Stability: 1 - Experimental
153
143
 
154
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080', {
155
- connections: 10, // Allow up to 10 concurrent connections
156
- pipelining: 1 // Enable HTTP/1.1 pipelining
157
- })
144
+ * Returns: {Promise<void>} Resolves once every per-origin pool has been closed.
158
145
 
159
- // Multiple requests will reuse connections through the SOCKS5 tunnel
160
- const responses = await Promise.all([
161
- request('http://api.example.com/endpoint1', { dispatcher: socks5Proxy }),
162
- request('http://api.example.com/endpoint2', { dispatcher: socks5Proxy }),
163
- request('http://api.example.com/endpoint3', { dispatcher: socks5Proxy })
164
- ])
146
+ Gracefully closes the agent, waiting for all underlying pools and their
147
+ connections to drain and close before resolving.
165
148
 
166
- console.log('All requests completed through the same SOCKS5 proxy')
167
- ```
149
+ ```mjs
150
+ import { setGlobalDispatcher, Socks5ProxyAgent } from 'undici'
168
151
 
169
- ### `Socks5ProxyAgent.close()`
152
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
153
+ setGlobalDispatcher(agent)
170
154
 
171
- Closes the SOCKS5 proxy wrapper and waits for all underlying pools and connections to close before resolving.
155
+ // ... make requests ...
172
156
 
173
- Returns: `Promise<void>`
174
-
175
- #### Example - clean up after tests are complete
176
-
177
- ```js
178
- import { Socks5ProxyAgent, setGlobalDispatcher } from 'undici'
179
-
180
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
181
- setGlobalDispatcher(socks5Proxy)
182
-
183
- // ... make requests
184
-
185
- await socks5Proxy.close()
157
+ await agent.close()
186
158
  ```
187
159
 
188
- ### `Socks5ProxyAgent.destroy([err])`
160
+ ### `socks5ProxyAgent.destroy([err])`
189
161
 
190
- Destroys the SOCKS5 proxy wrapper and all underlying connections immediately.
162
+ <!-- YAML
163
+ added: v7.23.0
164
+ -->
191
165
 
192
- Arguments:
193
- * **err** `Error` (optional) - The error that caused the destruction.
166
+ > Stability: 1 - Experimental
194
167
 
195
- Returns: `Promise<void>`
168
+ * `err` {Error} (optional) The error to reject in-flight requests with.
169
+ * Returns: {Promise<void>} Resolves once every per-origin pool has been
170
+ destroyed.
196
171
 
197
- #### Example - force close all connections
172
+ Forcibly destroys the agent and all underlying connections immediately, without
173
+ waiting for in-flight requests to complete.
198
174
 
199
- ```js
175
+ ```mjs
200
176
  import { Socks5ProxyAgent } from 'undici'
201
177
 
202
- const socks5Proxy = new Socks5ProxyAgent('socks5://localhost:1080')
178
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
203
179
 
204
- // Force close all connections
205
- await socks5Proxy.destroy()
180
+ await agent.destroy()
206
181
  ```
207
182
 
208
- ### `Socks5ProxyAgent.dispatch(options, handlers)`
209
-
210
- Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handlers).
183
+ ### `socks5ProxyAgent.dispatch(options, handlers)`
211
184
 
212
- ### `Socks5ProxyAgent.request(options[, callback])`
185
+ <!-- YAML
186
+ added: v7.23.0
187
+ -->
213
188
 
214
- See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
189
+ > Stability: 1 - Experimental
215
190
 
216
- ## Debugging
217
-
218
- SOCKS5 proxy connections can be debugged using Node.js diagnostics:
219
-
220
- ```sh
221
- NODE_DEBUG=undici:socks5 node script.js
222
- ```
191
+ * `options` {DispatchOptions}
192
+ * `handlers` {DispatchHandler}
193
+ * Returns: {boolean} `false` if the dispatcher is busy and the request should be
194
+ retried later, otherwise `true`.
223
195
 
224
- This will output detailed information about the SOCKS5 handshake, authentication, and connection establishment.
196
+ Routes a request through the SOCKS5 tunnel. The agent maintains a [`Pool`][] per
197
+ target origin; the first request to a given origin establishes the tunnel and
198
+ upgrades to TLS when the target is HTTPS, and later requests reuse the pool.
225
199
 
226
- ## SOCKS5 Protocol Support
200
+ This is the lower-level entry point implementing
201
+ [`Dispatcher.dispatch(options, handlers)`][]. Prefer
202
+ [`socks5ProxyAgent.request()`][] for most use cases.
227
203
 
228
- The Socks5ProxyAgent supports the following SOCKS5 features:
204
+ ### `socks5ProxyAgent.request(options[, callback])`
229
205
 
230
- ### Authentication Methods
206
+ <!-- YAML
207
+ added: v7.23.0
208
+ -->
231
209
 
232
- - **No Authentication** (`0x00`) - For public or internal proxies
233
- - **Username/Password** (`0x02`) - RFC 1929 authentication
210
+ > Stability: 1 - Experimental
234
211
 
235
- ### Address Types
212
+ * `options` {DispatchOptions}
213
+ * `callback` {Function} (optional)
214
+ * Returns: {Promise|void} A promise resolving to the response when `callback` is
215
+ omitted.
236
216
 
237
- - **IPv4** (`0x01`) - Standard IPv4 addresses
238
- - **Domain Name** (`0x03`) - Domain names (recommended for flexibility)
239
- - **IPv6** (`0x04`) - IPv6 addresses (full support for standard and compressed notation)
217
+ Performs a request through the SOCKS5 proxy. Inherited from
218
+ [`Dispatcher.request(options[, callback])`][]; see that method for the full set
219
+ of options and the shape of the resolved response.
240
220
 
241
- ### Commands
221
+ ```mjs
222
+ import { fetch, Socks5ProxyAgent } from 'undici'
242
223
 
243
- - **CONNECT** (`0x01`) - Establish TCP connection (primary use case for HTTP)
224
+ const agent = new Socks5ProxyAgent('socks5://localhost:1080')
244
225
 
245
- ### Error Handling
246
-
247
- The wrapper handles various SOCKS5 error conditions:
248
-
249
- - Connection refused by proxy
250
- - Authentication failures
251
- - Network unreachable
252
- - Host unreachable
253
- - Unsupported address types or commands
226
+ const response = await fetch('http://localhost:3000/api/users', {
227
+ dispatcher: agent
228
+ })
254
229
 
255
- ## Performance Considerations
230
+ console.log('Response status:', response.status)
231
+ console.log('Response data:', await response.text())
232
+ ```
256
233
 
257
- - **Connection Pooling**: Automatically pools connections through the SOCKS5 tunnel for better performance
258
- - **HTTP/1.1 Pipelining**: Supports pipelining when enabled
259
- - **DNS Resolution**: Domain names are resolved by the SOCKS5 proxy, reducing local DNS queries
260
- - **TLS Termination**: HTTPS connections are encrypted end-to-end, with the SOCKS5 proxy only handling the TCP tunnel
234
+ ## Debugging
261
235
 
262
- ## Security Notes
236
+ SOCKS5 proxy activity can be traced with the `undici:socks5-proxy` debug scope:
263
237
 
264
- 1. **Authentication**: Credentials are sent to the SOCKS5 proxy in plaintext unless using SOCKS5 over TLS
265
- 2. **DNS Leaks**: All DNS resolution happens on the proxy server, preventing DNS leaks
266
- 3. **End-to-end Encryption**: HTTPS traffic remains encrypted between client and final destination
267
- 4. **Connection Security**: Consider using authenticated proxies and secure networks
238
+ ```bash
239
+ NODE_DEBUG=undici:socks5-proxy node script.js
240
+ ```
268
241
 
269
- ## Compatibility
242
+ This logs the SOCKS5 handshake, authentication, and tunnel establishment steps.
270
243
 
271
- - **Protocol**: SOCKS5 (RFC 1928) with Username/Password Authentication (RFC 1929)
272
- - **Transport**: TCP only (UDP support not implemented)
273
- - **Node.js**: Compatible with all supported Node.js versions
274
- - **HTTP Versions**: Works with HTTP/1.1 and HTTP/2 over the tunnel
244
+ [SOCKS5]: https://www.rfc-editor.org/rfc/rfc1928
245
+ [`Dispatcher.dispatch(options, handlers)`]: Dispatcher.md#dispatcherdispatchoptions-handler
246
+ [`Dispatcher.request(options[, callback])`]: Dispatcher.md#dispatcherrequestoptions-callback
247
+ [`Dispatcher`]: Dispatcher.md#class-dispatcher
248
+ [`Pool`]: Pool.md#class-pool
249
+ [`setGlobalDispatcher()`]: Dispatcher.md#setglobaldispatcherdispatcher
250
+ [`socks5ProxyAgent.request()`]: #socks5proxyagentrequestoptions-callback
@@ -1,25 +1,82 @@
1
1
  # Util
2
2
 
3
- Utility API for third-party implementations of the dispatcher API.
3
+ <!--introduced_in=v1.2.0-->
4
+ <!--type=module-->
5
+ <!-- source_link=lib/core/util.js -->
4
6
 
5
- ## `parseHeaders(headers, [obj])`
7
+ > Stability: 2 - Stable
6
8
 
7
- Receives a header object and returns the parsed value.
9
+ A small set of utility helpers exposed for third-party implementations of the
10
+ [`Dispatcher`][] API. They cover the header-handling primitives undici uses
11
+ internally, so that custom dispatchers and handlers can normalize header names
12
+ and parse raw header lists exactly the way undici does.
8
13
 
9
- Arguments:
14
+ ```mjs
15
+ import { util } from 'undici'
10
16
 
11
- - **headers** `(Buffer | string | (Buffer | string)[])[]` (required) - Header object.
17
+ const { parseHeaders, headerNameToString } = util
18
+ ```
12
19
 
13
- - **obj** `Record<string, string | string[]>` (optional) - Object to specify a proxy object. The parsed value is assigned to this object. But, if **headers** is an object, it is not used.
20
+ ```cjs
21
+ const { util } = require('undici')
14
22
 
15
- Returns: `Record<string, string | string[]>` If **obj** is specified, it is equivalent to **obj**.
23
+ const { parseHeaders, headerNameToString } = util
24
+ ```
25
+
26
+ ## `parseHeaders(headers[, obj])`
27
+
28
+ <!-- YAML
29
+ added: v1.2.0
30
+ changes:
31
+ - version: v6.1.0
32
+ pr-url: https://github.com/nodejs/undici/pull/2501
33
+ description: Header names supplied as a `Buffer` are accepted and normalized.
34
+ -->
35
+
36
+ * `headers` {Array} A flat list of raw header entries where even indices are
37
+ header names and odd indices are the corresponding values. Each entry is a
38
+ {string}, {Buffer}, or an array of {string}/{Buffer}.
39
+ * `obj` {Record<string, string|string[]>} An object to assign the parsed values
40
+ to. When omitted, a new object is created. **Default:** `{}`.
41
+ * Returns: {Record<string, string|string[]>} The object the parsed headers were
42
+ assigned to. When `obj` is provided, the same reference is returned.
43
+
44
+ Receives a flat list of raw header name/value pairs and returns them as an
45
+ object keyed by lowercased header name. Header names are normalized with
46
+ [`headerNameToString()`][], and `Buffer` values are decoded as `latin1`. When a
47
+ header name appears more than once, its values are collected into an array.
48
+
49
+ ```mjs
50
+ import { util } from 'undici'
51
+
52
+ const raw = ['Content-Type', 'text/plain', 'Set-Cookie', 'a=1', 'Set-Cookie', 'b=2']
53
+
54
+ console.log(util.parseHeaders(raw))
55
+ // { 'content-type': 'text/plain', 'set-cookie': [ 'a=1', 'b=2' ] }
56
+ ```
16
57
 
17
58
  ## `headerNameToString(value)`
18
59
 
19
- Retrieves a header name and returns its lowercase value.
60
+ <!-- YAML
61
+ added: v6.1.0
62
+ -->
63
+
64
+ * `value` {string|Buffer} The header name to normalize.
65
+ * Returns: {string} The lowercased header name.
66
+
67
+ Returns the lowercased form of a header name. The `value` may be provided as a
68
+ {string} or as a {Buffer}, in which case it is decoded as `latin1`. Common
69
+ header names are resolved through an internal lookup table for performance.
70
+
71
+ ```mjs
72
+ import { util } from 'undici'
20
73
 
21
- Arguments:
74
+ console.log(util.headerNameToString('Content-Type'))
75
+ // 'content-type'
22
76
 
23
- - **value** `string | Buffer` (required) - Header name.
77
+ console.log(util.headerNameToString(Buffer.from('X-Custom-Header')))
78
+ // 'x-custom-header'
79
+ ```
24
80
 
25
- Returns: `string`
81
+ [`Dispatcher`]: Dispatcher.md#class-dispatcher
82
+ [`headerNameToString()`]: #headernametostringvalue