@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbdfdbf39ded

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 (205) hide show
  1. package/README.md +36 -20
  2. package/dist/align.d.ts +24 -18
  3. package/dist/align.d.ts.map +1 -1
  4. package/dist/align.js +23 -4
  5. package/dist/align.js.map +2 -2
  6. package/dist/browser-runtime.js +1721 -705
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +72 -34
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +309 -204
  11. package/dist/carp-catalog.js.map +3 -3
  12. package/dist/catalog-fec-params.d.ts +15 -4
  13. package/dist/catalog-fec-params.d.ts.map +1 -1
  14. package/dist/catalog-fec-params.js +137 -50
  15. package/dist/catalog-fec-params.js.map +4 -4
  16. package/dist/catalog-network-source.d.ts +24 -2
  17. package/dist/catalog-network-source.d.ts.map +1 -1
  18. package/dist/catalog-network-source.js +24 -1
  19. package/dist/catalog-network-source.js.map +3 -3
  20. package/dist/catalog-validator.d.ts +4 -3
  21. package/dist/catalog-validator.d.ts.map +1 -1
  22. package/dist/catalog-validator.js +0 -29
  23. package/dist/catalog-validator.js.map +3 -3
  24. package/dist/delivery-catalog.js +100 -230
  25. package/dist/delivery-catalog.js.map +4 -4
  26. package/dist/fec-manager.d.ts +64 -1
  27. package/dist/fec-manager.d.ts.map +1 -1
  28. package/dist/fec-manager.js +275 -62
  29. package/dist/fec-manager.js.map +4 -4
  30. package/dist/fec-state.d.ts +5 -3
  31. package/dist/fec-state.d.ts.map +1 -1
  32. package/dist/fec-state.js +34 -12
  33. package/dist/fec-state.js.map +4 -4
  34. package/dist/fec-worker-setup.d.ts +2 -0
  35. package/dist/fec-worker-setup.d.ts.map +1 -1
  36. package/dist/fec-worker-setup.js +15 -3
  37. package/dist/fec-worker-setup.js.map +3 -3
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +14 -8
  41. package/dist/index.js.map +2 -2
  42. package/dist/iso-block-locator.d.ts +29 -0
  43. package/dist/iso-block-locator.d.ts.map +1 -1
  44. package/dist/iso-block-locator.js +100 -17
  45. package/dist/iso-block-locator.js.map +4 -4
  46. package/dist/manifest-auth-plan.d.ts +26 -25
  47. package/dist/manifest-auth-plan.d.ts.map +1 -1
  48. package/dist/manifest-auth-plan.js +331 -1171
  49. package/dist/manifest-auth-plan.js.map +4 -4
  50. package/dist/mfu-reassembler.js +24 -13
  51. package/dist/mfu-reassembler.js.map +3 -3
  52. package/dist/mmtp-container-parser.d.ts.map +1 -1
  53. package/dist/mmtp-container-parser.js +96 -22
  54. package/dist/mmtp-container-parser.js.map +3 -3
  55. package/dist/mmtp-container-parser.no-modules.js +1138 -325
  56. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  57. package/dist/mmtp-decode-pipeline.js +96 -22
  58. package/dist/mmtp-decode-pipeline.js.map +3 -3
  59. package/dist/mmtp-fec-session.d.ts +159 -0
  60. package/dist/mmtp-fec-session.d.ts.map +1 -0
  61. package/dist/mmtp-fec-session.js +531 -0
  62. package/dist/mmtp-fec-session.js.map +7 -0
  63. package/dist/mmtp-router.d.ts +31 -5
  64. package/dist/mmtp-router.d.ts.map +1 -1
  65. package/dist/mmtp-router.js +168 -22
  66. package/dist/mmtp-router.js.map +3 -3
  67. package/dist/multicast-auth-catalog.d.ts +86 -92
  68. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  69. package/dist/multicast-auth-catalog.js +347 -132
  70. package/dist/multicast-auth-catalog.js.map +4 -4
  71. package/dist/multicast-input.d.ts +28 -6
  72. package/dist/multicast-input.d.ts.map +1 -1
  73. package/dist/multicast-input.js +293 -28
  74. package/dist/multicast-input.js.map +3 -3
  75. package/dist/multicast-manager.d.ts +89 -5
  76. package/dist/multicast-manager.d.ts.map +1 -1
  77. package/dist/multicast-manager.js +730 -356
  78. package/dist/multicast-manager.js.map +4 -4
  79. package/dist/multicast-transport.d.ts +12 -2
  80. package/dist/multicast-transport.d.ts.map +1 -1
  81. package/dist/multicast-transport.js +111 -235
  82. package/dist/multicast-transport.js.map +4 -4
  83. package/dist/multicast-unwrap.js +24 -13
  84. package/dist/multicast-unwrap.js.map +3 -3
  85. package/dist/no-modules.d.ts +4 -1
  86. package/dist/no-modules.d.ts.map +1 -1
  87. package/dist/no-modules.js +1087 -309
  88. package/dist/no-modules.js.map +4 -4
  89. package/dist/phase14-catalog-override.d.ts +1 -1
  90. package/dist/phase14-catalog-override.d.ts.map +1 -1
  91. package/dist/phase14-catalog-override.js +2 -2
  92. package/dist/phase14-catalog-override.js.map +2 -2
  93. package/dist/repair-fetch.d.ts +81 -6
  94. package/dist/repair-fetch.d.ts.map +1 -1
  95. package/dist/repair-fetch.js +159 -31
  96. package/dist/repair-fetch.js.map +3 -3
  97. package/dist/repair-layers.d.ts +2 -0
  98. package/dist/repair-layers.d.ts.map +1 -1
  99. package/dist/repair-layers.js +22 -2
  100. package/dist/repair-layers.js.map +3 -3
  101. package/dist/sample-combiner.d.ts +7 -1
  102. package/dist/sample-combiner.d.ts.map +1 -1
  103. package/dist/sample-combiner.js +14 -2
  104. package/dist/sample-combiner.js.map +2 -2
  105. package/dist/signaling.d.ts +2 -2
  106. package/dist/signaling.d.ts.map +1 -1
  107. package/dist/signaling.js +6 -3
  108. package/dist/signaling.js.map +3 -3
  109. package/dist/source-auth.js +2710 -7
  110. package/dist/source-auth.js.map +4 -4
  111. package/dist/switching-set-alignment.d.ts +1 -1
  112. package/dist/switching-set-alignment.js.map +1 -1
  113. package/dist/timestamp-codec.js +24 -13
  114. package/dist/timestamp-codec.js.map +3 -3
  115. package/dist/wasm-mfu-reassembler.js +3 -0
  116. package/dist/wasm-mfu-reassembler.js.map +3 -3
  117. package/dist/wasm-mmtp-container-parser.js +96 -22
  118. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  119. package/package.json +6 -9
  120. package/schemas/catalog.schema.json +124 -37
  121. package/src/align.ts +52 -21
  122. package/src/carp-catalog.ts +163 -61
  123. package/src/catalog-fec-params.ts +66 -20
  124. package/src/catalog-network-source.ts +45 -2
  125. package/src/catalog-validator.ts +4 -11
  126. package/src/fec-manager.ts +239 -63
  127. package/src/fec-state.ts +14 -12
  128. package/src/fec-worker-setup.ts +20 -2
  129. package/src/index.ts +29 -10
  130. package/src/iso-block-locator.ts +97 -6
  131. package/src/manifest-auth-plan.ts +39 -91
  132. package/src/mmtp-container-parser.ts +75 -7
  133. package/src/mmtp-fec-session.ts +533 -0
  134. package/src/mmtp-router.ts +133 -5
  135. package/src/multicast-auth-catalog.ts +131 -238
  136. package/src/multicast-input.ts +119 -61
  137. package/src/multicast-manager.ts +258 -21
  138. package/src/multicast-transport.ts +17 -3
  139. package/src/no-modules.ts +7 -1
  140. package/src/phase14-catalog-override.ts +3 -3
  141. package/src/repair-fetch.ts +283 -39
  142. package/src/repair-layers.ts +22 -2
  143. package/src/sample-combiner.ts +15 -2
  144. package/src/signaling.ts +2 -2
  145. package/src/switching-set-alignment.ts +1 -1
  146. package/test-vectors/align.json +108 -32
  147. package/test-vectors/bc-provenance-v2.json +1526 -0
  148. package/test-vectors/catalog/README.md +65 -4
  149. package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
  150. package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
  151. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
  152. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  153. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  154. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  155. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  156. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  157. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  158. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  159. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  160. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  161. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  162. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  163. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  164. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  165. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  166. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  167. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  168. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  169. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  170. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  171. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  172. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
  173. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  174. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  175. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  176. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  177. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  178. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  179. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  180. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  181. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  182. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  183. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
  184. package/test-vectors/catalog/positive/fec-multicast.json +1 -1
  185. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  186. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  187. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  188. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  189. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
  190. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  191. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  192. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  193. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  194. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  195. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  196. package/test-vectors/catalog/section-codes.json +30 -1
  197. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  198. package/test-vectors/catalog-validation.json +101 -5
  199. package/test-vectors/catalog-validator-public-api.mjs +14 -9
  200. package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
  201. package/dist/fec-codec.d.ts +0 -32
  202. package/dist/fec-codec.d.ts.map +0 -1
  203. package/dist/fec-codec.js +0 -47
  204. package/dist/fec-codec.js.map +0 -7
  205. package/src/fec-codec.ts +0 -61
@@ -26,195 +26,256 @@ function parseFecBlockProfile(value, where) {
26
26
  throw new Error(`${where} must be "iso-ssbg1-v1" (got ${JSON.stringify(value)})`);
27
27
  }
28
28
 
29
- // src/multicast-auth-catalog.ts
30
- var RAW_ED25519_KEY_LENGTH = 32;
31
- var SOURCE_AUTH_SCOPE_LENGTH = 32;
32
- var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
33
- function encodeBase64Url(bytes) {
34
- let output = "";
35
- for (let i = 0; i < bytes.length; i += 3) {
36
- const b0 = bytes[i];
37
- const b1 = bytes[i + 1];
38
- const b2 = bytes[i + 2];
39
- output += BASE64URL_ALPHABET[b0 >> 2];
40
- output += BASE64URL_ALPHABET[(b0 & 3) << 4 | (b1 === void 0 ? 0 : b1 >> 4)];
41
- if (b1 === void 0) break;
42
- output += BASE64URL_ALPHABET[(b1 & 15) << 2 | (b2 === void 0 ? 0 : b2 >> 6)];
43
- if (b2 === void 0) break;
44
- output += BASE64URL_ALPHABET[b2 & 63];
45
- }
46
- return output;
47
- }
48
- var BASE64URL_DECODE_TABLE = (() => {
49
- const table = new Int8Array(128).fill(-1);
50
- for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
51
- table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
52
- }
53
- return table;
54
- })();
55
- function decodeBase64Url(text) {
56
- if (text.length % 4 === 1) {
57
- throw new Error(`[multicast-auth-catalog] invalid unpadded base64url length for "${text}"`);
58
- }
59
- const bytes = [];
60
- let buffer = 0;
61
- let bits = 0;
62
- for (let i = 0; i < text.length; i++) {
63
- const code = text.charCodeAt(i);
64
- const value = code < 128 ? BASE64URL_DECODE_TABLE[code] : -1;
65
- if (value === void 0 || value < 0) {
66
- throw new Error(`[multicast-auth-catalog] invalid base64url character in "${text}"`);
67
- }
68
- buffer = buffer << 6 | value;
69
- bits += 6;
70
- if (bits >= 8) {
71
- bits -= 8;
72
- bytes.push(buffer >> bits & 255);
73
- }
74
- }
75
- const decoded = Uint8Array.from(bytes);
76
- if (encodeBase64Url(decoded) !== text) {
77
- throw new Error(`[multicast-auth-catalog] non-canonical base64url encoding "${text}"`);
78
- }
79
- return decoded;
80
- }
81
- function decodeAuthScope(authScope) {
82
- const bytes = decodeBase64Url(authScope);
83
- if (bytes.byteLength !== SOURCE_AUTH_SCOPE_LENGTH) {
84
- throw new Error(
85
- `[multicast-auth-catalog] authScope must decode to ${SOURCE_AUTH_SCOPE_LENGTH} raw bytes, got ${bytes.byteLength}`
86
- );
87
- }
88
- return bytes;
89
- }
90
- function decodeEd25519PublicKey(publicKey) {
91
- const bytes = decodeBase64Url(publicKey);
92
- if (bytes.byteLength !== RAW_ED25519_KEY_LENGTH) {
93
- throw new Error(
94
- `[multicast-auth-catalog] public key must decode to ${RAW_ED25519_KEY_LENGTH} raw bytes, got ${bytes.byteLength}`
95
- );
96
- }
97
- return bytes;
29
+ // ../mmt-base/dist/catalog-fec-source.js
30
+ var ALL_ROLES = Object.freeze(["video", "audio"]);
31
+ var ISO_SSBG1_MIN_SYMBOL_SIZE = 14;
32
+
33
+ // ../mmt-base/dist/multicast-catalog.js
34
+ var ED25519_PUBLIC_KEY_BASE64URL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
35
+ var UINT32_MAX = 4294967295;
36
+ var AUTH_MEMBERS = /* @__PURE__ */ new Set(["scheme", "version", "sig", "keys", "minEpoch"]);
37
+ var KEY_MEMBERS = /* @__PURE__ */ new Set(["kid", "publicKey", "firstEpoch"]);
38
+ var ENDPOINT_AUTH_MEMBERS = /* @__PURE__ */ new Set([
39
+ "manifestPort",
40
+ "streamId",
41
+ "senderAddress",
42
+ "maxAuthDelayMs",
43
+ "manifestTimerMs",
44
+ "manifestTrack"
45
+ ]);
46
+ function isObject(value) {
47
+ return typeof value === "object" && value !== null && !Array.isArray(value);
98
48
  }
99
49
  function isNonEmptyString(value) {
100
- return typeof value === "string" && value.length > 0;
50
+ return typeof value === "string" && value.trim().length > 0;
101
51
  }
102
- function isValidAuthScopeField(value) {
103
- if (!isNonEmptyString(value)) return false;
104
- try {
105
- decodeAuthScope(value);
106
- return true;
107
- } catch {
108
- return false;
109
- }
110
- }
111
- function isValidPublicKeyField(value) {
112
- if (!isNonEmptyString(value)) return false;
113
- try {
114
- decodeEd25519PublicKey(value);
115
- return true;
116
- } catch {
117
- return false;
118
- }
119
- }
120
- function hasOnlyKeys(object, allowed) {
121
- const allowedKeys = new Set(allowed);
122
- return Object.keys(object).every((key) => allowedKeys.has(key));
123
- }
124
- function isMulticastAuthTrackConfig(obj) {
125
- if (typeof obj !== "object" || obj === null) return false;
126
- const o = obj;
127
- return hasOnlyKeys(o, ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"]) && isNonEmptyString(o["mediaTrack"]) && isNonEmptyString(o["manifestTrack"]) && o["mediaTrack"] !== o["manifestTrack"] && isValidAuthScopeField(o["authScope"]) && isNonEmptyString(o["sourceSymbolFormat"]);
128
- }
129
- var VALID_COMPACTION = /* @__PURE__ */ new Set(["merkle", "none"]);
130
- var VALID_ENFORCEMENT = /* @__PURE__ */ new Set(["shadow", "enforce"]);
131
- function hasUniqueMulticastAuthTrackBindings(tracks) {
132
- const bindings = tracks.flatMap((track) => {
133
- if (typeof track !== "object" || track === null) return [];
134
- const value = track;
135
- if (typeof value["mediaTrack"] !== "string" || typeof value["sourceSymbolFormat"] !== "string") {
136
- return [];
137
- }
138
- return [JSON.stringify([value["mediaTrack"], value["sourceSymbolFormat"]])];
139
- });
140
- return new Set(bindings).size === bindings.length;
52
+ function isIntegerIn(value, min, max) {
53
+ return Number.isSafeInteger(value) && value >= min && value <= max;
141
54
  }
142
- function isMulticastAuthConfig(obj) {
143
- if (typeof obj !== "object" || obj === null) return false;
144
- const o = obj;
145
- if (o["scheme"] !== "bc-provenance") return false;
146
- if (o["hash"] !== "blake3") return false;
147
- if (o["sig"] !== "ed25519") return false;
148
- if (!hasOnlyKeys(o, ["scheme", "hash", "sig", "publicKey", "keyId", "previousKey", "compaction", "enforcement", "tracks"])) return false;
149
- if (!isValidPublicKeyField(o["publicKey"])) return false;
150
- if (!isNonEmptyString(o["keyId"])) return false;
151
- if (o["previousKey"] !== void 0 && !isValidPublicKeyField(o["previousKey"])) return false;
152
- if (o["previousKey"] === o["publicKey"]) return false;
153
- if (typeof o["compaction"] !== "string" || !VALID_COMPACTION.has(o["compaction"])) return false;
154
- if (o["enforcement"] !== void 0) {
155
- if (typeof o["enforcement"] !== "string" || !VALID_ENFORCEMENT.has(o["enforcement"])) return false;
156
- }
157
- if (!Array.isArray(o["tracks"]) || o["tracks"].length === 0) return false;
158
- const tracks = o["tracks"];
159
- if (!tracks.every((t) => isMulticastAuthTrackConfig(t))) return false;
160
- const typedTracks = tracks;
161
- const scopes = typedTracks.map((t) => t.authScope);
162
- if (new Set(scopes).size !== scopes.length) return false;
163
- if (!hasUniqueMulticastAuthTrackBindings(typedTracks)) return false;
164
- const manifestTracks = typedTracks.map((t) => t.manifestTrack);
165
- if (new Set(manifestTracks).size !== manifestTracks.length) return false;
166
- return true;
55
+ function multicastEndpointSource(endpoint) {
56
+ if (!isObject(endpoint))
57
+ return void 0;
58
+ const sourceAddress = endpoint["sourceAddress"];
59
+ if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress))
60
+ return void 0;
61
+ const mode = sourceAddress === void 0 ? "asm" : "ssm";
62
+ const protocol = endpoint["protocol"];
63
+ if (protocol !== void 0 && protocol !== mode)
64
+ return void 0;
65
+ const auth = endpoint["auth"];
66
+ const senderAddress = isObject(auth) ? auth["senderAddress"] : void 0;
67
+ if (mode === "ssm")
68
+ return senderAddress === void 0 ? { mode, source: sourceAddress } : void 0;
69
+ if (auth === void 0)
70
+ return { mode };
71
+ return isNonEmptyString(senderAddress) ? { mode, source: senderAddress } : void 0;
167
72
  }
168
- function resolveMulticastAuthMode(playerMode, auth) {
169
- if (playerMode !== void 0) return playerMode;
170
- if (auth === void 0) return "off";
171
- return auth.enforcement ?? "shadow";
73
+ function authIssues(auth) {
74
+ const base = "$.multicast.auth";
75
+ const issue = (path, message) => [
76
+ { code: "multicast_auth", path: `${base}${path}`, message }
77
+ ];
78
+ if (!isObject(auth))
79
+ return issue("", "auth must be an object");
80
+ const unknown = Object.keys(auth).filter((key) => !AUTH_MEMBERS.has(key));
81
+ if (unknown.length > 0) {
82
+ return issue("", `auth has unknown member(s) ${unknown.join(", ")}; draft -01 7.2.6 defines scheme, version, sig, keys and minEpoch`);
83
+ }
84
+ if (auth["scheme"] !== "bc-provenance")
85
+ return issue(".scheme", 'scheme must be "bc-provenance"');
86
+ if (auth["version"] !== 2)
87
+ return issue(".version", "version must be 2 (bc-provenance version 2, draft -01 7.2)");
88
+ if (auth["sig"] !== "ed25519")
89
+ return issue(".sig", 'sig must be "ed25519"');
90
+ const keys = auth["keys"];
91
+ if (!Array.isArray(keys) || keys.length < 1 || keys.length > 4) {
92
+ return issue(".keys", "keys must be an array of one to four {kid, publicKey, firstEpoch} objects");
93
+ }
94
+ const kids = /* @__PURE__ */ new Set();
95
+ const firstEpochs = /* @__PURE__ */ new Set();
96
+ for (let index = 0; index < keys.length; index++) {
97
+ const key = keys[index];
98
+ const at = `.keys[${index}]`;
99
+ if (!isObject(key) || Object.keys(key).some((member) => !KEY_MEMBERS.has(member))) {
100
+ return issue(at, "a key is exactly {kid, publicKey, firstEpoch}");
101
+ }
102
+ if (!isIntegerIn(key["kid"], 0, UINT32_MAX))
103
+ return issue(`${at}.kid`, "kid must be an unsigned 32-bit integer");
104
+ if (typeof key["publicKey"] !== "string" || !ED25519_PUBLIC_KEY_BASE64URL.test(key["publicKey"])) {
105
+ return issue(`${at}.publicKey`, "publicKey must be a 32-octet Ed25519 key in canonical unpadded base64url");
106
+ }
107
+ if (!isIntegerIn(key["firstEpoch"], 0, UINT32_MAX)) {
108
+ return issue(`${at}.firstEpoch`, "firstEpoch must be an unsigned 32-bit integer");
109
+ }
110
+ if (kids.has(key["kid"]))
111
+ return issue(`${at}.kid`, `kid ${key["kid"]} is repeated; the catalog holds no key set`);
112
+ if (firstEpochs.has(key["firstEpoch"])) {
113
+ return issue(`${at}.firstEpoch`, `firstEpoch ${key["firstEpoch"]} is repeated; the catalog holds no key set`);
114
+ }
115
+ kids.add(key["kid"]);
116
+ firstEpochs.add(key["firstEpoch"]);
117
+ }
118
+ if (!isIntegerIn(auth["minEpoch"], 0, UINT32_MAX)) {
119
+ return issue(".minEpoch", "minEpoch must be an unsigned 32-bit integer");
120
+ }
121
+ return [];
172
122
  }
173
- function resolveMulticastAuthCatalog(catalog, playerMode) {
174
- if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) {
175
- throw new Error("[multicast-auth-catalog] catalog must be an object");
123
+ function endpointAuthIssue(endpoint, mode, at) {
124
+ const auth = endpoint["auth"];
125
+ if (!isObject(auth))
126
+ return { path: `${at}.auth`, message: "auth must be an object" };
127
+ const unknown = Object.keys(auth).filter((key) => !ENDPOINT_AUTH_MEMBERS.has(key));
128
+ if (unknown.length > 0)
129
+ return { path: `${at}.auth`, message: `auth has unknown member(s) ${unknown.join(", ")}` };
130
+ if (!isIntegerIn(auth["manifestPort"], 1, 65535)) {
131
+ return { path: `${at}.auth.manifestPort`, message: "manifestPort must be an integer from 1 to 65535" };
176
132
  }
177
- const root = catalog;
178
- const rawAuth = root["multicast.auth"];
179
- if (rawAuth === void 0) {
180
- if (playerMode === "enforce") {
181
- throw new Error("[multicast-auth-catalog] player enforce mode requires multicast.auth");
182
- }
183
- return void 0;
133
+ if (!isIntegerIn(auth["streamId"], 0, UINT32_MAX)) {
134
+ return { path: `${at}.auth.streamId`, message: "streamId must be an unsigned 32-bit integer" };
184
135
  }
185
- if (!isMulticastAuthConfig(rawAuth)) {
186
- throw new Error("[multicast-auth-catalog] invalid multicast.auth v2 block");
136
+ if (mode === "ssm" && auth["senderAddress"] !== void 0) {
137
+ return { path: `${at}.auth.senderAddress`, message: "senderAddress must not appear on an SSM endpoint; S is sourceAddress" };
187
138
  }
188
- const rawTracks = root["tracks"];
189
- if (!Array.isArray(rawTracks)) {
190
- throw new Error("[multicast-auth-catalog] catalog tracks must be an array");
139
+ if (mode === "asm" && !isNonEmptyString(auth["senderAddress"])) {
140
+ return { path: `${at}.auth.senderAddress`, message: "a protected ASM endpoint requires senderAddress" };
191
141
  }
192
- const catalogTrackNames = new Set(
193
- rawTracks.flatMap(
194
- (track) => typeof track === "object" && track !== null && typeof track["name"] === "string" ? [track["name"]] : []
195
- )
196
- );
197
- for (const track of rawAuth.tracks) {
198
- if (!catalogTrackNames.has(track.mediaTrack)) {
199
- throw new Error(`[multicast-auth-catalog] unknown mediaTrack "${track.mediaTrack}"`);
200
- }
201
- if (!catalogTrackNames.has(track.manifestTrack)) {
202
- throw new Error(`[multicast-auth-catalog] unknown manifestTrack "${track.manifestTrack}"`);
203
- }
204
- }
205
- return {
206
- keyId: rawAuth.keyId,
207
- acceptedPublicKeys: [
208
- decodeEd25519PublicKey(rawAuth.publicKey),
209
- ...rawAuth.previousKey === void 0 ? [] : [decodeEd25519PublicKey(rawAuth.previousKey)]
210
- ],
211
- mode: resolveMulticastAuthMode(playerMode, rawAuth),
212
- compaction: rawAuth.compaction,
213
- tracks: rawAuth.tracks.map((track) => ({
214
- ...track,
215
- authScope: decodeAuthScope(track.authScope)
216
- }))
142
+ if (auth["maxAuthDelayMs"] !== void 0 && !isIntegerIn(auth["maxAuthDelayMs"], 50, 1e3)) {
143
+ return { path: `${at}.auth.maxAuthDelayMs`, message: "maxAuthDelayMs must be an integer from 50 to 1000" };
144
+ }
145
+ if (auth["manifestTimerMs"] !== void 0 && !isIntegerIn(auth["manifestTimerMs"], 1, Number.MAX_SAFE_INTEGER)) {
146
+ return { path: `${at}.auth.manifestTimerMs`, message: "manifestTimerMs must be an integer of at least 1" };
147
+ }
148
+ if (auth["manifestTrack"] !== void 0 && !isNonEmptyString(auth["manifestTrack"])) {
149
+ return { path: `${at}.auth.manifestTrack`, message: "manifestTrack must be a non-empty string" };
150
+ }
151
+ if (!isIntegerIn(endpoint["bandwidth"], 1, Number.MAX_SAFE_INTEGER)) {
152
+ return { path: `${at}.bandwidth`, message: "a protected endpoint requires bandwidth, which bounds the receiver's hold queues" };
153
+ }
154
+ return void 0;
155
+ }
156
+ var CATALOG_NAMESPACE = /* @__PURE__ */ Symbol.for("@blockcast/mmt-base/catalogNamespace");
157
+ function multicastCatalogIssues(catalog, options = {}) {
158
+ if (!isObject(catalog))
159
+ return [];
160
+ const issues = [];
161
+ if ("multicast.auth" in catalog) {
162
+ issues.push({
163
+ code: "multicast_auth",
164
+ path: '$["multicast.auth"]',
165
+ message: 'the root "multicast.auth" key is retired; declare auth as multicast.auth (draft -01 7.2.6)'
166
+ });
167
+ }
168
+ const multicast = catalog["multicast"];
169
+ if (!isObject(multicast))
170
+ return issues;
171
+ const protectedCatalog = multicast["auth"] !== void 0;
172
+ if (protectedCatalog)
173
+ issues.push(...authIssues(multicast["auth"]));
174
+ const endpoints = multicast["endpoints"];
175
+ if (!Array.isArray(endpoints))
176
+ return issues;
177
+ const tracks = Array.isArray(catalog["tracks"]) ? catalog["tracks"] : [];
178
+ const namespaceOf = /* @__PURE__ */ new Map();
179
+ for (const track of tracks) {
180
+ if (isObject(track) && typeof track["name"] === "string")
181
+ namespaceOf.set(track["name"], track["namespace"]);
182
+ }
183
+ const tagged = catalog[CATALOG_NAMESPACE];
184
+ let referenceNamespace = options.catalogNamespace ?? (typeof tagged === "string" ? tagged : void 0);
185
+ const sources = [];
186
+ for (let index = 0; index < endpoints.length; index++) {
187
+ const endpoint = endpoints[index];
188
+ const at = `$.multicast.endpoints[${index}]`;
189
+ const fail = (code, path, message) => {
190
+ issues.push({ code, path, message, endpointIndex: index });
191
+ };
192
+ sources.push(void 0);
193
+ if (!isObject(endpoint)) {
194
+ fail("multicast_endpoint", at, "endpoint must be an object");
195
+ continue;
196
+ }
197
+ const protocol = endpoint["protocol"];
198
+ if (protocol !== void 0 && protocol !== "ssm" && protocol !== "asm") {
199
+ fail("multicast_endpoint", `${at}.protocol`, `protocol must be "ssm" or "asm"; a bearer such as ${JSON.stringify(protocol)} is a networkSource entry (draft -01 4.2)`);
200
+ continue;
201
+ }
202
+ const hasAuth = endpoint["auth"] !== void 0;
203
+ if (protectedCatalog !== hasAuth) {
204
+ fail("multicast_endpoint_auth", `${at}.auth`, protectedCatalog ? "every endpoint requires auth when multicast carries auth; a receiver ignores this endpoint" : "auth names no key without multicast.auth; a receiver ignores this endpoint");
205
+ continue;
206
+ }
207
+ const sourceAddress = endpoint["sourceAddress"];
208
+ if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress)) {
209
+ fail("multicast_endpoint", `${at}.sourceAddress`, "sourceAddress must be a non-empty string");
210
+ continue;
211
+ }
212
+ const mode = sourceAddress === void 0 ? "asm" : "ssm";
213
+ if (protocol !== void 0 && protocol !== mode) {
214
+ fail("multicast_endpoint", `${at}.protocol`, `protocol ${JSON.stringify(protocol)} disagrees with sourceAddress, which selects ${mode}`);
215
+ continue;
216
+ }
217
+ if (!isIntegerIn(endpoint["port"], 1, 65535)) {
218
+ fail("multicast_endpoint", `${at}.port`, "port must be an integer from 1 to 65535");
219
+ continue;
220
+ }
221
+ if (hasAuth) {
222
+ const authIssue = endpointAuthIssue(endpoint, mode, at);
223
+ if (authIssue) {
224
+ fail("multicast_endpoint_auth", authIssue.path, authIssue.message);
225
+ continue;
226
+ }
227
+ }
228
+ sources[index] = multicastEndpointSource(endpoint);
229
+ const refs = Array.isArray(endpoint["tracks"]) ? endpoint["tracks"] : [];
230
+ for (let refIndex = 0; refIndex < refs.length; refIndex++) {
231
+ const ref = refs[refIndex];
232
+ const name = isObject(ref) ? ref["name"] : ref;
233
+ if (typeof name !== "string")
234
+ continue;
235
+ const namespace = namespaceOf.get(name);
236
+ if (typeof namespace !== "string")
237
+ continue;
238
+ referenceNamespace ??= namespace;
239
+ if (namespace !== referenceNamespace) {
240
+ fail("multicast_track", `${at}.tracks[${refIndex}].name`, `track ${JSON.stringify(name)} declares namespace ${JSON.stringify(namespace)}, not the catalog track's ${JSON.stringify(referenceNamespace)}`);
241
+ }
242
+ }
243
+ }
244
+ const tupleOf = (index) => {
245
+ const endpoint = endpoints[index];
246
+ const auth = endpoint["auth"];
247
+ return {
248
+ sg: JSON.stringify([sources[index].source ?? null, endpoint["groupAddress"]]),
249
+ port: endpoint["port"],
250
+ manifestPort: isObject(auth) ? auth["manifestPort"] : void 0
251
+ };
217
252
  };
253
+ for (let index = 0; index < endpoints.length; index++) {
254
+ if (!sources[index])
255
+ continue;
256
+ const own = tupleOf(index);
257
+ const at = `$.multicast.endpoints[${index}]`;
258
+ if (own.manifestPort !== void 0 && own.manifestPort === own.port) {
259
+ issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: "manifestPort must differ from the endpoint's own port", endpointIndex: index });
260
+ continue;
261
+ }
262
+ for (let other = 0; other < endpoints.length; other++) {
263
+ if (other === index || !sources[other])
264
+ continue;
265
+ const peer = tupleOf(other);
266
+ if (peer.sg !== own.sg)
267
+ continue;
268
+ if (peer.port === own.port) {
269
+ issues.push({ code: "multicast_endpoint", path: `${at}.port`, message: `(S, G, port) is shared with endpoint ${other}; one endpoint object per multicast tuple`, endpointIndex: index });
270
+ break;
271
+ }
272
+ if (own.manifestPort !== void 0 && (own.manifestPort === peer.port || own.manifestPort === peer.manifestPort)) {
273
+ issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: `manifestPort is a port or manifestPort of endpoint ${other} on the same (S, G)`, endpointIndex: index });
274
+ break;
275
+ }
276
+ }
277
+ }
278
+ return issues;
218
279
  }
219
280
 
220
281
  // src/repair-layers.ts
@@ -224,6 +285,7 @@ var DEFAULT_REPAIR_PRIORITY = 240;
224
285
  var MAX_RAPTORQ_SOURCE_SYMBOLS = 56403;
225
286
  var MAX_REPAIR_SYMBOLS = 16777215;
226
287
  var MAX_ENCODING_SYMBOL_ID = 16777215;
288
+ var MAX_REED_SOLOMON_BLOCK_SYMBOLS = 255;
227
289
  var RepairContractError = class extends Error {
228
290
  constructor(code, path, message) {
229
291
  super(`[repair-layers:${code}] ${path}: ${message}`);
@@ -406,11 +468,12 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
406
468
  if (layered && !positiveInteger(source.sourceSymbols)) {
407
469
  fail("track_fec", `${source.path}.sourceSymbols`, "layered or overlay repair needs a positive integer sourceSymbols on the source");
408
470
  }
409
- if (layered && source.algorithm !== "raptorq") {
471
+ const reedSolomon = source.algorithm === "reed-solomon";
472
+ if (layered && source.algorithm !== "raptorq" && !reedSolomon) {
410
473
  fail(
411
474
  "track_fec",
412
475
  `${source.path}.algorithm`,
413
- "repair layers and overlays are defined only for raptorq: a block code fixes its codeword length, so symbols of a larger P are not symbols of the code a receiver holding fewer layers decodes"
476
+ "repair layers and overlays are defined only for raptorq and reed-solomon (draft-ramadan-moq-fec-01 6.3.4 rule 7)"
414
477
  );
415
478
  }
416
479
  let layerZeroPriority = DEFAULT_REPAIR_PRIORITY;
@@ -469,6 +532,13 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
469
532
  `overlay sourceSymbols + repairSymbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
470
533
  );
471
534
  }
535
+ if (reedSolomon && sourceSymbols + repairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
536
+ fail(
537
+ "track_fec_bounds",
538
+ `${d.path}.repairSymbols`,
539
+ `reed-solomon overlay sourceSymbols + repairSymbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
540
+ );
541
+ }
472
542
  overlays.push({ repairTrackName: d.name, scope: "keyframe", sourceSymbols, repairSymbols, priority: d.priority });
473
543
  }
474
544
  let offset = layerZeroSymbols;
@@ -513,6 +583,13 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
513
583
  `sourceSymbols + total base repair symbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
514
584
  );
515
585
  }
586
+ if (reedSolomon && k + totalBaseRepairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
587
+ fail(
588
+ "track_fec_bounds",
589
+ `${source.path}.sourceSymbols`,
590
+ `reed-solomon sourceSymbols + total base repair symbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
591
+ );
592
+ }
516
593
  return { sourceTrackName: source.name, baseLayers, overlays, totalBaseRepairSymbols };
517
594
  }
518
595
 
@@ -562,7 +639,7 @@ function validateSwitchingSet(trackNames) {
562
639
  return { ok: true };
563
640
  }
564
641
  const presentRoles = new Set(roles.filter((r) => r !== "single"));
565
- const required = ["base", "delta", "repair"];
642
+ const required = ["base", "repair"];
566
643
  const missing = required.filter((r) => !presentRoles.has(r));
567
644
  if (missing.length > 0) {
568
645
  return { ok: false, missing };
@@ -574,7 +651,7 @@ function isFecCatalogGeometry(obj) {
574
651
  const o = obj;
575
652
  const algorithm = o["algorithm"];
576
653
  const symbolSize = o["symbolSize"];
577
- return typeof algorithm === "string" && (algorithm === "none" || algorithm === "raptorq" || algorithm === "reed-solomon") && typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 && typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 && typeof symbolSize === "number" && symbolSize >= 1 && (algorithm !== "raptorq" || symbolSize % 8 === 0) && typeof o["repairTrack"] === "string" && o["repairTrack"].length > 0;
654
+ return typeof algorithm === "string" && algorithm.length > 0 && typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 && typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 && typeof symbolSize === "number" && symbolSize >= 1 && (algorithm !== "raptorq" || symbolSize % 8 === 0) && typeof o["repairTrack"] === "string" && o["repairTrack"].length > 0;
578
655
  }
579
656
  function isFecCatalogConfig(obj) {
580
657
  if (!isFecCatalogGeometry(obj)) return false;
@@ -589,8 +666,7 @@ function isMulticastTrackObject(obj) {
589
666
  function isMulticastEndpoint(obj) {
590
667
  if (typeof obj !== "object" || obj === null) return false;
591
668
  const o = obj;
592
- const protocol = o["protocol"] ?? (typeof o["sourceAddress"] === "string" && o["sourceAddress"].length > 0 ? "ssm" : void 0);
593
- return typeof protocol === "string" && (protocol === "ssm" || protocol === "asm" || protocol === "amt" || protocol === "atsc3") && typeof o["groupAddress"] === "string" && o["groupAddress"].length > 0 && typeof o["port"] === "number" && o["port"] > 0 && o["port"] <= 65535 && Array.isArray(o["tracks"]) && o["tracks"].every((t) => typeof t === "string" || isMulticastTrackObject(t));
669
+ return multicastEndpointSource(o) !== void 0 && typeof o["groupAddress"] === "string" && o["groupAddress"].length > 0 && typeof o["port"] === "number" && o["port"] > 0 && o["port"] <= 65535 && Array.isArray(o["tracks"]) && o["tracks"].every((t) => typeof t === "string" || isMulticastTrackObject(t));
594
670
  }
595
671
  function isMulticastCatalogConfig(obj) {
596
672
  if (typeof obj !== "object" || obj === null) return false;
@@ -694,7 +770,7 @@ var CmsfCatalogValidationError = class extends Error {
694
770
  function catalogError(code, path, message) {
695
771
  throw new CmsfCatalogValidationError(code, path, message);
696
772
  }
697
- function validateCmsfMmtpCatalog(value) {
773
+ function validateCmsfMmtpCatalog(value, options = {}) {
698
774
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
699
775
  catalogError("catalog_object", "$", "catalog must be an object");
700
776
  }
@@ -715,6 +791,22 @@ function validateCmsfMmtpCatalog(value) {
715
791
  "commonTrackFields is retired; every track carries its own fields"
716
792
  );
717
793
  }
794
+ const initDataList = catalog["initDataList"];
795
+ if (initDataList !== void 0) {
796
+ if (!Array.isArray(initDataList)) {
797
+ catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
798
+ }
799
+ initDataList.forEach((entry, i) => {
800
+ const e = entry;
801
+ const entryPath = `$.initDataList[${i}]`;
802
+ if (typeof e !== "object" || e === null || Array.isArray(e) || typeof e["id"] !== "string" || e["id"].length === 0 || typeof e["type"] !== "string" || e["type"].length === 0) {
803
+ catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
804
+ }
805
+ if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
806
+ catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
807
+ }
808
+ });
809
+ }
718
810
  const tracks = catalog["tracks"];
719
811
  const trackRecords = [];
720
812
  const positiveInteger2 = (input) => Number.isSafeInteger(input) && input > 0;
@@ -766,6 +858,14 @@ function validateCmsfMmtpCatalog(value) {
766
858
  if (keyframeIntervalMs !== void 0 && !positiveNumber(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger2(keyframeIntervalTicks)) {
767
859
  catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
768
860
  }
861
+ const anchor = track["presentationAnchorTicks"];
862
+ if (anchor !== void 0 && !Number.isSafeInteger(anchor)) {
863
+ catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
864
+ }
865
+ const initRef = track["initRef"];
866
+ if (initRef !== void 0 && (typeof initRef !== "string" || initRef.length === 0)) {
867
+ catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
868
+ }
769
869
  if (packaging === "fec-repair") {
770
870
  rejectRepairTrackGeometry(path, track, catalogError);
771
871
  validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
@@ -773,9 +873,8 @@ function validateCmsfMmtpCatalog(value) {
773
873
  rejectRepairFieldsOnMediaTrack(path, track, catalogError);
774
874
  }
775
875
  if (packaging === "mmtp") {
776
- const mmtpMode = track["mmtpMode"];
777
- if (mmtpMode !== "mpu" && mmtpMode !== "mfu") {
778
- catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
876
+ if (track["mmtpMode"] !== "mfu") {
877
+ catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
779
878
  }
780
879
  if (!positiveInteger2(timescale)) {
781
880
  catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
@@ -798,8 +897,8 @@ function validateCmsfMmtpCatalog(value) {
798
897
  }
799
898
  const config = fec;
800
899
  const algorithm = config["algorithm"];
801
- if (algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon") {
802
- catalogError("track_fec", `${path}.fec.algorithm`, "algorithm is not supported");
900
+ if (typeof algorithm !== "string" || algorithm.length === 0) {
901
+ catalogError("track_fec", `${path}.fec.algorithm`, "must be a non-empty string");
803
902
  }
804
903
  if ("interleaveDepth" in config || "interleaveMs" in config) {
805
904
  catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
@@ -828,6 +927,9 @@ function validateCmsfMmtpCatalog(value) {
828
927
  }
829
928
  }
830
929
  readFecBlockProfile(config["blockProfile"], `${path}.fec.blockProfile`, algorithm !== "none", catalogError);
930
+ if (algorithm !== "none" && config["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE) {
931
+ catalogError("track_fec", `${path}.fec.symbolSize`, "iso-ssbg1-v1 symbolSize must be at least 14");
932
+ }
831
933
  }
832
934
  }
833
935
  const repairDescriptors = trackRecords.flatMap(
@@ -877,11 +979,21 @@ function validateCmsfMmtpCatalog(value) {
877
979
  const timescale = BigInt(track["timescale"]);
878
980
  const durationTicks = track["groupDurationTicks"];
879
981
  const ticks = durationTicks !== void 0 ? BigInt(durationTicks) : BigInt(track["groupDurationMs"]) * timescale / 1000n;
880
- const anchor = switchingSets.get(altGroup);
881
- if (anchor && ticks * anchor.timescale !== anchor.ticks * timescale) {
882
- catalogError("track_switching_set", `$.tracks[${index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
982
+ const framerate = track["framerate"];
983
+ const intraOnly = positiveNumber(framerate) && Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
984
+ const members = switchingSets.get(altGroup) ?? [];
985
+ members.push({ index, name: track["name"], ticks, timescale, intraOnly });
986
+ switchingSets.set(altGroup, members);
987
+ }
988
+ for (const [altGroup, members] of switchingSets) {
989
+ const anchor = members.find((member) => !member.intraOnly) ?? members[0];
990
+ for (const member of members) {
991
+ if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
992
+ const nests = member.intraOnly && !anchor.intraOnly && anchor.ticks * member.timescale % (member.ticks * anchor.timescale) === 0n;
993
+ if (!nests) {
994
+ catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
995
+ }
883
996
  }
884
- if (!anchor) switchingSets.set(altGroup, { name: track["name"], ticks, timescale });
885
997
  }
886
998
  const multicast = catalog["multicast"];
887
999
  if (typeof multicast === "object" && multicast !== null && !Array.isArray(multicast)) {
@@ -929,15 +1041,8 @@ function validateCmsfMmtpCatalog(value) {
929
1041
  }
930
1042
  }
931
1043
  }
932
- try {
933
- resolveMulticastAuthCatalog(catalog);
934
- } catch (error) {
935
- catalogError(
936
- "multicast_auth",
937
- "$.multicast.auth",
938
- error instanceof Error ? error.message : "invalid multicast.auth v2 block"
939
- );
940
- }
1044
+ const [multicastIssue] = multicastCatalogIssues(catalog, options);
1045
+ if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
941
1046
  validateArchive(catalog);
942
1047
  return catalog;
943
1048
  }
@@ -963,7 +1068,7 @@ function resolveGroupDurationTicks(timing, timescale) {
963
1068
  const product = timing.groupDurationMs * timescale;
964
1069
  if (product % 1e3 !== 0) {
965
1070
  throw new Error(
966
- `[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-00 \xA74.4.4)`
1071
+ `[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-01 \xA74.4.2)`
967
1072
  );
968
1073
  }
969
1074
  return product / 1e3;