@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.
Files changed (148) hide show
  1. package/dist/align.d.ts +6 -2
  2. package/dist/align.d.ts.map +1 -1
  3. package/dist/align.js.map +2 -2
  4. package/dist/audio-ring-buffer.js +23 -36
  5. package/dist/audio-ring-buffer.js.map +1 -1
  6. package/dist/browser-runtime.js +6865 -6485
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +3 -1
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +21 -2
  11. package/dist/carp-catalog.js.map +4 -4
  12. package/dist/catalog-fec-params.js +10 -0
  13. package/dist/catalog-fec-params.js.map +4 -4
  14. package/dist/cmaf-block-assembler.d.ts +42 -0
  15. package/dist/cmaf-block-assembler.d.ts.map +1 -1
  16. package/dist/cmaf-block-assembler.js +542 -535
  17. package/dist/cmaf-block-assembler.js.map +2 -2
  18. package/dist/cmaf-group-batcher.js +27 -46
  19. package/dist/cmaf-group-batcher.js.map +2 -2
  20. package/dist/cmcd-producer.js +45 -66
  21. package/dist/cmcd-producer.js.map +1 -1
  22. package/dist/fec-manager.d.ts +13 -1
  23. package/dist/fec-manager.d.ts.map +1 -1
  24. package/dist/fec-manager.js +1151 -871
  25. package/dist/fec-manager.js.map +2 -2
  26. package/dist/fec-starvation-detector.js +25 -40
  27. package/dist/fec-starvation-detector.js.map +1 -1
  28. package/dist/fec-worker-setup.js +242 -225
  29. package/dist/fec-worker-setup.js.map +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js.map +2 -2
  33. package/dist/iso-bmff-timing.js +63 -88
  34. package/dist/iso-bmff-timing.js.map +1 -1
  35. package/dist/loc.js +7 -4
  36. package/dist/loc.js.map +1 -1
  37. package/dist/manifest-auth-plan.js +292 -311
  38. package/dist/manifest-auth-plan.js.map +1 -1
  39. package/dist/media-router.d.ts +0 -99
  40. package/dist/media-router.d.ts.map +1 -1
  41. package/dist/media-router.js +270 -504
  42. package/dist/media-router.js.map +3 -3
  43. package/dist/mfu-reassembler.js +597 -607
  44. package/dist/mfu-reassembler.js.map +3 -3
  45. package/dist/mmtp-container-parser.d.ts +37 -0
  46. package/dist/mmtp-container-parser.d.ts.map +1 -1
  47. package/dist/mmtp-container-parser.js +1531 -1522
  48. package/dist/mmtp-container-parser.js.map +3 -3
  49. package/dist/mmtp-container-parser.no-modules.js +179 -102
  50. package/dist/mmtp-container-parser.no-modules.js.map +3 -3
  51. package/dist/mmtp-decode-pipeline.js +1641 -1651
  52. package/dist/mmtp-decode-pipeline.js.map +3 -3
  53. package/dist/mmtp-router.d.ts +34 -0
  54. package/dist/mmtp-router.d.ts.map +1 -1
  55. package/dist/mmtp-router.js +3676 -3390
  56. package/dist/mmtp-router.js.map +3 -3
  57. package/dist/mmtp-to-cmaf.d.ts +7 -1
  58. package/dist/mmtp-to-cmaf.d.ts.map +1 -1
  59. package/dist/mmtp-to-cmaf.js +109 -134
  60. package/dist/mmtp-to-cmaf.js.map +2 -2
  61. package/dist/multicast-input.d.ts +7 -35
  62. package/dist/multicast-input.d.ts.map +1 -1
  63. package/dist/multicast-input.js +21 -2
  64. package/dist/multicast-input.js.map +4 -4
  65. package/dist/multicast-manager.d.ts +10 -1
  66. package/dist/multicast-manager.d.ts.map +1 -1
  67. package/dist/multicast-manager.js +5584 -4961
  68. package/dist/multicast-manager.js.map +4 -4
  69. package/dist/multicast-transport.d.ts +7 -0
  70. package/dist/multicast-transport.d.ts.map +1 -1
  71. package/dist/multicast-transport.js +369 -421
  72. package/dist/multicast-transport.js.map +4 -4
  73. package/dist/multicast-unwrap.js +53 -30
  74. package/dist/multicast-unwrap.js.map +2 -2
  75. package/dist/no-modules.js +2096 -2097
  76. package/dist/no-modules.js.map +3 -3
  77. package/dist/sample-combiner.js +118 -139
  78. package/dist/sample-combiner.js.map +1 -1
  79. package/dist/signaling.js.map +2 -2
  80. package/dist/source-auth.js +353 -382
  81. package/dist/source-auth.js.map +1 -1
  82. package/dist/switching-set-alignment.js +14 -29
  83. package/dist/switching-set-alignment.js.map +1 -1
  84. package/dist/timestamp-codec.js +17 -11
  85. package/dist/timestamp-codec.js.map +2 -2
  86. package/dist/track-pipeline-setup.js +105 -125
  87. package/dist/track-pipeline-setup.js.map +1 -1
  88. package/dist/track-pipeline.js +107 -127
  89. package/dist/track-pipeline.js.map +1 -1
  90. package/dist/track-session.d.ts +16 -0
  91. package/dist/track-session.d.ts.map +1 -1
  92. package/dist/track-session.js +230 -243
  93. package/dist/track-session.js.map +2 -2
  94. package/dist/transport-pool.js +24 -38
  95. package/dist/transport-pool.js.map +1 -1
  96. package/dist/wasm-mfu-reassembler.d.ts +6 -1
  97. package/dist/wasm-mfu-reassembler.d.ts.map +1 -1
  98. package/dist/wasm-mfu-reassembler.js +127 -144
  99. package/dist/wasm-mfu-reassembler.js.map +2 -2
  100. package/dist/wasm-mmtp-container-parser.js +1659 -1650
  101. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  102. package/node_modules/@blockcast/fec-worker/README.md +5 -1
  103. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +8 -2
  104. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
  105. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +89 -16
  106. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
  107. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +48 -3
  108. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -1
  109. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +55 -8
  110. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +2 -2
  111. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +1 -1
  112. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -1
  113. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -1
  114. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +97 -17
  115. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +46 -2
  116. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +78 -10
  117. package/node_modules/@blockcast/fec-worker/src/index.ts +2 -0
  118. package/node_modules/@blockcast/mmt-base/README.md +1 -0
  119. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
  120. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
  121. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
  122. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
  123. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
  124. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +1 -0
  125. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
  126. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
  127. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
  128. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
  129. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
  130. package/package.json +7 -6
  131. package/schemas/catalog.schema.json +1 -1
  132. package/src/align.ts +6 -2
  133. package/src/carp-catalog.ts +13 -3
  134. package/src/cmaf-block-assembler.ts +90 -81
  135. package/src/fec-manager.ts +530 -146
  136. package/src/index.ts +2 -2
  137. package/src/media-router.ts +0 -397
  138. package/src/mmtp-container-parser.ts +97 -21
  139. package/src/mmtp-router.ts +302 -125
  140. package/src/mmtp-to-cmaf.ts +21 -7
  141. package/src/multicast-input.ts +23 -3
  142. package/src/multicast-manager.ts +83 -11
  143. package/src/multicast-transport.ts +56 -17
  144. package/src/track-session.ts +16 -0
  145. package/src/wasm-mfu-reassembler.ts +40 -24
  146. package/test-vectors/catalog/README.md +2 -0
  147. package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
  148. package/test-vectors/catalog-validation.json +11 -0
@@ -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
- __privateAdd(this, _SourceAuthAdmission_instances);
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
- __privateMethod(this, _SourceAuthAdmission_instances, requireGroup_fn).call(this, input.groupId);
635
- if (__privateGet(this, _closed))
623
+ this.#requireGroup(input.groupId);
624
+ if (this.#closed)
636
625
  throw new Error("source-auth group is already closed");
637
- if (__privateGet(this, _admissions).has(input.objectId) || __privateGet(this, _pendingObjects).has(input.objectId)) {
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 = __privateGet(this, _entries).get(input.objectId);
629
+ const entry = this.#entries.get(input.objectId);
641
630
  if (entry) {
642
- __privateGet(this, _entriesAwaitingObjects).delete(input.objectId);
643
- return __privateMethod(this, _SourceAuthAdmission_instances, verifyObject_fn).call(this, entry, input.bytes, input.recovered ?? false);
631
+ this.#entriesAwaitingObjects.delete(input.objectId);
632
+ return this.#verifyObject(entry, input.bytes, input.recovered ?? false);
644
633
  }
645
- if (__privateGet(this, _pendingObjects).size >= 1) {
634
+ if (this.#pendingObjects.size >= 1) {
646
635
  throw new Error("source-auth media exceeds one-object manifest skew");
647
636
  }
648
- __privateGet(this, _pendingObjects).set(input.objectId, {
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
- __privateMethod(this, _SourceAuthAdmission_instances, requireGroup_fn).call(this, entry.groupId);
661
- if (__privateGet(this, _closed))
649
+ this.#requireGroup(entry.groupId);
650
+ if (this.#closed)
662
651
  throw new Error("source-auth group is already closed");
663
- if (__privateGet(this, _entries).has(entry.objectId)) {
652
+ if (this.#entries.has(entry.objectId)) {
664
653
  throw new Error(`duplicate source-auth manifest entry ${entry.objectId}`);
665
654
  }
666
- const pending = __privateGet(this, _pendingObjects).get(entry.objectId);
667
- if (!pending && __privateGet(this, _entriesAwaitingObjects).size >= 1) {
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
- __privateGet(this, _entries).set(entry.objectId, entry);
659
+ this.#entries.set(entry.objectId, entry);
671
660
  if (!pending) {
672
- __privateGet(this, _entriesAwaitingObjects).add(entry.objectId);
661
+ this.#entriesAwaitingObjects.add(entry.objectId);
673
662
  return "pending-object";
674
663
  }
675
- __privateGet(this, _pendingObjects).delete(entry.objectId);
676
- return __privateMethod(this, _SourceAuthAdmission_instances, verifyObject_fn).call(this, entry, pending.bytes, pending.recovered);
664
+ this.#pendingObjects.delete(entry.objectId);
665
+ return this.#verifyObject(entry, pending.bytes, pending.recovered);
677
666
  }
678
667
  objectState(objectId) {
679
- if (__privateGet(this, _pendingObjects).has(objectId))
668
+ if (this.#pendingObjects.has(objectId))
680
669
  return "pending-entry";
681
- if (__privateGet(this, _entriesAwaitingObjects).has(objectId))
670
+ if (this.#entriesAwaitingObjects.has(objectId))
682
671
  return "pending-object";
683
- if (__privateGet(this, _closed) && __privateGet(this, _admissions).has(objectId))
672
+ if (this.#closed && this.#admissions.has(objectId))
684
673
  return "authenticated";
685
- return __privateGet(this, _admissions).get(objectId)?.state;
674
+ return this.#admissions.get(objectId)?.state;
686
675
  }
687
676
  async verifyClose(close, authScope, publicKey, subtle = globalThis.crypto.subtle) {
688
- __privateMethod(this, _SourceAuthAdmission_instances, requireGroup_fn).call(this, close.groupId);
689
- if (__privateGet(this, _closed))
677
+ this.#requireGroup(close.groupId);
678
+ if (this.#closed)
690
679
  throw new Error("source-auth group is already closed");
691
- if (__privateGet(this, _pendingObjects).size !== 0 || __privateGet(this, _entriesAwaitingObjects).size !== 0) {
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 !== __privateGet(this, _entries).size || __privateGet(this, _admissions).size !== __privateGet(this, _entries).size) {
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([...__privateGet(this, _entries).values()]);
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 __privateGet(this, _admissions).values())
692
+ for (const admission of this.#admissions.values())
704
693
  admission.state = "authenticated";
705
- __privateSet(this, _closed, true);
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
- __privateAdd(this, _ManifestVerifier_instances);
774
- __privateAdd(this, _config);
775
- __privateAdd(this, _verifySignature);
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 __privateGet(this, _config);
768
+ return this.#config;
790
769
  }
791
770
  get stats() {
792
771
  let quarantined = 0;
793
- for (const track of __privateGet(this, _tracks).values())
772
+ for (const track of this.#tracks.values())
794
773
  quarantined += track.quarantine.length;
795
774
  return {
796
- verified: __privateGet(this, _stats).verified,
797
- failures: { ...__privateGet(this, _stats).failures },
775
+ verified: this.#stats.verified,
776
+ failures: { ...this.#stats.failures },
798
777
  quarantined,
799
- quarantinedBytes: __privateGet(this, _stats).quarantinedBytes
778
+ quarantinedBytes: this.#stats.quarantinedBytes
800
779
  };
801
780
  }
802
781
  setMode(mode) {
803
- __privateSet(this, _config, { ...__privateGet(this, _config), mode });
782
+ this.#config = { ...this.#config, mode };
804
783
  if (mode !== "enforce")
805
- __privateMethod(this, _ManifestVerifier_instances, releaseAllQuarantine_fn).call(this, false);
784
+ this.#releaseAllQuarantine(false);
806
785
  }
807
786
  registerTrack(context) {
808
787
  const bindingId = context.bindingId ?? context.trackName;
809
- if (__privateGet(this, _tracks).has(bindingId)) {
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
- __privateGet(this, _tracks).set(bindingId, {
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 = __privateMethod(this, _ManifestVerifier_instances, requireTrack_fn).call(this, bindingId);
827
+ const track = this.#requireTrack(bindingId);
849
828
  try {
850
829
  const frame = decodeSourceAuthManifestFrame(frameBytes);
851
830
  const groupId = frame.groupId;
852
- const group = __privateMethod(this, _ManifestVerifier_instances, group_fn).call(this, track, groupId);
831
+ const group = this.#group(track, groupId);
853
832
  if (frame.kind === "object") {
854
833
  if (group.close || group.signaturePending || group.failed) {
855
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, bindingId, groupId, objectId: frame.objectId }, "verifierError");
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
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, bindingId, groupId, objectId: frame.objectId }, "verifierError");
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
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, bindingId, groupId, objectId: frame.objectId }, "verifierError");
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
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestLate");
871
- __privateMethod(this, _ManifestVerifier_instances, resolvePending_fn).call(this, track, group, pending, frame);
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
- __privateMethod(this, _ManifestVerifier_instances, closeGroup_fn).call(this, track, groupId, group, close);
855
+ this.#closeGroup(track, groupId, group, close);
877
856
  }
878
857
  return;
879
858
  }
880
- __privateMethod(this, _ManifestVerifier_instances, closeGroup_fn).call(this, track, groupId, group, frame);
859
+ this.#closeGroup(track, groupId, group, frame);
881
860
  } catch {
882
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, bindingId, groupId: 0, objectId: 0 }, "verifierError");
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 (__privateGet(this, _config).mode === "off") {
865
+ if (this.#config.mode === "off") {
887
866
  release();
888
867
  return { action: "play", verified: false };
889
868
  }
890
- const track = __privateGet(this, _tracks).get(identity.bindingId ?? identity.trackName);
869
+ const track = this.#tracks.get(identity.bindingId ?? identity.trackName);
891
870
  if (!track) {
892
871
  release();
893
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, identity, "verifierError");
872
+ this.#failure(identity, "verifierError");
894
873
  return { action: "play", verified: false, reason: "verifierError" };
895
874
  }
896
875
  try {
897
- if (!__privateMethod(this, _ManifestVerifier_instances, validateIdentity_fn).call(this, track, identity)) {
898
- return __privateMethod(this, _ManifestVerifier_instances, rejectOrShadow_fn).call(this, identity, release, "digestMismatch");
876
+ if (!this.#validateIdentity(track, identity)) {
877
+ return this.#rejectOrShadow(identity, release, "digestMismatch");
899
878
  }
900
- const group = __privateMethod(this, _ManifestVerifier_instances, group_fn).call(this, track, BigInt(identity.groupId));
879
+ const group = this.#group(track, BigInt(identity.groupId));
901
880
  if (group.failed === "sigInvalid" || group.failed === "digestMismatch") {
902
- return __privateMethod(this, _ManifestVerifier_instances, rejectOrShadow_fn).call(this, identity, release, group.failed);
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 __privateMethod(this, _ManifestVerifier_instances, admitAgainstEntry_fn).call(this, track, group, identity, data, release, entry, discard);
907
- if (__privateGet(this, _config).mode === "shadow" || __privateGet(this, _config).onMissingManifest === "fallback-shadow") {
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
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, identity, "manifestAbsent");
888
+ this.#failure(identity, "manifestAbsent");
910
889
  return { action: "play", verified: false, reason: "manifestAbsent" };
911
890
  }
912
- if (!__privateMethod(this, _ManifestVerifier_instances, quarantine_fn).call(this, track, group, { identity, data, release, discard, bytes: data.byteLength })) {
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
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, identity, "verifierError");
897
+ this.#failure(identity, "verifierError");
919
898
  return { action: "play", verified: false, reason: "verifierError" };
920
899
  }
921
900
  }
922
901
  dispose() {
923
- if (__privateGet(this, _disposed))
902
+ if (this.#disposed)
924
903
  return;
925
- __privateSet(this, _disposed, true);
926
- __privateMethod(this, _ManifestVerifier_instances, releaseAllQuarantine_fn).call(this, false);
927
- __privateGet(this, _tracks).clear();
928
- }
929
- };
930
- _config = new WeakMap();
931
- _verifySignature = new WeakMap();
932
- _onFailure = new WeakMap();
933
- _tracks = new WeakMap();
934
- _stats = new WeakMap();
935
- _disposed = new WeakMap();
936
- _ManifestVerifier_instances = new WeakSet();
937
- requireTrack_fn = function(bindingId) {
938
- const track = __privateGet(this, _tracks).get(bindingId);
939
- if (!track)
940
- throw new Error(`unknown manifest binding ${bindingId}`);
941
- return track;
942
- };
943
- group_fn = function(track, groupId) {
944
- let group = track.groups.get(groupId);
945
- if (!group) {
946
- group = { entries: /* @__PURE__ */ new Map(), pending: /* @__PURE__ */ new Map(), rootVerified: false };
947
- track.groups.set(groupId, group);
948
- while (track.groups.size > track.maxGroups) {
949
- const oldest = track.groups.entries().next().value;
950
- if (!oldest)
951
- break;
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
- return group;
963
- };
964
- validateIdentity_fn = function(track, identity) {
965
- const coordinates = track.context.mapper.derive(Number(identity.groupId), identity.objectId);
966
- return identity.ssId === void 0 || coordinates.ssId === identity.ssId;
967
- };
968
- admitAgainstEntry_fn = function(track, group, identity, data, release, entry, discard) {
969
- if (entry.trueLength !== data.byteLength) {
970
- return __privateMethod(this, _ManifestVerifier_instances, rejectOrShadow_fn).call(this, identity, release, "digestMismatch");
971
- }
972
- const digestMatches = equalBytes2(sourceAuthObjectDigest(data.subarray(0, entry.trueLength)), entry.digest);
973
- if (!digestMatches)
974
- return __privateMethod(this, _ManifestVerifier_instances, rejectOrShadow_fn).call(this, identity, release, "digestMismatch");
975
- if (!track.context.manifestChannelAuthenticated && !group.rootVerified) {
976
- if (__privateGet(this, _config).mode === "shadow") {
977
- release();
978
- return { action: "play", verified: false };
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
- if (!__privateMethod(this, _ManifestVerifier_instances, quarantine_fn).call(this, track, group, { identity, data, release, discard, bytes: data.byteLength })) {
981
- return { action: "drop", verified: false };
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
- return { action: "stall", verified: false };
966
+ release();
967
+ return { action: "play", verified: false, reason };
984
968
  }
985
- release();
986
- __privateGet(this, _stats).verified++;
987
- return { action: "play", verified: true };
988
- };
989
- rejectOrShadow_fn = function(identity, release, reason) {
990
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, identity, reason);
991
- if (__privateGet(this, _config).mode === "enforce") {
992
- console.warn(JSON.stringify({ event: "manifest-enforce-drop", track: identity.trackName, group: String(identity.groupId), object: identity.objectId, reason }));
993
- return { action: "drop", verified: false, reason };
994
- }
995
- release();
996
- return { action: "play", verified: false, reason };
997
- };
998
- resolvePending_fn = function(track, group, pending, entry) {
999
- __privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, pending);
1000
- __privateMethod(this, _ManifestVerifier_instances, admitAgainstEntry_fn).call(this, track, group, pending.identity, pending.data, pending.release, entry, pending.discard);
1001
- };
1002
- closeGroup_fn = function(track, groupId, group, close) {
1003
- if (group.close || group.signaturePending)
1004
- return;
1005
- const entries = [...group.entries.values()];
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
- } else {
1016
- for (const pending of group.pending.values()) {
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 (!hadPending) {
1021
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, { trackName: track.context.trackName, groupId, objectId: 0 }, "manifestAbsent");
996
+ if (!equalBytes2(sourceAuthMerkleRoot(entries), close.root)) {
997
+ group.failed = "digestMismatch";
998
+ this.#failGroup(track, groupId, group, "digestMismatch");
999
+ return;
1022
1000
  }
1023
- return;
1024
- }
1025
- if (!equalBytes2(sourceAuthMerkleRoot(entries), close.root)) {
1026
- group.failed = "digestMismatch";
1027
- __privateMethod(this, _ManifestVerifier_instances, failGroup_fn).call(this, track, groupId, group, "digestMismatch");
1028
- return;
1029
- }
1030
- const preimage = sourceAuthSignaturePreimage(track.context.authScope, close.groupId, close.objectCount, close.root);
1031
- let signatureValid;
1032
- try {
1033
- signatureValid = __privateMethod(this, _ManifestVerifier_instances, verifyAcceptedSignature_fn).call(this, track, preimage, close.signature);
1034
- } catch {
1035
- __privateMethod(this, _ManifestVerifier_instances, failOpenGroup_fn).call(this, track, groupId, group);
1036
- return;
1037
- }
1038
- if (isPromiseLike(signatureValid)) {
1039
- group.signaturePending = true;
1040
- void signatureValid.then((valid) => {
1041
- if (__privateGet(this, _disposed))
1042
- return;
1043
- group.signaturePending = false;
1044
- __privateMethod(this, _ManifestVerifier_instances, finishGroupSignature_fn).call(this, track, groupId, group, close, valid);
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
- verifyAcceptedSignature_fn = function(track, message, signature) {
1077
- const keys = track.context.acceptedPublicKeys ?? [track.context.publicKey];
1078
- const pending = [];
1079
- let hadSynchronousError = false;
1080
- for (const key of keys) {
1081
- try {
1082
- const result = __privateGet(this, _verifySignature).call(this, key, message, signature);
1083
- if (isPromiseLike(result)) {
1084
- pending.push(Promise.resolve(result).then((valid) => valid, () => "error"));
1085
- } else if (result) {
1086
- return true;
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
- if (pending.length === 0) {
1093
- if (hadSynchronousError)
1094
- throw new Error("manifest signature verifier unavailable");
1095
- return false;
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
- return Promise.all(pending).then((results) => {
1098
- if (results.some((valid) => valid === true))
1099
- return true;
1100
- if (hadSynchronousError || results.some((valid) => valid === "error")) {
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
- return false;
1104
- });
1105
- };
1106
- failGroup_fn = function(track, groupId, group, reason) {
1107
- if (group.pending.size === 0) {
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
- removePending_fn = function(track, group, pending) {
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
- __privateGet(this, _stats).quarantinedBytes -= pending.bytes;
1146
- __privateMethod(this, _ManifestVerifier_instances, giveUpOnPending_fn).call(this, pending);
1147
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "manifestAbsent");
1148
- 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"}`);
1149
- }
1150
- };
1151
- /**
1152
- * Stop waiting for a manifest that never arrived. In `enforce` the object is
1153
- * discarded: an eviction is a rejection, not a deferred play, so unverified
1154
- * media never reaches the player two groups after the stall was recorded
1155
- * (BLO-30095, CTO disposition on the issue thread).
1156
- *
1157
- * Deliberately NOT used by `#failOpenGroup`/`#failOpenTrack` — failing open on
1158
- * a genuine verifier fault is correct and stays untouched.
1159
- */
1160
- giveUpOnPending_fn = function(pending) {
1161
- if (__privateGet(this, _config).mode !== "enforce") {
1162
- pending.release();
1163
- return;
1164
- }
1165
- pending.discard?.();
1166
- };
1167
- failOpenTrack_fn = function(track, reason) {
1168
- for (const pending of [...track.quarantine]) {
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
- for (const object of pending) {
1183
- __privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, object);
1184
- object.release();
1185
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, object.identity, "verifierError");
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
- __privateMethod(this, _ManifestVerifier_instances, removePending_fn).call(this, track, group, pending);
1142
+ this.#removePending(track, group, pending);
1194
1143
  pending.release();
1195
- if (countFailure)
1196
- __privateMethod(this, _ManifestVerifier_instances, failure_fn).call(this, pending.identity, "verifierError");
1144
+ this.#failure(pending.identity, reason);
1197
1145
  }
1198
1146
  }
1199
- };
1200
- failure_fn = function(identity, reason) {
1201
- var _a;
1202
- __privateGet(this, _stats).failures[reason]++;
1203
- (_a = __privateGet(this, _onFailure)) == null ? void 0 : _a.call(this, {
1204
- trackName: identity.trackName,
1205
- ...identity.bindingId === void 0 ? {} : { bindingId: identity.bindingId },
1206
- groupId: identity.groupId,
1207
- objectId: identity.objectId,
1208
- reason
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,