@moqtap/codec 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +16 -4
  3. package/dist/{chunk-KCH4BQXK.cjs → chunk-AQ445VV7.cjs} +15 -9
  4. package/dist/{chunk-UZO5Z2XT.cjs → chunk-BIBMDTU5.cjs} +12 -6
  5. package/dist/chunk-BMJMY6FX.cjs +868 -0
  6. package/dist/{chunk-23KRITJ6.js → chunk-BX2N7TZM.js} +14 -8
  7. package/dist/{chunk-XQGEOFGE.js → chunk-CF5DDD3Q.js} +14 -8
  8. package/dist/chunk-FT3HDNIB.js +2374 -0
  9. package/dist/{chunk-TMXRYOBS.js → chunk-G53WYUXL.js} +13 -7
  10. package/dist/{chunk-JKMYAUGY.js → chunk-K2B3OVFK.js} +11 -8
  11. package/dist/{chunk-3YAR3I3S.js → chunk-KGDVC4O6.js} +36 -22
  12. package/dist/{chunk-VWXUT5R2.cjs → chunk-KTNERCTZ.cjs} +36 -22
  13. package/dist/{chunk-H6DTAIWM.js → chunk-L5DRACXS.js} +22 -16
  14. package/dist/{chunk-UA5XFP4O.cjs → chunk-OUNN4IQB.cjs} +14 -8
  15. package/dist/{chunk-NH4L6NIY.js → chunk-OZRK73NQ.js} +12 -6
  16. package/dist/{chunk-PU2KV7VP.cjs → chunk-RYKQXBG6.cjs} +12 -6
  17. package/dist/{chunk-EVCPBFSR.cjs → chunk-SDJTSMOW.cjs} +23 -17
  18. package/dist/chunk-T4VWPKDG.cjs +2374 -0
  19. package/dist/{chunk-2XH6PHXR.js → chunk-TSUZ6GJV.js} +12 -6
  20. package/dist/{chunk-QGIHC6BA.cjs → chunk-UKKDOOUO.cjs} +12 -9
  21. package/dist/{chunk-BV6MITLO.js → chunk-WCPENYNE.js} +14 -8
  22. package/dist/{chunk-IADVBKEJ.cjs → chunk-WCTMPDUX.cjs} +15 -9
  23. package/dist/chunk-WX5PU7HF.js +868 -0
  24. package/dist/{chunk-7ENEWAMZ.cjs → chunk-XCRCAUGI.cjs} +15 -9
  25. package/dist/{codec-BLYAy2OP.d.ts → codec--CVeqGQv.d.ts} +1 -1
  26. package/dist/{codec-BNS3gS77.d.ts → codec-08ZOr5wI.d.ts} +2 -2
  27. package/dist/{codec-DujHf55Z.d.ts → codec-BJ7BHuiZ.d.ts} +1 -1
  28. package/dist/{codec-CI0BjmHc.d.ts → codec-BNy5syCU.d.ts} +1 -1
  29. package/dist/{codec-N3g1lxQQ.d.cts → codec-Bd60SGKH.d.cts} +2 -2
  30. package/dist/{codec-xeuGZY77.d.cts → codec-BrTi4K7r.d.cts} +3 -3
  31. package/dist/{codec-DJmV04i0.d.ts → codec-Bux_Q40X.d.ts} +2 -2
  32. package/dist/{codec-BqqoYdh_.d.cts → codec-BxQTybUX.d.cts} +2 -2
  33. package/dist/{codec-D2JbI2tp.d.ts → codec-C3mdsGx3.d.ts} +2 -2
  34. package/dist/{codec-DQWQSam3.d.cts → codec-C6Mx4bwz.d.cts} +1 -1
  35. package/dist/{codec-DAePx2NL.d.ts → codec-CBdOIfMY.d.ts} +3 -3
  36. package/dist/codec-CFWu5KVT.d.cts +49 -0
  37. package/dist/{codec-CyApDKwf.d.cts → codec-CWnf8mn_.d.cts} +2 -2
  38. package/dist/{codec-DvcJgYKq.d.cts → codec-CXCjya_G.d.cts} +1 -1
  39. package/dist/{codec-BOyrk_C9.d.cts → codec-Cfo_z5ET.d.cts} +1 -1
  40. package/dist/{codec-v6Vloc7H.d.ts → codec-Cm3D261p.d.ts} +2 -2
  41. package/dist/codec-CwZ6OCPP.d.ts +49 -0
  42. package/dist/{codec-NMsTK0GX.d.cts → codec-Czejcmxr.d.cts} +2 -2
  43. package/dist/{codec-hvkJfCF5.d.cts → codec-DNmiG2e0.d.cts} +2 -2
  44. package/dist/{codec-CWj5iTxA.d.ts → codec-DOmAmFkI.d.ts} +2 -2
  45. package/dist/{codec-WwwUipaU.d.ts → codec-DaXjRrOV.d.ts} +2 -2
  46. package/dist/{codec-DplRgIKq.d.ts → codec-Dl_QIXMz.d.ts} +1 -1
  47. package/dist/{codec-D95gT98n.d.cts → codec-DzkdW4kO.d.cts} +1 -1
  48. package/dist/{codec-cou9XBMF.d.cts → codec-EvybrBuY.d.cts} +2 -2
  49. package/dist/{codec-DL0njGkL.d.ts → codec-alVA27Uc.d.ts} +2 -2
  50. package/dist/{codec-D89DWXbv.d.cts → codec-f7vxeVIS.d.cts} +2 -2
  51. package/dist/{codec-D47r_-Rl.d.ts → codec-gl4_QEva.d.ts} +2 -2
  52. package/dist/{codec-BOtv3R5j.d.cts → codec-guzqtfMk.d.cts} +2 -2
  53. package/dist/draft07-session.d.cts +3 -3
  54. package/dist/draft07-session.d.ts +3 -3
  55. package/dist/draft07.d.cts +3 -3
  56. package/dist/draft07.d.ts +3 -3
  57. package/dist/draft08-session.d.cts +3 -3
  58. package/dist/draft08-session.d.ts +3 -3
  59. package/dist/draft08.d.cts +4 -4
  60. package/dist/draft08.d.ts +4 -4
  61. package/dist/draft09-session.d.cts +3 -3
  62. package/dist/draft09-session.d.ts +3 -3
  63. package/dist/draft09.d.cts +4 -4
  64. package/dist/draft09.d.ts +4 -4
  65. package/dist/draft10-session.d.cts +3 -3
  66. package/dist/draft10-session.d.ts +3 -3
  67. package/dist/draft10.d.cts +4 -4
  68. package/dist/draft10.d.ts +4 -4
  69. package/dist/draft11-session.d.cts +4 -4
  70. package/dist/draft11-session.d.ts +4 -4
  71. package/dist/draft11.cjs +2 -2
  72. package/dist/draft11.d.cts +6 -6
  73. package/dist/draft11.d.ts +6 -6
  74. package/dist/draft11.js +1 -1
  75. package/dist/draft12-session.d.cts +4 -4
  76. package/dist/draft12-session.d.ts +4 -4
  77. package/dist/draft12.cjs +2 -2
  78. package/dist/draft12.d.cts +6 -6
  79. package/dist/draft12.d.ts +6 -6
  80. package/dist/draft12.js +1 -1
  81. package/dist/draft13-session.d.cts +4 -4
  82. package/dist/draft13-session.d.ts +4 -4
  83. package/dist/draft13.cjs +2 -2
  84. package/dist/draft13.d.cts +6 -6
  85. package/dist/draft13.d.ts +6 -6
  86. package/dist/draft13.js +1 -1
  87. package/dist/draft14-session.d.cts +4 -4
  88. package/dist/draft14-session.d.ts +4 -4
  89. package/dist/draft14.cjs +2 -2
  90. package/dist/draft14.d.cts +6 -6
  91. package/dist/draft14.d.ts +6 -6
  92. package/dist/draft14.js +1 -1
  93. package/dist/draft15-session.d.cts +4 -4
  94. package/dist/draft15-session.d.ts +4 -4
  95. package/dist/draft15.cjs +2 -2
  96. package/dist/draft15.d.cts +6 -6
  97. package/dist/draft15.d.ts +6 -6
  98. package/dist/draft15.js +1 -1
  99. package/dist/draft16-session.d.cts +4 -4
  100. package/dist/draft16-session.d.ts +4 -4
  101. package/dist/draft16.cjs +2 -2
  102. package/dist/draft16.d.cts +6 -6
  103. package/dist/draft16.d.ts +6 -6
  104. package/dist/draft16.js +1 -1
  105. package/dist/draft17-session.d.cts +4 -4
  106. package/dist/draft17-session.d.ts +4 -4
  107. package/dist/draft17.cjs +2 -2
  108. package/dist/draft17.d.cts +5 -5
  109. package/dist/draft17.d.ts +5 -5
  110. package/dist/draft17.js +1 -1
  111. package/dist/draft18-session.d.cts +4 -4
  112. package/dist/draft18-session.d.ts +4 -4
  113. package/dist/draft18.cjs +2 -2
  114. package/dist/draft18.d.cts +5 -5
  115. package/dist/draft18.d.ts +5 -5
  116. package/dist/draft18.js +1 -1
  117. package/dist/draft19-session.d.cts +4 -4
  118. package/dist/draft19-session.d.ts +4 -4
  119. package/dist/draft19.cjs +2 -2
  120. package/dist/draft19.d.cts +5 -5
  121. package/dist/draft19.d.ts +5 -5
  122. package/dist/draft19.js +1 -1
  123. package/dist/draft20-session.cjs +8 -0
  124. package/dist/draft20-session.d.cts +195 -0
  125. package/dist/draft20-session.d.ts +195 -0
  126. package/dist/draft20-session.js +8 -0
  127. package/dist/draft20.cjs +217 -0
  128. package/dist/draft20.d.cts +175 -0
  129. package/dist/draft20.d.ts +175 -0
  130. package/dist/draft20.js +217 -0
  131. package/dist/index.cjs +25 -19
  132. package/dist/index.d.cts +41 -26
  133. package/dist/index.d.ts +41 -26
  134. package/dist/index.js +16 -10
  135. package/dist/{session-types-KsqyVp6y.d.cts → session-types-B9idsih-.d.cts} +13 -1
  136. package/dist/{session-types-C0l_-Ups.d.ts → session-types-Dn7b3RZM.d.ts} +13 -1
  137. package/dist/session.cjs +5 -1
  138. package/dist/session.d.cts +14 -12
  139. package/dist/session.d.ts +14 -12
  140. package/dist/session.js +5 -1
  141. package/dist/{types-Cqp10JtB.d.cts → types-Bg86GGVZ.d.cts} +2 -2
  142. package/dist/{types-Cqp10JtB.d.ts → types-Bg86GGVZ.d.ts} +2 -2
  143. package/dist/{types-zHgCS6o5.d.cts → types-C1rxh-id.d.cts} +7 -7
  144. package/dist/{types-zHgCS6o5.d.ts → types-C1rxh-id.d.ts} +7 -7
  145. package/dist/{types-Bio-91Rt.d.cts → types-CI_SX4Xe.d.cts} +2 -2
  146. package/dist/{types-Bio-91Rt.d.ts → types-CI_SX4Xe.d.ts} +2 -2
  147. package/dist/types-CY-QWxd-.d.cts +359 -0
  148. package/dist/types-CY-QWxd-.d.ts +359 -0
  149. package/dist/{types-Cm9fjeYC.d.cts → types-CZTzbIzQ.d.cts} +2 -2
  150. package/dist/{types-Cm9fjeYC.d.ts → types-CZTzbIzQ.d.ts} +2 -2
  151. package/dist/{types-HI_bbXka.d.cts → types-CmqT0jUf.d.cts} +1 -1
  152. package/dist/{types-HI_bbXka.d.ts → types-CmqT0jUf.d.ts} +1 -1
  153. package/dist/{types-Ck45Ex5S.d.cts → types-D0kTgUuL.d.cts} +1 -1
  154. package/dist/{types-Ck45Ex5S.d.ts → types-D0kTgUuL.d.ts} +1 -1
  155. package/dist/{types-D9eiB_9A.d.cts → types-D4bmW8rY.d.cts} +2 -2
  156. package/dist/{types-D9eiB_9A.d.ts → types-D4bmW8rY.d.ts} +2 -2
  157. package/dist/{types-CdCSIfvI.d.cts → types-DG5_iKuv.d.cts} +1 -1
  158. package/dist/{types-CdCSIfvI.d.ts → types-DG5_iKuv.d.ts} +1 -1
  159. package/dist/{types-CXlSn0I9.d.cts → types-DjxexghA.d.cts} +2 -2
  160. package/dist/{types-CXlSn0I9.d.ts → types-DjxexghA.d.ts} +2 -2
  161. package/dist/{types-CPaYBsMG.d.cts → types-pShrs3fN.d.cts} +2 -2
  162. package/dist/{types-CPaYBsMG.d.ts → types-pShrs3fN.d.ts} +2 -2
  163. package/package.json +16 -3
  164. package/src/core/session-types.ts +7 -0
  165. package/src/core/types.ts +1 -0
  166. package/src/drafts/draft11/codec.ts +11 -8
  167. package/src/drafts/draft11/types.ts +1 -1
  168. package/src/drafts/draft12/codec.ts +22 -16
  169. package/src/drafts/draft12/types.ts +2 -2
  170. package/src/drafts/draft13/codec.ts +14 -8
  171. package/src/drafts/draft13/types.ts +2 -2
  172. package/src/drafts/draft14/codec.ts +14 -8
  173. package/src/drafts/draft14/types.ts +1 -1
  174. package/src/drafts/draft15/codec.ts +14 -8
  175. package/src/drafts/draft15/types.ts +2 -2
  176. package/src/drafts/draft16/codec.ts +13 -7
  177. package/src/drafts/draft16/types.ts +2 -2
  178. package/src/drafts/draft17/codec.ts +12 -6
  179. package/src/drafts/draft17/types.ts +2 -2
  180. package/src/drafts/draft18/codec.ts +12 -6
  181. package/src/drafts/draft18/types.ts +2 -2
  182. package/src/drafts/draft19/codec.ts +37 -23
  183. package/src/drafts/draft19/types.ts +10 -7
  184. package/src/drafts/draft20/codec.ts +1749 -0
  185. package/src/drafts/draft20/data-streams.ts +1291 -0
  186. package/src/drafts/draft20/error-codes.ts +135 -0
  187. package/src/drafts/draft20/index.ts +165 -0
  188. package/src/drafts/draft20/messages.ts +68 -0
  189. package/src/drafts/draft20/rules.ts +107 -0
  190. package/src/drafts/draft20/session-fsm.ts +1063 -0
  191. package/src/drafts/draft20/session.ts +21 -0
  192. package/src/drafts/draft20/types.ts +461 -0
  193. package/src/index.ts +20 -2
  194. package/src/session.ts +4 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@moqtap/codec` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ This file starts at 0.9.0. Earlier releases are in the git history.
9
+
10
+ ## [0.10.0] - 2026-09-03
11
+
12
+ ### Changed
13
+
14
+ - **Breaking.** `authorization_token` is `readonly AuthorizationToken[]` on
15
+ drafts 11 through 20, on message parameters and on setup options. A single
16
+ token is a one-element array.
17
+
18
+ Section 10.2.2 and its equivalents: "The AUTHORIZATION TOKEN parameter MAY be
19
+ repeated within a message as long as the combination of Token Type and Token
20
+ Value are unique after resolving any aliases."
21
+
22
+ - **Breaking.** `subgroup_filter`, `objectid_filter`, `priority_filter`,
23
+ `object_property_filter` and `track_property_filter` are
24
+ `readonly RangeFilter[]` on drafts 19 and 20, on message parameters and on
25
+ draft-20's `FILL_PARAMETERS`. A single filter is a one-element array.
26
+
27
+ Section 5.1.3 on draft-19 and 5.1.4 on draft-20: "All other filter parameters
28
+ MAY appear multiple times in a FETCH, SUBSCRIBE, SUBSCRIBE_TRACKS, or
29
+ REQUEST_UPDATE". One filter parameter carries one SetID and the sets are ORed,
30
+ so two alternatives over the same field need two parameters.
31
+
32
+ - `@moqtap/test-vectors` raised to `^0.15.0`, where a `decoded` message spells
33
+ each Key-Value-Pair block as a list of entries in wire order rather than as a
34
+ map keyed by parameter name.
35
+
36
+ ## [0.9.0] - 2026-09-03
37
+
38
+ Draft-20 support, and a fix to draft-19 that changes which state machine a
39
+ draft-19 session runs.
40
+
41
+ ### Added
42
+
43
+ - **Draft-20**: codec, message and data-stream tables, wire rules, error codes
44
+ and session FSM, exported as `@moqtap/codec/draft20` and
45
+ `@moqtap/codec/draft20/session`. `createCodec({ draft: '20' })` and
46
+ `createDraft20Codec()` both reach it.
47
+ - `PUBLISH_STATE_NOTIFY` (`0x22`), the one control message draft-20 adds. It is
48
+ unilateral and not subject to `MAX_REQUEST_UPDATES`.
49
+ - Draft-20's rewritten `FETCH`. The message keeps codepoint `0x16` but drops the
50
+ Fetch Type discriminator, carries Track Namespace and Track Name inline, and
51
+ moves its range into a `LOCATION_FILTER` parameter. Nothing on the wire
52
+ distinguishes it from a draft-19 `FETCH` at the type byte, so a session
53
+ decoded under the wrong draft will silently misparse it — pick the draft from
54
+ the negotiated `moqt-NN` protocol string, not from message content.
55
+ - `INCLUDE_PROPERTIES` (`0x35`), a uint8 boolean defaulting to `1`.
56
+
57
+ ### Fixed
58
+
59
+ - **`createDraft19Codec()` reported `draft: '18'`.** Since `createSessionState()`
60
+ keys off `codec.draft`, every draft-19 session was validated by the draft-18
61
+ FSM. Draft-19 sessions now run the draft-19 FSM, which enforces rules the
62
+ draft-18 one does not — a session that passed validation on 0.8.1 may now be
63
+ rejected, correctly.
64
+
65
+ ### Changed
66
+
67
+ - Draft-20 ranges are **inclusive**. An end location names the last object, not
68
+ one past it; do not carry a draft-19 `+ 1` forward.
69
+ - Retired error codes decode rather than being refused. Draft-20 Section 14
70
+ requires an unknown error code in any error context to be treated as
71
+ `INTERNAL_ERROR`, and forbids closing the session over one in `REQUEST_ERROR`
72
+ or `PUBLISH_DONE`. The `RETIRED_*` sets remain exported as advisory
73
+ diagnostics — useful for "this peer looks like draft-19" — but are no longer
74
+ decode gates.
75
+ - `@moqtap/test-vectors` dependency raised to `^0.13.0` for the draft-20 corpus.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  MoQT (Media over QUIC Transport) wire-format codec and session state machine for JavaScript/TypeScript.
4
4
 
5
- - Multi-draft support (drafts 07 through 19)
5
+ - Multi-draft support (drafts 07 through 20)
6
6
  - Stateless encode/decode of all MoQT control messages and data streams
7
7
  - Protocol session state machine with FSM-based validation per draft
8
8
  - Zero runtime dependencies
@@ -43,10 +43,11 @@ Or use the factory if your application supports multiple drafts:
43
43
  ```typescript
44
44
  import { createCodec, DRAFT_VERSIONS } from '@moqtap/codec'
45
45
 
46
- const codec = createCodec({ draft: '19' }) // '07' through '19'
46
+ const codec = createCodec({ draft: '20' }) // '07' through '20'
47
47
 
48
- // DRAFT_VERSIONS provides wire version numbers under short aliases:
49
- // DRAFT_VERSIONS['07'] — 0xff000007n
48
+ // DRAFT_VERSIONS provides version identifiers under short aliases:
49
+ // DRAFT_VERSIONS['07'] — 0xff000007n, a real draft-07 wire value
50
+ // DRAFT_VERSIONS['20'] — 0xff000014n, derived; see the note below
50
51
  ```
51
52
 
52
53
  ## Subpath Exports
@@ -69,10 +70,21 @@ Each draft is available as a subpath import with its own codec and session state
69
70
  | `@moqtap/codec/draft17` | Draft-17 codec |
70
71
  | `@moqtap/codec/draft18` | Draft-18 codec |
71
72
  | `@moqtap/codec/draft19` | Draft-19 codec |
73
+ | `@moqtap/codec/draft20` | Draft-20 codec |
72
74
  | `@moqtap/codec/draft{N}/session` | Session state machine for draft N |
73
75
 
74
76
  > **Note:** A default (versionless) codec will be available once the MoQT specification reaches RFC status. Until then, always specify a draft version.
75
77
 
78
+ `DRAFT_VERSIONS` is a table of numeric keys, and only the entries up to `'14'` are values a peer
79
+ ever puts on the wire. From draft-15 the version is negotiated by ALPN (raw QUIC) or
80
+ `WT-Available-Protocols` (WebTransport) as the string `moqt-NN`, and no version number is sent at
81
+ all — so `DRAFT_VERSIONS['20']` is a derived identifier, not something observed. Each draft module
82
+ from 15 on exports the real one:
83
+
84
+ ```typescript
85
+ import { PROTOCOL_STRING } from '@moqtap/codec/draft20' // 'moqt-20'
86
+ ```
87
+
76
88
  ## Draft-Specific Imports
77
89
 
78
90
  For applications targeting a single draft version:
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
@@ -411,7 +411,7 @@ function encodeSetupParams(params, w) {
411
411
  let count = 0;
412
412
  if (params.path !== void 0) count++;
413
413
  if (params.max_request_id !== void 0) count++;
414
- if (params.authorization_token !== void 0) count++;
414
+ count += _nullishCoalesce(_optionalChain([params, 'access', _2 => _2.authorization_token, 'optionalAccess', _3 => _3.length]), () => ( 0));
415
415
  if (params.max_auth_token_cache_size !== void 0) count++;
416
416
  if (params.unknown) count += params.unknown.length;
417
417
  w.writeVarInt(count);
@@ -425,9 +425,9 @@ function encodeSetupParams(params, w) {
425
425
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
426
426
  w.writeVarInt(params.max_request_id);
427
427
  }
428
- if (params.authorization_token !== void 0) {
428
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
429
429
  w.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN);
430
- encodeAuthorizationToken(params.authorization_token, w);
430
+ encodeAuthorizationToken(token, w);
431
431
  }
432
432
  if (params.max_auth_token_cache_size !== void 0) {
433
433
  w.writeVarInt(SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE);
@@ -477,7 +477,10 @@ function decodeSetupParams(r) {
477
477
  const bytes = r.readBytes(length);
478
478
  result.path = textDecoder.decode(bytes);
479
479
  } else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
480
- result.authorization_token = decodeAuthorizationToken(r, length);
480
+ result.authorization_token = [
481
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
482
+ decodeAuthorizationToken(r, length)
483
+ ];
481
484
  } else {
482
485
  const bytes = r.readBytes(length);
483
486
  unknown.push({
@@ -494,16 +497,16 @@ function decodeSetupParams(r) {
494
497
  function encodeParams(params, w) {
495
498
  let count = params.unknown ? params.unknown.length : 0;
496
499
  if (params.delivery_timeout !== void 0) count++;
497
- if (params.authorization_token !== void 0) count++;
500
+ count += _nullishCoalesce(_optionalChain([params, 'access', _4 => _4.authorization_token, 'optionalAccess', _5 => _5.length]), () => ( 0));
498
501
  if (params.max_cache_duration !== void 0) count++;
499
502
  w.writeVarInt(count);
500
503
  if (params.delivery_timeout !== void 0) {
501
504
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
502
505
  w.writeVarInt(params.delivery_timeout);
503
506
  }
504
- if (params.authorization_token !== void 0) {
507
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
505
508
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
506
- encodeAuthorizationToken(params.authorization_token, w);
509
+ encodeAuthorizationToken(token, w);
507
510
  }
508
511
  if (params.max_cache_duration !== void 0) {
509
512
  w.writeVarInt(PARAM_MAX_CACHE_DURATION);
@@ -550,7 +553,10 @@ function decodeParams(r) {
550
553
  } else {
551
554
  const length = Number(r.readVarInt());
552
555
  if (paramType === PARAM_AUTHORIZATION_TOKEN) {
553
- result.authorization_token = decodeAuthorizationToken(r, length);
556
+ result.authorization_token = [
557
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
558
+ decodeAuthorizationToken(r, length)
559
+ ];
554
560
  } else {
555
561
  const bytes = r.readBytes(length);
556
562
  unknown.push({
@@ -935,12 +935,12 @@ function encodeSetupOptions(opts, writer) {
935
935
  }
936
936
  });
937
937
  }
938
- if (opts.authorization_token !== void 0) {
938
+ for (const token of _nullishCoalesce(opts.authorization_token, () => ( []))) {
939
939
  entries.push({
940
940
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
941
941
  encode: (w) => {
942
942
  const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
943
- encodeAuthorizationToken(opts.authorization_token, tmpW);
943
+ encodeAuthorizationToken(token, tmpW);
944
944
  const raw = tmpW.finish();
945
945
  w.writeVarInt(BigInt(raw.byteLength));
946
946
  w.writeBytes(raw);
@@ -1028,7 +1028,10 @@ function decodeSetupOptions(reader, payloadEnd) {
1028
1028
  if (optType === SETUP_OPT_PATH) {
1029
1029
  result.path = textDecoder.decode(bytes);
1030
1030
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
1031
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
1031
+ result.authorization_token = [
1032
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1033
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes))
1034
+ ];
1032
1035
  } else if (optType === SETUP_OPT_AUTHORITY) {
1033
1036
  result.authority = textDecoder.decode(bytes);
1034
1037
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -1138,12 +1141,12 @@ function encodeParams(params, writer) {
1138
1141
  encode: (w) => w.writeVarInt(params.object_delivery_timeout)
1139
1142
  });
1140
1143
  }
1141
- if (params.authorization_token !== void 0) {
1144
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
1142
1145
  entries.push({
1143
1146
  type: PARAM_AUTHORIZATION_TOKEN,
1144
1147
  encode: (w) => {
1145
1148
  const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
1146
- encodeAuthorizationToken(params.authorization_token, tmpW);
1149
+ encodeAuthorizationToken(token, tmpW);
1147
1150
  const raw = tmpW.finish();
1148
1151
  w.writeVarInt(BigInt(raw.byteLength));
1149
1152
  w.writeBytes(raw);
@@ -1283,7 +1286,10 @@ function decodeParams(reader, messageType) {
1283
1286
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1284
1287
  const length = Number(reader.readVarInt());
1285
1288
  const bytes = reader.readBytes(length);
1286
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
1289
+ result.authorization_token = [
1290
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1291
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes))
1292
+ ];
1287
1293
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
1288
1294
  result.rendezvous_timeout = reader.readVarInt();
1289
1295
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {