@entelligentsia/forgecli 0.7.10 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/dist/CHANGELOG-forge-plugin.md +70 -0
- package/dist/CHANGELOG-pi.md +63 -0
- package/dist/bin/argv.d.ts +2 -2
- package/dist/bin/argv.js +10 -0
- package/dist/bin/argv.js.map +1 -1
- package/dist/bin/env-defaults.d.ts +1 -0
- package/dist/bin/env-defaults.js +13 -0
- package/dist/bin/env-defaults.js.map +1 -0
- package/dist/bin/forge.js +9 -0
- package/dist/bin/forge.js.map +1 -1
- package/dist/bin/update-cli.d.ts +9 -0
- package/dist/bin/update-cli.js +120 -0
- package/dist/bin/update-cli.js.map +1 -0
- package/dist/extensions/forgecli/index.js +3 -3
- package/dist/extensions/forgecli/index.js.map +1 -1
- package/dist/extensions/forgecli/update-check.js +1 -1
- package/dist/extensions/forgecli/update-check.js.map +1 -1
- package/dist/extensions/forgecli/whats-new-widget.d.ts +5 -5
- package/dist/extensions/forgecli/whats-new-widget.js +11 -11
- package/dist/extensions/forgecli/whats-new-widget.js.map +1 -1
- package/dist/extensions/forgecli/whats-new.js +6 -5
- package/dist/extensions/forgecli/whats-new.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +27 -98
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +62 -132
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +25 -15
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +17 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +8 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +17 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +63 -0
- package/node_modules/@earendil-works/pi-coding-agent/README.md +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js +6 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +12 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +30 -15
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +23 -13
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts +4 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +58 -38
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js +0 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +3 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +7 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +6 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +3 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts +7 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +60 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +1 -3
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
- package/node_modules/@earendil-works/pi-tui/package.json +2 -2
- package/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/fetch/index.d.ts +7 -7
- package/node_modules/@protobufjs/fetch/index.js +4 -7
- package/node_modules/@protobufjs/fetch/package.json +7 -5
- package/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
- package/node_modules/@protobufjs/fetch/tests/index.js +150 -8
- package/node_modules/@protobufjs/fetch/util/fs.js +11 -0
- package/node_modules/@protobufjs/inquire/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/inquire/index.d.ts +1 -0
- package/node_modules/@protobufjs/inquire/index.js +1 -0
- package/node_modules/@protobufjs/inquire/package.json +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.js +187 -153
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +14 -5
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.js +207 -173
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +6 -3
- package/node_modules/protobufjs/src/util/fs.js +11 -0
- package/node_modules/protobufjs/src/util/minimal.js +10 -2
- package/node_modules/protobufjs/src/util.js +1 -1
- package/node_modules/undici/README.md +14 -5
- package/node_modules/undici/docs/docs/api/Client.md +4 -2
- package/node_modules/undici/docs/docs/api/Dispatcher.md +62 -27
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +7 -5
- package/node_modules/undici/docs/docs/api/H2CClient.md +1 -1
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +14 -9
- package/node_modules/undici/docs/docs/api/RetryAgent.md +0 -1
- package/node_modules/undici/docs/docs/api/RetryHandler.md +12 -14
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +23 -0
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +231 -0
- package/node_modules/undici/index.js +4 -2
- package/node_modules/undici/lib/api/api-connect.js +13 -11
- package/node_modules/undici/lib/api/api-pipeline.js +26 -13
- package/node_modules/undici/lib/api/api-request.js +45 -21
- package/node_modules/undici/lib/api/api-stream.js +81 -20
- package/node_modules/undici/lib/api/api-upgrade.js +21 -11
- package/node_modules/undici/lib/api/readable.js +3 -2
- package/node_modules/undici/lib/cache/memory-cache-store.js +1 -1
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +6 -4
- package/node_modules/undici/lib/core/connect.js +17 -1
- package/node_modules/undici/lib/core/constants.js +1 -24
- package/node_modules/undici/lib/core/errors.js +2 -2
- package/node_modules/undici/lib/core/request.js +115 -18
- package/node_modules/undici/lib/core/socks5-client.js +24 -9
- package/node_modules/undici/lib/core/socks5-utils.js +32 -23
- package/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/undici/lib/core/util.js +70 -43
- package/node_modules/undici/lib/dispatcher/agent.js +47 -33
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +21 -26
- package/node_modules/undici/lib/dispatcher/client-h1.js +98 -39
- package/node_modules/undici/lib/dispatcher/client-h2.js +603 -272
- package/node_modules/undici/lib/dispatcher/client.js +12 -5
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +24 -5
- package/node_modules/undici/lib/dispatcher/dispatcher.js +0 -4
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +107 -0
- package/node_modules/undici/lib/dispatcher/h2c-client.js +5 -5
- package/node_modules/undici/lib/dispatcher/pool-base.js +28 -10
- package/node_modules/undici/lib/dispatcher/pool.js +31 -6
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +38 -13
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +31 -9
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +95 -80
- package/node_modules/undici/lib/global.js +13 -1
- package/node_modules/undici/lib/handler/cache-handler.js +16 -8
- package/node_modules/undici/lib/handler/decorator-handler.js +1 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -51
- package/node_modules/undici/lib/handler/retry-handler.js +15 -2
- package/node_modules/undici/lib/interceptor/cache.js +30 -17
- package/node_modules/undici/lib/interceptor/decompress.js +28 -2
- package/node_modules/undici/lib/interceptor/dns.js +1 -1
- package/node_modules/undici/lib/interceptor/redirect.js +3 -3
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +1 -1
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +1 -1
- package/node_modules/undici/lib/mock/mock-agent.js +8 -8
- package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
- package/node_modules/undici/lib/mock/mock-utils.js +37 -22
- package/node_modules/undici/lib/mock/snapshot-agent.js +16 -6
- package/node_modules/undici/lib/mock/snapshot-recorder.js +38 -3
- package/node_modules/undici/lib/util/cache.js +8 -7
- package/node_modules/undici/lib/util/runtime-features.js +3 -34
- package/node_modules/undici/lib/web/cache/cache.js +6 -8
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
- package/node_modules/undici/lib/web/fetch/body.js +3 -9
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +21 -2
- package/node_modules/undici/lib/web/fetch/index.js +214 -221
- package/node_modules/undici/lib/web/webidl/index.js +7 -9
- package/node_modules/undici/lib/web/websocket/frame.js +1 -7
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
- package/node_modules/undici/lib/web/websocket/receiver.js +62 -22
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +11 -17
- package/node_modules/undici/lib/web/websocket/websocket.js +6 -1
- package/node_modules/undici/package.json +9 -9
- package/node_modules/undici/types/agent.d.ts +0 -2
- package/node_modules/undici/types/client.d.ts +25 -19
- package/node_modules/undici/types/dispatcher.d.ts +7 -27
- package/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/undici/types/formdata.d.ts +0 -6
- package/node_modules/undici/types/h2c-client.d.ts +6 -6
- package/node_modules/undici/types/header.d.ts +5 -0
- package/node_modules/undici/types/index.d.ts +3 -1
- package/node_modules/undici/types/interceptors.d.ts +1 -1
- package/node_modules/undici/types/pool.d.ts +0 -2
- package/node_modules/undici/types/proxy-agent.d.ts +2 -2
- package/node_modules/undici/types/round-robin-pool.d.ts +0 -2
- package/node_modules/undici/types/snapshot-agent.d.ts +4 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -2
- package/node_modules/undici/types/webidl.d.ts +0 -1
- package/package.json +7 -8
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +0 -92
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +0 -31
- package/node_modules/undici/lib/handler/unwrap-handler.js +0 -100
- package/node_modules/undici/lib/handler/wrap-handler.js +0 -105
- package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/node_modules/undici/lib/util/promise.js +0 -28
- package/skills/refresh-kb-links/SKILL.md +0 -217
- package/skills/store-custodian/SKILL.md +0 -163
- package/skills/store-query-grammar/SKILL.md +0 -145
- package/skills/store-query-nlp/SKILL.md +0 -110
|
@@ -8,40 +8,35 @@ const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
|
|
|
8
8
|
const kBuffer = Symbol('kBuffer')
|
|
9
9
|
const kLength = Symbol('kLength')
|
|
10
10
|
|
|
11
|
-
// Default maximum decompressed message size: 4 MB
|
|
12
|
-
const kDefaultMaxDecompressedSize = 4 * 1024 * 1024
|
|
13
|
-
|
|
14
11
|
class PerMessageDeflate {
|
|
15
12
|
/** @type {import('node:zlib').InflateRaw} */
|
|
16
13
|
#inflate
|
|
17
14
|
|
|
18
15
|
#options = {}
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
#aborted = false
|
|
22
|
-
|
|
23
|
-
/** @type {Function|null} */
|
|
24
|
-
#currentCallback = null
|
|
17
|
+
#maxPayloadSize = 0
|
|
25
18
|
|
|
26
19
|
/**
|
|
27
20
|
* @param {Map<string, string>} extensions
|
|
28
21
|
*/
|
|
29
|
-
constructor (extensions) {
|
|
22
|
+
constructor (extensions, options) {
|
|
30
23
|
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
|
|
31
24
|
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
|
|
25
|
+
|
|
26
|
+
this.#maxPayloadSize = options.maxPayloadSize
|
|
32
27
|
}
|
|
33
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Decompress a compressed payload.
|
|
31
|
+
* @param {Buffer} chunk Compressed data
|
|
32
|
+
* @param {boolean} fin Final fragment flag
|
|
33
|
+
* @param {Function} callback Callback function
|
|
34
|
+
*/
|
|
34
35
|
decompress (chunk, fin, callback) {
|
|
35
36
|
// An endpoint uses the following algorithm to decompress a message.
|
|
36
37
|
// 1. Append 4 octets of 0x00 0x00 0xff 0xff to the tail end of the
|
|
37
38
|
// payload of the message.
|
|
38
39
|
// 2. Decompress the resulting data using DEFLATE.
|
|
39
|
-
|
|
40
|
-
if (this.#aborted) {
|
|
41
|
-
callback(new MessageSizeExceededError())
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
|
|
45
40
|
if (!this.#inflate) {
|
|
46
41
|
let windowBits = Z_DEFAULT_WINDOWBITS
|
|
47
42
|
|
|
@@ -64,23 +59,12 @@ class PerMessageDeflate {
|
|
|
64
59
|
this.#inflate[kLength] = 0
|
|
65
60
|
|
|
66
61
|
this.#inflate.on('data', (data) => {
|
|
67
|
-
if (this.#aborted) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
|
|
71
62
|
this.#inflate[kLength] += data.length
|
|
72
63
|
|
|
73
|
-
if (this.#inflate[kLength] >
|
|
74
|
-
|
|
64
|
+
if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
|
|
65
|
+
callback(new MessageSizeExceededError())
|
|
75
66
|
this.#inflate.removeAllListeners()
|
|
76
|
-
this.#inflate.destroy()
|
|
77
67
|
this.#inflate = null
|
|
78
|
-
|
|
79
|
-
if (this.#currentCallback) {
|
|
80
|
-
const cb = this.#currentCallback
|
|
81
|
-
this.#currentCallback = null
|
|
82
|
-
cb(new MessageSizeExceededError())
|
|
83
|
-
}
|
|
84
68
|
return
|
|
85
69
|
}
|
|
86
70
|
|
|
@@ -93,14 +77,13 @@ class PerMessageDeflate {
|
|
|
93
77
|
})
|
|
94
78
|
}
|
|
95
79
|
|
|
96
|
-
this.#currentCallback = callback
|
|
97
80
|
this.#inflate.write(chunk)
|
|
98
81
|
if (fin) {
|
|
99
82
|
this.#inflate.write(tail)
|
|
100
83
|
}
|
|
101
84
|
|
|
102
85
|
this.#inflate.flush(() => {
|
|
103
|
-
if (
|
|
86
|
+
if (!this.#inflate) {
|
|
104
87
|
return
|
|
105
88
|
}
|
|
106
89
|
|
|
@@ -108,7 +91,6 @@ class PerMessageDeflate {
|
|
|
108
91
|
|
|
109
92
|
this.#inflate[kBuffer].length = 0
|
|
110
93
|
this.#inflate[kLength] = 0
|
|
111
|
-
this.#currentCallback = null
|
|
112
94
|
|
|
113
95
|
callback(null, full)
|
|
114
96
|
})
|
|
@@ -39,18 +39,23 @@ class ByteParser extends Writable {
|
|
|
39
39
|
/** @type {import('./websocket').Handler} */
|
|
40
40
|
#handler
|
|
41
41
|
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
#maxPayloadSize
|
|
44
|
+
|
|
42
45
|
/**
|
|
43
46
|
* @param {import('./websocket').Handler} handler
|
|
44
47
|
* @param {Map<string, string>|null} extensions
|
|
48
|
+
* @param {{ maxPayloadSize?: number }} [options]
|
|
45
49
|
*/
|
|
46
|
-
constructor (handler, extensions) {
|
|
50
|
+
constructor (handler, extensions, options = {}) {
|
|
47
51
|
super()
|
|
48
52
|
|
|
49
53
|
this.#handler = handler
|
|
50
54
|
this.#extensions = extensions == null ? new Map() : extensions
|
|
55
|
+
this.#maxPayloadSize = options.maxPayloadSize ?? 0
|
|
51
56
|
|
|
52
57
|
if (this.#extensions.has('permessage-deflate')) {
|
|
53
|
-
this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions))
|
|
58
|
+
this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions, options))
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -66,6 +71,19 @@ class ByteParser extends Writable {
|
|
|
66
71
|
this.run(callback)
|
|
67
72
|
}
|
|
68
73
|
|
|
74
|
+
#validatePayloadLength () {
|
|
75
|
+
if (
|
|
76
|
+
this.#maxPayloadSize > 0 &&
|
|
77
|
+
!isControlFrame(this.#info.opcode) &&
|
|
78
|
+
this.#info.payloadLength > this.#maxPayloadSize
|
|
79
|
+
) {
|
|
80
|
+
failWebsocketConnection(this.#handler, 1009, 'Payload size exceeds maximum allowed size')
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
86
|
+
|
|
69
87
|
/**
|
|
70
88
|
* Runs whenever a new chunk is received.
|
|
71
89
|
* Callback is called whenever there are no more chunks buffering,
|
|
@@ -154,6 +172,10 @@ class ByteParser extends Writable {
|
|
|
154
172
|
if (payloadLength <= 125) {
|
|
155
173
|
this.#info.payloadLength = payloadLength
|
|
156
174
|
this.#state = parserStates.READ_DATA
|
|
175
|
+
|
|
176
|
+
if (!this.#validatePayloadLength()) {
|
|
177
|
+
return
|
|
178
|
+
}
|
|
157
179
|
} else if (payloadLength === 126) {
|
|
158
180
|
this.#state = parserStates.PAYLOADLENGTH_16
|
|
159
181
|
} else if (payloadLength === 127) {
|
|
@@ -178,6 +200,10 @@ class ByteParser extends Writable {
|
|
|
178
200
|
|
|
179
201
|
this.#info.payloadLength = buffer.readUInt16BE(0)
|
|
180
202
|
this.#state = parserStates.READ_DATA
|
|
203
|
+
|
|
204
|
+
if (!this.#validatePayloadLength()) {
|
|
205
|
+
return
|
|
206
|
+
}
|
|
181
207
|
} else if (this.#state === parserStates.PAYLOADLENGTH_64) {
|
|
182
208
|
if (this.#byteOffset < 8) {
|
|
183
209
|
return callback()
|
|
@@ -200,6 +226,10 @@ class ByteParser extends Writable {
|
|
|
200
226
|
|
|
201
227
|
this.#info.payloadLength = lower
|
|
202
228
|
this.#state = parserStates.READ_DATA
|
|
229
|
+
|
|
230
|
+
if (!this.#validatePayloadLength()) {
|
|
231
|
+
return
|
|
232
|
+
}
|
|
203
233
|
} else if (this.#state === parserStates.READ_DATA) {
|
|
204
234
|
if (this.#byteOffset < this.#info.payloadLength) {
|
|
205
235
|
return callback()
|
|
@@ -224,29 +254,39 @@ class ByteParser extends Writable {
|
|
|
224
254
|
|
|
225
255
|
this.#state = parserStates.INFO
|
|
226
256
|
} else {
|
|
227
|
-
this.#extensions.get('permessage-deflate').decompress(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
257
|
+
this.#extensions.get('permessage-deflate').decompress(
|
|
258
|
+
body,
|
|
259
|
+
this.#info.fin,
|
|
260
|
+
(error, data) => {
|
|
261
|
+
if (error) {
|
|
262
|
+
const code = error instanceof MessageSizeExceededError ? 1009 : 1007
|
|
263
|
+
failWebsocketConnection(this.#handler, code, error.message)
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
this.writeFragments(data)
|
|
268
|
+
|
|
269
|
+
// Check cumulative fragment size
|
|
270
|
+
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
|
271
|
+
failWebsocketConnection(this.#handler, 1009, new MessageSizeExceededError().message)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (!this.#info.fin) {
|
|
276
|
+
this.#state = parserStates.INFO
|
|
277
|
+
this.#loop = true
|
|
278
|
+
this.run(callback)
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments())
|
|
236
283
|
|
|
237
|
-
if (!this.#info.fin) {
|
|
238
|
-
this.#state = parserStates.INFO
|
|
239
284
|
this.#loop = true
|
|
285
|
+
this.#state = parserStates.INFO
|
|
240
286
|
this.run(callback)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments())
|
|
245
|
-
|
|
246
|
-
this.#loop = true
|
|
247
|
-
this.#state = parserStates.INFO
|
|
248
|
-
this.run(callback)
|
|
249
|
-
})
|
|
287
|
+
},
|
|
288
|
+
this.#fragmentsBytes
|
|
289
|
+
)
|
|
250
290
|
|
|
251
291
|
this.#loop = false
|
|
252
292
|
break
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const { environmentSettingsObject } = require('../../fetch/util')
|
|
3
|
+
const { addAbortListener } = require('node:events')
|
|
4
|
+
const { environmentSettingsObject, readableStreamClose } = require('../../fetch/util')
|
|
5
5
|
const { states, opcodes, sentCloseFrameState } = require('../constants')
|
|
6
6
|
const { webidl } = require('../../webidl')
|
|
7
7
|
const { getURLRecord, isValidSubprotocol, isEstablished, utf8Decode } = require('../util')
|
|
@@ -21,11 +21,11 @@ class WebSocketStream {
|
|
|
21
21
|
#url
|
|
22
22
|
|
|
23
23
|
// Each WebSocketStream object has an associated opened promise , which is a promise.
|
|
24
|
-
/** @type {
|
|
24
|
+
/** @type {ReturnType<typeof Promise.withResolvers>} */
|
|
25
25
|
#openedPromise
|
|
26
26
|
|
|
27
27
|
// Each WebSocketStream object has an associated closed promise , which is a promise.
|
|
28
|
-
/** @type {
|
|
28
|
+
/** @type {ReturnType<typeof Promise.withResolvers>} */
|
|
29
29
|
#closedPromise
|
|
30
30
|
|
|
31
31
|
// Each WebSocketStream object has an associated readable stream , which is a ReadableStream .
|
|
@@ -113,8 +113,8 @@ class WebSocketStream {
|
|
|
113
113
|
this.#url = urlRecord.toString()
|
|
114
114
|
|
|
115
115
|
// 6. Set this 's opened promise and closed promise to new promises.
|
|
116
|
-
this.#openedPromise =
|
|
117
|
-
this.#closedPromise =
|
|
116
|
+
this.#openedPromise = Promise.withResolvers()
|
|
117
|
+
this.#closedPromise = Promise.withResolvers()
|
|
118
118
|
|
|
119
119
|
// 7. Apply backpressure to the WebSocket.
|
|
120
120
|
// TODO
|
|
@@ -133,7 +133,7 @@ class WebSocketStream {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
// 8.3. Add the following abort steps to signal :
|
|
136
|
-
signal
|
|
136
|
+
addAbortListener(signal, () => {
|
|
137
137
|
// 8.3.1. If the WebSocket connection is not yet established : [WSP]
|
|
138
138
|
if (!isEstablished(this.#handler.readyState)) {
|
|
139
139
|
// 8.3.1.1. Fail the WebSocket connection .
|
|
@@ -149,7 +149,7 @@ class WebSocketStream {
|
|
|
149
149
|
// Set this 's handshake aborted to true.
|
|
150
150
|
this.#handshakeAborted = true
|
|
151
151
|
}
|
|
152
|
-
}
|
|
152
|
+
})
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// 9. Let client be this 's relevant settings object .
|
|
@@ -202,7 +202,7 @@ class WebSocketStream {
|
|
|
202
202
|
chunk = webidl.converters.WebSocketStreamWrite(chunk)
|
|
203
203
|
|
|
204
204
|
// 1. Let promise be a new promise created in stream ’s relevant realm .
|
|
205
|
-
const promise =
|
|
205
|
+
const promise = Promise.withResolvers()
|
|
206
206
|
|
|
207
207
|
// 2. Let data be null.
|
|
208
208
|
let data = null
|
|
@@ -284,12 +284,6 @@ class WebSocketStream {
|
|
|
284
284
|
start: (controller) => {
|
|
285
285
|
this.#readableStreamController = controller
|
|
286
286
|
},
|
|
287
|
-
pull (controller) {
|
|
288
|
-
let chunk
|
|
289
|
-
while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) {
|
|
290
|
-
controller.enqueue(chunk)
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
287
|
cancel: (reason) => this.#cancel(reason)
|
|
294
288
|
})
|
|
295
289
|
|
|
@@ -338,7 +332,7 @@ class WebSocketStream {
|
|
|
338
332
|
try {
|
|
339
333
|
chunk = utf8Decode(data)
|
|
340
334
|
} catch {
|
|
341
|
-
failWebsocketConnection(this.#handler, 'Received invalid UTF-8 in text frame.')
|
|
335
|
+
failWebsocketConnection(this.#handler, 1007, 'Received invalid UTF-8 in text frame.')
|
|
342
336
|
return
|
|
343
337
|
}
|
|
344
338
|
} else if (type === opcodes.BINARY) {
|
|
@@ -392,7 +386,7 @@ class WebSocketStream {
|
|
|
392
386
|
// 6. If the connection was closed cleanly ,
|
|
393
387
|
if (wasClean) {
|
|
394
388
|
// 6.1. Close stream ’s readable stream .
|
|
395
|
-
this.#readableStreamController
|
|
389
|
+
readableStreamClose(this.#readableStreamController)
|
|
396
390
|
|
|
397
391
|
// 6.2. Error stream ’s writable stream with an " InvalidStateError " DOMException indicating that a closed WebSocketStream cannot be written to.
|
|
398
392
|
if (!this.#writableStream.locked) {
|
|
@@ -468,7 +468,12 @@ class WebSocket extends EventTarget {
|
|
|
468
468
|
// once this happens, the connection is open
|
|
469
469
|
this.#handler.socket = response.socket
|
|
470
470
|
|
|
471
|
-
|
|
471
|
+
// Get maxPayloadSize from dispatcher options
|
|
472
|
+
const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize
|
|
473
|
+
|
|
474
|
+
const parser = new ByteParser(this.#handler, parsedExtensions, {
|
|
475
|
+
maxPayloadSize
|
|
476
|
+
})
|
|
472
477
|
parser.on('drain', () => this.#handler.onParserDrain())
|
|
473
478
|
parser.on('error', (err) => this.#handler.onParserError(err))
|
|
474
479
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "undici",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
|
5
5
|
"homepage": "https://undici.nodejs.org",
|
|
6
6
|
"bugs": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"test:websocket:autobahn": "node test/autobahn/client.js",
|
|
98
98
|
"test:websocket:autobahn:report": "node test/autobahn/report.js",
|
|
99
99
|
"test:wpt:setup": "node test/web-platform-tests/wpt-runner.mjs setup",
|
|
100
|
-
"test:wpt": "npm run test:wpt:setup && node test/web-platform-tests/wpt-runner.mjs run /fetch /mimesniff /
|
|
100
|
+
"test:wpt": "npm run test:wpt:setup && node test/web-platform-tests/wpt-runner.mjs run /fetch /mimesniff /websockets /serviceWorkers /eventsource",
|
|
101
101
|
"test:cache-tests": "node test/cache-interceptor/cache-tests.mjs --ci",
|
|
102
102
|
"coverage": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report",
|
|
103
103
|
"coverage:ci": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report:ci",
|
|
@@ -113,27 +113,27 @@
|
|
|
113
113
|
"@matteo.collina/tspl": "^0.2.0",
|
|
114
114
|
"@metcoder95/https-pem": "^1.0.0",
|
|
115
115
|
"@sinonjs/fake-timers": "^12.0.0",
|
|
116
|
-
"@types/node": "^
|
|
116
|
+
"@types/node": "^22.0.0",
|
|
117
117
|
"abort-controller": "^3.0.0",
|
|
118
|
-
"borp": "^0.
|
|
119
|
-
"c8": "^
|
|
118
|
+
"borp": "^1.0.0",
|
|
119
|
+
"c8": "^11.0.0",
|
|
120
120
|
"cross-env": "^10.0.0",
|
|
121
121
|
"dns-packet": "^5.4.0",
|
|
122
|
-
"esbuild": "^0.
|
|
122
|
+
"esbuild": "^0.28.0",
|
|
123
123
|
"eslint": "^9.9.0",
|
|
124
124
|
"fast-check": "^4.1.1",
|
|
125
125
|
"husky": "^9.0.7",
|
|
126
126
|
"jest": "^30.0.5",
|
|
127
127
|
"jsondiffpatch": "^0.7.3",
|
|
128
|
-
"neostandard": "^0.
|
|
128
|
+
"neostandard": "^0.13.0",
|
|
129
129
|
"node-forge": "^1.3.1",
|
|
130
|
-
"proxy": "^
|
|
130
|
+
"proxy": "^4.0.0",
|
|
131
131
|
"tsd": "^0.33.0",
|
|
132
132
|
"typescript": "^6.0.2",
|
|
133
133
|
"ws": "^8.11.0"
|
|
134
134
|
},
|
|
135
135
|
"engines": {
|
|
136
|
-
"node": ">=
|
|
136
|
+
"node": ">=22.19.0"
|
|
137
137
|
},
|
|
138
138
|
"tsd": {
|
|
139
139
|
"directory": "test/types",
|
|
@@ -22,8 +22,6 @@ declare namespace Agent {
|
|
|
22
22
|
export interface Options extends Pool.Options {
|
|
23
23
|
/** Default: `(origin, opts) => new Pool(origin, opts)`. */
|
|
24
24
|
factory?(origin: string | URL, opts: Object): Dispatcher;
|
|
25
|
-
|
|
26
|
-
interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors']
|
|
27
25
|
maxOrigins?: number
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -3,7 +3,7 @@ import Dispatcher from './dispatcher'
|
|
|
3
3
|
import buildConnector from './connector'
|
|
4
4
|
import TClientStats from './client-stats'
|
|
5
5
|
|
|
6
|
-
type ClientConnectOptions = Omit<Dispatcher.ConnectOptions
|
|
6
|
+
type ClientConnectOptions<TOpaque = null> = Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin'>
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
|
|
@@ -20,22 +20,17 @@ export class Client extends Dispatcher {
|
|
|
20
20
|
readonly stats: TClientStats
|
|
21
21
|
|
|
22
22
|
// Override dispatcher APIs.
|
|
23
|
-
override connect (
|
|
24
|
-
options: ClientConnectOptions
|
|
25
|
-
): Promise<Dispatcher.ConnectData
|
|
26
|
-
override connect (
|
|
27
|
-
options: ClientConnectOptions
|
|
28
|
-
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
|
|
23
|
+
override connect<TOpaque = null> (
|
|
24
|
+
options: ClientConnectOptions<TOpaque>
|
|
25
|
+
): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
26
|
+
override connect<TOpaque = null> (
|
|
27
|
+
options: ClientConnectOptions<TOpaque>,
|
|
28
|
+
callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void
|
|
29
29
|
): void
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export declare namespace Client {
|
|
33
|
-
export interface OptionsInterceptors {
|
|
34
|
-
Client: readonly Dispatcher.DispatchInterceptor[];
|
|
35
|
-
}
|
|
36
33
|
export interface Options {
|
|
37
|
-
/** TODO */
|
|
38
|
-
interceptors?: OptionsInterceptors;
|
|
39
34
|
/** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
|
|
40
35
|
maxHeaderSize?: number;
|
|
41
36
|
/** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
|
|
@@ -44,7 +39,7 @@ export declare namespace Client {
|
|
|
44
39
|
socketTimeout?: never;
|
|
45
40
|
/** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
|
|
46
41
|
requestTimeout?: never;
|
|
47
|
-
/**
|
|
42
|
+
/** The timeout for establishing a socket connection, in milliseconds. Use `0` to disable it entirely. Default: `10e3` milliseconds (10s). */
|
|
48
43
|
connectTimeout?: number;
|
|
49
44
|
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
|
|
50
45
|
bodyTimeout?: number;
|
|
@@ -60,7 +55,7 @@ export declare namespace Client {
|
|
|
60
55
|
keepAliveMaxTimeout?: number;
|
|
61
56
|
/** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
|
|
62
57
|
keepAliveTimeoutThreshold?: number;
|
|
63
|
-
/**
|
|
58
|
+
/** An IPC endpoint, either a Unix domain socket or Windows named pipe. Default: `null`. */
|
|
64
59
|
socketPath?: string;
|
|
65
60
|
/** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
|
|
66
61
|
pipelining?: number;
|
|
@@ -68,23 +63,25 @@ export declare namespace Client {
|
|
|
68
63
|
tls?: never;
|
|
69
64
|
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
|
|
70
65
|
strictContentLength?: boolean;
|
|
71
|
-
/**
|
|
66
|
+
/** Maximum number of TLS cached sessions used by the built-in connector. Use `0` to disable TLS session caching. Default: `100`. */
|
|
72
67
|
maxCachedSessions?: number;
|
|
73
|
-
/**
|
|
68
|
+
/** Connector options passed to `buildConnector`, or a custom connector function. Default: `null`. */
|
|
74
69
|
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
|
|
75
|
-
/**
|
|
70
|
+
/** The maximum number of requests to send over a single connection before it is reset. Use `0` to disable this limit. Default: `null`. */
|
|
76
71
|
maxRequestsPerClient?: number;
|
|
77
|
-
/**
|
|
72
|
+
/** Local IP address the socket should connect from. */
|
|
78
73
|
localAddress?: string;
|
|
79
74
|
/** Max response body size in bytes, -1 is disabled */
|
|
80
75
|
maxResponseSize?: number;
|
|
76
|
+
/** WebSocket-specific options */
|
|
77
|
+
webSocket?: Client.WebSocketOptions;
|
|
81
78
|
/** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
|
|
82
79
|
autoSelectFamily?: boolean;
|
|
83
80
|
/** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
|
|
84
81
|
autoSelectFamilyAttemptTimeout?: number;
|
|
85
82
|
/**
|
|
86
83
|
* @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
|
|
87
|
-
* @default
|
|
84
|
+
* @default true
|
|
88
85
|
*/
|
|
89
86
|
allowH2?: boolean;
|
|
90
87
|
/**
|
|
@@ -118,6 +115,15 @@ export declare namespace Client {
|
|
|
118
115
|
bytesWritten?: number
|
|
119
116
|
bytesRead?: number
|
|
120
117
|
}
|
|
118
|
+
export interface WebSocketOptions {
|
|
119
|
+
/**
|
|
120
|
+
* Maximum allowed payload size in bytes for WebSocket messages.
|
|
121
|
+
* Applied to uncompressed messages, compressed frame payloads, and decompressed (permessage-deflate) messages.
|
|
122
|
+
* Set to 0 to disable the limit.
|
|
123
|
+
* @default 134217728 (128 MB)
|
|
124
|
+
*/
|
|
125
|
+
maxPayloadSize?: number;
|
|
126
|
+
}
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
export default Client
|
|
@@ -2,17 +2,15 @@ import { URL } from 'node:url'
|
|
|
2
2
|
import { Duplex, Readable, Writable } from 'node:stream'
|
|
3
3
|
import { EventEmitter } from 'node:events'
|
|
4
4
|
import { Blob } from 'node:buffer'
|
|
5
|
-
import { IncomingHttpHeaders } from './header'
|
|
5
|
+
import { IncomingHttpHeaders, OutgoingHttpHeaders } from './header'
|
|
6
6
|
import BodyReadable from './readable'
|
|
7
7
|
import { FormData } from './formdata'
|
|
8
8
|
import Errors from './errors'
|
|
9
9
|
import { Autocomplete } from './utility'
|
|
10
10
|
|
|
11
|
-
type AbortSignal = unknown
|
|
12
|
-
|
|
13
11
|
export default Dispatcher
|
|
14
12
|
|
|
15
|
-
export type UndiciHeaders =
|
|
13
|
+
export type UndiciHeaders = OutgoingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null
|
|
16
14
|
|
|
17
15
|
/** Dispatcher is the core API used to dispatch requests. */
|
|
18
16
|
declare class Dispatcher extends EventEmitter {
|
|
@@ -123,8 +121,6 @@ declare namespace Dispatcher {
|
|
|
123
121
|
bodyTimeout?: number | null;
|
|
124
122
|
/** Whether the request should stablish a keep-alive or not. Default `false` */
|
|
125
123
|
reset?: boolean;
|
|
126
|
-
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
|
|
127
|
-
throwOnError?: boolean;
|
|
128
124
|
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
|
|
129
125
|
expectContinue?: boolean;
|
|
130
126
|
}
|
|
@@ -212,6 +208,8 @@ declare namespace Dispatcher {
|
|
|
212
208
|
get aborted(): boolean
|
|
213
209
|
get paused(): boolean
|
|
214
210
|
get reason(): Error | null
|
|
211
|
+
rawHeaders?: Buffer[] | string[] | IncomingHttpHeaders | null
|
|
212
|
+
rawTrailers?: Buffer[] | string[] | IncomingHttpHeaders | null
|
|
215
213
|
abort(reason: Error): void
|
|
216
214
|
pause(): void
|
|
217
215
|
resume(): void
|
|
@@ -225,30 +223,12 @@ declare namespace Dispatcher {
|
|
|
225
223
|
onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
|
|
226
224
|
onResponseError?(controller: DispatchController, error: Error): void;
|
|
227
225
|
|
|
228
|
-
/** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
|
|
229
|
-
/** @deprecated */
|
|
230
|
-
onConnect?(abort: (err?: Error) => void): void;
|
|
231
|
-
/** Invoked when an error has occurred. */
|
|
232
|
-
/** @deprecated */
|
|
233
|
-
onError?(err: Error): void;
|
|
234
|
-
/** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
|
|
235
|
-
/** @deprecated */
|
|
236
|
-
onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
|
|
237
226
|
/** Invoked when response is received, before headers have been read. **/
|
|
238
|
-
/** @deprecated */
|
|
239
227
|
onResponseStarted?(): void;
|
|
240
|
-
/** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
|
|
241
|
-
/** @deprecated */
|
|
242
|
-
onHeaders?(statusCode: number, headers: Buffer[], resume: () => void, statusText: string): boolean;
|
|
243
|
-
/** Invoked when response payload data is received. */
|
|
244
|
-
/** @deprecated */
|
|
245
|
-
onData?(chunk: Buffer): boolean;
|
|
246
|
-
/** Invoked when response payload and trailers have been received and the request has completed. */
|
|
247
|
-
/** @deprecated */
|
|
248
|
-
onComplete?(trailers: string[] | null): void;
|
|
249
228
|
/** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
|
|
250
|
-
|
|
251
|
-
|
|
229
|
+
onBodySent?(chunk: Buffer): void;
|
|
230
|
+
/** Invoked after the request body is fully sent. */
|
|
231
|
+
onRequestSent?(): void;
|
|
252
232
|
}
|
|
253
233
|
export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable
|
|
254
234
|
export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>
|
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
import { File } from 'node:buffer'
|
|
5
5
|
import { SpecIterableIterator } from './fetch'
|
|
6
6
|
|
|
7
|
-
declare module 'node:buffer' {
|
|
8
|
-
interface File {
|
|
9
|
-
readonly [Symbol.toStringTag]: string
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
/**
|
|
14
8
|
* A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
|
|
15
9
|
*/
|
|
@@ -32,7 +32,7 @@ export declare namespace H2CClient {
|
|
|
32
32
|
maxHeaderSize?: number;
|
|
33
33
|
/** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
|
|
34
34
|
headersTimeout?: number;
|
|
35
|
-
/**
|
|
35
|
+
/** The timeout for establishing a socket connection, in milliseconds. Use `0` to disable it entirely. Default: `10e3` milliseconds (10s). */
|
|
36
36
|
connectTimeout?: number;
|
|
37
37
|
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
|
|
38
38
|
bodyTimeout?: number;
|
|
@@ -42,19 +42,19 @@ export declare namespace H2CClient {
|
|
|
42
42
|
keepAliveMaxTimeout?: number;
|
|
43
43
|
/** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
|
|
44
44
|
keepAliveTimeoutThreshold?: number;
|
|
45
|
-
/**
|
|
45
|
+
/** An IPC endpoint, either a Unix domain socket or Windows named pipe. Default: `null`. */
|
|
46
46
|
socketPath?: string;
|
|
47
47
|
/** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
|
|
48
48
|
pipelining?: number;
|
|
49
49
|
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
|
|
50
50
|
strictContentLength?: boolean;
|
|
51
|
-
/**
|
|
51
|
+
/** Maximum number of TLS cached sessions used by the built-in connector. Use `0` to disable TLS session caching. Default: `100`. */
|
|
52
52
|
maxCachedSessions?: number;
|
|
53
|
-
/**
|
|
53
|
+
/** Connector options passed to `buildConnector`, or a custom connector function. Default: `null`. */
|
|
54
54
|
connect?: Omit<Partial<buildConnector.BuildOptions>, 'allowH2'> | buildConnector.connector;
|
|
55
|
-
/**
|
|
55
|
+
/** The maximum number of requests to send over a single connection before it is reset. Use `0` to disable this limit. Default: `null`. */
|
|
56
56
|
maxRequestsPerClient?: number;
|
|
57
|
-
/**
|
|
57
|
+
/** Local IP address the socket should connect from. */
|
|
58
58
|
localAddress?: string;
|
|
59
59
|
/** Max response body size in bytes, -1 is disabled */
|
|
60
60
|
maxResponseSize?: number;
|
|
@@ -5,6 +5,11 @@ import { Autocomplete } from './utility'
|
|
|
5
5
|
*/
|
|
6
6
|
export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The header type declaration of `undici` for outgoing requests.
|
|
10
|
+
*/
|
|
11
|
+
export type OutgoingHttpHeaders = Record<string, number | string | string[] | undefined>
|
|
12
|
+
|
|
8
13
|
type HeaderNames = Autocomplete<
|
|
9
14
|
| 'Accept'
|
|
10
15
|
| 'Accept-CH'
|