@openclaw/discord 2026.9.7 → 2026.10.1-beta.1
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/README.md +7 -0
- package/dist/.setup/{account-inspect-De8hOUxG.mjs → account-inspect-CjKqkDnH.mjs} +2 -2
- package/dist/.setup/{accounts-ChaMcixG.mjs → accounts-DXHCL8Zm.mjs} +9 -32
- package/dist/.setup/{active-turn-thread-route-fmHl1HNd.mjs → active-turn-thread-route-C4tp9noA.mjs} +5 -9
- package/dist/.setup/{activities-api-tvbsU2e3.mjs → activities-api-BL_hJ0JQ.mjs} +15 -18
- package/dist/.setup/{api-DVbJwZVt.mjs → api-_oznjffB.mjs} +1 -1
- package/dist/.setup/{approval-handler.runtime-DxCK2Rux.mjs → approval-handler.runtime-G-tMI_uD.mjs} +22 -61
- package/dist/.setup/{approval-message-updates-BKFqavHZ.mjs → approval-message-updates-CgRwc2_Q.mjs} +2 -2
- package/dist/.setup/{audit-CLg9I71N.mjs → audit-DtvzxONM.mjs} +4 -4
- package/dist/.setup/{channel-DxlUVU9t.mjs → channel-Ct3fRxet.mjs} +79 -75
- package/dist/.setup/{channel-access-C12aDZ0p.mjs → channel-access-BRp3Y-rF.mjs} +4 -17
- package/dist/.setup/{channel-type-DRCrEMss.mjs → channel-type-D1_b5UhU.mjs} +12 -16
- package/dist/.setup/{channel.setup-CRo1GjV7.mjs → channel.setup-DBJtugJO.mjs} +14 -34
- package/dist/.setup/{components-Cq1PvIpN.mjs → components-CzXLR3QH.mjs} +56 -72
- package/dist/.setup/{config-schema-oxELUSDx.mjs → config-schema-CsemBDpS.mjs} +6 -17
- package/dist/.setup/{conversation-binding-route-Caz_XuFH.mjs → conversation-binding-route-Bi62ApSt.mjs} +1 -1
- package/dist/.setup/{directory-config-esqNn0Eo.mjs → directory-config-BH1LA-gi.mjs} +1 -1
- package/dist/.setup/{directory-live-DtKRHuGV.mjs → directory-live-C9xz7IPm.mjs} +10 -13
- package/dist/.setup/{discord-0xJYfdDD.mjs → discord-J7aRzq2Q.mjs} +101 -381
- package/dist/.setup/{doctor-BCl1H5tl.mjs → doctor-DxSAngJq.mjs} +31 -70
- package/dist/.setup/doctor-contract-Bg3NPAMw.mjs +137 -0
- package/dist/.setup/{handle-action-CUvQWnE7.mjs → handle-action-DlmFX-_G.mjs} +10 -11
- package/dist/.setup/{handle-action.guild-admin-Df-8gVle.mjs → handle-action.guild-admin-BnyqTczR.mjs} +67 -129
- package/dist/.setup/{live-policy-config-8Pv20CHc.mjs → live-policy-config-emmPNyh4.mjs} +1 -1
- package/dist/.setup/{message-handler-B-Jk4oDk.mjs → message-handler-CDWDjWF0.mjs} +6 -6
- package/dist/.setup/{message-handler.preflight-v-__NSDq.mjs → message-handler.preflight-Cop4atEb.mjs} +13 -23
- package/dist/.setup/{message-handler.preflight-pluralkit-CWLUBVcx.mjs → message-handler.preflight-pluralkit-D1g3eq0B.mjs} +5 -8
- package/dist/.setup/{message-handler.process-BNFFuChn.mjs → message-handler.process-lX7pDqsd.mjs} +57 -96
- package/dist/.setup/{outbound-adapter-BobT-kse.mjs → outbound-adapter-BPq0c2wY.mjs} +11 -17
- package/dist/.setup/{outbound-session-route-zVGxxceg.mjs → outbound-session-route-DGPPKA0z.mjs} +21 -46
- package/dist/.setup/{presence-cache-Di3H3DIU.mjs → presence-cache-Dg3_dADn.mjs} +2 -4
- package/dist/.setup/{probe-LYrIHlBF.mjs → probe-DIRY8vh7.mjs} +17 -27
- package/dist/.setup/{provider-B_G5hASF.mjs → provider-DIexE7gK.mjs} +273 -446
- package/dist/.setup/{provider-session.runtime-BYlTBFD2.mjs → provider-session.runtime-C2UCZz8d.mjs} +3 -3
- package/dist/.setup/provider.runtime-Dkzrmmcm.mjs +2 -0
- package/dist/.setup/{realtime-session.runtime-oUd9DOcz.mjs → realtime-session.runtime-DvjyeY87.mjs} +6 -8
- package/dist/.setup/{receive-recovery-CHPOsnLc.mjs → receive-recovery-GqF2PUN_.mjs} +1 -4
- package/dist/.setup/{resolve-allowlist-common-DPdRggu5.mjs → resolve-allowlist-common-DUYRrrVB.mjs} +5 -9
- package/dist/.setup/{resolve-channels-BFPNRmVv.mjs → resolve-channels--MUatisx.mjs} +3 -3
- package/dist/.setup/{resolve-users-0-aBuCy3.mjs → resolve-users-CxLcDmM0.mjs} +6 -9
- package/dist/.setup/{retry-pz_cSha2.mjs → retry-BKzO25k4.mjs} +27 -51
- package/dist/.setup/{runtime-sUksZ--Q.mjs → runtime-CerRBfaa.mjs} +2 -2
- package/dist/.setup/{runtime-FN000lxA.mjs → runtime-CwUA0RLr.mjs} +228 -255
- package/dist/.setup/{runtime-doctor-migrations-CshUGl36.mjs → runtime-doctor-migrations-BPV-R4G9.mjs} +6 -0
- package/dist/.setup/{security-audit-Cdaegq7C.mjs → security-audit-D42cp5N7.mjs} +21 -48
- package/dist/.setup/{send-CrfEI6Bs.mjs → send-2X7m2Zmw.mjs} +45 -58
- package/dist/.setup/{send.components-DxQAMfES.mjs → send.components-RqvgmCs3.mjs} +44 -90
- package/dist/.setup/{send.outbound-BISKnb-a.mjs → send.outbound-B4QHSEzm.mjs} +60 -98
- package/dist/.setup/{send.shared-DGFkbkQR.mjs → send.shared-BQIUh6Vn.mjs} +13 -20
- package/dist/.setup/{sender-identity-B9X5Vb9R.mjs → sender-identity-CooeYfAn.mjs} +1 -1
- package/dist/.setup/{session-key-normalization-wJgsKPNF.mjs → session-key-normalization-CCHGNSQw.mjs} +3 -9
- package/dist/.setup/setup-plugin-api-nn_giXvZ.mjs +3 -0
- package/dist/.setup/{shared-B3wZ4hN-.mjs → shared-CIJn6AEC.mjs} +7 -7
- package/dist/.setup/{subagent-hooks-nlUE9ow7.mjs → subagent-hooks-BYlVnxzy.mjs} +4 -9
- package/dist/.setup/{system-events-CdeZnvPV.mjs → system-events-CQ3if_pS.mjs} +2 -2
- package/dist/.setup/{target-resolver-BuLapkhy.mjs → target-resolver-Dzxf80Y3.mjs} +5 -13
- package/dist/.setup/targets-Lf8D55w-.mjs +3 -0
- package/dist/.setup/{thread-bindings-D7TfgjR_.mjs → thread-bindings-yNNlcUWE.mjs} +5 -6
- package/dist/.setup/{thread-bindings.manager-DN-NissX.mjs → thread-bindings.manager-plk0zJAW.mjs} +14 -20
- package/dist/.setup/{thread-bindings.session-updates-CshfKghV.mjs → thread-bindings.session-updates-C9aKtVs6.mjs} +295 -5
- package/dist/.setup/{timeouts-D86uWLt_.mjs → timeouts-pun7VJ02.mjs} +2 -15
- package/dist/.setup/{transcripts-source-p8EV179h.mjs → transcripts-source-CNWswry-.mjs} +31 -79
- package/dist/.setup/typing-CNlSKY5S.mjs +11 -0
- package/dist/.setup/{voice-runtime-B46rcwrG.mjs → voice-runtime-CeS6zfY3.mjs} +62 -110
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +1 -1
- package/dist/api.js +18 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +1 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +19 -128
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +20 -21
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/src/voice/audio-worker.runtime.js +6 -8
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/libopus-wasm/CHANGELOG.md +8 -0
- package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/discordjs.js +14 -2
- package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
- package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/index.js +55 -100
- package/node_modules/libopus-wasm/package.json +5 -5
- 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 +6 -0
- package/package.json +12 -7
- package/dist/.setup/doctor-contract-CvvgwrrG.mjs +0 -409
- package/dist/.setup/model-picker-preference-primitives-BHT1LkR_.mjs +0 -37
- package/dist/.setup/provider.runtime-CUE3UxER.mjs +0 -2
- package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +0 -3
- package/dist/.setup/targets-0KUcEIYx.mjs +0 -3
- package/dist/.setup/thread-bindings.state-g6v9zAym.mjs +0 -331
- package/dist/.setup/typing-BiHCzBRu.mjs +0 -15
|
@@ -23,6 +23,7 @@ const assert = require('node:assert')
|
|
|
23
23
|
const { isomorphicEncode, serializeJavascriptValueToJSONString } = require('../infra')
|
|
24
24
|
|
|
25
25
|
const textEncoder = new TextEncoder('utf-8')
|
|
26
|
+
let getResponseHeaders, setResponseHeaders, getResponseState, setResponseState
|
|
26
27
|
|
|
27
28
|
// https://fetch.spec.whatwg.org/#response-class
|
|
28
29
|
class Response {
|
|
@@ -145,7 +146,7 @@ class Response {
|
|
|
145
146
|
|
|
146
147
|
// Returns response’s type, e.g., "cors".
|
|
147
148
|
get type () {
|
|
148
|
-
webidl.brandCheck(this, Response)
|
|
149
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
149
150
|
|
|
150
151
|
// The type getter steps are to return this’s response’s type.
|
|
151
152
|
return this.#state.type
|
|
@@ -153,7 +154,7 @@ class Response {
|
|
|
153
154
|
|
|
154
155
|
// Returns response’s URL, if it has one; otherwise the empty string.
|
|
155
156
|
get url () {
|
|
156
|
-
webidl.brandCheck(this, Response)
|
|
157
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
157
158
|
|
|
158
159
|
const urlList = this.#state.urlList
|
|
159
160
|
|
|
@@ -171,7 +172,7 @@ class Response {
|
|
|
171
172
|
|
|
172
173
|
// Returns whether response was obtained through a redirect.
|
|
173
174
|
get redirected () {
|
|
174
|
-
webidl.brandCheck(this, Response)
|
|
175
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
175
176
|
|
|
176
177
|
// The redirected getter steps are to return true if this’s response’s URL
|
|
177
178
|
// list has more than one item; otherwise false.
|
|
@@ -180,7 +181,7 @@ class Response {
|
|
|
180
181
|
|
|
181
182
|
// Returns response’s status.
|
|
182
183
|
get status () {
|
|
183
|
-
webidl.brandCheck(this, Response)
|
|
184
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
184
185
|
|
|
185
186
|
// The status getter steps are to return this’s response’s status.
|
|
186
187
|
return this.#state.status
|
|
@@ -188,7 +189,7 @@ class Response {
|
|
|
188
189
|
|
|
189
190
|
// Returns whether response’s status is an ok status.
|
|
190
191
|
get ok () {
|
|
191
|
-
webidl.brandCheck(this, Response)
|
|
192
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
192
193
|
|
|
193
194
|
// The ok getter steps are to return true if this’s response’s status is an
|
|
194
195
|
// ok status; otherwise false.
|
|
@@ -197,7 +198,7 @@ class Response {
|
|
|
197
198
|
|
|
198
199
|
// Returns response’s status message.
|
|
199
200
|
get statusText () {
|
|
200
|
-
webidl.brandCheck(this, Response)
|
|
201
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
201
202
|
|
|
202
203
|
// The statusText getter steps are to return this’s response’s status
|
|
203
204
|
// message.
|
|
@@ -206,27 +207,27 @@ class Response {
|
|
|
206
207
|
|
|
207
208
|
// Returns response’s headers as Headers.
|
|
208
209
|
get headers () {
|
|
209
|
-
webidl.brandCheck(this, Response)
|
|
210
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
210
211
|
|
|
211
212
|
// The headers getter steps are to return this’s headers.
|
|
212
213
|
return this.#headers
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
get body () {
|
|
216
|
-
webidl.brandCheck(this, Response)
|
|
217
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
217
218
|
|
|
218
219
|
return this.#state.body ? this.#state.body.stream : null
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
get bodyUsed () {
|
|
222
|
-
webidl.brandCheck(this, Response)
|
|
223
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
223
224
|
|
|
224
225
|
return !!this.#state.body && util.isDisturbed(this.#state.body.stream)
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
// Returns a clone of response.
|
|
228
229
|
clone () {
|
|
229
|
-
webidl.brandCheck(this, Response)
|
|
230
|
+
webidl.brandCheck(this, webidl.is.Response)
|
|
230
231
|
|
|
231
232
|
// 1. If this is unusable, then throw a TypeError.
|
|
232
233
|
if (bodyUnusable(this.#state)) {
|
|
@@ -272,44 +273,44 @@ class Response {
|
|
|
272
273
|
return `Response ${nodeUtil.formatWithOptions(options, properties)}`
|
|
273
274
|
}
|
|
274
275
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
static {
|
|
277
|
+
/**
|
|
278
|
+
* @param {Response} response
|
|
279
|
+
*/
|
|
280
|
+
getResponseHeaders = (response) => {
|
|
281
|
+
return response.#headers
|
|
282
|
+
}
|
|
281
283
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
284
|
+
/**
|
|
285
|
+
* @param {Response} response
|
|
286
|
+
* @param {Headers} newHeaders
|
|
287
|
+
*/
|
|
288
|
+
setResponseHeaders = (response, newHeaders) => {
|
|
289
|
+
response.#headers = newHeaders
|
|
290
|
+
}
|
|
289
291
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
/**
|
|
293
|
+
* @param {Response} response
|
|
294
|
+
*/
|
|
295
|
+
getResponseState = (response) => {
|
|
296
|
+
return response.#state
|
|
297
|
+
}
|
|
296
298
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
/**
|
|
300
|
+
* @param {Response} response
|
|
301
|
+
* @param {any} newState
|
|
302
|
+
*/
|
|
303
|
+
setResponseState = (response, newState) => {
|
|
304
|
+
response.#state = newState
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
webidl.is.Response = (arg) => {
|
|
308
|
+
return arg != null && typeof arg === 'object' && #state in arg
|
|
309
|
+
}
|
|
303
310
|
}
|
|
304
311
|
}
|
|
305
312
|
|
|
306
|
-
|
|
307
|
-
Reflect.deleteProperty(Response, 'getResponseHeaders')
|
|
308
|
-
Reflect.deleteProperty(Response, 'setResponseHeaders')
|
|
309
|
-
Reflect.deleteProperty(Response, 'getResponseState')
|
|
310
|
-
Reflect.deleteProperty(Response, 'setResponseState')
|
|
311
|
-
|
|
312
|
-
mixinBody(Response, getResponseState)
|
|
313
|
+
mixinBody(Response, getResponseState, webidl.is.Response)
|
|
313
314
|
|
|
314
315
|
Object.defineProperties(Response.prototype, {
|
|
315
316
|
type: kEnumerableProperty,
|
|
@@ -624,8 +625,6 @@ webidl.converters.ResponseInit = webidl.dictionaryConverter([
|
|
|
624
625
|
}
|
|
625
626
|
])
|
|
626
627
|
|
|
627
|
-
webidl.is.Response = webidl.util.MakeTypeAssertion(Response)
|
|
628
|
-
|
|
629
628
|
module.exports = {
|
|
630
629
|
isNetworkError,
|
|
631
630
|
makeNetworkError,
|
|
@@ -6,7 +6,7 @@ const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = require('./cons
|
|
|
6
6
|
const { getGlobalOrigin } = require('./global')
|
|
7
7
|
const { collectAnHTTPQuotedString, parseMIMEType } = require('./data-url')
|
|
8
8
|
const { performance } = require('node:perf_hooks')
|
|
9
|
-
const {
|
|
9
|
+
const { isValidHTTPToken, normalizedMethodRecordsBase } = require('../../core/util')
|
|
10
10
|
const assert = require('node:assert')
|
|
11
11
|
const { isUint8Array } = require('node:util/types')
|
|
12
12
|
const { webidl } = require('../webidl')
|
|
@@ -872,8 +872,9 @@ function createIterator (name, kInternalIterator, keyIndex = 0, valueIndex = 1)
|
|
|
872
872
|
* @param {(target: any) => any} kInternalIterator
|
|
873
873
|
* @param {string | number} [keyIndex]
|
|
874
874
|
* @param {string | number} [valueIndex]
|
|
875
|
+
* @param {import('../../../types/webidl').WebidlIsFunction} brandCheck
|
|
875
876
|
*/
|
|
876
|
-
function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueIndex = 1) {
|
|
877
|
+
function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueIndex = 1, brandCheck) {
|
|
877
878
|
const makeIterator = createIterator(name, kInternalIterator, keyIndex, valueIndex)
|
|
878
879
|
|
|
879
880
|
const properties = {
|
|
@@ -882,7 +883,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde
|
|
|
882
883
|
enumerable: true,
|
|
883
884
|
configurable: true,
|
|
884
885
|
value: function keys () {
|
|
885
|
-
webidl.brandCheck(this,
|
|
886
|
+
webidl.brandCheck(this, brandCheck)
|
|
886
887
|
return makeIterator(this, 'key')
|
|
887
888
|
}
|
|
888
889
|
},
|
|
@@ -891,7 +892,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde
|
|
|
891
892
|
enumerable: true,
|
|
892
893
|
configurable: true,
|
|
893
894
|
value: function values () {
|
|
894
|
-
webidl.brandCheck(this,
|
|
895
|
+
webidl.brandCheck(this, brandCheck)
|
|
895
896
|
return makeIterator(this, 'value')
|
|
896
897
|
}
|
|
897
898
|
},
|
|
@@ -900,7 +901,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde
|
|
|
900
901
|
enumerable: true,
|
|
901
902
|
configurable: true,
|
|
902
903
|
value: function entries () {
|
|
903
|
-
webidl.brandCheck(this,
|
|
904
|
+
webidl.brandCheck(this, brandCheck)
|
|
904
905
|
return makeIterator(this, 'key+value')
|
|
905
906
|
}
|
|
906
907
|
},
|
|
@@ -909,7 +910,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde
|
|
|
909
910
|
enumerable: true,
|
|
910
911
|
configurable: true,
|
|
911
912
|
value: function forEach (callbackfn, thisArg = globalThis) {
|
|
912
|
-
webidl.brandCheck(this,
|
|
913
|
+
webidl.brandCheck(this, brandCheck)
|
|
913
914
|
webidl.argumentLengthCheck(arguments, 1, `${name}.forEach`)
|
|
914
915
|
if (typeof callbackfn !== 'function') {
|
|
915
916
|
throw new TypeError(
|
|
@@ -1483,7 +1484,6 @@ module.exports = {
|
|
|
1483
1484
|
isAborted,
|
|
1484
1485
|
isCancelled,
|
|
1485
1486
|
isValidEncodedURL,
|
|
1486
|
-
ReadableStreamFrom,
|
|
1487
1487
|
tryUpgradeRequestToAPotentiallyTrustworthyURL,
|
|
1488
1488
|
clampAndCoarsenConnectionTimingInfo,
|
|
1489
1489
|
coarsenedSharedCurrentTime,
|
|
@@ -156,6 +156,20 @@ function isomorphicEncode (input) {
|
|
|
156
156
|
return input
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
const nonASCIIRegex = /[^\x00-\x7F]/ // eslint-disable-line no-control-regex
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @param {string} str
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*
|
|
165
|
+
* @see https://infra.spec.whatwg.org/#ascii-lowercase
|
|
166
|
+
*/
|
|
167
|
+
function asciiLowercase (str) {
|
|
168
|
+
return nonASCIIRegex.test(str)
|
|
169
|
+
? str.replace(/[A-Z]+/g, (upper) => upper.toLowerCase())
|
|
170
|
+
: str.toLowerCase()
|
|
171
|
+
}
|
|
172
|
+
|
|
159
173
|
/**
|
|
160
174
|
* @see https://infra.spec.whatwg.org/#parse-json-bytes-to-a-javascript-value
|
|
161
175
|
* @param {Uint8Array} bytes
|
|
@@ -192,7 +206,7 @@ function removeChars (str, leading, trailing, predicate) {
|
|
|
192
206
|
}
|
|
193
207
|
|
|
194
208
|
if (trailing) {
|
|
195
|
-
while (trail
|
|
209
|
+
while (trail >= lead && predicate(str.charCodeAt(trail))) trail--
|
|
196
210
|
}
|
|
197
211
|
|
|
198
212
|
return lead === 0 && trail === str.length - 1 ? str : str.slice(lead, trail + 1)
|
|
@@ -216,6 +230,7 @@ function serializeJavascriptValueToJSONString (value) {
|
|
|
216
230
|
}
|
|
217
231
|
|
|
218
232
|
module.exports = {
|
|
233
|
+
asciiLowercase,
|
|
219
234
|
collectASequenceOfCodePoints,
|
|
220
235
|
collectASequenceOfCodePointsFast,
|
|
221
236
|
forgivingBase64,
|
|
@@ -73,26 +73,14 @@ webidl.errors.invalidArgument = function (context) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// https://webidl.spec.whatwg.org/#implements
|
|
76
|
-
webidl.brandCheck = function (V,
|
|
77
|
-
if (!
|
|
76
|
+
webidl.brandCheck = function (V, is) {
|
|
77
|
+
if (!is(V)) {
|
|
78
78
|
const err = new TypeError('Illegal invocation')
|
|
79
79
|
err.code = 'ERR_INVALID_THIS' // node compat.
|
|
80
80
|
throw err
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
webidl.brandCheckMultiple = function (List) {
|
|
85
|
-
const prototypes = List.map((c) => webidl.util.MakeTypeAssertion(c))
|
|
86
|
-
|
|
87
|
-
return (V) => {
|
|
88
|
-
if (prototypes.every(typeCheck => !typeCheck(V))) {
|
|
89
|
-
const err = new TypeError('Illegal invocation')
|
|
90
|
-
err.code = 'ERR_INVALID_THIS' // node compat.
|
|
91
|
-
throw err
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
84
|
webidl.argumentLengthCheck = function ({ length }, min, ctx) {
|
|
97
85
|
if (length < min) {
|
|
98
86
|
throw webidl.errors.exception({
|
|
@@ -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 }
|