@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 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.
- package/README.md +31 -17
- 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 +1192 -375
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +67 -31
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +291 -199
- 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 +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 +18 -12
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +49 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +176 -23
- package/dist/fec-manager.js.map +3 -3
- 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 +2 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +2 -1
- package/dist/fec-worker-setup.js.map +2 -2
- 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 +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 +2 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +1014 -289
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +159 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +531 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +17 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +29 -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 +40 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +293 -54
- 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 -11
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +964 -274
- 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 +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- 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/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/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 +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -9
- package/schemas/catalog.schema.json +124 -37
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +131 -52
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +128 -14
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +4 -1
- package/src/index.ts +24 -10
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +57 -0
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +115 -14
- package/src/multicast-transport.ts +3 -0
- package/src/no-modules.ts +7 -1
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- package/src/repair-layers.ts +22 -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 +60 -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/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-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 +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 +30 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +6 -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/src/fec-codec.ts +0 -61
|
@@ -41,14 +41,19 @@ var BlockcastMmt = (() => {
|
|
|
41
41
|
FEC_INACTIVE_REASONS: () => FEC_INACTIVE_REASONS,
|
|
42
42
|
ManifestVerifier: () => ManifestVerifier,
|
|
43
43
|
MmtpContainerParser: () => MmtpContainerParser,
|
|
44
|
+
MmtpFecSession: () => MmtpFecSession,
|
|
44
45
|
MmtpToCmaf: () => MmtpToCmaf,
|
|
46
|
+
catalogAmtNetworkSource: () => catalogAmtNetworkSource,
|
|
47
|
+
catalogAtsc3NetworkSource: () => catalogAtsc3NetworkSource,
|
|
45
48
|
catalogDeclaresFec: () => catalogDeclaresFec,
|
|
46
49
|
catalogFecInterleaveMs: () => catalogFecInterleaveMs,
|
|
47
|
-
computeFecTimeout: () => computeFecTimeout,
|
|
48
50
|
createManifestAuthPlan: () => createManifestAuthPlan,
|
|
49
51
|
createWasmMmtpContainerParser: () => createWasmMmtpContainerParser,
|
|
50
52
|
createWebCryptoEd25519Verifier: () => createWebCryptoEd25519Verifier,
|
|
51
53
|
datagramMfuReassembly: () => datagramMfuReassembly,
|
|
54
|
+
fecBlockBudgetMs: () => fecBlockBudgetMs,
|
|
55
|
+
fecBlockDeadlineMs: () => fecBlockDeadlineMs,
|
|
56
|
+
isFmp4InitSegment: () => isFmp4InitSegment,
|
|
52
57
|
manifestBindingId: () => manifestBindingId,
|
|
53
58
|
mmtpFrameReorderWindowFrames: () => mmtpFrameReorderWindowFrames,
|
|
54
59
|
reliableMoqMfuReassembly: () => reliableMoqMfuReassembly,
|
|
@@ -348,6 +353,57 @@ var BlockcastMmt = (() => {
|
|
|
348
353
|
ssId: (mmtpPacket[off] << 24 | mmtpPacket[off + 1] << 16 | mmtpPacket[off + 2] << 8 | mmtpPacket[off + 3]) >>> 0
|
|
349
354
|
};
|
|
350
355
|
}
|
|
356
|
+
var REPAIR_FEC_PID_SIZE = 13;
|
|
357
|
+
function readRepairFecPayloadIdFields(mmtpPacket, parsedHeader) {
|
|
358
|
+
let header;
|
|
359
|
+
if (parsedHeader) {
|
|
360
|
+
header = parsedHeader;
|
|
361
|
+
} else {
|
|
362
|
+
try {
|
|
363
|
+
header = parseMMTPHeader(mmtpPacket);
|
|
364
|
+
} catch {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (header.packetType !== PACKET_TYPE_REPAIR || header.fecType !== 2)
|
|
369
|
+
return null;
|
|
370
|
+
const off = header.headerLength;
|
|
371
|
+
if (mmtpPacket.length < off + REPAIR_FEC_PID_SIZE)
|
|
372
|
+
return null;
|
|
373
|
+
const ssStart = (mmtpPacket[off] << 24 | mmtpPacket[off + 1] << 16 | mmtpPacket[off + 2] << 8 | mmtpPacket[off + 3]) >>> 0;
|
|
374
|
+
const rsbLength = mmtpPacket[off + 4] << 16 | mmtpPacket[off + 5] << 8 | mmtpPacket[off + 6];
|
|
375
|
+
const rsId = mmtpPacket[off + 7] << 16 | mmtpPacket[off + 8] << 8 | mmtpPacket[off + 9];
|
|
376
|
+
const ssbLength = mmtpPacket[off + 10] << 16 | mmtpPacket[off + 11] << 8 | mmtpPacket[off + 12];
|
|
377
|
+
return {
|
|
378
|
+
packetId: header.packetId,
|
|
379
|
+
ssStart,
|
|
380
|
+
rsbLength,
|
|
381
|
+
rsId,
|
|
382
|
+
ssbLength,
|
|
383
|
+
dataOffset: off + REPAIR_FEC_PID_SIZE
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function parseMoqRepairFrameWithHeader(frame, header) {
|
|
387
|
+
return moqRepairFrameFrom(frame, readRepairFecPayloadIdFields(frame, header));
|
|
388
|
+
}
|
|
389
|
+
function moqRepairFrameFrom(frame, repairId) {
|
|
390
|
+
if (!repairId)
|
|
391
|
+
return null;
|
|
392
|
+
const symbolData = frame.subarray(repairId.dataOffset);
|
|
393
|
+
if (repairId.rsbLength === 0 || repairId.ssbLength === 0 || repairId.rsId >= repairId.rsbLength || symbolData.length === 0)
|
|
394
|
+
return null;
|
|
395
|
+
return {
|
|
396
|
+
packetId: repairId.packetId,
|
|
397
|
+
ssStart: repairId.ssStart,
|
|
398
|
+
rsbLength: repairId.rsbLength,
|
|
399
|
+
rsId: repairId.rsId,
|
|
400
|
+
ssbLength: repairId.ssbLength,
|
|
401
|
+
symbolData
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ../mmt-base/dist/net-constants.js
|
|
406
|
+
var DEFAULT_AMT_RELAY_PORT = 2268;
|
|
351
407
|
|
|
352
408
|
// ../mmt-base/dist/ntp-short.js
|
|
353
409
|
var NTP_SHORT_BITS = 32;
|
|
@@ -356,6 +412,26 @@ var BlockcastMmt = (() => {
|
|
|
356
412
|
|
|
357
413
|
// ../mmt-base/dist/serial-number.js
|
|
358
414
|
var SERIAL32_SPAN = 4294967296;
|
|
415
|
+
var SERIAL32_HALF = 2147483648;
|
|
416
|
+
function assertUint32(value, name) {
|
|
417
|
+
if (!Number.isInteger(value) || value < 0 || value >= SERIAL32_SPAN) {
|
|
418
|
+
throw new RangeError(`${name} must be a uint32 (got ${value})`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function serial32Add(s, n) {
|
|
422
|
+
assertUint32(s, "s");
|
|
423
|
+
if (!Number.isInteger(n) || n <= -SERIAL32_HALF || n >= SERIAL32_HALF) {
|
|
424
|
+
throw new RangeError(`serial addend must lie in (-2^31, 2^31) (got ${n})`);
|
|
425
|
+
}
|
|
426
|
+
return (s + n + SERIAL32_SPAN) % SERIAL32_SPAN;
|
|
427
|
+
}
|
|
428
|
+
function serial32Distance(from, to) {
|
|
429
|
+
return to - from >>> 0;
|
|
430
|
+
}
|
|
431
|
+
function serial32Precedes(a, b) {
|
|
432
|
+
const distance = serial32Distance(a, b);
|
|
433
|
+
return distance !== 0 && distance < SERIAL32_HALF;
|
|
434
|
+
}
|
|
359
435
|
|
|
360
436
|
// ../mmt-base/dist/fec-block-profile.js
|
|
361
437
|
var FEC_BLOCK_PROFILES = Object.freeze([
|
|
@@ -372,6 +448,35 @@ var BlockcastMmt = (() => {
|
|
|
372
448
|
}
|
|
373
449
|
throw new Error(`${where} must be "iso-ssbg1-v1" (got ${JSON.stringify(value)})`);
|
|
374
450
|
}
|
|
451
|
+
var SSBG1_LENGTH_FIELD_BYTES = 2;
|
|
452
|
+
function ssbg1MaxPacketLength(symbolSize) {
|
|
453
|
+
return symbolSize - SSBG1_LENGTH_FIELD_BYTES;
|
|
454
|
+
}
|
|
455
|
+
function ssbg1FitsSymbol(packetLength, symbolSize) {
|
|
456
|
+
return Number.isSafeInteger(packetLength) && packetLength >= 0 && packetLength <= ssbg1MaxPacketLength(symbolSize) && packetLength <= 65535;
|
|
457
|
+
}
|
|
458
|
+
function trimSsbg1SourceSymbol(symbol) {
|
|
459
|
+
if (symbol.byteLength < SSBG1_LENGTH_FIELD_BYTES)
|
|
460
|
+
return null;
|
|
461
|
+
const length = symbol[0] << 8 | symbol[1];
|
|
462
|
+
const end = SSBG1_LENGTH_FIELD_BYTES + length;
|
|
463
|
+
if (end > symbol.byteLength)
|
|
464
|
+
return null;
|
|
465
|
+
for (let i = end; i < symbol.byteLength; i++) {
|
|
466
|
+
if (symbol[i] !== 0)
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
return symbol.subarray(SSBG1_LENGTH_FIELD_BYTES, end);
|
|
470
|
+
}
|
|
471
|
+
function isoBlockContains(ssStart, ssbLength, ssId) {
|
|
472
|
+
return serial32Distance(ssStart, ssId) < ssbLength;
|
|
473
|
+
}
|
|
474
|
+
function isoBlocksBehindLowerBound(a, b, kMax) {
|
|
475
|
+
if (!Number.isSafeInteger(kMax) || kMax <= 0) {
|
|
476
|
+
throw new Error(`iso-ssbg1-v1 block horizon needs a positive maximum K (got ${kMax})`);
|
|
477
|
+
}
|
|
478
|
+
return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0;
|
|
479
|
+
}
|
|
375
480
|
|
|
376
481
|
// ../mmt-base/dist/catalog-fec-source.js
|
|
377
482
|
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
@@ -385,6 +490,269 @@ var BlockcastMmt = (() => {
|
|
|
385
490
|
const ms = block["interleaveDepthMs"];
|
|
386
491
|
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
387
492
|
}
|
|
493
|
+
function fecAlgorithmUnimplemented(algorithm) {
|
|
494
|
+
return typeof algorithm === "string" && algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon";
|
|
495
|
+
}
|
|
496
|
+
function isPositiveSafeInteger(value) {
|
|
497
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
498
|
+
}
|
|
499
|
+
var ISO_SSBG1_MIN_SYMBOL_SIZE = 14;
|
|
500
|
+
function catalogFecDeclaresUnconfigurableInstance(fec) {
|
|
501
|
+
const block = recordOf(fec);
|
|
502
|
+
if (block === void 0 || block["algorithm"] === "none" || fecAlgorithmUnimplemented(block["algorithm"]))
|
|
503
|
+
return false;
|
|
504
|
+
if (!(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"])))
|
|
505
|
+
return true;
|
|
506
|
+
return block["blockProfile"] === "iso-ssbg1-v1" && block["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// ../mmt-base/dist/multicast-catalog.js
|
|
510
|
+
var ED25519_PUBLIC_KEY_BASE64URL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
511
|
+
var UINT32_MAX = 4294967295;
|
|
512
|
+
var AUTH_MEMBERS = /* @__PURE__ */ new Set(["scheme", "version", "sig", "keys", "minEpoch"]);
|
|
513
|
+
var KEY_MEMBERS = /* @__PURE__ */ new Set(["kid", "publicKey", "firstEpoch"]);
|
|
514
|
+
var ENDPOINT_AUTH_MEMBERS = /* @__PURE__ */ new Set([
|
|
515
|
+
"manifestPort",
|
|
516
|
+
"streamId",
|
|
517
|
+
"senderAddress",
|
|
518
|
+
"maxAuthDelayMs",
|
|
519
|
+
"manifestTimerMs",
|
|
520
|
+
"manifestTrack"
|
|
521
|
+
]);
|
|
522
|
+
function isObject(value) {
|
|
523
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
524
|
+
}
|
|
525
|
+
function isNonEmptyString(value) {
|
|
526
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
527
|
+
}
|
|
528
|
+
function isIntegerIn(value, min, max) {
|
|
529
|
+
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
530
|
+
}
|
|
531
|
+
function multicastEndpointSource(endpoint) {
|
|
532
|
+
if (!isObject(endpoint))
|
|
533
|
+
return void 0;
|
|
534
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
535
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress))
|
|
536
|
+
return void 0;
|
|
537
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
538
|
+
const protocol = endpoint["protocol"];
|
|
539
|
+
if (protocol !== void 0 && protocol !== mode)
|
|
540
|
+
return void 0;
|
|
541
|
+
const auth = endpoint["auth"];
|
|
542
|
+
const senderAddress = isObject(auth) ? auth["senderAddress"] : void 0;
|
|
543
|
+
if (mode === "ssm")
|
|
544
|
+
return senderAddress === void 0 ? { mode, source: sourceAddress } : void 0;
|
|
545
|
+
if (auth === void 0)
|
|
546
|
+
return { mode };
|
|
547
|
+
return isNonEmptyString(senderAddress) ? { mode, source: senderAddress } : void 0;
|
|
548
|
+
}
|
|
549
|
+
function authIssues(auth) {
|
|
550
|
+
const base = "$.multicast.auth";
|
|
551
|
+
const issue = (path, message) => [
|
|
552
|
+
{ code: "multicast_auth", path: `${base}${path}`, message }
|
|
553
|
+
];
|
|
554
|
+
if (!isObject(auth))
|
|
555
|
+
return issue("", "auth must be an object");
|
|
556
|
+
const unknown = Object.keys(auth).filter((key) => !AUTH_MEMBERS.has(key));
|
|
557
|
+
if (unknown.length > 0) {
|
|
558
|
+
return issue("", `auth has unknown member(s) ${unknown.join(", ")}; draft -01 7.2.6 defines scheme, version, sig, keys and minEpoch`);
|
|
559
|
+
}
|
|
560
|
+
if (auth["scheme"] !== "bc-provenance")
|
|
561
|
+
return issue(".scheme", 'scheme must be "bc-provenance"');
|
|
562
|
+
if (auth["version"] !== 2)
|
|
563
|
+
return issue(".version", "version must be 2 (bc-provenance version 2, draft -01 7.2)");
|
|
564
|
+
if (auth["sig"] !== "ed25519")
|
|
565
|
+
return issue(".sig", 'sig must be "ed25519"');
|
|
566
|
+
const keys = auth["keys"];
|
|
567
|
+
if (!Array.isArray(keys) || keys.length < 1 || keys.length > 4) {
|
|
568
|
+
return issue(".keys", "keys must be an array of one to four {kid, publicKey, firstEpoch} objects");
|
|
569
|
+
}
|
|
570
|
+
const kids = /* @__PURE__ */ new Set();
|
|
571
|
+
const firstEpochs = /* @__PURE__ */ new Set();
|
|
572
|
+
for (let index = 0; index < keys.length; index++) {
|
|
573
|
+
const key = keys[index];
|
|
574
|
+
const at = `.keys[${index}]`;
|
|
575
|
+
if (!isObject(key) || Object.keys(key).some((member) => !KEY_MEMBERS.has(member))) {
|
|
576
|
+
return issue(at, "a key is exactly {kid, publicKey, firstEpoch}");
|
|
577
|
+
}
|
|
578
|
+
if (!isIntegerIn(key["kid"], 0, UINT32_MAX))
|
|
579
|
+
return issue(`${at}.kid`, "kid must be an unsigned 32-bit integer");
|
|
580
|
+
if (typeof key["publicKey"] !== "string" || !ED25519_PUBLIC_KEY_BASE64URL.test(key["publicKey"])) {
|
|
581
|
+
return issue(`${at}.publicKey`, "publicKey must be a 32-octet Ed25519 key in canonical unpadded base64url");
|
|
582
|
+
}
|
|
583
|
+
if (!isIntegerIn(key["firstEpoch"], 0, UINT32_MAX)) {
|
|
584
|
+
return issue(`${at}.firstEpoch`, "firstEpoch must be an unsigned 32-bit integer");
|
|
585
|
+
}
|
|
586
|
+
if (kids.has(key["kid"]))
|
|
587
|
+
return issue(`${at}.kid`, `kid ${key["kid"]} is repeated; the catalog holds no key set`);
|
|
588
|
+
if (firstEpochs.has(key["firstEpoch"])) {
|
|
589
|
+
return issue(`${at}.firstEpoch`, `firstEpoch ${key["firstEpoch"]} is repeated; the catalog holds no key set`);
|
|
590
|
+
}
|
|
591
|
+
kids.add(key["kid"]);
|
|
592
|
+
firstEpochs.add(key["firstEpoch"]);
|
|
593
|
+
}
|
|
594
|
+
if (!isIntegerIn(auth["minEpoch"], 0, UINT32_MAX)) {
|
|
595
|
+
return issue(".minEpoch", "minEpoch must be an unsigned 32-bit integer");
|
|
596
|
+
}
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
function endpointAuthIssue(endpoint, mode, at) {
|
|
600
|
+
const auth = endpoint["auth"];
|
|
601
|
+
if (!isObject(auth))
|
|
602
|
+
return { path: `${at}.auth`, message: "auth must be an object" };
|
|
603
|
+
const unknown = Object.keys(auth).filter((key) => !ENDPOINT_AUTH_MEMBERS.has(key));
|
|
604
|
+
if (unknown.length > 0)
|
|
605
|
+
return { path: `${at}.auth`, message: `auth has unknown member(s) ${unknown.join(", ")}` };
|
|
606
|
+
if (!isIntegerIn(auth["manifestPort"], 1, 65535)) {
|
|
607
|
+
return { path: `${at}.auth.manifestPort`, message: "manifestPort must be an integer from 1 to 65535" };
|
|
608
|
+
}
|
|
609
|
+
if (!isIntegerIn(auth["streamId"], 0, UINT32_MAX)) {
|
|
610
|
+
return { path: `${at}.auth.streamId`, message: "streamId must be an unsigned 32-bit integer" };
|
|
611
|
+
}
|
|
612
|
+
if (mode === "ssm" && auth["senderAddress"] !== void 0) {
|
|
613
|
+
return { path: `${at}.auth.senderAddress`, message: "senderAddress must not appear on an SSM endpoint; S is sourceAddress" };
|
|
614
|
+
}
|
|
615
|
+
if (mode === "asm" && !isNonEmptyString(auth["senderAddress"])) {
|
|
616
|
+
return { path: `${at}.auth.senderAddress`, message: "a protected ASM endpoint requires senderAddress" };
|
|
617
|
+
}
|
|
618
|
+
if (auth["maxAuthDelayMs"] !== void 0 && !isIntegerIn(auth["maxAuthDelayMs"], 50, 1e3)) {
|
|
619
|
+
return { path: `${at}.auth.maxAuthDelayMs`, message: "maxAuthDelayMs must be an integer from 50 to 1000" };
|
|
620
|
+
}
|
|
621
|
+
if (auth["manifestTimerMs"] !== void 0 && !isIntegerIn(auth["manifestTimerMs"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
622
|
+
return { path: `${at}.auth.manifestTimerMs`, message: "manifestTimerMs must be an integer of at least 1" };
|
|
623
|
+
}
|
|
624
|
+
if (auth["manifestTrack"] !== void 0 && !isNonEmptyString(auth["manifestTrack"])) {
|
|
625
|
+
return { path: `${at}.auth.manifestTrack`, message: "manifestTrack must be a non-empty string" };
|
|
626
|
+
}
|
|
627
|
+
if (!isIntegerIn(endpoint["bandwidth"], 1, Number.MAX_SAFE_INTEGER)) {
|
|
628
|
+
return { path: `${at}.bandwidth`, message: "a protected endpoint requires bandwidth, which bounds the receiver's hold queues" };
|
|
629
|
+
}
|
|
630
|
+
return void 0;
|
|
631
|
+
}
|
|
632
|
+
var CATALOG_NAMESPACE = /* @__PURE__ */ Symbol.for("@blockcast/mmt-base/catalogNamespace");
|
|
633
|
+
function multicastCatalogIssues(catalog, options = {}) {
|
|
634
|
+
if (!isObject(catalog))
|
|
635
|
+
return [];
|
|
636
|
+
const issues = [];
|
|
637
|
+
if ("multicast.auth" in catalog) {
|
|
638
|
+
issues.push({
|
|
639
|
+
code: "multicast_auth",
|
|
640
|
+
path: '$["multicast.auth"]',
|
|
641
|
+
message: 'the root "multicast.auth" key is retired; declare auth as multicast.auth (draft -01 7.2.6)'
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
const multicast = catalog["multicast"];
|
|
645
|
+
if (!isObject(multicast))
|
|
646
|
+
return issues;
|
|
647
|
+
const protectedCatalog = multicast["auth"] !== void 0;
|
|
648
|
+
if (protectedCatalog)
|
|
649
|
+
issues.push(...authIssues(multicast["auth"]));
|
|
650
|
+
const endpoints = multicast["endpoints"];
|
|
651
|
+
if (!Array.isArray(endpoints))
|
|
652
|
+
return issues;
|
|
653
|
+
const tracks = Array.isArray(catalog["tracks"]) ? catalog["tracks"] : [];
|
|
654
|
+
const namespaceOf = /* @__PURE__ */ new Map();
|
|
655
|
+
for (const track of tracks) {
|
|
656
|
+
if (isObject(track) && typeof track["name"] === "string")
|
|
657
|
+
namespaceOf.set(track["name"], track["namespace"]);
|
|
658
|
+
}
|
|
659
|
+
const tagged = catalog[CATALOG_NAMESPACE];
|
|
660
|
+
let referenceNamespace = options.catalogNamespace ?? (typeof tagged === "string" ? tagged : void 0);
|
|
661
|
+
const sources = [];
|
|
662
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
663
|
+
const endpoint = endpoints[index];
|
|
664
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
665
|
+
const fail = (code, path, message) => {
|
|
666
|
+
issues.push({ code, path, message, endpointIndex: index });
|
|
667
|
+
};
|
|
668
|
+
sources.push(void 0);
|
|
669
|
+
if (!isObject(endpoint)) {
|
|
670
|
+
fail("multicast_endpoint", at, "endpoint must be an object");
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
const protocol = endpoint["protocol"];
|
|
674
|
+
if (protocol !== void 0 && protocol !== "ssm" && protocol !== "asm") {
|
|
675
|
+
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)`);
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
const hasAuth = endpoint["auth"] !== void 0;
|
|
679
|
+
if (protectedCatalog !== hasAuth) {
|
|
680
|
+
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");
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
const sourceAddress = endpoint["sourceAddress"];
|
|
684
|
+
if (sourceAddress !== void 0 && !isNonEmptyString(sourceAddress)) {
|
|
685
|
+
fail("multicast_endpoint", `${at}.sourceAddress`, "sourceAddress must be a non-empty string");
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
const mode = sourceAddress === void 0 ? "asm" : "ssm";
|
|
689
|
+
if (protocol !== void 0 && protocol !== mode) {
|
|
690
|
+
fail("multicast_endpoint", `${at}.protocol`, `protocol ${JSON.stringify(protocol)} disagrees with sourceAddress, which selects ${mode}`);
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (!isIntegerIn(endpoint["port"], 1, 65535)) {
|
|
694
|
+
fail("multicast_endpoint", `${at}.port`, "port must be an integer from 1 to 65535");
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
if (hasAuth) {
|
|
698
|
+
const authIssue = endpointAuthIssue(endpoint, mode, at);
|
|
699
|
+
if (authIssue) {
|
|
700
|
+
fail("multicast_endpoint_auth", authIssue.path, authIssue.message);
|
|
701
|
+
continue;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
sources[index] = multicastEndpointSource(endpoint);
|
|
705
|
+
const refs = Array.isArray(endpoint["tracks"]) ? endpoint["tracks"] : [];
|
|
706
|
+
for (let refIndex = 0; refIndex < refs.length; refIndex++) {
|
|
707
|
+
const ref = refs[refIndex];
|
|
708
|
+
const name = isObject(ref) ? ref["name"] : ref;
|
|
709
|
+
if (typeof name !== "string")
|
|
710
|
+
continue;
|
|
711
|
+
const namespace = namespaceOf.get(name);
|
|
712
|
+
if (typeof namespace !== "string")
|
|
713
|
+
continue;
|
|
714
|
+
referenceNamespace ?? (referenceNamespace = namespace);
|
|
715
|
+
if (namespace !== referenceNamespace) {
|
|
716
|
+
fail("multicast_track", `${at}.tracks[${refIndex}].name`, `track ${JSON.stringify(name)} declares namespace ${JSON.stringify(namespace)}, not the catalog track's ${JSON.stringify(referenceNamespace)}`);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
const tupleOf = (index) => {
|
|
721
|
+
const endpoint = endpoints[index];
|
|
722
|
+
const auth = endpoint["auth"];
|
|
723
|
+
return {
|
|
724
|
+
sg: JSON.stringify([sources[index].source ?? null, endpoint["groupAddress"]]),
|
|
725
|
+
port: endpoint["port"],
|
|
726
|
+
manifestPort: isObject(auth) ? auth["manifestPort"] : void 0
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
for (let index = 0; index < endpoints.length; index++) {
|
|
730
|
+
if (!sources[index])
|
|
731
|
+
continue;
|
|
732
|
+
const own = tupleOf(index);
|
|
733
|
+
const at = `$.multicast.endpoints[${index}]`;
|
|
734
|
+
if (own.manifestPort !== void 0 && own.manifestPort === own.port) {
|
|
735
|
+
issues.push({ code: "multicast_endpoint_auth", path: `${at}.auth.manifestPort`, message: "manifestPort must differ from the endpoint's own port", endpointIndex: index });
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
for (let other = 0; other < endpoints.length; other++) {
|
|
739
|
+
if (other === index || !sources[other])
|
|
740
|
+
continue;
|
|
741
|
+
const peer = tupleOf(other);
|
|
742
|
+
if (peer.sg !== own.sg)
|
|
743
|
+
continue;
|
|
744
|
+
if (peer.port === own.port) {
|
|
745
|
+
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 });
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
if (own.manifestPort !== void 0 && (own.manifestPort === peer.port || own.manifestPort === peer.manifestPort)) {
|
|
749
|
+
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 });
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return issues;
|
|
755
|
+
}
|
|
388
756
|
|
|
389
757
|
// src/mfu-reassembler.ts
|
|
390
758
|
function fragmentProvenance(fragment) {
|
|
@@ -7067,197 +7435,6 @@ var BlockcastMmt = (() => {
|
|
|
7067
7435
|
});
|
|
7068
7436
|
}
|
|
7069
7437
|
|
|
7070
|
-
// src/multicast-auth-catalog.ts
|
|
7071
|
-
var RAW_ED25519_KEY_LENGTH = 32;
|
|
7072
|
-
var SOURCE_AUTH_SCOPE_LENGTH = 32;
|
|
7073
|
-
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
7074
|
-
function encodeBase64Url(bytes) {
|
|
7075
|
-
let output = "";
|
|
7076
|
-
for (let i = 0; i < bytes.length; i += 3) {
|
|
7077
|
-
const b0 = bytes[i];
|
|
7078
|
-
const b1 = bytes[i + 1];
|
|
7079
|
-
const b2 = bytes[i + 2];
|
|
7080
|
-
output += BASE64URL_ALPHABET[b0 >> 2];
|
|
7081
|
-
output += BASE64URL_ALPHABET[(b0 & 3) << 4 | (b1 === void 0 ? 0 : b1 >> 4)];
|
|
7082
|
-
if (b1 === void 0) break;
|
|
7083
|
-
output += BASE64URL_ALPHABET[(b1 & 15) << 2 | (b2 === void 0 ? 0 : b2 >> 6)];
|
|
7084
|
-
if (b2 === void 0) break;
|
|
7085
|
-
output += BASE64URL_ALPHABET[b2 & 63];
|
|
7086
|
-
}
|
|
7087
|
-
return output;
|
|
7088
|
-
}
|
|
7089
|
-
var BASE64URL_DECODE_TABLE = (() => {
|
|
7090
|
-
const table = new Int8Array(128).fill(-1);
|
|
7091
|
-
for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
|
|
7092
|
-
table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
|
|
7093
|
-
}
|
|
7094
|
-
return table;
|
|
7095
|
-
})();
|
|
7096
|
-
function decodeBase64Url(text) {
|
|
7097
|
-
if (text.length % 4 === 1) {
|
|
7098
|
-
throw new Error(`[multicast-auth-catalog] invalid unpadded base64url length for "${text}"`);
|
|
7099
|
-
}
|
|
7100
|
-
const bytes = [];
|
|
7101
|
-
let buffer = 0;
|
|
7102
|
-
let bits = 0;
|
|
7103
|
-
for (let i = 0; i < text.length; i++) {
|
|
7104
|
-
const code = text.charCodeAt(i);
|
|
7105
|
-
const value = code < 128 ? BASE64URL_DECODE_TABLE[code] : -1;
|
|
7106
|
-
if (value === void 0 || value < 0) {
|
|
7107
|
-
throw new Error(`[multicast-auth-catalog] invalid base64url character in "${text}"`);
|
|
7108
|
-
}
|
|
7109
|
-
buffer = buffer << 6 | value;
|
|
7110
|
-
bits += 6;
|
|
7111
|
-
if (bits >= 8) {
|
|
7112
|
-
bits -= 8;
|
|
7113
|
-
bytes.push(buffer >> bits & 255);
|
|
7114
|
-
}
|
|
7115
|
-
}
|
|
7116
|
-
const decoded = Uint8Array.from(bytes);
|
|
7117
|
-
if (encodeBase64Url(decoded) !== text) {
|
|
7118
|
-
throw new Error(`[multicast-auth-catalog] non-canonical base64url encoding "${text}"`);
|
|
7119
|
-
}
|
|
7120
|
-
return decoded;
|
|
7121
|
-
}
|
|
7122
|
-
function decodeAuthScope(authScope) {
|
|
7123
|
-
const bytes = decodeBase64Url(authScope);
|
|
7124
|
-
if (bytes.byteLength !== SOURCE_AUTH_SCOPE_LENGTH) {
|
|
7125
|
-
throw new Error(
|
|
7126
|
-
`[multicast-auth-catalog] authScope must decode to ${SOURCE_AUTH_SCOPE_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
7127
|
-
);
|
|
7128
|
-
}
|
|
7129
|
-
return bytes;
|
|
7130
|
-
}
|
|
7131
|
-
function decodeEd25519PublicKey(publicKey) {
|
|
7132
|
-
const bytes = decodeBase64Url(publicKey);
|
|
7133
|
-
if (bytes.byteLength !== RAW_ED25519_KEY_LENGTH) {
|
|
7134
|
-
throw new Error(
|
|
7135
|
-
`[multicast-auth-catalog] public key must decode to ${RAW_ED25519_KEY_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
7136
|
-
);
|
|
7137
|
-
}
|
|
7138
|
-
return bytes;
|
|
7139
|
-
}
|
|
7140
|
-
function isNonEmptyString(value) {
|
|
7141
|
-
return typeof value === "string" && value.length > 0;
|
|
7142
|
-
}
|
|
7143
|
-
function isValidAuthScopeField(value) {
|
|
7144
|
-
if (!isNonEmptyString(value)) return false;
|
|
7145
|
-
try {
|
|
7146
|
-
decodeAuthScope(value);
|
|
7147
|
-
return true;
|
|
7148
|
-
} catch {
|
|
7149
|
-
return false;
|
|
7150
|
-
}
|
|
7151
|
-
}
|
|
7152
|
-
function isValidPublicKeyField(value) {
|
|
7153
|
-
if (!isNonEmptyString(value)) return false;
|
|
7154
|
-
try {
|
|
7155
|
-
decodeEd25519PublicKey(value);
|
|
7156
|
-
return true;
|
|
7157
|
-
} catch {
|
|
7158
|
-
return false;
|
|
7159
|
-
}
|
|
7160
|
-
}
|
|
7161
|
-
function hasOnlyKeys(object, allowed) {
|
|
7162
|
-
const allowedKeys = new Set(allowed);
|
|
7163
|
-
return Object.keys(object).every((key) => allowedKeys.has(key));
|
|
7164
|
-
}
|
|
7165
|
-
function isMulticastAuthTrackConfig(obj) {
|
|
7166
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
7167
|
-
const o = obj;
|
|
7168
|
-
return hasOnlyKeys(o, ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"]) && isNonEmptyString(o["mediaTrack"]) && isNonEmptyString(o["manifestTrack"]) && o["mediaTrack"] !== o["manifestTrack"] && isValidAuthScopeField(o["authScope"]) && isNonEmptyString(o["sourceSymbolFormat"]);
|
|
7169
|
-
}
|
|
7170
|
-
var VALID_COMPACTION = /* @__PURE__ */ new Set(["merkle", "none"]);
|
|
7171
|
-
var VALID_ENFORCEMENT = /* @__PURE__ */ new Set(["shadow", "enforce"]);
|
|
7172
|
-
function hasUniqueMulticastAuthTrackBindings(tracks) {
|
|
7173
|
-
const bindings = tracks.flatMap((track) => {
|
|
7174
|
-
if (typeof track !== "object" || track === null) return [];
|
|
7175
|
-
const value = track;
|
|
7176
|
-
if (typeof value["mediaTrack"] !== "string" || typeof value["sourceSymbolFormat"] !== "string") {
|
|
7177
|
-
return [];
|
|
7178
|
-
}
|
|
7179
|
-
return [JSON.stringify([value["mediaTrack"], value["sourceSymbolFormat"]])];
|
|
7180
|
-
});
|
|
7181
|
-
return new Set(bindings).size === bindings.length;
|
|
7182
|
-
}
|
|
7183
|
-
function isMulticastAuthConfig(obj) {
|
|
7184
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
7185
|
-
const o = obj;
|
|
7186
|
-
if (o["scheme"] !== "bc-provenance") return false;
|
|
7187
|
-
if (o["hash"] !== "blake3") return false;
|
|
7188
|
-
if (o["sig"] !== "ed25519") return false;
|
|
7189
|
-
if (!hasOnlyKeys(o, ["scheme", "hash", "sig", "publicKey", "keyId", "previousKey", "compaction", "enforcement", "tracks"])) return false;
|
|
7190
|
-
if (!isValidPublicKeyField(o["publicKey"])) return false;
|
|
7191
|
-
if (!isNonEmptyString(o["keyId"])) return false;
|
|
7192
|
-
if (o["previousKey"] !== void 0 && !isValidPublicKeyField(o["previousKey"])) return false;
|
|
7193
|
-
if (o["previousKey"] === o["publicKey"]) return false;
|
|
7194
|
-
if (typeof o["compaction"] !== "string" || !VALID_COMPACTION.has(o["compaction"])) return false;
|
|
7195
|
-
if (o["enforcement"] !== void 0) {
|
|
7196
|
-
if (typeof o["enforcement"] !== "string" || !VALID_ENFORCEMENT.has(o["enforcement"])) return false;
|
|
7197
|
-
}
|
|
7198
|
-
if (!Array.isArray(o["tracks"]) || o["tracks"].length === 0) return false;
|
|
7199
|
-
const tracks = o["tracks"];
|
|
7200
|
-
if (!tracks.every((t) => isMulticastAuthTrackConfig(t))) return false;
|
|
7201
|
-
const typedTracks = tracks;
|
|
7202
|
-
const scopes = typedTracks.map((t) => t.authScope);
|
|
7203
|
-
if (new Set(scopes).size !== scopes.length) return false;
|
|
7204
|
-
if (!hasUniqueMulticastAuthTrackBindings(typedTracks)) return false;
|
|
7205
|
-
const manifestTracks = typedTracks.map((t) => t.manifestTrack);
|
|
7206
|
-
if (new Set(manifestTracks).size !== manifestTracks.length) return false;
|
|
7207
|
-
return true;
|
|
7208
|
-
}
|
|
7209
|
-
function resolveMulticastAuthMode(playerMode, auth) {
|
|
7210
|
-
if (playerMode !== void 0) return playerMode;
|
|
7211
|
-
if (auth === void 0) return "off";
|
|
7212
|
-
return auth.enforcement ?? "shadow";
|
|
7213
|
-
}
|
|
7214
|
-
function resolveMulticastAuthCatalog(catalog, playerMode) {
|
|
7215
|
-
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) {
|
|
7216
|
-
throw new Error("[multicast-auth-catalog] catalog must be an object");
|
|
7217
|
-
}
|
|
7218
|
-
const root = catalog;
|
|
7219
|
-
const rawAuth = root["multicast.auth"];
|
|
7220
|
-
if (rawAuth === void 0) {
|
|
7221
|
-
if (playerMode === "enforce") {
|
|
7222
|
-
throw new Error("[multicast-auth-catalog] player enforce mode requires multicast.auth");
|
|
7223
|
-
}
|
|
7224
|
-
return void 0;
|
|
7225
|
-
}
|
|
7226
|
-
if (!isMulticastAuthConfig(rawAuth)) {
|
|
7227
|
-
throw new Error("[multicast-auth-catalog] invalid multicast.auth v2 block");
|
|
7228
|
-
}
|
|
7229
|
-
const rawTracks = root["tracks"];
|
|
7230
|
-
if (!Array.isArray(rawTracks)) {
|
|
7231
|
-
throw new Error("[multicast-auth-catalog] catalog tracks must be an array");
|
|
7232
|
-
}
|
|
7233
|
-
const catalogTrackNames = new Set(
|
|
7234
|
-
rawTracks.flatMap(
|
|
7235
|
-
(track) => typeof track === "object" && track !== null && typeof track["name"] === "string" ? [track["name"]] : []
|
|
7236
|
-
)
|
|
7237
|
-
);
|
|
7238
|
-
for (const track of rawAuth.tracks) {
|
|
7239
|
-
if (!catalogTrackNames.has(track.mediaTrack)) {
|
|
7240
|
-
throw new Error(`[multicast-auth-catalog] unknown mediaTrack "${track.mediaTrack}"`);
|
|
7241
|
-
}
|
|
7242
|
-
if (!catalogTrackNames.has(track.manifestTrack)) {
|
|
7243
|
-
throw new Error(`[multicast-auth-catalog] unknown manifestTrack "${track.manifestTrack}"`);
|
|
7244
|
-
}
|
|
7245
|
-
}
|
|
7246
|
-
return {
|
|
7247
|
-
keyId: rawAuth.keyId,
|
|
7248
|
-
acceptedPublicKeys: [
|
|
7249
|
-
decodeEd25519PublicKey(rawAuth.publicKey),
|
|
7250
|
-
...rawAuth.previousKey === void 0 ? [] : [decodeEd25519PublicKey(rawAuth.previousKey)]
|
|
7251
|
-
],
|
|
7252
|
-
mode: resolveMulticastAuthMode(playerMode, rawAuth),
|
|
7253
|
-
compaction: rawAuth.compaction,
|
|
7254
|
-
tracks: rawAuth.tracks.map((track) => ({
|
|
7255
|
-
...track,
|
|
7256
|
-
authScope: decodeAuthScope(track.authScope)
|
|
7257
|
-
}))
|
|
7258
|
-
};
|
|
7259
|
-
}
|
|
7260
|
-
|
|
7261
7438
|
// src/repair-layers.ts
|
|
7262
7439
|
var REPAIR_PRIORITY_MIN = 192;
|
|
7263
7440
|
var REPAIR_PRIORITY_MAX = 255;
|
|
@@ -7265,6 +7442,7 @@ var BlockcastMmt = (() => {
|
|
|
7265
7442
|
var MAX_RAPTORQ_SOURCE_SYMBOLS = 56403;
|
|
7266
7443
|
var MAX_REPAIR_SYMBOLS = 16777215;
|
|
7267
7444
|
var MAX_ENCODING_SYMBOL_ID = 16777215;
|
|
7445
|
+
var MAX_REED_SOLOMON_BLOCK_SYMBOLS = 255;
|
|
7268
7446
|
var RepairContractError = class extends Error {
|
|
7269
7447
|
constructor(code, path, message) {
|
|
7270
7448
|
super(`[repair-layers:${code}] ${path}: ${message}`);
|
|
@@ -7447,11 +7625,12 @@ var BlockcastMmt = (() => {
|
|
|
7447
7625
|
if (layered && !positiveInteger(source.sourceSymbols)) {
|
|
7448
7626
|
fail("track_fec", `${source.path}.sourceSymbols`, "layered or overlay repair needs a positive integer sourceSymbols on the source");
|
|
7449
7627
|
}
|
|
7450
|
-
|
|
7628
|
+
const reedSolomon = source.algorithm === "reed-solomon";
|
|
7629
|
+
if (layered && source.algorithm !== "raptorq" && !reedSolomon) {
|
|
7451
7630
|
fail(
|
|
7452
7631
|
"track_fec",
|
|
7453
7632
|
`${source.path}.algorithm`,
|
|
7454
|
-
"repair layers and overlays are defined only for raptorq
|
|
7633
|
+
"repair layers and overlays are defined only for raptorq and reed-solomon (draft-ramadan-moq-fec-01 6.3.4 rule 7)"
|
|
7455
7634
|
);
|
|
7456
7635
|
}
|
|
7457
7636
|
let layerZeroPriority = DEFAULT_REPAIR_PRIORITY;
|
|
@@ -7510,6 +7689,13 @@ var BlockcastMmt = (() => {
|
|
|
7510
7689
|
`overlay sourceSymbols + repairSymbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
|
|
7511
7690
|
);
|
|
7512
7691
|
}
|
|
7692
|
+
if (reedSolomon && sourceSymbols + repairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
|
|
7693
|
+
fail(
|
|
7694
|
+
"track_fec_bounds",
|
|
7695
|
+
`${d.path}.repairSymbols`,
|
|
7696
|
+
`reed-solomon overlay sourceSymbols + repairSymbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
|
|
7697
|
+
);
|
|
7698
|
+
}
|
|
7513
7699
|
overlays.push({ repairTrackName: d.name, scope: "keyframe", sourceSymbols, repairSymbols, priority: d.priority });
|
|
7514
7700
|
}
|
|
7515
7701
|
let offset = layerZeroSymbols;
|
|
@@ -7554,6 +7740,13 @@ var BlockcastMmt = (() => {
|
|
|
7554
7740
|
`sourceSymbols + total base repair symbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
|
|
7555
7741
|
);
|
|
7556
7742
|
}
|
|
7743
|
+
if (reedSolomon && k + totalBaseRepairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
|
|
7744
|
+
fail(
|
|
7745
|
+
"track_fec_bounds",
|
|
7746
|
+
`${source.path}.sourceSymbols`,
|
|
7747
|
+
`reed-solomon sourceSymbols + total base repair symbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
|
|
7748
|
+
);
|
|
7749
|
+
}
|
|
7557
7750
|
return { sourceTrackName: source.name, baseLayers, overlays, totalBaseRepairSymbols };
|
|
7558
7751
|
}
|
|
7559
7752
|
|
|
@@ -7641,7 +7834,7 @@ var BlockcastMmt = (() => {
|
|
|
7641
7834
|
function catalogError(code, path, message) {
|
|
7642
7835
|
throw new CmsfCatalogValidationError(code, path, message);
|
|
7643
7836
|
}
|
|
7644
|
-
function validateCmsfMmtpCatalog(value) {
|
|
7837
|
+
function validateCmsfMmtpCatalog(value, options = {}) {
|
|
7645
7838
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7646
7839
|
catalogError("catalog_object", "$", "catalog must be an object");
|
|
7647
7840
|
}
|
|
@@ -7662,6 +7855,22 @@ var BlockcastMmt = (() => {
|
|
|
7662
7855
|
"commonTrackFields is retired; every track carries its own fields"
|
|
7663
7856
|
);
|
|
7664
7857
|
}
|
|
7858
|
+
const initDataList = catalog["initDataList"];
|
|
7859
|
+
if (initDataList !== void 0) {
|
|
7860
|
+
if (!Array.isArray(initDataList)) {
|
|
7861
|
+
catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
|
|
7862
|
+
}
|
|
7863
|
+
initDataList.forEach((entry, i) => {
|
|
7864
|
+
const e = entry;
|
|
7865
|
+
const entryPath = `$.initDataList[${i}]`;
|
|
7866
|
+
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) {
|
|
7867
|
+
catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
|
|
7868
|
+
}
|
|
7869
|
+
if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
|
|
7870
|
+
catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
|
|
7871
|
+
}
|
|
7872
|
+
});
|
|
7873
|
+
}
|
|
7665
7874
|
const tracks = catalog["tracks"];
|
|
7666
7875
|
const trackRecords = [];
|
|
7667
7876
|
const positiveInteger2 = (input) => Number.isSafeInteger(input) && input > 0;
|
|
@@ -7713,6 +7922,14 @@ var BlockcastMmt = (() => {
|
|
|
7713
7922
|
if (keyframeIntervalMs !== void 0 && !positiveNumber(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger2(keyframeIntervalTicks)) {
|
|
7714
7923
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
7715
7924
|
}
|
|
7925
|
+
const anchor = track["presentationAnchorTicks"];
|
|
7926
|
+
if (anchor !== void 0 && !Number.isSafeInteger(anchor)) {
|
|
7927
|
+
catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
|
|
7928
|
+
}
|
|
7929
|
+
const initRef = track["initRef"];
|
|
7930
|
+
if (initRef !== void 0 && (typeof initRef !== "string" || initRef.length === 0)) {
|
|
7931
|
+
catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
|
|
7932
|
+
}
|
|
7716
7933
|
if (packaging === "fec-repair") {
|
|
7717
7934
|
rejectRepairTrackGeometry(path, track, catalogError);
|
|
7718
7935
|
validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
|
|
@@ -7720,9 +7937,8 @@ var BlockcastMmt = (() => {
|
|
|
7720
7937
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
7721
7938
|
}
|
|
7722
7939
|
if (packaging === "mmtp") {
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
|
|
7940
|
+
if (track["mmtpMode"] !== "mfu") {
|
|
7941
|
+
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
|
|
7726
7942
|
}
|
|
7727
7943
|
if (!positiveInteger2(timescale)) {
|
|
7728
7944
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -7745,8 +7961,8 @@ var BlockcastMmt = (() => {
|
|
|
7745
7961
|
}
|
|
7746
7962
|
const config = fec;
|
|
7747
7963
|
const algorithm = config["algorithm"];
|
|
7748
|
-
if (
|
|
7749
|
-
catalogError("track_fec", `${path}.fec.algorithm`, "
|
|
7964
|
+
if (typeof algorithm !== "string" || algorithm.length === 0) {
|
|
7965
|
+
catalogError("track_fec", `${path}.fec.algorithm`, "must be a non-empty string");
|
|
7750
7966
|
}
|
|
7751
7967
|
if ("interleaveDepth" in config || "interleaveMs" in config) {
|
|
7752
7968
|
catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
|
|
@@ -7775,6 +7991,9 @@ var BlockcastMmt = (() => {
|
|
|
7775
7991
|
}
|
|
7776
7992
|
}
|
|
7777
7993
|
readFecBlockProfile(config["blockProfile"], `${path}.fec.blockProfile`, algorithm !== "none", catalogError);
|
|
7994
|
+
if (algorithm !== "none" && config["symbolSize"] < ISO_SSBG1_MIN_SYMBOL_SIZE) {
|
|
7995
|
+
catalogError("track_fec", `${path}.fec.symbolSize`, "iso-ssbg1-v1 symbolSize must be at least 14");
|
|
7996
|
+
}
|
|
7778
7997
|
}
|
|
7779
7998
|
}
|
|
7780
7999
|
const repairDescriptors = trackRecords.flatMap(
|
|
@@ -7886,15 +8105,8 @@ var BlockcastMmt = (() => {
|
|
|
7886
8105
|
}
|
|
7887
8106
|
}
|
|
7888
8107
|
}
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
} catch (error) {
|
|
7892
|
-
catalogError(
|
|
7893
|
-
"multicast_auth",
|
|
7894
|
-
"$.multicast.auth",
|
|
7895
|
-
error instanceof Error ? error.message : "invalid multicast.auth v2 block"
|
|
7896
|
-
);
|
|
7897
|
-
}
|
|
8108
|
+
const [multicastIssue] = multicastCatalogIssues(catalog, options);
|
|
8109
|
+
if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
|
|
7898
8110
|
validateArchive(catalog);
|
|
7899
8111
|
return catalog;
|
|
7900
8112
|
}
|
|
@@ -7904,14 +8116,42 @@ var BlockcastMmt = (() => {
|
|
|
7904
8116
|
const ms = fec?.interleaveDepthMs;
|
|
7905
8117
|
return typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0 ? ms : void 0;
|
|
7906
8118
|
}
|
|
7907
|
-
function
|
|
7908
|
-
|
|
8119
|
+
function fecBlockDeadlineMs(params) {
|
|
8120
|
+
const { firstAcceptedAtMs, interleaveDepthMs, reorderToleranceMs } = params;
|
|
8121
|
+
if (!Number.isFinite(firstAcceptedAtMs)) {
|
|
8122
|
+
throw new Error(`[FEC] firstAcceptedAtMs must be finite (got ${firstAcceptedAtMs}).`);
|
|
8123
|
+
}
|
|
8124
|
+
return firstAcceptedAtMs + fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs);
|
|
8125
|
+
}
|
|
8126
|
+
function fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs) {
|
|
8127
|
+
if (!Number.isFinite(interleaveDepthMs) || !(interleaveDepthMs > 0)) {
|
|
7909
8128
|
throw new Error(`[FEC] interleaveDepthMs must be a finite value > 0 (got ${interleaveDepthMs}ms). Fix encoder config.`);
|
|
7910
8129
|
}
|
|
7911
|
-
if (!
|
|
7912
|
-
throw new Error(`[FEC]
|
|
8130
|
+
if (!(reorderToleranceMs >= 0) || !Number.isFinite(reorderToleranceMs)) {
|
|
8131
|
+
throw new Error(`[FEC] reorderToleranceMs must be a finite value >= 0 (got ${reorderToleranceMs}ms). It is a catalog value (fec.reorderToleranceMs), not a local default.`);
|
|
7913
8132
|
}
|
|
7914
|
-
return Math.ceil(interleaveDepthMs
|
|
8133
|
+
return Math.ceil(interleaveDepthMs + reorderToleranceMs);
|
|
8134
|
+
}
|
|
8135
|
+
function deriveFecRetentionBlocks(deliveryWindowMs, interleaveDepthMs) {
|
|
8136
|
+
const blocks = tryDeriveFecRetentionBlocks(deliveryWindowMs, interleaveDepthMs);
|
|
8137
|
+
if (blocks !== void 0)
|
|
8138
|
+
return blocks;
|
|
8139
|
+
if (!Number.isFinite(interleaveDepthMs) || !(interleaveDepthMs > 0)) {
|
|
8140
|
+
throw new Error(`[FEC] interleaveDepthMs must be a finite value > 0 (got ${interleaveDepthMs}ms). Fix encoder config.`);
|
|
8141
|
+
}
|
|
8142
|
+
if (!Number.isFinite(deliveryWindowMs) || !(deliveryWindowMs > 0)) {
|
|
8143
|
+
throw new Error(`[FEC] deliveryWindowMs must be a finite value > 0 (got ${deliveryWindowMs}ms). It is derived from catalog geometry, not a local default.`);
|
|
8144
|
+
}
|
|
8145
|
+
throw new Error(`[FEC] retention of ${Math.ceil(deliveryWindowMs / interleaveDepthMs) + 1} blocks exceeds the 255 the decoder and the ISO/IEC 23008-1 AL-FEC signaling byte accept (deliveryWindowMs=${deliveryWindowMs}ms over interleaveDepthMs=${interleaveDepthMs}ms). Fix the catalog geometry: a span this short cannot carry a window this wide.`);
|
|
8146
|
+
}
|
|
8147
|
+
var MAX_FEC_RETENTION_BLOCKS = 255;
|
|
8148
|
+
function tryDeriveFecRetentionBlocks(deliveryWindowMs, interleaveDepthMs) {
|
|
8149
|
+
if (!Number.isFinite(interleaveDepthMs) || !(interleaveDepthMs > 0))
|
|
8150
|
+
return void 0;
|
|
8151
|
+
if (!Number.isFinite(deliveryWindowMs) || !(deliveryWindowMs > 0))
|
|
8152
|
+
return void 0;
|
|
8153
|
+
const blocks = Math.ceil(deliveryWindowMs / interleaveDepthMs) + 1;
|
|
8154
|
+
return blocks > MAX_FEC_RETENTION_BLOCKS ? void 0 : blocks;
|
|
7915
8155
|
}
|
|
7916
8156
|
|
|
7917
8157
|
// ../fec/dist/repair-group.js
|
|
@@ -7935,13 +8175,13 @@ var BlockcastMmt = (() => {
|
|
|
7935
8175
|
function recordOf2(value) {
|
|
7936
8176
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
7937
8177
|
}
|
|
7938
|
-
function
|
|
8178
|
+
function isPositiveSafeInteger2(value) {
|
|
7939
8179
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
7940
8180
|
}
|
|
7941
8181
|
function catalogDeclaresFec(fec) {
|
|
7942
8182
|
const block = recordOf2(fec);
|
|
7943
|
-
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
7944
|
-
return
|
|
8183
|
+
if (block === void 0 || block["algorithm"] === "none" || fecAlgorithmUnimplemented(block["algorithm"])) return false;
|
|
8184
|
+
return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block) && !catalogFecDeclaresUnconfigurableInstance(block);
|
|
7945
8185
|
}
|
|
7946
8186
|
function requireBoolean(value, field) {
|
|
7947
8187
|
if (typeof value !== "boolean") {
|
|
@@ -7969,6 +8209,395 @@ var BlockcastMmt = (() => {
|
|
|
7969
8209
|
return INACTIVE["reliable-moq"];
|
|
7970
8210
|
}
|
|
7971
8211
|
|
|
8212
|
+
// src/mmtp-fec-session.ts
|
|
8213
|
+
var PATH_BITS = { moq: 1, multicast: 2 };
|
|
8214
|
+
var MIXED_PATHS = PATH_BITS.moq | PATH_BITS.multicast;
|
|
8215
|
+
var _decoder, _blocks, _settled, _have, _newest, _prunedAt, _repairPacketId, _stats3, _MmtpFecSession_instances, drop_fn2, noteNewest_fn, blockStartOf_fn, countHeld_fn, noteMixed_fn, behindHorizon_fn, settle_fn, settleClean_fn, settleDecoded_fn, retireBehindHorizon_fn;
|
|
8216
|
+
var MmtpFecSession = class {
|
|
8217
|
+
/**
|
|
8218
|
+
* @throws when the catalog block lacks or misstates a field the session
|
|
8219
|
+
* needs: the block profile, K, T, `interleaveDepthMs` or
|
|
8220
|
+
* `reorderToleranceMs`. None is defaulted.
|
|
8221
|
+
*/
|
|
8222
|
+
constructor(config) {
|
|
8223
|
+
__privateAdd(this, _MmtpFecSession_instances);
|
|
8224
|
+
__privateAdd(this, _decoder);
|
|
8225
|
+
/** Blocks a repair has defined and that are not settled yet, by SS_Start. */
|
|
8226
|
+
__privateAdd(this, _blocks, /* @__PURE__ */ new Map());
|
|
8227
|
+
/** SS_Starts of settled blocks, so a later repair for one is refused. */
|
|
8228
|
+
__privateAdd(this, _settled, /* @__PURE__ */ new Set());
|
|
8229
|
+
/**
|
|
8230
|
+
* SS_IDs whose packet the parser has, with the PATH_BITS of the path it was
|
|
8231
|
+
* received on, or 0 for one the session recovered.
|
|
8232
|
+
*/
|
|
8233
|
+
__privateAdd(this, _have, /* @__PURE__ */ new Map());
|
|
8234
|
+
__privateAdd(this, _newest);
|
|
8235
|
+
/** The newest SS_ID when the remembered SS_IDs were last pruned. */
|
|
8236
|
+
__privateAdd(this, _prunedAt);
|
|
8237
|
+
__privateAdd(this, _repairPacketId);
|
|
8238
|
+
__privateAdd(this, _stats3, {
|
|
8239
|
+
sourceSymbols: 0,
|
|
8240
|
+
repairSymbols: 0,
|
|
8241
|
+
blocksClean: 0,
|
|
8242
|
+
blocksRecovered: 0,
|
|
8243
|
+
blocksFailed: 0,
|
|
8244
|
+
blocksReleased: 0,
|
|
8245
|
+
packetsRecovered: 0,
|
|
8246
|
+
packetsLost: 0,
|
|
8247
|
+
dropped: {},
|
|
8248
|
+
sourceSymbolsByPath: { moq: 0, multicast: 0 },
|
|
8249
|
+
repairSymbolsByPath: { moq: 0, multicast: 0 },
|
|
8250
|
+
mixedPath: { clean: 0, recovered: 0, failed: 0, released: 0 }
|
|
8251
|
+
});
|
|
8252
|
+
const fec = config?.fec;
|
|
8253
|
+
if (!fec || typeof fec !== "object") {
|
|
8254
|
+
throw new Error("MmtpFecSession: the catalog fec block is required");
|
|
8255
|
+
}
|
|
8256
|
+
this.blockProfile = parseFecBlockProfile(fec.blockProfile, "fec.blockProfile");
|
|
8257
|
+
if (fec.algorithm !== void 0 && fec.algorithm !== "raptorq" && fec.algorithm !== "reed-solomon") {
|
|
8258
|
+
throw new Error(`MmtpFecSession: fec.algorithm ${JSON.stringify(fec.algorithm)} is not implemented`);
|
|
8259
|
+
}
|
|
8260
|
+
this.algorithm = fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq";
|
|
8261
|
+
this.sourceSymbols = requirePositiveInteger(fec.sourceSymbols, "fec.sourceSymbols");
|
|
8262
|
+
this.symbolSize = requirePositiveInteger(fec.symbolSize, "fec.symbolSize");
|
|
8263
|
+
const interleaveDepthMs = requireNumber(fec.interleaveDepthMs, "fec.interleaveDepthMs");
|
|
8264
|
+
const reorderToleranceMs = requireNumber(fec.reorderToleranceMs, "fec.reorderToleranceMs");
|
|
8265
|
+
this.retentionBlocks = deriveFecRetentionBlocks(
|
|
8266
|
+
fecBlockBudgetMs(interleaveDepthMs, reorderToleranceMs),
|
|
8267
|
+
interleaveDepthMs
|
|
8268
|
+
);
|
|
8269
|
+
if (typeof config.Decoder !== "function") {
|
|
8270
|
+
throw new Error("MmtpFecSession: a decoder constructor (wasm_bindgen.MmtFecDecoder) is required");
|
|
8271
|
+
}
|
|
8272
|
+
const decoder = new config.Decoder(this.retentionBlocks, this.blockProfile, this.algorithm);
|
|
8273
|
+
try {
|
|
8274
|
+
decoder.configure_params(this.sourceSymbols, this.symbolSize);
|
|
8275
|
+
} catch (error) {
|
|
8276
|
+
decoder.free();
|
|
8277
|
+
throw error;
|
|
8278
|
+
}
|
|
8279
|
+
__privateSet(this, _decoder, decoder);
|
|
8280
|
+
}
|
|
8281
|
+
/** True once release() ran. */
|
|
8282
|
+
get released() {
|
|
8283
|
+
return __privateGet(this, _decoder) === null;
|
|
8284
|
+
}
|
|
8285
|
+
get stats() {
|
|
8286
|
+
return {
|
|
8287
|
+
...__privateGet(this, _stats3),
|
|
8288
|
+
dropped: { ...__privateGet(this, _stats3).dropped },
|
|
8289
|
+
sourceSymbolsByPath: { ...__privateGet(this, _stats3).sourceSymbolsByPath },
|
|
8290
|
+
repairSymbolsByPath: { ...__privateGet(this, _stats3).repairSymbolsByPath },
|
|
8291
|
+
mixedPath: { ...__privateGet(this, _stats3).mixedPath }
|
|
8292
|
+
};
|
|
8293
|
+
}
|
|
8294
|
+
/**
|
|
8295
|
+
* Feeds one received source packet: the MMTP packet without its four-byte
|
|
8296
|
+
* Source FEC Payload ID, under the SS_ID that ID stated. This is what
|
|
8297
|
+
* MmtpContainerParser's onSourceSymbol() hands over. `path` is where it
|
|
8298
|
+
* was received; a caller that only subscribes over MoQT can leave it out.
|
|
8299
|
+
*
|
|
8300
|
+
* @returns the protected packets of this packet's block that it recovered,
|
|
8301
|
+
* in SS_ID order, for the caller to feed to its parser with
|
|
8302
|
+
* `{skipFecPayloadId: true, recovered: true}`. Usually empty.
|
|
8303
|
+
*/
|
|
8304
|
+
addSource(ssId, packet, path = "moq") {
|
|
8305
|
+
const decoder = __privateGet(this, _decoder);
|
|
8306
|
+
if (!decoder) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "source:released");
|
|
8307
|
+
const pathBit = PATH_BITS[path];
|
|
8308
|
+
if (!pathBit) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "source:unknown-path");
|
|
8309
|
+
if (!Number.isInteger(ssId) || ssId < 0 || ssId > 4294967295) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "source:bad-ss-id");
|
|
8310
|
+
if (!ssbg1FitsSymbol(packet.byteLength, this.symbolSize)) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "source:exceeds-symbol");
|
|
8311
|
+
if (__privateGet(this, _have).has(ssId)) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "source:duplicate");
|
|
8312
|
+
__privateGet(this, _have).set(ssId, pathBit);
|
|
8313
|
+
__privateGet(this, _stats3).sourceSymbols++;
|
|
8314
|
+
__privateGet(this, _stats3).sourceSymbolsByPath[path]++;
|
|
8315
|
+
__privateMethod(this, _MmtpFecSession_instances, noteNewest_fn).call(this, ssId);
|
|
8316
|
+
const start = __privateMethod(this, _MmtpFecSession_instances, blockStartOf_fn).call(this, ssId);
|
|
8317
|
+
const block = start === void 0 ? void 0 : __privateGet(this, _blocks).get(start);
|
|
8318
|
+
if (block) {
|
|
8319
|
+
block.received++;
|
|
8320
|
+
block.paths |= pathBit;
|
|
8321
|
+
}
|
|
8322
|
+
let output;
|
|
8323
|
+
try {
|
|
8324
|
+
output = decoder.add_source(ssId, packet, 0);
|
|
8325
|
+
} catch {
|
|
8326
|
+
__privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "source:decoder-refused");
|
|
8327
|
+
output = void 0;
|
|
8328
|
+
}
|
|
8329
|
+
const recovered = [];
|
|
8330
|
+
if (start !== void 0 && block) {
|
|
8331
|
+
if (output) {
|
|
8332
|
+
recovered.push(...__privateMethod(this, _MmtpFecSession_instances, settleDecoded_fn).call(this, start, block, output));
|
|
8333
|
+
} else if (block.received >= block.ssbLength) {
|
|
8334
|
+
__privateMethod(this, _MmtpFecSession_instances, settleClean_fn).call(this, start);
|
|
8335
|
+
}
|
|
8336
|
+
}
|
|
8337
|
+
__privateMethod(this, _MmtpFecSession_instances, retireBehindHorizon_fn).call(this);
|
|
8338
|
+
return recovered;
|
|
8339
|
+
}
|
|
8340
|
+
/**
|
|
8341
|
+
* Feeds one object of the repair track: a whole MMTP repair packet (ISO/IEC
|
|
8342
|
+
* 23008-1 C.5.3). A repair track carries one repair flow, so the first
|
|
8343
|
+
* repair packet fixes its packet ID and a packet of any other is refused.
|
|
8344
|
+
* `path` is where it was received, as for addSource().
|
|
8345
|
+
*
|
|
8346
|
+
* @returns the protected packets this repair symbol recovered, as for
|
|
8347
|
+
* addSource().
|
|
8348
|
+
*/
|
|
8349
|
+
addRepair(packet, path = "moq") {
|
|
8350
|
+
const decoder = __privateGet(this, _decoder);
|
|
8351
|
+
if (!decoder) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:released");
|
|
8352
|
+
const pathBit = PATH_BITS[path];
|
|
8353
|
+
if (!pathBit) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:unknown-path");
|
|
8354
|
+
let header;
|
|
8355
|
+
try {
|
|
8356
|
+
header = parseMMTPHeader(packet);
|
|
8357
|
+
} catch {
|
|
8358
|
+
return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:malformed");
|
|
8359
|
+
}
|
|
8360
|
+
const frame = parseMoqRepairFrameWithHeader(packet, header);
|
|
8361
|
+
if (!frame) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:malformed");
|
|
8362
|
+
if (__privateGet(this, _repairPacketId) === void 0) {
|
|
8363
|
+
__privateSet(this, _repairPacketId, frame.packetId);
|
|
8364
|
+
} else if (frame.packetId !== __privateGet(this, _repairPacketId)) {
|
|
8365
|
+
return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:foreign-packet-id");
|
|
8366
|
+
}
|
|
8367
|
+
if (frame.symbolData.byteLength !== this.symbolSize) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:symbol-size");
|
|
8368
|
+
if (frame.ssbLength > this.sourceSymbols) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:ssb-length");
|
|
8369
|
+
if (this.algorithm === "reed-solomon" && frame.ssbLength + frame.rsbLength > 255) {
|
|
8370
|
+
return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:rs-block-length");
|
|
8371
|
+
}
|
|
8372
|
+
const start = frame.ssStart;
|
|
8373
|
+
let block = __privateGet(this, _blocks).get(start);
|
|
8374
|
+
if (block && block.ssbLength !== frame.ssbLength) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:conflicting-ssb-length");
|
|
8375
|
+
if (block?.rsIds.has(frame.rsId)) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:duplicate");
|
|
8376
|
+
if (!block) {
|
|
8377
|
+
if (__privateGet(this, _settled).has(start)) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:block-settled");
|
|
8378
|
+
if (__privateMethod(this, _MmtpFecSession_instances, behindHorizon_fn).call(this, start)) return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:behind-horizon");
|
|
8379
|
+
block = { ssbLength: frame.ssbLength, received: 0, paths: 0, rsIds: /* @__PURE__ */ new Set() };
|
|
8380
|
+
__privateMethod(this, _MmtpFecSession_instances, countHeld_fn).call(this, start, block);
|
|
8381
|
+
__privateGet(this, _blocks).set(start, block);
|
|
8382
|
+
}
|
|
8383
|
+
__privateMethod(this, _MmtpFecSession_instances, noteNewest_fn).call(this, serial32Add(start, frame.ssbLength - 1));
|
|
8384
|
+
if (block.received >= block.ssbLength) {
|
|
8385
|
+
__privateMethod(this, _MmtpFecSession_instances, settleClean_fn).call(this, start);
|
|
8386
|
+
__privateMethod(this, _MmtpFecSession_instances, retireBehindHorizon_fn).call(this);
|
|
8387
|
+
return [];
|
|
8388
|
+
}
|
|
8389
|
+
let output;
|
|
8390
|
+
try {
|
|
8391
|
+
output = decoder.add_repair(start, frame.ssbLength, frame.rsId, frame.symbolData, 0);
|
|
8392
|
+
} catch {
|
|
8393
|
+
return __privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "repair:decoder-refused");
|
|
8394
|
+
}
|
|
8395
|
+
block.rsIds.add(frame.rsId);
|
|
8396
|
+
__privateGet(this, _stats3).repairSymbols++;
|
|
8397
|
+
__privateGet(this, _stats3).repairSymbolsByPath[path]++;
|
|
8398
|
+
block.paths |= pathBit;
|
|
8399
|
+
const recovered = output ? __privateMethod(this, _MmtpFecSession_instances, settleDecoded_fn).call(this, start, block, output) : [];
|
|
8400
|
+
__privateMethod(this, _MmtpFecSession_instances, retireBehindHorizon_fn).call(this);
|
|
8401
|
+
return recovered;
|
|
8402
|
+
}
|
|
8403
|
+
/**
|
|
8404
|
+
* Frees the decoder and every block. Blocks still unsettled are counted as
|
|
8405
|
+
* released, not failed: nothing proved them unrecoverable. Idempotent;
|
|
8406
|
+
* returns whether this call released anything.
|
|
8407
|
+
*/
|
|
8408
|
+
release() {
|
|
8409
|
+
const decoder = __privateGet(this, _decoder);
|
|
8410
|
+
if (!decoder) return false;
|
|
8411
|
+
__privateSet(this, _decoder, null);
|
|
8412
|
+
__privateGet(this, _stats3).blocksReleased += __privateGet(this, _blocks).size;
|
|
8413
|
+
for (const block of __privateGet(this, _blocks).values()) __privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "released");
|
|
8414
|
+
__privateGet(this, _blocks).clear();
|
|
8415
|
+
__privateGet(this, _settled).clear();
|
|
8416
|
+
__privateGet(this, _have).clear();
|
|
8417
|
+
decoder.free();
|
|
8418
|
+
return true;
|
|
8419
|
+
}
|
|
8420
|
+
};
|
|
8421
|
+
_decoder = new WeakMap();
|
|
8422
|
+
_blocks = new WeakMap();
|
|
8423
|
+
_settled = new WeakMap();
|
|
8424
|
+
_have = new WeakMap();
|
|
8425
|
+
_newest = new WeakMap();
|
|
8426
|
+
_prunedAt = new WeakMap();
|
|
8427
|
+
_repairPacketId = new WeakMap();
|
|
8428
|
+
_stats3 = new WeakMap();
|
|
8429
|
+
_MmtpFecSession_instances = new WeakSet();
|
|
8430
|
+
drop_fn2 = function(reason) {
|
|
8431
|
+
__privateGet(this, _stats3).dropped[reason] = (__privateGet(this, _stats3).dropped[reason] ?? 0) + 1;
|
|
8432
|
+
return [];
|
|
8433
|
+
};
|
|
8434
|
+
noteNewest_fn = function(ssId) {
|
|
8435
|
+
if (__privateGet(this, _newest) === void 0 || serial32Precedes(__privateGet(this, _newest), ssId)) __privateSet(this, _newest, ssId);
|
|
8436
|
+
};
|
|
8437
|
+
blockStartOf_fn = function(ssId) {
|
|
8438
|
+
for (const [start, block] of __privateGet(this, _blocks)) {
|
|
8439
|
+
if (isoBlockContains(start, block.ssbLength, ssId)) return start;
|
|
8440
|
+
}
|
|
8441
|
+
return void 0;
|
|
8442
|
+
};
|
|
8443
|
+
/** Counts the sources of a new block the parser already has, and their paths. */
|
|
8444
|
+
countHeld_fn = function(start, block) {
|
|
8445
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
8446
|
+
const pathBit = __privateGet(this, _have).get(serial32Add(start, i));
|
|
8447
|
+
if (pathBit === void 0) continue;
|
|
8448
|
+
block.received++;
|
|
8449
|
+
block.paths |= pathBit;
|
|
8450
|
+
}
|
|
8451
|
+
};
|
|
8452
|
+
noteMixed_fn = function(block, outcome) {
|
|
8453
|
+
if ((block.paths & MIXED_PATHS) === MIXED_PATHS) __privateGet(this, _stats3).mixedPath[outcome]++;
|
|
8454
|
+
};
|
|
8455
|
+
/** The decoder's own rule: more than its retention behind, counted from below. */
|
|
8456
|
+
behindHorizon_fn = function(start) {
|
|
8457
|
+
const newest = __privateGet(this, _newest);
|
|
8458
|
+
if (newest === void 0) return false;
|
|
8459
|
+
return isoBlocksBehindLowerBound(start, newest, this.sourceSymbols) > this.retentionBlocks;
|
|
8460
|
+
};
|
|
8461
|
+
settle_fn = function(start) {
|
|
8462
|
+
__privateGet(this, _blocks).delete(start);
|
|
8463
|
+
__privateGet(this, _settled).add(start);
|
|
8464
|
+
};
|
|
8465
|
+
settleClean_fn = function(start) {
|
|
8466
|
+
const block = __privateGet(this, _blocks).get(start);
|
|
8467
|
+
if (!block) return;
|
|
8468
|
+
__privateMethod(this, _MmtpFecSession_instances, settle_fn).call(this, start);
|
|
8469
|
+
__privateGet(this, _stats3).blocksClean++;
|
|
8470
|
+
__privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "clean");
|
|
8471
|
+
try {
|
|
8472
|
+
__privateGet(this, _decoder)?.cleanup_blocks_detailed(Uint32Array.of(start));
|
|
8473
|
+
} catch {
|
|
8474
|
+
}
|
|
8475
|
+
};
|
|
8476
|
+
/**
|
|
8477
|
+
* The decoder returns a completed block as its K' ssbg_mode1 symbols,
|
|
8478
|
+
* concatenated: split by T, trim by each symbol's length field, and hand
|
|
8479
|
+
* back the packets the parser does not have yet.
|
|
8480
|
+
*/
|
|
8481
|
+
settleDecoded_fn = function(start, block, output) {
|
|
8482
|
+
__privateMethod(this, _MmtpFecSession_instances, settle_fn).call(this, start);
|
|
8483
|
+
if (output.byteLength !== block.ssbLength * this.symbolSize) {
|
|
8484
|
+
__privateGet(this, _stats3).blocksFailed++;
|
|
8485
|
+
__privateGet(this, _stats3).packetsLost += block.ssbLength - block.received;
|
|
8486
|
+
__privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "failed");
|
|
8487
|
+
__privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "block:decoded-length");
|
|
8488
|
+
return [];
|
|
8489
|
+
}
|
|
8490
|
+
const recovered = [];
|
|
8491
|
+
let refused = 0;
|
|
8492
|
+
for (let i = 0; i < block.ssbLength; i++) {
|
|
8493
|
+
const ssId = serial32Add(start, i);
|
|
8494
|
+
if (__privateGet(this, _have).has(ssId)) continue;
|
|
8495
|
+
const symbol = output.subarray(i * this.symbolSize, (i + 1) * this.symbolSize);
|
|
8496
|
+
const packet = trimSsbg1SourceSymbol(symbol);
|
|
8497
|
+
if (!packet) {
|
|
8498
|
+
refused++;
|
|
8499
|
+
continue;
|
|
8500
|
+
}
|
|
8501
|
+
__privateGet(this, _have).set(ssId, 0);
|
|
8502
|
+
recovered.push(packet.slice());
|
|
8503
|
+
}
|
|
8504
|
+
if (refused > 0) {
|
|
8505
|
+
__privateGet(this, _stats3).blocksFailed++;
|
|
8506
|
+
__privateGet(this, _stats3).packetsLost += refused;
|
|
8507
|
+
__privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "failed");
|
|
8508
|
+
__privateMethod(this, _MmtpFecSession_instances, drop_fn2).call(this, "block:bad-ssbg1-symbol");
|
|
8509
|
+
} else if (recovered.length === 0) {
|
|
8510
|
+
__privateGet(this, _stats3).blocksClean++;
|
|
8511
|
+
__privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "clean");
|
|
8512
|
+
} else {
|
|
8513
|
+
__privateGet(this, _stats3).blocksRecovered++;
|
|
8514
|
+
__privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "recovered");
|
|
8515
|
+
}
|
|
8516
|
+
__privateGet(this, _stats3).packetsRecovered += recovered.length;
|
|
8517
|
+
return recovered;
|
|
8518
|
+
};
|
|
8519
|
+
/**
|
|
8520
|
+
* Retires every block, and every SS_ID the session remembers, that the
|
|
8521
|
+
* newest SS_ID has moved past the retention. An unsettled block retired
|
|
8522
|
+
* here is a failure: more of its sources were lost than its repair could
|
|
8523
|
+
* restore, or its repair never arrived.
|
|
8524
|
+
*/
|
|
8525
|
+
retireBehindHorizon_fn = function() {
|
|
8526
|
+
const decoder = __privateGet(this, _decoder);
|
|
8527
|
+
const newest = __privateGet(this, _newest);
|
|
8528
|
+
if (!decoder || newest === void 0) return;
|
|
8529
|
+
try {
|
|
8530
|
+
decoder.cleanup_by_ss_start(newest);
|
|
8531
|
+
} catch {
|
|
8532
|
+
}
|
|
8533
|
+
for (const [start, block] of __privateGet(this, _blocks)) {
|
|
8534
|
+
if (!__privateMethod(this, _MmtpFecSession_instances, behindHorizon_fn).call(this, start)) continue;
|
|
8535
|
+
__privateMethod(this, _MmtpFecSession_instances, settle_fn).call(this, start);
|
|
8536
|
+
__privateGet(this, _stats3).blocksFailed++;
|
|
8537
|
+
__privateGet(this, _stats3).packetsLost += block.ssbLength - block.received;
|
|
8538
|
+
__privateMethod(this, _MmtpFecSession_instances, noteMixed_fn).call(this, block, "failed");
|
|
8539
|
+
}
|
|
8540
|
+
const prunedAt = __privateGet(this, _prunedAt);
|
|
8541
|
+
if (prunedAt !== void 0 && serial32Distance(prunedAt, newest) < this.sourceSymbols) return;
|
|
8542
|
+
__privateSet(this, _prunedAt, newest);
|
|
8543
|
+
for (const ssId of __privateGet(this, _have).keys()) {
|
|
8544
|
+
if (__privateMethod(this, _MmtpFecSession_instances, behindHorizon_fn).call(this, ssId)) __privateGet(this, _have).delete(ssId);
|
|
8545
|
+
}
|
|
8546
|
+
for (const start of __privateGet(this, _settled)) {
|
|
8547
|
+
if (__privateMethod(this, _MmtpFecSession_instances, behindHorizon_fn).call(this, start)) __privateGet(this, _settled).delete(start);
|
|
8548
|
+
}
|
|
8549
|
+
};
|
|
8550
|
+
function requirePositiveInteger(value, path) {
|
|
8551
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
8552
|
+
throw new Error(`MmtpFecSession: ${path} must be a positive integer (got ${String(value)})`);
|
|
8553
|
+
}
|
|
8554
|
+
return value;
|
|
8555
|
+
}
|
|
8556
|
+
function requireNumber(value, path) {
|
|
8557
|
+
if (typeof value !== "number") {
|
|
8558
|
+
throw new Error(`MmtpFecSession: ${path} is required (got ${String(value)}); it is never defaulted`);
|
|
8559
|
+
}
|
|
8560
|
+
return value;
|
|
8561
|
+
}
|
|
8562
|
+
|
|
8563
|
+
// src/catalog-network-source.ts
|
|
8564
|
+
function normalizePort(value) {
|
|
8565
|
+
const n = typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number.NaN;
|
|
8566
|
+
return Number.isInteger(n) && n > 0 && n <= 65535 ? n : void 0;
|
|
8567
|
+
}
|
|
8568
|
+
function catalogAmtNetworkSource(networkSource) {
|
|
8569
|
+
const entries = Array.isArray(networkSource) ? networkSource : networkSource ? [networkSource] : [];
|
|
8570
|
+
for (const raw of entries) {
|
|
8571
|
+
if (!raw || typeof raw !== "object") continue;
|
|
8572
|
+
const ns = raw;
|
|
8573
|
+
if (ns.type !== "amt") continue;
|
|
8574
|
+
if (ns.discovery === "driad") continue;
|
|
8575
|
+
const relay = typeof ns.relay === "string" ? ns.relay.trim() : "";
|
|
8576
|
+
if (!relay) continue;
|
|
8577
|
+
return { relay, port: normalizePort(ns.port) ?? DEFAULT_AMT_RELAY_PORT };
|
|
8578
|
+
}
|
|
8579
|
+
return void 0;
|
|
8580
|
+
}
|
|
8581
|
+
function intIn(value, min, max) {
|
|
8582
|
+
return Number.isInteger(value) && value >= min && value <= max;
|
|
8583
|
+
}
|
|
8584
|
+
function catalogAtsc3NetworkSource(networkSource) {
|
|
8585
|
+
const entries = Array.isArray(networkSource) ? networkSource : networkSource ? [networkSource] : [];
|
|
8586
|
+
for (const raw of entries) {
|
|
8587
|
+
if (!raw || typeof raw !== "object") continue;
|
|
8588
|
+
const ns = raw;
|
|
8589
|
+
if (ns.type !== "atsc3" || !intIn(ns.frequency, 1, Number.MAX_SAFE_INTEGER)) continue;
|
|
8590
|
+
const slsUri = typeof ns.slsUri === "string" ? ns.slsUri.trim() : "";
|
|
8591
|
+
return {
|
|
8592
|
+
frequency: ns.frequency,
|
|
8593
|
+
...intIn(ns.plpId, 0, 63) ? { plpId: ns.plpId } : {},
|
|
8594
|
+
...intIn(ns.serviceId, 0, 65535) ? { serviceId: ns.serviceId } : {},
|
|
8595
|
+
...slsUri ? { slsUri } : {}
|
|
8596
|
+
};
|
|
8597
|
+
}
|
|
8598
|
+
return void 0;
|
|
8599
|
+
}
|
|
8600
|
+
|
|
7972
8601
|
// src/mmtp-to-cmaf.ts
|
|
7973
8602
|
function box(type, ...children2) {
|
|
7974
8603
|
let size = 8;
|
|
@@ -8011,8 +8640,8 @@ var BlockcastMmt = (() => {
|
|
|
8011
8640
|
}
|
|
8012
8641
|
var KEYFRAME_FLAGS = 33554432;
|
|
8013
8642
|
var DELTA_FLAGS = 16842752;
|
|
8014
|
-
var
|
|
8015
|
-
var MAX_TRACK_ID =
|
|
8643
|
+
var UINT32_MAX2 = 4294967295;
|
|
8644
|
+
var MAX_TRACK_ID = UINT32_MAX2 - 1;
|
|
8016
8645
|
var INT32_MIN = -2147483648;
|
|
8017
8646
|
var INT32_MAX = 2147483647;
|
|
8018
8647
|
function assertTrackId(trackId, label) {
|
|
@@ -8021,8 +8650,8 @@ var BlockcastMmt = (() => {
|
|
|
8021
8650
|
}
|
|
8022
8651
|
}
|
|
8023
8652
|
function assertTimescale(timescale, label) {
|
|
8024
|
-
if (!Number.isInteger(timescale) || timescale <= 0 || timescale >
|
|
8025
|
-
throw new RangeError(`${label} must be an integer in 1..${
|
|
8653
|
+
if (!Number.isInteger(timescale) || timescale <= 0 || timescale > UINT32_MAX2) {
|
|
8654
|
+
throw new RangeError(`${label} must be an integer in 1..${UINT32_MAX2}, got ${timescale}`);
|
|
8026
8655
|
}
|
|
8027
8656
|
}
|
|
8028
8657
|
function assertCompositionTimeOffsets(samples) {
|
|
@@ -9086,7 +9715,7 @@ var BlockcastMmt = (() => {
|
|
|
9086
9715
|
var SOURCE_AUTH_GROUP_CLOSE_LENGTH = 112;
|
|
9087
9716
|
var SOURCE_AUTH_MAX_OBJECTS_PER_GROUP = 4096;
|
|
9088
9717
|
var SOURCE_AUTH_MAX_TRUE_LENGTH = 16 * 1024 * 1024;
|
|
9089
|
-
var
|
|
9718
|
+
var SOURCE_AUTH_SCOPE_LENGTH = 32;
|
|
9090
9719
|
var SIGNATURE_DOMAIN = new TextEncoder().encode("blockcast-mmt-root-v1\0\0\0");
|
|
9091
9720
|
function requireBytes(name, value, length) {
|
|
9092
9721
|
if (value.byteLength !== length) {
|
|
@@ -9163,7 +9792,7 @@ var BlockcastMmt = (() => {
|
|
|
9163
9792
|
throw new Error(`objectCount must be between 1 and ${SOURCE_AUTH_MAX_OBJECTS_PER_GROUP}`);
|
|
9164
9793
|
}
|
|
9165
9794
|
requireU64("groupId", groupId);
|
|
9166
|
-
requireBytes("authScope", authScope,
|
|
9795
|
+
requireBytes("authScope", authScope, SOURCE_AUTH_SCOPE_LENGTH);
|
|
9167
9796
|
requireBytes("root", root, 32);
|
|
9168
9797
|
const preimage = new Uint8Array(100);
|
|
9169
9798
|
const view2 = new DataView(preimage.buffer);
|
|
@@ -9214,6 +9843,20 @@ var BlockcastMmt = (() => {
|
|
|
9214
9843
|
}
|
|
9215
9844
|
|
|
9216
9845
|
// ../mmt-manifest-verify/dist/verifier.js
|
|
9846
|
+
function manifestKeyFor(keys, epoch, kid) {
|
|
9847
|
+
if (new Set(keys.map((key) => key.kid)).size !== keys.length)
|
|
9848
|
+
return void 0;
|
|
9849
|
+
if (new Set(keys.map((key) => key.firstEpoch)).size !== keys.length)
|
|
9850
|
+
return void 0;
|
|
9851
|
+
let signer;
|
|
9852
|
+
for (const key of keys) {
|
|
9853
|
+
if (key.firstEpoch <= epoch && (signer === void 0 || key.firstEpoch > signer.firstEpoch))
|
|
9854
|
+
signer = key;
|
|
9855
|
+
}
|
|
9856
|
+
if (signer === void 0 || kid !== void 0 && signer.kid !== kid)
|
|
9857
|
+
return void 0;
|
|
9858
|
+
return signer.publicKey;
|
|
9859
|
+
}
|
|
9217
9860
|
function manifestBindingId(trackName, sourceSymbolFormat) {
|
|
9218
9861
|
return JSON.stringify([trackName, sourceSymbolFormat]);
|
|
9219
9862
|
}
|
|
@@ -9242,7 +9885,7 @@ var BlockcastMmt = (() => {
|
|
|
9242
9885
|
return diff === 0;
|
|
9243
9886
|
};
|
|
9244
9887
|
var isPromiseLike = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
|
|
9245
|
-
var _config, _verifySignature, _onFailure, _tracks2,
|
|
9888
|
+
var _config, _verifySignature, _onFailure, _tracks2, _stats4, _disposed2, _ManifestVerifier_instances, requireTrack_fn, group_fn, validateIdentity_fn, admitAgainstEntry_fn, rejectOrShadow_fn, resolvePending_fn, closeGroup_fn, finishGroupSignature_fn, verifyAcceptedSignature_fn, failGroup_fn, removePending_fn, quarantine_fn, enforceCap_fn, giveUpOnPending_fn, failOpenTrack_fn, failOpenGroup_fn, releaseAllQuarantine_fn, failure_fn;
|
|
9246
9889
|
var ManifestVerifier = class {
|
|
9247
9890
|
constructor(options) {
|
|
9248
9891
|
__privateAdd(this, _ManifestVerifier_instances);
|
|
@@ -9250,7 +9893,7 @@ var BlockcastMmt = (() => {
|
|
|
9250
9893
|
__privateAdd(this, _verifySignature);
|
|
9251
9894
|
__privateAdd(this, _onFailure);
|
|
9252
9895
|
__privateAdd(this, _tracks2, /* @__PURE__ */ new Map());
|
|
9253
|
-
__privateAdd(this,
|
|
9896
|
+
__privateAdd(this, _stats4, {
|
|
9254
9897
|
verified: 0,
|
|
9255
9898
|
failures: Object.fromEntries(FAILURE_REASONS.map((reason) => [reason, 0])),
|
|
9256
9899
|
quarantinedBytes: 0
|
|
@@ -9268,10 +9911,10 @@ var BlockcastMmt = (() => {
|
|
|
9268
9911
|
for (const track of __privateGet(this, _tracks2).values())
|
|
9269
9912
|
quarantined += track.quarantine.length;
|
|
9270
9913
|
return {
|
|
9271
|
-
verified: __privateGet(this,
|
|
9272
|
-
failures: { ...__privateGet(this,
|
|
9914
|
+
verified: __privateGet(this, _stats4).verified,
|
|
9915
|
+
failures: { ...__privateGet(this, _stats4).failures },
|
|
9273
9916
|
quarantined,
|
|
9274
|
-
quarantinedBytes: __privateGet(this,
|
|
9917
|
+
quarantinedBytes: __privateGet(this, _stats4).quarantinedBytes
|
|
9275
9918
|
};
|
|
9276
9919
|
}
|
|
9277
9920
|
setMode(mode) {
|
|
@@ -9292,11 +9935,12 @@ var BlockcastMmt = (() => {
|
|
|
9292
9935
|
}
|
|
9293
9936
|
if (context.authScope.byteLength !== 32)
|
|
9294
9937
|
throw new Error("manifest authScope must be 32 bytes");
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9938
|
+
for (const key of context.keys) {
|
|
9939
|
+
if (key.publicKey.byteLength !== 32)
|
|
9940
|
+
throw new Error("manifest keys must carry 32-byte public keys");
|
|
9941
|
+
}
|
|
9942
|
+
if (manifestKeyFor(context.keys, context.keyEpoch) === void 0) {
|
|
9943
|
+
throw new Error(`manifest keys hold no key set signing keyEpoch ${context.keyEpoch}`);
|
|
9300
9944
|
}
|
|
9301
9945
|
for (const [name, value] of Object.entries({
|
|
9302
9946
|
broadcastNamespaceId: context.broadcastNamespaceId,
|
|
@@ -9406,7 +10050,7 @@ var BlockcastMmt = (() => {
|
|
|
9406
10050
|
_verifySignature = new WeakMap();
|
|
9407
10051
|
_onFailure = new WeakMap();
|
|
9408
10052
|
_tracks2 = new WeakMap();
|
|
9409
|
-
|
|
10053
|
+
_stats4 = new WeakMap();
|
|
9410
10054
|
_disposed2 = new WeakMap();
|
|
9411
10055
|
_ManifestVerifier_instances = new WeakSet();
|
|
9412
10056
|
requireTrack_fn = function(bindingId) {
|
|
@@ -9458,7 +10102,7 @@ var BlockcastMmt = (() => {
|
|
|
9458
10102
|
return { action: "stall", verified: false };
|
|
9459
10103
|
}
|
|
9460
10104
|
release();
|
|
9461
|
-
__privateGet(this,
|
|
10105
|
+
__privateGet(this, _stats4).verified++;
|
|
9462
10106
|
return { action: "play", verified: true };
|
|
9463
10107
|
};
|
|
9464
10108
|
rejectOrShadow_fn = function(identity, release, reason) {
|
|
@@ -9549,7 +10193,7 @@ var BlockcastMmt = (() => {
|
|
|
9549
10193
|
}
|
|
9550
10194
|
};
|
|
9551
10195
|
verifyAcceptedSignature_fn = function(track, message, signature) {
|
|
9552
|
-
const keys = track.context.
|
|
10196
|
+
const keys = [manifestKeyFor(track.context.keys, track.context.keyEpoch)];
|
|
9553
10197
|
const pending = [];
|
|
9554
10198
|
let hadSynchronousError = false;
|
|
9555
10199
|
for (const key of keys) {
|
|
@@ -9598,7 +10242,7 @@ var BlockcastMmt = (() => {
|
|
|
9598
10242
|
if (index >= 0)
|
|
9599
10243
|
track.quarantine.splice(index, 1);
|
|
9600
10244
|
track.quarantinedBytes -= pending.bytes;
|
|
9601
|
-
__privateGet(this,
|
|
10245
|
+
__privateGet(this, _stats4).quarantinedBytes -= pending.bytes;
|
|
9602
10246
|
};
|
|
9603
10247
|
quarantine_fn = function(track, group, pending) {
|
|
9604
10248
|
if (group.pending.has(pending.identity.objectId))
|
|
@@ -9606,7 +10250,7 @@ var BlockcastMmt = (() => {
|
|
|
9606
10250
|
group.pending.set(pending.identity.objectId, pending);
|
|
9607
10251
|
track.quarantine.push(pending);
|
|
9608
10252
|
track.quarantinedBytes += pending.bytes;
|
|
9609
|
-
__privateGet(this,
|
|
10253
|
+
__privateGet(this, _stats4).quarantinedBytes += pending.bytes;
|
|
9610
10254
|
__privateMethod(this, _ManifestVerifier_instances, enforceCap_fn).call(this, track);
|
|
9611
10255
|
return true;
|
|
9612
10256
|
};
|
|
@@ -9617,7 +10261,7 @@ var BlockcastMmt = (() => {
|
|
|
9617
10261
|
if (group)
|
|
9618
10262
|
group.pending.delete(pending.identity.objectId);
|
|
9619
10263
|
track.quarantinedBytes -= pending.bytes;
|
|
9620
|
-
__privateGet(this,
|
|
10264
|
+
__privateGet(this, _stats4).quarantinedBytes -= pending.bytes;
|
|
9621
10265
|
__privateMethod(this, _ManifestVerifier_instances, giveUpOnPending_fn).call(this, pending);
|
|
9622
10266
|
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestAbsent");
|
|
9623
10267
|
console.warn(`[ManifestVerifier] quarantine cap eviction track=${pending.identity.trackName} group=${pending.identity.groupId} object=${pending.identity.objectId} disposition=${__privateGet(this, _config).mode === "enforce" ? "drop" : "fail-open"}`);
|
|
@@ -9674,7 +10318,7 @@ var BlockcastMmt = (() => {
|
|
|
9674
10318
|
};
|
|
9675
10319
|
failure_fn = function(identity, reason) {
|
|
9676
10320
|
var _a;
|
|
9677
|
-
__privateGet(this,
|
|
10321
|
+
__privateGet(this, _stats4).failures[reason]++;
|
|
9678
10322
|
(_a = __privateGet(this, _onFailure)) == null ? void 0 : _a.call(this, {
|
|
9679
10323
|
trackName: identity.trackName,
|
|
9680
10324
|
...identity.bindingId === void 0 ? {} : { bindingId: identity.bindingId },
|
|
@@ -9684,59 +10328,140 @@ var BlockcastMmt = (() => {
|
|
|
9684
10328
|
});
|
|
9685
10329
|
};
|
|
9686
10330
|
|
|
9687
|
-
//
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
10331
|
+
// ../mmt-manifest-verify/dist/bc-provenance-v2.js
|
|
10332
|
+
var BCPV2_HEADER_LENGTH = 68;
|
|
10333
|
+
var BCPV2_SIGNATURE_LENGTH = 64;
|
|
10334
|
+
var BCPV2_MIN_RECORD_LENGTH = BCPV2_HEADER_LENGTH + 32 + BCPV2_SIGNATURE_LENGTH;
|
|
10335
|
+
var text = new TextEncoder();
|
|
10336
|
+
var MAGIC = Uint8Array.from([77, 72, 77, 50]);
|
|
10337
|
+
var SIGNING_DOMAIN = text.encode("mcast-manifest-v2\0");
|
|
10338
|
+
|
|
10339
|
+
// src/multicast-auth-catalog.ts
|
|
10340
|
+
var RAW_ED25519_KEY_LENGTH = 32;
|
|
10341
|
+
var DEFAULT_MAX_AUTH_DELAY_MS = 200;
|
|
10342
|
+
var DEFAULT_MANIFEST_TIMER_MS = 20;
|
|
10343
|
+
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
10344
|
+
function encodeBase64Url(bytes) {
|
|
10345
|
+
let output = "";
|
|
10346
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
10347
|
+
const b0 = bytes[i];
|
|
10348
|
+
const b1 = bytes[i + 1];
|
|
10349
|
+
const b2 = bytes[i + 2];
|
|
10350
|
+
output += BASE64URL_ALPHABET[b0 >> 2];
|
|
10351
|
+
output += BASE64URL_ALPHABET[(b0 & 3) << 4 | (b1 === void 0 ? 0 : b1 >> 4)];
|
|
10352
|
+
if (b1 === void 0) break;
|
|
10353
|
+
output += BASE64URL_ALPHABET[(b1 & 15) << 2 | (b2 === void 0 ? 0 : b2 >> 6)];
|
|
10354
|
+
if (b2 === void 0) break;
|
|
10355
|
+
output += BASE64URL_ALPHABET[b2 & 63];
|
|
10356
|
+
}
|
|
10357
|
+
return output;
|
|
10358
|
+
}
|
|
10359
|
+
var BASE64URL_DECODE_TABLE = (() => {
|
|
10360
|
+
const table = new Int8Array(128).fill(-1);
|
|
10361
|
+
for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
|
|
10362
|
+
table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
|
|
10363
|
+
}
|
|
10364
|
+
return table;
|
|
10365
|
+
})();
|
|
10366
|
+
function decodeBase64Url(text2) {
|
|
10367
|
+
if (text2.length % 4 === 1) {
|
|
10368
|
+
throw new Error(`[multicast-auth-catalog] invalid unpadded base64url length for "${text2}"`);
|
|
10369
|
+
}
|
|
10370
|
+
const bytes = [];
|
|
10371
|
+
let buffer = 0;
|
|
10372
|
+
let bits = 0;
|
|
10373
|
+
for (let i = 0; i < text2.length; i++) {
|
|
10374
|
+
const code = text2.charCodeAt(i);
|
|
10375
|
+
const value = code < 128 ? BASE64URL_DECODE_TABLE[code] : -1;
|
|
10376
|
+
if (value === void 0 || value < 0) {
|
|
10377
|
+
throw new Error(`[multicast-auth-catalog] invalid base64url character in "${text2}"`);
|
|
10378
|
+
}
|
|
10379
|
+
buffer = buffer << 6 | value;
|
|
10380
|
+
bits += 6;
|
|
10381
|
+
if (bits >= 8) {
|
|
10382
|
+
bits -= 8;
|
|
10383
|
+
bytes.push(buffer >> bits & 255);
|
|
10384
|
+
}
|
|
10385
|
+
}
|
|
10386
|
+
const decoded = Uint8Array.from(bytes);
|
|
10387
|
+
if (encodeBase64Url(decoded) !== text2) {
|
|
10388
|
+
throw new Error(`[multicast-auth-catalog] non-canonical base64url encoding "${text2}"`);
|
|
10389
|
+
}
|
|
10390
|
+
return decoded;
|
|
10391
|
+
}
|
|
10392
|
+
function decodeEd25519PublicKey(publicKey) {
|
|
10393
|
+
const bytes = decodeBase64Url(publicKey);
|
|
10394
|
+
if (bytes.byteLength !== RAW_ED25519_KEY_LENGTH) {
|
|
10395
|
+
throw new Error(
|
|
10396
|
+
`[multicast-auth-catalog] public key must decode to ${RAW_ED25519_KEY_LENGTH} raw bytes, got ${bytes.byteLength}`
|
|
10397
|
+
);
|
|
10398
|
+
}
|
|
10399
|
+
return bytes;
|
|
10400
|
+
}
|
|
10401
|
+
function resolveMulticastAuthCatalog(catalog, options = {}) {
|
|
10402
|
+
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) {
|
|
10403
|
+
throw new Error("[multicast-auth-catalog] catalog must be an object");
|
|
10404
|
+
}
|
|
10405
|
+
const issues = multicastCatalogIssues(catalog, options);
|
|
10406
|
+
const fatal = issues.find((issue) => issue.endpointIndex === void 0);
|
|
10407
|
+
if (fatal) throw new Error(`[multicast-auth-catalog] ${fatal.path}: ${fatal.message}`);
|
|
10408
|
+
const multicast = catalog["multicast"];
|
|
10409
|
+
const auth = multicast?.["auth"];
|
|
10410
|
+
if (auth === void 0) {
|
|
10411
|
+
if (options.requireAuth) {
|
|
10412
|
+
throw new Error("[multicast-auth-catalog] authentication is pinned but the catalog declares no multicast.auth");
|
|
10413
|
+
}
|
|
10414
|
+
return void 0;
|
|
10415
|
+
}
|
|
10416
|
+
const ignored = new Set(issues.map((issue) => issue.endpointIndex));
|
|
10417
|
+
const endpoints = multicast["endpoints"] ?? [];
|
|
10418
|
+
const flows = [];
|
|
10419
|
+
endpoints.forEach((endpoint, endpointIndex) => {
|
|
10420
|
+
if (ignored.has(endpointIndex)) return;
|
|
10421
|
+
const flowAuth = endpoint["auth"];
|
|
10422
|
+
flows.push({
|
|
10423
|
+
endpointIndex,
|
|
10424
|
+
source: endpoint["sourceAddress"] ?? flowAuth.senderAddress,
|
|
10425
|
+
groupAddress: endpoint["groupAddress"],
|
|
10426
|
+
port: endpoint["port"],
|
|
10427
|
+
bandwidth: endpoint["bandwidth"],
|
|
10428
|
+
manifestPort: flowAuth.manifestPort,
|
|
10429
|
+
streamId: flowAuth.streamId,
|
|
10430
|
+
maxAuthDelayMs: flowAuth.maxAuthDelayMs ?? DEFAULT_MAX_AUTH_DELAY_MS,
|
|
10431
|
+
manifestTimerMs: flowAuth.manifestTimerMs ?? DEFAULT_MANIFEST_TIMER_MS,
|
|
10432
|
+
...flowAuth.manifestTrack === void 0 ? {} : { manifestTrack: flowAuth.manifestTrack },
|
|
10433
|
+
tracks: (endpoint["tracks"] ?? []).map(({ name, packetId }) => ({
|
|
10434
|
+
name,
|
|
10435
|
+
packetId
|
|
10436
|
+
}))
|
|
9716
10437
|
});
|
|
9717
|
-
byManifestTrack.set(binding.manifestTrack, planned);
|
|
9718
|
-
return planned;
|
|
9719
10438
|
});
|
|
9720
|
-
let disposed = false;
|
|
9721
10439
|
return {
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
10440
|
+
keys: auth.keys.map((key) => ({ kid: key.kid, publicKey: decodeEd25519PublicKey(key.publicKey), firstEpoch: key.firstEpoch })).sort((a, b) => a.firstEpoch - b.firstEpoch),
|
|
10441
|
+
minEpoch: auth.minEpoch,
|
|
10442
|
+
flows
|
|
10443
|
+
};
|
|
10444
|
+
}
|
|
10445
|
+
function multicastAuthKeyFor(resolved, kid, epoch) {
|
|
10446
|
+
return manifestKeyFor(resolved.keys, epoch, kid);
|
|
10447
|
+
}
|
|
10448
|
+
|
|
10449
|
+
// src/manifest-auth-plan.ts
|
|
10450
|
+
function createManifestAuthPlan(catalog, options = {}) {
|
|
10451
|
+
const resolved = resolveMulticastAuthCatalog(catalog, options);
|
|
10452
|
+
if (!resolved) return void 0;
|
|
10453
|
+
const byManifestTrack = /* @__PURE__ */ new Map();
|
|
10454
|
+
for (const flow of resolved.flows) {
|
|
10455
|
+
if (flow.manifestTrack !== void 0) byManifestTrack.set(flow.manifestTrack, flow);
|
|
10456
|
+
}
|
|
10457
|
+
return {
|
|
10458
|
+
keys: resolved.keys,
|
|
10459
|
+
minEpoch: resolved.minEpoch,
|
|
10460
|
+
flows: resolved.flows,
|
|
9725
10461
|
manifestTracks: [...byManifestTrack.keys()],
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
},
|
|
9730
|
-
ingestManifestPayload(manifestTrack, payload) {
|
|
9731
|
-
const binding = byManifestTrack.get(manifestTrack);
|
|
9732
|
-
if (!binding) throw new Error(`unknown manifest subscription track ${manifestTrack}`);
|
|
9733
|
-
verifier.ingestManifestFrame(binding.bindingId, payload);
|
|
9734
|
-
},
|
|
9735
|
-
dispose() {
|
|
9736
|
-
if (disposed) return;
|
|
9737
|
-
disposed = true;
|
|
9738
|
-
verifier.dispose();
|
|
9739
|
-
}
|
|
10462
|
+
keyFor: (kid, epoch) => multicastAuthKeyFor(resolved, kid, epoch),
|
|
10463
|
+
flowForManifestPort: (source, groupAddress, manifestPort) => resolved.flows.find((flow) => flow.source === source && flow.groupAddress === groupAddress && flow.manifestPort === manifestPort),
|
|
10464
|
+
flowForManifestTrack: (manifestTrack) => byManifestTrack.get(manifestTrack)
|
|
9740
10465
|
};
|
|
9741
10466
|
}
|
|
9742
10467
|
return __toCommonJS(no_modules_exports);
|