@blockcast/mmt-container 0.4.0-main.94b7ef7dcd8d → 0.4.0-main.9d97fa55ba69
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.
- package/README.md +15 -11
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +704 -302
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +57 -29
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +266 -194
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +1 -1
- package/dist/catalog-fec-params.js +0 -10
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +24 -2
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/delivery-catalog.js +16 -2
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/fec-manager.d.ts +36 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +161 -23
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.js.map +1 -1
- package/dist/fec-worker-setup.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +29 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/manifest-auth-plan.d.ts +26 -25
- package/dist/manifest-auth-plan.d.ts.map +1 -1
- package/dist/manifest-auth-plan.js +331 -1171
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mfu-reassembler.js.map +1 -1
- package/dist/mmtp-container-parser.js.map +1 -1
- package/dist/mmtp-container-parser.no-modules.js +457 -266
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js.map +1 -1
- package/dist/mmtp-fec-session.d.ts.map +1 -1
- package/dist/mmtp-fec-session.js +3 -1
- package/dist/mmtp-fec-session.js.map +2 -2
- package/dist/mmtp-router.d.ts +14 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +11 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +347 -132
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +28 -6
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +290 -28
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +19 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +212 -44
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +18 -3
- package/dist/multicast-transport.js.map +2 -2
- package/dist/multicast-unwrap.js.map +1 -1
- package/dist/no-modules.d.ts +1 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +457 -266
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +58 -5
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +122 -22
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.js.map +1 -1
- package/dist/signaling.js.map +1 -1
- package/dist/source-auth.js +2710 -7
- package/dist/source-auth.js.map +4 -4
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js.map +1 -1
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js.map +1 -1
- package/package.json +6 -5
- package/schemas/catalog.schema.json +113 -36
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +106 -48
- package/src/catalog-fec-params.ts +1 -1
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +99 -14
- package/src/index.ts +7 -2
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-fec-session.ts +7 -1
- package/src/mmtp-router.ts +24 -0
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +35 -12
- package/src/multicast-transport.ts +3 -0
- package/src/no-modules.ts +1 -1
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +204 -25
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +47 -3
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +21 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +3 -2
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
package/dist/carp-catalog.js
CHANGED
|
@@ -30,195 +30,252 @@ function parseFecBlockProfile(value, where) {
|
|
|
30
30
|
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
31
31
|
var ISO_SSBG1_MIN_SYMBOL_SIZE = 14;
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
output += BASE64URL_ALPHABET[b2 & 63];
|
|
49
|
-
}
|
|
50
|
-
return output;
|
|
51
|
-
}
|
|
52
|
-
var BASE64URL_DECODE_TABLE = (() => {
|
|
53
|
-
const table = new Int8Array(128).fill(-1);
|
|
54
|
-
for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
|
|
55
|
-
table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
|
|
56
|
-
}
|
|
57
|
-
return table;
|
|
58
|
-
})();
|
|
59
|
-
function decodeBase64Url(text) {
|
|
60
|
-
if (text.length % 4 === 1) {
|
|
61
|
-
throw new Error(`[multicast-auth-catalog] invalid unpadded base64url length for "${text}"`);
|
|
62
|
-
}
|
|
63
|
-
const bytes = [];
|
|
64
|
-
let buffer = 0;
|
|
65
|
-
let bits = 0;
|
|
66
|
-
for (let i = 0; i < text.length; i++) {
|
|
67
|
-
const code = text.charCodeAt(i);
|
|
68
|
-
const value = code < 128 ? BASE64URL_DECODE_TABLE[code] : -1;
|
|
69
|
-
if (value === void 0 || value < 0) {
|
|
70
|
-
throw new Error(`[multicast-auth-catalog] invalid base64url character in "${text}"`);
|
|
71
|
-
}
|
|
72
|
-
buffer = buffer << 6 | value;
|
|
73
|
-
bits += 6;
|
|
74
|
-
if (bits >= 8) {
|
|
75
|
-
bits -= 8;
|
|
76
|
-
bytes.push(buffer >> bits & 255);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const decoded = Uint8Array.from(bytes);
|
|
80
|
-
if (encodeBase64Url(decoded) !== text) {
|
|
81
|
-
throw new Error(`[multicast-auth-catalog] non-canonical base64url encoding "${text}"`);
|
|
82
|
-
}
|
|
83
|
-
return decoded;
|
|
84
|
-
}
|
|
85
|
-
function decodeAuthScope(authScope) {
|
|
86
|
-
const bytes = decodeBase64Url(authScope);
|
|
87
|
-
if (bytes.byteLength !== SOURCE_AUTH_SCOPE_LENGTH) {
|
|
88
|
-
throw new Error(
|
|
89
|
-
`[multicast-auth-catalog] authScope must decode to ${SOURCE_AUTH_SCOPE_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return bytes;
|
|
93
|
-
}
|
|
94
|
-
function decodeEd25519PublicKey(publicKey) {
|
|
95
|
-
const bytes = decodeBase64Url(publicKey);
|
|
96
|
-
if (bytes.byteLength !== RAW_ED25519_KEY_LENGTH) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`[multicast-auth-catalog] public key must decode to ${RAW_ED25519_KEY_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
return bytes;
|
|
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);
|
|
102
48
|
}
|
|
103
49
|
function isNonEmptyString(value) {
|
|
104
|
-
return typeof value === "string" && value.length > 0;
|
|
105
|
-
}
|
|
106
|
-
function isValidAuthScopeField(value) {
|
|
107
|
-
if (!isNonEmptyString(value)) return false;
|
|
108
|
-
try {
|
|
109
|
-
decodeAuthScope(value);
|
|
110
|
-
return true;
|
|
111
|
-
} catch {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
50
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
114
51
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
decodeEd25519PublicKey(value);
|
|
119
|
-
return true;
|
|
120
|
-
} catch {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function hasOnlyKeys(object, allowed) {
|
|
125
|
-
const allowedKeys = new Set(allowed);
|
|
126
|
-
return Object.keys(object).every((key) => allowedKeys.has(key));
|
|
127
|
-
}
|
|
128
|
-
function isMulticastAuthTrackConfig(obj) {
|
|
129
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
130
|
-
const o = obj;
|
|
131
|
-
return hasOnlyKeys(o, ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"]) && isNonEmptyString(o["mediaTrack"]) && isNonEmptyString(o["manifestTrack"]) && o["mediaTrack"] !== o["manifestTrack"] && isValidAuthScopeField(o["authScope"]) && isNonEmptyString(o["sourceSymbolFormat"]);
|
|
132
|
-
}
|
|
133
|
-
var VALID_COMPACTION = /* @__PURE__ */ new Set(["merkle", "none"]);
|
|
134
|
-
var VALID_ENFORCEMENT = /* @__PURE__ */ new Set(["shadow", "enforce"]);
|
|
135
|
-
function hasUniqueMulticastAuthTrackBindings(tracks) {
|
|
136
|
-
const bindings = tracks.flatMap((track) => {
|
|
137
|
-
if (typeof track !== "object" || track === null) return [];
|
|
138
|
-
const value = track;
|
|
139
|
-
if (typeof value["mediaTrack"] !== "string" || typeof value["sourceSymbolFormat"] !== "string") {
|
|
140
|
-
return [];
|
|
141
|
-
}
|
|
142
|
-
return [JSON.stringify([value["mediaTrack"], value["sourceSymbolFormat"]])];
|
|
143
|
-
});
|
|
144
|
-
return new Set(bindings).size === bindings.length;
|
|
52
|
+
function isIntegerIn(value, min, max) {
|
|
53
|
+
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
145
54
|
}
|
|
146
|
-
function
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (!tracks.every((t) => isMulticastAuthTrackConfig(t))) return false;
|
|
164
|
-
const typedTracks = tracks;
|
|
165
|
-
const scopes = typedTracks.map((t) => t.authScope);
|
|
166
|
-
if (new Set(scopes).size !== scopes.length) return false;
|
|
167
|
-
if (!hasUniqueMulticastAuthTrackBindings(typedTracks)) return false;
|
|
168
|
-
const manifestTracks = typedTracks.map((t) => t.manifestTrack);
|
|
169
|
-
if (new Set(manifestTracks).size !== manifestTracks.length) return false;
|
|
170
|
-
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;
|
|
171
72
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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 [];
|
|
176
122
|
}
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
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" };
|
|
180
132
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (rawAuth === void 0) {
|
|
184
|
-
if (playerMode === "enforce") {
|
|
185
|
-
throw new Error("[multicast-auth-catalog] player enforce mode requires multicast.auth");
|
|
186
|
-
}
|
|
187
|
-
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" };
|
|
188
135
|
}
|
|
189
|
-
if (
|
|
190
|
-
|
|
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" };
|
|
191
138
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
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" };
|
|
195
141
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
})
|
|
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
|
+
};
|
|
221
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;
|
|
222
279
|
}
|
|
223
280
|
|
|
224
281
|
// src/repair-layers.ts
|
|
@@ -593,8 +650,7 @@ function isMulticastTrackObject(obj) {
|
|
|
593
650
|
function isMulticastEndpoint(obj) {
|
|
594
651
|
if (typeof obj !== "object" || obj === null) return false;
|
|
595
652
|
const o = obj;
|
|
596
|
-
|
|
597
|
-
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));
|
|
653
|
+
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));
|
|
598
654
|
}
|
|
599
655
|
function isMulticastCatalogConfig(obj) {
|
|
600
656
|
if (typeof obj !== "object" || obj === null) return false;
|
|
@@ -698,7 +754,7 @@ var CmsfCatalogValidationError = class extends Error {
|
|
|
698
754
|
function catalogError(code, path, message) {
|
|
699
755
|
throw new CmsfCatalogValidationError(code, path, message);
|
|
700
756
|
}
|
|
701
|
-
function validateCmsfMmtpCatalog(value) {
|
|
757
|
+
function validateCmsfMmtpCatalog(value, options = {}) {
|
|
702
758
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
703
759
|
catalogError("catalog_object", "$", "catalog must be an object");
|
|
704
760
|
}
|
|
@@ -719,6 +775,22 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
719
775
|
"commonTrackFields is retired; every track carries its own fields"
|
|
720
776
|
);
|
|
721
777
|
}
|
|
778
|
+
const initDataList = catalog["initDataList"];
|
|
779
|
+
if (initDataList !== void 0) {
|
|
780
|
+
if (!Array.isArray(initDataList)) {
|
|
781
|
+
catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
|
|
782
|
+
}
|
|
783
|
+
initDataList.forEach((entry, i) => {
|
|
784
|
+
const e = entry;
|
|
785
|
+
const entryPath = `$.initDataList[${i}]`;
|
|
786
|
+
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) {
|
|
787
|
+
catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
|
|
788
|
+
}
|
|
789
|
+
if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
|
|
790
|
+
catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
}
|
|
722
794
|
const tracks = catalog["tracks"];
|
|
723
795
|
const trackRecords = [];
|
|
724
796
|
const positiveInteger2 = (input) => Number.isSafeInteger(input) && input > 0;
|
|
@@ -770,6 +842,14 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
770
842
|
if (keyframeIntervalMs !== void 0 && !positiveNumber(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger2(keyframeIntervalTicks)) {
|
|
771
843
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
772
844
|
}
|
|
845
|
+
const anchor = track["presentationAnchorTicks"];
|
|
846
|
+
if (anchor !== void 0 && !Number.isSafeInteger(anchor)) {
|
|
847
|
+
catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
|
|
848
|
+
}
|
|
849
|
+
const initRef = track["initRef"];
|
|
850
|
+
if (initRef !== void 0 && (typeof initRef !== "string" || initRef.length === 0)) {
|
|
851
|
+
catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
|
|
852
|
+
}
|
|
773
853
|
if (packaging === "fec-repair") {
|
|
774
854
|
rejectRepairTrackGeometry(path, track, catalogError);
|
|
775
855
|
validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
|
|
@@ -777,9 +857,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
777
857
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
778
858
|
}
|
|
779
859
|
if (packaging === "mmtp") {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
|
|
860
|
+
if (track["mmtpMode"] !== "mfu") {
|
|
861
|
+
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
|
|
783
862
|
}
|
|
784
863
|
if (!positiveInteger2(timescale)) {
|
|
785
864
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -946,15 +1025,8 @@ function validateCmsfMmtpCatalog(value) {
|
|
|
946
1025
|
}
|
|
947
1026
|
}
|
|
948
1027
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
} catch (error) {
|
|
952
|
-
catalogError(
|
|
953
|
-
"multicast_auth",
|
|
954
|
-
"$.multicast.auth",
|
|
955
|
-
error instanceof Error ? error.message : "invalid multicast.auth v2 block"
|
|
956
|
-
);
|
|
957
|
-
}
|
|
1028
|
+
const [multicastIssue] = multicastCatalogIssues(catalog, options);
|
|
1029
|
+
if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
|
|
958
1030
|
validateArchive(catalog);
|
|
959
1031
|
return catalog;
|
|
960
1032
|
}
|
|
@@ -980,7 +1052,7 @@ function resolveGroupDurationTicks(timing, timescale) {
|
|
|
980
1052
|
const product = timing.groupDurationMs * timescale;
|
|
981
1053
|
if (product % 1e3 !== 0) {
|
|
982
1054
|
throw new Error(
|
|
983
|
-
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} produces non-integer ticks (${product / 1e3}); publisher must use groupDurationTicks override (mmt-
|
|
1055
|
+
`[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)`
|
|
984
1056
|
);
|
|
985
1057
|
}
|
|
986
1058
|
return product / 1e3;
|