@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
@@ -937,12 +937,12 @@ function encodeSetupOptions(opts, writer) {
937
937
  }
938
938
  });
939
939
  }
940
- if (opts.authorization_token !== void 0) {
940
+ for (const token of _nullishCoalesce(opts.authorization_token, () => ( []))) {
941
941
  entries.push({
942
942
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
943
943
  encode: (w) => {
944
944
  const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
945
- encodeAuthorizationToken(opts.authorization_token, tmpW);
945
+ encodeAuthorizationToken(token, tmpW);
946
946
  const raw = tmpW.finish();
947
947
  w.writeVarInt(BigInt(raw.byteLength));
948
948
  w.writeBytes(raw);
@@ -1046,7 +1046,10 @@ function decodeSetupOptions(reader, payloadEnd) {
1046
1046
  if (optType === SETUP_OPT_PATH) {
1047
1047
  result.path = textDecoder.decode(bytes);
1048
1048
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
1049
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
1049
+ result.authorization_token = [
1050
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1051
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes))
1052
+ ];
1050
1053
  } else if (optType === SETUP_OPT_AUTHORITY) {
1051
1054
  result.authority = textDecoder.decode(bytes);
1052
1055
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -1213,12 +1216,12 @@ function encodeParams(params, writer) {
1213
1216
  encode: (w) => w.writeVarInt(params.object_delivery_timeout)
1214
1217
  });
1215
1218
  }
1216
- if (params.authorization_token !== void 0) {
1219
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
1217
1220
  entries.push({
1218
1221
  type: PARAM_AUTHORIZATION_TOKEN,
1219
1222
  encode: (w) => {
1220
1223
  const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
1221
- encodeAuthorizationToken(params.authorization_token, tmpW);
1224
+ encodeAuthorizationToken(token, tmpW);
1222
1225
  const raw = tmpW.finish();
1223
1226
  w.writeVarInt(BigInt(raw.byteLength));
1224
1227
  w.writeBytes(raw);
@@ -1299,34 +1302,34 @@ function encodeParams(params, writer) {
1299
1302
  encode: (w) => w.writeUint8(Number(params.group_order))
1300
1303
  });
1301
1304
  }
1302
- if (params.subgroup_filter !== void 0) {
1305
+ for (const filter of _nullishCoalesce(params.subgroup_filter, () => ( []))) {
1303
1306
  entries.push({
1304
1307
  type: PARAM_SUBGROUP_FILTER,
1305
- encode: (w) => encodeRangeFilter(params.subgroup_filter, false, w)
1308
+ encode: (w) => encodeRangeFilter(filter, false, w)
1306
1309
  });
1307
1310
  }
1308
- if (params.objectid_filter !== void 0) {
1311
+ for (const filter of _nullishCoalesce(params.objectid_filter, () => ( []))) {
1309
1312
  entries.push({
1310
1313
  type: PARAM_OBJECTID_FILTER,
1311
- encode: (w) => encodeRangeFilter(params.objectid_filter, false, w)
1314
+ encode: (w) => encodeRangeFilter(filter, false, w)
1312
1315
  });
1313
1316
  }
1314
- if (params.priority_filter !== void 0) {
1317
+ for (const filter of _nullishCoalesce(params.priority_filter, () => ( []))) {
1315
1318
  entries.push({
1316
1319
  type: PARAM_PRIORITY_FILTER,
1317
- encode: (w) => encodeRangeFilter(params.priority_filter, false, w)
1320
+ encode: (w) => encodeRangeFilter(filter, false, w)
1318
1321
  });
1319
1322
  }
1320
- if (params.object_property_filter !== void 0) {
1323
+ for (const filter of _nullishCoalesce(params.object_property_filter, () => ( []))) {
1321
1324
  entries.push({
1322
1325
  type: PARAM_OBJECT_PROPERTY_FILTER,
1323
- encode: (w) => encodeRangeFilter(params.object_property_filter, true, w)
1326
+ encode: (w) => encodeRangeFilter(filter, true, w)
1324
1327
  });
1325
1328
  }
1326
- if (params.track_property_filter !== void 0) {
1329
+ for (const filter of _nullishCoalesce(params.track_property_filter, () => ( []))) {
1327
1330
  entries.push({
1328
1331
  type: PARAM_TRACK_PROPERTY_FILTER,
1329
- encode: (w) => encodeRangeFilter(params.track_property_filter, true, w)
1332
+ encode: (w) => encodeRangeFilter(filter, true, w)
1330
1333
  });
1331
1334
  }
1332
1335
  if (params.new_group_request !== void 0) {
@@ -1388,7 +1391,10 @@ function decodeParams(reader, messageType) {
1388
1391
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1389
1392
  const length = Number(reader.readVarInt());
1390
1393
  const bytes = reader.readBytes(length);
1391
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
1394
+ result.authorization_token = [
1395
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1396
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes))
1397
+ ];
1392
1398
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
1393
1399
  result.rendezvous_timeout = reader.readVarInt();
1394
1400
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
@@ -1423,15 +1429,21 @@ function decodeParams(reader, messageType) {
1423
1429
  } else if (paramType === PARAM_GROUP_ORDER) {
1424
1430
  result.group_order = BigInt(reader.readUint8());
1425
1431
  } else if (paramType === PARAM_SUBGROUP_FILTER) {
1426
- result.subgroup_filter = decodeRangeFilter(reader, false);
1432
+ result.subgroup_filter = [..._nullishCoalesce(result.subgroup_filter, () => ( [])), decodeRangeFilter(reader, false)];
1427
1433
  } else if (paramType === PARAM_OBJECTID_FILTER) {
1428
- result.objectid_filter = decodeRangeFilter(reader, false);
1434
+ result.objectid_filter = [..._nullishCoalesce(result.objectid_filter, () => ( [])), decodeRangeFilter(reader, false)];
1429
1435
  } else if (paramType === PARAM_PRIORITY_FILTER) {
1430
- result.priority_filter = decodeRangeFilter(reader, false);
1436
+ result.priority_filter = [..._nullishCoalesce(result.priority_filter, () => ( [])), decodeRangeFilter(reader, false)];
1431
1437
  } else if (paramType === PARAM_OBJECT_PROPERTY_FILTER) {
1432
- result.object_property_filter = decodeRangeFilter(reader, true);
1438
+ result.object_property_filter = [
1439
+ ..._nullishCoalesce(result.object_property_filter, () => ( [])),
1440
+ decodeRangeFilter(reader, true)
1441
+ ];
1433
1442
  } else if (paramType === PARAM_TRACK_PROPERTY_FILTER) {
1434
- result.track_property_filter = decodeRangeFilter(reader, true);
1443
+ result.track_property_filter = [
1444
+ ..._nullishCoalesce(result.track_property_filter, () => ( [])),
1445
+ decodeRangeFilter(reader, true)
1446
+ ];
1435
1447
  } else if (paramType === PARAM_NEW_GROUP_REQUEST) {
1436
1448
  result.new_group_request = reader.readVarInt();
1437
1449
  } else if (paramType === PARAM_TRACK_NAMESPACE_PREFIX) {
@@ -376,7 +376,7 @@ function encodeSetupParams(params, w) {
376
376
  let count = 0;
377
377
  if (params.path !== void 0) count++;
378
378
  if (params.max_request_id !== void 0) count++;
379
- if (params.authorization_token !== void 0) count++;
379
+ count += params.authorization_token?.length ?? 0;
380
380
  if (params.unknown) count += params.unknown.length;
381
381
  w.writeVarInt(count);
382
382
  if (params.path !== void 0) {
@@ -389,9 +389,9 @@ function encodeSetupParams(params, w) {
389
389
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
390
390
  w.writeVarInt(params.max_request_id);
391
391
  }
392
- if (params.authorization_token !== void 0) {
392
+ for (const token of params.authorization_token ?? []) {
393
393
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
394
- const at = params.authorization_token;
394
+ const at = token;
395
395
  const tmpW = new BufferWriter(64);
396
396
  tmpW.writeVarInt(at.alias_type);
397
397
  tmpW.writeVarInt(at.token_type);
@@ -447,11 +447,14 @@ function decodeSetupParams(r) {
447
447
  const token_type = r.readVarInt();
448
448
  const tokenBytesLen = length - (r.offset - startOff);
449
449
  const tokenBytes = r.readBytes(tokenBytesLen);
450
- result.authorization_token = {
451
- alias_type,
452
- token_type,
453
- token_value: tokenBytes
454
- };
450
+ result.authorization_token = [
451
+ ...result.authorization_token ?? [],
452
+ {
453
+ alias_type,
454
+ token_type,
455
+ token_value: tokenBytes
456
+ }
457
+ ];
455
458
  } else {
456
459
  const bytes = r.readBytes(length);
457
460
  unknown.push({
@@ -468,16 +471,16 @@ function decodeSetupParams(r) {
468
471
  function encodeParams(params, w) {
469
472
  let count = params.unknown ? params.unknown.length : 0;
470
473
  if (params.delivery_timeout !== void 0) count++;
471
- if (params.authorization_token !== void 0) count++;
474
+ count += params.authorization_token?.length ?? 0;
472
475
  if (params.max_cache_duration !== void 0) count++;
473
476
  w.writeVarInt(count);
474
477
  if (params.delivery_timeout !== void 0) {
475
478
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
476
479
  w.writeVarInt(params.delivery_timeout);
477
480
  }
478
- if (params.authorization_token !== void 0) {
481
+ for (const token of params.authorization_token ?? []) {
479
482
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
480
- const at = params.authorization_token;
483
+ const at = token;
481
484
  const tmpW = new BufferWriter(64);
482
485
  tmpW.writeVarInt(at.alias_type);
483
486
  tmpW.writeVarInt(at.token_type);
@@ -536,11 +539,14 @@ function decodeParams(r) {
536
539
  const token_type = r.readVarInt();
537
540
  const tokenBytesLen = length - (r.offset - startOff);
538
541
  const tokenBytes = r.readBytes(tokenBytesLen);
539
- result.authorization_token = {
540
- alias_type,
541
- token_type,
542
- token_value: tokenBytes
543
- };
542
+ result.authorization_token = [
543
+ ...result.authorization_token ?? [],
544
+ {
545
+ alias_type,
546
+ token_type,
547
+ token_value: tokenBytes
548
+ }
549
+ ];
544
550
  } else {
545
551
  const bytes = r.readBytes(length);
546
552
  unknown.push({
@@ -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
 
@@ -776,7 +776,7 @@ function encodeSetupParams(params, writer) {
776
776
  let count = 0;
777
777
  if (params.path !== void 0) count++;
778
778
  if (params.max_request_id !== void 0) count++;
779
- if (params.authorization_token !== void 0) count++;
779
+ count += _nullishCoalesce(_optionalChain([params, 'access', _ => _.authorization_token, 'optionalAccess', _2 => _2.length]), () => ( 0));
780
780
  if (params.max_auth_token_cache_size !== void 0) count++;
781
781
  if (params.authority !== void 0) count++;
782
782
  if (params.moqt_implementation !== void 0) count++;
@@ -792,10 +792,10 @@ function encodeSetupParams(params, writer) {
792
792
  writer.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
793
793
  writer.writeVarInt(params.max_request_id);
794
794
  }
795
- if (params.authorization_token !== void 0) {
795
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
796
796
  writer.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN);
797
797
  const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
798
- encodeAuthorizationToken(params.authorization_token, tmpW);
798
+ encodeAuthorizationToken(token, tmpW);
799
799
  const raw = tmpW.finish();
800
800
  writer.writeVarInt(raw.byteLength);
801
801
  writer.writeBytes(raw);
@@ -861,7 +861,10 @@ function decodeSetupParams(reader) {
861
861
  if (paramType === SETUP_PARAM_PATH) {
862
862
  result.path = textDecoder.decode(bytes);
863
863
  } else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
864
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes));
864
+ result.authorization_token = [
865
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
866
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes))
867
+ ];
865
868
  } else if (paramType === SETUP_PARAM_AUTHORITY) {
866
869
  result.authority = textDecoder.decode(bytes);
867
870
  } else if (paramType === SETUP_PARAM_MOQT_IMPLEMENTATION) {
@@ -994,12 +997,12 @@ function encodeParams(params, writer) {
994
997
  encode: (w) => w.writeVarInt(params.delivery_timeout)
995
998
  });
996
999
  }
997
- if (params.authorization_token !== void 0) {
1000
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
998
1001
  entries.push({
999
1002
  type: PARAM_AUTHORIZATION_TOKEN,
1000
1003
  encode: (w) => {
1001
1004
  const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
1002
- encodeAuthorizationToken(params.authorization_token, tmpW);
1005
+ encodeAuthorizationToken(token, tmpW);
1003
1006
  const raw = tmpW.finish();
1004
1007
  w.writeVarInt(raw.byteLength);
1005
1008
  w.writeBytes(raw);
@@ -1121,7 +1124,10 @@ function decodeParams(reader) {
1121
1124
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1122
1125
  const length = Number(reader.readVarInt());
1123
1126
  const tokenBytes = reader.readBytes(length);
1124
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.BufferReader)(tokenBytes));
1127
+ result.authorization_token = [
1128
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1129
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.BufferReader)(tokenBytes))
1130
+ ];
1125
1131
  } else if (paramType === PARAM_MAX_CACHE_DURATION) {
1126
1132
  result.max_cache_duration = reader.readVarInt();
1127
1133
  } else if (paramType === PARAM_EXPIRES) {
@@ -910,12 +910,12 @@ function encodeSetupOptions(opts, writer) {
910
910
  }
911
911
  });
912
912
  }
913
- if (opts.authorization_token !== void 0) {
913
+ for (const token of opts.authorization_token ?? []) {
914
914
  entries.push({
915
915
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
916
916
  encode: (w) => {
917
917
  const tmpW = new Draft17BufferWriter(64);
918
- encodeAuthorizationToken(opts.authorization_token, tmpW);
918
+ encodeAuthorizationToken(token, tmpW);
919
919
  const raw = tmpW.finish();
920
920
  w.writeVarInt(BigInt(raw.byteLength));
921
921
  w.writeBytes(raw);
@@ -1003,7 +1003,10 @@ function decodeSetupOptions(reader, payloadEnd) {
1003
1003
  if (optType === SETUP_OPT_PATH) {
1004
1004
  result.path = textDecoder.decode(bytes);
1005
1005
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
1006
- result.authorization_token = decodeAuthorizationToken(new Draft17BufferReader(bytes));
1006
+ result.authorization_token = [
1007
+ ...result.authorization_token ?? [],
1008
+ decodeAuthorizationToken(new Draft17BufferReader(bytes))
1009
+ ];
1007
1010
  } else if (optType === SETUP_OPT_AUTHORITY) {
1008
1011
  result.authority = textDecoder.decode(bytes);
1009
1012
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -1091,12 +1094,12 @@ function encodeParams(params, writer) {
1091
1094
  encode: (w) => w.writeVarInt(params.delivery_timeout)
1092
1095
  });
1093
1096
  }
1094
- if (params.authorization_token !== void 0) {
1097
+ for (const token of params.authorization_token ?? []) {
1095
1098
  entries.push({
1096
1099
  type: PARAM_AUTHORIZATION_TOKEN,
1097
1100
  encode: (w) => {
1098
1101
  const tmpW = new Draft17BufferWriter(64);
1099
- encodeAuthorizationToken(params.authorization_token, tmpW);
1102
+ encodeAuthorizationToken(token, tmpW);
1100
1103
  const raw = tmpW.finish();
1101
1104
  w.writeVarInt(BigInt(raw.byteLength));
1102
1105
  w.writeBytes(raw);
@@ -1210,7 +1213,10 @@ function decodeParams(reader, messageType) {
1210
1213
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1211
1214
  const length = Number(reader.readVarInt());
1212
1215
  const bytes = reader.readBytes(length);
1213
- result.authorization_token = decodeAuthorizationToken(new Draft17BufferReader(bytes));
1216
+ result.authorization_token = [
1217
+ ...result.authorization_token ?? [],
1218
+ decodeAuthorizationToken(new Draft17BufferReader(bytes))
1219
+ ];
1214
1220
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
1215
1221
  result.rendezvous_timeout = reader.readVarInt();
1216
1222
  } else if (paramType === PARAM_EXPIRES) {
@@ -910,12 +910,12 @@ function encodeSetupOptions(opts, writer) {
910
910
  }
911
911
  });
912
912
  }
913
- if (opts.authorization_token !== void 0) {
913
+ for (const token of _nullishCoalesce(opts.authorization_token, () => ( []))) {
914
914
  entries.push({
915
915
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
916
916
  encode: (w) => {
917
917
  const tmpW = new (0, _chunk4XLYCT5Qcjs.Draft17BufferWriter)(64);
918
- encodeAuthorizationToken(opts.authorization_token, tmpW);
918
+ encodeAuthorizationToken(token, tmpW);
919
919
  const raw = tmpW.finish();
920
920
  w.writeVarInt(BigInt(raw.byteLength));
921
921
  w.writeBytes(raw);
@@ -1003,7 +1003,10 @@ function decodeSetupOptions(reader, payloadEnd) {
1003
1003
  if (optType === SETUP_OPT_PATH) {
1004
1004
  result.path = textDecoder.decode(bytes);
1005
1005
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
1006
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.Draft17BufferReader)(bytes));
1006
+ result.authorization_token = [
1007
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1008
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.Draft17BufferReader)(bytes))
1009
+ ];
1007
1010
  } else if (optType === SETUP_OPT_AUTHORITY) {
1008
1011
  result.authority = textDecoder.decode(bytes);
1009
1012
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -1091,12 +1094,12 @@ function encodeParams(params, writer) {
1091
1094
  encode: (w) => w.writeVarInt(params.delivery_timeout)
1092
1095
  });
1093
1096
  }
1094
- if (params.authorization_token !== void 0) {
1097
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
1095
1098
  entries.push({
1096
1099
  type: PARAM_AUTHORIZATION_TOKEN,
1097
1100
  encode: (w) => {
1098
1101
  const tmpW = new (0, _chunk4XLYCT5Qcjs.Draft17BufferWriter)(64);
1099
- encodeAuthorizationToken(params.authorization_token, tmpW);
1102
+ encodeAuthorizationToken(token, tmpW);
1100
1103
  const raw = tmpW.finish();
1101
1104
  w.writeVarInt(BigInt(raw.byteLength));
1102
1105
  w.writeBytes(raw);
@@ -1210,7 +1213,10 @@ function decodeParams(reader, messageType) {
1210
1213
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1211
1214
  const length = Number(reader.readVarInt());
1212
1215
  const bytes = reader.readBytes(length);
1213
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.Draft17BufferReader)(bytes));
1216
+ result.authorization_token = [
1217
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1218
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.Draft17BufferReader)(bytes))
1219
+ ];
1214
1220
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
1215
1221
  result.rendezvous_timeout = reader.readVarInt();
1216
1222
  } else if (paramType === PARAM_EXPIRES) {
@@ -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
 
@@ -376,7 +376,7 @@ function encodeSetupParams(params, w) {
376
376
  let count = 0;
377
377
  if (params.path !== void 0) count++;
378
378
  if (params.max_request_id !== void 0) count++;
379
- if (params.authorization_token !== void 0) count++;
379
+ count += _nullishCoalesce(_optionalChain([params, 'access', _2 => _2.authorization_token, 'optionalAccess', _3 => _3.length]), () => ( 0));
380
380
  if (params.unknown) count += params.unknown.length;
381
381
  w.writeVarInt(count);
382
382
  if (params.path !== void 0) {
@@ -389,9 +389,9 @@ function encodeSetupParams(params, w) {
389
389
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
390
390
  w.writeVarInt(params.max_request_id);
391
391
  }
392
- if (params.authorization_token !== void 0) {
392
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
393
393
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
394
- const at = params.authorization_token;
394
+ const at = token;
395
395
  const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
396
396
  tmpW.writeVarInt(at.alias_type);
397
397
  tmpW.writeVarInt(at.token_type);
@@ -447,11 +447,14 @@ function decodeSetupParams(r) {
447
447
  const token_type = r.readVarInt();
448
448
  const tokenBytesLen = length - (r.offset - startOff);
449
449
  const tokenBytes = r.readBytes(tokenBytesLen);
450
- result.authorization_token = {
451
- alias_type,
452
- token_type,
453
- token_value: tokenBytes
454
- };
450
+ result.authorization_token = [
451
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
452
+ {
453
+ alias_type,
454
+ token_type,
455
+ token_value: tokenBytes
456
+ }
457
+ ];
455
458
  } else {
456
459
  const bytes = r.readBytes(length);
457
460
  unknown.push({
@@ -468,16 +471,16 @@ function decodeSetupParams(r) {
468
471
  function encodeParams(params, w) {
469
472
  let count = params.unknown ? params.unknown.length : 0;
470
473
  if (params.delivery_timeout !== void 0) count++;
471
- if (params.authorization_token !== void 0) count++;
474
+ count += _nullishCoalesce(_optionalChain([params, 'access', _4 => _4.authorization_token, 'optionalAccess', _5 => _5.length]), () => ( 0));
472
475
  if (params.max_cache_duration !== void 0) count++;
473
476
  w.writeVarInt(count);
474
477
  if (params.delivery_timeout !== void 0) {
475
478
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
476
479
  w.writeVarInt(params.delivery_timeout);
477
480
  }
478
- if (params.authorization_token !== void 0) {
481
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
479
482
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
480
- const at = params.authorization_token;
483
+ const at = token;
481
484
  const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
482
485
  tmpW.writeVarInt(at.alias_type);
483
486
  tmpW.writeVarInt(at.token_type);
@@ -536,11 +539,14 @@ function decodeParams(r) {
536
539
  const token_type = r.readVarInt();
537
540
  const tokenBytesLen = length - (r.offset - startOff);
538
541
  const tokenBytes = r.readBytes(tokenBytesLen);
539
- result.authorization_token = {
540
- alias_type,
541
- token_type,
542
- token_value: tokenBytes
543
- };
542
+ result.authorization_token = [
543
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
544
+ {
545
+ alias_type,
546
+ token_type,
547
+ token_value: tokenBytes
548
+ }
549
+ ];
544
550
  } else {
545
551
  const bytes = r.readBytes(length);
546
552
  unknown.push({
@@ -1079,12 +1079,12 @@ function encodeSetupOptions(opts, writer) {
1079
1079
  }
1080
1080
  });
1081
1081
  }
1082
- if (opts.authorization_token !== void 0) {
1082
+ for (const token of _nullishCoalesce(opts.authorization_token, () => ( []))) {
1083
1083
  entries.push({
1084
1084
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
1085
1085
  encode: (w) => {
1086
1086
  const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
1087
- encodeAuthorizationToken(opts.authorization_token, tmpW);
1087
+ encodeAuthorizationToken(token, tmpW);
1088
1088
  const raw = tmpW.finish();
1089
1089
  w.writeVarInt(BigInt(raw.byteLength));
1090
1090
  w.writeBytes(raw);
@@ -1188,7 +1188,10 @@ function decodeSetupOptions(reader, payloadEnd) {
1188
1188
  if (optType === SETUP_OPT_PATH) {
1189
1189
  result.path = textDecoder.decode(bytes);
1190
1190
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
1191
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
1191
+ result.authorization_token = [
1192
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1193
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes))
1194
+ ];
1192
1195
  } else if (optType === SETUP_OPT_AUTHORITY) {
1193
1196
  result.authority = textDecoder.decode(bytes);
1194
1197
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -1469,12 +1472,12 @@ function encodeParams(params, writer) {
1469
1472
  encode: (w) => w.writeVarInt(params.object_delivery_timeout)
1470
1473
  });
1471
1474
  }
1472
- if (params.authorization_token !== void 0) {
1475
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
1473
1476
  entries.push({
1474
1477
  type: PARAM_AUTHORIZATION_TOKEN,
1475
1478
  encode: (w) => {
1476
1479
  const tmpW = new (0, _chunk4XLYCT5Qcjs.MoqtBufferWriter)(64);
1477
- encodeAuthorizationToken(params.authorization_token, tmpW);
1480
+ encodeAuthorizationToken(token, tmpW);
1478
1481
  const raw = tmpW.finish();
1479
1482
  w.writeVarInt(BigInt(raw.byteLength));
1480
1483
  w.writeBytes(raw);
@@ -1554,34 +1557,34 @@ function encodeParams(params, writer) {
1554
1557
  }
1555
1558
  });
1556
1559
  }
1557
- if (params.subgroup_filter !== void 0) {
1560
+ for (const filter of _nullishCoalesce(params.subgroup_filter, () => ( []))) {
1558
1561
  entries.push({
1559
1562
  type: PARAM_SUBGROUP_FILTER,
1560
- encode: (w) => encodeRangeFilter(params.subgroup_filter, false, w)
1563
+ encode: (w) => encodeRangeFilter(filter, false, w)
1561
1564
  });
1562
1565
  }
1563
- if (params.objectid_filter !== void 0) {
1566
+ for (const filter of _nullishCoalesce(params.objectid_filter, () => ( []))) {
1564
1567
  entries.push({
1565
1568
  type: PARAM_OBJECTID_FILTER,
1566
- encode: (w) => encodeRangeFilter(params.objectid_filter, false, w)
1569
+ encode: (w) => encodeRangeFilter(filter, false, w)
1567
1570
  });
1568
1571
  }
1569
- if (params.priority_filter !== void 0) {
1572
+ for (const filter of _nullishCoalesce(params.priority_filter, () => ( []))) {
1570
1573
  entries.push({
1571
1574
  type: PARAM_PRIORITY_FILTER,
1572
- encode: (w) => encodeRangeFilter(params.priority_filter, false, w)
1575
+ encode: (w) => encodeRangeFilter(filter, false, w)
1573
1576
  });
1574
1577
  }
1575
- if (params.object_property_filter !== void 0) {
1578
+ for (const filter of _nullishCoalesce(params.object_property_filter, () => ( []))) {
1576
1579
  entries.push({
1577
1580
  type: PARAM_OBJECT_PROPERTY_FILTER,
1578
- encode: (w) => encodeRangeFilter(params.object_property_filter, true, w)
1581
+ encode: (w) => encodeRangeFilter(filter, true, w)
1579
1582
  });
1580
1583
  }
1581
- if (params.track_property_filter !== void 0) {
1584
+ for (const filter of _nullishCoalesce(params.track_property_filter, () => ( []))) {
1582
1585
  entries.push({
1583
1586
  type: PARAM_TRACK_PROPERTY_FILTER,
1584
- encode: (w) => encodeRangeFilter(params.track_property_filter, true, w)
1587
+ encode: (w) => encodeRangeFilter(filter, true, w)
1585
1588
  });
1586
1589
  }
1587
1590
  if (params.new_group_request !== void 0) {
@@ -1650,7 +1653,10 @@ function decodeParams(reader, messageType) {
1650
1653
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
1651
1654
  const length = Number(reader.readVarInt());
1652
1655
  const bytes = reader.readBytes(length);
1653
- result.authorization_token = decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes));
1656
+ result.authorization_token = [
1657
+ ..._nullishCoalesce(result.authorization_token, () => ( [])),
1658
+ decodeAuthorizationToken(new (0, _chunk4XLYCT5Qcjs.MoqtBufferReader)(bytes))
1659
+ ];
1654
1660
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
1655
1661
  result.rendezvous_timeout = reader.readVarInt();
1656
1662
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
@@ -1674,15 +1680,21 @@ function decodeParams(reader, messageType) {
1674
1680
  } else if (paramType === PARAM_FILL_PARAMETERS) {
1675
1681
  result.fill_parameters = decodeFillParameters(reader);
1676
1682
  } else if (paramType === PARAM_SUBGROUP_FILTER) {
1677
- result.subgroup_filter = decodeRangeFilter(reader, false);
1683
+ result.subgroup_filter = [..._nullishCoalesce(result.subgroup_filter, () => ( [])), decodeRangeFilter(reader, false)];
1678
1684
  } else if (paramType === PARAM_OBJECTID_FILTER) {
1679
- result.objectid_filter = decodeRangeFilter(reader, false);
1685
+ result.objectid_filter = [..._nullishCoalesce(result.objectid_filter, () => ( [])), decodeRangeFilter(reader, false)];
1680
1686
  } else if (paramType === PARAM_PRIORITY_FILTER) {
1681
- result.priority_filter = decodeRangeFilter(reader, false);
1687
+ result.priority_filter = [..._nullishCoalesce(result.priority_filter, () => ( [])), decodeRangeFilter(reader, false)];
1682
1688
  } else if (paramType === PARAM_OBJECT_PROPERTY_FILTER) {
1683
- result.object_property_filter = decodeRangeFilter(reader, true);
1689
+ result.object_property_filter = [
1690
+ ..._nullishCoalesce(result.object_property_filter, () => ( [])),
1691
+ decodeRangeFilter(reader, true)
1692
+ ];
1684
1693
  } else if (paramType === PARAM_TRACK_PROPERTY_FILTER) {
1685
- result.track_property_filter = decodeRangeFilter(reader, true);
1694
+ result.track_property_filter = [
1695
+ ..._nullishCoalesce(result.track_property_filter, () => ( [])),
1696
+ decodeRangeFilter(reader, true)
1697
+ ];
1686
1698
  } else if (paramType === PARAM_NEW_GROUP_REQUEST) {
1687
1699
  result.new_group_request = reader.readVarInt();
1688
1700
  } else if (paramType === PARAM_TRACK_NAMESPACE_PREFIX) {
@@ -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 opts.authorization_token ?? []) {
939
939
  entries.push({
940
940
  type: SETUP_OPT_AUTHORIZATION_TOKEN,
941
941
  encode: (w) => {
942
942
  const tmpW = new 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 MoqtBufferReader(bytes));
1031
+ result.authorization_token = [
1032
+ ...result.authorization_token ?? [],
1033
+ decodeAuthorizationToken(new 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 params.authorization_token ?? []) {
1142
1145
  entries.push({
1143
1146
  type: PARAM_AUTHORIZATION_TOKEN,
1144
1147
  encode: (w) => {
1145
1148
  const tmpW = new 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 MoqtBufferReader(bytes));
1289
+ result.authorization_token = [
1290
+ ...result.authorization_token ?? [],
1291
+ decodeAuthorizationToken(new 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) {