@full-self-browsing/phantom-stream 0.1.0 → 0.2.1
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/types/adapters/extension.d.ts.map +1 -1
- package/dist/types/adapters/playwright.d.ts.map +1 -1
- package/dist/types/capture/index.d.ts +112 -0
- package/dist/types/capture/index.d.ts.map +1 -1
- package/dist/types/protocol/constants.d.ts +22 -0
- package/dist/types/protocol/constants.d.ts.map +1 -1
- package/dist/types/protocol/index.d.ts +1 -0
- package/dist/types/protocol/media-reconcile.d.ts +53 -0
- package/dist/types/protocol/media-reconcile.d.ts.map +1 -0
- package/dist/types/protocol/messages.d.ts +266 -2
- package/dist/types/protocol/messages.d.ts.map +1 -1
- package/dist/types/renderer/asset-policy.d.ts +72 -0
- package/dist/types/renderer/asset-policy.d.ts.map +1 -0
- package/dist/types/renderer/diff.d.ts.map +1 -1
- package/dist/types/renderer/index.d.ts +13 -0
- package/dist/types/renderer/index.d.ts.map +1 -1
- package/dist/types/renderer/media-player.d.ts +114 -0
- package/dist/types/renderer/media-player.d.ts.map +1 -0
- package/dist/types/renderer/overlays.d.ts +12 -0
- package/dist/types/renderer/overlays.d.ts.map +1 -1
- package/dist/types/renderer/sanitize.d.ts +22 -0
- package/dist/types/renderer/sanitize.d.ts.map +1 -1
- package/dist/types/renderer/snapshot.d.ts +38 -0
- package/dist/types/renderer/snapshot.d.ts.map +1 -1
- package/dist/types/transport/websocket.d.ts.map +1 -1
- package/docs/ARCHITECTURE.md +13 -4
- package/docs/SECURITY.md +233 -2
- package/examples/bookmarklet-demo/viewer.html +12 -3
- package/examples/extension-mv3/viewer.html +10 -3
- package/package.json +9 -1
- package/src/adapters/extension.js +202 -7
- package/src/adapters/playwright-inject.js +50 -0
- package/src/adapters/playwright.js +159 -0
- package/src/capture/index.js +1071 -11
- package/src/protocol/constants.js +24 -0
- package/src/protocol/index.js +1 -0
- package/src/protocol/media-reconcile.js +188 -0
- package/src/protocol/messages.js +145 -2
- package/src/renderer/asset-policy.js +172 -0
- package/src/renderer/diff.js +106 -2
- package/src/renderer/index.js +849 -9
- package/src/renderer/media-player.js +367 -0
- package/src/renderer/overlays.js +324 -0
- package/src/renderer/sanitize.js +25 -3
- package/src/renderer/snapshot.js +534 -3
- package/src/transport/websocket.js +36 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../src/adapters/extension.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../src/adapters/extension.js"],"names":[],"mappings":"AAkIA;;;;;;;;;;;;;;;;GAgBG;AACH,gDAbG;IAAwB,MAAM;IAC4B,SAAS,GAA3D;QAAC,IAAI,CAAC,WAAW;QAAC,SAAS,CAAC,WAAU;KAAC;IACtB,SAAS,GAA1B,MAAM;IACW,UAAU,GAA3B,MAAM;IACW,MAAM;IACJ,GAAG;CAC9B,GAAU;IACR,OAAO,EAAE,MAAM,OAAO,KAAQ,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,KAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,eAAe,EAAE,MAAM,MAAO,IAAI,CAAA;CACnC,CAuWH;AAED;;;;;GAKG;AACH,gDAFa,MAAM,CAMlB;AA7fD,2CAA4C,wBAAwB,CAAC;AACrE,wCAAyC,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../../src/adapters/playwright.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../../src/adapters/playwright.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,yDAFa,MAAM,CAIlB;AA6BD;;;;;GAKG;AACH,2DAunBC"}
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify an asset URL by FETCHABILITY (Phase 12 ASST-04). This is a control
|
|
3
|
+
* distinct from hasDangerousScheme (injection): a URL can be injection-safe yet
|
|
4
|
+
* non-shareable as a mirrored reference. Two non-shareable classes degrade to a
|
|
5
|
+
* dimensioned placeholder at capture so a dead/blob reference never reaches the
|
|
6
|
+
* wire and one giant inline image cannot blow the per-message cap:
|
|
7
|
+
* - `blob:`/origin-local object URLs (always non-shareable -- they are
|
|
8
|
+
* origin-local and dead at the cross-origin viewer);
|
|
9
|
+
* - `data:` URIs whose UTF-8 byte length exceeds `capBytes`.
|
|
10
|
+
* Everything else (http/https, small inline `data:`, relative URLs that
|
|
11
|
+
* absolutify) is shareable and passes through untouched -- benign small `data:`
|
|
12
|
+
* icons stay byte-identical (Pitfall 5: no over-degrade).
|
|
13
|
+
* @param {string} url the (resolved or raw) asset reference
|
|
14
|
+
* @param {number} capBytes byte cap for inline `data:` (ASSET_DATA_URI_MAX_BYTES)
|
|
15
|
+
* @returns {{ok: true}|{ok: false, reason: 'blob'|'oversized-data'}}
|
|
16
|
+
*/
|
|
17
|
+
export function classifyAssetRef(url: string, capBytes: number): {
|
|
18
|
+
ok: true;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: "blob" | "oversized-data";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Pure predicate (Phase 12 ASST-03): true only when a resolved `currentSrc`
|
|
25
|
+
* is present AND differs from the resolved plain `src`, i.e. a responsive
|
|
26
|
+
* `srcset`/`<picture>` actually negotiated a non-default variant worth pinning.
|
|
27
|
+
* Empty `currentSrc` (jsdom returns "") never enriches; an equal value never
|
|
28
|
+
* enriches (plain `<img src>` stays byte-identical on the wire).
|
|
29
|
+
* @param {string} resolvedCurrentSrc absolutified currentSrc
|
|
30
|
+
* @param {string} resolvedSrc absolutified src
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
33
|
+
export function currentSrcDiffers(resolvedCurrentSrc: string, resolvedSrc: string): boolean;
|
|
1
34
|
/**
|
|
2
35
|
* The host-injected message sink. `send` mirrors the fire-and-forget
|
|
3
36
|
* semantics of the reference's messaging call: the capture core never awaits
|
|
@@ -80,6 +113,31 @@
|
|
|
80
113
|
* @property {(text: string, element: Element) => string} [maskInputFn]
|
|
81
114
|
* Optional (SEC-03). Custom input-value mask (rrweb signature). Same
|
|
82
115
|
* fail-closed containment as maskTextFn.
|
|
116
|
+
* @property {string} [maskMediaSelector]
|
|
117
|
+
* Optional (MSEC-03). CSS selector: matching <video>/<audio>/asset elements
|
|
118
|
+
* omit their URL from the wire and degrade to the dimension-only block
|
|
119
|
+
* placeholder (the blockSelector placeholder path), AND emit NO STREAM.MEDIA
|
|
120
|
+
* state (the media-tracker skip predicates also gate on this selector). The
|
|
121
|
+
* privacy control for "mirror nothing about this media -- not its URL, not
|
|
122
|
+
* its playback timeline." Invalid selectors THROW Error('invalid-mask-
|
|
123
|
+
* selector') at factory time, exactly like blockSelector/maskTextSelector.
|
|
124
|
+
* @property {boolean} [maskAssetUrls]
|
|
125
|
+
* Optional (MSEC-03), default false. When true, strip a documented token/PII
|
|
126
|
+
* query-param denylist (AWS SigV4/SigV2, GCP signed-URL, Azure SAS, and a
|
|
127
|
+
* generic token/secret/auth set -- case-insensitive, exact-name OR denied
|
|
128
|
+
* prefix) from asset/media URLs before the wire. Functional params (w, h, q,
|
|
129
|
+
* format, v, id, t, ...) survive. A URL with no denylisted param is emitted
|
|
130
|
+
* BYTE-IDENTICAL (the original string, never URL.toString() normalization),
|
|
131
|
+
* so off-by-default keeps the wire byte-identical (the differential oracle is
|
|
132
|
+
* unaffected). See TOKEN_PARAM_DENYLIST + docs/SECURITY.md for the exact list.
|
|
133
|
+
* @property {(url: string, ctx: {attr: string, tag: string, nid: string, kind: ('image'|'media')}) => (string|null)} [maskAssetUrlFn]
|
|
134
|
+
* Optional (MSEC-03). Custom asset/media URL redactor; takes precedence over
|
|
135
|
+
* maskAssetUrls. A returned string replaces the URL on the wire; null BLOCKS
|
|
136
|
+
* the URL (the attribute is removed -> the viewer never fetches it); a THROW
|
|
137
|
+
* FAILS CLOSED -> block (logged, treated as null -- never raised, never the
|
|
138
|
+
* raw URL). Stricter than maskTextFn: a thrown text mask falls back to the
|
|
139
|
+
* asterisk default, but a thrown URL redactor blocks (a half-redacted URL
|
|
140
|
+
* that the viewer then fetches is worse than no URL).
|
|
83
141
|
*/
|
|
84
142
|
/**
|
|
85
143
|
* @typedef {Object} CaptureHandle
|
|
@@ -104,6 +162,24 @@
|
|
|
104
162
|
* @returns {CaptureHandle}
|
|
105
163
|
*/
|
|
106
164
|
export function createCapture(config: CaptureOptions): CaptureHandle;
|
|
165
|
+
/**
|
|
166
|
+
* Serialize ONE snapshot of the given document and return the snapshot payload
|
|
167
|
+
* (`{ html, nodeIds, ... }`). A convenience top-level entry that swaps the
|
|
168
|
+
* ambient globals from `doc.defaultView` for the lifetime of one serialization
|
|
169
|
+
* (mirroring the differential harness's createExtractedSide), runs a fresh
|
|
170
|
+
* capture's serializer against it, and restores the globals unconditionally.
|
|
171
|
+
*
|
|
172
|
+
* This is the no-observer path used by the capture-asset-degrade unit tests to
|
|
173
|
+
* prove the clone-only currentSrc enrichment and the blob:/oversized-data:
|
|
174
|
+
* placeholder degrade WITHOUT mutating the live document.
|
|
175
|
+
*
|
|
176
|
+
* @param {Document} doc the document to snapshot (must have a defaultView)
|
|
177
|
+
* @returns {{html: string, nodeIds: string[]}} the snapshot payload
|
|
178
|
+
*/
|
|
179
|
+
export function serializeSnapshot(doc: Document): {
|
|
180
|
+
html: string;
|
|
181
|
+
nodeIds: string[];
|
|
182
|
+
};
|
|
107
183
|
/**
|
|
108
184
|
* The host-injected message sink. `send` mirrors the fire-and-forget
|
|
109
185
|
* semantics of the reference's messaging call: the capture core never awaits
|
|
@@ -213,6 +289,42 @@ export type CaptureOptions = {
|
|
|
213
289
|
* fail-closed containment as maskTextFn.
|
|
214
290
|
*/
|
|
215
291
|
maskInputFn?: (text: string, element: Element) => string;
|
|
292
|
+
/**
|
|
293
|
+
* Optional (MSEC-03). CSS selector: matching <video>/<audio>/asset elements
|
|
294
|
+
* omit their URL from the wire and degrade to the dimension-only block
|
|
295
|
+
* placeholder (the blockSelector placeholder path), AND emit NO STREAM.MEDIA
|
|
296
|
+
* state (the media-tracker skip predicates also gate on this selector). The
|
|
297
|
+
* privacy control for "mirror nothing about this media -- not its URL, not
|
|
298
|
+
* its playback timeline." Invalid selectors THROW Error('invalid-mask-
|
|
299
|
+
* selector') at factory time, exactly like blockSelector/maskTextSelector.
|
|
300
|
+
*/
|
|
301
|
+
maskMediaSelector?: string;
|
|
302
|
+
/**
|
|
303
|
+
* Optional (MSEC-03), default false. When true, strip a documented token/PII
|
|
304
|
+
* query-param denylist (AWS SigV4/SigV2, GCP signed-URL, Azure SAS, and a
|
|
305
|
+
* generic token/secret/auth set -- case-insensitive, exact-name OR denied
|
|
306
|
+
* prefix) from asset/media URLs before the wire. Functional params (w, h, q,
|
|
307
|
+
* format, v, id, t, ...) survive. A URL with no denylisted param is emitted
|
|
308
|
+
* BYTE-IDENTICAL (the original string, never URL.toString() normalization),
|
|
309
|
+
* so off-by-default keeps the wire byte-identical (the differential oracle is
|
|
310
|
+
* unaffected). See TOKEN_PARAM_DENYLIST + docs/SECURITY.md for the exact list.
|
|
311
|
+
*/
|
|
312
|
+
maskAssetUrls?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Optional (MSEC-03). Custom asset/media URL redactor; takes precedence over
|
|
315
|
+
* maskAssetUrls. A returned string replaces the URL on the wire; null BLOCKS
|
|
316
|
+
* the URL (the attribute is removed -> the viewer never fetches it); a THROW
|
|
317
|
+
* FAILS CLOSED -> block (logged, treated as null -- never raised, never the
|
|
318
|
+
* raw URL). Stricter than maskTextFn: a thrown text mask falls back to the
|
|
319
|
+
* asterisk default, but a thrown URL redactor blocks (a half-redacted URL
|
|
320
|
+
* that the viewer then fetches is worse than no URL).
|
|
321
|
+
*/
|
|
322
|
+
maskAssetUrlFn?: (url: string, ctx: {
|
|
323
|
+
attr: string;
|
|
324
|
+
tag: string;
|
|
325
|
+
nid: string;
|
|
326
|
+
kind: ("image" | "media");
|
|
327
|
+
}) => (string | null);
|
|
216
328
|
};
|
|
217
329
|
export type CaptureHandle = {
|
|
218
330
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/capture/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/capture/index.js"],"names":[],"mappings":"AA8NA;;;;;;;;;;;;;;;GAeG;AACH,sCAJW,MAAM,YACN,MAAM,GACJ;IAAC,EAAE,EAAE,IAAI,CAAA;CAAC,GAAC;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,GAAC,gBAAgB,CAAA;CAAC,CAkBnE;AAED;;;;;;;;;GASG;AACH,sDAJW,MAAM,eACN,MAAM,GACJ,OAAO,CAMnB;AA2JD;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AACH,sCAHW,cAAc,GACZ,aAAa,CAisJzB;AAYD;;;;;;;;;;;;;GAaG;AACH,uCAHW,QAAQ,GACN;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAC,CAqC7C;;;;;;;;;;;;;;;;UAx3Ja,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,KAAQ,KAAK,IAAI;;;;;YAGvC,MAAM,IAAI;;;UAOV,CAAC,GAAG,IAAI,EAAE,GAAC,KAAK,IAAI;UACpB,CAAC,GAAG,IAAI,EAAE,GAAC,KAAK,IAAI;WACpB,CAAC,GAAG,IAAI,EAAE,GAAC,KAAK,IAAI;;;;;;;;;;;;;;;WAYpB,MAAO,IAAI;;;;eACX,MAAO,IAAI;;;;;;;;eAKX,SAAS;;;;aAIT,aAAa;;;;;;;;;sBAEb,CAAC,MAAM,YAAY,GAAC,IAAI,CAAC;;;;;;;;;;kBAOzB,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO;;;;;;;;;;oBAQxB,MAAM;;;;;;;uBAQN,MAAM;;;;;;iBAKN,OAAO;;;;;iBAIP,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM;;;;;kBAG1C,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM;;;;;;;;;;wBAG1C,MAAM;;;;;;;;;;;oBAQN,OAAO;;;;;;;;;;qBASP,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,OAAO,GAAC,OAAO,CAAC,CAAA;KAAC,KAAK,CAAC,MAAM,GAAC,IAAI,CAAC;;;;;;WAYtG,MAAM,IAAI;;;;UACV,MAAM,IAAI;;;;WACV,MAAM,IAAI;;;;YACV,MAAM,IAAI;;;;;;eACV,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAC,IAAI"}
|
|
@@ -18,6 +18,17 @@ export const SNAPSHOT_BUDGET_BYTES: number;
|
|
|
18
18
|
export const TRUNCATION_VIEWPORT_MULTIPLIER: 3;
|
|
19
19
|
/** Scroll side-channel throttle: at most one event per this many ms. */
|
|
20
20
|
export const SCROLL_THROTTLE_MS: 200;
|
|
21
|
+
/**
|
|
22
|
+
* Media side-channel heartbeat throttle: while a tracked <video>/<audio> is
|
|
23
|
+
* playing, a `timeupdate` heartbeat (STREAM.MEDIA) is emitted at most once per
|
|
24
|
+
* this many ms for drift correction. 250 ms is a practice-based co-watching
|
|
25
|
+
* cadence (~4 Hz) -- frequent enough for the reconciler to converge sub-second
|
|
26
|
+
* drift, sparse enough to stay well under the relay cap. Discrete transitions
|
|
27
|
+
* (play/pause/seeked/ratechange/ended/volumechange/loadedmetadata) bypass this
|
|
28
|
+
* throttle and flush immediately; the value is tunable against the v2.1
|
|
29
|
+
* evaluation harness (Phase 13 concern).
|
|
30
|
+
*/
|
|
31
|
+
export const MEDIA_SYNC_THROTTLE_MS: 250;
|
|
21
32
|
/** Overlay side-channel throttle: at most one broadcast per this many ms. */
|
|
22
33
|
export const OVERLAY_THROTTLE_MS: 500;
|
|
23
34
|
/**
|
|
@@ -32,4 +43,15 @@ export const READY_PROBE_INTERVAL_MS: 200;
|
|
|
32
43
|
export const READY_PROBE_BUDGET_MS: 5000;
|
|
33
44
|
/** Inline <style> tags larger than this are skipped during snapshot capture. */
|
|
34
45
|
export const INLINE_STYLE_MAX_BYTES: 500000;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum UTF-8 byte length of an inline `data:` image URI that capture will
|
|
48
|
+
* emit verbatim on the wire. 262144 = 256 KiB -- roughly a quarter of the
|
|
49
|
+
* per-message cap headroom (SNAPSHOT_BUDGET_BYTES is ~838 KiB, the 80%
|
|
50
|
+
* truncation budget of the 1 MiB relay cap), so a single inline asset cannot
|
|
51
|
+
* crowd out the rest of the snapshot. A `data:` image larger than this degrades
|
|
52
|
+
* to a dimensioned placeholder; small inline icons/sprites (<= cap) pass through
|
|
53
|
+
* byte-identical, preserving the existing `data:image/*` pass-through and the
|
|
54
|
+
* differential oracle. (Phase 12 ASST-04.)
|
|
55
|
+
*/
|
|
56
|
+
export const ASSET_DATA_URI_MAX_BYTES: 262144;
|
|
35
57
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/protocol/constants.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH,4CAA6C,OAAO,CAAC;AAErD;;;;GAIG;AACH,uCAAwC,GAAG,CAAC;AAE5C,uCAAuC;AACvC,2CAEE;AAEF;;;GAGG;AACH,6CAA8C,CAAC,CAAC;AAEhD,wEAAwE;AACxE,iCAAkC,GAAG,CAAC;AAEtC,6EAA6E;AAC7E,kCAAmC,GAAG,CAAC;AAEvC;;;GAGG;AACH,0CAA2C,IAAI,CAAC;AAEhD,0CAA0C;AAC1C,+BAAgC,GAAG,CAAC;AAEpC,uDAAuD;AACvD,sCAAuC,GAAG,CAAC;AAC3C,oCAAqC,IAAI,CAAC;AAE1C,gFAAgF;AAChF,qCAAsC,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/protocol/constants.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH,4CAA6C,OAAO,CAAC;AAErD;;;;GAIG;AACH,uCAAwC,GAAG,CAAC;AAE5C,uCAAuC;AACvC,2CAEE;AAEF;;;GAGG;AACH,6CAA8C,CAAC,CAAC;AAEhD,wEAAwE;AACxE,iCAAkC,GAAG,CAAC;AAEtC;;;;;;;;;GASG;AACH,qCAAsC,GAAG,CAAC;AAE1C,6EAA6E;AAC7E,kCAAmC,GAAG,CAAC;AAEvC;;;GAGG;AACH,0CAA2C,IAAI,CAAC;AAEhD,0CAA0C;AAC1C,+BAAgC,GAAG,CAAC;AAEpC,uDAAuD;AACvD,sCAAuC,GAAG,CAAC;AAC3C,oCAAqC,IAAI,CAAC;AAE1C,gFAAgF;AAChF,qCAAsC,MAAM,CAAC;AAE7C;;;;;;;;;GASG;AACH,uCAAwC,MAAM,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decide the single drift-correction action for one media element.
|
|
3
|
+
*
|
|
4
|
+
* Decision order (RESEARCH Pattern 1, exact):
|
|
5
|
+
* merge cfg -> incomplete-remote guard -> explicit `seeked` short-circuit ->
|
|
6
|
+
* paused/rate-0 -> NaN local guard -> latency-compensated `expected` (elapsed
|
|
7
|
+
* clamped >= 0) -> LIVE branch (before any duration math) -> VOD: loop-wrap ->
|
|
8
|
+
* hold band (carries revertRate) -> bounded sign-correct nudge (carries
|
|
9
|
+
* baseRate) -> hard-seek (clamp toTime into [0, duration]).
|
|
10
|
+
*
|
|
11
|
+
* @param {{currentTime?: number, paused?: boolean, playbackRate?: number}} local Observed element state
|
|
12
|
+
* @param {import('./messages.js').MediaSyncPayload|null} remote Latency-uncompensated captured state
|
|
13
|
+
* @param {number} now Caller clock (ms), e.g. performance.now()-equivalent
|
|
14
|
+
* @param {Partial<MediaReconcileConfig>} [config] Overrides merged over DEFAULT_MEDIA_RECONCILE_CONFIG
|
|
15
|
+
* @returns {{action:'hold'|'pause'|'nudge'|'seek'|'rejoin-edge', toTime?:number, rate?:number, baseRate?:number, revertRate?:number, reason?:string}}
|
|
16
|
+
*/
|
|
17
|
+
export function reconcileMediaDrift(local: {
|
|
18
|
+
currentTime?: number;
|
|
19
|
+
paused?: boolean;
|
|
20
|
+
playbackRate?: number;
|
|
21
|
+
}, remote: import("./messages.js").MediaSyncPayload | null, now: number, config?: Partial<MediaReconcileConfig>): {
|
|
22
|
+
action: "hold" | "pause" | "nudge" | "seek" | "rejoin-edge";
|
|
23
|
+
toTime?: number;
|
|
24
|
+
rate?: number;
|
|
25
|
+
baseRate?: number;
|
|
26
|
+
revertRate?: number;
|
|
27
|
+
reason?: string;
|
|
28
|
+
};
|
|
29
|
+
export namespace DEFAULT_MEDIA_RECONCILE_CONFIG {
|
|
30
|
+
let holdBandSec: number;
|
|
31
|
+
let hardSeekSec: number;
|
|
32
|
+
let maxNudgeFraction: number;
|
|
33
|
+
let liveRejoinSec: number;
|
|
34
|
+
}
|
|
35
|
+
export type MediaReconcileConfig = {
|
|
36
|
+
/**
|
|
37
|
+
* In-tolerance band (s); within this, hold. Default 0.25
|
|
38
|
+
*/
|
|
39
|
+
holdBandSec: number;
|
|
40
|
+
/**
|
|
41
|
+
* Hard-seek threshold (s); above this, seek. Default 1.0
|
|
42
|
+
*/
|
|
43
|
+
hardSeekSec: number;
|
|
44
|
+
/**
|
|
45
|
+
* Max temporary rate delta (fraction). Default 0.05
|
|
46
|
+
*/
|
|
47
|
+
maxNudgeFraction: number;
|
|
48
|
+
/**
|
|
49
|
+
* Live-edge rejoin threshold (s). Default 1.0
|
|
50
|
+
*/
|
|
51
|
+
liveRejoinSec: number;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=media-reconcile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-reconcile.d.ts","sourceRoot":"","sources":["../../../src/protocol/media-reconcile.js"],"names":[],"mappings":"AAoGA;;;;;;;;;;;;;;;GAeG;AACH,2CANW;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAC,UAC/D,OAAO,eAAe,EAAE,gBAAgB,GAAC,IAAI,OAC7C,MAAM,WACN,OAAO,CAAC,oBAAoB,CAAC,GAC3B;IAAC,MAAM,EAAC,MAAM,GAAC,OAAO,GAAC,OAAO,GAAC,MAAM,GAAC,aAAa,CAAC;IAAC,MAAM,CAAC,EAAC,MAAM,CAAC;IAAC,IAAI,CAAC,EAAC,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAC,MAAM,CAAC;IAAC,UAAU,CAAC,EAAC,MAAM,CAAC;IAAC,MAAM,CAAC,EAAC,MAAM,CAAA;CAAC,CAyEpJ;;;;;;;;;;;iBArKa,MAAM;;;;iBACN,MAAM;;;;sBACN,MAAM;;;;mBACN,MAAM"}
|
|
@@ -77,7 +77,81 @@
|
|
|
77
77
|
* @property {string} nid
|
|
78
78
|
* @property {string} [value] Textual value for input/textarea/select-like controls
|
|
79
79
|
* @property {boolean} [checked] Checked state for checkbox/radio controls
|
|
80
|
-
* @property {string[]} [selectedValues] Selected option values for
|
|
80
|
+
* @property {string[]} [selectedValues] Selected option values for select controls (masked when maskInputs is on, so renderers must not treat these as a selection key)
|
|
81
|
+
* @property {number[]} [selectedIndexes] Authoritative positional identity of selected options; preferred over selectedValues because option indexes never carry page content and stay unambiguous under masking
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Captured live playback state of a single <video>/<audio> element, keyed by
|
|
85
|
+
* nid. Models the DIFF_OP.VALUE side-channel-property-state precedent: live
|
|
86
|
+
* media properties travel as side-channel data, never serialized into the HTML
|
|
87
|
+
* clone (preserves the Phase 7 no-mutation invariant + HTML byte-identity).
|
|
88
|
+
*
|
|
89
|
+
* Live/Infinity-duration encoding: `duration` is present ONLY when finite;
|
|
90
|
+
* non-finite (streaming) durations are encoded as `live: true` instead, never
|
|
91
|
+
* both. This sidesteps the JSON Infinity -> null trap (JSON.stringify(Infinity)
|
|
92
|
+
* === "null") so the reconciler can branch on `live` before any duration math
|
|
93
|
+
* and never compute NaN.
|
|
94
|
+
*
|
|
95
|
+
* @typedef {Object} MediaBaselineEntry
|
|
96
|
+
* @property {string} nid Element nid the playback state addresses
|
|
97
|
+
* @property {number} currentTime Playback position in seconds
|
|
98
|
+
* @property {boolean} paused Whether the element is paused
|
|
99
|
+
* @property {boolean} muted Whether audio output is muted
|
|
100
|
+
* @property {number} volume Audio volume in [0, 1]
|
|
101
|
+
* @property {number} playbackRate Effective playback rate (1 = normal)
|
|
102
|
+
* @property {boolean} loop Whether the element loops
|
|
103
|
+
* @property {boolean} ended Whether playback reached the end
|
|
104
|
+
* @property {number} [duration] Media duration in seconds; present ONLY when finite
|
|
105
|
+
* @property {boolean} [live] true when duration is non-finite (stream); mutually exclusive with duration
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* One STREAM.MEDIA wire message: a MediaBaselineEntry enriched with the event
|
|
109
|
+
* that triggered emission, a capture-side monotonic timestamp for latency
|
|
110
|
+
* compensation, and the stream identity stamps every side channel carries.
|
|
111
|
+
*
|
|
112
|
+
* The reconciler predicts the expected position from `currentTime`,
|
|
113
|
+
* `playbackRate`, and `(now - sentAt)`; `streamSessionId`/`snapshotId` let the
|
|
114
|
+
* renderer reject stale cross-generation frames via isCurrentStream (Plan 03).
|
|
115
|
+
* One message is emitted per media element per tick (scroll-like granularity).
|
|
116
|
+
*
|
|
117
|
+
* @typedef {Object} MediaSyncPayload
|
|
118
|
+
* @property {string} nid Element nid the playback state addresses
|
|
119
|
+
* @property {'play'|'pause'|'seeked'|'ratechange'|'ended'|'volumechange'|'loadedmetadata'|'timeupdate'} event Triggering media event
|
|
120
|
+
* @property {number} currentTime Playback position in seconds at capture
|
|
121
|
+
* @property {boolean} paused Whether the element is paused
|
|
122
|
+
* @property {boolean} muted Whether audio output is muted
|
|
123
|
+
* @property {number} volume Audio volume in [0, 1]
|
|
124
|
+
* @property {number} playbackRate Effective playback rate (1 = normal)
|
|
125
|
+
* @property {boolean} loop Whether the element loops
|
|
126
|
+
* @property {boolean} ended Whether playback reached the end
|
|
127
|
+
* @property {number} [duration] Media duration in seconds; present ONLY when finite
|
|
128
|
+
* @property {boolean} [live] true when duration is non-finite (stream); mutually exclusive with duration
|
|
129
|
+
* @property {number} sentAt Capture-side monotonic ms stamp for latency compensation
|
|
130
|
+
* @property {string} streamSessionId Identity: minted per stream session
|
|
131
|
+
* @property {number} snapshotId Identity: minted per snapshot
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* One adaptive-manifest discovery hint surfaced by an adapter's opt-in network
|
|
135
|
+
* observation (Playwright `page.on('response')` / extension `chrome.webRequest`).
|
|
136
|
+
* The hint originates in the ADAPTER, never the capture core, so it adds no
|
|
137
|
+
* capture-wire divergence (no differential-oracle entry); it rides the existing
|
|
138
|
+
* raw relay + 1 MiB cap with the envelope byte-unchanged, and old viewers ignore
|
|
139
|
+
* the unknown STREAM.MEDIA_HINT type via the renderer dispatch default.
|
|
140
|
+
*
|
|
141
|
+
* Addressing is nid-scoped when manifest->element correlation is confident, else
|
|
142
|
+
* page-scoped (nid omitted, scope 'page'); a page hint is matched to an
|
|
143
|
+
* MSE-opaque media element on play by the viewer. Identity-stamped like every
|
|
144
|
+
* side channel; the viewer re-gates `manifestUrl` through the same fail-closed
|
|
145
|
+
* origin policy before any use.
|
|
146
|
+
*
|
|
147
|
+
* @typedef {Object} MediaHintPayload
|
|
148
|
+
* @property {string} [nid] Element nid when correlation is confident; omitted for page-level
|
|
149
|
+
* @property {'page'|'element'} scope 'element' (nid set) or 'page' (viewer matches on play)
|
|
150
|
+
* @property {string} manifestUrl Absolute manifest URL (https; viewer re-gates before use)
|
|
151
|
+
* @property {'hls'|'dash'} kind Derived from URL extension and/or content-type
|
|
152
|
+
* @property {string} [contentType] Observed response content-type (diagnostic)
|
|
153
|
+
* @property {string} streamSessionId Identity: minted per stream session
|
|
154
|
+
* @property {number} snapshotId Identity: minted per snapshot
|
|
81
155
|
*/
|
|
82
156
|
/**
|
|
83
157
|
* @typedef {Object} SubtreeRequestPayload
|
|
@@ -159,6 +233,24 @@ export function isCurrentStream(msg: {
|
|
|
159
233
|
streamSessionId?: string;
|
|
160
234
|
snapshotId?: number;
|
|
161
235
|
}): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Pure manifest classifier: is an observed response an adaptive-streaming
|
|
238
|
+
* manifest, and of which kind? Returns `'hls'` for an `.m3u8` path OR an HLS
|
|
239
|
+
* content-type; `'dash'` for an `.mpd` path OR `application/dash+xml`; `null`
|
|
240
|
+
* otherwise. URL-OR-content-type: either signal is independently sufficient.
|
|
241
|
+
*
|
|
242
|
+
* Never throws (T-14-03): a malformed/hostile url string is a guarded `null`
|
|
243
|
+
* (or a regex-fallback classification when the extension is still discernible),
|
|
244
|
+
* so it can never wedge the adapter. Project convention: a pure helper returns
|
|
245
|
+
* a primitive, not the `{ok,...}` fallible shape.
|
|
246
|
+
*
|
|
247
|
+
* @param {{url?: string, contentType?: string}} [input]
|
|
248
|
+
* @returns {'hls'|'dash'|null}
|
|
249
|
+
*/
|
|
250
|
+
export function classifyManifest(input?: {
|
|
251
|
+
url?: string;
|
|
252
|
+
contentType?: string;
|
|
253
|
+
}): "hls" | "dash" | null;
|
|
162
254
|
export namespace CONTROL {
|
|
163
255
|
let START: string;
|
|
164
256
|
let STOP: string;
|
|
@@ -170,6 +262,8 @@ export namespace STREAM {
|
|
|
170
262
|
let SNAPSHOT: string;
|
|
171
263
|
let MUTATIONS: string;
|
|
172
264
|
let SCROLL: string;
|
|
265
|
+
let MEDIA: string;
|
|
266
|
+
let MEDIA_HINT: string;
|
|
173
267
|
let OVERLAY: string;
|
|
174
268
|
let DIALOG: string;
|
|
175
269
|
let READY: string;
|
|
@@ -378,9 +472,179 @@ export type ValueDiffOp = {
|
|
|
378
472
|
*/
|
|
379
473
|
checked?: boolean;
|
|
380
474
|
/**
|
|
381
|
-
* Selected option values for
|
|
475
|
+
* Selected option values for select controls (masked when maskInputs is on, so renderers must not treat these as a selection key)
|
|
382
476
|
*/
|
|
383
477
|
selectedValues?: string[];
|
|
478
|
+
/**
|
|
479
|
+
* Authoritative positional identity of selected options; preferred over selectedValues because option indexes never carry page content and stay unambiguous under masking
|
|
480
|
+
*/
|
|
481
|
+
selectedIndexes?: number[];
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* Captured live playback state of a single <video>/<audio> element, keyed by
|
|
485
|
+
* nid. Models the DIFF_OP.VALUE side-channel-property-state precedent: live
|
|
486
|
+
* media properties travel as side-channel data, never serialized into the HTML
|
|
487
|
+
* clone (preserves the Phase 7 no-mutation invariant + HTML byte-identity).
|
|
488
|
+
*
|
|
489
|
+
* Live/Infinity-duration encoding: `duration` is present ONLY when finite;
|
|
490
|
+
* non-finite (streaming) durations are encoded as `live: true` instead, never
|
|
491
|
+
* both. This sidesteps the JSON Infinity -> null trap (JSON.stringify(Infinity)
|
|
492
|
+
* === "null") so the reconciler can branch on `live` before any duration math
|
|
493
|
+
* and never compute NaN.
|
|
494
|
+
*/
|
|
495
|
+
export type MediaBaselineEntry = {
|
|
496
|
+
/**
|
|
497
|
+
* Element nid the playback state addresses
|
|
498
|
+
*/
|
|
499
|
+
nid: string;
|
|
500
|
+
/**
|
|
501
|
+
* Playback position in seconds
|
|
502
|
+
*/
|
|
503
|
+
currentTime: number;
|
|
504
|
+
/**
|
|
505
|
+
* Whether the element is paused
|
|
506
|
+
*/
|
|
507
|
+
paused: boolean;
|
|
508
|
+
/**
|
|
509
|
+
* Whether audio output is muted
|
|
510
|
+
*/
|
|
511
|
+
muted: boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Audio volume in [0, 1]
|
|
514
|
+
*/
|
|
515
|
+
volume: number;
|
|
516
|
+
/**
|
|
517
|
+
* Effective playback rate (1 = normal)
|
|
518
|
+
*/
|
|
519
|
+
playbackRate: number;
|
|
520
|
+
/**
|
|
521
|
+
* Whether the element loops
|
|
522
|
+
*/
|
|
523
|
+
loop: boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Whether playback reached the end
|
|
526
|
+
*/
|
|
527
|
+
ended: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Media duration in seconds; present ONLY when finite
|
|
530
|
+
*/
|
|
531
|
+
duration?: number;
|
|
532
|
+
/**
|
|
533
|
+
* true when duration is non-finite (stream); mutually exclusive with duration
|
|
534
|
+
*/
|
|
535
|
+
live?: boolean;
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* One STREAM.MEDIA wire message: a MediaBaselineEntry enriched with the event
|
|
539
|
+
* that triggered emission, a capture-side monotonic timestamp for latency
|
|
540
|
+
* compensation, and the stream identity stamps every side channel carries.
|
|
541
|
+
*
|
|
542
|
+
* The reconciler predicts the expected position from `currentTime`,
|
|
543
|
+
* `playbackRate`, and `(now - sentAt)`; `streamSessionId`/`snapshotId` let the
|
|
544
|
+
* renderer reject stale cross-generation frames via isCurrentStream (Plan 03).
|
|
545
|
+
* One message is emitted per media element per tick (scroll-like granularity).
|
|
546
|
+
*/
|
|
547
|
+
export type MediaSyncPayload = {
|
|
548
|
+
/**
|
|
549
|
+
* Element nid the playback state addresses
|
|
550
|
+
*/
|
|
551
|
+
nid: string;
|
|
552
|
+
/**
|
|
553
|
+
* Triggering media event
|
|
554
|
+
*/
|
|
555
|
+
event: "play" | "pause" | "seeked" | "ratechange" | "ended" | "volumechange" | "loadedmetadata" | "timeupdate";
|
|
556
|
+
/**
|
|
557
|
+
* Playback position in seconds at capture
|
|
558
|
+
*/
|
|
559
|
+
currentTime: number;
|
|
560
|
+
/**
|
|
561
|
+
* Whether the element is paused
|
|
562
|
+
*/
|
|
563
|
+
paused: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* Whether audio output is muted
|
|
566
|
+
*/
|
|
567
|
+
muted: boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Audio volume in [0, 1]
|
|
570
|
+
*/
|
|
571
|
+
volume: number;
|
|
572
|
+
/**
|
|
573
|
+
* Effective playback rate (1 = normal)
|
|
574
|
+
*/
|
|
575
|
+
playbackRate: number;
|
|
576
|
+
/**
|
|
577
|
+
* Whether the element loops
|
|
578
|
+
*/
|
|
579
|
+
loop: boolean;
|
|
580
|
+
/**
|
|
581
|
+
* Whether playback reached the end
|
|
582
|
+
*/
|
|
583
|
+
ended: boolean;
|
|
584
|
+
/**
|
|
585
|
+
* Media duration in seconds; present ONLY when finite
|
|
586
|
+
*/
|
|
587
|
+
duration?: number;
|
|
588
|
+
/**
|
|
589
|
+
* true when duration is non-finite (stream); mutually exclusive with duration
|
|
590
|
+
*/
|
|
591
|
+
live?: boolean;
|
|
592
|
+
/**
|
|
593
|
+
* Capture-side monotonic ms stamp for latency compensation
|
|
594
|
+
*/
|
|
595
|
+
sentAt: number;
|
|
596
|
+
/**
|
|
597
|
+
* Identity: minted per stream session
|
|
598
|
+
*/
|
|
599
|
+
streamSessionId: string;
|
|
600
|
+
/**
|
|
601
|
+
* Identity: minted per snapshot
|
|
602
|
+
*/
|
|
603
|
+
snapshotId: number;
|
|
604
|
+
};
|
|
605
|
+
/**
|
|
606
|
+
* One adaptive-manifest discovery hint surfaced by an adapter's opt-in network
|
|
607
|
+
* observation (Playwright `page.on('response')` / extension `chrome.webRequest`).
|
|
608
|
+
* The hint originates in the ADAPTER, never the capture core, so it adds no
|
|
609
|
+
* capture-wire divergence (no differential-oracle entry); it rides the existing
|
|
610
|
+
* raw relay + 1 MiB cap with the envelope byte-unchanged, and old viewers ignore
|
|
611
|
+
* the unknown STREAM.MEDIA_HINT type via the renderer dispatch default.
|
|
612
|
+
*
|
|
613
|
+
* Addressing is nid-scoped when manifest->element correlation is confident, else
|
|
614
|
+
* page-scoped (nid omitted, scope 'page'); a page hint is matched to an
|
|
615
|
+
* MSE-opaque media element on play by the viewer. Identity-stamped like every
|
|
616
|
+
* side channel; the viewer re-gates `manifestUrl` through the same fail-closed
|
|
617
|
+
* origin policy before any use.
|
|
618
|
+
*/
|
|
619
|
+
export type MediaHintPayload = {
|
|
620
|
+
/**
|
|
621
|
+
* Element nid when correlation is confident; omitted for page-level
|
|
622
|
+
*/
|
|
623
|
+
nid?: string;
|
|
624
|
+
/**
|
|
625
|
+
* 'element' (nid set) or 'page' (viewer matches on play)
|
|
626
|
+
*/
|
|
627
|
+
scope: "page" | "element";
|
|
628
|
+
/**
|
|
629
|
+
* Absolute manifest URL (https; viewer re-gates before use)
|
|
630
|
+
*/
|
|
631
|
+
manifestUrl: string;
|
|
632
|
+
/**
|
|
633
|
+
* Derived from URL extension and/or content-type
|
|
634
|
+
*/
|
|
635
|
+
kind: "hls" | "dash";
|
|
636
|
+
/**
|
|
637
|
+
* Observed response content-type (diagnostic)
|
|
638
|
+
*/
|
|
639
|
+
contentType?: string;
|
|
640
|
+
/**
|
|
641
|
+
* Identity: minted per stream session
|
|
642
|
+
*/
|
|
643
|
+
streamSessionId: string;
|
|
644
|
+
/**
|
|
645
|
+
* Identity: minted per snapshot
|
|
646
|
+
*/
|
|
647
|
+
snapshotId: number;
|
|
384
648
|
};
|
|
385
649
|
export type SubtreeRequestPayload = {
|
|
386
650
|
requestId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/protocol/messages.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/protocol/messages.js"],"names":[],"mappings":"AA2FA;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,6CAHW,MAAM,QACN,MAAM,UAIhB;AAED;;;;;;;;GAQG;AACH,qCAJW;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAC,UAC/C;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAC,GAC7C,OAAO,CAanB;AAgCD;;;;;;;;;;;;;GAaG;AACH,yCAHW;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAC,GAClC,KAAK,GAAC,MAAM,GAAC,IAAI,CAkB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvUD;;;;;GAKG;AACH,uBAAwB,cAAc,CAAC;;UAIzB,UAAU,GAAC,QAAQ,GAAC,OAAO;;;;cAC3B,MAAM;;;;eACN,MAAM;;;cAKN,MAAM;WACN,UAAU;eACV,MAAM,GAAC,OAAO,GAAC,eAAe,GAAC,SAAS,GAAC,UAAU;WACnD,MAAM;WACN,MAAM,GAAC,IAAI;YACX,MAAM;eACN,OAAO;cACP,MAAM;eACN;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,GAAC,IAAI;kBACrB,MAAM;;;UAKN,UAAU,GAAC,OAAO;iBAClB,MAAM;mBACN,MAAM;2BACN,MAAM;oBACN,MAAM;;;QAKN,cAAc;YACd,QAAQ,GAAC,SAAS,GAAC,QAAQ;cAC3B,MAAM;WACN,UAAU;aACV,WAAW;;;QAKX,KAAK;;;;eACL,MAAM;;;;UACN,MAAM;;;;eACN,MAAM,GAAC,IAAI;;;;aACX,MAAM,EAAE;;;;kBACR,iBAAiB,EAAE;;;;aACnB,YAAY,EAAE;;;;;;aAKd,MAAM;;;;UACN,MAAM;;;;UACN,MAAM;;;;aACN,MAAM,EAAE;;;;oBACR,MAAM;;;;mBACN,WAAW,EAAE;;;;oBACb,aAAa;;;;;;cAKb,MAAM;;;;UACN,MAAM;;;;WACN,MAAM;;;;cACN,MAAM,EAAE;;;;kBACR,MAAM,EAAE;;;;mBACR,MAAM,EAAE;;;;mBACR,WAAW,EAAE;;;;oBACb,aAAa;;;;;;;;;;;;gBAGb,MAAM;;;;gBACN,MAAM;;;;YACN,MAAM;;;;UACN,MAAM;;;;aACN,MAAM;;;QAKN,OAAO;SACP,MAAM;;;;YACN,MAAM;;;;cACN,OAAO;;;;qBACP,MAAM,EAAE;;;;sBACR,MAAM,EAAE;;;;;;;;;;;;;;;;;;SAgBR,MAAM;;;;iBACN,MAAM;;;;YACN,OAAO;;;;WACP,OAAO;;;;YACP,MAAM;;;;kBACN,MAAM;;;;UACN,OAAO;;;;WACP,OAAO;;;;eACP,MAAM;;;;WACN,OAAO;;;;;;;;;;;;;;;;SAcP,MAAM;;;;WACN,MAAM,GAAC,OAAO,GAAC,QAAQ,GAAC,YAAY,GAAC,OAAO,GAAC,cAAc,GAAC,gBAAgB,GAAC,YAAY;;;;iBACzF,MAAM;;;;YACN,OAAO;;;;WACP,OAAO;;;;YACP,MAAM;;;;kBACN,MAAM;;;;UACN,OAAO;;;;WACP,OAAO;;;;eACP,MAAM;;;;WACN,OAAO;;;;YACP,MAAM;;;;qBACN,MAAM;;;;gBACN,MAAM;;;;;;;;;;;;;;;;;;;;UAkBN,MAAM;;;;WACN,MAAM,GAAC,SAAS;;;;iBAChB,MAAM;;;;UACN,KAAK,GAAC,MAAM;;;;kBACZ,MAAM;;;;qBACN,MAAM;;;;gBACN,MAAM;;;eAKN,MAAM;SACN,MAAM;qBACN,MAAM;gBACN,MAAM;aACN,MAAM;;;eAKN,MAAM;SACN,MAAM;;;;YACN,MAAM;;;;WACN,MAAM;;;;cACN,MAAM,EAAE;;;;kBACR,iBAAiB,EAAE;;;;aACnB,YAAY,EAAE;;;;mBACd,WAAW,EAAE;;;;oBACb,aAAa;qBACb,MAAM;gBACN,MAAM;;;;;;UAKN,MAAM;;;;aACN,MAAM,EAAE;;;;kBACR,iBAAiB,EAAE;;;;aACnB,YAAY,EAAE;;;;eACd,OAAO;;;;wBACP,MAAM;;;;iBACN,MAAM,EAAE;;;;kBACR,MAAM,EAAE;;;;mBACR,WAAW,EAAE;;;;oBACb,aAAa;;;;;;;;;;;;eAGb,MAAM;;;;eACN,MAAM;aACN,MAAM;aACN,MAAM;mBACN,MAAM;oBACN,MAAM;eACN,MAAM;gBACN,MAAM;SACN,MAAM;WACN,MAAM;;;;qBACN,MAAM;;;;gBACN,MAAM;;;UAKN,OAAO,GAAC,SAAS,GAAC,QAAQ;WAC1B,MAAM,GAAC,QAAQ;cACf,MAAM;;;;mBACN,MAAM;;;;aACN,GAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} AssetOriginVerdict
|
|
3
|
+
* @property {boolean} allowed True only for a provably public https origin.
|
|
4
|
+
* @property {string} reason One of 'ok' | 'bad-scheme' | 'private-host'
|
|
5
|
+
* | 'unqualified-host' | 'parse-error'.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* True when a (lowercased) hostname names a private, internal, loopback,
|
|
9
|
+
* link-local, or ULA address -- i.e. a host the viewer must never fetch from
|
|
10
|
+
* by default. Pure string/regex logic over the fixed, fully-enumerable
|
|
11
|
+
* denylist (RFC1918 + RFC3927 link-local + loopback + RFC4193 ULA + the
|
|
12
|
+
* mDNS .local suffix); a dependency-free hand-roll is preferred here over an
|
|
13
|
+
* IP library so the predicate stays Phase-15-reusable and table-testable.
|
|
14
|
+
*
|
|
15
|
+
* Bracketed IPv6 literals: WHATWG URL keeps the surrounding brackets on
|
|
16
|
+
* u.hostname (verified: new URL('https://[::1]/').hostname === '[::1]'), so
|
|
17
|
+
* the brackets are stripped here before the IPv6 checks match the bare
|
|
18
|
+
* address form. (.local is intentionally NOT handled here -- it is the
|
|
19
|
+
* unqualified-host branch's job in classifyAssetOrigin so a *.local name
|
|
20
|
+
* classifies as 'unqualified-host', not 'private-host'.)
|
|
21
|
+
*
|
|
22
|
+
* SELF-CONTAINED NORMALIZATION (Phase 12 review CR-01/WR-01): this predicate
|
|
23
|
+
* is an exported Phase-15-reusable seam, so it must NOT depend on the caller
|
|
24
|
+
* having pre-normalized the host through WHATWG `new URL()`. A single trailing
|
|
25
|
+
* dot (the FQDN root label -- 'localhost.', '127.0.0.1.') is stripped, the host
|
|
26
|
+
* is lowercased, and any IPv6 zone-id ('%eth0') is dropped here so a raw
|
|
27
|
+
* `Host:` header / CSS url() host / media URL host cannot bypass the deny
|
|
28
|
+
* decision. Beyond the IPv4 dotted-quad ranges this blocks IPv6 loopback
|
|
29
|
+
* (`::1`), the unspecified address (`::`), link-local fe80::/10, ULA fc00::/7,
|
|
30
|
+
* the NAT64 well-known prefix 64:ff9b::/96, and IPv4-mapped / IPv4-compatible
|
|
31
|
+
* IPv6 (`::ffff:a.b.c.d`, `::ffff:HHHH:HHHH`, `::a.b.c.d`) by extracting the
|
|
32
|
+
* embedded IPv4 and re-running the v4 ranges -- so the AWS/GCP/Azure metadata
|
|
33
|
+
* host 169.254.169.254 and 127.0.0.1 are blocked in every representation. The
|
|
34
|
+
* milestone has no use case for fetching from a raw IP literal, so this stays
|
|
35
|
+
* fail-closed: an IP-literal form it cannot confidently prove public is denied.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} host Lowercased hostname (u.hostname) OR a raw host string.
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export function isPrivateOrLocalHost(host: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Classify an asset URL for viewer-side fetch (MSEC-01). Fail-closed: every
|
|
43
|
+
* branch that is not "a provably public https host" returns allowed:false
|
|
44
|
+
* with a machine-readable reason. The reasons are stable identifiers the
|
|
45
|
+
* renderer maps to a dimensioned blocked-origin placeholder and that the
|
|
46
|
+
* asset-policy table test pins.
|
|
47
|
+
*
|
|
48
|
+
* parse failure -> { allowed:false, reason:'parse-error' }
|
|
49
|
+
* protocol !== 'https:' -> { allowed:false, reason:'bad-scheme' }
|
|
50
|
+
* private/internal/ULA host -> { allowed:false, reason:'private-host' }
|
|
51
|
+
* dotless or *.local host -> { allowed:false, reason:'unqualified-host' }
|
|
52
|
+
* otherwise -> { allowed:true, reason:'ok' }
|
|
53
|
+
*
|
|
54
|
+
* Note this is a FETCH gate, not an injection gate; http: is blocked here
|
|
55
|
+
* (mixed-content / no-TLS) even though hasDangerousScheme would allow it.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} url Absolute asset URL (already absolutified by capture).
|
|
58
|
+
* @returns {AssetOriginVerdict}
|
|
59
|
+
*/
|
|
60
|
+
export function classifyAssetOrigin(url: string): AssetOriginVerdict;
|
|
61
|
+
export type AssetOriginVerdict = {
|
|
62
|
+
/**
|
|
63
|
+
* True only for a provably public https origin.
|
|
64
|
+
*/
|
|
65
|
+
allowed: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* One of 'ok' | 'bad-scheme' | 'private-host'
|
|
68
|
+
* | 'unqualified-host' | 'parse-error'.
|
|
69
|
+
*/
|
|
70
|
+
reason: string;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=asset-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-policy.d.ts","sourceRoot":"","sources":["../../../src/renderer/asset-policy.js"],"names":[],"mappings":"AA+BA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,2CAHW,MAAM,GACJ,OAAO,CA+DnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAHW,MAAM,GACJ,kBAAkB,CAoB9B;;;;;aA1Ia,OAAO;;;;;YACP,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/renderer/diff.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/renderer/diff.js"],"names":[],"mappings":"AA0FA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;GAaG;AACH,oCANW,QAAQ,aACR,KAAK,KAAQ,YACb,YAAY,SACZ,SAAS,GACP,IAAI,CAmXhB;;;;;iBAhZa,MAAM;;;;mBACN,MAAM;;;;;;YAKN;QAAC,IAAI,EAAE,IAAS,IAAI,EAAD,GAAC,EAAA,KAAG,IAAI,CAAA;KAAC;;;;;mBAE5B,CAAS,IAAM,EAAN,MAAM,EAAE,IAAM,UAAG,IAAI;;;;;;uBAG9B,OAAO,eAAe,EAAE,gBAAgB"}
|