@openclaw/discord 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.
Files changed (147) hide show
  1. package/README.md +7 -0
  2. package/dist/.setup/{account-inspect-De8hOUxG.mjs → account-inspect-CjKqkDnH.mjs} +2 -2
  3. package/dist/.setup/{accounts-ChaMcixG.mjs → accounts-DXHCL8Zm.mjs} +9 -32
  4. package/dist/.setup/{active-turn-thread-route-fmHl1HNd.mjs → active-turn-thread-route-C4tp9noA.mjs} +5 -9
  5. package/dist/.setup/{activities-api-tvbsU2e3.mjs → activities-api-BL_hJ0JQ.mjs} +15 -18
  6. package/dist/.setup/{api-DVbJwZVt.mjs → api-_oznjffB.mjs} +1 -1
  7. package/dist/.setup/{approval-handler.runtime-DxCK2Rux.mjs → approval-handler.runtime-BilYSrRF.mjs} +22 -61
  8. package/dist/.setup/{approval-message-updates-BKFqavHZ.mjs → approval-message-updates-CgRwc2_Q.mjs} +2 -2
  9. package/dist/.setup/{audit-CLg9I71N.mjs → audit-DtvzxONM.mjs} +4 -4
  10. package/dist/.setup/{channel-access-C12aDZ0p.mjs → channel-access-BRp3Y-rF.mjs} +4 -17
  11. package/dist/.setup/{channel-type-DRCrEMss.mjs → channel-type-D1_b5UhU.mjs} +12 -16
  12. package/dist/.setup/{channel-DxlUVU9t.mjs → channel-z5lQMS_9.mjs} +79 -75
  13. package/dist/.setup/{channel.setup-CRo1GjV7.mjs → channel.setup-DBJtugJO.mjs} +14 -34
  14. package/dist/.setup/{components-Cq1PvIpN.mjs → components-CzXLR3QH.mjs} +56 -72
  15. package/dist/.setup/{config-schema-oxELUSDx.mjs → config-schema-CsemBDpS.mjs} +6 -17
  16. package/dist/.setup/{conversation-binding-route-Caz_XuFH.mjs → conversation-binding-route-Bi62ApSt.mjs} +1 -1
  17. package/dist/.setup/{directory-config-esqNn0Eo.mjs → directory-config-BH1LA-gi.mjs} +1 -1
  18. package/dist/.setup/{directory-live-DtKRHuGV.mjs → directory-live-C9xz7IPm.mjs} +10 -13
  19. package/dist/.setup/{discord-0xJYfdDD.mjs → discord-J7aRzq2Q.mjs} +101 -381
  20. package/dist/.setup/{doctor-BCl1H5tl.mjs → doctor-DxSAngJq.mjs} +31 -70
  21. package/dist/.setup/doctor-contract-Bg3NPAMw.mjs +137 -0
  22. package/dist/.setup/{handle-action-CUvQWnE7.mjs → handle-action-DlmFX-_G.mjs} +10 -11
  23. package/dist/.setup/{handle-action.guild-admin-Df-8gVle.mjs → handle-action.guild-admin-BnyqTczR.mjs} +67 -129
  24. package/dist/.setup/{live-policy-config-8Pv20CHc.mjs → live-policy-config-emmPNyh4.mjs} +1 -1
  25. package/dist/.setup/{message-handler-B-Jk4oDk.mjs → message-handler-BNToPZrx.mjs} +7 -6
  26. package/dist/.setup/{message-handler.preflight-v-__NSDq.mjs → message-handler.preflight-D0BcCyI7.mjs} +13 -23
  27. package/dist/.setup/{message-handler.preflight-pluralkit-CWLUBVcx.mjs → message-handler.preflight-pluralkit-D1g3eq0B.mjs} +5 -8
  28. package/dist/.setup/{message-handler.process-BNFFuChn.mjs → message-handler.process-CThRmCWK.mjs} +57 -96
  29. package/dist/.setup/{outbound-adapter-BobT-kse.mjs → outbound-adapter-BPq0c2wY.mjs} +11 -17
  30. package/dist/.setup/{outbound-session-route-zVGxxceg.mjs → outbound-session-route-DGPPKA0z.mjs} +21 -46
  31. package/dist/.setup/{presence-cache-Di3H3DIU.mjs → presence-cache-Dg3_dADn.mjs} +2 -4
  32. package/dist/.setup/{probe-LYrIHlBF.mjs → probe-DIRY8vh7.mjs} +17 -27
  33. package/dist/.setup/{provider-B_G5hASF.mjs → provider-D2OKMo0f.mjs} +273 -446
  34. package/dist/.setup/{provider-session.runtime-BYlTBFD2.mjs → provider-session.runtime-BupCTZQv.mjs} +3 -3
  35. package/dist/.setup/provider.runtime-BaW_JnfU.mjs +2 -0
  36. package/dist/.setup/{realtime-session.runtime-oUd9DOcz.mjs → realtime-session.runtime-D5RSC8Mm.mjs} +6 -8
  37. package/dist/.setup/{receive-recovery-CHPOsnLc.mjs → receive-recovery-GqF2PUN_.mjs} +1 -4
  38. package/dist/.setup/{resolve-allowlist-common-DPdRggu5.mjs → resolve-allowlist-common-DUYRrrVB.mjs} +5 -9
  39. package/dist/.setup/{resolve-channels-BFPNRmVv.mjs → resolve-channels--MUatisx.mjs} +3 -3
  40. package/dist/.setup/{resolve-users-0-aBuCy3.mjs → resolve-users-CxLcDmM0.mjs} +6 -9
  41. package/dist/.setup/{retry-pz_cSha2.mjs → retry-BKzO25k4.mjs} +27 -51
  42. package/dist/.setup/{runtime-sUksZ--Q.mjs → runtime-CerRBfaa.mjs} +2 -2
  43. package/dist/.setup/{runtime-FN000lxA.mjs → runtime-CwUA0RLr.mjs} +228 -255
  44. package/dist/.setup/{runtime-doctor-migrations-CshUGl36.mjs → runtime-doctor-migrations-BPV-R4G9.mjs} +6 -0
  45. package/dist/.setup/{security-audit-Cdaegq7C.mjs → security-audit-D42cp5N7.mjs} +21 -48
  46. package/dist/.setup/{send-CrfEI6Bs.mjs → send-2X7m2Zmw.mjs} +45 -58
  47. package/dist/.setup/{send.components-DxQAMfES.mjs → send.components-RqvgmCs3.mjs} +44 -90
  48. package/dist/.setup/{send.outbound-BISKnb-a.mjs → send.outbound-B4QHSEzm.mjs} +60 -98
  49. package/dist/.setup/{send.shared-DGFkbkQR.mjs → send.shared-BQIUh6Vn.mjs} +13 -20
  50. package/dist/.setup/{sender-identity-B9X5Vb9R.mjs → sender-identity-CooeYfAn.mjs} +1 -1
  51. package/dist/.setup/{session-key-normalization-wJgsKPNF.mjs → session-key-normalization-CCHGNSQw.mjs} +3 -9
  52. package/dist/.setup/setup-plugin-api-nn_giXvZ.mjs +3 -0
  53. package/dist/.setup/{shared-B3wZ4hN-.mjs → shared-CIJn6AEC.mjs} +7 -7
  54. package/dist/.setup/{subagent-hooks-nlUE9ow7.mjs → subagent-hooks-BYlVnxzy.mjs} +4 -9
  55. package/dist/.setup/{system-events-CdeZnvPV.mjs → system-events-CQ3if_pS.mjs} +2 -2
  56. package/dist/.setup/{target-resolver-BuLapkhy.mjs → target-resolver-Dzxf80Y3.mjs} +5 -13
  57. package/dist/.setup/targets-Lf8D55w-.mjs +3 -0
  58. package/dist/.setup/{thread-bindings-D7TfgjR_.mjs → thread-bindings-yNNlcUWE.mjs} +5 -6
  59. package/dist/.setup/{thread-bindings.manager-DN-NissX.mjs → thread-bindings.manager-plk0zJAW.mjs} +14 -20
  60. package/dist/.setup/{thread-bindings.session-updates-CshfKghV.mjs → thread-bindings.session-updates-C9aKtVs6.mjs} +295 -5
  61. package/dist/.setup/{timeouts-D86uWLt_.mjs → timeouts-pun7VJ02.mjs} +2 -15
  62. package/dist/.setup/{transcripts-source-p8EV179h.mjs → transcripts-source-CNWswry-.mjs} +31 -79
  63. package/dist/.setup/typing-CNlSKY5S.mjs +11 -0
  64. package/dist/.setup/{voice-runtime-B46rcwrG.mjs → voice-runtime-Bc75quiH.mjs} +62 -110
  65. package/dist/account-inspect-api.js +1 -1
  66. package/dist/action-runtime-api.js +1 -1
  67. package/dist/activities-api.js +1 -1
  68. package/dist/api.js +18 -18
  69. package/dist/channel-config-api.js +1 -1
  70. package/dist/channel-plugin-api.js +1 -1
  71. package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +1 -0
  72. package/dist/directory-contract-api.js +1 -1
  73. package/dist/doctor-contract-api.js +19 -128
  74. package/dist/index.js +1 -1
  75. package/dist/runtime-api.js +20 -21
  76. package/dist/security-audit-contract-api.js +1 -1
  77. package/dist/session-key-api.js +1 -1
  78. package/dist/setup-entry.js +1 -1
  79. package/dist/setup-plugin-api.js +1 -1
  80. package/dist/src/voice/audio-worker.runtime.js +6 -8
  81. package/dist/subagent-hooks-api.js +1 -1
  82. package/dist/transcripts-source-api.js +1 -1
  83. package/node_modules/libopus-wasm/CHANGELOG.md +8 -0
  84. package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
  85. package/node_modules/libopus-wasm/dist/discordjs.js +14 -2
  86. package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
  87. package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
  88. package/node_modules/libopus-wasm/dist/index.js +55 -100
  89. package/node_modules/libopus-wasm/package.json +5 -5
  90. package/node_modules/undici/README.md +10 -1
  91. package/node_modules/undici/docs/docs/api/Agent.md +8 -8
  92. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
  93. package/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
  94. package/node_modules/undici/docs/docs/api/Errors.md +25 -0
  95. package/node_modules/undici/docs/docs/api/Fetch.md +10 -0
  96. package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
  97. package/node_modules/undici/docs/docs/api/Pool.md +5 -6
  98. package/node_modules/undici/docs/docs/index.md +10 -1
  99. package/node_modules/undici/lib/api/readable.js +1 -2
  100. package/node_modules/undici/lib/core/request.js +23 -2
  101. package/node_modules/undici/lib/core/util.js +0 -39
  102. package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
  103. package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
  104. package/node_modules/undici/lib/dispatcher/client.js +6 -1
  105. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
  106. package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
  107. package/node_modules/undici/lib/dispatcher/pool.js +90 -7
  108. package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
  109. package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
  110. package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
  111. package/node_modules/undici/lib/handler/retry-handler.js +72 -13
  112. package/node_modules/undici/lib/interceptor/cache.js +4 -1
  113. package/node_modules/undici/lib/interceptor/decompress.js +236 -69
  114. package/node_modules/undici/lib/web/cache/cache.js +17 -8
  115. package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
  116. package/node_modules/undici/lib/web/cookies/index.js +19 -7
  117. package/node_modules/undici/lib/web/cookies/util.js +3 -1
  118. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
  119. package/node_modules/undici/lib/web/fetch/body.js +22 -15
  120. package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
  121. package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
  122. package/node_modules/undici/lib/web/fetch/headers.js +34 -31
  123. package/node_modules/undici/lib/web/fetch/index.js +46 -25
  124. package/node_modules/undici/lib/web/fetch/request.js +74 -79
  125. package/node_modules/undici/lib/web/fetch/response.js +43 -44
  126. package/node_modules/undici/lib/web/fetch/util.js +7 -7
  127. package/node_modules/undici/lib/web/infra/index.js +16 -1
  128. package/node_modules/undici/lib/web/webidl/index.js +2 -14
  129. package/node_modules/undici/lib/web/websocket/connection.js +33 -12
  130. package/node_modules/undici/lib/web/websocket/events.js +43 -26
  131. package/node_modules/undici/lib/web/websocket/receiver.js +2 -0
  132. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
  133. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
  134. package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
  135. package/node_modules/undici/package.json +1 -1
  136. package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
  137. package/node_modules/undici/types/interceptors.d.ts +1 -1
  138. package/node_modules/undici/types/webidl.d.ts +13 -7
  139. package/openclaw.plugin.json +6 -0
  140. package/package.json +12 -7
  141. package/dist/.setup/doctor-contract-CvvgwrrG.mjs +0 -409
  142. package/dist/.setup/model-picker-preference-primitives-BHT1LkR_.mjs +0 -37
  143. package/dist/.setup/provider.runtime-CUE3UxER.mjs +0 -2
  144. package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +0 -3
  145. package/dist/.setup/targets-0KUcEIYx.mjs +0 -3
  146. package/dist/.setup/thread-bindings.state-g6v9zAym.mjs +0 -331
  147. package/dist/.setup/typing-BiHCzBRu.mjs +0 -15
@@ -41,7 +41,7 @@ class Cache {
41
41
  }
42
42
 
43
43
  async match (request, options = {}) {
44
- webidl.brandCheck(this, Cache)
44
+ webidl.brandCheck(this, webidl.is.Cache)
45
45
 
46
46
  const prefix = 'Cache.match'
47
47
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -59,7 +59,7 @@ class Cache {
59
59
  }
60
60
 
61
61
  async matchAll (request = undefined, options = {}) {
62
- webidl.brandCheck(this, Cache)
62
+ webidl.brandCheck(this, webidl.is.Cache)
63
63
 
64
64
  const prefix = 'Cache.matchAll'
65
65
  if (request !== undefined) request = webidl.converters.RequestInfo(request)
@@ -69,7 +69,7 @@ class Cache {
69
69
  }
70
70
 
71
71
  async add (request) {
72
- webidl.brandCheck(this, Cache)
72
+ webidl.brandCheck(this, webidl.is.Cache)
73
73
 
74
74
  const prefix = 'Cache.add'
75
75
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -87,7 +87,7 @@ class Cache {
87
87
  }
88
88
 
89
89
  async addAll (requests) {
90
- webidl.brandCheck(this, Cache)
90
+ webidl.brandCheck(this, webidl.is.Cache)
91
91
 
92
92
  const prefix = 'Cache.addAll'
93
93
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -185,7 +185,10 @@ class Cache {
185
185
  }
186
186
  }
187
187
  },
188
- processResponseEndOfBody (response) {
188
+ // Possible spec bug. If the body is never read, `processResponseEndOfBody` (which is attached to a TransformStream's flush hook)
189
+ // never runs, so this would hang. This hook, on the other hand, always reads the body.
190
+ // https://github.com/nodejs/undici/issues/5615
191
+ processResponseConsumeBody (response) {
189
192
  // 1.
190
193
  if (response.aborted) {
191
194
  responsePromise.reject(new DOMException('aborted', 'AbortError'))
@@ -257,7 +260,7 @@ class Cache {
257
260
  }
258
261
 
259
262
  async put (request, response) {
260
- webidl.brandCheck(this, Cache)
263
+ webidl.brandCheck(this, webidl.is.Cache)
261
264
 
262
265
  const prefix = 'Cache.put'
263
266
  webidl.argumentLengthCheck(arguments, 2, prefix)
@@ -388,7 +391,7 @@ class Cache {
388
391
  }
389
392
 
390
393
  async delete (request, options = {}) {
391
- webidl.brandCheck(this, Cache)
394
+ webidl.brandCheck(this, webidl.is.Cache)
392
395
 
393
396
  const prefix = 'Cache.delete'
394
397
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -454,7 +457,7 @@ class Cache {
454
457
  * @returns {Promise<readonly Request[]>}
455
458
  */
456
459
  async keys (request = undefined, options = {}) {
457
- webidl.brandCheck(this, Cache)
460
+ webidl.brandCheck(this, webidl.is.Cache)
458
461
 
459
462
  const prefix = 'Cache.keys'
460
463
 
@@ -804,6 +807,12 @@ class Cache {
804
807
  // 6.
805
808
  return Object.freeze(responseList)
806
809
  }
810
+
811
+ static {
812
+ webidl.is.Cache = (arg) => {
813
+ return arg != null && typeof arg === 'object' && #relevantRequestResponseList in arg
814
+ }
815
+ }
807
816
  }
808
817
 
809
818
  Object.defineProperties(Cache.prototype, {
@@ -21,7 +21,7 @@ class CacheStorage {
21
21
  }
22
22
 
23
23
  async match (request, options = {}) {
24
- webidl.brandCheck(this, CacheStorage)
24
+ webidl.brandCheck(this, webidl.is.CacheStorage)
25
25
  webidl.argumentLengthCheck(arguments, 1, 'CacheStorage.match')
26
26
 
27
27
  request = webidl.converters.RequestInfo(request)
@@ -58,7 +58,7 @@ class CacheStorage {
58
58
  * @returns {Promise<boolean>}
59
59
  */
60
60
  async has (cacheName) {
61
- webidl.brandCheck(this, CacheStorage)
61
+ webidl.brandCheck(this, webidl.is.CacheStorage)
62
62
 
63
63
  const prefix = 'CacheStorage.has'
64
64
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -76,7 +76,7 @@ class CacheStorage {
76
76
  * @returns {Promise<Cache>}
77
77
  */
78
78
  async open (cacheName) {
79
- webidl.brandCheck(this, CacheStorage)
79
+ webidl.brandCheck(this, webidl.is.CacheStorage)
80
80
 
81
81
  const prefix = 'CacheStorage.open'
82
82
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -110,7 +110,7 @@ class CacheStorage {
110
110
  * @returns {Promise<boolean>}
111
111
  */
112
112
  async delete (cacheName) {
113
- webidl.brandCheck(this, CacheStorage)
113
+ webidl.brandCheck(this, webidl.is.CacheStorage)
114
114
 
115
115
  const prefix = 'CacheStorage.delete'
116
116
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -125,7 +125,7 @@ class CacheStorage {
125
125
  * @returns {Promise<string[]>}
126
126
  */
127
127
  async keys () {
128
- webidl.brandCheck(this, CacheStorage)
128
+ webidl.brandCheck(this, webidl.is.CacheStorage)
129
129
 
130
130
  // 2.1
131
131
  const keys = this.#caches.keys()
@@ -133,6 +133,12 @@ class CacheStorage {
133
133
  // 2.2
134
134
  return [...keys]
135
135
  }
136
+
137
+ static {
138
+ webidl.is.CacheStorage = (arg) => {
139
+ return arg != null && typeof arg === 'object' && #caches in arg
140
+ }
141
+ }
136
142
  }
137
143
 
138
144
  Object.defineProperties(CacheStorage.prototype, {
@@ -3,9 +3,19 @@
3
3
  const { parseSetCookie } = require('./parse')
4
4
  const { stringify } = require('./util')
5
5
  const { webidl } = require('../webidl')
6
- const { Headers } = require('../fetch/headers')
7
6
 
8
- const brandChecks = webidl.brandCheckMultiple([Headers, globalThis.Headers].filter(Boolean))
7
+ const globalHeadersBrandCheck = (arg) => webidl.brandCheck(arg, webidl.util.MakeTypeAssertion(globalThis.Headers))
8
+ const undiciHeadersBrandCheck = (arg) => webidl.brandCheck(arg, webidl.is.Headers)
9
+
10
+ function brandCheckHeaders (arg) {
11
+ try {
12
+ undiciHeadersBrandCheck(arg)
13
+ return
14
+ } catch {
15
+ }
16
+
17
+ globalHeadersBrandCheck(arg)
18
+ }
9
19
 
10
20
  /**
11
21
  * @typedef {Object} Cookie
@@ -28,12 +38,14 @@ const brandChecks = webidl.brandCheckMultiple([Headers, globalThis.Headers].filt
28
38
  function getCookies (headers) {
29
39
  webidl.argumentLengthCheck(arguments, 1, 'getCookies')
30
40
 
31
- brandChecks(headers)
41
+ brandCheckHeaders(headers)
32
42
 
33
43
  const cookie = headers.get('cookie')
34
44
 
45
+ // A null prototype keeps a cookie named `__proto__` from hitting the
46
+ // Object.prototype setter, which would silently drop it.
35
47
  /** @type {Record<string, string>} */
36
- const out = {}
48
+ const out = { __proto__: null }
37
49
 
38
50
  if (!cookie) {
39
51
  return out
@@ -55,7 +67,7 @@ function getCookies (headers) {
55
67
  * @returns {void}
56
68
  */
57
69
  function deleteCookie (headers, name, attributes) {
58
- brandChecks(headers)
70
+ brandCheckHeaders(headers)
59
71
 
60
72
  const prefix = 'deleteCookie'
61
73
  webidl.argumentLengthCheck(arguments, 2, prefix)
@@ -80,7 +92,7 @@ function deleteCookie (headers, name, attributes) {
80
92
  function getSetCookies (headers) {
81
93
  webidl.argumentLengthCheck(arguments, 1, 'getSetCookies')
82
94
 
83
- brandChecks(headers)
95
+ brandCheckHeaders(headers)
84
96
 
85
97
  const cookies = headers.getSetCookie()
86
98
 
@@ -109,7 +121,7 @@ function parseCookie (cookie) {
109
121
  function setCookie (headers, cookie) {
110
122
  webidl.argumentLengthCheck(arguments, 2, 'setCookie')
111
123
 
112
- brandChecks(headers)
124
+ brandCheckHeaders(headers)
113
125
 
114
126
  cookie = webidl.converters.Cookie(cookie)
115
127
 
@@ -315,7 +315,9 @@ function stringify (cookie) {
315
315
  out.push(`Path=${cookie.path}`)
316
316
  }
317
317
 
318
- if (cookie.expires && cookie.expires.toString() !== 'Invalid Date') {
318
+ // A numeric 0 is the Unix epoch, not an absent value -- the same reason the
319
+ // Max-Age check above tests the type rather than truthiness.
320
+ if (cookie.expires != null && cookie.expires.toString() !== 'Invalid Date') {
319
321
  out.push(`Expires=${toIMFDate(cookie.expires)}`)
320
322
  }
321
323
 
@@ -191,6 +191,8 @@ class EventSource extends EventTarget {
191
191
  * @readonly
192
192
  */
193
193
  get readyState () {
194
+ webidl.brandCheck(this, webidl.is.EventSource)
195
+
194
196
  return this.#readyState
195
197
  }
196
198
 
@@ -200,6 +202,8 @@ class EventSource extends EventTarget {
200
202
  * @returns {string}
201
203
  */
202
204
  get url () {
205
+ webidl.brandCheck(this, webidl.is.EventSource)
206
+
203
207
  return this.#url
204
208
  }
205
209
 
@@ -208,6 +212,8 @@ class EventSource extends EventTarget {
208
212
  * instantiated with CORS credentials set (true), or not (false, the default).
209
213
  */
210
214
  get withCredentials () {
215
+ webidl.brandCheck(this, webidl.is.EventSource)
216
+
211
217
  return this.#withCredentials
212
218
  }
213
219
 
@@ -363,7 +369,7 @@ class EventSource extends EventTarget {
363
369
  * CLOSED.
364
370
  */
365
371
  close () {
366
- webidl.brandCheck(this, EventSource)
372
+ webidl.brandCheck(this, webidl.is.EventSource)
367
373
 
368
374
  if (this.#readyState === CLOSED) return
369
375
  this.#readyState = CLOSED
@@ -372,10 +378,14 @@ class EventSource extends EventTarget {
372
378
  }
373
379
 
374
380
  get onopen () {
381
+ webidl.brandCheck(this, webidl.is.EventSource)
382
+
375
383
  return this.#events.open
376
384
  }
377
385
 
378
386
  set onopen (fn) {
387
+ webidl.brandCheck(this, webidl.is.EventSource)
388
+
379
389
  if (this.#events.open) {
380
390
  this.removeEventListener('open', this.#events.open)
381
391
  }
@@ -391,10 +401,14 @@ class EventSource extends EventTarget {
391
401
  }
392
402
 
393
403
  get onmessage () {
404
+ webidl.brandCheck(this, webidl.is.EventSource)
405
+
394
406
  return this.#events.message
395
407
  }
396
408
 
397
409
  set onmessage (fn) {
410
+ webidl.brandCheck(this, webidl.is.EventSource)
411
+
398
412
  if (this.#events.message) {
399
413
  this.removeEventListener('message', this.#events.message)
400
414
  }
@@ -410,10 +424,14 @@ class EventSource extends EventTarget {
410
424
  }
411
425
 
412
426
  get onerror () {
427
+ webidl.brandCheck(this, webidl.is.EventSource)
428
+
413
429
  return this.#events.error
414
430
  }
415
431
 
416
432
  set onerror (fn) {
433
+ webidl.brandCheck(this, webidl.is.EventSource)
434
+
417
435
  if (this.#events.error) {
418
436
  this.removeEventListener('error', this.#events.error)
419
437
  }
@@ -427,6 +445,12 @@ class EventSource extends EventTarget {
427
445
  this.#events.error = null
428
446
  }
429
447
  }
448
+
449
+ static {
450
+ webidl.is.EventSource = (arg) => {
451
+ return arg != null && typeof arg === 'object' && #events in arg
452
+ }
453
+ }
430
454
  }
431
455
 
432
456
  const constantsPropertyDescriptors = {
@@ -2,7 +2,6 @@
2
2
 
3
3
  const util = require('../../core/util')
4
4
  const {
5
- ReadableStreamFrom,
6
5
  readableStreamClose,
7
6
  fullyReadBody,
8
7
  extractMimeType
@@ -197,8 +196,16 @@ function extractBody (object, keepalive = false) {
197
196
  )
198
197
  }
199
198
 
200
- stream =
201
- webidl.is.ReadableStream(object) ? object : ReadableStreamFrom(object)
199
+ stream = webidl.is.ReadableStream(object)
200
+ ? object
201
+ : ReadableStream.from(object).pipeThrough(new TransformStream({
202
+ transform (chunk, controller) {
203
+ const bytes = isUint8Array(chunk) ? chunk : Buffer.from(chunk)
204
+ if (bytes.byteLength) {
205
+ controller.enqueue(bytes)
206
+ }
207
+ }
208
+ }))
202
209
  }
203
210
 
204
211
  // 11. If source is a byte sequence, then set action to a
@@ -293,7 +300,7 @@ function cloneBody (body) {
293
300
  }
294
301
  }
295
302
 
296
- function bodyMixinMethods (instance, getInternalState) {
303
+ function bodyMixinMethods (brandCheck, getInternalState) {
297
304
  const methods = {
298
305
  blob () {
299
306
  // The blob() method steps are to return the result of
@@ -313,7 +320,7 @@ function bodyMixinMethods (instance, getInternalState) {
313
320
  // Return a Blob whose contents are bytes and type attribute
314
321
  // is mimeType.
315
322
  return new Blob([bytes], { type: mimeType })
316
- }, instance, getInternalState)
323
+ }, brandCheck, getInternalState)
317
324
  },
318
325
 
319
326
  arrayBuffer () {
@@ -323,19 +330,19 @@ function bodyMixinMethods (instance, getInternalState) {
323
330
  // whose contents are bytes.
324
331
  return consumeBody(this, (bytes) => {
325
332
  return new Uint8Array(bytes).buffer
326
- }, instance, getInternalState)
333
+ }, brandCheck, getInternalState)
327
334
  },
328
335
 
329
336
  text () {
330
337
  // The text() method steps are to return the result of running
331
338
  // consume body with this and UTF-8 decode.
332
- return consumeBody(this, utf8DecodeBytes, instance, getInternalState)
339
+ return consumeBody(this, utf8DecodeBytes, brandCheck, getInternalState)
333
340
  },
334
341
 
335
342
  json () {
336
343
  // The json() method steps are to return the result of running
337
344
  // consume body with this and parse JSON from bytes.
338
- return consumeBody(this, parseJSONFromBytes, instance, getInternalState)
345
+ return consumeBody(this, parseJSONFromBytes, brandCheck, getInternalState)
339
346
  },
340
347
 
341
348
  formData () {
@@ -383,7 +390,7 @@ function bodyMixinMethods (instance, getInternalState) {
383
390
  throw new TypeError(
384
391
  'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
385
392
  )
386
- }, instance, getInternalState)
393
+ }, brandCheck, getInternalState)
387
394
  },
388
395
 
389
396
  bytes () {
@@ -392,7 +399,7 @@ function bodyMixinMethods (instance, getInternalState) {
392
399
  // result of creating a Uint8Array from bytes in this’s relevant realm.
393
400
  return consumeBody(this, (bytes) => {
394
401
  return new Uint8Array(bytes)
395
- }, instance, getInternalState)
402
+ }, brandCheck, getInternalState)
396
403
  },
397
404
 
398
405
  textStream () {
@@ -442,20 +449,20 @@ function bodyMixinMethods (instance, getInternalState) {
442
449
  return methods
443
450
  }
444
451
 
445
- function mixinBody (prototype, getInternalState) {
446
- Object.assign(prototype.prototype, bodyMixinMethods(prototype, getInternalState))
452
+ function mixinBody (prototype, getInternalState, brandCheck) {
453
+ Object.assign(prototype.prototype, bodyMixinMethods(brandCheck, getInternalState))
447
454
  }
448
455
 
449
456
  /**
450
457
  * @see https://fetch.spec.whatwg.org/#concept-body-consume-body
451
458
  * @param {any} object internal state
452
459
  * @param {(value: unknown) => unknown} convertBytesToJSValue
453
- * @param {any} instance
460
+ * @param {import('../../../types/webidl').WebidlIsFunction} brandCheck
454
461
  * @param {(target: any) => any} getInternalState
455
462
  */
456
- function consumeBody (object, convertBytesToJSValue, instance, getInternalState) {
463
+ function consumeBody (object, convertBytesToJSValue, brandCheck, getInternalState) {
457
464
  try {
458
- webidl.brandCheck(object, instance)
465
+ webidl.brandCheck(object, brandCheck)
459
466
  } catch (e) {
460
467
  return Promise.reject(e)
461
468
  }
@@ -1,14 +1,14 @@
1
1
  'use strict'
2
2
 
3
3
  const assert = require('node:assert')
4
- const { forgivingBase64, collectASequenceOfCodePoints, collectASequenceOfCodePointsFast, isomorphicDecode, removeASCIIWhitespace, removeChars } = require('../infra')
4
+ const { asciiLowercase, forgivingBase64, collectASequenceOfCodePoints, collectASequenceOfCodePointsFast, isomorphicDecode, removeASCIIWhitespace, removeChars } = require('../infra')
5
5
 
6
6
  const encoder = new TextEncoder()
7
7
 
8
8
  /**
9
9
  * @see https://mimesniff.spec.whatwg.org/#http-token-code-point
10
10
  */
11
- const HTTP_TOKEN_CODEPOINTS = /^[-!#$%&'*+.^_|~A-Za-z0-9]+$/u
11
+ const HTTP_TOKEN_CODEPOINTS = /^[-!#$%&'*+.^_`|~A-Za-z0-9]+$/u
12
12
  const HTTP_WHITESPACE_REGEX = /[\u000A\u000D\u0009\u0020]/u // eslint-disable-line
13
13
 
14
14
  /**
@@ -69,7 +69,7 @@ function dataURLProcessor (dataURL) {
69
69
  // 11. If mimeType ends with U+003B (;), followed by
70
70
  // zero or more U+0020 SPACE, followed by an ASCII
71
71
  // case-insensitive match for "base64", then:
72
- if (/;(?:\u0020*)base64$/ui.test(mimeType)) {
72
+ if (/;\u0020*[Bb][Aa][Ss][Ee]64$/u.test(mimeType)) {
73
73
  // 1. Let stringBody be the isomorphic decode of body.
74
74
  const stringBody = isomorphicDecode(body)
75
75
 
@@ -268,8 +268,8 @@ function parseMIMEType (input) {
268
268
  return 'failure'
269
269
  }
270
270
 
271
- const typeLowercase = type.toLowerCase()
272
- const subtypeLowercase = subtype.toLowerCase()
271
+ const typeLowercase = asciiLowercase(type)
272
+ const subtypeLowercase = asciiLowercase(subtype)
273
273
 
274
274
  // 10. Let mimeType be a new MIME type record whose type
275
275
  // is type, in ASCII lowercase, and subtype is subtype,
@@ -309,7 +309,7 @@ function parseMIMEType (input) {
309
309
 
310
310
  // 4. Set parameterName to parameterName, in ASCII
311
311
  // lowercase.
312
- parameterName = parameterName.toLowerCase()
312
+ parameterName = asciiLowercase(parameterName)
313
313
 
314
314
  // 5. If position is not past the end of input, then:
315
315
  if (position.position < input.length) {
@@ -10,6 +10,8 @@ const random = runtimeFeatures.has('crypto')
10
10
  ? require('node:crypto').randomInt
11
11
  : (max) => Math.floor(Math.random() * max)
12
12
 
13
+ let getFormDataState, setFormDataState, getFormDataBoundary
14
+
13
15
  // https://xhr.spec.whatwg.org/#formdata
14
16
  class FormData {
15
17
  #state = []
@@ -28,7 +30,7 @@ class FormData {
28
30
  }
29
31
 
30
32
  append (name, value, filename = undefined) {
31
- webidl.brandCheck(this, FormData)
33
+ webidl.brandCheck(this, webidl.is.FormData)
32
34
 
33
35
  const prefix = 'FormData.append'
34
36
  webidl.argumentLengthCheck(arguments, 2, prefix)
@@ -56,7 +58,7 @@ class FormData {
56
58
  }
57
59
 
58
60
  delete (name) {
59
- webidl.brandCheck(this, FormData)
61
+ webidl.brandCheck(this, webidl.is.FormData)
60
62
 
61
63
  const prefix = 'FormData.delete'
62
64
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -69,7 +71,7 @@ class FormData {
69
71
  }
70
72
 
71
73
  get (name) {
72
- webidl.brandCheck(this, FormData)
74
+ webidl.brandCheck(this, webidl.is.FormData)
73
75
 
74
76
  const prefix = 'FormData.get'
75
77
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -89,7 +91,7 @@ class FormData {
89
91
  }
90
92
 
91
93
  getAll (name) {
92
- webidl.brandCheck(this, FormData)
94
+ webidl.brandCheck(this, webidl.is.FormData)
93
95
 
94
96
  const prefix = 'FormData.getAll'
95
97
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -106,7 +108,7 @@ class FormData {
106
108
  }
107
109
 
108
110
  has (name) {
109
- webidl.brandCheck(this, FormData)
111
+ webidl.brandCheck(this, webidl.is.FormData)
110
112
 
111
113
  const prefix = 'FormData.has'
112
114
  webidl.argumentLengthCheck(arguments, 1, prefix)
@@ -119,7 +121,7 @@ class FormData {
119
121
  }
120
122
 
121
123
  set (name, value, filename = undefined) {
122
- webidl.brandCheck(this, FormData)
124
+ webidl.brandCheck(this, webidl.is.FormData)
123
125
 
124
126
  const prefix = 'FormData.set'
125
127
  webidl.argumentLengthCheck(arguments, 2, prefix)
@@ -184,40 +186,34 @@ class FormData {
184
186
  return `FormData ${output.slice(output.indexOf(']') + 2)}`
185
187
  }
186
188
 
187
- /**
188
- * @param {FormData} formData
189
- */
190
- static getFormDataState (formData) {
191
- return formData.#state
192
- }
189
+ static {
190
+ /** @param {FormData} formData */
191
+ getFormDataState = (formData) => formData.#state
193
192
 
194
- /**
195
- * @param {FormData} formData
196
- * @param {any[]} newState
197
- */
198
- static setFormDataState (formData, newState) {
199
- formData.#state = newState
200
- }
193
+ /**
194
+ * @param {FormData} formData
195
+ * @param {any[]} newState
196
+ */
197
+ setFormDataState = (formData, newState) => {
198
+ formData.#state = newState
199
+ }
201
200
 
202
- /**
203
- * @param {FormData} formData
204
- * @returns {string | null}
205
- */
206
- static getFormDataBoundary (formData) {
207
- const boundary = formData.#boundary
208
- if (boundary != null) return boundary
201
+ /**
202
+ * @param {FormData} formData
203
+ * @returns {string | null}
204
+ */
205
+ getFormDataBoundary = (formData) => {
206
+ // eslint-disable-next-line no-return-assign
207
+ return formData.#boundary ??= `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
208
+ }
209
209
 
210
- // eslint-disable-next-line no-return-assign
211
- return formData.#boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
210
+ webidl.is.FormData = (arg) => {
211
+ return arg != null && typeof arg === 'object' && #state in arg
212
+ }
212
213
  }
213
214
  }
214
215
 
215
- const { getFormDataState, setFormDataState, getFormDataBoundary } = FormData
216
- Reflect.deleteProperty(FormData, 'getFormDataState')
217
- Reflect.deleteProperty(FormData, 'setFormDataState')
218
- Reflect.deleteProperty(FormData, 'getFormDataBoundary')
219
-
220
- iteratorMixin('FormData', FormData, getFormDataState, 'name', 'value')
216
+ iteratorMixin('FormData', FormData, getFormDataState, 'name', 'value', webidl.is.FormData)
221
217
 
222
218
  Object.defineProperties(FormData.prototype, {
223
219
  append: kEnumerableProperty,
@@ -273,6 +269,4 @@ function makeEntry (name, value, filename) {
273
269
  return { name, value }
274
270
  }
275
271
 
276
- webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData)
277
-
278
272
  module.exports = { FormData, makeEntry, setFormDataState, getFormDataBoundary }