@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbdfdbf39ded
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -20
- 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 +1721 -705
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +72 -34
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +309 -204
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +15 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +137 -50
- package/dist/catalog-fec-params.js.map +4 -4
- 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 +24 -1
- package/dist/catalog-network-source.js.map +3 -3
- 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 +100 -230
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +64 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +275 -62
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +5 -3
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +34 -12
- package/dist/fec-state.js.map +4 -4
- 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 +15 -3
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -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 +100 -17
- package/dist/iso-block-locator.js.map +4 -4
- 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 +24 -13
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +96 -22
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +1138 -325
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +96 -22
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- 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 +31 -5
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +168 -22
- package/dist/mmtp-router.js.map +3 -3
- 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 +293 -28
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +89 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +730 -356
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +12 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +111 -235
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +24 -13
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +1087 -309
- 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 +159 -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 +22 -2
- package/dist/repair-layers.js.map +3 -3
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +6 -3
- package/dist/signaling.js.map +3 -3
- 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 +24 -13
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +3 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +96 -22
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +6 -9
- package/schemas/catalog.schema.json +124 -37
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +163 -61
- package/src/catalog-fec-params.ts +66 -20
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +239 -63
- package/src/fec-state.ts +14 -12
- package/src/fec-worker-setup.ts +20 -2
- package/src/index.ts +29 -10
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +133 -5
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +258 -21
- package/src/multicast-transport.ts +17 -3
- 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/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +65 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-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 +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/src/fec-codec.ts +0 -61
package/src/mmtp-router.ts
CHANGED
|
@@ -435,10 +435,11 @@ export type RoutedPacketMeta = {
|
|
|
435
435
|
/**
|
|
436
436
|
* The MMTP header RAP flag: the packet starts a random access point. On a
|
|
437
437
|
* `recovered` packet it is read from the FEC-reconstructed header, which is
|
|
438
|
-
* byte-exact, so it is the flag the
|
|
439
|
-
* decisions deliberately ignore it for
|
|
440
|
-
* judges those by bitstream only); a host
|
|
441
|
-
* point should decide explicitly whether a
|
|
438
|
+
* byte-exact outside packet_sequence_number, so it is the flag the
|
|
439
|
+
* publisher sent. The router's own gap decisions deliberately ignore it for
|
|
440
|
+
* recovered frames (`#isRapForGap` judges those by bitstream only); a host
|
|
441
|
+
* using it as a tier-switch commit point should decide explicitly whether a
|
|
442
|
+
* recovered RAP qualifies.
|
|
442
443
|
*/
|
|
443
444
|
rap: boolean;
|
|
444
445
|
/** True when FEC reconstructed this source packet. */
|
|
@@ -560,6 +561,20 @@ export interface FECManagerLike {
|
|
|
560
561
|
/** A block's RSB_length, from one of its repair symbols (optional). */
|
|
561
562
|
noteRepairGroupLength?(sbn: number, packetId: number, rsbLength: number, catalogTrackName?: string): void;
|
|
562
563
|
|
|
564
|
+
/** fec-01 4.5: refuse a repair header whose block length the track's scheme
|
|
565
|
+
* forbids, before it touches block state (optional). */
|
|
566
|
+
admitRepairBlockLength?(packetId: number, ssbLength: number, rsbLength: number, rsId: number): boolean;
|
|
567
|
+
|
|
568
|
+
/** Validate a repair symbol's size before it touches block state; counts a
|
|
569
|
+
* mismatch on `repairSymbolSizeMismatches` (optional). */
|
|
570
|
+
admitRepairSymbolSize?(
|
|
571
|
+
packetId: number,
|
|
572
|
+
ssStart: number,
|
|
573
|
+
ssbLength: number,
|
|
574
|
+
rsId: number,
|
|
575
|
+
byteLength: number,
|
|
576
|
+
): boolean;
|
|
577
|
+
|
|
563
578
|
/** Feed a repair symbol to the FEC decoder for a given track.
|
|
564
579
|
* Returns recovered block bytes if recovery completes, else null. */
|
|
565
580
|
feedRepairSymbol(
|
|
@@ -695,6 +710,13 @@ export interface FECManagerLike {
|
|
|
695
710
|
ssStart: number,
|
|
696
711
|
ssbLength: number,
|
|
697
712
|
): IsoRepairPlacement<IsoHeldSource>;
|
|
713
|
+
/** iso-ssbg1-v1: turn the pending holes in a range into spans, with the sources they place. */
|
|
714
|
+
closeIsoHoles?(
|
|
715
|
+
packetId: number,
|
|
716
|
+
catalogTrackName: string | undefined,
|
|
717
|
+
start: number,
|
|
718
|
+
length: number,
|
|
719
|
+
): readonly { readonly block: { readonly start: number }; readonly placed: readonly IsoPlacedSource<IsoHeldSource>[] }[];
|
|
698
720
|
/** iso-ssbg1-v1: resolution of the SS_IDs strictly between two released frames. */
|
|
699
721
|
isoSpanResolution?(
|
|
700
722
|
packetId: number,
|
|
@@ -896,6 +918,18 @@ export class MmtpRouter {
|
|
|
896
918
|
// MSE recovery routes through CmafBlockAssembler and can reorder by block; the
|
|
897
919
|
// direct callback path has to preserve decode order before frames leave libmmt.
|
|
898
920
|
#latestVideoSeqByStream = new Map<string, number>();
|
|
921
|
+
/**
|
|
922
|
+
* Per stream, SS_ID - packet_sequence_number (mod 2^32) of its latest
|
|
923
|
+
* first-arrival FEC source packet. A recovered source symbol's wire
|
|
924
|
+
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
925
|
+
*/
|
|
926
|
+
#ssIdSeqOffsetByStream = new Map<string, number>();
|
|
927
|
+
/**
|
|
928
|
+
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
929
|
+
* not parsed, typically because its overlap copy was parsed first
|
|
930
|
+
* (BLO-49179). The next video keyframe emitted on the stream consumes it.
|
|
931
|
+
*/
|
|
932
|
+
#multicastRapTwinByStream = new Set<string>();
|
|
899
933
|
#lastDirectSourceVideoTsByStream = new Map<string, number>();
|
|
900
934
|
#lastDirectEmittedVideoTsByStream = new Map<string, number>();
|
|
901
935
|
#pendingDirectRecoveredVideoByStream = new Map<string, Map<string, PendingRecoveredVideoFrame>>();
|
|
@@ -988,6 +1022,7 @@ export class MmtpRouter {
|
|
|
988
1022
|
*/
|
|
989
1023
|
#onPublisherRestart: ((packetId: number, catalogTrackName: string) => void) | null;
|
|
990
1024
|
#publisherRestarts = 0;
|
|
1025
|
+
#restampedRecoveredSeqs = 0;
|
|
991
1026
|
/** Inits delivered with no onTrackInit handler for their packetId (MOQT-01). */
|
|
992
1027
|
#unmappedInitDeliveries = 0;
|
|
993
1028
|
// FEC Payload IDs left unread because their (owner) packetId had no
|
|
@@ -1119,6 +1154,19 @@ export class MmtpRouter {
|
|
|
1119
1154
|
: { catalogTrackName: meta.catalogTrackName }),
|
|
1120
1155
|
};
|
|
1121
1156
|
if (meta.source) frameMeta.source = meta.source;
|
|
1157
|
+
// During make-before-break the overlap copy usually wins the parse ledger,
|
|
1158
|
+
// so almost every frame is head-attributed to "moq" and multicast takeover
|
|
1159
|
+
// waited on a rare multicast-won keyframe (BLO-49179: 34 s, 38 s, or past
|
|
1160
|
+
// the 30 s window). A RAP whose multicast twin the ledger dropped is
|
|
1161
|
+
// multicast delivering keyframes, so the next keyframe routes as multicast:
|
|
1162
|
+
// this one if the twin beat its tail, else at most one GOP later.
|
|
1163
|
+
// deliveryProvenance is unchanged and stays 'mixed'.
|
|
1164
|
+
if (isVideo && frameMeta.keyframe) {
|
|
1165
|
+
const twinSeen = this.#multicastRapTwinByStream.delete(
|
|
1166
|
+
this.#mediaStreamKey(packetId, frameMeta.catalogTrackName),
|
|
1167
|
+
);
|
|
1168
|
+
if (twinSeen && frameMeta.source === "moq") frameMeta.source = "multicast";
|
|
1169
|
+
}
|
|
1122
1170
|
// Forward whenever present, not when truthy: 'unknown' is a verdict the
|
|
1123
1171
|
// parser reached, not a value to drop.
|
|
1124
1172
|
if (meta.deliveryProvenance !== undefined)
|
|
@@ -1364,6 +1412,15 @@ export class MmtpRouter {
|
|
|
1364
1412
|
return this.#publisherRestarts;
|
|
1365
1413
|
}
|
|
1366
1414
|
|
|
1415
|
+
/**
|
|
1416
|
+
* FEC-recovered source symbols whose reconstructed header named a
|
|
1417
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to:
|
|
1418
|
+
* a hop re-stamped the sequence after the sender protected the packet.
|
|
1419
|
+
*/
|
|
1420
|
+
get restampedRecoveredSequenceCount(): number {
|
|
1421
|
+
return this.#restampedRecoveredSeqs;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1367
1424
|
/**
|
|
1368
1425
|
* Packets whose Source or Repair FEC Payload ID was left unread because
|
|
1369
1426
|
* their (owner) packetId had no configured `fec.blockProfile`: FEC not
|
|
@@ -2014,6 +2071,23 @@ export class MmtpRouter {
|
|
|
2014
2071
|
`[MmtpRouter] packetId=${ownerPacketId} is iso-ssbg1-v1 but its FEC manager cannot place ISO blocks`,
|
|
2015
2072
|
);
|
|
2016
2073
|
}
|
|
2074
|
+
// A repair symbol that is not exactly T bytes is invalid: refuse it before
|
|
2075
|
+
// it can place a block or be swallowed by dedup, so it is always counted
|
|
2076
|
+
// and never reaches the decoder (BLO-48306).
|
|
2077
|
+
if (
|
|
2078
|
+
fec.admitRepairBlockLength &&
|
|
2079
|
+
!fec.admitRepairBlockLength(ownerPacketId, repair.ssbLength, repair.rsbLength, repair.rsId)
|
|
2080
|
+
) return;
|
|
2081
|
+
if (
|
|
2082
|
+
fec.admitRepairSymbolSize &&
|
|
2083
|
+
!fec.admitRepairSymbolSize(
|
|
2084
|
+
ownerPacketId,
|
|
2085
|
+
repair.ssStart,
|
|
2086
|
+
repair.ssbLength,
|
|
2087
|
+
repair.rsId,
|
|
2088
|
+
repair.symbolData.byteLength,
|
|
2089
|
+
)
|
|
2090
|
+
) return;
|
|
2017
2091
|
const placement = fec.placeIsoRepair(ownerPacketId, catalogTrackName, repair.ssStart, repair.ssbLength);
|
|
2018
2092
|
if (placement.status !== "placed") return;
|
|
2019
2093
|
const blockStart = placement.block.start;
|
|
@@ -2049,6 +2123,23 @@ export class MmtpRouter {
|
|
|
2049
2123
|
}
|
|
2050
2124
|
}
|
|
2051
2125
|
|
|
2126
|
+
/**
|
|
2127
|
+
* The range repair FETCH for an undelimited hole ended (draft-ramadan-moq-fec
|
|
2128
|
+
* §7.5): what no repair stated becomes repair-less spans, whose held sources
|
|
2129
|
+
* are fed exactly as a span a repair closed.
|
|
2130
|
+
*/
|
|
2131
|
+
closeIsoHoles(
|
|
2132
|
+
ownerPacketId: number,
|
|
2133
|
+
catalogTrackName: string | undefined,
|
|
2134
|
+
start: number,
|
|
2135
|
+
length: number,
|
|
2136
|
+
): void {
|
|
2137
|
+
const spans = this.#fecManager?.closeIsoHoles?.(ownerPacketId, catalogTrackName, start, length) ?? [];
|
|
2138
|
+
for (const span of spans) {
|
|
2139
|
+
this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2052
2143
|
/**
|
|
2053
2144
|
* Feed iso-ssbg1-v1 sources a repair just placed, in SS_ID order, exactly as
|
|
2054
2145
|
* a first-arrival source is fed once its block is known: transport
|
|
@@ -2180,6 +2271,8 @@ export class MmtpRouter {
|
|
|
2180
2271
|
this.#trackSynced.delete(streamKey);
|
|
2181
2272
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
2182
2273
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
2274
|
+
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
2275
|
+
this.#multicastRapTwinByStream.delete(streamKey);
|
|
2183
2276
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
2184
2277
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
2185
2278
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -3205,6 +3298,13 @@ export class MmtpRouter {
|
|
|
3205
3298
|
parseSourceSymbol = !duplicates.parsedSymbols.has(info.fecPayloadId.ssId);
|
|
3206
3299
|
}
|
|
3207
3300
|
|
|
3301
|
+
if (fecPayloadId && !overlapCopy) {
|
|
3302
|
+
this.#ssIdSeqOffsetByStream.set(
|
|
3303
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName),
|
|
3304
|
+
(fecPayloadId.ssId - info.sequenceNumber) >>> 0,
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3208
3308
|
// Parse only the first copy of an FEC source symbol. A late direct copy
|
|
3209
3309
|
// of a worker-recovered fragment has the same SBN/ESI and fragment
|
|
3210
3310
|
// counter; feeding it again can make the MFU buffer non-contiguous even
|
|
@@ -3231,6 +3331,11 @@ export class MmtpRouter {
|
|
|
3231
3331
|
// An FEC source frame is anchored by its own SS_ID (C.5.2).
|
|
3232
3332
|
...(fecSource && fecPayloadId ? { fecSbn: fecPayloadId.ssId } : {}),
|
|
3233
3333
|
}, parsed);
|
|
3334
|
+
} else if (source === "multicast" && info.rapFlag) {
|
|
3335
|
+
// Usually the twin of a RAP its overlap copy already parsed.
|
|
3336
|
+
this.#multicastRapTwinByStream.add(
|
|
3337
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName),
|
|
3338
|
+
);
|
|
3234
3339
|
}
|
|
3235
3340
|
// The frame this packet completed can commit an in-place switch that
|
|
3236
3341
|
// retires this very packet ID. Its FEC state is gone then, and feeding
|
|
@@ -4080,6 +4185,28 @@ export class MmtpRouter {
|
|
|
4080
4185
|
// which track this block belongs to — resolves per-track, then legacy fallback.
|
|
4081
4186
|
if (ownerPacketId == null) return; // no track association
|
|
4082
4187
|
if (this.#classifyPacketId(ownerPacketId) === null) return; // unknown track
|
|
4188
|
+
// A recovered symbol's header names the sequence the sender protected. A
|
|
4189
|
+
// hop that re-stamps packet_sequence_number after protection (cast's
|
|
4190
|
+
// publisher-rotation bridge) leaves the decode mixing every received
|
|
4191
|
+
// source's re-stamped bytes into it. The reassembler addresses a
|
|
4192
|
+
// fragmented data unit by sequence + fragment counter, and the source
|
|
4193
|
+
// dedup reads the same number, so that fragment would park under a
|
|
4194
|
+
// foreign address until its data unit times out. Its SS_ID still names
|
|
4195
|
+
// its wire sequence, through the offset every received source states.
|
|
4196
|
+
const ssIdSeqOffset = this.#ssIdSeqOffsetByStream.get(
|
|
4197
|
+
this.#mediaStreamKey(ownerPacketId, catalogTrackName),
|
|
4198
|
+
);
|
|
4199
|
+
if (ssIdSeqOffset !== undefined) {
|
|
4200
|
+
result = {
|
|
4201
|
+
...result,
|
|
4202
|
+
symbols: result.symbols.map((sym) => {
|
|
4203
|
+
const wire = (this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset) >>> 0;
|
|
4204
|
+
if (wire === sym.packetSequenceNumber) return sym;
|
|
4205
|
+
this.#restampedRecoveredSeqs++;
|
|
4206
|
+
return { ...sym, packetSequenceNumber: wire };
|
|
4207
|
+
}),
|
|
4208
|
+
};
|
|
4209
|
+
}
|
|
4083
4210
|
this.#stream(ownerPacketId, catalogTrackName).duplicates.advance(blockId);
|
|
4084
4211
|
|
|
4085
4212
|
// A recovered symbol is a function of EVERY symbol that entered its block,
|
|
@@ -4100,7 +4227,8 @@ export class MmtpRouter {
|
|
|
4100
4227
|
) ?? 'unknown';
|
|
4101
4228
|
|
|
4102
4229
|
for (const sym of result.symbols) {
|
|
4103
|
-
// The block processor read these from the recovered packet's own
|
|
4230
|
+
// The block processor read these from the recovered packet's own
|
|
4231
|
+
// header; the sequence is the wire one derived above.
|
|
4104
4232
|
this.#routeTrackPacket(sym.rawSymbol, ownerPacketId, sym.packetSequenceNumber, {
|
|
4105
4233
|
mmtpTimestamp: sym.fragment.timestamp,
|
|
4106
4234
|
rap: sym.fragment.rapFlag,
|
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `multicast.auth`
|
|
3
|
-
*
|
|
2
|
+
* `multicast.auth` and an endpoint's `auth`: bc-provenance version 2, per
|
|
3
|
+
* draft-ramadan-moq-multicast-01 7.2.6 at
|
|
4
|
+
* Blockcast/moqcast-draft@fd962fd73d21ed281b60219c11ea61cc9e4e91c4.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* describe two protected tracks (e.g. audio + video) in one session.
|
|
6
|
+
* The block lives in the `multicast` object, never the root: the root dotted
|
|
7
|
+
* key `"multicast.auth"` was draft -00's (libmmt called its `tracks[]` shape
|
|
8
|
+
* "multicast.auth v2 (BLO-16700)", which is the draft's bc-provenance
|
|
9
|
+
* version 1) and is refused. `multicast.auth` declares the profile and its
|
|
10
|
+
* keys; an endpoint's `auth` marks that endpoint's flow protected and carries
|
|
11
|
+
* the flow's parameters. There is no verify-and-report mode (7.2.7): a
|
|
12
|
+
* receiver that implements the profile enforces it.
|
|
13
13
|
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
16
|
-
* `manifestTrack` into a `tracks[]` array, one entry per protected media
|
|
17
|
-
* track, each carrying its own `manifestTrack` name, `authScope`, and
|
|
18
|
-
* `sourceSymbolFormat`. This is additive over the S3 draft shape (every
|
|
19
|
-
* top-level field the draft specified still exists at the top level) —
|
|
20
|
-
* only `manifestTrack` moves from top-level into each track entry.
|
|
21
|
-
*
|
|
22
|
-
* `manifestTrack` is carried as an opaque string field, deliberately NOT
|
|
23
|
-
* run through `parseTrackRole`/`VALID_ROLE_SUFFIXES` in ./carp-catalog.ts.
|
|
24
|
-
* `carp-catalog.ts` only recognises `base`/`delta`/`repair` role suffixes
|
|
25
|
-
* and throws on anything else (including a hypothetical `manifest` role);
|
|
26
|
-
* resolving BLO-16485's "manifest-track name collision" MANDATORY item by
|
|
27
|
-
* adding a role would force every catalog consumer to learn a fourth role
|
|
28
|
-
* and would break `validateSwitchingSet`'s base/delta/repair completeness
|
|
29
|
-
* check. Carrying it as a typed field here avoids both.
|
|
14
|
+
* The rules are `multicastCatalogIssues` in `@blockcast/mmt-base`, shared with
|
|
15
|
+
* the transport receivers; this module decodes what they admit.
|
|
30
16
|
*/
|
|
31
17
|
|
|
18
|
+
import { multicastCatalogIssues } from "@blockcast/mmt-base";
|
|
19
|
+
import { manifestKeyFor, type ManifestKey } from "@blockcast/mmt-manifest-verify";
|
|
20
|
+
|
|
32
21
|
export type MulticastAuthScheme = "bc-provenance";
|
|
33
|
-
export type MulticastAuthHash = "blake3";
|
|
34
22
|
export type MulticastAuthSig = "ed25519";
|
|
35
|
-
export type MulticastAuthCompaction = "merkle" | "none";
|
|
36
|
-
export type MulticastAuthEnforcement = "shadow" | "enforce";
|
|
37
|
-
export type MulticastAuthMode = "off" | MulticastAuthEnforcement;
|
|
38
23
|
|
|
39
24
|
const RAW_ED25519_KEY_LENGTH = 32;
|
|
40
|
-
|
|
25
|
+
|
|
26
|
+
/** Default `maxAuthDelayMs` and `manifestTimerMs` of an endpoint's `auth`. */
|
|
27
|
+
export const DEFAULT_MAX_AUTH_DELAY_MS = 200;
|
|
28
|
+
export const DEFAULT_MANIFEST_TIMER_MS = 20;
|
|
41
29
|
|
|
42
30
|
const BASE64URL_ALPHABET =
|
|
43
31
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
44
32
|
|
|
45
33
|
/** Encode raw bytes as unpadded base64url — the one accepted encoding for
|
|
46
|
-
* `
|
|
34
|
+
* `multicast.auth.keys[].publicKey`. */
|
|
47
35
|
export function encodeBase64Url(bytes: Uint8Array): string {
|
|
48
36
|
let output = "";
|
|
49
37
|
for (let i = 0; i < bytes.length; i += 3) {
|
|
@@ -97,18 +85,6 @@ export function decodeBase64Url(text: string): Uint8Array {
|
|
|
97
85
|
return decoded;
|
|
98
86
|
}
|
|
99
87
|
|
|
100
|
-
/** Decode + length-validate an `authScope` field. Throws unless it decodes
|
|
101
|
-
* to exactly `SOURCE_AUTH_SCOPE_LENGTH` (32) raw bytes. */
|
|
102
|
-
export function decodeAuthScope(authScope: string): Uint8Array {
|
|
103
|
-
const bytes = decodeBase64Url(authScope);
|
|
104
|
-
if (bytes.byteLength !== SOURCE_AUTH_SCOPE_LENGTH) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
`[multicast-auth-catalog] authScope must decode to ${SOURCE_AUTH_SCOPE_LENGTH} raw bytes, got ${bytes.byteLength}`,
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
return bytes;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
88
|
/** Decode a catalog key in the only accepted representation: exactly 32 raw
|
|
113
89
|
* ed25519 bytes encoded as canonical, unpadded base64url. */
|
|
114
90
|
export function decodeEd25519PublicKey(publicKey: string): Uint8Array {
|
|
@@ -121,220 +97,137 @@ export function decodeEd25519PublicKey(publicKey: string): Uint8Array {
|
|
|
121
97
|
return bytes;
|
|
122
98
|
}
|
|
123
99
|
|
|
124
|
-
/**
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
* `SourceAuthGroupClose`). Opaque string — not role-parsed.
|
|
131
|
-
* - `authScope`: this track's unique 32-byte scope, raw bytes as unpadded
|
|
132
|
-
* base64url. BLO-16481 requires a scope fresh per (publisher session,
|
|
133
|
-
* track, source-symbol format) — a track publishing under two source-
|
|
134
|
-
* symbol formats in the same session MUST appear as two entries here,
|
|
135
|
-
* each with its own scope.
|
|
136
|
-
* - `sourceSymbolFormat`: names the deployed source-symbol profile this
|
|
137
|
-
* track's authenticated bytes are derived from (e.g.
|
|
138
|
-
* `"full-mmtp-packet"` or `"fec-padded-recovery"`, the two formats
|
|
139
|
-
* BLO-16481's S0 fixture covers).
|
|
140
|
-
*/
|
|
141
|
-
export interface MulticastAuthTrackConfig {
|
|
142
|
-
mediaTrack: string;
|
|
143
|
-
manifestTrack: string;
|
|
144
|
-
authScope: string;
|
|
145
|
-
sourceSymbolFormat: string;
|
|
100
|
+
/** One `multicast.auth.keys[]` entry: `kid` and `firstEpoch` are u32,
|
|
101
|
+
* `publicKey` the 32-octet Ed25519 key in canonical unpadded base64url. */
|
|
102
|
+
export interface MulticastAuthKey {
|
|
103
|
+
kid: number;
|
|
104
|
+
publicKey: string;
|
|
105
|
+
firstEpoch: number;
|
|
146
106
|
}
|
|
147
107
|
|
|
148
|
-
/**
|
|
149
|
-
* `multicast.auth` v2 — supersedes the BLO-16485 draft's singular
|
|
150
|
-
* `manifestTrack`/no-`authScope` shape (BLO-16700 decision).
|
|
151
|
-
*/
|
|
108
|
+
/** `multicast.auth` (7.2.6). `hash_alg` is a record octet, not a member. */
|
|
152
109
|
export interface MulticastAuthConfig {
|
|
153
110
|
scheme: MulticastAuthScheme;
|
|
154
|
-
|
|
111
|
+
version: 2;
|
|
155
112
|
sig: MulticastAuthSig;
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function isValidPublicKeyField(value: unknown): value is string {
|
|
184
|
-
if (!isNonEmptyString(value)) return false;
|
|
185
|
-
try {
|
|
186
|
-
decodeEd25519PublicKey(value);
|
|
187
|
-
return true;
|
|
188
|
-
} catch {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function hasOnlyKeys(object: Record<string, unknown>, allowed: readonly string[]): boolean {
|
|
194
|
-
const allowedKeys = new Set(allowed);
|
|
195
|
-
return Object.keys(object).every((key) => allowedKeys.has(key));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function isMulticastAuthTrackConfig(obj: unknown): obj is MulticastAuthTrackConfig {
|
|
199
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
200
|
-
const o = obj as Record<string, unknown>;
|
|
201
|
-
return (
|
|
202
|
-
hasOnlyKeys(o, ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"]) &&
|
|
203
|
-
isNonEmptyString(o["mediaTrack"]) &&
|
|
204
|
-
isNonEmptyString(o["manifestTrack"]) &&
|
|
205
|
-
o["mediaTrack"] !== o["manifestTrack"] &&
|
|
206
|
-
isValidAuthScopeField(o["authScope"]) &&
|
|
207
|
-
isNonEmptyString(o["sourceSymbolFormat"])
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const VALID_COMPACTION = new Set<string>(["merkle", "none"]);
|
|
212
|
-
const VALID_ENFORCEMENT = new Set<string>(["shadow", "enforce"]);
|
|
213
|
-
|
|
214
|
-
/** Semantic uniqueness rule shared by runtime parsing and the published
|
|
215
|
-
* catalog schema's `uniqueMulticastAuthTrackBindings` keyword. */
|
|
216
|
-
export function hasUniqueMulticastAuthTrackBindings(tracks: readonly unknown[]): boolean {
|
|
217
|
-
const bindings = tracks.flatMap((track) => {
|
|
218
|
-
if (typeof track !== "object" || track === null) return [];
|
|
219
|
-
const value = track as Record<string, unknown>;
|
|
220
|
-
if (typeof value["mediaTrack"] !== "string" || typeof value["sourceSymbolFormat"] !== "string") {
|
|
221
|
-
return [];
|
|
222
|
-
}
|
|
223
|
-
return [JSON.stringify([value["mediaTrack"], value["sourceSymbolFormat"]])];
|
|
224
|
-
});
|
|
225
|
-
return new Set(bindings).size === bindings.length;
|
|
226
|
-
}
|
|
227
|
-
|
|
113
|
+
/** One to four keys; `kid` and `firstEpoch` each distinct. */
|
|
114
|
+
keys: MulticastAuthKey[];
|
|
115
|
+
/** Lowest `epoch` a receiver accepts at join. */
|
|
116
|
+
minEpoch: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** An endpoint's `auth` (7.2.6). A protected endpoint also declares `bandwidth`. */
|
|
120
|
+
export interface EndpointAuthConfig {
|
|
121
|
+
/** Destination port of the record datagrams on the endpoint's `(S, G)`. */
|
|
122
|
+
manifestPort: number;
|
|
123
|
+
/** u32 chosen per channel generation. */
|
|
124
|
+
streamId: number;
|
|
125
|
+
/** `S` of a protected ASM endpoint; never on SSM. */
|
|
126
|
+
senderAddress?: string;
|
|
127
|
+
/** 50..1000, default 200. */
|
|
128
|
+
maxAuthDelayMs?: number;
|
|
129
|
+
/** At least 1, default 20. */
|
|
130
|
+
manifestTimerMs?: number;
|
|
131
|
+
/** MoQ track mirroring the records. */
|
|
132
|
+
manifestTrack?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Structural check of a `multicast.auth` block, duplicate `kid` and
|
|
136
|
+
* `firstEpoch` included. */
|
|
228
137
|
export function isMulticastAuthConfig(obj: unknown): obj is MulticastAuthConfig {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (!tracks.every((t) => isMulticastAuthTrackConfig(t))) return false;
|
|
248
|
-
const typedTracks = tracks as MulticastAuthTrackConfig[];
|
|
249
|
-
|
|
250
|
-
// BLO-16481: a fresh scope per track — catalog-declared scopes must be
|
|
251
|
-
// pairwise distinct within one auth block.
|
|
252
|
-
const scopes = typedTracks.map((t) => t.authScope);
|
|
253
|
-
if (new Set(scopes).size !== scopes.length) return false;
|
|
254
|
-
if (!hasUniqueMulticastAuthTrackBindings(typedTracks)) return false;
|
|
255
|
-
|
|
256
|
-
// Each entry must point at its own manifest track.
|
|
257
|
-
const manifestTracks = typedTracks.map((t) => t.manifestTrack);
|
|
258
|
-
if (new Set(manifestTracks).size !== manifestTracks.length) return false;
|
|
259
|
-
|
|
260
|
-
return true;
|
|
138
|
+
return multicastCatalogIssues({ multicast: { auth: obj } }).length === 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A protected flow as a receiver binds it: one per protected endpoint. */
|
|
142
|
+
export interface ResolvedMulticastAuthFlow {
|
|
143
|
+
/** Index of the endpoint in `multicast.endpoints`. */
|
|
144
|
+
endpointIndex: number;
|
|
145
|
+
/** `S`: `sourceAddress` on SSM, `auth.senderAddress` on ASM. */
|
|
146
|
+
source: string;
|
|
147
|
+
groupAddress: string;
|
|
148
|
+
port: number;
|
|
149
|
+
bandwidth: number;
|
|
150
|
+
manifestPort: number;
|
|
151
|
+
streamId: number;
|
|
152
|
+
maxAuthDelayMs: number;
|
|
153
|
+
manifestTimerMs: number;
|
|
154
|
+
manifestTrack?: string;
|
|
155
|
+
tracks: Array<{ name: string; packetId: number }>;
|
|
261
156
|
}
|
|
262
157
|
|
|
263
158
|
export interface ResolvedMulticastAuthConfig {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
compaction: MulticastAuthCompaction;
|
|
269
|
-
tracks: Array<Omit<MulticastAuthTrackConfig, "authScope"> & { authScope: Uint8Array }>;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/** Player configuration is authoritative, including an explicit `off`.
|
|
273
|
-
* Catalog enforcement is only a default; an auth block without it defaults
|
|
274
|
-
* to shadow, while a catalog without auth defaults to off. */
|
|
275
|
-
export function resolveMulticastAuthMode(
|
|
276
|
-
playerMode: MulticastAuthMode | undefined,
|
|
277
|
-
auth: MulticastAuthConfig | undefined,
|
|
278
|
-
): MulticastAuthMode {
|
|
279
|
-
if (playerMode !== undefined) return playerMode;
|
|
280
|
-
if (auth === undefined) return "off";
|
|
281
|
-
return auth.enforcement ?? "shadow";
|
|
159
|
+
/** Decoded keys, ascending by `firstEpoch`. */
|
|
160
|
+
keys: ManifestKey[];
|
|
161
|
+
minEpoch: number;
|
|
162
|
+
flows: ResolvedMulticastAuthFlow[];
|
|
282
163
|
}
|
|
283
164
|
|
|
284
|
-
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
165
|
+
/**
|
|
166
|
+
* Resolve `multicast.auth` and every protected endpoint into decoded keys and
|
|
167
|
+
* per-endpoint flows. Returns `undefined` for an unprotected catalog unless
|
|
168
|
+
* `requireAuth` pins authentication (7.2.7), which then throws.
|
|
169
|
+
*
|
|
170
|
+
* A catalog-level fault (no key set: a malformed block, a repeated `kid` or
|
|
171
|
+
* `firstEpoch`, the retired root key) throws, so nothing is admitted and
|
|
172
|
+
* nothing falls back to unauthenticated reception. An endpoint the rules make
|
|
173
|
+
* a receiver ignore yields no flow; the others still bind.
|
|
174
|
+
*/
|
|
287
175
|
export function resolveMulticastAuthCatalog(
|
|
288
176
|
catalog: unknown,
|
|
289
|
-
|
|
177
|
+
options: { requireAuth?: boolean; catalogNamespace?: string } = {},
|
|
290
178
|
): ResolvedMulticastAuthConfig | undefined {
|
|
291
179
|
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) {
|
|
292
180
|
throw new Error("[multicast-auth-catalog] catalog must be an object");
|
|
293
181
|
}
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
182
|
+
const issues = multicastCatalogIssues(catalog, options);
|
|
183
|
+
const fatal = issues.find((issue) => issue.endpointIndex === undefined);
|
|
184
|
+
if (fatal) throw new Error(`[multicast-auth-catalog] ${fatal.path}: ${fatal.message}`);
|
|
185
|
+
const multicast = (catalog as Record<string, unknown>)["multicast"] as Record<string, unknown> | undefined;
|
|
186
|
+
const auth = multicast?.["auth"] as MulticastAuthConfig | undefined;
|
|
187
|
+
if (auth === undefined) {
|
|
188
|
+
if (options.requireAuth) {
|
|
189
|
+
throw new Error("[multicast-auth-catalog] authentication is pinned but the catalog declares no multicast.auth");
|
|
299
190
|
}
|
|
300
191
|
return undefined;
|
|
301
192
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
193
|
+
const ignored = new Set(issues.map((issue) => issue.endpointIndex));
|
|
194
|
+
const endpoints = (multicast!["endpoints"] ?? []) as Array<Record<string, unknown>>;
|
|
195
|
+
const flows: ResolvedMulticastAuthFlow[] = [];
|
|
196
|
+
endpoints.forEach((endpoint, endpointIndex) => {
|
|
197
|
+
if (ignored.has(endpointIndex)) return;
|
|
198
|
+
const flowAuth = endpoint["auth"] as EndpointAuthConfig;
|
|
199
|
+
flows.push({
|
|
200
|
+
endpointIndex,
|
|
201
|
+
source: (endpoint["sourceAddress"] ?? flowAuth.senderAddress) as string,
|
|
202
|
+
groupAddress: endpoint["groupAddress"] as string,
|
|
203
|
+
port: endpoint["port"] as number,
|
|
204
|
+
bandwidth: endpoint["bandwidth"] as number,
|
|
205
|
+
manifestPort: flowAuth.manifestPort,
|
|
206
|
+
streamId: flowAuth.streamId,
|
|
207
|
+
maxAuthDelayMs: flowAuth.maxAuthDelayMs ?? DEFAULT_MAX_AUTH_DELAY_MS,
|
|
208
|
+
manifestTimerMs: flowAuth.manifestTimerMs ?? DEFAULT_MANIFEST_TIMER_MS,
|
|
209
|
+
...(flowAuth.manifestTrack === undefined ? {} : { manifestTrack: flowAuth.manifestTrack }),
|
|
210
|
+
tracks: ((endpoint["tracks"] ?? []) as Array<{ name: string; packetId: number }>).map(({ name, packetId }) => ({
|
|
211
|
+
name,
|
|
212
|
+
packetId,
|
|
213
|
+
})),
|
|
214
|
+
});
|
|
215
|
+
});
|
|
327
216
|
return {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
mode: resolveMulticastAuthMode(playerMode, rawAuth),
|
|
334
|
-
compaction: rawAuth.compaction,
|
|
335
|
-
tracks: rawAuth.tracks.map((track) => ({
|
|
336
|
-
...track,
|
|
337
|
-
authScope: decodeAuthScope(track.authScope),
|
|
338
|
-
})),
|
|
217
|
+
keys: auth.keys
|
|
218
|
+
.map((key) => ({ kid: key.kid, publicKey: decodeEd25519PublicKey(key.publicKey), firstEpoch: key.firstEpoch }))
|
|
219
|
+
.sort((a, b) => a.firstEpoch - b.firstEpoch),
|
|
220
|
+
minEpoch: auth.minEpoch,
|
|
221
|
+
flows,
|
|
339
222
|
};
|
|
340
223
|
}
|
|
224
|
+
|
|
225
|
+
/** The key that signs a record of `kid` at `epoch`, or `undefined` when that
|
|
226
|
+
* `kid` does not sign it (7.2.7: such a record is dropped before verification). */
|
|
227
|
+
export function multicastAuthKeyFor(
|
|
228
|
+
resolved: ResolvedMulticastAuthConfig,
|
|
229
|
+
kid: number,
|
|
230
|
+
epoch: number,
|
|
231
|
+
): Uint8Array | undefined {
|
|
232
|
+
return manifestKeyFor(resolved.keys, epoch, kid);
|
|
233
|
+
}
|