@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.
- 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/curated/hook-notes.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/curated/hook-notes.js +2 -1
- package/node_modules/@noodle-borg/agent-kit/dist/curated/hook-notes.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.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/bridge.d.ts +9 -1
- package/node_modules/@noodle-borg/authoring/dist/react/bridge.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/bridge.js +11 -1
- package/node_modules/@noodle-borg/authoring/dist/react/bridge.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +306 -9
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +63 -11
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/hooks.d.ts +2 -0
- package/node_modules/@noodle-borg/authoring/dist/react/hooks.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/hooks.js +11 -0
- package/node_modules/@noodle-borg/authoring/dist/react/hooks.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +7 -3
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/native-components.d.ts +1159 -0
- package/node_modules/@noodle-borg/authoring/dist/react/native-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/native-components.js +66 -0
- package/node_modules/@noodle-borg/authoring/dist/react/native-components.js.map +1 -0
- 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 +8 -6
- package/react/styles.css +851 -0
- 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,274 +1,250 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Socks5ProxyAgent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!--introduced_in=v7.23.0-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/dispatcher/socks5-proxy-agent.js -->
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
> Stability: 1 - Experimental
|
|
6
8
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12
|
-
* **options** `Socks5ProxyAgent.Options` (optional) - Additional configuration options.
|
|
19
|
+
Import it from `'undici'`:
|
|
13
20
|
|
|
14
|
-
|
|
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
|
-
|
|
25
|
+
Constructing the agent emits a one-time `ExperimentalWarning`, reflecting the
|
|
26
|
+
experimental status of SOCKS5 support.
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
## Class: `Socks5ProxyAgent`
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
<!-- YAML
|
|
31
|
+
added: v7.23.0
|
|
32
|
+
-->
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
```
|
|
34
|
+
> Stability: 1 - Experimental
|
|
51
35
|
|
|
52
|
-
|
|
36
|
+
* Extends: {Dispatcher}
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
setGlobalDispatcher(socks5Proxy)
|
|
42
|
+
### `new Socks5ProxyAgent(proxyUrl[, options])`
|
|
59
43
|
|
|
60
|
-
|
|
44
|
+
<!-- YAML
|
|
45
|
+
added: v7.23.0
|
|
46
|
+
-->
|
|
61
47
|
|
|
62
|
-
|
|
48
|
+
> Stability: 1 - Experimental
|
|
63
49
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
72
|
-
|
|
71
|
+
Throws an `InvalidArgumentError` if `proxyUrl` is missing or does not use the
|
|
72
|
+
`socks5:` or `socks:` protocol.
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
```mjs
|
|
75
|
+
import { Socks5ProxyAgent } from 'undici'
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
+
// With credentials in the URL.
|
|
81
|
+
const authAgent = new Socks5ProxyAgent('socks5://user:pass@localhost:1080')
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
91
|
+
Using the agent as the global dispatcher:
|
|
89
92
|
|
|
90
|
-
```
|
|
93
|
+
```mjs
|
|
91
94
|
import { setGlobalDispatcher, request, Socks5ProxyAgent } from 'undici'
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
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'))
|
|
103
|
+
console.log('data', data.toString('utf8'))
|
|
110
104
|
}
|
|
111
105
|
```
|
|
112
106
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
SOCKS5 proxy supports both HTTP and HTTPS requests through tunneling:
|
|
107
|
+
Using the agent per request:
|
|
116
108
|
|
|
117
|
-
```
|
|
118
|
-
import {
|
|
109
|
+
```mjs
|
|
110
|
+
import { request, Socks5ProxyAgent } from 'undici'
|
|
119
111
|
|
|
120
|
-
const
|
|
112
|
+
const agent = new Socks5ProxyAgent('socks5://localhost:1080')
|
|
121
113
|
|
|
122
|
-
const
|
|
123
|
-
dispatcher:
|
|
124
|
-
method: 'GET'
|
|
114
|
+
const { statusCode, body } = await request('http://localhost:3000/foo', {
|
|
115
|
+
dispatcher: agent
|
|
125
116
|
})
|
|
126
117
|
|
|
127
|
-
console.log('
|
|
128
|
-
console.log('Response data:', await response.body.json())
|
|
118
|
+
console.log('response received', statusCode)
|
|
129
119
|
```
|
|
130
120
|
|
|
131
|
-
|
|
121
|
+
HTTPS targets are tunnelled and encrypted end-to-end:
|
|
132
122
|
|
|
133
|
-
```
|
|
134
|
-
import {
|
|
123
|
+
```mjs
|
|
124
|
+
import { request, Socks5ProxyAgent } from 'undici'
|
|
135
125
|
|
|
136
|
-
const
|
|
126
|
+
const agent = new Socks5ProxyAgent('socks5://localhost:1080')
|
|
137
127
|
|
|
138
|
-
const
|
|
139
|
-
dispatcher:
|
|
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:',
|
|
144
|
-
console.log('Response data:', await
|
|
132
|
+
console.log('Response status:', statusCode)
|
|
133
|
+
console.log('Response data:', await body.json())
|
|
145
134
|
```
|
|
146
135
|
|
|
147
|
-
|
|
136
|
+
### `socks5ProxyAgent.close()`
|
|
148
137
|
|
|
149
|
-
|
|
138
|
+
<!-- YAML
|
|
139
|
+
added: v7.23.0
|
|
140
|
+
-->
|
|
150
141
|
|
|
151
|
-
|
|
152
|
-
import { Socks5ProxyAgent, request } from 'undici'
|
|
142
|
+
> Stability: 1 - Experimental
|
|
153
143
|
|
|
154
|
-
|
|
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
|
-
|
|
160
|
-
|
|
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
|
-
|
|
167
|
-
|
|
149
|
+
```mjs
|
|
150
|
+
import { setGlobalDispatcher, Socks5ProxyAgent } from 'undici'
|
|
168
151
|
|
|
169
|
-
|
|
152
|
+
const agent = new Socks5ProxyAgent('socks5://localhost:1080')
|
|
153
|
+
setGlobalDispatcher(agent)
|
|
170
154
|
|
|
171
|
-
|
|
155
|
+
// ... make requests ...
|
|
172
156
|
|
|
173
|
-
|
|
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
|
-
### `
|
|
160
|
+
### `socks5ProxyAgent.destroy([err])`
|
|
189
161
|
|
|
190
|
-
|
|
162
|
+
<!-- YAML
|
|
163
|
+
added: v7.23.0
|
|
164
|
+
-->
|
|
191
165
|
|
|
192
|
-
|
|
193
|
-
* **err** `Error` (optional) - The error that caused the destruction.
|
|
166
|
+
> Stability: 1 - Experimental
|
|
194
167
|
|
|
195
|
-
|
|
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
|
-
|
|
172
|
+
Forcibly destroys the agent and all underlying connections immediately, without
|
|
173
|
+
waiting for in-flight requests to complete.
|
|
198
174
|
|
|
199
|
-
```
|
|
175
|
+
```mjs
|
|
200
176
|
import { Socks5ProxyAgent } from 'undici'
|
|
201
177
|
|
|
202
|
-
const
|
|
178
|
+
const agent = new Socks5ProxyAgent('socks5://localhost:1080')
|
|
203
179
|
|
|
204
|
-
|
|
205
|
-
await socks5Proxy.destroy()
|
|
180
|
+
await agent.destroy()
|
|
206
181
|
```
|
|
207
182
|
|
|
208
|
-
### `
|
|
209
|
-
|
|
210
|
-
Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handlers).
|
|
183
|
+
### `socks5ProxyAgent.dispatch(options, handlers)`
|
|
211
184
|
|
|
212
|
-
|
|
185
|
+
<!-- YAML
|
|
186
|
+
added: v7.23.0
|
|
187
|
+
-->
|
|
213
188
|
|
|
214
|
-
|
|
189
|
+
> Stability: 1 - Experimental
|
|
215
190
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
204
|
+
### `socks5ProxyAgent.request(options[, callback])`
|
|
229
205
|
|
|
230
|
-
|
|
206
|
+
<!-- YAML
|
|
207
|
+
added: v7.23.0
|
|
208
|
+
-->
|
|
231
209
|
|
|
232
|
-
|
|
233
|
-
- **Username/Password** (`0x02`) - RFC 1929 authentication
|
|
210
|
+
> Stability: 1 - Experimental
|
|
234
211
|
|
|
235
|
-
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
221
|
+
```mjs
|
|
222
|
+
import { fetch, Socks5ProxyAgent } from 'undici'
|
|
242
223
|
|
|
243
|
-
|
|
224
|
+
const agent = new Socks5ProxyAgent('socks5://localhost:1080')
|
|
244
225
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
230
|
+
console.log('Response status:', response.status)
|
|
231
|
+
console.log('Response data:', await response.text())
|
|
232
|
+
```
|
|
256
233
|
|
|
257
|
-
|
|
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
|
-
|
|
236
|
+
SOCKS5 proxy activity can be traced with the `undici:socks5-proxy` debug scope:
|
|
263
237
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
242
|
+
This logs the SOCKS5 handshake, authentication, and tunnel establishment steps.
|
|
270
243
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
3
|
+
<!--introduced_in=v1.2.0-->
|
|
4
|
+
<!--type=module-->
|
|
5
|
+
<!-- source_link=lib/core/util.js -->
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
> Stability: 2 - Stable
|
|
6
8
|
|
|
7
|
-
|
|
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
|
-
|
|
14
|
+
```mjs
|
|
15
|
+
import { util } from 'undici'
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
const { parseHeaders, headerNameToString } = util
|
|
18
|
+
```
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
```cjs
|
|
21
|
+
const { util } = require('undici')
|
|
14
22
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
74
|
+
console.log(util.headerNameToString('Content-Type'))
|
|
75
|
+
// 'content-type'
|
|
22
76
|
|
|
23
|
-
|
|
77
|
+
console.log(util.headerNameToString(Buffer.from('X-Custom-Header')))
|
|
78
|
+
// 'x-custom-header'
|
|
79
|
+
```
|
|
24
80
|
|
|
25
|
-
|
|
81
|
+
[`Dispatcher`]: Dispatcher.md#class-dispatcher
|
|
82
|
+
[`headerNameToString()`]: #headernametostringvalue
|