@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
@@ -24,7 +24,7 @@ export interface Draft11SetupParams {
24
24
 
25
25
  // Version-specific parameters — even/odd convention
26
26
  export interface Draft11Params {
27
- authorization_token?: AuthorizationToken // 0x01 odd
27
+ authorization_token?: readonly AuthorizationToken[] // 0x01 odd
28
28
  delivery_timeout?: bigint // 0x02 even
29
29
  max_cache_duration?: bigint // 0x04 even
30
30
  unknown?: UnknownParam[]
@@ -73,7 +73,7 @@ function encodeSetupParams(params: Draft12SetupParams, w: BufferWriter): void {
73
73
  let count = 0
74
74
  if (params.path !== undefined) count++
75
75
  if (params.max_request_id !== undefined) count++
76
- if (params.authorization_token !== undefined) count++
76
+ count += params.authorization_token?.length ?? 0
77
77
  if (params.unknown) count += params.unknown.length
78
78
 
79
79
  w.writeVarInt(count)
@@ -88,9 +88,9 @@ function encodeSetupParams(params: Draft12SetupParams, w: BufferWriter): void {
88
88
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID)
89
89
  w.writeVarInt(params.max_request_id)
90
90
  }
91
- if (params.authorization_token !== undefined) {
91
+ for (const token of params.authorization_token ?? []) {
92
92
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
93
- const at = params.authorization_token
93
+ const at = token
94
94
  const tmpW = new BufferWriter(64)
95
95
  tmpW.writeVarInt(at.alias_type)
96
96
  tmpW.writeVarInt(at.token_type)
@@ -148,11 +148,14 @@ function decodeSetupParams(r: BufferReader): Draft12SetupParams {
148
148
  const token_type = r.readVarInt()
149
149
  const tokenBytesLen = length - (r.offset - startOff)
150
150
  const tokenBytes = r.readBytes(tokenBytesLen)
151
- result.authorization_token = {
152
- alias_type,
153
- token_type,
154
- token_value: tokenBytes,
155
- }
151
+ result.authorization_token = [
152
+ ...(result.authorization_token ?? []),
153
+ {
154
+ alias_type,
155
+ token_type,
156
+ token_value: tokenBytes,
157
+ },
158
+ ]
156
159
  } else {
157
160
  const bytes = r.readBytes(length)
158
161
  unknown.push({
@@ -174,7 +177,7 @@ function decodeSetupParams(r: BufferReader): Draft12SetupParams {
174
177
  function encodeParams(params: Draft12Params, w: BufferWriter): void {
175
178
  let count = params.unknown ? params.unknown.length : 0
176
179
  if (params.delivery_timeout !== undefined) count++
177
- if (params.authorization_token !== undefined) count++
180
+ count += params.authorization_token?.length ?? 0
178
181
  if (params.max_cache_duration !== undefined) count++
179
182
  w.writeVarInt(count)
180
183
 
@@ -183,10 +186,10 @@ function encodeParams(params: Draft12Params, w: BufferWriter): void {
183
186
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT)
184
187
  w.writeVarInt(params.delivery_timeout)
185
188
  }
186
- if (params.authorization_token !== undefined) {
189
+ for (const token of params.authorization_token ?? []) {
187
190
  // AUTHORIZATION_TOKEN = 0x03 (odd → length-prefixed)
188
191
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
189
- const at = params.authorization_token
192
+ const at = token
190
193
  const tmpW = new BufferWriter(64)
191
194
  tmpW.writeVarInt(at.alias_type)
192
195
  tmpW.writeVarInt(at.token_type)
@@ -254,11 +257,14 @@ function decodeParams(r: BufferReader): Draft12Params {
254
257
  const token_type = r.readVarInt()
255
258
  const tokenBytesLen = length - (r.offset - startOff)
256
259
  const tokenBytes = r.readBytes(tokenBytesLen)
257
- result.authorization_token = {
258
- alias_type,
259
- token_type,
260
- token_value: tokenBytes,
261
- }
260
+ result.authorization_token = [
261
+ ...(result.authorization_token ?? []),
262
+ {
263
+ alias_type,
264
+ token_type,
265
+ token_value: tokenBytes,
266
+ },
267
+ ]
262
268
  } else {
263
269
  const bytes = r.readBytes(length)
264
270
  unknown.push({
@@ -19,14 +19,14 @@ export interface AuthorizationToken {
19
19
  export interface Draft12SetupParams {
20
20
  path?: string // 0x01 odd
21
21
  max_request_id?: bigint // 0x02 even
22
- authorization_token?: AuthorizationToken // 0x03 odd
22
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
23
23
  unknown?: UnknownParam[]
24
24
  }
25
25
 
26
26
  // Version-specific parameters — even/odd convention
27
27
  export interface Draft12Params {
28
28
  delivery_timeout?: bigint // 0x02 even
29
- authorization_token?: AuthorizationToken // 0x03 odd
29
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
30
30
  max_cache_duration?: bigint // 0x04 even
31
31
  unknown?: UnknownParam[]
32
32
  }
@@ -115,7 +115,7 @@ function encodeSetupParams(params: Draft13SetupParams, w: BufferWriter): void {
115
115
  let count = 0
116
116
  if (params.path !== undefined) count++
117
117
  if (params.max_request_id !== undefined) count++
118
- if (params.authorization_token !== undefined) count++
118
+ count += params.authorization_token?.length ?? 0
119
119
  if (params.max_auth_token_cache_size !== undefined) count++
120
120
  if (params.unknown) count += params.unknown.length
121
121
 
@@ -131,9 +131,9 @@ function encodeSetupParams(params: Draft13SetupParams, w: BufferWriter): void {
131
131
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID)
132
132
  w.writeVarInt(params.max_request_id)
133
133
  }
134
- if (params.authorization_token !== undefined) {
134
+ for (const token of params.authorization_token ?? []) {
135
135
  w.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN)
136
- encodeAuthorizationToken(params.authorization_token, w)
136
+ encodeAuthorizationToken(token, w)
137
137
  }
138
138
  if (params.max_auth_token_cache_size !== undefined) {
139
139
  w.writeVarInt(SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE)
@@ -185,7 +185,10 @@ function decodeSetupParams(r: BufferReader): Draft13SetupParams {
185
185
  const bytes = r.readBytes(length)
186
186
  result.path = textDecoder.decode(bytes)
187
187
  } else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
188
- result.authorization_token = decodeAuthorizationToken(r, length)
188
+ result.authorization_token = [
189
+ ...(result.authorization_token ?? []),
190
+ decodeAuthorizationToken(r, length),
191
+ ]
189
192
  } else {
190
193
  const bytes = r.readBytes(length)
191
194
  unknown.push({
@@ -207,7 +210,7 @@ function decodeSetupParams(r: BufferReader): Draft13SetupParams {
207
210
  function encodeParams(params: Draft13Params, w: BufferWriter): void {
208
211
  let count = params.unknown ? params.unknown.length : 0
209
212
  if (params.delivery_timeout !== undefined) count++
210
- if (params.authorization_token !== undefined) count++
213
+ count += params.authorization_token?.length ?? 0
211
214
  if (params.max_cache_duration !== undefined) count++
212
215
  w.writeVarInt(count)
213
216
 
@@ -216,10 +219,10 @@ function encodeParams(params: Draft13Params, w: BufferWriter): void {
216
219
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT)
217
220
  w.writeVarInt(params.delivery_timeout)
218
221
  }
219
- if (params.authorization_token !== undefined) {
222
+ for (const token of params.authorization_token ?? []) {
220
223
  // AUTHORIZATION_TOKEN = 0x03 (odd → length-prefixed)
221
224
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
222
- encodeAuthorizationToken(params.authorization_token, w)
225
+ encodeAuthorizationToken(token, w)
223
226
  }
224
227
  if (params.max_cache_duration !== undefined) {
225
228
  // MAX_CACHE_DURATION = 0x04 (even → bare varint)
@@ -275,7 +278,10 @@ function decodeParams(r: BufferReader): Draft13Params {
275
278
  const length = Number(r.readVarInt())
276
279
 
277
280
  if (paramType === PARAM_AUTHORIZATION_TOKEN) {
278
- result.authorization_token = decodeAuthorizationToken(r, length)
281
+ result.authorization_token = [
282
+ ...(result.authorization_token ?? []),
283
+ decodeAuthorizationToken(r, length),
284
+ ]
279
285
  } else {
280
286
  const bytes = r.readBytes(length)
281
287
  unknown.push({
@@ -21,7 +21,7 @@ export interface AuthorizationToken {
21
21
  export interface Draft13SetupParams {
22
22
  path?: string // 0x01 odd
23
23
  max_request_id?: bigint // 0x02 even
24
- authorization_token?: AuthorizationToken // 0x03 odd
24
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
25
25
  max_auth_token_cache_size?: bigint // 0x04 even
26
26
  unknown?: UnknownParam[]
27
27
  }
@@ -29,7 +29,7 @@ export interface Draft13SetupParams {
29
29
  // Version-specific parameters — even/odd convention
30
30
  export interface Draft13Params {
31
31
  delivery_timeout?: bigint // 0x02 even
32
- authorization_token?: AuthorizationToken // 0x03 odd
32
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
33
33
  max_cache_duration?: bigint // 0x04 even
34
34
  unknown?: UnknownParam[]
35
35
  }
@@ -78,7 +78,7 @@ function encodeSetupParams(params: Draft14Params, writer: BufferWriter): void {
78
78
  if (params.role !== undefined) count++
79
79
  if (params.path !== undefined) count++
80
80
  if (params.max_request_id !== undefined) count++
81
- if (params.authorization_token !== undefined) count++
81
+ count += params.authorization_token?.length ?? 0
82
82
  if (params.authority !== undefined) count++
83
83
  if (params.max_auth_token_cache_size !== undefined) count++
84
84
  if (params.moqt_implementation !== undefined) count++
@@ -100,9 +100,9 @@ function encodeSetupParams(params: Draft14Params, writer: BufferWriter): void {
100
100
  writer.writeVarInt(PARAM_MAX_REQUEST_ID)
101
101
  writer.writeVarInt(params.max_request_id)
102
102
  }
103
- if (params.authorization_token !== undefined) {
103
+ for (const token of params.authorization_token ?? []) {
104
104
  writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
105
- const tok = params.authorization_token
105
+ const tok = token
106
106
  const tmpWriter = new BufferWriter(64)
107
107
  tmpWriter.writeVarInt(tok.alias_type)
108
108
  if (tok.token_type !== undefined) {
@@ -187,7 +187,10 @@ function decodeSetupParams(reader: BufferReader): Draft14Params {
187
187
  tok.token_value = new Uint8Array(tokenValue)
188
188
  }
189
189
  }
190
- result.authorization_token = tok as unknown as AuthorizationToken
190
+ result.authorization_token = [
191
+ ...(result.authorization_token ?? []),
192
+ tok as unknown as AuthorizationToken,
193
+ ]
191
194
  } else if (paramType === PARAM_AUTHORITY) {
192
195
  result.authority = textDecoder.decode(bytes)
193
196
  } else if (paramType === PARAM_MOQT_IMPLEMENTATION) {
@@ -209,7 +212,7 @@ function decodeSetupParams(reader: BufferReader): Draft14Params {
209
212
  function encodeMessageParams(params: Draft14Params, writer: BufferWriter): void {
210
213
  let count = 0
211
214
  if (params.delivery_timeout !== undefined) count++
212
- if (params.authorization_token !== undefined) count++
215
+ count += params.authorization_token?.length ?? 0
213
216
  if (params.max_cache_duration !== undefined) count++
214
217
  if (params.unknown) count += params.unknown.length
215
218
 
@@ -219,9 +222,9 @@ function encodeMessageParams(params: Draft14Params, writer: BufferWriter): void
219
222
  writer.writeVarInt(PARAM_DELIVERY_TIMEOUT)
220
223
  writer.writeVarInt(params.delivery_timeout)
221
224
  }
222
- if (params.authorization_token !== undefined) {
225
+ for (const token of params.authorization_token ?? []) {
223
226
  writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
224
- const tok = params.authorization_token
227
+ const tok = token
225
228
  const tmpWriter = new BufferWriter(64)
226
229
  tmpWriter.writeVarInt(tok.alias_type)
227
230
  if (tok.token_type !== undefined) {
@@ -290,7 +293,10 @@ function decodeMessageParams(reader: BufferReader): Draft14Params {
290
293
  tok.token_value = new Uint8Array(tokenValue)
291
294
  }
292
295
  }
293
- result.authorization_token = tok as unknown as AuthorizationToken
296
+ result.authorization_token = [
297
+ ...(result.authorization_token ?? []),
298
+ tok as unknown as AuthorizationToken,
299
+ ]
294
300
  } else {
295
301
  unknown.push({
296
302
  id: `0x${paramType.toString(16)}`,
@@ -47,7 +47,7 @@ export interface Draft14Params {
47
47
  moqt_implementation?: string // 0x07 odd, length-prefixed UTF-8
48
48
  // Message parameters (SUBSCRIBE, PUBLISH, etc.)
49
49
  delivery_timeout?: bigint
50
- authorization_token?: AuthorizationToken
50
+ authorization_token?: readonly AuthorizationToken[]
51
51
  max_cache_duration?: bigint
52
52
  // Unknown / extension
53
53
  unknown?: UnknownParam[]
@@ -63,7 +63,7 @@ function encodeSetupParams(params: Draft15SetupParams, writer: BufferWriter): vo
63
63
  let count = 0
64
64
  if (params.path !== undefined) count++
65
65
  if (params.max_request_id !== undefined) count++
66
- if (params.authorization_token !== undefined) count++
66
+ count += params.authorization_token?.length ?? 0
67
67
  if (params.max_auth_token_cache_size !== undefined) count++
68
68
  if (params.authority !== undefined) count++
69
69
  if (params.moqt_implementation !== undefined) count++
@@ -86,10 +86,10 @@ function encodeSetupParams(params: Draft15SetupParams, writer: BufferWriter): vo
86
86
  }
87
87
 
88
88
  // AUTHORIZATION_TOKEN (0x03) - odd, length-prefixed with nested structure
89
- if (params.authorization_token !== undefined) {
89
+ for (const token of params.authorization_token ?? []) {
90
90
  writer.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN)
91
91
  const tmpW = new BufferWriter(64)
92
- encodeAuthorizationToken(params.authorization_token, tmpW)
92
+ encodeAuthorizationToken(token, tmpW)
93
93
  const raw = tmpW.finish()
94
94
  writer.writeVarInt(raw.byteLength)
95
95
  writer.writeBytes(raw)
@@ -170,7 +170,10 @@ function decodeSetupParams(reader: BufferReader): Draft15SetupParams {
170
170
  if (paramType === SETUP_PARAM_PATH) {
171
171
  result.path = textDecoder.decode(bytes)
172
172
  } else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
173
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
173
+ result.authorization_token = [
174
+ ...(result.authorization_token ?? []),
175
+ decodeAuthorizationToken(new BufferReader(bytes)),
176
+ ]
174
177
  } else if (paramType === SETUP_PARAM_AUTHORITY) {
175
178
  result.authority = textDecoder.decode(bytes)
176
179
  } else if (paramType === SETUP_PARAM_MOQT_IMPLEMENTATION) {
@@ -242,7 +245,7 @@ function encodeParams(params: Draft15Params, writer: BufferWriter): void {
242
245
  // Count known + unknown params
243
246
  let count = params.unknown ? params.unknown.length : 0
244
247
  if (params.delivery_timeout !== undefined) count++
245
- if (params.authorization_token !== undefined) count++
248
+ count += params.authorization_token?.length ?? 0
246
249
  if (params.max_cache_duration !== undefined) count++
247
250
  if (params.expires !== undefined) count++
248
251
  if (params.largest_object !== undefined) count++
@@ -260,10 +263,10 @@ function encodeParams(params: Draft15Params, writer: BufferWriter): void {
260
263
  writer.writeVarInt(PARAM_DELIVERY_TIMEOUT)
261
264
  writer.writeVarInt(params.delivery_timeout)
262
265
  }
263
- if (params.authorization_token !== undefined) {
266
+ for (const token of params.authorization_token ?? []) {
264
267
  writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
265
268
  const tmpW = new BufferWriter(64)
266
- encodeAuthorizationToken(params.authorization_token, tmpW)
269
+ encodeAuthorizationToken(token, tmpW)
267
270
  const raw = tmpW.finish()
268
271
  writer.writeVarInt(raw.byteLength)
269
272
  writer.writeBytes(raw)
@@ -358,7 +361,10 @@ function decodeParams(reader: BufferReader): Draft15Params {
358
361
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
359
362
  const length = Number(reader.readVarInt())
360
363
  const tokenBytes = reader.readBytes(length)
361
- result.authorization_token = decodeAuthorizationToken(new BufferReader(tokenBytes))
364
+ result.authorization_token = [
365
+ ...(result.authorization_token ?? []),
366
+ decodeAuthorizationToken(new BufferReader(tokenBytes)),
367
+ ]
362
368
  } else if (paramType === PARAM_MAX_CACHE_DURATION) {
363
369
  result.max_cache_duration = reader.readVarInt()
364
370
  } else if (paramType === PARAM_EXPIRES) {
@@ -20,7 +20,7 @@ export interface AuthorizationToken {
20
20
  export interface Draft15SetupParams {
21
21
  path?: string // 0x01 odd
22
22
  max_request_id?: bigint // 0x02 even
23
- authorization_token?: AuthorizationToken // 0x03 odd (length-prefixed, nested)
23
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd (length-prefixed, nested)
24
24
  max_auth_token_cache_size?: bigint // 0x04 even
25
25
  authority?: string // 0x05 odd
26
26
  moqt_implementation?: string // 0x07 odd
@@ -44,7 +44,7 @@ export interface LargestObject {
44
44
  // Version-specific parameters (well-known + unknown)
45
45
  export interface Draft15Params {
46
46
  delivery_timeout?: bigint // 0x02 even
47
- authorization_token?: AuthorizationToken // 0x03 odd (length-prefixed, nested)
47
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd (length-prefixed, nested)
48
48
  max_cache_duration?: bigint // 0x04 even
49
49
  expires?: bigint // 0x08 even
50
50
  largest_object?: LargestObject // 0x09 odd (length-prefixed)
@@ -65,7 +65,7 @@ function encodeSetupParams(params: Draft16SetupParams, writer: BufferWriter): vo
65
65
  let count = 0
66
66
  if (params.path !== undefined) count++
67
67
  if (params.max_request_id !== undefined) count++
68
- if (params.authorization_token !== undefined) count++
68
+ count += params.authorization_token?.length ?? 0
69
69
  if (params.max_auth_token_cache_size !== undefined) count++
70
70
  if (params.authority !== undefined) count++
71
71
  if (params.moqt_implementation !== undefined) count++
@@ -88,10 +88,10 @@ function encodeSetupParams(params: Draft16SetupParams, writer: BufferWriter): vo
88
88
  }
89
89
 
90
90
  // AUTHORIZATION_TOKEN (0x03) - odd, length-prefixed with nested structure
91
- if (params.authorization_token !== undefined) {
91
+ for (const token of params.authorization_token ?? []) {
92
92
  writer.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN)
93
93
  const tmpW = new BufferWriter(64)
94
- encodeAuthorizationToken(params.authorization_token, tmpW)
94
+ encodeAuthorizationToken(token, tmpW)
95
95
  const raw = tmpW.finish()
96
96
  writer.writeVarInt(raw.byteLength)
97
97
  writer.writeBytes(raw)
@@ -168,7 +168,10 @@ function decodeSetupParams(reader: BufferReader): Draft16SetupParams {
168
168
  if (paramType === SETUP_PARAM_PATH) {
169
169
  result.path = textDecoder.decode(bytes)
170
170
  } else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
171
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
171
+ result.authorization_token = [
172
+ ...(result.authorization_token ?? []),
173
+ decodeAuthorizationToken(new BufferReader(bytes)),
174
+ ]
172
175
  } else if (paramType === SETUP_PARAM_AUTHORITY) {
173
176
  result.authority = textDecoder.decode(bytes)
174
177
  } else if (paramType === SETUP_PARAM_MOQT_IMPLEMENTATION) {
@@ -324,12 +327,12 @@ function encodeParams(params: Draft16Params, writer: BufferWriter): void {
324
327
  encode: (w) => w.writeVarInt(params.delivery_timeout!),
325
328
  })
326
329
  }
327
- if (params.authorization_token !== undefined) {
330
+ for (const token of params.authorization_token ?? []) {
328
331
  entries.push({
329
332
  type: PARAM_AUTHORIZATION_TOKEN,
330
333
  encode: (w) => {
331
334
  const tmpW = new BufferWriter(64)
332
- encodeAuthorizationToken(params.authorization_token!, tmpW)
335
+ encodeAuthorizationToken(token, tmpW)
333
336
  const raw = tmpW.finish()
334
337
  w.writeVarInt(raw.byteLength)
335
338
  w.writeBytes(raw)
@@ -457,7 +460,10 @@ function decodeParams(reader: BufferReader): Draft16Params {
457
460
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
458
461
  const length = Number(reader.readVarInt())
459
462
  const tokenBytes = reader.readBytes(length)
460
- result.authorization_token = decodeAuthorizationToken(new BufferReader(tokenBytes))
463
+ result.authorization_token = [
464
+ ...(result.authorization_token ?? []),
465
+ decodeAuthorizationToken(new BufferReader(tokenBytes)),
466
+ ]
461
467
  } else if (paramType === PARAM_MAX_CACHE_DURATION) {
462
468
  result.max_cache_duration = reader.readVarInt()
463
469
  } else if (paramType === PARAM_EXPIRES) {
@@ -20,7 +20,7 @@ export interface AuthorizationToken {
20
20
  export interface Draft16SetupParams {
21
21
  path?: string // 0x01 odd
22
22
  max_request_id?: bigint // 0x02 even
23
- authorization_token?: AuthorizationToken // 0x03 odd
23
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
24
24
  max_auth_token_cache_size?: bigint // 0x04 even
25
25
  authority?: string // 0x05 odd
26
26
  moqt_implementation?: string // 0x07 odd
@@ -52,7 +52,7 @@ export interface Draft16TrackExtensions {
52
52
  // Version-specific parameters (well-known + unknown)
53
53
  export interface Draft16Params {
54
54
  delivery_timeout?: bigint // 0x02 even
55
- authorization_token?: AuthorizationToken // 0x03 odd
55
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
56
56
  max_cache_duration?: bigint // 0x04 even
57
57
  expires?: bigint // 0x08 even
58
58
  largest_object?: LargestObject // 0x09 odd (length-prefixed)
@@ -68,12 +68,12 @@ function encodeSetupOptions(opts: Draft17SetupOptions, writer: BufferWriter): vo
68
68
  },
69
69
  })
70
70
  }
71
- if (opts.authorization_token !== undefined) {
71
+ for (const token of opts.authorization_token ?? []) {
72
72
  entries.push({
73
73
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
74
74
  encode: (w) => {
75
75
  const tmpW = new BufferWriter(64)
76
- encodeAuthorizationToken(opts.authorization_token!, tmpW)
76
+ encodeAuthorizationToken(token, tmpW)
77
77
  const raw = tmpW.finish()
78
78
  w.writeVarInt(BigInt(raw.byteLength))
79
79
  w.writeBytes(raw)
@@ -168,7 +168,10 @@ function decodeSetupOptions(reader: BufferReader, payloadEnd: number): Draft17Se
168
168
  if (optType === SETUP_OPT_PATH) {
169
169
  result.path = textDecoder.decode(bytes)
170
170
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
171
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
171
+ result.authorization_token = [
172
+ ...(result.authorization_token ?? []),
173
+ decodeAuthorizationToken(new BufferReader(bytes)),
174
+ ]
172
175
  } else if (optType === SETUP_OPT_AUTHORITY) {
173
176
  result.authority = textDecoder.decode(bytes)
174
177
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -283,12 +286,12 @@ function encodeParams(params: Draft17Params, writer: BufferWriter): void {
283
286
  encode: (w) => w.writeVarInt(params.delivery_timeout!),
284
287
  })
285
288
  }
286
- if (params.authorization_token !== undefined) {
289
+ for (const token of params.authorization_token ?? []) {
287
290
  entries.push({
288
291
  type: PARAM_AUTHORIZATION_TOKEN,
289
292
  encode: (w) => {
290
293
  const tmpW = new BufferWriter(64)
291
- encodeAuthorizationToken(params.authorization_token!, tmpW)
294
+ encodeAuthorizationToken(token, tmpW)
292
295
  const raw = tmpW.finish()
293
296
  w.writeVarInt(BigInt(raw.byteLength))
294
297
  w.writeBytes(raw)
@@ -411,7 +414,10 @@ function decodeParams(reader: BufferReader, messageType: string): Draft17Params
411
414
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
412
415
  const length = Number(reader.readVarInt())
413
416
  const bytes = reader.readBytes(length)
414
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
417
+ result.authorization_token = [
418
+ ...(result.authorization_token ?? []),
419
+ decodeAuthorizationToken(new BufferReader(bytes)),
420
+ ]
415
421
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
416
422
  result.rendezvous_timeout = reader.readVarInt()
417
423
  } else if (paramType === PARAM_EXPIRES) {
@@ -18,7 +18,7 @@ export interface AuthorizationToken {
18
18
  // Setup options (KVP encoding, no count prefix)
19
19
  export interface Draft17SetupOptions {
20
20
  path?: string // 0x01 odd
21
- authorization_token?: AuthorizationToken // 0x03 odd
21
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
22
22
  max_auth_token_cache_size?: bigint // 0x04 even
23
23
  authority?: string // 0x05 odd
24
24
  moqt_implementation?: string // 0x07 odd
@@ -42,7 +42,7 @@ export interface LargestObject {
42
42
  // Version-specific parameters (delta-encoded types, count-prefixed)
43
43
  export interface Draft17Params {
44
44
  delivery_timeout?: bigint // 0x02 varint
45
- authorization_token?: AuthorizationToken // 0x03 length-prefixed nested
45
+ authorization_token?: readonly AuthorizationToken[] // 0x03 length-prefixed nested
46
46
  rendezvous_timeout?: bigint // 0x04 varint
47
47
  expires?: bigint // 0x08 varint
48
48
  largest_object?: LargestObject // 0x09 Location (2 bare varints)
@@ -71,12 +71,12 @@ function encodeSetupOptions(opts: Draft18SetupOptions, writer: BufferWriter): vo
71
71
  },
72
72
  })
73
73
  }
74
- if (opts.authorization_token !== undefined) {
74
+ for (const token of opts.authorization_token ?? []) {
75
75
  entries.push({
76
76
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
77
77
  encode: (w) => {
78
78
  const tmpW = new BufferWriter(64)
79
- encodeAuthorizationToken(opts.authorization_token!, tmpW)
79
+ encodeAuthorizationToken(token, tmpW)
80
80
  const raw = tmpW.finish()
81
81
  w.writeVarInt(BigInt(raw.byteLength))
82
82
  w.writeBytes(raw)
@@ -171,7 +171,10 @@ function decodeSetupOptions(reader: BufferReader, payloadEnd: number): Draft18Se
171
171
  if (optType === SETUP_OPT_PATH) {
172
172
  result.path = textDecoder.decode(bytes)
173
173
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
174
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
174
+ result.authorization_token = [
175
+ ...(result.authorization_token ?? []),
176
+ decodeAuthorizationToken(new BufferReader(bytes)),
177
+ ]
175
178
  } else if (optType === SETUP_OPT_AUTHORITY) {
176
179
  result.authority = textDecoder.decode(bytes)
177
180
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -315,12 +318,12 @@ function encodeParams(params: Draft18Params, writer: BufferWriter): void {
315
318
  encode: (w) => w.writeVarInt(params.object_delivery_timeout!),
316
319
  })
317
320
  }
318
- if (params.authorization_token !== undefined) {
321
+ for (const token of params.authorization_token ?? []) {
319
322
  entries.push({
320
323
  type: PARAM_AUTHORIZATION_TOKEN,
321
324
  encode: (w) => {
322
325
  const tmpW = new BufferWriter(64)
323
- encodeAuthorizationToken(params.authorization_token!, tmpW)
326
+ encodeAuthorizationToken(token, tmpW)
324
327
  const raw = tmpW.finish()
325
328
  w.writeVarInt(BigInt(raw.byteLength))
326
329
  w.writeBytes(raw)
@@ -469,7 +472,10 @@ function decodeParams(reader: BufferReader, messageType: string): Draft18Params
469
472
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
470
473
  const length = Number(reader.readVarInt())
471
474
  const bytes = reader.readBytes(length)
472
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
475
+ result.authorization_token = [
476
+ ...(result.authorization_token ?? []),
477
+ decodeAuthorizationToken(new BufferReader(bytes)),
478
+ ]
473
479
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
474
480
  result.rendezvous_timeout = reader.readVarInt()
475
481
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
@@ -18,7 +18,7 @@ export interface AuthorizationToken {
18
18
  // Setup options (KVP encoding, no count prefix)
19
19
  export interface Draft18SetupOptions {
20
20
  path?: string // 0x01 odd
21
- authorization_token?: AuthorizationToken // 0x03 odd
21
+ authorization_token?: readonly AuthorizationToken[] // 0x03 odd
22
22
  max_auth_token_cache_size?: bigint // 0x04 even
23
23
  authority?: string // 0x05 odd
24
24
  moqt_implementation?: string // 0x07 odd
@@ -42,7 +42,7 @@ export interface LargestObject {
42
42
  // Version-specific parameters (delta-encoded types, count-prefixed)
43
43
  export interface Draft18Params {
44
44
  object_delivery_timeout?: bigint // 0x02 varint (renamed from delivery_timeout in draft-17)
45
- authorization_token?: AuthorizationToken // 0x03 length-prefixed nested
45
+ authorization_token?: readonly AuthorizationToken[] // 0x03 length-prefixed nested
46
46
  rendezvous_timeout?: bigint // 0x04 varint
47
47
  subgroup_delivery_timeout?: bigint // 0x06 varint (NEW in draft-18)
48
48
  expires?: bigint // 0x08 varint