@moqtap/codec 0.9.0 → 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 (148) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/{chunk-KCH4BQXK.cjs → chunk-AQ445VV7.cjs} +15 -9
  3. package/dist/{chunk-UZO5Z2XT.cjs → chunk-BIBMDTU5.cjs} +12 -6
  4. package/dist/{chunk-23KRITJ6.js → chunk-BX2N7TZM.js} +14 -8
  5. package/dist/{chunk-XQGEOFGE.js → chunk-CF5DDD3Q.js} +14 -8
  6. package/dist/{chunk-YJGOD3Y4.js → chunk-FT3HDNIB.js} +33 -21
  7. package/dist/{chunk-TMXRYOBS.js → chunk-G53WYUXL.js} +13 -7
  8. package/dist/{chunk-JKMYAUGY.js → chunk-K2B3OVFK.js} +11 -8
  9. package/dist/{chunk-Q7NSUXXB.js → chunk-KGDVC4O6.js} +33 -21
  10. package/dist/{chunk-TVSFDQYE.cjs → chunk-KTNERCTZ.cjs} +33 -21
  11. package/dist/{chunk-H6DTAIWM.js → chunk-L5DRACXS.js} +22 -16
  12. package/dist/{chunk-UA5XFP4O.cjs → chunk-OUNN4IQB.cjs} +14 -8
  13. package/dist/{chunk-NH4L6NIY.js → chunk-OZRK73NQ.js} +12 -6
  14. package/dist/{chunk-PU2KV7VP.cjs → chunk-RYKQXBG6.cjs} +12 -6
  15. package/dist/{chunk-EVCPBFSR.cjs → chunk-SDJTSMOW.cjs} +23 -17
  16. package/dist/{chunk-MAXEHYVB.cjs → chunk-T4VWPKDG.cjs} +33 -21
  17. package/dist/{chunk-2XH6PHXR.js → chunk-TSUZ6GJV.js} +12 -6
  18. package/dist/{chunk-QGIHC6BA.cjs → chunk-UKKDOOUO.cjs} +12 -9
  19. package/dist/{chunk-BV6MITLO.js → chunk-WCPENYNE.js} +14 -8
  20. package/dist/{chunk-IADVBKEJ.cjs → chunk-WCTMPDUX.cjs} +15 -9
  21. package/dist/{chunk-7ENEWAMZ.cjs → chunk-XCRCAUGI.cjs} +15 -9
  22. package/dist/{codec-BMwgZIgG.d.ts → codec-08ZOr5wI.d.ts} +1 -1
  23. package/dist/{codec-DzLvG8Wb.d.cts → codec-Bd60SGKH.d.cts} +1 -1
  24. package/dist/{codec-CgZdadPt.d.cts → codec-BrTi4K7r.d.cts} +1 -1
  25. package/dist/{codec-D4RvFQmu.d.ts → codec-Bux_Q40X.d.ts} +1 -1
  26. package/dist/{codec-vddqy0KY.d.cts → codec-BxQTybUX.d.cts} +1 -1
  27. package/dist/{codec-C006F75E.d.ts → codec-C3mdsGx3.d.ts} +1 -1
  28. package/dist/{codec-CviAa4lp.d.ts → codec-CBdOIfMY.d.ts} +1 -1
  29. package/dist/{codec-Bym-K2q2.d.cts → codec-CFWu5KVT.d.cts} +1 -1
  30. package/dist/{codec-DJmqoIsp.d.cts → codec-CWnf8mn_.d.cts} +1 -1
  31. package/dist/{codec-BQa6Qsav.d.ts → codec-Cm3D261p.d.ts} +1 -1
  32. package/dist/{codec-C5evFHL-.d.ts → codec-CwZ6OCPP.d.ts} +1 -1
  33. package/dist/{codec-DchsPfr3.d.cts → codec-Czejcmxr.d.cts} +1 -1
  34. package/dist/{codec-C_xxsbKy.d.cts → codec-DNmiG2e0.d.cts} +1 -1
  35. package/dist/{codec-O-1Js7h4.d.ts → codec-DOmAmFkI.d.ts} +1 -1
  36. package/dist/{codec-Cl73EfRW.d.ts → codec-DaXjRrOV.d.ts} +1 -1
  37. package/dist/{codec-DAyiF5sq.d.cts → codec-EvybrBuY.d.cts} +1 -1
  38. package/dist/{codec-CA6nbbEk.d.ts → codec-alVA27Uc.d.ts} +1 -1
  39. package/dist/{codec-CSBFdPgP.d.cts → codec-f7vxeVIS.d.cts} +1 -1
  40. package/dist/{codec-BKsVu3Fr.d.ts → codec-gl4_QEva.d.ts} +1 -1
  41. package/dist/{codec-CtvFK4aV.d.cts → codec-guzqtfMk.d.cts} +1 -1
  42. package/dist/draft11-session.d.cts +1 -1
  43. package/dist/draft11-session.d.ts +1 -1
  44. package/dist/draft11.cjs +2 -2
  45. package/dist/draft11.d.cts +3 -3
  46. package/dist/draft11.d.ts +3 -3
  47. package/dist/draft11.js +1 -1
  48. package/dist/draft12-session.d.cts +1 -1
  49. package/dist/draft12-session.d.ts +1 -1
  50. package/dist/draft12.cjs +2 -2
  51. package/dist/draft12.d.cts +3 -3
  52. package/dist/draft12.d.ts +3 -3
  53. package/dist/draft12.js +1 -1
  54. package/dist/draft13-session.d.cts +1 -1
  55. package/dist/draft13-session.d.ts +1 -1
  56. package/dist/draft13.cjs +2 -2
  57. package/dist/draft13.d.cts +3 -3
  58. package/dist/draft13.d.ts +3 -3
  59. package/dist/draft13.js +1 -1
  60. package/dist/draft14-session.d.cts +1 -1
  61. package/dist/draft14-session.d.ts +1 -1
  62. package/dist/draft14.cjs +2 -2
  63. package/dist/draft14.d.cts +3 -3
  64. package/dist/draft14.d.ts +3 -3
  65. package/dist/draft14.js +1 -1
  66. package/dist/draft15-session.d.cts +1 -1
  67. package/dist/draft15-session.d.ts +1 -1
  68. package/dist/draft15.cjs +2 -2
  69. package/dist/draft15.d.cts +3 -3
  70. package/dist/draft15.d.ts +3 -3
  71. package/dist/draft15.js +1 -1
  72. package/dist/draft16-session.d.cts +1 -1
  73. package/dist/draft16-session.d.ts +1 -1
  74. package/dist/draft16.cjs +2 -2
  75. package/dist/draft16.d.cts +3 -3
  76. package/dist/draft16.d.ts +3 -3
  77. package/dist/draft16.js +1 -1
  78. package/dist/draft17-session.d.cts +1 -1
  79. package/dist/draft17-session.d.ts +1 -1
  80. package/dist/draft17.cjs +2 -2
  81. package/dist/draft17.d.cts +3 -3
  82. package/dist/draft17.d.ts +3 -3
  83. package/dist/draft17.js +1 -1
  84. package/dist/draft18-session.d.cts +1 -1
  85. package/dist/draft18-session.d.ts +1 -1
  86. package/dist/draft18.cjs +2 -2
  87. package/dist/draft18.d.cts +3 -3
  88. package/dist/draft18.d.ts +3 -3
  89. package/dist/draft18.js +1 -1
  90. package/dist/draft19-session.d.cts +1 -1
  91. package/dist/draft19-session.d.ts +1 -1
  92. package/dist/draft19.cjs +2 -2
  93. package/dist/draft19.d.cts +3 -3
  94. package/dist/draft19.d.ts +3 -3
  95. package/dist/draft19.js +1 -1
  96. package/dist/draft20-session.d.cts +1 -1
  97. package/dist/draft20-session.d.ts +1 -1
  98. package/dist/draft20.cjs +2 -2
  99. package/dist/draft20.d.cts +3 -3
  100. package/dist/draft20.d.ts +3 -3
  101. package/dist/draft20.js +1 -1
  102. package/dist/index.cjs +20 -20
  103. package/dist/index.d.cts +20 -20
  104. package/dist/index.d.ts +20 -20
  105. package/dist/index.js +10 -10
  106. package/dist/session.d.cts +10 -10
  107. package/dist/session.d.ts +10 -10
  108. package/dist/{types-Cqp10JtB.d.cts → types-Bg86GGVZ.d.cts} +2 -2
  109. package/dist/{types-Cqp10JtB.d.ts → types-Bg86GGVZ.d.ts} +2 -2
  110. package/dist/{types-zHgCS6o5.d.cts → types-C1rxh-id.d.cts} +7 -7
  111. package/dist/{types-zHgCS6o5.d.ts → types-C1rxh-id.d.ts} +7 -7
  112. package/dist/{types-Bio-91Rt.d.cts → types-CI_SX4Xe.d.cts} +2 -2
  113. package/dist/{types-Bio-91Rt.d.ts → types-CI_SX4Xe.d.ts} +2 -2
  114. package/dist/{types-CWCQwuvy.d.cts → types-CY-QWxd-.d.cts} +11 -11
  115. package/dist/{types-CWCQwuvy.d.ts → types-CY-QWxd-.d.ts} +11 -11
  116. package/dist/{types-Cm9fjeYC.d.cts → types-CZTzbIzQ.d.cts} +2 -2
  117. package/dist/{types-Cm9fjeYC.d.ts → types-CZTzbIzQ.d.ts} +2 -2
  118. package/dist/{types-HI_bbXka.d.cts → types-CmqT0jUf.d.cts} +1 -1
  119. package/dist/{types-HI_bbXka.d.ts → types-CmqT0jUf.d.ts} +1 -1
  120. package/dist/{types-Ck45Ex5S.d.cts → types-D0kTgUuL.d.cts} +1 -1
  121. package/dist/{types-Ck45Ex5S.d.ts → types-D0kTgUuL.d.ts} +1 -1
  122. package/dist/{types-D9eiB_9A.d.cts → types-D4bmW8rY.d.cts} +2 -2
  123. package/dist/{types-D9eiB_9A.d.ts → types-D4bmW8rY.d.ts} +2 -2
  124. package/dist/{types-CXlSn0I9.d.cts → types-DjxexghA.d.cts} +2 -2
  125. package/dist/{types-CXlSn0I9.d.ts → types-DjxexghA.d.ts} +2 -2
  126. package/dist/{types-CPaYBsMG.d.cts → types-pShrs3fN.d.cts} +2 -2
  127. package/dist/{types-CPaYBsMG.d.ts → types-pShrs3fN.d.ts} +2 -2
  128. package/package.json +2 -2
  129. package/src/drafts/draft11/codec.ts +11 -8
  130. package/src/drafts/draft11/types.ts +1 -1
  131. package/src/drafts/draft12/codec.ts +22 -16
  132. package/src/drafts/draft12/types.ts +2 -2
  133. package/src/drafts/draft13/codec.ts +14 -8
  134. package/src/drafts/draft13/types.ts +2 -2
  135. package/src/drafts/draft14/codec.ts +14 -8
  136. package/src/drafts/draft14/types.ts +1 -1
  137. package/src/drafts/draft15/codec.ts +14 -8
  138. package/src/drafts/draft15/types.ts +2 -2
  139. package/src/drafts/draft16/codec.ts +13 -7
  140. package/src/drafts/draft16/types.ts +2 -2
  141. package/src/drafts/draft17/codec.ts +12 -6
  142. package/src/drafts/draft17/types.ts +2 -2
  143. package/src/drafts/draft18/codec.ts +12 -6
  144. package/src/drafts/draft18/types.ts +2 -2
  145. package/src/drafts/draft19/codec.ts +33 -21
  146. package/src/drafts/draft19/types.ts +10 -7
  147. package/src/drafts/draft20/codec.ts +33 -21
  148. package/src/drafts/draft20/types.ts +17 -11
@@ -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
@@ -75,12 +75,12 @@ function encodeSetupOptions(opts: Draft19SetupOptions, writer: BufferWriter): vo
75
75
  },
76
76
  })
77
77
  }
78
- if (opts.authorization_token !== undefined) {
78
+ for (const token of opts.authorization_token ?? []) {
79
79
  entries.push({
80
80
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
81
81
  encode: (w) => {
82
82
  const tmpW = new BufferWriter(64)
83
- encodeAuthorizationToken(opts.authorization_token!, tmpW)
83
+ encodeAuthorizationToken(token, tmpW)
84
84
  const raw = tmpW.finish()
85
85
  w.writeVarInt(BigInt(raw.byteLength))
86
86
  w.writeBytes(raw)
@@ -191,7 +191,10 @@ function decodeSetupOptions(reader: BufferReader, payloadEnd: number): Draft19Se
191
191
  if (optType === SETUP_OPT_PATH) {
192
192
  result.path = textDecoder.decode(bytes)
193
193
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
194
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
194
+ result.authorization_token = [
195
+ ...(result.authorization_token ?? []),
196
+ decodeAuthorizationToken(new BufferReader(bytes)),
197
+ ]
195
198
  } else if (optType === SETUP_OPT_AUTHORITY) {
196
199
  result.authority = textDecoder.decode(bytes)
197
200
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -403,12 +406,12 @@ function encodeParams(params: Draft19Params, writer: BufferWriter): void {
403
406
  encode: (w) => w.writeVarInt(params.object_delivery_timeout!),
404
407
  })
405
408
  }
406
- if (params.authorization_token !== undefined) {
409
+ for (const token of params.authorization_token ?? []) {
407
410
  entries.push({
408
411
  type: PARAM_AUTHORIZATION_TOKEN,
409
412
  encode: (w) => {
410
413
  const tmpW = new BufferWriter(64)
411
- encodeAuthorizationToken(params.authorization_token!, tmpW)
414
+ encodeAuthorizationToken(token, tmpW)
412
415
  const raw = tmpW.finish()
413
416
  w.writeVarInt(BigInt(raw.byteLength))
414
417
  w.writeBytes(raw)
@@ -489,34 +492,34 @@ function encodeParams(params: Draft19Params, writer: BufferWriter): void {
489
492
  encode: (w) => w.writeUint8(Number(params.group_order!)),
490
493
  })
491
494
  }
492
- if (params.subgroup_filter !== undefined) {
495
+ for (const filter of params.subgroup_filter ?? []) {
493
496
  entries.push({
494
497
  type: PARAM_SUBGROUP_FILTER,
495
- encode: (w) => encodeRangeFilter(params.subgroup_filter!, false, w),
498
+ encode: (w) => encodeRangeFilter(filter, false, w),
496
499
  })
497
500
  }
498
- if (params.objectid_filter !== undefined) {
501
+ for (const filter of params.objectid_filter ?? []) {
499
502
  entries.push({
500
503
  type: PARAM_OBJECTID_FILTER,
501
- encode: (w) => encodeRangeFilter(params.objectid_filter!, false, w),
504
+ encode: (w) => encodeRangeFilter(filter, false, w),
502
505
  })
503
506
  }
504
- if (params.priority_filter !== undefined) {
507
+ for (const filter of params.priority_filter ?? []) {
505
508
  entries.push({
506
509
  type: PARAM_PRIORITY_FILTER,
507
- encode: (w) => encodeRangeFilter(params.priority_filter!, false, w),
510
+ encode: (w) => encodeRangeFilter(filter, false, w),
508
511
  })
509
512
  }
510
- if (params.object_property_filter !== undefined) {
513
+ for (const filter of params.object_property_filter ?? []) {
511
514
  entries.push({
512
515
  type: PARAM_OBJECT_PROPERTY_FILTER,
513
- encode: (w) => encodeRangeFilter(params.object_property_filter!, true, w),
516
+ encode: (w) => encodeRangeFilter(filter, true, w),
514
517
  })
515
518
  }
516
- if (params.track_property_filter !== undefined) {
519
+ for (const filter of params.track_property_filter ?? []) {
517
520
  entries.push({
518
521
  type: PARAM_TRACK_PROPERTY_FILTER,
519
- encode: (w) => encodeRangeFilter(params.track_property_filter!, true, w),
522
+ encode: (w) => encodeRangeFilter(filter, true, w),
520
523
  })
521
524
  }
522
525
  if (params.new_group_request !== undefined) {
@@ -587,7 +590,10 @@ function decodeParams(reader: BufferReader, messageType: string): Draft19Params
587
590
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
588
591
  const length = Number(reader.readVarInt())
589
592
  const bytes = reader.readBytes(length)
590
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
593
+ result.authorization_token = [
594
+ ...(result.authorization_token ?? []),
595
+ decodeAuthorizationToken(new BufferReader(bytes)),
596
+ ]
591
597
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
592
598
  result.rendezvous_timeout = reader.readVarInt()
593
599
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
@@ -632,15 +638,21 @@ function decodeParams(reader: BufferReader, messageType: string): Draft19Params
632
638
  // uint8: single raw byte
633
639
  result.group_order = BigInt(reader.readUint8())
634
640
  } else if (paramType === PARAM_SUBGROUP_FILTER) {
635
- result.subgroup_filter = decodeRangeFilter(reader, false)
641
+ result.subgroup_filter = [...(result.subgroup_filter ?? []), decodeRangeFilter(reader, false)]
636
642
  } else if (paramType === PARAM_OBJECTID_FILTER) {
637
- result.objectid_filter = decodeRangeFilter(reader, false)
643
+ result.objectid_filter = [...(result.objectid_filter ?? []), decodeRangeFilter(reader, false)]
638
644
  } else if (paramType === PARAM_PRIORITY_FILTER) {
639
- result.priority_filter = decodeRangeFilter(reader, false)
645
+ result.priority_filter = [...(result.priority_filter ?? []), decodeRangeFilter(reader, false)]
640
646
  } else if (paramType === PARAM_OBJECT_PROPERTY_FILTER) {
641
- result.object_property_filter = decodeRangeFilter(reader, true)
647
+ result.object_property_filter = [
648
+ ...(result.object_property_filter ?? []),
649
+ decodeRangeFilter(reader, true),
650
+ ]
642
651
  } else if (paramType === PARAM_TRACK_PROPERTY_FILTER) {
643
- result.track_property_filter = decodeRangeFilter(reader, true)
652
+ result.track_property_filter = [
653
+ ...(result.track_property_filter ?? []),
654
+ decodeRangeFilter(reader, true),
655
+ ]
644
656
  } else if (paramType === PARAM_NEW_GROUP_REQUEST) {
645
657
  result.new_group_request = reader.readVarInt()
646
658
  } else if (paramType === PARAM_TRACK_NAMESPACE_PREFIX) {
@@ -18,7 +18,7 @@ export interface AuthorizationToken {
18
18
  // Setup options (KVP encoding, no count prefix)
19
19
  export interface Draft19SetupOptions {
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
  max_filter_ranges?: bigint // 0x06 even (NEW in draft-19)
@@ -58,7 +58,7 @@ export interface LargestObject {
58
58
  // Version-specific parameters (delta-encoded types, count-prefixed)
59
59
  export interface Draft19Params {
60
60
  object_delivery_timeout?: bigint // 0x02 varint (renamed from delivery_timeout in draft-17)
61
- authorization_token?: AuthorizationToken // 0x03 length-prefixed nested
61
+ authorization_token?: readonly AuthorizationToken[] // 0x03 length-prefixed nested
62
62
  rendezvous_timeout?: bigint // 0x04 varint
63
63
  subgroup_delivery_timeout?: bigint // 0x06 varint (NEW in draft-18)
64
64
  expires?: bigint // 0x08 varint
@@ -68,11 +68,14 @@ export interface Draft19Params {
68
68
  subscriber_priority?: bigint // 0x20 uint8
69
69
  location_filter?: LocationFilter // 0x21 length-prefixed (renamed from subscription_filter in draft-19)
70
70
  group_order?: bigint // 0x22 uint8
71
- subgroup_filter?: RangeFilter // 0x25 length-prefixed (NEW in draft-19)
72
- objectid_filter?: RangeFilter // 0x26 length-prefixed (NEW in draft-19)
73
- priority_filter?: RangeFilter // 0x27 length-prefixed (NEW in draft-19)
74
- object_property_filter?: RangeFilter // 0x28 length-prefixed (NEW in draft-19)
75
- track_property_filter?: RangeFilter // 0x29 length-prefixed (NEW in draft-19)
71
+ // Section 5.1.3 permits each of the five more than once in a message: a
72
+ // filter parameter carries one SetID, so two alternatives over the same
73
+ // field need two parameters. A single filter is a one-element list.
74
+ subgroup_filter?: readonly RangeFilter[] // 0x25 length-prefixed (NEW in draft-19)
75
+ objectid_filter?: readonly RangeFilter[] // 0x26 length-prefixed (NEW in draft-19)
76
+ priority_filter?: readonly RangeFilter[] // 0x27 length-prefixed (NEW in draft-19)
77
+ object_property_filter?: readonly RangeFilter[] // 0x28 length-prefixed (NEW in draft-19)
78
+ track_property_filter?: readonly RangeFilter[] // 0x29 length-prefixed (NEW in draft-19)
76
79
  new_group_request?: bigint // 0x32 varint
77
80
  track_namespace_prefix?: string[] // 0x34 Track Namespace encoding (NEW in draft-18)
78
81
  unknown?: UnknownParam[]
@@ -98,12 +98,12 @@ function encodeSetupOptions(opts: Draft20SetupOptions, writer: BufferWriter): vo
98
98
  },
99
99
  })
100
100
  }
101
- if (opts.authorization_token !== undefined) {
101
+ for (const token of opts.authorization_token ?? []) {
102
102
  entries.push({
103
103
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
104
104
  encode: (w) => {
105
105
  const tmpW = new BufferWriter(64)
106
- encodeAuthorizationToken(opts.authorization_token!, tmpW)
106
+ encodeAuthorizationToken(token, tmpW)
107
107
  const raw = tmpW.finish()
108
108
  w.writeVarInt(BigInt(raw.byteLength))
109
109
  w.writeBytes(raw)
@@ -216,7 +216,10 @@ function decodeSetupOptions(reader: BufferReader, payloadEnd: number): Draft20Se
216
216
  if (optType === SETUP_OPT_PATH) {
217
217
  result.path = textDecoder.decode(bytes)
218
218
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
219
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
219
+ result.authorization_token = [
220
+ ...(result.authorization_token ?? []),
221
+ decodeAuthorizationToken(new BufferReader(bytes)),
222
+ ]
220
223
  } else if (optType === SETUP_OPT_AUTHORITY) {
221
224
  result.authority = textDecoder.decode(bytes)
222
225
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -619,12 +622,12 @@ function encodeParams(params: Draft20Params, writer: BufferWriter): void {
619
622
  encode: (w) => w.writeVarInt(params.object_delivery_timeout!),
620
623
  })
621
624
  }
622
- if (params.authorization_token !== undefined) {
625
+ for (const token of params.authorization_token ?? []) {
623
626
  entries.push({
624
627
  type: PARAM_AUTHORIZATION_TOKEN,
625
628
  encode: (w) => {
626
629
  const tmpW = new BufferWriter(64)
627
- encodeAuthorizationToken(params.authorization_token!, tmpW)
630
+ encodeAuthorizationToken(token, tmpW)
628
631
  const raw = tmpW.finish()
629
632
  w.writeVarInt(BigInt(raw.byteLength))
630
633
  w.writeBytes(raw)
@@ -718,34 +721,34 @@ function encodeParams(params: Draft20Params, writer: BufferWriter): void {
718
721
  },
719
722
  })
720
723
  }
721
- if (params.subgroup_filter !== undefined) {
724
+ for (const filter of params.subgroup_filter ?? []) {
722
725
  entries.push({
723
726
  type: PARAM_SUBGROUP_FILTER,
724
- encode: (w) => encodeRangeFilter(params.subgroup_filter!, false, w),
727
+ encode: (w) => encodeRangeFilter(filter, false, w),
725
728
  })
726
729
  }
727
- if (params.objectid_filter !== undefined) {
730
+ for (const filter of params.objectid_filter ?? []) {
728
731
  entries.push({
729
732
  type: PARAM_OBJECTID_FILTER,
730
- encode: (w) => encodeRangeFilter(params.objectid_filter!, false, w),
733
+ encode: (w) => encodeRangeFilter(filter, false, w),
731
734
  })
732
735
  }
733
- if (params.priority_filter !== undefined) {
736
+ for (const filter of params.priority_filter ?? []) {
734
737
  entries.push({
735
738
  type: PARAM_PRIORITY_FILTER,
736
- encode: (w) => encodeRangeFilter(params.priority_filter!, false, w),
739
+ encode: (w) => encodeRangeFilter(filter, false, w),
737
740
  })
738
741
  }
739
- if (params.object_property_filter !== undefined) {
742
+ for (const filter of params.object_property_filter ?? []) {
740
743
  entries.push({
741
744
  type: PARAM_OBJECT_PROPERTY_FILTER,
742
- encode: (w) => encodeRangeFilter(params.object_property_filter!, true, w),
745
+ encode: (w) => encodeRangeFilter(filter, true, w),
743
746
  })
744
747
  }
745
- if (params.track_property_filter !== undefined) {
748
+ for (const filter of params.track_property_filter ?? []) {
746
749
  entries.push({
747
750
  type: PARAM_TRACK_PROPERTY_FILTER,
748
- encode: (w) => encodeRangeFilter(params.track_property_filter!, true, w),
751
+ encode: (w) => encodeRangeFilter(filter, true, w),
749
752
  })
750
753
  }
751
754
  if (params.new_group_request !== undefined) {
@@ -823,7 +826,10 @@ function decodeParams(reader: BufferReader, messageType: string): Draft20Params
823
826
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
824
827
  const length = Number(reader.readVarInt())
825
828
  const bytes = reader.readBytes(length)
826
- result.authorization_token = decodeAuthorizationToken(new BufferReader(bytes))
829
+ result.authorization_token = [
830
+ ...(result.authorization_token ?? []),
831
+ decodeAuthorizationToken(new BufferReader(bytes)),
832
+ ]
827
833
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
828
834
  result.rendezvous_timeout = reader.readVarInt()
829
835
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
@@ -851,15 +857,21 @@ function decodeParams(reader: BufferReader, messageType: string): Draft20Params
851
857
  } else if (paramType === PARAM_FILL_PARAMETERS) {
852
858
  result.fill_parameters = decodeFillParameters(reader)
853
859
  } else if (paramType === PARAM_SUBGROUP_FILTER) {
854
- result.subgroup_filter = decodeRangeFilter(reader, false)
860
+ result.subgroup_filter = [...(result.subgroup_filter ?? []), decodeRangeFilter(reader, false)]
855
861
  } else if (paramType === PARAM_OBJECTID_FILTER) {
856
- result.objectid_filter = decodeRangeFilter(reader, false)
862
+ result.objectid_filter = [...(result.objectid_filter ?? []), decodeRangeFilter(reader, false)]
857
863
  } else if (paramType === PARAM_PRIORITY_FILTER) {
858
- result.priority_filter = decodeRangeFilter(reader, false)
864
+ result.priority_filter = [...(result.priority_filter ?? []), decodeRangeFilter(reader, false)]
859
865
  } else if (paramType === PARAM_OBJECT_PROPERTY_FILTER) {
860
- result.object_property_filter = decodeRangeFilter(reader, true)
866
+ result.object_property_filter = [
867
+ ...(result.object_property_filter ?? []),
868
+ decodeRangeFilter(reader, true),
869
+ ]
861
870
  } else if (paramType === PARAM_TRACK_PROPERTY_FILTER) {
862
- result.track_property_filter = decodeRangeFilter(reader, true)
871
+ result.track_property_filter = [
872
+ ...(result.track_property_filter ?? []),
873
+ decodeRangeFilter(reader, true),
874
+ ]
863
875
  } else if (paramType === PARAM_NEW_GROUP_REQUEST) {
864
876
  result.new_group_request = reader.readVarInt()
865
877
  } else if (paramType === PARAM_TRACK_NAMESPACE_PREFIX) {