@moqtap/codec 0.8.0 → 0.9.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 (160) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +16 -4
  3. package/dist/{chunk-5XZKO2U5.js → chunk-2XH6PHXR.js} +62 -51
  4. package/dist/{chunk-BQHLUT37.cjs → chunk-7ENEWAMZ.cjs} +2 -6
  5. package/dist/chunk-BMJMY6FX.cjs +868 -0
  6. package/dist/{chunk-MD2OA7SE.js → chunk-BV6MITLO.js} +15 -8
  7. package/dist/{chunk-B56AG5HU.cjs → chunk-EVCPBFSR.cjs} +6 -4
  8. package/dist/{chunk-KNLPX3YA.js → chunk-H6DTAIWM.js} +6 -4
  9. package/dist/{chunk-J3ASFPCX.cjs → chunk-IADVBKEJ.cjs} +15 -8
  10. package/dist/chunk-MAXEHYVB.cjs +2362 -0
  11. package/dist/{chunk-I55J3KXD.js → chunk-NH4L6NIY.js} +48 -33
  12. package/dist/{chunk-EQAYMCXO.cjs → chunk-PU2KV7VP.cjs} +48 -33
  13. package/dist/{chunk-APTV6F72.js → chunk-Q7NSUXXB.js} +70 -52
  14. package/dist/{chunk-HEO2JG6C.js → chunk-TMXRYOBS.js} +100 -92
  15. package/dist/{chunk-MH7537FB.cjs → chunk-TVSFDQYE.cjs} +70 -52
  16. package/dist/{chunk-IEJULBKB.cjs → chunk-UA5XFP4O.cjs} +100 -92
  17. package/dist/{chunk-KTVN4P6J.cjs → chunk-UZO5Z2XT.cjs} +62 -51
  18. package/dist/chunk-WX5PU7HF.js +868 -0
  19. package/dist/{chunk-JJEN2VG5.js → chunk-XQGEOFGE.js} +2 -6
  20. package/dist/chunk-YJGOD3Y4.js +2362 -0
  21. package/dist/{codec-BLYAy2OP.d.ts → codec--CVeqGQv.d.ts} +1 -1
  22. package/dist/{codec-DujHf55Z.d.ts → codec-BJ7BHuiZ.d.ts} +1 -1
  23. package/dist/{codec-D47r_-Rl.d.ts → codec-BKsVu3Fr.d.ts} +1 -1
  24. package/dist/{codec-BNS3gS77.d.ts → codec-BMwgZIgG.d.ts} +1 -1
  25. package/dist/{codec-CI0BjmHc.d.ts → codec-BNy5syCU.d.ts} +1 -1
  26. package/dist/{codec-CFhUGTu2.d.ts → codec-BQa6Qsav.d.ts} +2 -2
  27. package/dist/codec-Bym-K2q2.d.cts +49 -0
  28. package/dist/{codec-D2JbI2tp.d.ts → codec-C006F75E.d.ts} +1 -1
  29. package/dist/codec-C5evFHL-.d.ts +49 -0
  30. package/dist/{codec-DQWQSam3.d.cts → codec-C6Mx4bwz.d.cts} +1 -1
  31. package/dist/{codec-DL0njGkL.d.ts → codec-CA6nbbEk.d.ts} +1 -1
  32. package/dist/{codec-D89DWXbv.d.cts → codec-CSBFdPgP.d.cts} +1 -1
  33. package/dist/{codec-DvcJgYKq.d.cts → codec-CXCjya_G.d.cts} +1 -1
  34. package/dist/{codec-hvkJfCF5.d.cts → codec-C_xxsbKy.d.cts} +1 -1
  35. package/dist/{codec-BOyrk_C9.d.cts → codec-Cfo_z5ET.d.cts} +1 -1
  36. package/dist/{codec-xeuGZY77.d.cts → codec-CgZdadPt.d.cts} +2 -2
  37. package/dist/{codec-WwwUipaU.d.ts → codec-Cl73EfRW.d.ts} +1 -1
  38. package/dist/{codec-BOtv3R5j.d.cts → codec-CtvFK4aV.d.cts} +1 -1
  39. package/dist/{codec-DAePx2NL.d.ts → codec-CviAa4lp.d.ts} +2 -2
  40. package/dist/{codec-DJmV04i0.d.ts → codec-D4RvFQmu.d.ts} +1 -1
  41. package/dist/{codec-cou9XBMF.d.cts → codec-DAyiF5sq.d.cts} +1 -1
  42. package/dist/{codec-CyApDKwf.d.cts → codec-DJmqoIsp.d.cts} +1 -1
  43. package/dist/{codec-NMsTK0GX.d.cts → codec-DchsPfr3.d.cts} +1 -1
  44. package/dist/{codec-DplRgIKq.d.ts → codec-Dl_QIXMz.d.ts} +1 -1
  45. package/dist/{codec-BnamSx7L.d.cts → codec-DzLvG8Wb.d.cts} +2 -2
  46. package/dist/{codec-D95gT98n.d.cts → codec-DzkdW4kO.d.cts} +1 -1
  47. package/dist/{codec-CWj5iTxA.d.ts → codec-O-1Js7h4.d.ts} +1 -1
  48. package/dist/{codec-BqqoYdh_.d.cts → codec-vddqy0KY.d.cts} +1 -1
  49. package/dist/draft07-session.d.cts +3 -3
  50. package/dist/draft07-session.d.ts +3 -3
  51. package/dist/draft07.d.cts +3 -3
  52. package/dist/draft07.d.ts +3 -3
  53. package/dist/draft08-session.d.cts +3 -3
  54. package/dist/draft08-session.d.ts +3 -3
  55. package/dist/draft08.d.cts +4 -4
  56. package/dist/draft08.d.ts +4 -4
  57. package/dist/draft09-session.d.cts +3 -3
  58. package/dist/draft09-session.d.ts +3 -3
  59. package/dist/draft09.d.cts +4 -4
  60. package/dist/draft09.d.ts +4 -4
  61. package/dist/draft10-session.d.cts +3 -3
  62. package/dist/draft10-session.d.ts +3 -3
  63. package/dist/draft10.d.cts +4 -4
  64. package/dist/draft10.d.ts +4 -4
  65. package/dist/draft11-session.d.cts +3 -3
  66. package/dist/draft11-session.d.ts +3 -3
  67. package/dist/draft11.d.cts +4 -4
  68. package/dist/draft11.d.ts +4 -4
  69. package/dist/draft12-session.d.cts +3 -3
  70. package/dist/draft12-session.d.ts +3 -3
  71. package/dist/draft12.cjs +2 -2
  72. package/dist/draft12.d.cts +4 -4
  73. package/dist/draft12.d.ts +4 -4
  74. package/dist/draft12.js +1 -1
  75. package/dist/draft13-session.d.cts +3 -3
  76. package/dist/draft13-session.d.ts +3 -3
  77. package/dist/draft13.d.cts +4 -4
  78. package/dist/draft13.d.ts +4 -4
  79. package/dist/draft14-session.d.cts +4 -4
  80. package/dist/draft14-session.d.ts +4 -4
  81. package/dist/draft14.cjs +2 -2
  82. package/dist/draft14.d.cts +6 -6
  83. package/dist/draft14.d.ts +6 -6
  84. package/dist/draft14.js +1 -1
  85. package/dist/draft15-session.d.cts +3 -3
  86. package/dist/draft15-session.d.ts +3 -3
  87. package/dist/draft15.cjs +2 -2
  88. package/dist/draft15.d.cts +4 -4
  89. package/dist/draft15.d.ts +4 -4
  90. package/dist/draft15.js +1 -1
  91. package/dist/draft16-session.d.cts +3 -3
  92. package/dist/draft16-session.d.ts +3 -3
  93. package/dist/draft16.cjs +2 -2
  94. package/dist/draft16.d.cts +4 -4
  95. package/dist/draft16.d.ts +4 -4
  96. package/dist/draft16.js +1 -1
  97. package/dist/draft17-session.d.cts +3 -3
  98. package/dist/draft17-session.d.ts +3 -3
  99. package/dist/draft17.cjs +2 -2
  100. package/dist/draft17.d.cts +3 -3
  101. package/dist/draft17.d.ts +3 -3
  102. package/dist/draft17.js +1 -1
  103. package/dist/draft18-session.d.cts +3 -3
  104. package/dist/draft18-session.d.ts +3 -3
  105. package/dist/draft18.cjs +2 -2
  106. package/dist/draft18.d.cts +3 -3
  107. package/dist/draft18.d.ts +3 -3
  108. package/dist/draft18.js +1 -1
  109. package/dist/draft19-session.d.cts +3 -3
  110. package/dist/draft19-session.d.ts +3 -3
  111. package/dist/draft19.cjs +2 -2
  112. package/dist/draft19.d.cts +3 -3
  113. package/dist/draft19.d.ts +3 -3
  114. package/dist/draft19.js +1 -1
  115. package/dist/draft20-session.cjs +8 -0
  116. package/dist/draft20-session.d.cts +195 -0
  117. package/dist/draft20-session.d.ts +195 -0
  118. package/dist/draft20-session.js +8 -0
  119. package/dist/draft20.cjs +217 -0
  120. package/dist/draft20.d.cts +175 -0
  121. package/dist/draft20.d.ts +175 -0
  122. package/dist/draft20.js +217 -0
  123. package/dist/index.cjs +21 -15
  124. package/dist/index.d.cts +33 -18
  125. package/dist/index.d.ts +33 -18
  126. package/dist/index.js +14 -8
  127. package/dist/{session-types-KsqyVp6y.d.cts → session-types-B9idsih-.d.cts} +13 -1
  128. package/dist/{session-types-C0l_-Ups.d.ts → session-types-Dn7b3RZM.d.ts} +13 -1
  129. package/dist/session.cjs +5 -1
  130. package/dist/session.d.cts +6 -4
  131. package/dist/session.d.ts +6 -4
  132. package/dist/session.js +5 -1
  133. package/dist/types-CWCQwuvy.d.cts +359 -0
  134. package/dist/types-CWCQwuvy.d.ts +359 -0
  135. package/dist/{types-CdCSIfvI.d.cts → types-DG5_iKuv.d.cts} +1 -1
  136. package/dist/{types-CdCSIfvI.d.ts → types-DG5_iKuv.d.ts} +1 -1
  137. package/dist/{types-CVeKIk7A.d.cts → types-HI_bbXka.d.cts} +0 -2
  138. package/dist/{types-CVeKIk7A.d.ts → types-HI_bbXka.d.ts} +0 -2
  139. package/package.json +16 -3
  140. package/src/core/session-types.ts +7 -0
  141. package/src/core/types.ts +1 -0
  142. package/src/drafts/draft12/data-streams.ts +13 -4
  143. package/src/drafts/draft14/codec.ts +2 -6
  144. package/src/drafts/draft14/types.ts +0 -2
  145. package/src/drafts/draft15/data-streams.ts +30 -16
  146. package/src/drafts/draft16/codec.ts +116 -93
  147. package/src/drafts/draft17/codec.ts +72 -35
  148. package/src/drafts/draft18/codec.ts +89 -53
  149. package/src/drafts/draft19/codec.ts +98 -55
  150. package/src/drafts/draft20/codec.ts +1737 -0
  151. package/src/drafts/draft20/data-streams.ts +1291 -0
  152. package/src/drafts/draft20/error-codes.ts +135 -0
  153. package/src/drafts/draft20/index.ts +165 -0
  154. package/src/drafts/draft20/messages.ts +68 -0
  155. package/src/drafts/draft20/rules.ts +107 -0
  156. package/src/drafts/draft20/session-fsm.ts +1063 -0
  157. package/src/drafts/draft20/session.ts +21 -0
  158. package/src/drafts/draft20/types.ts +455 -0
  159. package/src/index.ts +20 -2
  160. package/src/session.ts +4 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@moqtap/codec` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ This file starts at 0.9.0. Earlier releases are in the git history.
9
+
10
+ ## [0.9.0] - 2026-09-03
11
+
12
+ Draft-20 support, and a fix to draft-19 that changes which state machine a
13
+ draft-19 session runs.
14
+
15
+ ### Added
16
+
17
+ - **Draft-20**: codec, message and data-stream tables, wire rules, error codes
18
+ and session FSM, exported as `@moqtap/codec/draft20` and
19
+ `@moqtap/codec/draft20/session`. `createCodec({ draft: '20' })` and
20
+ `createDraft20Codec()` both reach it.
21
+ - `PUBLISH_STATE_NOTIFY` (`0x22`), the one control message draft-20 adds. It is
22
+ unilateral and not subject to `MAX_REQUEST_UPDATES`.
23
+ - Draft-20's rewritten `FETCH`. The message keeps codepoint `0x16` but drops the
24
+ Fetch Type discriminator, carries Track Namespace and Track Name inline, and
25
+ moves its range into a `LOCATION_FILTER` parameter. Nothing on the wire
26
+ distinguishes it from a draft-19 `FETCH` at the type byte, so a session
27
+ decoded under the wrong draft will silently misparse it — pick the draft from
28
+ the negotiated `moqt-NN` protocol string, not from message content.
29
+ - `INCLUDE_PROPERTIES` (`0x35`), a uint8 boolean defaulting to `1`.
30
+
31
+ ### Fixed
32
+
33
+ - **`createDraft19Codec()` reported `draft: '18'`.** Since `createSessionState()`
34
+ keys off `codec.draft`, every draft-19 session was validated by the draft-18
35
+ FSM. Draft-19 sessions now run the draft-19 FSM, which enforces rules the
36
+ draft-18 one does not — a session that passed validation on 0.8.1 may now be
37
+ rejected, correctly.
38
+
39
+ ### Changed
40
+
41
+ - Draft-20 ranges are **inclusive**. An end location names the last object, not
42
+ one past it; do not carry a draft-19 `+ 1` forward.
43
+ - Retired error codes decode rather than being refused. Draft-20 Section 14
44
+ requires an unknown error code in any error context to be treated as
45
+ `INTERNAL_ERROR`, and forbids closing the session over one in `REQUEST_ERROR`
46
+ or `PUBLISH_DONE`. The `RETIRED_*` sets remain exported as advisory
47
+ diagnostics — useful for "this peer looks like draft-19" — but are no longer
48
+ decode gates.
49
+ - `@moqtap/test-vectors` dependency raised to `^0.13.0` for the draft-20 corpus.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  MoQT (Media over QUIC Transport) wire-format codec and session state machine for JavaScript/TypeScript.
4
4
 
5
- - Multi-draft support (drafts 07 through 19)
5
+ - Multi-draft support (drafts 07 through 20)
6
6
  - Stateless encode/decode of all MoQT control messages and data streams
7
7
  - Protocol session state machine with FSM-based validation per draft
8
8
  - Zero runtime dependencies
@@ -43,10 +43,11 @@ Or use the factory if your application supports multiple drafts:
43
43
  ```typescript
44
44
  import { createCodec, DRAFT_VERSIONS } from '@moqtap/codec'
45
45
 
46
- const codec = createCodec({ draft: '19' }) // '07' through '19'
46
+ const codec = createCodec({ draft: '20' }) // '07' through '20'
47
47
 
48
- // DRAFT_VERSIONS provides wire version numbers under short aliases:
49
- // DRAFT_VERSIONS['07'] — 0xff000007n
48
+ // DRAFT_VERSIONS provides version identifiers under short aliases:
49
+ // DRAFT_VERSIONS['07'] — 0xff000007n, a real draft-07 wire value
50
+ // DRAFT_VERSIONS['20'] — 0xff000014n, derived; see the note below
50
51
  ```
51
52
 
52
53
  ## Subpath Exports
@@ -69,10 +70,21 @@ Each draft is available as a subpath import with its own codec and session state
69
70
  | `@moqtap/codec/draft17` | Draft-17 codec |
70
71
  | `@moqtap/codec/draft18` | Draft-18 codec |
71
72
  | `@moqtap/codec/draft19` | Draft-19 codec |
73
+ | `@moqtap/codec/draft20` | Draft-20 codec |
72
74
  | `@moqtap/codec/draft{N}/session` | Session state machine for draft N |
73
75
 
74
76
  > **Note:** A default (versionless) codec will be available once the MoQT specification reaches RFC status. Until then, always specify a draft version.
75
77
 
78
+ `DRAFT_VERSIONS` is a table of numeric keys, and only the entries up to `'14'` are values a peer
79
+ ever puts on the wire. From draft-15 the version is negotiated by ALPN (raw QUIC) or
80
+ `WT-Available-Protocols` (WebTransport) as the string `moqt-NN`, and no version number is sent at
81
+ all — so `DRAFT_VERSIONS['20']` is a derived identifier, not something observed. Each draft module
82
+ from 15 on exports the real one:
83
+
84
+ ```typescript
85
+ import { PROTOCOL_STRING } from '@moqtap/codec/draft20' // 'moqt-20'
86
+ ```
87
+
76
88
  ## Draft-Specific Imports
77
89
 
78
90
  For applications targeting a single draft version:
@@ -1103,6 +1103,33 @@ var PARAM_SUBSCRIPTION_FILTER = 0x21n;
1103
1103
  var PARAM_GROUP_ORDER = 0x22n;
1104
1104
  var PARAM_NEW_GROUP_REQUEST = 0x32n;
1105
1105
  var PARAM_TRACK_NAMESPACE_PREFIX = 0x34n;
1106
+ var PARAMETER_SCOPE = /* @__PURE__ */ new Map([
1107
+ [0x02n, /* @__PURE__ */ new Set(["request_ok", "subscribe", "request_update"])],
1108
+ [
1109
+ 0x03n,
1110
+ /* @__PURE__ */ new Set([
1111
+ "publish",
1112
+ "subscribe",
1113
+ "request_update",
1114
+ "subscribe_namespace",
1115
+ "subscribe_tracks",
1116
+ "publish_namespace",
1117
+ "track_status",
1118
+ "fetch"
1119
+ ])
1120
+ ],
1121
+ [0x04n, /* @__PURE__ */ new Set(["subscribe"])],
1122
+ [0x06n, /* @__PURE__ */ new Set(["request_ok", "subscribe", "request_update"])],
1123
+ [0x08n, /* @__PURE__ */ new Set(["subscribe_ok", "publish", "request_ok"])],
1124
+ [0x09n, /* @__PURE__ */ new Set(["subscribe_ok", "publish", "request_ok"])],
1125
+ [0x0an, /* @__PURE__ */ new Set(["fetch"])],
1126
+ [0x10n, /* @__PURE__ */ new Set(["subscribe", "request_update", "publish", "request_ok", "subscribe_tracks"])],
1127
+ [0x20n, /* @__PURE__ */ new Set(["subscribe", "fetch", "request_update", "request_ok"])],
1128
+ [0x21n, /* @__PURE__ */ new Set(["subscribe", "request_ok", "request_update"])],
1129
+ [0x22n, /* @__PURE__ */ new Set(["subscribe", "request_ok", "fetch"])],
1130
+ [0x32n, /* @__PURE__ */ new Set(["request_ok", "subscribe", "request_update"])],
1131
+ [0x34n, /* @__PURE__ */ new Set(["request_update"])]
1132
+ ]);
1106
1133
  function encodeParams(params, writer) {
1107
1134
  const entries = [];
1108
1135
  if (params.object_delivery_timeout !== void 0) {
@@ -1144,13 +1171,12 @@ function encodeParams(params, writer) {
1144
1171
  if (params.largest_object !== void 0) {
1145
1172
  entries.push({
1146
1173
  type: PARAM_LARGEST_OBJECT,
1174
+ // A Location is "Two consecutive varints (Group, Object)", which is a
1175
+ // different value encoding from "Length-prefixed". Nothing states the
1176
+ // length, so nothing writes one.
1147
1177
  encode: (w) => {
1148
- const tmpW = new MoqtBufferWriter(16);
1149
- tmpW.writeVarInt(params.largest_object.group);
1150
- tmpW.writeVarInt(params.largest_object.object);
1151
- const raw = tmpW.finish();
1152
- w.writeVarInt(BigInt(raw.byteLength));
1153
- w.writeBytes(raw);
1178
+ w.writeVarInt(params.largest_object.group);
1179
+ w.writeVarInt(params.largest_object.object);
1154
1180
  }
1155
1181
  });
1156
1182
  }
@@ -1207,12 +1233,11 @@ function encodeParams(params, writer) {
1207
1233
  if (params.track_namespace_prefix !== void 0) {
1208
1234
  entries.push({
1209
1235
  type: PARAM_TRACK_NAMESPACE_PREFIX,
1236
+ // The parameter "uses the Track Namespace encoding", which is a tuple
1237
+ // that states its own field count. That is not the Length-prefixed
1238
+ // encoding, so there is no byte length ahead of it.
1210
1239
  encode: (w) => {
1211
- const tmpW = new MoqtBufferWriter(32);
1212
- encodeNamespaceTuple(params.track_namespace_prefix, tmpW);
1213
- const raw = tmpW.finish();
1214
- w.writeVarInt(BigInt(raw.byteLength));
1215
- w.writeBytes(raw);
1240
+ encodeNamespaceTuple(params.track_namespace_prefix, w);
1216
1241
  }
1217
1242
  });
1218
1243
  }
@@ -1237,15 +1262,22 @@ function encodeParams(params, writer) {
1237
1262
  prevType = entry.type;
1238
1263
  }
1239
1264
  }
1240
- function decodeParams(reader) {
1265
+ function decodeParams(reader, messageType) {
1241
1266
  const count = Number(reader.readVarInt());
1242
1267
  const result = {};
1243
- const unknown = [];
1244
1268
  let prevType = 0n;
1245
1269
  for (let i = 0; i < count; i++) {
1246
1270
  const delta = reader.readVarInt();
1247
1271
  const paramType = prevType + delta;
1248
1272
  prevType = paramType;
1273
+ const scope = PARAMETER_SCOPE.get(paramType);
1274
+ if (scope !== void 0 && !scope.has(messageType)) {
1275
+ throw new DecodeError(
1276
+ "CONSTRAINT_VIOLATION",
1277
+ `Message Parameter 0x${paramType.toString(16)} may not appear in ${messageType}`,
1278
+ reader.offset
1279
+ );
1280
+ }
1249
1281
  if (paramType === PARAM_OBJECT_DELIVERY_TIMEOUT) {
1250
1282
  result.object_delivery_timeout = reader.readVarInt();
1251
1283
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
@@ -1259,12 +1291,8 @@ function decodeParams(reader) {
1259
1291
  } else if (paramType === PARAM_EXPIRES) {
1260
1292
  result.expires = reader.readVarInt();
1261
1293
  } else if (paramType === PARAM_LARGEST_OBJECT) {
1262
- const length = Number(reader.readVarInt());
1263
- const startOff = reader.offset;
1264
1294
  const group = reader.readVarInt();
1265
1295
  const object = reader.readVarInt();
1266
- const consumed = reader.offset - startOff;
1267
- if (consumed < length) reader.readBytes(length - consumed);
1268
1296
  result.largest_object = { group, object };
1269
1297
  } else if (paramType === PARAM_FILL_TIMEOUT) {
1270
1298
  result.fill_timeout = reader.readVarInt();
@@ -1292,32 +1320,15 @@ function decodeParams(reader) {
1292
1320
  } else if (paramType === PARAM_NEW_GROUP_REQUEST) {
1293
1321
  result.new_group_request = reader.readVarInt();
1294
1322
  } else if (paramType === PARAM_TRACK_NAMESPACE_PREFIX) {
1295
- const length = Number(reader.readVarInt());
1296
- const bytes = reader.readBytes(length);
1297
- result.track_namespace_prefix = decodeNamespaceTuple(new MoqtBufferReader(bytes));
1323
+ result.track_namespace_prefix = decodeNamespaceTuple(reader);
1298
1324
  } else {
1299
- if (paramType % 2n === 0n) {
1300
- const value = reader.readVarInt();
1301
- const tmpWriter = new MoqtBufferWriter(16);
1302
- tmpWriter.writeVarInt(value);
1303
- const raw = tmpWriter.finish();
1304
- unknown.push({
1305
- id: `0x${paramType.toString(16)}`,
1306
- length: raw.byteLength,
1307
- raw_hex: bytesToHex(raw)
1308
- });
1309
- } else {
1310
- const length = Number(reader.readVarInt());
1311
- const bytes = reader.readBytes(length);
1312
- unknown.push({
1313
- id: `0x${paramType.toString(16)}`,
1314
- length,
1315
- raw_hex: bytesToHex(bytes)
1316
- });
1317
- }
1325
+ throw new DecodeError(
1326
+ "INVALID_PARAMETER",
1327
+ `Unknown Message Parameter type 0x${paramType.toString(16)}`,
1328
+ reader.offset
1329
+ );
1318
1330
  }
1319
1331
  }
1320
- if (unknown.length > 0) result.unknown = unknown;
1321
1332
  return result;
1322
1333
  }
1323
1334
  var TPROP_OBJECT_DELIVERY_TIMEOUT = 0x02n;
@@ -1579,7 +1590,7 @@ function decodeSubscribePayload(r) {
1579
1590
  const request_id = r.readVarInt();
1580
1591
  const track_namespace = r.readTuple();
1581
1592
  const track_name = r.readString();
1582
- const parameters = decodeParams(r);
1593
+ const parameters = decodeParams(r, "subscribe");
1583
1594
  return {
1584
1595
  type: "subscribe",
1585
1596
  request_id,
@@ -1590,13 +1601,13 @@ function decodeSubscribePayload(r) {
1590
1601
  }
1591
1602
  function decodeSubscribeOkPayload(r, payloadEnd) {
1592
1603
  const track_alias = r.readVarInt();
1593
- const parameters = decodeParams(r);
1604
+ const parameters = decodeParams(r, "subscribe_ok");
1594
1605
  const track_properties = decodeTrackProperties(r, payloadEnd);
1595
1606
  return { type: "subscribe_ok", track_alias, parameters, track_properties };
1596
1607
  }
1597
1608
  function decodeRequestUpdatePayload(r) {
1598
1609
  const request_id = r.readVarInt();
1599
- const parameters = decodeParams(r);
1610
+ const parameters = decodeParams(r, "request_update");
1600
1611
  return {
1601
1612
  type: "request_update",
1602
1613
  request_id,
@@ -1608,7 +1619,7 @@ function decodePublishPayload(r, payloadEnd) {
1608
1619
  const track_namespace = r.readTuple();
1609
1620
  const track_name = r.readString();
1610
1621
  const track_alias = r.readVarInt();
1611
- const parameters = decodeParams(r);
1622
+ const parameters = decodeParams(r, "publish");
1612
1623
  const track_properties = decodeTrackProperties(r, payloadEnd);
1613
1624
  return {
1614
1625
  type: "publish",
@@ -1629,7 +1640,7 @@ function decodePublishDonePayload(r) {
1629
1640
  function decodePublishNamespacePayload(r) {
1630
1641
  const request_id = r.readVarInt();
1631
1642
  const track_namespace = r.readTuple();
1632
- const parameters = decodeParams(r);
1643
+ const parameters = decodeParams(r, "publish_namespace");
1633
1644
  return {
1634
1645
  type: "publish_namespace",
1635
1646
  request_id,
@@ -1648,7 +1659,7 @@ function decodeNamespaceDonePayload(r) {
1648
1659
  function decodeSubscribeNamespacePayload(r) {
1649
1660
  const request_id = r.readVarInt();
1650
1661
  const namespace_prefix = r.readTuple();
1651
- const parameters = decodeParams(r);
1662
+ const parameters = decodeParams(r, "subscribe_namespace");
1652
1663
  return {
1653
1664
  type: "subscribe_namespace",
1654
1665
  request_id,
@@ -1659,7 +1670,7 @@ function decodeSubscribeNamespacePayload(r) {
1659
1670
  function decodeSubscribeTracksPayload(r) {
1660
1671
  const request_id = r.readVarInt();
1661
1672
  const namespace_prefix = r.readTuple();
1662
- const parameters = decodeParams(r);
1673
+ const parameters = decodeParams(r, "subscribe_tracks");
1663
1674
  return {
1664
1675
  type: "subscribe_tracks",
1665
1676
  request_id,
@@ -1701,7 +1712,7 @@ function decodeFetchPayload(r) {
1701
1712
  const joining_start = r.readVarInt();
1702
1713
  joining = { joining_request_id, joining_start };
1703
1714
  }
1704
- const parameters = decodeParams(r);
1715
+ const parameters = decodeParams(r, "fetch");
1705
1716
  return {
1706
1717
  type: "fetch",
1707
1718
  request_id,
@@ -1715,7 +1726,7 @@ function decodeFetchOkPayload(r, payloadEnd) {
1715
1726
  const end_of_track = r.readUint8();
1716
1727
  const end_group = r.readVarInt();
1717
1728
  const end_object = r.readVarInt();
1718
- const parameters = decodeParams(r);
1729
+ const parameters = decodeParams(r, "fetch_ok");
1719
1730
  const track_properties = decodeTrackProperties(r, payloadEnd);
1720
1731
  return {
1721
1732
  type: "fetch_ok",
@@ -1730,7 +1741,7 @@ function decodeTrackStatusPayload(r) {
1730
1741
  const request_id = r.readVarInt();
1731
1742
  const track_namespace = r.readTuple();
1732
1743
  const track_name = r.readString();
1733
- const parameters = decodeParams(r);
1744
+ const parameters = decodeParams(r, "track_status");
1734
1745
  return {
1735
1746
  type: "track_status",
1736
1747
  request_id,
@@ -1740,7 +1751,7 @@ function decodeTrackStatusPayload(r) {
1740
1751
  };
1741
1752
  }
1742
1753
  function decodeRequestOkPayload(r, payloadEnd) {
1743
- const parameters = decodeParams(r);
1754
+ const parameters = decodeParams(r, "request_ok");
1744
1755
  const track_properties = decodeTrackProperties(r, payloadEnd);
1745
1756
  return { type: "request_ok", parameters, track_properties };
1746
1757
  }
@@ -1121,7 +1121,6 @@ function encodePublishNamespacePayload(msg, w) {
1121
1121
  }
1122
1122
  function encodePublishNamespaceOkPayload(msg, w) {
1123
1123
  w.writeVarInt(msg.request_id);
1124
- encodeMessageParams(msg.parameters, w);
1125
1124
  }
1126
1125
  function encodePublishNamespaceErrorPayload(msg, w) {
1127
1126
  w.writeVarInt(msg.request_id);
@@ -1143,7 +1142,6 @@ function encodeSubscribeNamespacePayload(msg, w) {
1143
1142
  }
1144
1143
  function encodeSubscribeNamespaceOkPayload(msg, w) {
1145
1144
  w.writeVarInt(msg.request_id);
1146
- encodeMessageParams(msg.parameters, w);
1147
1145
  }
1148
1146
  function encodeSubscribeNamespaceErrorPayload(msg, w) {
1149
1147
  w.writeVarInt(msg.request_id);
@@ -1431,8 +1429,7 @@ function decodePublishNamespacePayload(r) {
1431
1429
  }
1432
1430
  function decodePublishNamespaceOkPayload(r) {
1433
1431
  const request_id = r.readVarInt();
1434
- const parameters = decodeMessageParams(r);
1435
- return { type: "publish_namespace_ok", request_id, parameters };
1432
+ return { type: "publish_namespace_ok", request_id };
1436
1433
  }
1437
1434
  function decodePublishNamespaceErrorPayload(r) {
1438
1435
  const request_id = r.readVarInt();
@@ -1473,8 +1470,7 @@ function decodeSubscribeNamespacePayload(r) {
1473
1470
  }
1474
1471
  function decodeSubscribeNamespaceOkPayload(r) {
1475
1472
  const request_id = r.readVarInt();
1476
- const parameters = decodeMessageParams(r);
1477
- return { type: "subscribe_namespace_ok", request_id, parameters };
1473
+ return { type: "subscribe_namespace_ok", request_id };
1478
1474
  }
1479
1475
  function decodeSubscribeNamespaceErrorPayload(r) {
1480
1476
  const request_id = r.readVarInt();