@openclaw/slack 2026.9.8 → 2026.10.1-beta.2
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/.setup/{account-inspect-DWBXpER6.mjs → account-inspect-Cs-7DXXW.mjs} +1 -1
- package/dist/.setup/{accounts-D_N9IqNA.mjs → accounts-CDgkV7Cm.mjs} +4 -16
- package/dist/.setup/{action-runtime-DfWvuiZd.mjs → action-runtime-DJ1daRAZ.mjs} +5 -7
- package/dist/.setup/action-runtime.runtime-CdWL2mLC.mjs +2 -0
- package/dist/.setup/{actions-Df0CzcDl.mjs → actions-DDoAJnrH.mjs} +16 -35
- package/dist/.setup/{approval-handler.runtime-Ed6Sw5VK.mjs → approval-handler.runtime-BcE_shWc.mjs} +5 -5
- package/dist/.setup/{approval-message-updates-BadvtA7R.mjs → approval-message-updates-EgKGmFXx.mjs} +1 -1
- package/dist/.setup/{channel-C7bgPSTE.mjs → channel-DgKSu8Iv.mjs} +46 -48
- package/dist/.setup/{channel-type-ClOttrZ5.mjs → channel-type-B9zYYzBU.mjs} +4 -4
- package/dist/.setup/{channel.setup-Dh2jzAjN.mjs → channel.setup-BYIlwbQ7.mjs} +27 -27
- package/dist/.setup/{config-schema-BZCxmHKG.mjs → config-schema-BH0K9-Um.mjs} +4 -0
- package/dist/.setup/{directory-config-BOUWH3hR.mjs → directory-config-B_by7zrc.mjs} +2 -2
- package/dist/.setup/{directory-live-B2O4B_Ho.mjs → directory-live-C48wazJt.mjs} +3 -3
- package/dist/.setup/{doctor-contract-CRN1Z_c7.mjs → doctor-contract-Cd4-VzIM.mjs} +28 -28
- package/dist/.setup/{message-tool-api-Cu4lwlGy.mjs → message-tool-api-CcjLPN3v.mjs} +2 -2
- package/dist/.setup/{monitor-BPVfkumU.mjs → monitor-BuYBDmm7.mjs} +190 -315
- package/dist/.setup/{outbound-adapter-Bv48XUjq.mjs → outbound-adapter-BZFkK-mw.mjs} +6 -17
- package/dist/.setup/{pipeline.runtime-B1H63Frf.mjs → pipeline.runtime-CIepKmZt.mjs} +241 -247
- package/dist/.setup/{policy-D-jfM174.mjs → policy-KKTqEiDv.mjs} +12 -22
- package/dist/.setup/{probe-B2Y9qc_z.mjs → probe-BVlJ3dp0.mjs} +4 -7
- package/dist/.setup/{relay-source-BpKdjsll.mjs → relay-source-CC3h6M7y.mjs} +2 -2
- package/dist/.setup/{replies-BAnUtr2f.mjs → replies-DHbuthIR.mjs} +12 -26
- package/dist/.setup/{reply-blocks-SE1kTE3I.mjs → reply-blocks-CKnO4BSG.mjs} +4 -29
- package/dist/.setup/{resolve-channels-XXBn8UU_.mjs → resolve-channels-HR0TgArR.mjs} +2 -2
- package/dist/.setup/{resolve-users-DW0ngD03.mjs → resolve-users-BNYBhF0q.mjs} +4 -4
- package/dist/.setup/rolldown-runtime-B4FMCO8f.mjs +28 -0
- package/dist/.setup/{scopes-CasuDvaa.mjs → scopes-DrDbyUH2.mjs} +1 -1
- package/dist/.setup/secret-contract-B-Qm6aQQ.mjs +65 -0
- package/dist/.setup/{secret-contract-api-Dp6290Vg.mjs → secret-contract-api-DmUVxIRs.mjs} +1 -1
- package/dist/.setup/{security-audit-BqDc-6VL.mjs → security-audit-C1nOGzJa.mjs} +1 -1
- package/dist/.setup/{send-BOVLQi3n.mjs → send-CgPI3Zj8.mjs} +22 -53
- package/dist/.setup/{session-status-DscajIsd.mjs → session-status-D46GHwOV.mjs} +39 -49
- package/dist/.setup/{setup-plugin-api-DTtbTKNk.mjs → setup-plugin-api-ZrHs0N4U.mjs} +1 -1
- package/dist/.setup/{setup-surface-Dn7QgWRE.mjs → setup-surface-83lxvE2y.mjs} +10 -13
- package/dist/.setup/{shared-qau-uDGl.mjs → shared-VtmYNj-v.mjs} +53 -57
- package/dist/.setup/{slash-dispatch.runtime--AEzLVBF.mjs → slash-dispatch.runtime-gBj_uaLM.mjs} +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/api.js +13 -13
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/control-ui/2f4b1e827be6b68ced2ea0d8b7da8529a4eafbe72be27ee37e1064bdd530ec10/index.js +1 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/message-tool-api.js +1 -1
- package/dist/runtime-api.js +10 -10
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/setup-entry.js +2 -2
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/undici/README.md +10 -1
- package/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
- package/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +10 -0
- package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/undici/docs/docs/index.md +10 -1
- package/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/undici/lib/dispatcher/client.js +6 -1
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/undici/lib/web/fetch/index.js +46 -25
- package/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/undici/lib/web/websocket/connection.js +33 -12
- package/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/undici/lib/web/websocket/receiver.js +2 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
- package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
- package/node_modules/undici/types/interceptors.d.ts +1 -1
- package/node_modules/undici/types/webidl.d.ts +13 -7
- package/openclaw.plugin.json +4 -1
- package/package.json +14 -6
- package/dist/.setup/action-runtime.runtime-Ck4bAWOX.mjs +0 -2
- package/dist/.setup/secret-contract-BaZcu6P_.mjs +0 -82
- package/dist/.setup/streaming-compat-C5Wut626.mjs +0 -62
|
@@ -101,13 +101,13 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
101
101
|
// The presence of a session property on the socket indicates HTTP2
|
|
102
102
|
// HTTP1
|
|
103
103
|
if (response.socket?.session == null) {
|
|
104
|
-
|
|
104
|
+
failHandshake(handler, response, 1002, 'Received network error or non-101 status code.', response.error)
|
|
105
105
|
return
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// HTTP2
|
|
109
109
|
if (response.status !== 200) {
|
|
110
|
-
|
|
110
|
+
failHandshake(handler, response, 1002, 'Received network error or non-200 status code.', response.error)
|
|
111
111
|
return
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -122,7 +122,7 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
122
122
|
// header list results in null, failure, or the empty byte
|
|
123
123
|
// sequence, then fail the WebSocket connection.
|
|
124
124
|
if (protocols.length !== 0 && !response.headersList.get('Sec-WebSocket-Protocol')) {
|
|
125
|
-
|
|
125
|
+
failHandshake(handler, response, 1002, 'Server did not respond with sent protocols.')
|
|
126
126
|
return
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -138,7 +138,7 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
138
138
|
// _Fail the WebSocket Connection_.
|
|
139
139
|
// For H2, no upgrade header is expected.
|
|
140
140
|
if (response.socket.session == null && response.headersList.get('Upgrade')?.toLowerCase() !== 'websocket') {
|
|
141
|
-
|
|
141
|
+
failHandshake(handler, response, 1002, 'Server did not set Upgrade header to "websocket".')
|
|
142
142
|
return
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -148,7 +148,7 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
148
148
|
// MUST _Fail the WebSocket Connection_.
|
|
149
149
|
// For H2, no connection header is expected.
|
|
150
150
|
if (response.socket.session == null && response.headersList.get('Connection')?.toLowerCase() !== 'upgrade') {
|
|
151
|
-
|
|
151
|
+
failHandshake(handler, response, 1002, 'Server did not set Connection header to "upgrade".')
|
|
152
152
|
return
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -159,11 +159,15 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
159
159
|
// E914-47DA-95CA-C5AB0DC85B11" but ignoring any leading and
|
|
160
160
|
// trailing whitespace, the client MUST _Fail the WebSocket
|
|
161
161
|
// Connection_.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
// For H2, implementations "do not do the processing of the Sec-WebSocket-Key and
|
|
163
|
+
// Sec-WebSocket-Accept header fields". https://datatracker.ietf.org/doc/html/rfc8441#section-5
|
|
164
|
+
if (response.socket.session == null) {
|
|
165
|
+
const secWSAccept = response.headersList.get('Sec-WebSocket-Accept')
|
|
166
|
+
const digest = crypto.hash('sha1', keyValue + uid, 'base64')
|
|
167
|
+
if (secWSAccept !== digest) {
|
|
168
|
+
failHandshake(handler, response, 1002, 'Incorrect hash received in Sec-WebSocket-Accept header.')
|
|
169
|
+
return
|
|
170
|
+
}
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
// 5. If the response includes a |Sec-WebSocket-Extensions| header
|
|
@@ -180,7 +184,7 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
180
184
|
extensions = parseExtensions(secExtension)
|
|
181
185
|
|
|
182
186
|
if (!extensions.has('permessage-deflate')) {
|
|
183
|
-
|
|
187
|
+
failHandshake(handler, response, 1002, 'Sec-WebSocket-Extensions header does not match.')
|
|
184
188
|
return
|
|
185
189
|
}
|
|
186
190
|
}
|
|
@@ -201,11 +205,18 @@ function establishWebSocketConnection (url, protocols, client, handler, options)
|
|
|
201
205
|
// the selected subprotocol values in its response for the connection to
|
|
202
206
|
// be established.
|
|
203
207
|
if (requestProtocols === null || !requestProtocols.includes(secProtocol)) {
|
|
204
|
-
|
|
208
|
+
failHandshake(handler, response, 1002, 'Protocol was not set in the opening handshake.')
|
|
205
209
|
return
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
|
|
213
|
+
// For H2, "Orderly TCP-level closures are represented as END_STREAM flags", so
|
|
214
|
+
// end our side of the stream when the server ends its side, as a TCP socket would.
|
|
215
|
+
// https://datatracker.ietf.org/doc/html/rfc8441#section-5
|
|
216
|
+
if (response.socket.session != null) {
|
|
217
|
+
response.socket.allowHalfOpen = false
|
|
218
|
+
}
|
|
219
|
+
|
|
209
220
|
response.socket.on('data', handler.onSocketData)
|
|
210
221
|
response.socket.on('close', handler.onSocketClose)
|
|
211
222
|
response.socket.on('error', handler.onSocketError)
|
|
@@ -296,6 +307,16 @@ function closeWebSocketConnection (object, code, reason, validate = false) {
|
|
|
296
307
|
}
|
|
297
308
|
}
|
|
298
309
|
|
|
310
|
+
function failHandshake (handler, response, code, reason, cause) {
|
|
311
|
+
// The H2 upgrade request has already completed and handed off its stream.
|
|
312
|
+
// Aborting the request cannot close that stream after handshake validation fails.
|
|
313
|
+
if (response.socket?.session != null && !response.socket.destroyed) {
|
|
314
|
+
response.socket.destroy()
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
failWebsocketConnection(handler, code, reason, cause)
|
|
318
|
+
}
|
|
319
|
+
|
|
299
320
|
/**
|
|
300
321
|
* @param {import('./websocket').Handler} handler
|
|
301
322
|
* @param {number} code
|
|
@@ -4,6 +4,8 @@ const { webidl } = require('../webidl')
|
|
|
4
4
|
const { kEnumerableProperty } = require('../../core/util')
|
|
5
5
|
const { kConstruct } = require('../../core/symbols')
|
|
6
6
|
|
|
7
|
+
let createFastMessageEvent
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @see https://html.spec.whatwg.org/multipage/comms.html#messageevent
|
|
9
11
|
*/
|
|
@@ -30,31 +32,31 @@ class MessageEvent extends Event {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
get data () {
|
|
33
|
-
webidl.brandCheck(this, MessageEvent)
|
|
35
|
+
webidl.brandCheck(this, webidl.is.MessageEvent)
|
|
34
36
|
|
|
35
37
|
return this.#eventInit.data
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
get origin () {
|
|
39
|
-
webidl.brandCheck(this, MessageEvent)
|
|
41
|
+
webidl.brandCheck(this, webidl.is.MessageEvent)
|
|
40
42
|
|
|
41
43
|
return this.#eventInit.origin
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
get lastEventId () {
|
|
45
|
-
webidl.brandCheck(this, MessageEvent)
|
|
47
|
+
webidl.brandCheck(this, webidl.is.MessageEvent)
|
|
46
48
|
|
|
47
49
|
return this.#eventInit.lastEventId
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
get source () {
|
|
51
|
-
webidl.brandCheck(this, MessageEvent)
|
|
53
|
+
webidl.brandCheck(this, webidl.is.MessageEvent)
|
|
52
54
|
|
|
53
55
|
return this.#eventInit.source
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
get ports () {
|
|
57
|
-
webidl.brandCheck(this, MessageEvent)
|
|
59
|
+
webidl.brandCheck(this, webidl.is.MessageEvent)
|
|
58
60
|
|
|
59
61
|
if (!Object.isFrozen(this.#eventInit.ports)) {
|
|
60
62
|
Object.freeze(this.#eventInit.ports)
|
|
@@ -73,7 +75,7 @@ class MessageEvent extends Event {
|
|
|
73
75
|
source = null,
|
|
74
76
|
ports = []
|
|
75
77
|
) {
|
|
76
|
-
webidl.brandCheck(this, MessageEvent)
|
|
78
|
+
webidl.brandCheck(this, webidl.is.MessageEvent)
|
|
77
79
|
|
|
78
80
|
webidl.argumentLengthCheck(arguments, 1, 'MessageEvent.initMessageEvent')
|
|
79
81
|
|
|
@@ -82,21 +84,24 @@ class MessageEvent extends Event {
|
|
|
82
84
|
})
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
static
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
static {
|
|
88
|
+
createFastMessageEvent = (type, init) => {
|
|
89
|
+
const messageEvent = new MessageEvent(kConstruct, type, init)
|
|
90
|
+
messageEvent.#eventInit = init
|
|
91
|
+
messageEvent.#eventInit.data ??= null
|
|
92
|
+
messageEvent.#eventInit.origin ??= ''
|
|
93
|
+
messageEvent.#eventInit.lastEventId ??= ''
|
|
94
|
+
messageEvent.#eventInit.source ??= null
|
|
95
|
+
messageEvent.#eventInit.ports ??= []
|
|
96
|
+
return messageEvent
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
webidl.is.MessageEvent = (arg) => {
|
|
100
|
+
return arg != null && typeof arg === 'object' && #eventInit in arg
|
|
101
|
+
}
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
|
|
97
|
-
const { createFastMessageEvent } = MessageEvent
|
|
98
|
-
delete MessageEvent.createFastMessageEvent
|
|
99
|
-
|
|
100
105
|
/**
|
|
101
106
|
* @see https://websockets.spec.whatwg.org/#the-closeevent-interface
|
|
102
107
|
*/
|
|
@@ -117,22 +122,28 @@ class CloseEvent extends Event {
|
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
get wasClean () {
|
|
120
|
-
webidl.brandCheck(this, CloseEvent)
|
|
125
|
+
webidl.brandCheck(this, webidl.is.CloseEvent)
|
|
121
126
|
|
|
122
127
|
return this.#eventInit.wasClean
|
|
123
128
|
}
|
|
124
129
|
|
|
125
130
|
get code () {
|
|
126
|
-
webidl.brandCheck(this, CloseEvent)
|
|
131
|
+
webidl.brandCheck(this, webidl.is.CloseEvent)
|
|
127
132
|
|
|
128
133
|
return this.#eventInit.code
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
get reason () {
|
|
132
|
-
webidl.brandCheck(this, CloseEvent)
|
|
137
|
+
webidl.brandCheck(this, webidl.is.CloseEvent)
|
|
133
138
|
|
|
134
139
|
return this.#eventInit.reason
|
|
135
140
|
}
|
|
141
|
+
|
|
142
|
+
static {
|
|
143
|
+
webidl.is.CloseEvent = (arg) => {
|
|
144
|
+
return arg != null && typeof arg === 'object' && #eventInit in arg
|
|
145
|
+
}
|
|
146
|
+
}
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
// https://html.spec.whatwg.org/multipage/webappapis.html#the-errorevent-interface
|
|
@@ -153,34 +164,40 @@ class ErrorEvent extends Event {
|
|
|
153
164
|
}
|
|
154
165
|
|
|
155
166
|
get message () {
|
|
156
|
-
webidl.brandCheck(this, ErrorEvent)
|
|
167
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent)
|
|
157
168
|
|
|
158
169
|
return this.#eventInit.message
|
|
159
170
|
}
|
|
160
171
|
|
|
161
172
|
get filename () {
|
|
162
|
-
webidl.brandCheck(this, ErrorEvent)
|
|
173
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent)
|
|
163
174
|
|
|
164
175
|
return this.#eventInit.filename
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
get lineno () {
|
|
168
|
-
webidl.brandCheck(this, ErrorEvent)
|
|
179
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent)
|
|
169
180
|
|
|
170
181
|
return this.#eventInit.lineno
|
|
171
182
|
}
|
|
172
183
|
|
|
173
184
|
get colno () {
|
|
174
|
-
webidl.brandCheck(this, ErrorEvent)
|
|
185
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent)
|
|
175
186
|
|
|
176
187
|
return this.#eventInit.colno
|
|
177
188
|
}
|
|
178
189
|
|
|
179
190
|
get error () {
|
|
180
|
-
webidl.brandCheck(this, ErrorEvent)
|
|
191
|
+
webidl.brandCheck(this, webidl.is.ErrorEvent)
|
|
181
192
|
|
|
182
193
|
return this.#eventInit.error
|
|
183
194
|
}
|
|
195
|
+
|
|
196
|
+
static {
|
|
197
|
+
webidl.is.ErrorEvent = (arg) => {
|
|
198
|
+
return arg != null && typeof arg === 'object' && #eventInit in arg
|
|
199
|
+
}
|
|
200
|
+
}
|
|
184
201
|
}
|
|
185
202
|
|
|
186
203
|
Object.defineProperties(MessageEvent.prototype, {
|
|
@@ -26,6 +26,8 @@ function createInheritableDOMException () {
|
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
let createUnvalidatedWebSocketError
|
|
30
|
+
|
|
29
31
|
class WebSocketError extends createInheritableDOMException() {
|
|
30
32
|
#closeCode
|
|
31
33
|
#reason
|
|
@@ -77,17 +79,20 @@ class WebSocketError extends createInheritableDOMException() {
|
|
|
77
79
|
* @param {number|null} code
|
|
78
80
|
* @param {string} reason
|
|
79
81
|
*/
|
|
80
|
-
static
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
static {
|
|
83
|
+
createUnvalidatedWebSocketError = (message, code, reason) => {
|
|
84
|
+
const error = new WebSocketError(message, kConstruct)
|
|
85
|
+
error.#closeCode = code
|
|
86
|
+
error.#reason = reason
|
|
87
|
+
return error
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
webidl.is.WebSocketError = (arg) => {
|
|
91
|
+
return arg != null && typeof arg === 'object' && #reason in arg
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
|
|
88
|
-
const { createUnvalidatedWebSocketError } = WebSocketError
|
|
89
|
-
delete WebSocketError.createUnvalidatedWebSocketError
|
|
90
|
-
|
|
91
96
|
Object.defineProperties(WebSocketError.prototype, {
|
|
92
97
|
closeCode: kEnumerableProperty,
|
|
93
98
|
reason: kEnumerableProperty,
|
|
@@ -99,6 +104,4 @@ Object.defineProperties(WebSocketError.prototype, {
|
|
|
99
104
|
}
|
|
100
105
|
})
|
|
101
106
|
|
|
102
|
-
webidl.is.WebSocketError = webidl.util.MakeTypeAssertion(WebSocketError)
|
|
103
|
-
|
|
104
107
|
module.exports = { WebSocketError, createUnvalidatedWebSocketError }
|
|
@@ -62,7 +62,9 @@ class WebSocketStream {
|
|
|
62
62
|
|
|
63
63
|
this.#handler.socket.destroy()
|
|
64
64
|
},
|
|
65
|
-
|
|
65
|
+
// When the WebSocket connection is closed for a WebSocketStream stream, possibly cleanly, the user agent must
|
|
66
|
+
// queue a global task on the WebSocket task source given stream ’s relevant global object to run the following substeps:
|
|
67
|
+
onSocketClose: () => queueMicrotask(() => this.#onSocketClose()),
|
|
66
68
|
onPing: () => {},
|
|
67
69
|
onPong: () => {},
|
|
68
70
|
|
|
@@ -246,11 +248,15 @@ class WebSocketStream {
|
|
|
246
248
|
const frame = new WebsocketFrameSend(data)
|
|
247
249
|
|
|
248
250
|
this.#handler.socket.write(frame.createFrame(opcode), () => {
|
|
251
|
+
// 6.3. Queue a global task on the WebSocket task source given stream ’s relevant global object to resolve promise with undefined.
|
|
249
252
|
promise.resolve(undefined)
|
|
250
253
|
})
|
|
254
|
+
} else {
|
|
255
|
+
// 6.3. Queue a global task on the WebSocket task source given stream ’s relevant global object to resolve promise with undefined.
|
|
256
|
+
promise.resolve(undefined)
|
|
251
257
|
}
|
|
252
258
|
|
|
253
|
-
//
|
|
259
|
+
// 7. Return promise.
|
|
254
260
|
return promise.promise
|
|
255
261
|
}
|
|
256
262
|
|
|
@@ -278,7 +284,7 @@ class WebSocketStream {
|
|
|
278
284
|
// This is done in the opening handshake.
|
|
279
285
|
|
|
280
286
|
// 3. Let extensions be the extensions in use .
|
|
281
|
-
const extensions =
|
|
287
|
+
const extensions = response.headersList.get('sec-websocket-extensions') ?? ''
|
|
282
288
|
|
|
283
289
|
// 4. Let protocol be the subprotocol in use .
|
|
284
290
|
const protocol = response.headersList.get('sec-websocket-protocol') ?? ''
|
|
@@ -291,6 +297,7 @@ class WebSocketStream {
|
|
|
291
297
|
start: (controller) => {
|
|
292
298
|
this.#readableStreamController = controller
|
|
293
299
|
},
|
|
300
|
+
pull: () => this.#pull(),
|
|
294
301
|
cancel: (reason) => this.#cancel(reason)
|
|
295
302
|
})
|
|
296
303
|
|
|
@@ -350,6 +357,9 @@ class WebSocketStream {
|
|
|
350
357
|
this.#readableStreamController.enqueue(chunk)
|
|
351
358
|
|
|
352
359
|
// 4. Apply backpressure to the WebSocket.
|
|
360
|
+
if (this.#readableStreamController.desiredSize <= 0) {
|
|
361
|
+
this.#handler.socket.pause()
|
|
362
|
+
}
|
|
353
363
|
}
|
|
354
364
|
|
|
355
365
|
/** @type {import('../websocket').Handler['onSocketClose']} */
|
|
@@ -383,7 +393,7 @@ class WebSocketStream {
|
|
|
383
393
|
// 1006.
|
|
384
394
|
let code = result?.code ?? 1005
|
|
385
395
|
|
|
386
|
-
if (!this.#handler.closeState.has(sentCloseFrameState.
|
|
396
|
+
if (!this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
387
397
|
code = 1006
|
|
388
398
|
}
|
|
389
399
|
|
|
@@ -441,6 +451,11 @@ class WebSocketStream {
|
|
|
441
451
|
closeWebSocketConnection(this.#handler, code, reasonString)
|
|
442
452
|
}
|
|
443
453
|
|
|
454
|
+
// To pull bytes from a WebSocketStream stream , if stream is currently applying backpressure, release backpressure.
|
|
455
|
+
#pull () {
|
|
456
|
+
this.#handler.socket.resume()
|
|
457
|
+
}
|
|
458
|
+
|
|
444
459
|
// To cancel a WebSocketStream stream given reason , close using reason giving stream and reason .
|
|
445
460
|
#cancel (reason) {
|
|
446
461
|
this.#closeUsingReason(reason)
|
|
@@ -28,6 +28,8 @@ const { channels } = require('../../core/diagnostics')
|
|
|
28
28
|
const kRef = Symbol.for('nodejs.ref')
|
|
29
29
|
const kUnref = Symbol.for('nodejs.unref')
|
|
30
30
|
|
|
31
|
+
let ping
|
|
32
|
+
|
|
31
33
|
function getSocketAddress (socket) {
|
|
32
34
|
if (typeof socket?.address === 'function') {
|
|
33
35
|
return socket.address()
|
|
@@ -198,16 +200,14 @@ class WebSocket extends EventTarget {
|
|
|
198
200
|
this.#binaryType = 'blob'
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
// TODO: remove this
|
|
201
204
|
[kRef] () {
|
|
202
|
-
webidl.brandCheck(this, WebSocket)
|
|
203
|
-
|
|
204
205
|
this.#refed = true
|
|
205
206
|
this.#handler.socket?.ref?.()
|
|
206
207
|
}
|
|
207
208
|
|
|
209
|
+
// TODO: remove this
|
|
208
210
|
[kUnref] () {
|
|
209
|
-
webidl.brandCheck(this, WebSocket)
|
|
210
|
-
|
|
211
211
|
this.#refed = false
|
|
212
212
|
this.#handler.socket?.unref?.()
|
|
213
213
|
}
|
|
@@ -218,7 +218,7 @@ class WebSocket extends EventTarget {
|
|
|
218
218
|
* @param {string|undefined} reason
|
|
219
219
|
*/
|
|
220
220
|
close (code = undefined, reason = undefined) {
|
|
221
|
-
webidl.brandCheck(this, WebSocket)
|
|
221
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
222
222
|
|
|
223
223
|
const prefix = 'WebSocket.close'
|
|
224
224
|
|
|
@@ -245,7 +245,7 @@ class WebSocket extends EventTarget {
|
|
|
245
245
|
* @param {NodeJS.TypedArray|ArrayBuffer|Blob|string} data
|
|
246
246
|
*/
|
|
247
247
|
send (data) {
|
|
248
|
-
webidl.brandCheck(this, WebSocket)
|
|
248
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
249
249
|
|
|
250
250
|
const prefix = 'WebSocket.send'
|
|
251
251
|
webidl.argumentLengthCheck(arguments, 1, prefix)
|
|
@@ -339,45 +339,45 @@ class WebSocket extends EventTarget {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
get readyState () {
|
|
342
|
-
webidl.brandCheck(this, WebSocket)
|
|
342
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
343
343
|
|
|
344
344
|
// The readyState getter steps are to return this's ready state.
|
|
345
345
|
return this.#handler.readyState
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
get bufferedAmount () {
|
|
349
|
-
webidl.brandCheck(this, WebSocket)
|
|
349
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
350
350
|
|
|
351
351
|
return this.#bufferedAmount
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
get url () {
|
|
355
|
-
webidl.brandCheck(this, WebSocket)
|
|
355
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
356
356
|
|
|
357
357
|
// The url getter steps are to return this's url, serialized.
|
|
358
358
|
return URLSerializer(this.#url)
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
get extensions () {
|
|
362
|
-
webidl.brandCheck(this, WebSocket)
|
|
362
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
363
363
|
|
|
364
364
|
return this.#extensions
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
get protocol () {
|
|
368
|
-
webidl.brandCheck(this, WebSocket)
|
|
368
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
369
369
|
|
|
370
370
|
return this.#protocol
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
get onopen () {
|
|
374
|
-
webidl.brandCheck(this, WebSocket)
|
|
374
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
375
375
|
|
|
376
376
|
return this.#events.open
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
set onopen (fn) {
|
|
380
|
-
webidl.brandCheck(this, WebSocket)
|
|
380
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
381
381
|
|
|
382
382
|
if (this.#events.open) {
|
|
383
383
|
this.removeEventListener('open', this.#events.open)
|
|
@@ -394,13 +394,13 @@ class WebSocket extends EventTarget {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
get onerror () {
|
|
397
|
-
webidl.brandCheck(this, WebSocket)
|
|
397
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
398
398
|
|
|
399
399
|
return this.#events.error
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
set onerror (fn) {
|
|
403
|
-
webidl.brandCheck(this, WebSocket)
|
|
403
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
404
404
|
|
|
405
405
|
if (this.#events.error) {
|
|
406
406
|
this.removeEventListener('error', this.#events.error)
|
|
@@ -417,13 +417,13 @@ class WebSocket extends EventTarget {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
get onclose () {
|
|
420
|
-
webidl.brandCheck(this, WebSocket)
|
|
420
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
421
421
|
|
|
422
422
|
return this.#events.close
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
set onclose (fn) {
|
|
426
|
-
webidl.brandCheck(this, WebSocket)
|
|
426
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
427
427
|
|
|
428
428
|
if (this.#events.close) {
|
|
429
429
|
this.removeEventListener('close', this.#events.close)
|
|
@@ -440,13 +440,13 @@ class WebSocket extends EventTarget {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
get onmessage () {
|
|
443
|
-
webidl.brandCheck(this, WebSocket)
|
|
443
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
444
444
|
|
|
445
445
|
return this.#events.message
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
set onmessage (fn) {
|
|
449
|
-
webidl.brandCheck(this, WebSocket)
|
|
449
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
450
450
|
|
|
451
451
|
if (this.#events.message) {
|
|
452
452
|
this.removeEventListener('message', this.#events.message)
|
|
@@ -463,13 +463,13 @@ class WebSocket extends EventTarget {
|
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
get binaryType () {
|
|
466
|
-
webidl.brandCheck(this, WebSocket)
|
|
466
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
467
467
|
|
|
468
468
|
return this.#binaryType
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
set binaryType (type) {
|
|
472
|
-
webidl.brandCheck(this, WebSocket)
|
|
472
|
+
webidl.brandCheck(this, webidl.is.WebSocket)
|
|
473
473
|
|
|
474
474
|
if (type !== 'blob' && type !== 'arraybuffer') {
|
|
475
475
|
this.#binaryType = 'blob'
|
|
@@ -654,33 +654,36 @@ class WebSocket extends EventTarget {
|
|
|
654
654
|
}
|
|
655
655
|
}
|
|
656
656
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (buffer
|
|
664
|
-
|
|
657
|
+
static {
|
|
658
|
+
/**
|
|
659
|
+
* @param {WebSocket} ws
|
|
660
|
+
* @param {Buffer|undefined} buffer
|
|
661
|
+
*/
|
|
662
|
+
ping = (ws, buffer) => {
|
|
663
|
+
if (Buffer.isBuffer(buffer)) {
|
|
664
|
+
if (buffer.length > 125) {
|
|
665
|
+
throw new TypeError('A PING frame cannot have a body larger than 125 bytes.')
|
|
666
|
+
}
|
|
667
|
+
} else if (buffer !== undefined) {
|
|
668
|
+
throw new TypeError('Expected buffer payload')
|
|
665
669
|
}
|
|
666
|
-
} else if (buffer !== undefined) {
|
|
667
|
-
throw new TypeError('Expected buffer payload')
|
|
668
|
-
}
|
|
669
670
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
671
|
+
// An endpoint MAY send a Ping frame any time after the connection is
|
|
672
|
+
// established and before the connection is closed.
|
|
673
|
+
const readyState = ws.#handler.readyState
|
|
673
674
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
675
|
+
if (isEstablished(readyState) && !isClosing(readyState) && !isClosed(readyState)) {
|
|
676
|
+
const frame = new WebsocketFrameSend(buffer)
|
|
677
|
+
ws.#handler.socket.write(frame.createFrame(opcodes.PING))
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
webidl.is.WebSocket = (arg) => {
|
|
682
|
+
return arg != null && typeof arg === 'object' && #handler in arg
|
|
677
683
|
}
|
|
678
684
|
}
|
|
679
685
|
}
|
|
680
686
|
|
|
681
|
-
const { ping } = WebSocket
|
|
682
|
-
Reflect.deleteProperty(WebSocket, 'ping')
|
|
683
|
-
|
|
684
687
|
// https://websockets.spec.whatwg.org/#dom-websocket-connecting
|
|
685
688
|
WebSocket.CONNECTING = WebSocket.prototype.CONNECTING = states.CONNECTING
|
|
686
689
|
// https://websockets.spec.whatwg.org/#dom-websocket-open
|
|
@@ -2,6 +2,7 @@ import { Socket } from 'node:net'
|
|
|
2
2
|
import { URL } from 'node:url'
|
|
3
3
|
import buildConnector from './connector'
|
|
4
4
|
import Dispatcher from './dispatcher'
|
|
5
|
+
import { IncomingHttpHeaders } from './header'
|
|
5
6
|
|
|
6
7
|
declare namespace DiagnosticsChannel {
|
|
7
8
|
interface Request {
|
|
@@ -14,7 +15,7 @@ declare namespace DiagnosticsChannel {
|
|
|
14
15
|
interface Response {
|
|
15
16
|
statusCode: number;
|
|
16
17
|
statusText: string;
|
|
17
|
-
headers: Array<Buffer
|
|
18
|
+
headers: Array<Buffer> | IncomingHttpHeaders;
|
|
18
19
|
}
|
|
19
20
|
interface ConnectParams {
|
|
20
21
|
host: URL['host'];
|
|
@@ -12,7 +12,7 @@ declare namespace Interceptors {
|
|
|
12
12
|
export type DecompressInterceptorOpts = {
|
|
13
13
|
skipErrorResponses?: boolean
|
|
14
14
|
skipStatusCodes?: number[]
|
|
15
|
-
/** Maximum decompressed response size in bytes. @default
|
|
15
|
+
/** Maximum decompressed response size in bytes per stage. 0 disables the limit. @default 0 */
|
|
16
16
|
maxSize?: number
|
|
17
17
|
}
|
|
18
18
|
|