@blockcast/mmt-container 0.4.0 → 0.4.1-main.2e0aa69d293d
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 +37 -21
- 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 +5070 -908
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- 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/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +115 -235
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +113 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +464 -66
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3692 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +101 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +422 -189
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +94 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +746 -131
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +140 -12
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +4104 -605
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +16 -3
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +127 -240
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3643 -1197
- 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 +90 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +160 -32
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +378 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +453 -236
- package/src/multicast-auth-catalog.ts +196 -231
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +447 -53
- package/src/multicast-transport.ts +23 -5
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +306 -42
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- 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 +71 -4
- 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/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- 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-amt-driad-with-relay.json +38 -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-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.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-algorithm-unimplemented.json +29 -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/fec-reed-solomon-layered.json +50 -0
- 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 +3 -3
- 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 +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +0 -61
package/dist/multicast-input.js
CHANGED
|
@@ -18,6 +18,254 @@ var FEC_BLOCK_PROFILES = Object.freeze([
|
|
|
18
18
|
// ../mmt-base/dist/catalog-fec-source.js
|
|
19
19
|
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
20
20
|
|
|
21
|
+
// ../mmt-base/dist/multicast-catalog.js
|
|
22
|
+
var ED25519_PUBLIC_KEY_BASE64URL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
23
|
+
var UINT32_MAX = 4294967295;
|
|
24
|
+
var AUTH_MEMBERS = /* @__PURE__ */ new Set(["scheme", "version", "sig", "keys", "minEpoch"]);
|
|
25
|
+
var KEY_MEMBERS = /* @__PURE__ */ new Set(["kid", "publicKey", "firstEpoch"]);
|
|
26
|
+
var ENDPOINT_AUTH_MEMBERS = /* @__PURE__ */ new Set([
|
|
27
|
+
"manifestPort",
|
|
28
|
+
"streamId",
|
|
29
|
+
"senderAddress",
|
|
30
|
+
"maxAuthDelayMs",
|
|
31
|
+
"manifestTimerMs",
|
|
32
|
+
"manifestTrack"
|
|
33
|
+
]);
|
|
34
|
+
function isObject(value) {
|
|
35
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36
|
+
}
|
|
37
|
+
function isNonEmptyString(value) {
|
|
38
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
39
|
+
}
|
|
40
|
+
function isIntegerIn(value, min, max) {
|
|
41
|
+
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
42
|
+
}
|
|
43
|
+
function multicastEndpointSource(endpoint) {
|
|
44
|
+
if (!isObject(endpoint))
|
|
45
|
+
return void 0;
|
|
46
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
47
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress))
|
|
48
|
+
return void 0;
|
|
49
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
50
|
+
const protocol = endpoint["protocol"];
|
|
51
|
+
if (protocol !== void 0 && protocol !== mode)
|
|
52
|
+
return void 0;
|
|
53
|
+
const auth = endpoint["auth"];
|
|
54
|
+
const senderAddress = isObject(auth) ? auth["senderAddress"] : void 0;
|
|
55
|
+
if (mode === "ssm")
|
|
56
|
+
return senderAddress === void 0 ? { mode, source: sourceAddress } : void 0;
|
|
57
|
+
if (auth === void 0)
|
|
58
|
+
return { mode };
|
|
59
|
+
return isNonEmptyString(senderAddress) ? { mode, source: senderAddress } : void 0;
|
|
60
|
+
}
|
|
61
|
+
function authIssues(auth) {
|
|
62
|
+
const base = "$.multicast.auth";
|
|
63
|
+
const issue = (path, message) => [
|
|
64
|
+
{ code: "multicast_auth", path: `${base}${path}`, message }
|
|
65
|
+
];
|
|
66
|
+
if (!isObject(auth))
|
|
67
|
+
return issue("", "auth must be an object");
|
|
68
|
+
const unknown = Object.keys(auth).filter((key) => !AUTH_MEMBERS.has(key));
|
|
69
|
+
if (unknown.length > 0) {
|
|
70
|
+
return issue("", `auth has unknown member(s) ${unknown.join(", ")}; draft -01 7.2.6 defines scheme, version, sig, keys and minEpoch`);
|
|
71
|
+
}
|
|
72
|
+
if (auth["scheme"] !== "bc-provenance")
|
|
73
|
+
return issue(".scheme", 'scheme must be "bc-provenance"');
|
|
74
|
+
if (auth["version"] !== 2)
|
|
75
|
+
return issue(".version", "version must be 2 (bc-provenance version 2, draft -01 7.2)");
|
|
76
|
+
if (auth["sig"] !== "ed25519")
|
|
77
|
+
return issue(".sig", 'sig must be "ed25519"');
|
|
78
|
+
const keys = auth["keys"];
|
|
79
|
+
if (!Array.isArray(keys) || keys.length < 1 || keys.length > 4) {
|
|
80
|
+
return issue(".keys", "keys must be an array of one to four {kid, publicKey, firstEpoch} objects");
|
|
81
|
+
}
|
|
82
|
+
const kids = /* @__PURE__ */ new Set();
|
|
83
|
+
const firstEpochs = /* @__PURE__ */ new Set();
|
|
84
|
+
for (let index = 0; index < keys.length; index++) {
|
|
85
|
+
const key = keys[index];
|
|
86
|
+
const at = `.keys[${index}]`;
|
|
87
|
+
if (!isObject(key) || Object.keys(key).some((member) => !KEY_MEMBERS.has(member))) {
|
|
88
|
+
return issue(at, "a key is exactly {kid, publicKey, firstEpoch}");
|
|
89
|
+
}
|
|
90
|
+
if (!isIntegerIn(key["kid"], 0, UINT32_MAX))
|
|
91
|
+
return issue(`${at}.kid`, "kid must be an unsigned 32-bit integer");
|
|
92
|
+
if (typeof key["publicKey"] !== "string" || !ED25519_PUBLIC_KEY_BASE64URL.test(key["publicKey"])) {
|
|
93
|
+
return issue(`${at}.publicKey`, "publicKey must be a 32-octet Ed25519 key in canonical unpadded base64url");
|
|
94
|
+
}
|
|
95
|
+
if (!isIntegerIn(key["firstEpoch"], 0, UINT32_MAX)) {
|
|
96
|
+
return issue(`${at}.firstEpoch`, "firstEpoch must be an unsigned 32-bit integer");
|
|
97
|
+
}
|
|
98
|
+
if (kids.has(key["kid"]))
|
|
99
|
+
return issue(`${at}.kid`, `kid ${key["kid"]} is repeated; the catalog holds no key set`);
|
|
100
|
+
if (firstEpochs.has(key["firstEpoch"])) {
|
|
101
|
+
return issue(`${at}.firstEpoch`, `firstEpoch ${key["firstEpoch"]} is repeated; the catalog holds no key set`);
|
|
102
|
+
}
|
|
103
|
+
kids.add(key["kid"]);
|
|
104
|
+
firstEpochs.add(key["firstEpoch"]);
|
|
105
|
+
}
|
|
106
|
+
if (!isIntegerIn(auth["minEpoch"], 0, UINT32_MAX)) {
|
|
107
|
+
return issue(".minEpoch", "minEpoch must be an unsigned 32-bit integer");
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
function endpointAuthIssue(endpoint, mode, at) {
|
|
112
|
+
const auth = endpoint["auth"];
|
|
113
|
+
if (!isObject(auth))
|
|
114
|
+
return { path: `${at}.auth`, message: "auth must be an object" };
|
|
115
|
+
const unknown = Object.keys(auth).filter((key) => !ENDPOINT_AUTH_MEMBERS.has(key));
|
|
116
|
+
if (unknown.length > 0)
|
|
117
|
+
return { path: `${at}.auth`, message: `auth has unknown member(s) ${unknown.join(", ")}` };
|
|
118
|
+
if (!isIntegerIn(auth["manifestPort"], 1, 65535)) {
|
|
119
|
+
return { path: `${at}.auth.manifestPort`, message: "manifestPort must be an integer from 1 to 65535" };
|
|
120
|
+
}
|
|
121
|
+
if (!isIntegerIn(auth["streamId"], 0, UINT32_MAX)) {
|
|
122
|
+
return { path: `${at}.auth.streamId`, message: "streamId must be an unsigned 32-bit integer" };
|
|
123
|
+
}
|
|
124
|
+
if (mode === "ssm" && auth["senderAddress"] !== void 0) {
|
|
125
|
+
return { path: `${at}.auth.senderAddress`, message: "senderAddress must not appear on an SSM endpoint; S is sourceAddress" };
|
|
126
|
+
}
|
|
127
|
+
if (mode === "asm" && !isNonEmptyString(auth["senderAddress"])) {
|
|
128
|
+
return { path: `${at}.auth.senderAddress`, message: "a protected ASM endpoint requires senderAddress" };
|
|
129
|
+
}
|
|
130
|
+
if (auth["maxAuthDelayMs"] !== void 0 && !isIntegerIn(auth["maxAuthDelayMs"], 50, 1e3)) {
|
|
131
|
+
return { path: `${at}.auth.maxAuthDelayMs`, message: "maxAuthDelayMs must be an integer from 50 to 1000" };
|
|
132
|
+
}
|
|
133
|
+
if (auth["manifestTimerMs"] !== void 0 && !isIntegerIn(auth["manifestTimerMs"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
134
|
+
return { path: `${at}.auth.manifestTimerMs`, message: "manifestTimerMs must be an integer of at least 1" };
|
|
135
|
+
}
|
|
136
|
+
if (auth["manifestTrack"] !== void 0 && !isNonEmptyString(auth["manifestTrack"])) {
|
|
137
|
+
return { path: `${at}.auth.manifestTrack`, message: "manifestTrack must be a non-empty string" };
|
|
138
|
+
}
|
|
139
|
+
if (!isIntegerIn(endpoint["bandwidth"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
140
|
+
return { path: `${at}.bandwidth`, message: "a protected endpoint requires bandwidth, which bounds the receiver's hold queues" };
|
|
141
|
+
}
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
var CATALOG_NAMESPACE = /* @__PURE__ */ Symbol.for("@blockcast/mmt-base/catalogNamespace");
|
|
145
|
+
function multicastCatalogIssues(catalog, options = {}) {
|
|
146
|
+
if (!isObject(catalog))
|
|
147
|
+
return [];
|
|
148
|
+
const issues = [];
|
|
149
|
+
if ("multicast.auth" in catalog) {
|
|
150
|
+
issues.push({
|
|
151
|
+
code: "multicast_auth",
|
|
152
|
+
path: '$["multicast.auth"]',
|
|
153
|
+
message: 'the root "multicast.auth" key is retired; declare auth as multicast.auth (draft -01 7.2.6)'
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const multicast = catalog["multicast"];
|
|
157
|
+
if (!isObject(multicast))
|
|
158
|
+
return issues;
|
|
159
|
+
const protectedCatalog = multicast["auth"] !== void 0;
|
|
160
|
+
if (protectedCatalog)
|
|
161
|
+
issues.push(...authIssues(multicast["auth"]));
|
|
162
|
+
const endpoints = multicast["endpoints"];
|
|
163
|
+
if (!Array.isArray(endpoints))
|
|
164
|
+
return issues;
|
|
165
|
+
const tracks = Array.isArray(catalog["tracks"]) ? catalog["tracks"] : [];
|
|
166
|
+
const namespaceOf = /* @__PURE__ */ new Map();
|
|
167
|
+
for (const track of tracks) {
|
|
168
|
+
if (isObject(track) && typeof track["name"] === "string")
|
|
169
|
+
namespaceOf.set(track["name"], track["namespace"]);
|
|
170
|
+
}
|
|
171
|
+
const tagged = catalog[CATALOG_NAMESPACE];
|
|
172
|
+
let referenceNamespace = options.catalogNamespace ?? (typeof tagged === "string" ? tagged : void 0);
|
|
173
|
+
const sources = [];
|
|
174
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
175
|
+
const endpoint = endpoints[index];
|
|
176
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
177
|
+
const fail = (code, path, message) => {
|
|
178
|
+
issues.push({ code, path, message, endpointIndex: index });
|
|
179
|
+
};
|
|
180
|
+
sources.push(void 0);
|
|
181
|
+
if (!isObject(endpoint)) {
|
|
182
|
+
fail("multicast_endpoint", at, "endpoint must be an object");
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const protocol = endpoint["protocol"];
|
|
186
|
+
if (protocol !== void 0 && protocol !== "ssm" && protocol !== "asm") {
|
|
187
|
+
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)`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const hasAuth = endpoint["auth"] !== void 0;
|
|
191
|
+
if (protectedCatalog !== hasAuth) {
|
|
192
|
+
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");
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
196
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress)) {
|
|
197
|
+
fail("multicast_endpoint", `${at}.sourceAddress`, "sourceAddress must be a non-empty string");
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
201
|
+
if (protocol !== void 0 && protocol !== mode) {
|
|
202
|
+
fail("multicast_endpoint", `${at}.protocol`, `protocol ${JSON.stringify(protocol)} disagrees with sourceAddress, which selects ${mode}`);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (!isIntegerIn(endpoint["port"], 1, 65535)) {
|
|
206
|
+
fail("multicast_endpoint", `${at}.port`, "port must be an integer from 1 to 65535");
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (hasAuth) {
|
|
210
|
+
const authIssue = endpointAuthIssue(endpoint, mode, at);
|
|
211
|
+
if (authIssue) {
|
|
212
|
+
fail("multicast_endpoint_auth", authIssue.path, authIssue.message);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
sources[index] = multicastEndpointSource(endpoint);
|
|
217
|
+
const refs = Array.isArray(endpoint["tracks"]) ? endpoint["tracks"] : [];
|
|
218
|
+
for (let refIndex = 0; refIndex < refs.length; refIndex++) {
|
|
219
|
+
const ref = refs[refIndex];
|
|
220
|
+
const name = isObject(ref) ? ref["name"] : ref;
|
|
221
|
+
if (typeof name !== "string")
|
|
222
|
+
continue;
|
|
223
|
+
const namespace = namespaceOf.get(name);
|
|
224
|
+
if (typeof namespace !== "string")
|
|
225
|
+
continue;
|
|
226
|
+
referenceNamespace ??= namespace;
|
|
227
|
+
if (namespace !== referenceNamespace) {
|
|
228
|
+
fail("multicast_track", `${at}.tracks[${refIndex}].name`, `track ${JSON.stringify(name)} declares namespace ${JSON.stringify(namespace)}, not the catalog track's ${JSON.stringify(referenceNamespace)}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const tupleOf = (index) => {
|
|
233
|
+
const endpoint = endpoints[index];
|
|
234
|
+
const auth = endpoint["auth"];
|
|
235
|
+
return {
|
|
236
|
+
sg: JSON.stringify([sources[index].source ?? null, endpoint["groupAddress"]]),
|
|
237
|
+
port: endpoint["port"],
|
|
238
|
+
manifestPort: isObject(auth) ? auth["manifestPort"] : void 0
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
242
|
+
if (!sources[index])
|
|
243
|
+
continue;
|
|
244
|
+
const own = tupleOf(index);
|
|
245
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
246
|
+
if (own.manifestPort !== void 0 && own.manifestPort === own.port) {
|
|
247
|
+
issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: "manifestPort must differ from the endpoint's own port", endpointIndex: index });
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
for (let other = 0; other < endpoints.length; other++) {
|
|
251
|
+
if (other === index || !sources[other])
|
|
252
|
+
continue;
|
|
253
|
+
const peer = tupleOf(other);
|
|
254
|
+
if (peer.sg !== own.sg)
|
|
255
|
+
continue;
|
|
256
|
+
if (peer.port === own.port) {
|
|
257
|
+
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 });
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
if (own.manifestPort !== void 0 && (own.manifestPort === peer.port || own.manifestPort === peer.manifestPort)) {
|
|
261
|
+
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 });
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return issues;
|
|
267
|
+
}
|
|
268
|
+
|
|
21
269
|
// src/multicast-input.ts
|
|
22
270
|
var MulticastInputError = class extends Error {
|
|
23
271
|
constructor(kind, endpointIndex, message) {
|
|
@@ -61,25 +309,20 @@ function multicastFromConfig(input) {
|
|
|
61
309
|
);
|
|
62
310
|
}
|
|
63
311
|
}
|
|
64
|
-
const
|
|
65
|
-
const endpoints = input.endpoints.map((ep, idx) => validateEndpoint(ep, idx, seenTuples));
|
|
312
|
+
const endpoints = input.endpoints.map((ep, idx) => validateEndpoint(ep, idx));
|
|
66
313
|
const out = { endpoints };
|
|
67
314
|
const { entries: networkSource, relayFrom } = resolveNetworkSource(input);
|
|
68
315
|
networkSource.forEach(validateNetworkSourceEntry);
|
|
69
316
|
if (networkSource.length > 0) out.networkSource = networkSource;
|
|
70
317
|
const amtRelays = new Set(
|
|
71
|
-
networkSource.flatMap((s) => s.type === "amt" && s.
|
|
318
|
+
networkSource.flatMap((s) => s.type === "amt" && s.relay?.trim() ? [s.relay.trim()] : []).slice(0, 1)
|
|
72
319
|
);
|
|
73
320
|
input.endpoints.forEach((ep, idx) => {
|
|
74
321
|
const relay = ep.relayAddress?.trim();
|
|
75
322
|
if (!relay || amtRelays.has(relay)) return;
|
|
76
|
-
const demoted = networkSource.some(
|
|
77
|
-
(s) => s.type === "amt" && s.discovery === "driad" && s.relay?.trim() === relay
|
|
78
|
-
);
|
|
79
323
|
const shadowed = networkSource.some(
|
|
80
|
-
(s) => s.type === "amt" && s.
|
|
324
|
+
(s) => s.type === "amt" && s.relay?.trim() === relay
|
|
81
325
|
);
|
|
82
|
-
const derived = input.networkSource === void 0;
|
|
83
326
|
const fromAmtFallback = ", derived from amtFallback/MOQCAST_MULTICAST_AMT_*";
|
|
84
327
|
const fromRelay = relayFrom === "amtFallback.relayDns" ? fromAmtFallback : relayFrom === "endpoint.relayAddress" ? ", derived from the endpoint relayAddress values" : "";
|
|
85
328
|
const relayDns = input.amtFallback?.relayDns?.trim();
|
|
@@ -87,7 +330,7 @@ function multicastFromConfig(input) {
|
|
|
87
330
|
throw new MulticastInputError(
|
|
88
331
|
"conflicting_amt_relay",
|
|
89
332
|
idx,
|
|
90
|
-
`endpoint[${idx}] relayAddress ${JSON.stringify(relay)} ` + (
|
|
333
|
+
`endpoint[${idx}] relayAddress ${JSON.stringify(relay)} ` + (shadowed ? `is carried by a multicast.networkSource AMT entry that is not the first one: both readers join the first AMT entry (${[...amtRelays].join(", ")}) and ignore the rest, so this relay is never joined; keep a single AMT entry, or put this one first` : `is not the relay of any multicast.networkSource AMT entry (${[...amtRelays].join(", ") || "none"})${fromRelay}; ` + (outranked ? `amtFallback.relayDns/MOQCAST_MULTICAST_AMT_RELAY_DNS (${relayDns}) outranks an endpoint relay when networkSource is derived -- drop one, or make them agree` : "networkSource is catalog-level and cannot represent per-endpoint relays"))
|
|
91
334
|
);
|
|
92
335
|
});
|
|
93
336
|
input.endpoints.forEach((ep, idx) => {
|
|
@@ -96,9 +339,20 @@ function multicastFromConfig(input) {
|
|
|
96
339
|
throw new MulticastInputError(
|
|
97
340
|
ep.protocol === "amt" ? "amt_requires_relay" : "atsc3_requires_tuning",
|
|
98
341
|
idx,
|
|
99
|
-
`endpoint[${idx}] protocol=${ep.protocol} requires a multicast.networkSource entry of type "${ep.protocol}"` + (ep.protocol === "atsc3" ? " carrying
|
|
342
|
+
`endpoint[${idx}] protocol=${ep.protocol} requires a multicast.networkSource entry of type "${ep.protocol}"` + (ep.protocol === "atsc3" ? " carrying at least its frequency (kHz) \u2014 an ATSC3 endpoint is not tunable without it" : "")
|
|
100
343
|
);
|
|
101
344
|
});
|
|
345
|
+
input.endpoints.forEach((ep, idx) => {
|
|
346
|
+
if (ep.protocol !== "amt" && ep.protocol !== "atsc3") return;
|
|
347
|
+
endpoints[idx].networkSource = networkSource.filter((s) => s.type === ep.protocol).map((s) => ({ ...s }));
|
|
348
|
+
});
|
|
349
|
+
if (input.auth !== void 0) out.auth = input.auth;
|
|
350
|
+
const [issue] = multicastCatalogIssues({ multicast: out });
|
|
351
|
+
if (issue) {
|
|
352
|
+
const kind = issue.code === "multicast_auth" ? "invalid_multicast_auth" : issue.code === "multicast_endpoint_auth" ? "invalid_endpoint_auth" : issue.path.endsWith(".port") ? "duplicate_endpoint_tuple" : "protocol_source_mismatch";
|
|
353
|
+
const where = issue.endpointIndex === void 0 ? "" : `endpoint[${issue.endpointIndex}] `;
|
|
354
|
+
throw new MulticastInputError(kind, issue.endpointIndex ?? null, `${where}${issue.path.replace("$.multicast.", "")}: ${issue.message}`);
|
|
355
|
+
}
|
|
102
356
|
if (input.enabled !== void 0) out.enabled = input.enabled;
|
|
103
357
|
if (input.version !== void 0) out.version = input.version;
|
|
104
358
|
if (input.validUntil !== void 0) out.validUntil = input.validUntil;
|
|
@@ -110,10 +364,10 @@ function resolveNetworkSource(input) {
|
|
|
110
364
|
}
|
|
111
365
|
const relayDns = input.amtFallback?.relayDns?.trim();
|
|
112
366
|
const relay = relayDns || input.endpoints.map((ep) => ep.relayAddress?.trim()).find((r) => !!r);
|
|
113
|
-
const discovery = input.amtFallback?.discovery
|
|
114
|
-
if (discovery === void 0) return { entries: [], relayFrom: null };
|
|
367
|
+
const discovery = input.amtFallback?.discovery;
|
|
368
|
+
if (discovery === void 0 && !relay) return { entries: [], relayFrom: null };
|
|
115
369
|
return {
|
|
116
|
-
entries: [{ type: "amt", discovery, ...relay ? { relay } : {} }],
|
|
370
|
+
entries: [{ type: "amt", ...discovery ? { discovery } : {}, ...relay ? { relay } : {} }],
|
|
117
371
|
relayFrom: !relay ? null : relayDns ? "amtFallback.relayDns" : "endpoint.relayAddress"
|
|
118
372
|
};
|
|
119
373
|
}
|
|
@@ -126,8 +380,11 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
126
380
|
const extra = Object.keys(s).filter((k) => !keys.has(k) && s[k] !== void 0);
|
|
127
381
|
if (extra.length > 0) throw err("invalid_network_source", `has keys the schema rejects: ${extra.join(", ")}`);
|
|
128
382
|
if (s.type === "amt") {
|
|
129
|
-
if (s.discovery !== "driad" && s.discovery !== "manual") {
|
|
130
|
-
throw err(
|
|
383
|
+
if (s.discovery !== void 0 && s.discovery !== "dns" && s.discovery !== "driad" && s.discovery !== "manual") {
|
|
384
|
+
throw err(
|
|
385
|
+
"invalid_amt_discovery",
|
|
386
|
+
`discovery must be "dns", "driad" or "manual" when present; got ${JSON.stringify(s.discovery)}`
|
|
387
|
+
);
|
|
131
388
|
}
|
|
132
389
|
if (s.relay !== void 0) {
|
|
133
390
|
const relay = typeof s.relay === "string" ? s.relay.trim() : "";
|
|
@@ -136,8 +393,14 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
136
393
|
}
|
|
137
394
|
s.relay = relay;
|
|
138
395
|
}
|
|
139
|
-
if (s.discovery === "manual" && s.relay === void 0) {
|
|
140
|
-
throw err("amt_requires_relay", `discovery="
|
|
396
|
+
if ((s.discovery === "dns" || s.discovery === "manual") && s.relay === void 0) {
|
|
397
|
+
throw err("amt_requires_relay", `discovery="${s.discovery}" requires a relay ("driad" resolves it at runtime)`);
|
|
398
|
+
}
|
|
399
|
+
if (s.discovery === "driad" && s.relay !== void 0) {
|
|
400
|
+
throw err(
|
|
401
|
+
"invalid_network_source",
|
|
402
|
+
`discovery="driad" must omit relay: DRIAD supplies the relay candidates (draft -01 4.2.1); drop the relay (amtFallback.relayDns / endpoint relayAddress on the derived path), or use "dns" or "manual"`
|
|
403
|
+
);
|
|
141
404
|
}
|
|
142
405
|
if (s.port !== void 0 && (!Number.isInteger(s.port) || s.port < 1 || s.port > 65535)) {
|
|
143
406
|
throw err("invalid_port", `port must be 1..65535; got ${s.port}`);
|
|
@@ -146,13 +409,15 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
146
409
|
}
|
|
147
410
|
const inRange = (v, min, max) => Number.isInteger(v) && v >= min && v <= max;
|
|
148
411
|
if (!inRange(s.frequency, 1, Number.MAX_SAFE_INTEGER)) {
|
|
149
|
-
throw err("invalid_network_source", `frequency must be a positive integer; got ${s.frequency}`);
|
|
412
|
+
throw err("invalid_network_source", `frequency must be a positive integer in kHz; got ${s.frequency}`);
|
|
413
|
+
}
|
|
414
|
+
if (s.plpId !== void 0 && !inRange(s.plpId, 0, 63)) {
|
|
415
|
+
throw err("invalid_network_source", `plpId must be 0..63; got ${s.plpId}`);
|
|
150
416
|
}
|
|
151
|
-
if (!inRange(s.
|
|
152
|
-
if (!inRange(s.serviceId, 0, 65535)) {
|
|
417
|
+
if (s.serviceId !== void 0 && !inRange(s.serviceId, 0, 65535)) {
|
|
153
418
|
throw err("invalid_network_source", `serviceId must be 0..65535; got ${s.serviceId}`);
|
|
154
419
|
}
|
|
155
|
-
if (typeof s.slsUri !== "string" || !isAbsoluteUri(s.slsUri)) {
|
|
420
|
+
if (s.slsUri !== void 0 && (typeof s.slsUri !== "string" || !isAbsoluteUri(s.slsUri))) {
|
|
156
421
|
throw err("invalid_network_source", `slsUri must be an absolute URI; got ${JSON.stringify(s.slsUri)}`);
|
|
157
422
|
}
|
|
158
423
|
}
|
|
@@ -164,7 +429,7 @@ function isAbsoluteUri(value) {
|
|
|
164
429
|
return false;
|
|
165
430
|
}
|
|
166
431
|
}
|
|
167
|
-
function validateEndpoint(ep, idx
|
|
432
|
+
function validateEndpoint(ep, idx) {
|
|
168
433
|
if (ep.protocol === "ssm" && (!ep.sourceAddress || ep.sourceAddress.length === 0)) {
|
|
169
434
|
throw new MulticastInputError(
|
|
170
435
|
"ssm_requires_source",
|
|
@@ -172,6 +437,13 @@ function validateEndpoint(ep, idx, seenTuples) {
|
|
|
172
437
|
`endpoint[${idx}] protocol=ssm requires sourceAddress`
|
|
173
438
|
);
|
|
174
439
|
}
|
|
440
|
+
if (ep.protocol === "asm" && ep.sourceAddress !== void 0) {
|
|
441
|
+
throw new MulticastInputError(
|
|
442
|
+
"protocol_source_mismatch",
|
|
443
|
+
idx,
|
|
444
|
+
`endpoint[${idx}] protocol=asm with sourceAddress "${ep.sourceAddress}"; sourceAddress selects SSM (draft -01 4.1)`
|
|
445
|
+
);
|
|
446
|
+
}
|
|
175
447
|
if (!isMulticastGroupAddress(ep.groupAddress)) {
|
|
176
448
|
throw new MulticastInputError(
|
|
177
449
|
"invalid_group_address",
|
|
@@ -231,23 +503,15 @@ function validateEndpoint(ep, idx, seenTuples) {
|
|
|
231
503
|
`endpoint[${idx}] bandwidth must be positive; got ${ep.bandwidth}`
|
|
232
504
|
);
|
|
233
505
|
}
|
|
234
|
-
const tupleKey = `${ep.sourceAddress ?? ""}|${ep.groupAddress}|${ep.port}`;
|
|
235
|
-
if (seenTuples.has(tupleKey)) {
|
|
236
|
-
throw new MulticastInputError(
|
|
237
|
-
"duplicate_endpoint_tuple",
|
|
238
|
-
idx,
|
|
239
|
-
`endpoint[${idx}] duplicates (sourceAddress, groupAddress, port) tuple "${tupleKey}"`
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
seenTuples.add(tupleKey);
|
|
243
506
|
const out = {
|
|
244
|
-
protocol: ep.
|
|
507
|
+
protocol: ep.sourceAddress === void 0 ? "asm" : "ssm",
|
|
245
508
|
groupAddress: ep.groupAddress,
|
|
246
509
|
port: ep.port,
|
|
247
510
|
tracks: ep.tracks.map((t) => ({ name: t.name, packetId: t.packetId }))
|
|
248
511
|
};
|
|
249
512
|
if (ep.sourceAddress !== void 0) out.sourceAddress = ep.sourceAddress;
|
|
250
513
|
if (ep.bandwidth !== void 0) out.bandwidth = ep.bandwidth;
|
|
514
|
+
if (ep.auth !== void 0) out.auth = { ...ep.auth };
|
|
251
515
|
return out;
|
|
252
516
|
}
|
|
253
517
|
function isMulticastGroupAddress(addr) {
|
|
@@ -290,9 +554,9 @@ function multicastFromEnv(env = globalThis.process?.env ?? {}) {
|
|
|
290
554
|
endpoints,
|
|
291
555
|
...hasCatalogAmt ? {
|
|
292
556
|
amtFallback: {
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
discovery: amtDiscovery
|
|
557
|
+
// No default: an omitted discovery with a relay hostname is
|
|
558
|
+
// "dns" (draft-ramadan-moq-multicast-01 4.2.1).
|
|
559
|
+
...amtDiscovery ? { discovery: amtDiscovery } : {},
|
|
296
560
|
...amtRelayDns ? { relayDns: amtRelayDns } : {}
|
|
297
561
|
}
|
|
298
562
|
} : {}
|