@blockcast/mmt-container 0.1.0-main.c71423b8a4e4 → 0.1.0-main.ce3c8aeb7f68
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/dist/align.d.ts +6 -2
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js.map +2 -2
- package/dist/audio-ring-buffer.js +23 -36
- package/dist/audio-ring-buffer.js.map +1 -1
- package/dist/browser-runtime.js +6865 -6485
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +3 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +21 -2
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.js +10 -0
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/cmaf-block-assembler.d.ts +42 -0
- package/dist/cmaf-block-assembler.d.ts.map +1 -1
- package/dist/cmaf-block-assembler.js +542 -535
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/cmaf-group-batcher.js +27 -46
- package/dist/cmaf-group-batcher.js.map +2 -2
- package/dist/cmcd-producer.js +45 -66
- package/dist/cmcd-producer.js.map +1 -1
- package/dist/fec-manager.d.ts +13 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +1151 -871
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-starvation-detector.js +25 -40
- package/dist/fec-starvation-detector.js.map +1 -1
- package/dist/fec-worker-setup.js +242 -225
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-bmff-timing.js +63 -88
- package/dist/iso-bmff-timing.js.map +1 -1
- package/dist/loc.js +7 -4
- package/dist/loc.js.map +1 -1
- package/dist/manifest-auth-plan.js +292 -311
- package/dist/manifest-auth-plan.js.map +1 -1
- package/dist/media-router.d.ts +0 -99
- package/dist/media-router.d.ts.map +1 -1
- package/dist/media-router.js +270 -504
- package/dist/media-router.js.map +3 -3
- package/dist/mfu-reassembler.js +597 -607
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +37 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +1531 -1522
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +179 -102
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +1641 -1651
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +34 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +3676 -3390
- package/dist/mmtp-router.js.map +3 -3
- package/dist/mmtp-to-cmaf.d.ts +7 -1
- package/dist/mmtp-to-cmaf.d.ts.map +1 -1
- package/dist/mmtp-to-cmaf.js +109 -134
- package/dist/mmtp-to-cmaf.js.map +2 -2
- package/dist/multicast-input.d.ts +7 -35
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +21 -2
- package/dist/multicast-input.js.map +4 -4
- package/dist/multicast-manager.d.ts +10 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +5584 -4961
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +7 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +369 -421
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +53 -30
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.js +2096 -2097
- package/dist/no-modules.js.map +3 -3
- package/dist/sample-combiner.js +118 -139
- package/dist/sample-combiner.js.map +1 -1
- package/dist/signaling.js.map +2 -2
- package/dist/source-auth.js +353 -382
- package/dist/source-auth.js.map +1 -1
- package/dist/switching-set-alignment.js +14 -29
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +17 -11
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/track-pipeline-setup.js +105 -125
- package/dist/track-pipeline-setup.js.map +1 -1
- package/dist/track-pipeline.js +107 -127
- package/dist/track-pipeline.js.map +1 -1
- package/dist/track-session.d.ts +16 -0
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +230 -243
- package/dist/track-session.js.map +2 -2
- package/dist/transport-pool.js +24 -38
- package/dist/transport-pool.js.map +1 -1
- package/dist/wasm-mfu-reassembler.d.ts +6 -1
- package/dist/wasm-mfu-reassembler.d.ts.map +1 -1
- package/dist/wasm-mfu-reassembler.js +127 -144
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +1659 -1650
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/node_modules/@blockcast/fec-worker/README.md +5 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +8 -2
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +89 -16
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +48 -3
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +55 -8
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +2 -2
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts +1 -1
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -1
- package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -1
- package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +97 -17
- package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +46 -2
- package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +78 -10
- package/node_modules/@blockcast/fec-worker/src/index.ts +2 -0
- package/node_modules/@blockcast/mmt-base/README.md +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
- package/package.json +7 -6
- package/schemas/catalog.schema.json +1 -1
- package/src/align.ts +6 -2
- package/src/carp-catalog.ts +13 -3
- package/src/cmaf-block-assembler.ts +90 -81
- package/src/fec-manager.ts +530 -146
- package/src/index.ts +2 -2
- package/src/media-router.ts +0 -397
- package/src/mmtp-container-parser.ts +97 -21
- package/src/mmtp-router.ts +302 -125
- package/src/mmtp-to-cmaf.ts +21 -7
- package/src/multicast-input.ts +23 -3
- package/src/multicast-manager.ts +83 -11
- package/src/multicast-transport.ts +56 -17
- package/src/track-session.ts +16 -0
- package/src/wasm-mfu-reassembler.ts +40 -24
- package/test-vectors/catalog/README.md +2 -0
- package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
- package/test-vectors/catalog-validation.json +11 -0
package/dist/source-auth.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
|
|
10
1
|
// ../mmt-manifest-verify/node_modules/@noble/hashes/esm/utils.js
|
|
11
2
|
function isBytes(a) {
|
|
12
3
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
@@ -617,35 +608,33 @@ function equalBytes(left, right) {
|
|
|
617
608
|
return false;
|
|
618
609
|
return left.every((value, index) => value === right[index]);
|
|
619
610
|
}
|
|
620
|
-
var _manifestAuthenticated, _entries, _pendingObjects, _entriesAwaitingObjects, _admissions, _groupId, _closed, _SourceAuthAdmission_instances, requireGroup_fn, verifyObject_fn;
|
|
621
611
|
var SourceAuthAdmission = class {
|
|
612
|
+
#manifestAuthenticated;
|
|
613
|
+
#entries = /* @__PURE__ */ new Map();
|
|
614
|
+
#pendingObjects = /* @__PURE__ */ new Map();
|
|
615
|
+
#entriesAwaitingObjects = /* @__PURE__ */ new Set();
|
|
616
|
+
#admissions = /* @__PURE__ */ new Map();
|
|
617
|
+
#groupId = null;
|
|
618
|
+
#closed = false;
|
|
622
619
|
constructor(options) {
|
|
623
|
-
|
|
624
|
-
__privateAdd(this, _manifestAuthenticated);
|
|
625
|
-
__privateAdd(this, _entries, /* @__PURE__ */ new Map());
|
|
626
|
-
__privateAdd(this, _pendingObjects, /* @__PURE__ */ new Map());
|
|
627
|
-
__privateAdd(this, _entriesAwaitingObjects, /* @__PURE__ */ new Set());
|
|
628
|
-
__privateAdd(this, _admissions, /* @__PURE__ */ new Map());
|
|
629
|
-
__privateAdd(this, _groupId, null);
|
|
630
|
-
__privateAdd(this, _closed, false);
|
|
631
|
-
__privateSet(this, _manifestAuthenticated, options.manifestAuthenticated);
|
|
620
|
+
this.#manifestAuthenticated = options.manifestAuthenticated;
|
|
632
621
|
}
|
|
633
622
|
admitObject(input) {
|
|
634
|
-
|
|
635
|
-
if (
|
|
623
|
+
this.#requireGroup(input.groupId);
|
|
624
|
+
if (this.#closed)
|
|
636
625
|
throw new Error("source-auth group is already closed");
|
|
637
|
-
if (
|
|
626
|
+
if (this.#admissions.has(input.objectId) || this.#pendingObjects.has(input.objectId)) {
|
|
638
627
|
throw new Error(`duplicate source-auth object ${input.objectId}`);
|
|
639
628
|
}
|
|
640
|
-
const entry =
|
|
629
|
+
const entry = this.#entries.get(input.objectId);
|
|
641
630
|
if (entry) {
|
|
642
|
-
|
|
643
|
-
return
|
|
631
|
+
this.#entriesAwaitingObjects.delete(input.objectId);
|
|
632
|
+
return this.#verifyObject(entry, input.bytes, input.recovered ?? false);
|
|
644
633
|
}
|
|
645
|
-
if (
|
|
634
|
+
if (this.#pendingObjects.size >= 1) {
|
|
646
635
|
throw new Error("source-auth media exceeds one-object manifest skew");
|
|
647
636
|
}
|
|
648
|
-
|
|
637
|
+
this.#pendingObjects.set(input.objectId, {
|
|
649
638
|
bytes: input.bytes,
|
|
650
639
|
recovered: input.recovered ?? false
|
|
651
640
|
});
|
|
@@ -657,86 +646,78 @@ var SourceAuthAdmission = class {
|
|
|
657
646
|
};
|
|
658
647
|
}
|
|
659
648
|
admitEntry(entry) {
|
|
660
|
-
|
|
661
|
-
if (
|
|
649
|
+
this.#requireGroup(entry.groupId);
|
|
650
|
+
if (this.#closed)
|
|
662
651
|
throw new Error("source-auth group is already closed");
|
|
663
|
-
if (
|
|
652
|
+
if (this.#entries.has(entry.objectId)) {
|
|
664
653
|
throw new Error(`duplicate source-auth manifest entry ${entry.objectId}`);
|
|
665
654
|
}
|
|
666
|
-
const pending =
|
|
667
|
-
if (!pending &&
|
|
655
|
+
const pending = this.#pendingObjects.get(entry.objectId);
|
|
656
|
+
if (!pending && this.#entriesAwaitingObjects.size >= 1) {
|
|
668
657
|
throw new Error("source-auth manifest exceeds one-object media skew");
|
|
669
658
|
}
|
|
670
|
-
|
|
659
|
+
this.#entries.set(entry.objectId, entry);
|
|
671
660
|
if (!pending) {
|
|
672
|
-
|
|
661
|
+
this.#entriesAwaitingObjects.add(entry.objectId);
|
|
673
662
|
return "pending-object";
|
|
674
663
|
}
|
|
675
|
-
|
|
676
|
-
return
|
|
664
|
+
this.#pendingObjects.delete(entry.objectId);
|
|
665
|
+
return this.#verifyObject(entry, pending.bytes, pending.recovered);
|
|
677
666
|
}
|
|
678
667
|
objectState(objectId) {
|
|
679
|
-
if (
|
|
668
|
+
if (this.#pendingObjects.has(objectId))
|
|
680
669
|
return "pending-entry";
|
|
681
|
-
if (
|
|
670
|
+
if (this.#entriesAwaitingObjects.has(objectId))
|
|
682
671
|
return "pending-object";
|
|
683
|
-
if (
|
|
672
|
+
if (this.#closed && this.#admissions.has(objectId))
|
|
684
673
|
return "authenticated";
|
|
685
|
-
return
|
|
674
|
+
return this.#admissions.get(objectId)?.state;
|
|
686
675
|
}
|
|
687
676
|
async verifyClose(close, authScope, publicKey, subtle = globalThis.crypto.subtle) {
|
|
688
|
-
|
|
689
|
-
if (
|
|
677
|
+
this.#requireGroup(close.groupId);
|
|
678
|
+
if (this.#closed)
|
|
690
679
|
throw new Error("source-auth group is already closed");
|
|
691
|
-
if (
|
|
680
|
+
if (this.#pendingObjects.size !== 0 || this.#entriesAwaitingObjects.size !== 0) {
|
|
692
681
|
throw new Error("source-auth group closed with unmatched objects or entries");
|
|
693
682
|
}
|
|
694
|
-
if (close.objectCount !==
|
|
683
|
+
if (close.objectCount !== this.#entries.size || this.#admissions.size !== this.#entries.size) {
|
|
695
684
|
throw new Error("source-auth group close object count mismatch");
|
|
696
685
|
}
|
|
697
|
-
const root = sourceAuthMerkleRoot([...
|
|
686
|
+
const root = sourceAuthMerkleRoot([...this.#entries.values()]);
|
|
698
687
|
if (!equalBytes(root, close.root))
|
|
699
688
|
throw new Error("source-auth group root mismatch");
|
|
700
689
|
const verified = await subtle.verify("Ed25519", publicKey, new Uint8Array(close.signature).buffer, new Uint8Array(sourceAuthSignaturePreimage(authScope, close.groupId, close.objectCount, root)).buffer);
|
|
701
690
|
if (!verified)
|
|
702
691
|
throw new Error("source-auth group close signature failed");
|
|
703
|
-
for (const admission of
|
|
692
|
+
for (const admission of this.#admissions.values())
|
|
704
693
|
admission.state = "authenticated";
|
|
705
|
-
|
|
694
|
+
this.#closed = true;
|
|
695
|
+
}
|
|
696
|
+
#requireGroup(groupId) {
|
|
697
|
+
requireU642("groupId", groupId);
|
|
698
|
+
if (this.#groupId === null)
|
|
699
|
+
this.#groupId = groupId;
|
|
700
|
+
else if (this.#groupId !== groupId)
|
|
701
|
+
throw new Error("source-auth group identity mismatch");
|
|
702
|
+
}
|
|
703
|
+
#verifyObject(entry, bytes, recovered) {
|
|
704
|
+
const authenticated = recovered ? trimRecoveredSourceAuthObject(bytes, entry.trueLength) : bytes;
|
|
705
|
+
if (!recovered && bytes.byteLength !== entry.trueLength) {
|
|
706
|
+
throw new Error(`direct source-auth object length mismatch for ${entry.objectId}`);
|
|
707
|
+
}
|
|
708
|
+
if (!equalBytes(sourceAuthObjectDigest(authenticated), entry.digest)) {
|
|
709
|
+
throw new Error(`source-auth object digest mismatch for ${entry.objectId}`);
|
|
710
|
+
}
|
|
711
|
+
const admission = {
|
|
712
|
+
groupId: entry.groupId,
|
|
713
|
+
objectId: entry.objectId,
|
|
714
|
+
recovered,
|
|
715
|
+
state: this.#manifestAuthenticated ? "authenticated" : "provisional"
|
|
716
|
+
};
|
|
717
|
+
this.#admissions.set(entry.objectId, admission);
|
|
718
|
+
return admission;
|
|
706
719
|
}
|
|
707
720
|
};
|
|
708
|
-
_manifestAuthenticated = new WeakMap();
|
|
709
|
-
_entries = new WeakMap();
|
|
710
|
-
_pendingObjects = new WeakMap();
|
|
711
|
-
_entriesAwaitingObjects = new WeakMap();
|
|
712
|
-
_admissions = new WeakMap();
|
|
713
|
-
_groupId = new WeakMap();
|
|
714
|
-
_closed = new WeakMap();
|
|
715
|
-
_SourceAuthAdmission_instances = new WeakSet();
|
|
716
|
-
requireGroup_fn = function(groupId) {
|
|
717
|
-
requireU642("groupId", groupId);
|
|
718
|
-
if (__privateGet(this, _groupId) === null)
|
|
719
|
-
__privateSet(this, _groupId, groupId);
|
|
720
|
-
else if (__privateGet(this, _groupId) !== groupId)
|
|
721
|
-
throw new Error("source-auth group identity mismatch");
|
|
722
|
-
};
|
|
723
|
-
verifyObject_fn = function(entry, bytes, recovered) {
|
|
724
|
-
const authenticated = recovered ? trimRecoveredSourceAuthObject(bytes, entry.trueLength) : bytes;
|
|
725
|
-
if (!recovered && bytes.byteLength !== entry.trueLength) {
|
|
726
|
-
throw new Error(`direct source-auth object length mismatch for ${entry.objectId}`);
|
|
727
|
-
}
|
|
728
|
-
if (!equalBytes(sourceAuthObjectDigest(authenticated), entry.digest)) {
|
|
729
|
-
throw new Error(`source-auth object digest mismatch for ${entry.objectId}`);
|
|
730
|
-
}
|
|
731
|
-
const admission = {
|
|
732
|
-
groupId: entry.groupId,
|
|
733
|
-
objectId: entry.objectId,
|
|
734
|
-
recovered,
|
|
735
|
-
state: __privateGet(this, _manifestAuthenticated) ? "authenticated" : "provisional"
|
|
736
|
-
};
|
|
737
|
-
__privateGet(this, _admissions).set(entry.objectId, admission);
|
|
738
|
-
return admission;
|
|
739
|
-
};
|
|
740
721
|
|
|
741
722
|
// ../mmt-manifest-verify/dist/verifier.js
|
|
742
723
|
function manifestBindingId(trackName, sourceSymbolFormat) {
|
|
@@ -767,46 +748,44 @@ var equalBytes2 = (left, right) => {
|
|
|
767
748
|
return diff === 0;
|
|
768
749
|
};
|
|
769
750
|
var isPromiseLike = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
|
|
770
|
-
var _config, _verifySignature, _onFailure, _tracks, _stats, _disposed, _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;
|
|
771
751
|
var ManifestVerifier = class {
|
|
752
|
+
#config;
|
|
753
|
+
#verifySignature;
|
|
754
|
+
#onFailure;
|
|
755
|
+
#tracks = /* @__PURE__ */ new Map();
|
|
756
|
+
#stats = {
|
|
757
|
+
verified: 0,
|
|
758
|
+
failures: Object.fromEntries(FAILURE_REASONS.map((reason) => [reason, 0])),
|
|
759
|
+
quarantinedBytes: 0
|
|
760
|
+
};
|
|
761
|
+
#disposed = false;
|
|
772
762
|
constructor(options) {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
__privateAdd(this, _onFailure);
|
|
777
|
-
__privateAdd(this, _tracks, /* @__PURE__ */ new Map());
|
|
778
|
-
__privateAdd(this, _stats, {
|
|
779
|
-
verified: 0,
|
|
780
|
-
failures: Object.fromEntries(FAILURE_REASONS.map((reason) => [reason, 0])),
|
|
781
|
-
quarantinedBytes: 0
|
|
782
|
-
});
|
|
783
|
-
__privateAdd(this, _disposed, false);
|
|
784
|
-
__privateSet(this, _config, { ...options.manifestAuth });
|
|
785
|
-
__privateSet(this, _verifySignature, options.verifySignature);
|
|
786
|
-
__privateSet(this, _onFailure, options.onFailure);
|
|
763
|
+
this.#config = { ...options.manifestAuth };
|
|
764
|
+
this.#verifySignature = options.verifySignature;
|
|
765
|
+
this.#onFailure = options.onFailure;
|
|
787
766
|
}
|
|
788
767
|
get config() {
|
|
789
|
-
return
|
|
768
|
+
return this.#config;
|
|
790
769
|
}
|
|
791
770
|
get stats() {
|
|
792
771
|
let quarantined = 0;
|
|
793
|
-
for (const track of
|
|
772
|
+
for (const track of this.#tracks.values())
|
|
794
773
|
quarantined += track.quarantine.length;
|
|
795
774
|
return {
|
|
796
|
-
verified:
|
|
797
|
-
failures: { ...
|
|
775
|
+
verified: this.#stats.verified,
|
|
776
|
+
failures: { ...this.#stats.failures },
|
|
798
777
|
quarantined,
|
|
799
|
-
quarantinedBytes:
|
|
778
|
+
quarantinedBytes: this.#stats.quarantinedBytes
|
|
800
779
|
};
|
|
801
780
|
}
|
|
802
781
|
setMode(mode) {
|
|
803
|
-
|
|
782
|
+
this.#config = { ...this.#config, mode };
|
|
804
783
|
if (mode !== "enforce")
|
|
805
|
-
|
|
784
|
+
this.#releaseAllQuarantine(false);
|
|
806
785
|
}
|
|
807
786
|
registerTrack(context) {
|
|
808
787
|
const bindingId = context.bindingId ?? context.trackName;
|
|
809
|
-
if (
|
|
788
|
+
if (this.#tracks.has(bindingId)) {
|
|
810
789
|
throw new Error(`manifest binding ${bindingId} is already registered`);
|
|
811
790
|
}
|
|
812
791
|
if (!Number.isFinite(context.bitrate) || context.bitrate <= 0) {
|
|
@@ -833,7 +812,7 @@ var ManifestVerifier = class {
|
|
|
833
812
|
if (value.length === 0)
|
|
834
813
|
throw new Error(`manifest ${name} must not be empty`);
|
|
835
814
|
}
|
|
836
|
-
|
|
815
|
+
this.#tracks.set(bindingId, {
|
|
837
816
|
context: { ...context, bindingId },
|
|
838
817
|
groups: /* @__PURE__ */ new Map(),
|
|
839
818
|
quarantine: [],
|
|
@@ -845,368 +824,360 @@ var ManifestVerifier = class {
|
|
|
845
824
|
});
|
|
846
825
|
}
|
|
847
826
|
ingestManifestFrame(bindingId, frameBytes) {
|
|
848
|
-
const track =
|
|
827
|
+
const track = this.#requireTrack(bindingId);
|
|
849
828
|
try {
|
|
850
829
|
const frame = decodeSourceAuthManifestFrame(frameBytes);
|
|
851
830
|
const groupId = frame.groupId;
|
|
852
|
-
const group =
|
|
831
|
+
const group = this.#group(track, groupId);
|
|
853
832
|
if (frame.kind === "object") {
|
|
854
833
|
if (group.close || group.signaturePending || group.failed) {
|
|
855
|
-
|
|
834
|
+
this.#failure({ trackName: track.context.trackName, bindingId, groupId, objectId: frame.objectId }, "verifierError");
|
|
856
835
|
return;
|
|
857
836
|
}
|
|
858
837
|
if (group.entries.has(frame.objectId)) {
|
|
859
|
-
|
|
838
|
+
this.#failure({ trackName: track.context.trackName, bindingId, groupId, objectId: frame.objectId }, "verifierError");
|
|
860
839
|
return;
|
|
861
840
|
}
|
|
862
841
|
if (group.entries.size >= 4096 || track.manifestEntries >= track.maxManifestEntries) {
|
|
863
|
-
|
|
842
|
+
this.#failure({ trackName: track.context.trackName, bindingId, groupId, objectId: frame.objectId }, "verifierError");
|
|
864
843
|
return;
|
|
865
844
|
}
|
|
866
845
|
group.entries.set(frame.objectId, frame);
|
|
867
846
|
track.manifestEntries++;
|
|
868
847
|
const pending = group.pending.get(frame.objectId);
|
|
869
848
|
if (pending) {
|
|
870
|
-
|
|
871
|
-
|
|
849
|
+
this.#failure(pending.identity, "manifestLate");
|
|
850
|
+
this.#resolvePending(track, group, pending, frame);
|
|
872
851
|
}
|
|
873
852
|
if (group.pendingClose && group.entries.size === group.pendingClose.objectCount) {
|
|
874
853
|
const close = group.pendingClose;
|
|
875
854
|
group.pendingClose = void 0;
|
|
876
|
-
|
|
855
|
+
this.#closeGroup(track, groupId, group, close);
|
|
877
856
|
}
|
|
878
857
|
return;
|
|
879
858
|
}
|
|
880
|
-
|
|
859
|
+
this.#closeGroup(track, groupId, group, frame);
|
|
881
860
|
} catch {
|
|
882
|
-
|
|
861
|
+
this.#failure({ trackName: track.context.trackName, bindingId, groupId: 0, objectId: 0 }, "verifierError");
|
|
883
862
|
}
|
|
884
863
|
}
|
|
885
864
|
admitObject(identity, data, release, discard) {
|
|
886
|
-
if (
|
|
865
|
+
if (this.#config.mode === "off") {
|
|
887
866
|
release();
|
|
888
867
|
return { action: "play", verified: false };
|
|
889
868
|
}
|
|
890
|
-
const track =
|
|
869
|
+
const track = this.#tracks.get(identity.bindingId ?? identity.trackName);
|
|
891
870
|
if (!track) {
|
|
892
871
|
release();
|
|
893
|
-
|
|
872
|
+
this.#failure(identity, "verifierError");
|
|
894
873
|
return { action: "play", verified: false, reason: "verifierError" };
|
|
895
874
|
}
|
|
896
875
|
try {
|
|
897
|
-
if (!
|
|
898
|
-
return
|
|
876
|
+
if (!this.#validateIdentity(track, identity)) {
|
|
877
|
+
return this.#rejectOrShadow(identity, release, "digestMismatch");
|
|
899
878
|
}
|
|
900
|
-
const group =
|
|
879
|
+
const group = this.#group(track, BigInt(identity.groupId));
|
|
901
880
|
if (group.failed === "sigInvalid" || group.failed === "digestMismatch") {
|
|
902
|
-
return
|
|
881
|
+
return this.#rejectOrShadow(identity, release, group.failed);
|
|
903
882
|
}
|
|
904
883
|
const entry = group.entries.get(identity.objectId);
|
|
905
884
|
if (entry)
|
|
906
|
-
return
|
|
907
|
-
if (
|
|
885
|
+
return this.#admitAgainstEntry(track, group, identity, data, release, entry, discard);
|
|
886
|
+
if (this.#config.mode === "shadow" || this.#config.onMissingManifest === "fallback-shadow") {
|
|
908
887
|
release();
|
|
909
|
-
|
|
888
|
+
this.#failure(identity, "manifestAbsent");
|
|
910
889
|
return { action: "play", verified: false, reason: "manifestAbsent" };
|
|
911
890
|
}
|
|
912
|
-
if (!
|
|
891
|
+
if (!this.#quarantine(track, group, { identity, data, release, discard, bytes: data.byteLength })) {
|
|
913
892
|
return { action: "drop", verified: false };
|
|
914
893
|
}
|
|
915
894
|
return { action: "stall", verified: false };
|
|
916
895
|
} catch {
|
|
917
896
|
release();
|
|
918
|
-
|
|
897
|
+
this.#failure(identity, "verifierError");
|
|
919
898
|
return { action: "play", verified: false, reason: "verifierError" };
|
|
920
899
|
}
|
|
921
900
|
}
|
|
922
901
|
dispose() {
|
|
923
|
-
if (
|
|
902
|
+
if (this.#disposed)
|
|
924
903
|
return;
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
const [oldestId, oldestGroup] = oldest;
|
|
953
|
-
for (const pending of [...oldestGroup.pending.values()]) {
|
|
954
|
-
__privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, oldestGroup, pending);
|
|
955
|
-
__privateMethod(this, _ManifestVerifier_instances, giveUpOnPending_fn).call(this, pending);
|
|
956
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestAbsent");
|
|
904
|
+
this.#disposed = true;
|
|
905
|
+
this.#releaseAllQuarantine(false);
|
|
906
|
+
this.#tracks.clear();
|
|
907
|
+
}
|
|
908
|
+
#requireTrack(bindingId) {
|
|
909
|
+
const track = this.#tracks.get(bindingId);
|
|
910
|
+
if (!track)
|
|
911
|
+
throw new Error(`unknown manifest binding ${bindingId}`);
|
|
912
|
+
return track;
|
|
913
|
+
}
|
|
914
|
+
#group(track, groupId) {
|
|
915
|
+
let group = track.groups.get(groupId);
|
|
916
|
+
if (!group) {
|
|
917
|
+
group = { entries: /* @__PURE__ */ new Map(), pending: /* @__PURE__ */ new Map(), rootVerified: false };
|
|
918
|
+
track.groups.set(groupId, group);
|
|
919
|
+
while (track.groups.size > track.maxGroups) {
|
|
920
|
+
const oldest = track.groups.entries().next().value;
|
|
921
|
+
if (!oldest)
|
|
922
|
+
break;
|
|
923
|
+
const [oldestId, oldestGroup] = oldest;
|
|
924
|
+
for (const pending of [...oldestGroup.pending.values()]) {
|
|
925
|
+
this.#removePending(track, oldestGroup, pending);
|
|
926
|
+
this.#giveUpOnPending(pending);
|
|
927
|
+
this.#failure(pending.identity, "manifestAbsent");
|
|
928
|
+
}
|
|
929
|
+
track.manifestEntries -= oldestGroup.entries.size;
|
|
930
|
+
track.groups.delete(oldestId);
|
|
957
931
|
}
|
|
958
|
-
track.manifestEntries -= oldestGroup.entries.size;
|
|
959
|
-
track.groups.delete(oldestId);
|
|
960
932
|
}
|
|
933
|
+
return group;
|
|
961
934
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
935
|
+
#validateIdentity(track, identity) {
|
|
936
|
+
const coordinates = track.context.mapper.derive(Number(identity.groupId), identity.objectId);
|
|
937
|
+
return identity.ssId === void 0 || coordinates.ssId === identity.ssId;
|
|
938
|
+
}
|
|
939
|
+
#admitAgainstEntry(track, group, identity, data, release, entry, discard) {
|
|
940
|
+
if (entry.trueLength !== data.byteLength) {
|
|
941
|
+
return this.#rejectOrShadow(identity, release, "digestMismatch");
|
|
942
|
+
}
|
|
943
|
+
const digestMatches = equalBytes2(sourceAuthObjectDigest(data.subarray(0, entry.trueLength)), entry.digest);
|
|
944
|
+
if (!digestMatches)
|
|
945
|
+
return this.#rejectOrShadow(identity, release, "digestMismatch");
|
|
946
|
+
if (!track.context.manifestChannelAuthenticated && !group.rootVerified) {
|
|
947
|
+
if (this.#config.mode === "shadow") {
|
|
948
|
+
release();
|
|
949
|
+
return { action: "play", verified: false };
|
|
950
|
+
}
|
|
951
|
+
if (!this.#quarantine(track, group, { identity, data, release, discard, bytes: data.byteLength })) {
|
|
952
|
+
return { action: "drop", verified: false };
|
|
953
|
+
}
|
|
954
|
+
return { action: "stall", verified: false };
|
|
979
955
|
}
|
|
980
|
-
|
|
981
|
-
|
|
956
|
+
release();
|
|
957
|
+
this.#stats.verified++;
|
|
958
|
+
return { action: "play", verified: true };
|
|
959
|
+
}
|
|
960
|
+
#rejectOrShadow(identity, release, reason) {
|
|
961
|
+
this.#failure(identity, reason);
|
|
962
|
+
if (this.#config.mode === "enforce") {
|
|
963
|
+
console.warn(JSON.stringify({ event: "manifest-enforce-drop", track: identity.trackName, group: String(identity.groupId), object: identity.objectId, reason }));
|
|
964
|
+
return { action: "drop", verified: false, reason };
|
|
982
965
|
}
|
|
983
|
-
|
|
966
|
+
release();
|
|
967
|
+
return { action: "play", verified: false, reason };
|
|
984
968
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
if (entries.length !== close.objectCount) {
|
|
1007
|
-
group.pendingClose = close;
|
|
1008
|
-
const hadPending = group.pending.size > 0;
|
|
1009
|
-
if (__privateGet(this, _config).onMissingManifest === "fallback-shadow" || __privateGet(this, _config).mode === "shadow") {
|
|
1010
|
-
for (const pending of [...group.pending.values()]) {
|
|
1011
|
-
__privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, pending);
|
|
1012
|
-
pending.release();
|
|
1013
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestAbsent");
|
|
969
|
+
#resolvePending(track, group, pending, entry) {
|
|
970
|
+
this.#removePending(track, group, pending);
|
|
971
|
+
this.#admitAgainstEntry(track, group, pending.identity, pending.data, pending.release, entry, pending.discard);
|
|
972
|
+
}
|
|
973
|
+
#closeGroup(track, groupId, group, close) {
|
|
974
|
+
if (group.close || group.signaturePending)
|
|
975
|
+
return;
|
|
976
|
+
const entries = [...group.entries.values()];
|
|
977
|
+
if (entries.length !== close.objectCount) {
|
|
978
|
+
group.pendingClose = close;
|
|
979
|
+
const hadPending = group.pending.size > 0;
|
|
980
|
+
if (this.#config.onMissingManifest === "fallback-shadow" || this.#config.mode === "shadow") {
|
|
981
|
+
for (const pending of [...group.pending.values()]) {
|
|
982
|
+
this.#removePending(track, group, pending);
|
|
983
|
+
pending.release();
|
|
984
|
+
this.#failure(pending.identity, "manifestAbsent");
|
|
985
|
+
}
|
|
986
|
+
} else {
|
|
987
|
+
for (const pending of group.pending.values()) {
|
|
988
|
+
this.#failure(pending.identity, "manifestAbsent");
|
|
989
|
+
}
|
|
1014
990
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestAbsent");
|
|
991
|
+
if (!hadPending) {
|
|
992
|
+
this.#failure({ trackName: track.context.trackName, groupId, objectId: 0 }, "manifestAbsent");
|
|
1018
993
|
}
|
|
994
|
+
return;
|
|
1019
995
|
}
|
|
1020
|
-
if (!
|
|
1021
|
-
|
|
996
|
+
if (!equalBytes2(sourceAuthMerkleRoot(entries), close.root)) {
|
|
997
|
+
group.failed = "digestMismatch";
|
|
998
|
+
this.#failGroup(track, groupId, group, "digestMismatch");
|
|
999
|
+
return;
|
|
1022
1000
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}, () => {
|
|
1046
|
-
if (__privateGet(this, _disposed))
|
|
1047
|
-
return;
|
|
1048
|
-
group.signaturePending = false;
|
|
1049
|
-
__privateMethod(this, _ManifestVerifier_instances, failOpenGroup_fn).call(this, track, groupId, group);
|
|
1050
|
-
});
|
|
1051
|
-
return;
|
|
1052
|
-
}
|
|
1053
|
-
__privateMethod(this, _ManifestVerifier_instances, finishGroupSignature_fn).call(this, track, groupId, group, close, signatureValid);
|
|
1054
|
-
};
|
|
1055
|
-
finishGroupSignature_fn = function(track, groupId, group, close, signatureValid) {
|
|
1056
|
-
if (!signatureValid) {
|
|
1057
|
-
group.failed = "sigInvalid";
|
|
1058
|
-
__privateMethod(this, _ManifestVerifier_instances, failGroup_fn).call(this, track, groupId, group, "sigInvalid");
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
group.failed = void 0;
|
|
1062
|
-
group.close = close;
|
|
1063
|
-
group.pendingClose = void 0;
|
|
1064
|
-
group.rootVerified = true;
|
|
1065
|
-
for (const pending of [...group.pending.values()]) {
|
|
1066
|
-
const entry = group.entries.get(pending.identity.objectId);
|
|
1067
|
-
if (entry)
|
|
1068
|
-
__privateMethod(this, _ManifestVerifier_instances, resolvePending_fn).call(this, track, group, pending, entry);
|
|
1069
|
-
else if (__privateGet(this, _config).onMissingManifest === "fallback-shadow") {
|
|
1070
|
-
__privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, pending);
|
|
1071
|
-
pending.release();
|
|
1072
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestAbsent");
|
|
1001
|
+
const preimage = sourceAuthSignaturePreimage(track.context.authScope, close.groupId, close.objectCount, close.root);
|
|
1002
|
+
let signatureValid;
|
|
1003
|
+
try {
|
|
1004
|
+
signatureValid = this.#verifyAcceptedSignature(track, preimage, close.signature);
|
|
1005
|
+
} catch {
|
|
1006
|
+
this.#failOpenGroup(track, groupId, group);
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
if (isPromiseLike(signatureValid)) {
|
|
1010
|
+
group.signaturePending = true;
|
|
1011
|
+
void signatureValid.then((valid) => {
|
|
1012
|
+
if (this.#disposed)
|
|
1013
|
+
return;
|
|
1014
|
+
group.signaturePending = false;
|
|
1015
|
+
this.#finishGroupSignature(track, groupId, group, close, valid);
|
|
1016
|
+
}, () => {
|
|
1017
|
+
if (this.#disposed)
|
|
1018
|
+
return;
|
|
1019
|
+
group.signaturePending = false;
|
|
1020
|
+
this.#failOpenGroup(track, groupId, group);
|
|
1021
|
+
});
|
|
1022
|
+
return;
|
|
1073
1023
|
}
|
|
1024
|
+
this.#finishGroupSignature(track, groupId, group, close, signatureValid);
|
|
1074
1025
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1026
|
+
#finishGroupSignature(track, groupId, group, close, signatureValid) {
|
|
1027
|
+
if (!signatureValid) {
|
|
1028
|
+
group.failed = "sigInvalid";
|
|
1029
|
+
this.#failGroup(track, groupId, group, "sigInvalid");
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
group.failed = void 0;
|
|
1033
|
+
group.close = close;
|
|
1034
|
+
group.pendingClose = void 0;
|
|
1035
|
+
group.rootVerified = true;
|
|
1036
|
+
for (const pending of [...group.pending.values()]) {
|
|
1037
|
+
const entry = group.entries.get(pending.identity.objectId);
|
|
1038
|
+
if (entry)
|
|
1039
|
+
this.#resolvePending(track, group, pending, entry);
|
|
1040
|
+
else if (this.#config.onMissingManifest === "fallback-shadow") {
|
|
1041
|
+
this.#removePending(track, group, pending);
|
|
1042
|
+
pending.release();
|
|
1043
|
+
this.#failure(pending.identity, "manifestAbsent");
|
|
1087
1044
|
}
|
|
1088
|
-
} catch {
|
|
1089
|
-
hadSynchronousError = true;
|
|
1090
1045
|
}
|
|
1091
1046
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1047
|
+
#verifyAcceptedSignature(track, message, signature) {
|
|
1048
|
+
const keys = track.context.acceptedPublicKeys ?? [track.context.publicKey];
|
|
1049
|
+
const pending = [];
|
|
1050
|
+
let hadSynchronousError = false;
|
|
1051
|
+
for (const key of keys) {
|
|
1052
|
+
try {
|
|
1053
|
+
const result = this.#verifySignature(key, message, signature);
|
|
1054
|
+
if (isPromiseLike(result)) {
|
|
1055
|
+
pending.push(Promise.resolve(result).then((valid) => valid, () => "error"));
|
|
1056
|
+
} else if (result) {
|
|
1057
|
+
return true;
|
|
1058
|
+
}
|
|
1059
|
+
} catch {
|
|
1060
|
+
hadSynchronousError = true;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
if (pending.length === 0) {
|
|
1064
|
+
if (hadSynchronousError)
|
|
1065
|
+
throw new Error("manifest signature verifier unavailable");
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
return Promise.all(pending).then((results) => {
|
|
1069
|
+
if (results.some((valid) => valid === true))
|
|
1070
|
+
return true;
|
|
1071
|
+
if (hadSynchronousError || results.some((valid) => valid === "error")) {
|
|
1072
|
+
throw new Error("manifest signature verifier unavailable");
|
|
1073
|
+
}
|
|
1074
|
+
return false;
|
|
1075
|
+
});
|
|
1096
1076
|
}
|
|
1097
|
-
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
throw new Error("manifest signature verifier unavailable");
|
|
1077
|
+
#failGroup(track, groupId, group, reason) {
|
|
1078
|
+
if (group.pending.size === 0) {
|
|
1079
|
+
this.#failure({ trackName: track.context.trackName, groupId, objectId: 0 }, reason);
|
|
1080
|
+
return;
|
|
1102
1081
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, groupId, objectId: 0 }, reason);
|
|
1109
|
-
return;
|
|
1110
|
-
}
|
|
1111
|
-
for (const pending of [...group.pending.values()]) {
|
|
1112
|
-
__privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, pending);
|
|
1113
|
-
if (__privateMethod(this, _ManifestVerifier_instances, rejectOrShadow_fn).call(this, pending.identity, pending.release, reason).action === "drop") {
|
|
1114
|
-
pending.discard?.();
|
|
1082
|
+
for (const pending of [...group.pending.values()]) {
|
|
1083
|
+
this.#removePending(track, group, pending);
|
|
1084
|
+
if (this.#rejectOrShadow(pending.identity, pending.release, reason).action === "drop") {
|
|
1085
|
+
pending.discard?.();
|
|
1086
|
+
}
|
|
1115
1087
|
}
|
|
1116
1088
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
if (group.pending.get(pending.identity.objectId) === pending) {
|
|
1120
|
-
group.pending.delete(pending.identity.objectId);
|
|
1121
|
-
}
|
|
1122
|
-
const index = track.quarantine.indexOf(pending);
|
|
1123
|
-
if (index >= 0)
|
|
1124
|
-
track.quarantine.splice(index, 1);
|
|
1125
|
-
track.quarantinedBytes -= pending.bytes;
|
|
1126
|
-
__privateGet(this, _stats).quarantinedBytes -= pending.bytes;
|
|
1127
|
-
};
|
|
1128
|
-
quarantine_fn = function(track, group, pending) {
|
|
1129
|
-
if (group.pending.has(pending.identity.objectId))
|
|
1130
|
-
return false;
|
|
1131
|
-
group.pending.set(pending.identity.objectId, pending);
|
|
1132
|
-
track.quarantine.push(pending);
|
|
1133
|
-
track.quarantinedBytes += pending.bytes;
|
|
1134
|
-
__privateGet(this, _stats).quarantinedBytes += pending.bytes;
|
|
1135
|
-
__privateMethod(this, _ManifestVerifier_instances, enforceCap_fn).call(this, track);
|
|
1136
|
-
return true;
|
|
1137
|
-
};
|
|
1138
|
-
enforceCap_fn = function(track) {
|
|
1139
|
-
while (track.quarantinedBytes > track.capBytes && track.quarantine.length > 0) {
|
|
1140
|
-
const pending = track.quarantine.shift();
|
|
1141
|
-
const group = track.groups.get(BigInt(pending.identity.groupId));
|
|
1142
|
-
if (group)
|
|
1089
|
+
#removePending(track, group, pending) {
|
|
1090
|
+
if (group.pending.get(pending.identity.objectId) === pending) {
|
|
1143
1091
|
group.pending.delete(pending.identity.objectId);
|
|
1092
|
+
}
|
|
1093
|
+
const index = track.quarantine.indexOf(pending);
|
|
1094
|
+
if (index >= 0)
|
|
1095
|
+
track.quarantine.splice(index, 1);
|
|
1144
1096
|
track.quarantinedBytes -= pending.bytes;
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
const group = track.groups.get(BigInt(pending.identity.groupId));
|
|
1170
|
-
if (group)
|
|
1171
|
-
__privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, pending);
|
|
1172
|
-
pending.release();
|
|
1173
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, reason);
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
failOpenGroup_fn = function(track, groupId, group) {
|
|
1177
|
-
const pending = [...group.pending.values()];
|
|
1178
|
-
if (pending.length === 0) {
|
|
1179
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, groupId, objectId: 0 }, "verifierError");
|
|
1180
|
-
return;
|
|
1097
|
+
this.#stats.quarantinedBytes -= pending.bytes;
|
|
1098
|
+
}
|
|
1099
|
+
#quarantine(track, group, pending) {
|
|
1100
|
+
if (group.pending.has(pending.identity.objectId))
|
|
1101
|
+
return false;
|
|
1102
|
+
group.pending.set(pending.identity.objectId, pending);
|
|
1103
|
+
track.quarantine.push(pending);
|
|
1104
|
+
track.quarantinedBytes += pending.bytes;
|
|
1105
|
+
this.#stats.quarantinedBytes += pending.bytes;
|
|
1106
|
+
this.#enforceCap(track);
|
|
1107
|
+
return true;
|
|
1108
|
+
}
|
|
1109
|
+
#enforceCap(track) {
|
|
1110
|
+
while (track.quarantinedBytes > track.capBytes && track.quarantine.length > 0) {
|
|
1111
|
+
const pending = track.quarantine.shift();
|
|
1112
|
+
const group = track.groups.get(BigInt(pending.identity.groupId));
|
|
1113
|
+
if (group)
|
|
1114
|
+
group.pending.delete(pending.identity.objectId);
|
|
1115
|
+
track.quarantinedBytes -= pending.bytes;
|
|
1116
|
+
this.#stats.quarantinedBytes -= pending.bytes;
|
|
1117
|
+
this.#giveUpOnPending(pending);
|
|
1118
|
+
this.#failure(pending.identity, "manifestAbsent");
|
|
1119
|
+
console.warn(`[ManifestVerifier] quarantine cap eviction track=${pending.identity.trackName} group=${pending.identity.groupId} object=${pending.identity.objectId} disposition=${this.#config.mode === "enforce" ? "drop" : "fail-open"}`);
|
|
1120
|
+
}
|
|
1181
1121
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1122
|
+
/**
|
|
1123
|
+
* Stop waiting for a manifest that never arrived. In `enforce` the object is
|
|
1124
|
+
* discarded: an eviction is a rejection, not a deferred play, so unverified
|
|
1125
|
+
* media never reaches the player two groups after the stall was recorded
|
|
1126
|
+
* (BLO-30095, CTO disposition on the issue thread).
|
|
1127
|
+
*
|
|
1128
|
+
* Deliberately NOT used by `#failOpenGroup`/`#failOpenTrack` — failing open on
|
|
1129
|
+
* a genuine verifier fault is correct and stays untouched.
|
|
1130
|
+
*/
|
|
1131
|
+
#giveUpOnPending(pending) {
|
|
1132
|
+
if (this.#config.mode !== "enforce") {
|
|
1133
|
+
pending.release();
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
pending.discard?.();
|
|
1186
1137
|
}
|
|
1187
|
-
|
|
1188
|
-
releaseAllQuarantine_fn = function(countFailure) {
|
|
1189
|
-
for (const track of __privateGet(this, _tracks).values()) {
|
|
1138
|
+
#failOpenTrack(track, reason) {
|
|
1190
1139
|
for (const pending of [...track.quarantine]) {
|
|
1191
1140
|
const group = track.groups.get(BigInt(pending.identity.groupId));
|
|
1192
1141
|
if (group)
|
|
1193
|
-
|
|
1142
|
+
this.#removePending(track, group, pending);
|
|
1194
1143
|
pending.release();
|
|
1195
|
-
|
|
1196
|
-
__privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "verifierError");
|
|
1144
|
+
this.#failure(pending.identity, reason);
|
|
1197
1145
|
}
|
|
1198
1146
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1147
|
+
#failOpenGroup(track, groupId, group) {
|
|
1148
|
+
const pending = [...group.pending.values()];
|
|
1149
|
+
if (pending.length === 0) {
|
|
1150
|
+
this.#failure({ trackName: track.context.trackName, groupId, objectId: 0 }, "verifierError");
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
for (const object of pending) {
|
|
1154
|
+
this.#removePending(track, group, object);
|
|
1155
|
+
object.release();
|
|
1156
|
+
this.#failure(object.identity, "verifierError");
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
#releaseAllQuarantine(countFailure) {
|
|
1160
|
+
for (const track of this.#tracks.values()) {
|
|
1161
|
+
for (const pending of [...track.quarantine]) {
|
|
1162
|
+
const group = track.groups.get(BigInt(pending.identity.groupId));
|
|
1163
|
+
if (group)
|
|
1164
|
+
this.#removePending(track, group, pending);
|
|
1165
|
+
pending.release();
|
|
1166
|
+
if (countFailure)
|
|
1167
|
+
this.#failure(pending.identity, "verifierError");
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
#failure(identity, reason) {
|
|
1172
|
+
this.#stats.failures[reason]++;
|
|
1173
|
+
this.#onFailure?.({
|
|
1174
|
+
trackName: identity.trackName,
|
|
1175
|
+
...identity.bindingId === void 0 ? {} : { bindingId: identity.bindingId },
|
|
1176
|
+
groupId: identity.groupId,
|
|
1177
|
+
objectId: identity.objectId,
|
|
1178
|
+
reason
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1210
1181
|
};
|
|
1211
1182
|
export {
|
|
1212
1183
|
ManifestVerifier,
|