@blockcast/mmt-container 2.2.0-main.94f541fafcc0 → 2.2.0-main.9684cdc1a86c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/__tests__/ad-creative-signer.d.ts +2 -1
- package/dist/__tests__/ad-creative-signer.d.ts.map +1 -1
- package/dist/ad-beacon.d.ts +1 -1
- package/dist/ad-beacon.js.map +1 -1
- package/dist/ad-creative-record.d.ts +13 -4
- package/dist/ad-creative-record.d.ts.map +1 -1
- package/dist/ad-creative-record.js +27 -16
- package/dist/ad-creative-record.js.map +2 -2
- package/dist/ad-creative-timeline.d.ts +6 -6
- package/dist/ad-creative-timeline.d.ts.map +1 -1
- package/dist/ad-creative-timeline.js +31 -17
- package/dist/ad-creative-timeline.js.map +2 -2
- package/dist/browser-runtime.js +6270 -5428
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +3 -3
- package/dist/carp-catalog.js.map +1 -1
- package/dist/catalog-fec-params.d.ts +12 -14
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +11 -5
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/conceal-timeline.d.ts +7 -4
- package/dist/conceal-timeline.d.ts.map +1 -1
- package/dist/conceal-timeline.js +121 -4
- package/dist/conceal-timeline.js.map +2 -2
- package/dist/datagram-leg-deadline.d.ts +35 -0
- package/dist/datagram-leg-deadline.d.ts.map +1 -1
- package/dist/datagram-leg-deadline.js +13 -0
- package/dist/datagram-leg-deadline.js.map +2 -2
- package/dist/fec-manager.d.ts +67 -4
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +9 -4
- package/dist/fec-manager.js.map +2 -2
- package/dist/feed-gate.d.ts +85 -2
- package/dist/feed-gate.d.ts.map +1 -1
- package/dist/feed-gate.js +186 -3
- package/dist/feed-gate.js.map +2 -2
- package/dist/fetch-on-gap.d.ts +318 -0
- package/dist/fetch-on-gap.d.ts.map +1 -0
- package/dist/fetch-on-gap.js +1960 -0
- package/dist/fetch-on-gap.js.map +7 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -3
- package/dist/index.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-router.d.ts +22 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +61 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts +47 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +5921 -5757
- package/dist/multicast-manager.js.map +4 -4
- package/dist/no-modules.js.map +2 -2
- package/dist/repair-layer-subscriptions.d.ts +10 -7
- package/dist/repair-layer-subscriptions.d.ts.map +1 -1
- package/dist/repair-layer-subscriptions.js +1 -1
- package/dist/repair-layer-subscriptions.js.map +2 -2
- package/package.json +7 -6
- package/src/ad-beacon.ts +1 -1
- package/src/ad-creative-record.ts +50 -20
- package/src/ad-creative-timeline.ts +14 -10
- package/src/carp-catalog.ts +3 -3
- package/src/catalog-fec-params.ts +26 -18
- package/src/conceal-timeline.ts +13 -4
- package/src/datagram-leg-deadline.ts +49 -0
- package/src/fec-manager.ts +81 -5
- package/src/feed-gate.ts +290 -3
- package/src/fetch-on-gap.ts +907 -0
- package/src/index.ts +26 -1
- package/src/mmtp-router.ts +65 -0
- package/src/multicast-manager.ts +104 -2
- package/src/repair-layer-subscriptions.ts +11 -8
- package/test-vectors/source-gap-fetch.json +843 -0
package/README.md
CHANGED
|
@@ -525,6 +525,16 @@ Every FEC block still gets in-band FEC decode. On top of that:
|
|
|
525
525
|
that report the gate withholds the rest of a GOP in which it had withheld a
|
|
526
526
|
frame or fed one across a gap, up to the next keyframe. The gate's counters
|
|
527
527
|
are the timeline's `gateStats`.
|
|
528
|
+
- **A frame that conceals on its own.** Given the frame's bytes (and, for
|
|
529
|
+
AV1, the sequence header kept from the last keyframe, `readAv1Sequence`),
|
|
530
|
+
`decoderTolerance` answers `conceals` for a VP9 frame, or a frame of a
|
|
531
|
+
layered AV1 stream with no frame ids and no order hints, that sets
|
|
532
|
+
`error_resilient_mode`. The sink feeds it across a loss. That answer is
|
|
533
|
+
about the decoder, not the loss: it cannot tell that the missing frame was
|
|
534
|
+
a keyframe. Where the FEC gate owns the track, `decideGap` sees a lost
|
|
535
|
+
keyframe (`rap-lost`) and stalls. A track with no catalog K and T carries
|
|
536
|
+
no decision, so a sink that feeds across a hole on this answer also feeds
|
|
537
|
+
across a lost keyframe (hang and MOQtail do, for VP9 and for layered AV1).
|
|
528
538
|
|
|
529
539
|
Typed evidence is `RepairLifecycleEvent` version 2 and
|
|
530
540
|
`MulticastManager.getBlockPolicyStats()`.
|
|
@@ -6,6 +6,7 @@ import { type AdCreativeKeys } from '../ad-creative-record.js';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function testSigner(kid?: string, seed?: number): {
|
|
8
8
|
keys: AdCreativeKeys;
|
|
9
|
-
|
|
9
|
+
/** `header` adds protected header members, such as iat (riedl 4.5). */
|
|
10
|
+
sign(record: Record<string, unknown>, header?: Record<string, unknown>): Record<string, unknown>;
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=ad-creative-signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ad-creative-signer.d.ts","sourceRoot":"","sources":["../../src/__tests__/ad-creative-signer.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAKnG;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,SAAmB,EAAE,IAAI,SAAI,GAAG;IAC5D,IAAI,EAAE,cAAc,CAAA;IACpB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"ad-creative-signer.d.ts","sourceRoot":"","sources":["../../src/__tests__/ad-creative-signer.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAKnG;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,SAAmB,EAAE,IAAI,SAAI,GAAG;IAC5D,IAAI,EAAE,cAAc,CAAA;IACpB,uEAAuE;IACvE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjG,CAYA"}
|
package/dist/ad-beacon.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Beacon planning for ad creative signaling (draft-riedl-moq-ad-creative-signaling-
|
|
2
|
+
* Beacon planning for ad creative signaling (draft-riedl-moq-ad-creative-signaling-02 7, 12):
|
|
3
3
|
* which URL to request and when. No I/O and no timers here (the cmcd-producer.ts precedent):
|
|
4
4
|
* the player sends each plan at sendAtMs with
|
|
5
5
|
* fetch(url, { mode: 'no-cors', credentials: 'omit', keepalive: true, referrerPolicy: 'no-referrer' }).
|
package/dist/ad-beacon.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/ad-beacon.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Beacon planning for ad creative signaling (draft-riedl-moq-ad-creative-signaling-
|
|
4
|
+
"sourcesContent": ["/**\n * Beacon planning for ad creative signaling (draft-riedl-moq-ad-creative-signaling-02 7, 12):\n * which URL to request and when. No I/O and no timers here (the cmcd-producer.ts precedent):\n * the player sends each plan at sendAtMs with\n * fetch(url, { mode: 'no-cors', credentials: 'omit', keepalive: true, referrerPolicy: 'no-referrer' }).\n * The player calls this only for events the timeline emitted, so only for verified records.\n */\nimport type { AdTrackEvent } from './ad-creative-timeline.js'\n\nexport interface AdBeaconPolicy {\n /** Lower-case host[:port] beacons may go to (riedl 12.1), typically the distributor's beacon proxy. Empty: nothing is sent. */\n readonly authorities: readonly string[]\n /** Uniform jitter window W in ms (riedl 7.2). Size it from the audience: W >= 1000 * N * k / C ms, for N receivers,\n * k requests each at that instant and C beacon-proxy requests/s. */\n readonly jitterMs: number\n /** Event types sent at once, unjittered: the verification-critical ones (riedl 7.2). */\n readonly immediate?: readonly string[]\n /** Pseudonymous, session-scoped client id appended as a query parameter (riedl 7.1). Never a device id. */\n readonly clientId?: { readonly param: string; readonly value: string }\n /** Query parameter carrying the event's wallclock ms on a jittered request (riedl 7.2). */\n readonly eventTimeParam?: string\n /** URLs sent per event at most; the rest are suppressed (riedl 12.2). Default 16, also used for a NaN, infinite or negative value. */\n readonly maxUrlsPerEvent?: number\n}\n\nexport type AdBeaconPlan =\n | { readonly url: string; readonly sendAtMs: number; readonly eventType: string }\n | { readonly url: string; readonly suppressed: 'authority' | 'cap' | 'macro'; readonly eventType: string }\n\n/** A VAST macro such as [CACHEBUSTING]: riedl 7's first pattern (client-side substitution) is not supported. */\nconst VAST_MACRO = /\\[[A-Z0-9_]+\\]/\n\n/** `random` gives the jitter phase in [0, 1). The player passes one phase drawn per session, so a device's events\n * keep their order and spacing while the audience still spreads uniformly over [0, W) (riedl 7.2). */\nexport function planAdBeacons(event: AdTrackEvent, policy: AdBeaconPolicy, nowMs: number, random: () => number = Math.random): AdBeaconPlan[] {\n const jittered = policy.jitterMs > 0 && !(policy.immediate ?? []).includes(event.eventType)\n const delay = jittered ? Math.floor(random() * policy.jitterMs) : 0\n const params: string[] = []\n if (policy.clientId) params.push(`${encodeURIComponent(policy.clientId.param)}=${encodeURIComponent(policy.clientId.value)}`)\n if (policy.eventTimeParam && jittered) params.push(`${encodeURIComponent(policy.eventTimeParam)}=${nowMs}`)\n // A malformed setting (NaN from Number(undefined)) must not turn the cap off: i >= NaN is always false.\n const max = policy.maxUrlsPerEvent\n const cap = max !== undefined && Number.isFinite(max) && max >= 0 ? max : 16\n return event.urls.map((raw, i): AdBeaconPlan => {\n if (i >= cap) return { url: raw, suppressed: 'cap', eventType: event.eventType }\n // Never sent unexpanded, and a device-identifier macro is never expanded (riedl 7.1, R33).\n if (VAST_MACRO.test(raw)) return { url: raw, suppressed: 'macro', eventType: event.eventType }\n const url = new URL(raw) // https and parseable: checked when the record was accepted (riedl 12.3)\n if (!policy.authorities.includes(url.host)) return { url: raw, suppressed: 'authority', eventType: event.eventType }\n // Append without re-encoding the capability URL's own query; a fragment stays last.\n if (params.length > 0) url.search = url.search ? `${url.search}&${params.join('&')}` : `?${params.join('&')}`\n return { url: url.href, sendAtMs: nowMs + delay, eventType: event.eventType }\n })\n}\n"],
|
|
5
5
|
"mappings": ";AA8BA,IAAM,aAAa;AAIZ,SAAS,cAAc,OAAqB,QAAwB,OAAe,SAAuB,KAAK,QAAwB;AAC5I,QAAM,WAAW,OAAO,WAAW,KAAK,EAAE,OAAO,aAAa,CAAC,GAAG,SAAS,MAAM,SAAS;AAC1F,QAAM,QAAQ,WAAW,KAAK,MAAM,OAAO,IAAI,OAAO,QAAQ,IAAI;AAClE,QAAM,SAAmB,CAAC;AAC1B,MAAI,OAAO,SAAU,QAAO,KAAK,GAAG,mBAAmB,OAAO,SAAS,KAAK,CAAC,IAAI,mBAAmB,OAAO,SAAS,KAAK,CAAC,EAAE;AAC5H,MAAI,OAAO,kBAAkB,SAAU,QAAO,KAAK,GAAG,mBAAmB,OAAO,cAAc,CAAC,IAAI,KAAK,EAAE;AAE1G,QAAM,MAAM,OAAO;AACnB,QAAM,MAAM,QAAQ,UAAa,OAAO,SAAS,GAAG,KAAK,OAAO,IAAI,MAAM;AAC1E,SAAO,MAAM,KAAK,IAAI,CAAC,KAAK,MAAoB;AAC9C,QAAI,KAAK,IAAK,QAAO,EAAE,KAAK,KAAK,YAAY,OAAO,WAAW,MAAM,UAAU;AAE/E,QAAI,WAAW,KAAK,GAAG,EAAG,QAAO,EAAE,KAAK,KAAK,YAAY,SAAS,WAAW,MAAM,UAAU;AAC7F,UAAM,MAAM,IAAI,IAAI,GAAG;AACvB,QAAI,CAAC,OAAO,YAAY,SAAS,IAAI,IAAI,EAAG,QAAO,EAAE,KAAK,KAAK,YAAY,aAAa,WAAW,MAAM,UAAU;AAEnH,QAAI,OAAO,SAAS,EAAG,KAAI,SAAS,IAAI,SAAS,GAAG,IAAI,MAAM,IAAI,OAAO,KAAK,GAAG,CAAC,KAAK,IAAI,OAAO,KAAK,GAAG,CAAC;AAC3G,WAAO,EAAE,KAAK,IAAI,MAAM,UAAU,QAAQ,OAAO,WAAW,MAAM,UAAU;AAAA,EAC9E,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/** kid -> raw 32-byte Ed25519 public key: one channel's JWK Set (riedl 4.5). */
|
|
2
2
|
export type AdCreativeKeys = ReadonlyMap<string, Uint8Array>;
|
|
3
|
-
export type AdSigVerdict = 'verified' | 'unsigned' | 'sig' | 'alg' | 'kid' | 'signature';
|
|
3
|
+
export type AdSigVerdict = 'verified' | 'unsigned' | 'sig' | 'alg' | 'kid' | 'signature' | 'iat';
|
|
4
|
+
/** riedl 4.5: a maximum age for records, provisioned with the key set. Without maxAgeS, iat is ignored. */
|
|
5
|
+
export interface AdSigMaxAge {
|
|
6
|
+
/** Seconds a record's iat may lie behind now. */
|
|
7
|
+
readonly maxAgeS?: number;
|
|
8
|
+
/** Seconds iat may lie ahead of now, "the clock difference the deployment allows" (riedl 4.5). Default 30. */
|
|
9
|
+
readonly maxSkewS?: number;
|
|
10
|
+
/** Unix ms. A deployment's time reference where device clocks are unreliable (riedl 4.5). Default Date.now. */
|
|
11
|
+
readonly now?: () => number;
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* The host-provisioned JWK Set (RFC 7517): OKP/Ed25519 public keys by kid (RFC 8037). This set is
|
|
6
15
|
* the only key source; jku, jwk, x5u and x5c in a header are never read (riedl 4.5). Never throws:
|
|
@@ -12,7 +21,7 @@ export declare function importAdCreativeJwks(jwks: unknown, kids?: readonly stri
|
|
|
12
21
|
/** RFC 8785 for JSON.parse output: riedl's reference canonicalize() (scripts/sign-record.mjs at 443f90b2). */
|
|
13
22
|
export declare function canonicalJson(value: unknown): string;
|
|
14
23
|
/** riedl 4.5 for one record as parsed from JSON: the verification entry point. */
|
|
15
|
-
export declare function verifyAdCreativeSig(record: Readonly<Record<string, unknown>>, keys: AdCreativeKeys): AdSigVerdict;
|
|
24
|
+
export declare function verifyAdCreativeSig(record: Readonly<Record<string, unknown>>, keys: AdCreativeKeys, maxAge?: AdSigMaxAge): AdSigVerdict;
|
|
16
25
|
export declare const AD_CREATIVE_EVENT_TYPE = "urn:svta:advertising-wg:ad-creative-signaling";
|
|
17
26
|
/** riedl 12.3 size limit. An Object of two signed pods is about 4.4 KB. */
|
|
18
27
|
export declare const AD_OBJECT_MAX_BYTES = 65536;
|
|
@@ -59,7 +68,7 @@ export interface AdObjectResult {
|
|
|
59
68
|
readonly records: readonly AdRecordResult[];
|
|
60
69
|
}
|
|
61
70
|
/** One record: riedl 4.1 and 4.3 rules, 12.3 limits, SVTA flags, then the 4.5 signature. */
|
|
62
|
-
export declare function parseAdCreativeRecord(value: unknown, keys: AdCreativeKeys): AdRecordResult;
|
|
71
|
+
export declare function parseAdCreativeRecord(value: unknown, keys: AdCreativeKeys, maxAge?: AdSigMaxAge): AdRecordResult;
|
|
63
72
|
/** One MoQ Object of the track (msf-01 8.1: a JSON array of records). A gzip Object (MSF_COMPRESSION, msf 12.1) is not inflated here, so it drops as 'utf8' or 'json'. */
|
|
64
|
-
export declare function parseAdCreativeObject(bytes: Uint8Array, keys: AdCreativeKeys): AdObjectResult;
|
|
73
|
+
export declare function parseAdCreativeObject(bytes: Uint8Array, keys: AdCreativeKeys, maxAge?: AdSigMaxAge): AdObjectResult;
|
|
65
74
|
//# sourceMappingURL=ad-creative-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ad-creative-record.d.ts","sourceRoot":"","sources":["../src/ad-creative-record.ts"],"names":[],"mappings":"AASA,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAC5D,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"ad-creative-record.d.ts","sourceRoot":"","sources":["../src/ad-creative-record.ts"],"names":[],"mappings":"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"}
|
|
@@ -2121,7 +2121,7 @@ function canonicalJson(value) {
|
|
|
2121
2121
|
if (typeof value === "number" && !Number.isFinite(value)) throw new RangeError("RFC 8785 has no non-finite numbers");
|
|
2122
2122
|
return JSON.stringify(value);
|
|
2123
2123
|
}
|
|
2124
|
-
function checkJws(sig, canonical, keys) {
|
|
2124
|
+
function checkJws(sig, canonical, keys, maxAge) {
|
|
2125
2125
|
if (sig === void 0) return "unsigned";
|
|
2126
2126
|
const parts = typeof sig === "string" ? DETACHED_JWS.exec(sig) : null;
|
|
2127
2127
|
if (!parts) return "sig";
|
|
@@ -2143,15 +2143,19 @@ function checkJws(sig, canonical, keys) {
|
|
|
2143
2143
|
if (!key) return "kid";
|
|
2144
2144
|
try {
|
|
2145
2145
|
const input = ENCODER.encode(`${protectedB64}.${canonical}`);
|
|
2146
|
-
|
|
2146
|
+
if (!ed25519.verify(signature, input, key, { zip215: false })) return "signature";
|
|
2147
2147
|
} catch {
|
|
2148
2148
|
return "signature";
|
|
2149
2149
|
}
|
|
2150
|
+
if (maxAge.maxAgeS === void 0) return "verified";
|
|
2151
|
+
const iat = header["iat"];
|
|
2152
|
+
const aheadMs = typeof iat === "number" ? iat * 1e3 - (maxAge.now ?? Date.now)() : NaN;
|
|
2153
|
+
return aheadMs <= (maxAge.maxSkewS ?? 30) * 1e3 && -aheadMs <= maxAge.maxAgeS * 1e3 ? "verified" : "iat";
|
|
2150
2154
|
}
|
|
2151
|
-
function verifyAdCreativeSig(record, keys) {
|
|
2155
|
+
function verifyAdCreativeSig(record, keys, maxAge = {}) {
|
|
2152
2156
|
const unsigned = { ...record };
|
|
2153
2157
|
delete unsigned["sig"];
|
|
2154
|
-
return checkJws(record["sig"], canonicalJson(unsigned), keys);
|
|
2158
|
+
return checkJws(record["sig"], canonicalJson(unsigned), keys, maxAge);
|
|
2155
2159
|
}
|
|
2156
2160
|
var AD_CREATIVE_EVENT_TYPE = "urn:svta:advertising-wg:ad-creative-signaling";
|
|
2157
2161
|
var AD_OBJECT_MAX_BYTES = 65536;
|
|
@@ -2198,17 +2202,24 @@ var isHttpsUrl = (value) => {
|
|
|
2198
2202
|
}
|
|
2199
2203
|
};
|
|
2200
2204
|
var allHttps = (value) => typeof value === "string" ? isHttpsUrl(value) : typeof value !== "object" || value === null || (Array.isArray(value) ? value : Object.values(value)).every(allHttps);
|
|
2201
|
-
|
|
2202
|
-
|
|
2205
|
+
var CHILDREN = {
|
|
2206
|
+
pod: [["tracking", "trackingEvent"], ["slots", "slot"]],
|
|
2207
|
+
slot: [["tracking", "trackingEvent"], ["verifications", "verification"]],
|
|
2208
|
+
trackingEvent: [],
|
|
2209
|
+
verification: []
|
|
2210
|
+
};
|
|
2211
|
+
function httpsOnly(kind, value) {
|
|
2203
2212
|
if (!isObject(value)) return true;
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2213
|
+
if ("$remote" in value && !allHttps(value["$remote"])) return false;
|
|
2214
|
+
const urls = value["urls"];
|
|
2215
|
+
if (kind === "trackingEvent" && "urls" in value && !(Array.isArray(urls) && urls.every(isHttpsUrl))) return false;
|
|
2216
|
+
if (kind === "verification" && "resource" in value && !isHttpsUrl(value["resource"])) return false;
|
|
2217
|
+
return CHILDREN[kind].every(([name, child]) => {
|
|
2218
|
+
const list = value[name];
|
|
2219
|
+
return !(name in value) || Array.isArray(list) && list.every((item) => httpsOnly(child, item));
|
|
2209
2220
|
});
|
|
2210
2221
|
}
|
|
2211
|
-
function parseAdCreativeRecord(value, keys) {
|
|
2222
|
+
function parseAdCreativeRecord(value, keys, maxAge = {}) {
|
|
2212
2223
|
if (!isObject(value)) return { verdict: "shape" };
|
|
2213
2224
|
if (!depthWithin(value, AD_JSON_MAX_DEPTH)) return { verdict: "depth" };
|
|
2214
2225
|
const index = indexOf(value);
|
|
@@ -2218,7 +2229,7 @@ function parseAdCreativeRecord(value, keys) {
|
|
|
2218
2229
|
if (!isObject(data)) return { verdict: "data", key };
|
|
2219
2230
|
const envelope = envelopeOf(data);
|
|
2220
2231
|
if (!envelope) return { verdict: "envelope", key };
|
|
2221
|
-
if (!httpsOnly(
|
|
2232
|
+
if (!envelope.payload.every((item) => httpsOnly(envelope.type, item))) return { verdict: "url", key };
|
|
2222
2233
|
if (Object.entries(envelope.features ?? {}).some(([name, on]) => on && !SUPPORTED_FEATURES.has(name))) {
|
|
2223
2234
|
return { verdict: "feature", key };
|
|
2224
2235
|
}
|
|
@@ -2234,10 +2245,10 @@ function parseAdCreativeRecord(value, keys) {
|
|
|
2234
2245
|
return { verdict: "number", key };
|
|
2235
2246
|
}
|
|
2236
2247
|
const record = { index, key, data: envelope, canonical };
|
|
2237
|
-
const verdict = checkJws(value["sig"], record.canonical, keys);
|
|
2248
|
+
const verdict = checkJws(value["sig"], record.canonical, keys, maxAge);
|
|
2238
2249
|
return verdict === "verified" || verdict === "unsigned" || verdict === "kid" ? { verdict, key, record } : { verdict, key };
|
|
2239
2250
|
}
|
|
2240
|
-
function parseAdCreativeObject(bytes, keys) {
|
|
2251
|
+
function parseAdCreativeObject(bytes, keys, maxAge = {}) {
|
|
2241
2252
|
if (bytes.byteLength > AD_OBJECT_MAX_BYTES) return { verdict: "size", records: [] };
|
|
2242
2253
|
let text2;
|
|
2243
2254
|
try {
|
|
@@ -2253,7 +2264,7 @@ function parseAdCreativeObject(bytes, keys) {
|
|
|
2253
2264
|
}
|
|
2254
2265
|
if (!Array.isArray(doc)) return { verdict: "not-array", records: [] };
|
|
2255
2266
|
if (doc.length > AD_OBJECT_MAX_RECORDS) return { verdict: "count", records: [] };
|
|
2256
|
-
return { verdict: "accepted", records: doc.map((record) => parseAdCreativeRecord(record, keys)) };
|
|
2267
|
+
return { verdict: "accepted", records: doc.map((record) => parseAdCreativeRecord(record, keys, maxAge)) };
|
|
2257
2268
|
}
|
|
2258
2269
|
export {
|
|
2259
2270
|
AD_CREATIVE_EVENT_TYPE,
|