@blockcast/mmt-manifest-verify 0.4.0 → 0.4.1-main.2e0aa69d293d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bc-provenance-v2-receiver.d.ts +139 -0
- package/dist/bc-provenance-v2-receiver.d.ts.map +1 -0
- package/dist/bc-provenance-v2-receiver.js +439 -0
- package/dist/bc-provenance-v2-receiver.js.map +1 -0
- package/dist/bc-provenance-v2.d.ts +74 -0
- package/dist/bc-provenance-v2.d.ts.map +1 -0
- package/dist/bc-provenance-v2.js +232 -0
- package/dist/bc-provenance-v2.js.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/bc-provenance-v2-receiver.ts +520 -0
- package/src/bc-provenance-v2.ts +311 -0
- package/src/index.ts +2 -3
- package/dist/admission.d.ts +0 -28
- package/dist/admission.d.ts.map +0 -1
- package/dist/admission.js +0 -128
- package/dist/admission.js.map +0 -1
- package/dist/source-auth.d.ts +0 -37
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -179
- package/dist/source-auth.js.map +0 -1
- package/dist/verifier.d.ts +0 -99
- package/dist/verifier.d.ts.map +0 -1
- package/dist/verifier.js +0 -492
- package/dist/verifier.js.map +0 -1
- package/src/admission.ts +0 -171
- package/src/source-auth.ts +0 -230
- package/src/verifier.ts +0 -669
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type BcProvenanceV2Endpoint } from './bc-provenance-v2.js';
|
|
2
|
+
/**
|
|
3
|
+
* Receiver enforcement for bc-provenance version 2, draft-ramadan-moq-multicast-01
|
|
4
|
+
* Section 7.2.7 at abf183bfb83e616909453872c4d788db4b3acd19 (md :1397-2010).
|
|
5
|
+
* One instance is one flow (S, G, port) of one stream generation.
|
|
6
|
+
*/
|
|
7
|
+
/** Record path: `manifestPort` on the multicast tuple, or the MoQ manifest track mirror. */
|
|
8
|
+
export type BcpV2RecordPath = 'multicast' | 'mirror';
|
|
9
|
+
/** Data path: the multicast group, or a MoQ unicast path (hold queue widened by W). */
|
|
10
|
+
export type BcpV2DataPath = 'multicast' | 'unicast';
|
|
11
|
+
export type BcpV2RecordDrop = 'length' | 'magic' | 'kid' | 'epoch' | 'mseq' | 'closed' | 'sent' | 'count' | 'hash_alg' | 'ctx' | 'budget' | 'signature' | 'duplicate';
|
|
12
|
+
export interface BcpV2Key {
|
|
13
|
+
kid: number;
|
|
14
|
+
publicKey: Uint8Array;
|
|
15
|
+
firstEpoch: number;
|
|
16
|
+
}
|
|
17
|
+
export interface BcpV2ReceiverConfig {
|
|
18
|
+
endpoint: BcProvenanceV2Endpoint;
|
|
19
|
+
keys: readonly BcpV2Key[];
|
|
20
|
+
/** Catalog (or provisioned) join floor. */
|
|
21
|
+
minEpoch: number;
|
|
22
|
+
/** Per-kid epoch floor kept with a key pin; applies at join. */
|
|
23
|
+
pinnedEpochFloor?: ReadonlyMap<number, number>;
|
|
24
|
+
/** Endpoint `bandwidth`, bits per second; bounds the hold queues. */
|
|
25
|
+
bandwidth: number;
|
|
26
|
+
maxAuthDelayMs?: number;
|
|
27
|
+
manifestTimerMs?: number;
|
|
28
|
+
/** Recomputed `ctx`; omit when the receiver has no catalog (ctx carried blind). */
|
|
29
|
+
catalogCtx?: Uint8Array;
|
|
30
|
+
acceptedHashAlgs?: readonly number[];
|
|
31
|
+
/** Widening W (ms) of the unicast hold and the mirror's freshness; capped at 5000. */
|
|
32
|
+
widenMs?: number;
|
|
33
|
+
/** True when the receiver reads the manifest track and may be on the multicast path: the lead applies. */
|
|
34
|
+
applyLead?: boolean;
|
|
35
|
+
/** False on a receiver without a UTC-synchronized clock (Clock paragraph). */
|
|
36
|
+
checkFreshness?: boolean;
|
|
37
|
+
/** Unix milliseconds; one clock serves both the UTC freshness check and the timers. */
|
|
38
|
+
now?: () => number;
|
|
39
|
+
verifySignature?: (publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface BcpV2RecordResult {
|
|
42
|
+
verdict: 'verified' | BcpV2RecordDrop;
|
|
43
|
+
/** Held datagrams admitted, in order: by a verified record, or by a duplicate copy that raised the lead. */
|
|
44
|
+
admitted: Uint8Array[];
|
|
45
|
+
}
|
|
46
|
+
export interface BcpV2DatagramResult {
|
|
47
|
+
verdict: 'admitted' | 'held' | 'duplicate' | 'overflow';
|
|
48
|
+
admitted: Uint8Array[];
|
|
49
|
+
}
|
|
50
|
+
/** The bound of Section 7.2.5 (Emission and Cadence) on the lead and on W. */
|
|
51
|
+
export declare const BCPV2_LEAD_BOUND_MS = 5000;
|
|
52
|
+
interface Bucket {
|
|
53
|
+
tokens: number;
|
|
54
|
+
last: number;
|
|
55
|
+
dropped: number;
|
|
56
|
+
}
|
|
57
|
+
export declare class BcProvenanceV2Receiver {
|
|
58
|
+
readonly maxAuthDelayMs: number;
|
|
59
|
+
readonly manifestTimerMs: number;
|
|
60
|
+
readonly widenMs: number;
|
|
61
|
+
/** Datagrams that left a hold queue at expiry, per path: the loss signal for failover. */
|
|
62
|
+
readonly expired: {
|
|
63
|
+
multicast: number;
|
|
64
|
+
unicast: number;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Unicast repair (Section 7.2.7 step 2): on a receiver that can request it, how
|
|
68
|
+
* long ago (ms) the first packet admitted into the oldest open block with an FEC
|
|
69
|
+
* deadline was admitted; undefined with none open. A pending entry still live
|
|
70
|
+
* then is kept instead of expiring, and is released with the block, under the
|
|
71
|
+
* open-block bound of [MOQ-FEC] Section 9.
|
|
72
|
+
*/
|
|
73
|
+
keepPendingAgeMs: (() => number | undefined) | null;
|
|
74
|
+
private readonly cfg;
|
|
75
|
+
private readonly now;
|
|
76
|
+
private readonly verifySig;
|
|
77
|
+
private readonly accepted;
|
|
78
|
+
private readonly queueLimit;
|
|
79
|
+
private current;
|
|
80
|
+
private previous;
|
|
81
|
+
private graceStart;
|
|
82
|
+
private hashAlg;
|
|
83
|
+
private verified;
|
|
84
|
+
private highest;
|
|
85
|
+
private closedAt;
|
|
86
|
+
private lead;
|
|
87
|
+
private pending;
|
|
88
|
+
private admittedUntil;
|
|
89
|
+
private hold;
|
|
90
|
+
private holdBytes;
|
|
91
|
+
private order;
|
|
92
|
+
readonly buckets: Record<BcpV2RecordPath, Bucket>;
|
|
93
|
+
constructor(cfg: BcpV2ReceiverConfig);
|
|
94
|
+
private get grace();
|
|
95
|
+
/** The mirror's lead in force: 0 without a manifest track, the bound until one is measured. */
|
|
96
|
+
get leadMs(): number;
|
|
97
|
+
/** Step 1: a record datagram on `manifestPort`, or a record object of the manifest track. */
|
|
98
|
+
onRecord(bytes: Uint8Array, path: BcpV2RecordPath): BcpV2RecordResult;
|
|
99
|
+
/** Step 2: a data datagram on `port` (or a packet of a listed track over MoQ unicast). */
|
|
100
|
+
onDatagram(datagram: Uint8Array, path: BcpV2DataPath): BcpV2DatagramResult;
|
|
101
|
+
/**
|
|
102
|
+
* A source packet recovered by FEC decode, its base SS_ID (SS_Start + ESI)
|
|
103
|
+
* appended: admitted only on a pending entry it consumes, never held. One no
|
|
104
|
+
* verified record lists, or a copy of an admitted packet, is dropped.
|
|
105
|
+
*/
|
|
106
|
+
admitRecovered(datagram: Uint8Array): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Discard the per-flow state on a `streamId` change or a key-set change that fails the
|
|
109
|
+
* flow's current (kid, epoch): budgets and hold queues survive, held digests are cleared.
|
|
110
|
+
*/
|
|
111
|
+
resetGeneration(): void;
|
|
112
|
+
/** The receiver ceased to hold the endpoint: drop everything; no drop here is an expiry. */
|
|
113
|
+
release(): void;
|
|
114
|
+
private digest;
|
|
115
|
+
/** Consume the lowest-seq pending entry for `digest`, admitting it. */
|
|
116
|
+
private consumePending;
|
|
117
|
+
private enqueue;
|
|
118
|
+
/** Remove and return the oldest held datagram with `digest`, across both queues. */
|
|
119
|
+
private takeHeld;
|
|
120
|
+
private dropAdmittedHeld;
|
|
121
|
+
/** Step 1 pair handling: admit a held copy, or insert a pending entry. */
|
|
122
|
+
private handlePair;
|
|
123
|
+
/** A byte-identical copy dropped by the already-verified lookup. */
|
|
124
|
+
private arrival;
|
|
125
|
+
private previousAdmitted;
|
|
126
|
+
/** The replay floor this record meets: its path's, or the higher of both from the mirror. */
|
|
127
|
+
private floor;
|
|
128
|
+
private raise;
|
|
129
|
+
private take;
|
|
130
|
+
private expire;
|
|
131
|
+
/**
|
|
132
|
+
* Retire verified entries below their arrival path's replay floor, keeping a mirrored entry
|
|
133
|
+
* while the freshness check would still pass its copy on `manifestPort`.
|
|
134
|
+
* ponytail: linear scan per record; index by (kid, epoch) if retained sets grow past a few thousand.
|
|
135
|
+
*/
|
|
136
|
+
private prune;
|
|
137
|
+
}
|
|
138
|
+
export {};
|
|
139
|
+
//# sourceMappingURL=bc-provenance-v2-receiver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bc-provenance-v2-receiver.d.ts","sourceRoot":"","sources":["../src/bc-provenance-v2-receiver.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAA;AAE9B;;;;GAIG;AAEH,4FAA4F;AAC5F,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,QAAQ,CAAA;AACpD,uFAAuF;AACvF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,SAAS,CAAA;AAEnD,MAAM,MAAM,eAAe,GACvB,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAC3E,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAA;AAE7D,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,UAAU,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA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,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,GAAG,mBAAmB;IAY1E;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO;IAM7C;;;OAGG;IACH,eAAe,IAAI,IAAI;IAcvB,4FAA4F;IAC5F,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,MAAM;IAId,uEAAuE;IACvE,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,OAAO;IAWf,oFAAoF;IACpF,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,gBAAgB;IAUxB,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAelB,oEAAoE;IACpE,OAAO,CAAC,OAAO;IAmCf,OAAO,CAAC,gBAAgB;IAQxB,6FAA6F;IAC7F,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,MAAM;IA4Bd;;;;OAIG;IACH,OAAO,CAAC,KAAK;CAWd"}
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
2
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
+
import { BCPV2_HASH_ALG_SHA256, BCPV2_MAX_RECORD_LENGTH, BCPV2_MIN_RECORD_LENGTH, bcProvenanceV2DatagramDigest, bcProvenanceV2SignedMessage, decodeBcProvenanceV2Record, } from './bc-provenance-v2.js';
|
|
4
|
+
/** The bound of Section 7.2.5 (Emission and Cadence) on the lead and on W. */
|
|
5
|
+
export const BCPV2_LEAD_BOUND_MS = 5000;
|
|
6
|
+
const REPLAY_WINDOW = 64n;
|
|
7
|
+
const BUCKET_DEPTH = 64;
|
|
8
|
+
const BUCKET_RATE_PER_MS = 1;
|
|
9
|
+
const hex = (bytes) => Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
10
|
+
function sameBytes(a, b) {
|
|
11
|
+
if (a.byteLength !== b.byteLength)
|
|
12
|
+
return false;
|
|
13
|
+
let diff = 0;
|
|
14
|
+
for (let i = 0; i < a.byteLength; i++)
|
|
15
|
+
diff |= a[i] ^ b[i];
|
|
16
|
+
return diff === 0;
|
|
17
|
+
}
|
|
18
|
+
export class BcProvenanceV2Receiver {
|
|
19
|
+
maxAuthDelayMs;
|
|
20
|
+
manifestTimerMs;
|
|
21
|
+
widenMs;
|
|
22
|
+
/** Datagrams that left a hold queue at expiry, per path: the loss signal for failover. */
|
|
23
|
+
expired = { multicast: 0, unicast: 0 };
|
|
24
|
+
/**
|
|
25
|
+
* Unicast repair (Section 7.2.7 step 2): on a receiver that can request it, how
|
|
26
|
+
* long ago (ms) the first packet admitted into the oldest open block with an FEC
|
|
27
|
+
* deadline was admitted; undefined with none open. A pending entry still live
|
|
28
|
+
* then is kept instead of expiring, and is released with the block, under the
|
|
29
|
+
* open-block bound of [MOQ-FEC] Section 9.
|
|
30
|
+
*/
|
|
31
|
+
keepPendingAgeMs = null;
|
|
32
|
+
cfg;
|
|
33
|
+
now;
|
|
34
|
+
verifySig;
|
|
35
|
+
accepted;
|
|
36
|
+
queueLimit;
|
|
37
|
+
current = null;
|
|
38
|
+
previous = null;
|
|
39
|
+
graceStart = {};
|
|
40
|
+
hashAlg = null;
|
|
41
|
+
verified = new Map();
|
|
42
|
+
highest = { multicast: new Map(), mirror: new Map() };
|
|
43
|
+
closedAt = new Map();
|
|
44
|
+
lead = null;
|
|
45
|
+
pending = new Map();
|
|
46
|
+
admittedUntil = new Map();
|
|
47
|
+
hold = { multicast: [], unicast: [] };
|
|
48
|
+
holdBytes = { multicast: 0, unicast: 0 };
|
|
49
|
+
order = 0;
|
|
50
|
+
buckets;
|
|
51
|
+
constructor(cfg) {
|
|
52
|
+
this.maxAuthDelayMs = cfg.maxAuthDelayMs ?? 200;
|
|
53
|
+
this.manifestTimerMs = cfg.manifestTimerMs ?? 20;
|
|
54
|
+
// Section 4.1 / 7.2.6: an endpoint outside these ranges is ignored, never clamped.
|
|
55
|
+
if (!(this.maxAuthDelayMs >= 50 && this.maxAuthDelayMs <= 1000) || !(this.manifestTimerMs >= 1)) {
|
|
56
|
+
throw new Error('BCPV2 endpoint ignored: maxAuthDelayMs or manifestTimerMs out of range');
|
|
57
|
+
}
|
|
58
|
+
if (!(cfg.bandwidth > 0))
|
|
59
|
+
throw new Error('BCPV2 endpoint ignored: protected endpoint without bandwidth');
|
|
60
|
+
const kids = new Set(cfg.keys.map((k) => k.kid));
|
|
61
|
+
const firsts = new Set(cfg.keys.map((k) => k.firstEpoch));
|
|
62
|
+
if (cfg.keys.length < 1 || kids.size !== cfg.keys.length || firsts.size !== cfg.keys.length) {
|
|
63
|
+
throw new Error('BCPV2 key set invalid: no keys, or a repeated kid or firstEpoch');
|
|
64
|
+
}
|
|
65
|
+
this.cfg = cfg;
|
|
66
|
+
this.widenMs = Math.min(Math.max(cfg.widenMs ?? 0, 0), BCPV2_LEAD_BOUND_MS);
|
|
67
|
+
this.now = cfg.now ?? Date.now;
|
|
68
|
+
this.verifySig = cfg.verifySignature ?? ((pk, msg, sig) => {
|
|
69
|
+
try {
|
|
70
|
+
return ed25519.verify(sig, msg, pk, { zip215: false });
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
this.accepted = cfg.acceptedHashAlgs ?? [BCPV2_HASH_ALG_SHA256];
|
|
77
|
+
// Receiver-local policy (Section 7.3) bounds the catalog's bandwidth: 10 Gbit/s.
|
|
78
|
+
const bandwidth = Math.min(cfg.bandwidth, 10e9);
|
|
79
|
+
this.queueLimit = {
|
|
80
|
+
multicast: (this.maxAuthDelayMs * bandwidth) / 8000,
|
|
81
|
+
unicast: ((this.maxAuthDelayMs + this.widenMs) * bandwidth) / 8000,
|
|
82
|
+
};
|
|
83
|
+
const t = this.now();
|
|
84
|
+
this.buckets = {
|
|
85
|
+
multicast: { tokens: BUCKET_DEPTH, last: t, dropped: 0 },
|
|
86
|
+
mirror: { tokens: BUCKET_DEPTH, last: t, dropped: 0 },
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
get grace() {
|
|
90
|
+
return this.maxAuthDelayMs + 2 * this.manifestTimerMs;
|
|
91
|
+
}
|
|
92
|
+
/** The mirror's lead in force: 0 without a manifest track, the bound until one is measured. */
|
|
93
|
+
get leadMs() {
|
|
94
|
+
if (!this.cfg.applyLead)
|
|
95
|
+
return 0;
|
|
96
|
+
return this.lead ?? BCPV2_LEAD_BOUND_MS;
|
|
97
|
+
}
|
|
98
|
+
/** Step 1: a record datagram on `manifestPort`, or a record object of the manifest track. */
|
|
99
|
+
onRecord(bytes, path) {
|
|
100
|
+
const now = this.now();
|
|
101
|
+
this.expire(now);
|
|
102
|
+
const drop = (verdict) => ({ verdict, admitted: [] });
|
|
103
|
+
const len = bytes.byteLength;
|
|
104
|
+
if (len < BCPV2_MIN_RECORD_LENGTH || len > BCPV2_MAX_RECORD_LENGTH || (len - 132) % 32 !== 0)
|
|
105
|
+
return drop('length');
|
|
106
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, len);
|
|
107
|
+
if (view.getUint32(0) !== 0x4d484d32)
|
|
108
|
+
return drop('magic');
|
|
109
|
+
const kid = view.getUint32(4);
|
|
110
|
+
const epoch = view.getUint32(8);
|
|
111
|
+
const mseq = view.getBigUint64(12);
|
|
112
|
+
const count = view.getUint16(28);
|
|
113
|
+
const hashAlg = bytes[30];
|
|
114
|
+
const sent = view.getUint32(32);
|
|
115
|
+
const key = this.cfg.keys.find((k) => k.kid === kid);
|
|
116
|
+
if (!key)
|
|
117
|
+
return drop('kid');
|
|
118
|
+
const next = Math.min(...this.cfg.keys.map((k) => k.firstEpoch).filter((f) => f > key.firstEpoch), Infinity);
|
|
119
|
+
if (epoch < key.firstEpoch || epoch >= next)
|
|
120
|
+
return drop('epoch');
|
|
121
|
+
const id = `${kid}:${epoch}:${mseq}`;
|
|
122
|
+
const seen = this.verified.get(id);
|
|
123
|
+
if (seen) {
|
|
124
|
+
// One lookup and one hash: a byte-identical copy counts as an arrival on this path.
|
|
125
|
+
const admitted = hex(sha256(bytes)) === seen.digest ? this.arrival(seen, path, now) : [];
|
|
126
|
+
return { verdict: 'duplicate', admitted };
|
|
127
|
+
}
|
|
128
|
+
const ke = `${kid}:${epoch}`;
|
|
129
|
+
if (this.current === null) {
|
|
130
|
+
if (epoch < this.cfg.minEpoch || epoch < (this.cfg.pinnedEpochFloor?.get(kid) ?? 0))
|
|
131
|
+
return drop('epoch');
|
|
132
|
+
}
|
|
133
|
+
else if (epoch < this.current.epoch && !this.previousAdmitted(epoch, path, now)) {
|
|
134
|
+
return drop('epoch');
|
|
135
|
+
}
|
|
136
|
+
const floor = this.floor(ke, path);
|
|
137
|
+
if (floor !== undefined && mseq <= floor - REPLAY_WINDOW)
|
|
138
|
+
return drop('mseq');
|
|
139
|
+
const closed = this.closedAt.get(ke);
|
|
140
|
+
if (closed !== undefined && mseq > closed)
|
|
141
|
+
return drop('closed');
|
|
142
|
+
if (this.cfg.checkFreshness !== false) {
|
|
143
|
+
const behind = 7000 + this.maxAuthDelayMs + (path === 'mirror' ? this.widenMs : 0);
|
|
144
|
+
if (sent * 1000 < now - behind || sent * 1000 > now + 6000)
|
|
145
|
+
return drop('sent');
|
|
146
|
+
}
|
|
147
|
+
if (count !== (len - 132) / 32)
|
|
148
|
+
return drop('count');
|
|
149
|
+
if (!this.accepted.includes(hashAlg) || (this.hashAlg !== null && hashAlg !== this.hashAlg))
|
|
150
|
+
return drop('hash_alg');
|
|
151
|
+
if (this.cfg.catalogCtx && !sameBytes(bytes.subarray(36, 68), this.cfg.catalogCtx))
|
|
152
|
+
return drop('ctx');
|
|
153
|
+
if (!this.take(path, now))
|
|
154
|
+
return drop('budget');
|
|
155
|
+
const record = decodeBcProvenanceV2Record(bytes);
|
|
156
|
+
if (!this.verifySig(key.publicKey, bcProvenanceV2SignedMessage(record, this.cfg.endpoint), record.signature)) {
|
|
157
|
+
return drop('signature');
|
|
158
|
+
}
|
|
159
|
+
if (this.current === null || epoch > this.current.epoch) {
|
|
160
|
+
if (this.current !== null) {
|
|
161
|
+
this.previous = { epoch: this.current.epoch, deadline: now + BCPV2_LEAD_BOUND_MS + this.grace };
|
|
162
|
+
}
|
|
163
|
+
this.current = { epoch, since: now };
|
|
164
|
+
this.graceStart = { [path]: now };
|
|
165
|
+
if (this.hashAlg === null) {
|
|
166
|
+
this.hashAlg = hashAlg;
|
|
167
|
+
for (const queue of Object.values(this.hold)) {
|
|
168
|
+
for (const held of queue)
|
|
169
|
+
held.digest ??= this.digest(held.datagram);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (epoch === this.current.epoch) {
|
|
174
|
+
this.graceStart[path] ??= now;
|
|
175
|
+
}
|
|
176
|
+
const entry = {
|
|
177
|
+
kid, epoch, mseq, path, arrival: now, sent,
|
|
178
|
+
digest: hex(sha256(bytes)),
|
|
179
|
+
pairs: record.digests.map((d, i) => ({ digest: hex(d), seq: record.firstSeq + BigInt(i), admitted: false })),
|
|
180
|
+
awaitingMulticast: path === 'mirror',
|
|
181
|
+
};
|
|
182
|
+
this.verified.set(id, entry);
|
|
183
|
+
this.raise(ke, path, mseq);
|
|
184
|
+
if (record.flags & 1)
|
|
185
|
+
this.closedAt.set(ke, mseq);
|
|
186
|
+
const widen = path === 'mirror' ? (this.cfg.applyLead ? this.leadMs : this.widenMs) : 0;
|
|
187
|
+
const admitted = [];
|
|
188
|
+
for (const pair of entry.pairs)
|
|
189
|
+
this.handlePair(pair, now, now + this.grace + widen, now, admitted);
|
|
190
|
+
this.dropAdmittedHeld();
|
|
191
|
+
this.prune(now);
|
|
192
|
+
return { verdict: 'verified', admitted };
|
|
193
|
+
}
|
|
194
|
+
/** Step 2: a data datagram on `port` (or a packet of a listed track over MoQ unicast). */
|
|
195
|
+
onDatagram(datagram, path) {
|
|
196
|
+
const now = this.now();
|
|
197
|
+
this.expire(now);
|
|
198
|
+
if (this.hashAlg !== null) {
|
|
199
|
+
const d = this.digest(datagram);
|
|
200
|
+
if (this.consumePending(d, now))
|
|
201
|
+
return { verdict: 'admitted', admitted: [datagram] };
|
|
202
|
+
if (this.admittedUntil.has(d))
|
|
203
|
+
return { verdict: 'duplicate', admitted: [] };
|
|
204
|
+
return this.enqueue({ digest: d, datagram, expiry: 0, order: 0 }, path, now);
|
|
205
|
+
}
|
|
206
|
+
return this.enqueue({ datagram, expiry: 0, order: 0 }, path, now);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A source packet recovered by FEC decode, its base SS_ID (SS_Start + ESI)
|
|
210
|
+
* appended: admitted only on a pending entry it consumes, never held. One no
|
|
211
|
+
* verified record lists, or a copy of an admitted packet, is dropped.
|
|
212
|
+
*/
|
|
213
|
+
admitRecovered(datagram) {
|
|
214
|
+
const now = this.now();
|
|
215
|
+
this.expire(now);
|
|
216
|
+
return this.hashAlg !== null && this.consumePending(this.digest(datagram), now);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Discard the per-flow state on a `streamId` change or a key-set change that fails the
|
|
220
|
+
* flow's current (kid, epoch): budgets and hold queues survive, held digests are cleared.
|
|
221
|
+
*/
|
|
222
|
+
resetGeneration() {
|
|
223
|
+
this.current = null;
|
|
224
|
+
this.previous = null;
|
|
225
|
+
this.graceStart = {};
|
|
226
|
+
this.hashAlg = null;
|
|
227
|
+
this.verified.clear();
|
|
228
|
+
this.highest = { multicast: new Map(), mirror: new Map() };
|
|
229
|
+
this.closedAt.clear();
|
|
230
|
+
this.lead = null;
|
|
231
|
+
this.pending.clear();
|
|
232
|
+
this.admittedUntil.clear();
|
|
233
|
+
for (const queue of Object.values(this.hold))
|
|
234
|
+
for (const held of queue)
|
|
235
|
+
held.digest = undefined;
|
|
236
|
+
}
|
|
237
|
+
/** The receiver ceased to hold the endpoint: drop everything; no drop here is an expiry. */
|
|
238
|
+
release() {
|
|
239
|
+
this.resetGeneration();
|
|
240
|
+
this.hold = { multicast: [], unicast: [] };
|
|
241
|
+
this.holdBytes = { multicast: 0, unicast: 0 };
|
|
242
|
+
}
|
|
243
|
+
digest(datagram) {
|
|
244
|
+
return hex(bcProvenanceV2DatagramDigest(this.cfg.endpoint, datagram));
|
|
245
|
+
}
|
|
246
|
+
/** Consume the lowest-seq pending entry for `digest`, admitting it. */
|
|
247
|
+
consumePending(digest, now) {
|
|
248
|
+
const list = this.pending.get(digest);
|
|
249
|
+
if (!list?.length)
|
|
250
|
+
return false;
|
|
251
|
+
list.sort((a, b) => (a.pair.seq < b.pair.seq ? -1 : a.pair.seq > b.pair.seq ? 1 : 0));
|
|
252
|
+
const hit = list.shift();
|
|
253
|
+
if (list.length === 0)
|
|
254
|
+
this.pending.delete(digest);
|
|
255
|
+
hit.pair.pending = undefined;
|
|
256
|
+
hit.pair.admitted = true;
|
|
257
|
+
this.admittedUntil.set(digest, now + this.maxAuthDelayMs + this.leadMs);
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
enqueue(held, path, now) {
|
|
261
|
+
if (this.holdBytes[path] + held.datagram.byteLength > this.queueLimit[path]) {
|
|
262
|
+
return { verdict: 'overflow', admitted: [] }; // drop newest
|
|
263
|
+
}
|
|
264
|
+
held.expiry = now + this.maxAuthDelayMs + (path === 'unicast' ? this.widenMs : 0);
|
|
265
|
+
held.order = this.order++;
|
|
266
|
+
this.hold[path].push(held);
|
|
267
|
+
this.holdBytes[path] += held.datagram.byteLength;
|
|
268
|
+
return { verdict: 'held', admitted: [] };
|
|
269
|
+
}
|
|
270
|
+
/** Remove and return the oldest held datagram with `digest`, across both queues. */
|
|
271
|
+
takeHeld(digest) {
|
|
272
|
+
let best;
|
|
273
|
+
for (const path of ['multicast', 'unicast']) {
|
|
274
|
+
const index = this.hold[path].findIndex((h) => h.digest === digest);
|
|
275
|
+
if (index >= 0 && (!best || this.hold[path][index].order < best.order)) {
|
|
276
|
+
best = { path, index, order: this.hold[path][index].order };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!best)
|
|
280
|
+
return undefined;
|
|
281
|
+
const [held] = this.hold[best.path].splice(best.index, 1);
|
|
282
|
+
this.holdBytes[best.path] -= held.datagram.byteLength;
|
|
283
|
+
return held.datagram;
|
|
284
|
+
}
|
|
285
|
+
dropAdmittedHeld() {
|
|
286
|
+
for (const path of ['multicast', 'unicast']) {
|
|
287
|
+
this.hold[path] = this.hold[path].filter((h) => {
|
|
288
|
+
const keep = h.digest === undefined || !this.admittedUntil.has(h.digest);
|
|
289
|
+
if (!keep)
|
|
290
|
+
this.holdBytes[path] -= h.datagram.byteLength;
|
|
291
|
+
return keep;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/** Step 1 pair handling: admit a held copy, or insert a pending entry. */
|
|
296
|
+
handlePair(pair, now, expiry, inserted, out) {
|
|
297
|
+
const datagram = this.takeHeld(pair.digest);
|
|
298
|
+
if (datagram) {
|
|
299
|
+
pair.admitted = true;
|
|
300
|
+
this.admittedUntil.set(pair.digest, now + this.maxAuthDelayMs + this.leadMs);
|
|
301
|
+
out.push(datagram);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const entry = { pair, inserted, expiry };
|
|
305
|
+
pair.pending = entry;
|
|
306
|
+
const list = this.pending.get(pair.digest);
|
|
307
|
+
if (list)
|
|
308
|
+
list.push(entry);
|
|
309
|
+
else
|
|
310
|
+
this.pending.set(pair.digest, [entry]);
|
|
311
|
+
}
|
|
312
|
+
/** A byte-identical copy dropped by the already-verified lookup. */
|
|
313
|
+
arrival(seen, path, now) {
|
|
314
|
+
const ke = `${seen.kid}:${seen.epoch}`;
|
|
315
|
+
this.raise(ke, path, seen.mseq);
|
|
316
|
+
if (this.current && seen.epoch === this.current.epoch)
|
|
317
|
+
this.graceStart[path] ??= now;
|
|
318
|
+
if (path !== 'multicast' || !seen.awaitingMulticast)
|
|
319
|
+
return [];
|
|
320
|
+
seen.awaitingMulticast = false;
|
|
321
|
+
if (!this.cfg.applyLead)
|
|
322
|
+
return [];
|
|
323
|
+
const t = this.manifestTimerMs;
|
|
324
|
+
const interval = Math.min(Math.ceil((now - seen.arrival) / t) * t, BCPV2_LEAD_BOUND_MS);
|
|
325
|
+
if (this.lead === null) {
|
|
326
|
+
this.lead = interval; // the bound applied until now covered every earlier entry
|
|
327
|
+
return [];
|
|
328
|
+
}
|
|
329
|
+
if (interval <= this.lead)
|
|
330
|
+
return [];
|
|
331
|
+
this.lead = interval;
|
|
332
|
+
// Re-handle this record and every mirrored record within the raised lead still awaiting its copy.
|
|
333
|
+
const out = [];
|
|
334
|
+
const records = [seen, ...[...this.verified.values()].filter((v) => v.awaitingMulticast && v.arrival >= now - interval)];
|
|
335
|
+
for (const v of records) {
|
|
336
|
+
for (const pair of v.pairs) {
|
|
337
|
+
if (pair.admitted) {
|
|
338
|
+
this.admittedUntil.set(pair.digest, now + this.maxAuthDelayMs + interval);
|
|
339
|
+
}
|
|
340
|
+
else if (pair.pending) {
|
|
341
|
+
pair.pending.expiry = pair.pending.inserted + this.grace + interval;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
this.handlePair(pair, now, now + this.grace + interval, now, out);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
this.dropAdmittedHeld();
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
previousAdmitted(epoch, path, now) {
|
|
352
|
+
if (!this.previous || epoch !== this.previous.epoch)
|
|
353
|
+
return false; // expire() retires it at its deadline
|
|
354
|
+
const m = this.graceStart.multicast;
|
|
355
|
+
if (path === 'multicast')
|
|
356
|
+
return m === undefined || now <= m + this.grace;
|
|
357
|
+
const starts = [m, this.graceStart.mirror].filter((s) => s !== undefined);
|
|
358
|
+
return starts.length > 0 && now <= Math.min(...starts) + this.grace;
|
|
359
|
+
}
|
|
360
|
+
/** The replay floor this record meets: its path's, or the higher of both from the mirror. */
|
|
361
|
+
floor(ke, path) {
|
|
362
|
+
const m = this.highest.multicast.get(ke);
|
|
363
|
+
if (path === 'multicast')
|
|
364
|
+
return m;
|
|
365
|
+
const r = this.highest.mirror.get(ke);
|
|
366
|
+
if (m === undefined)
|
|
367
|
+
return r;
|
|
368
|
+
return r === undefined || m > r ? m : r;
|
|
369
|
+
}
|
|
370
|
+
raise(ke, path, mseq) {
|
|
371
|
+
const h = this.highest[path].get(ke);
|
|
372
|
+
if (h === undefined || mseq > h)
|
|
373
|
+
this.highest[path].set(ke, mseq);
|
|
374
|
+
}
|
|
375
|
+
take(path, now) {
|
|
376
|
+
const b = this.buckets[path];
|
|
377
|
+
b.tokens = Math.min(BUCKET_DEPTH, b.tokens + (now - b.last) * BUCKET_RATE_PER_MS);
|
|
378
|
+
b.last = now;
|
|
379
|
+
if (b.tokens < 1) {
|
|
380
|
+
b.dropped++;
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
b.tokens -= 1;
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
expire(now) {
|
|
387
|
+
for (const path of ['multicast', 'unicast']) {
|
|
388
|
+
this.hold[path] = this.hold[path].filter((h) => {
|
|
389
|
+
if (h.expiry > now)
|
|
390
|
+
return true;
|
|
391
|
+
this.holdBytes[path] -= h.datagram.byteLength;
|
|
392
|
+
this.expired[path]++;
|
|
393
|
+
return false;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
let keepFrom = null; // read once, only when an entry is due
|
|
397
|
+
for (const [d, list] of this.pending) {
|
|
398
|
+
const live = list.filter((p) => {
|
|
399
|
+
if (p.expiry > now)
|
|
400
|
+
return true;
|
|
401
|
+
if (keepFrom === null) {
|
|
402
|
+
const age = this.keepPendingAgeMs?.();
|
|
403
|
+
keepFrom = age === undefined ? undefined : now - age;
|
|
404
|
+
}
|
|
405
|
+
if (keepFrom !== undefined && keepFrom !== null && p.expiry > keepFrom)
|
|
406
|
+
return true;
|
|
407
|
+
p.pair.pending = undefined;
|
|
408
|
+
return false;
|
|
409
|
+
});
|
|
410
|
+
if (live.length)
|
|
411
|
+
this.pending.set(d, live);
|
|
412
|
+
else
|
|
413
|
+
this.pending.delete(d);
|
|
414
|
+
}
|
|
415
|
+
for (const [d, until] of this.admittedUntil)
|
|
416
|
+
if (until <= now)
|
|
417
|
+
this.admittedUntil.delete(d);
|
|
418
|
+
if (this.previous && now > this.previous.deadline)
|
|
419
|
+
this.previous = null;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Retire verified entries below their arrival path's replay floor, keeping a mirrored entry
|
|
423
|
+
* while the freshness check would still pass its copy on `manifestPort`.
|
|
424
|
+
* ponytail: linear scan per record; index by (kid, epoch) if retained sets grow past a few thousand.
|
|
425
|
+
*/
|
|
426
|
+
prune(now) {
|
|
427
|
+
const retention = 7000 + this.maxAuthDelayMs;
|
|
428
|
+
for (const [id, v] of this.verified) {
|
|
429
|
+
const h = this.highest[v.path].get(`${v.kid}:${v.epoch}`);
|
|
430
|
+
const aboveFloor = h === undefined || v.mseq > h - REPLAY_WINDOW;
|
|
431
|
+
const fresh = this.cfg.checkFreshness === false ? v.arrival + retention >= now : v.sent * 1000 + retention >= now;
|
|
432
|
+
const current = this.current && (v.epoch === this.current.epoch || v.epoch === this.previous?.epoch);
|
|
433
|
+
if (current && (aboveFloor || (v.path === 'mirror' && fresh)))
|
|
434
|
+
continue;
|
|
435
|
+
this.verified.delete(id);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
//# sourceMappingURL=bc-provenance-v2-receiver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bc-provenance-v2-receiver.js","sourceRoot":"","sources":["../src/bc-provenance-v2-receiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4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