@botiverse/porthole 0.12.0 → 0.14.0
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/annotate/types.d.ts +32 -3
- package/dist/annotate/types.js +4 -0
- package/dist/annotate/validate.js +19 -2
- package/dist/bridge/bridge.d.ts +8 -1
- package/dist/bridge/bridge.js +7 -0
- package/dist/bridge/unseen.d.ts +8 -0
- package/dist/bridge/unseen.js +17 -0
- package/dist/check/files.js +14 -10
- package/dist/check/lint.js +1 -1
- package/dist/check/page-source.js +1 -1
- package/dist/check/scroll.d.ts +29 -13
- package/dist/check/scroll.js +74 -18
- package/dist/compile/policy.d.ts +7 -0
- package/dist/compile/policy.js +13 -1
- package/dist/config/capabilities.d.ts +16 -3
- package/dist/config/capabilities.js +1 -0
- package/dist/config/schema.d.ts +11 -0
- package/dist/config/validate.js +19 -0
- package/dist/conformance/harness-source.js +1 -1
- package/dist/displays/displays.js +3 -1
- package/dist/guide/limits.js +1 -1
- package/dist/guide/runtime.js +1 -1
- package/dist/host/create-host.d.ts +2 -0
- package/dist/host/create-host.js +100 -3
- package/dist/host/pass-on.d.ts +15 -0
- package/dist/host/pass-on.js +65 -0
- package/dist/host/types.d.ts +37 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/isolation/types.d.ts +8 -0
- package/dist/isolation/types.js +8 -0
- package/dist/platform/focus-guard.d.ts +212 -0
- package/dist/platform/focus-guard.js +620 -0
- package/dist/platform/types.d.ts +25 -0
- package/dist/platform/web.js +80 -2
- package/dist/presets/presets.d.ts +2 -0
- package/dist/presets/presets.js +1 -0
- package/dist/react/frame.d.ts +8 -0
- package/dist/react/frame.js +4 -0
- package/dist/runtime/requests.js +34 -12
- package/dist/runtime/types.generated.js +1 -1
- package/dist/server/files.js +19 -3
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +4 -0
- package/dist/server/nested.d.ts +37 -0
- package/dist/server/nested.js +70 -0
- package/dist/server/server.js +57 -7
- package/dist/shell/annotate.d.ts +1 -1
- package/dist/shell/annotate.js +157 -7
- package/dist/shell/frame.d.ts +45 -0
- package/dist/shell/frame.js +250 -0
- package/dist/shell/plan.js +2 -1
- package/dist/shell/runtime.js +49 -14
- package/docs/ADOPTING.md +140 -7
- package/docs/ARCHITECTURE.md +23 -0
- package/docs/DECISIONS.md +564 -5
- package/docs/DESIGN.md +18 -2
- package/docs/THREAT_MODEL.md +192 -30
- package/package.json +1 -1
- package/src/annotate/types.ts +28 -3
- package/src/annotate/validate.ts +23 -2
- package/src/bridge/bridge.ts +17 -1
- package/src/bridge/unseen.ts +24 -0
- package/src/check/files.ts +14 -10
- package/src/check/lint.ts +1 -1
- package/src/check/scroll.ts +106 -38
- package/src/compile/policy.ts +14 -1
- package/src/config/capabilities.ts +16 -3
- package/src/config/schema.ts +11 -0
- package/src/config/validate.ts +23 -0
- package/src/displays/displays.ts +3 -1
- package/src/guide/limits.ts +1 -1
- package/src/guide/runtime.ts +1 -1
- package/src/host/create-host.ts +105 -4
- package/src/host/pass-on.ts +73 -0
- package/src/host/types.ts +33 -0
- package/src/index.ts +5 -1
- package/src/isolation/types.ts +12 -0
- package/src/platform/focus-guard.ts +815 -0
- package/src/platform/types.ts +24 -0
- package/src/platform/web.ts +96 -2
- package/src/presets/presets.ts +3 -0
- package/src/react/frame.tsx +10 -0
- package/src/runtime/requests.ts +36 -14
- package/src/runtime/types.generated.ts +1 -1
- package/src/server/files.ts +19 -3
- package/src/server/index.ts +10 -0
- package/src/server/nested.ts +86 -0
- package/src/server/server.ts +65 -6
- package/src/shell/annotate.ts +157 -7
- package/src/shell/frame.ts +268 -0
- package/src/shell/plan.ts +2 -1
- package/src/shell/runtime.ts +49 -14
- package/types/runtime/v1/comments.d.ts +8 -4
package/docs/DESIGN.md
CHANGED
|
@@ -629,8 +629,9 @@ What both adopters still wrote after 0.2 moves into Porthole (ADOPTING.md is the
|
|
|
629
629
|
`document.write`. Warnings for the rest: a document sent as a widget (taken as its body,
|
|
630
630
|
`fragmentOf`), the clipboard, dialogs, forms, hosts outside egress, unpinned CDN libraries,
|
|
631
631
|
`position: fixed` in a flow layout, new windows without `openLink`, the page's own styles
|
|
632
|
-
holding it to one screen (P106: `src/check/scroll.ts`, a cascade of html, body and the
|
|
633
|
-
overflow, height and position; `lintFiles` reads the version's linked stylesheets too
|
|
632
|
+
holding it to one screen (P106, P110: `src/check/scroll.ts`, a cascade of html, body and the
|
|
633
|
+
root's overflow, height and position; `lintFiles` reads the version's linked stylesheets too,
|
|
634
|
+
only those within its caps; advisory, so a throw in it says the page wasn't checked).
|
|
634
635
|
- **`admitContent(config, content, { refuseOn })`**: the show tool's gate. It refuses errors by
|
|
635
636
|
default with a text that says what to change; otherwise it shows the content (a widget's
|
|
636
637
|
document taken as its body) and returns the warnings as a note.
|
|
@@ -991,6 +992,10 @@ for that to lapse and click with raw input.
|
|
|
991
992
|
| The runtime: per-user data (P088) | `dbAccess`: `me` is the host's id; another's `data/users/<id>`, or anything else under `data`, refused at every level, in the bridge and the host | `test/runtime.test.ts`; `leak/served/runtime.spec.ts`: "a person's own data is theirs" | `db-private` → that case (all three) |
|
|
992
993
|
| The runtime: comments write-only (P090) | the bridge answers `comments` with `true` only for a handler's `true`; no read method | `test/runtime.test.ts`; `leak/served/runtime.spec.ts`: "comments are write-only" | `comments-result` → that case (all three) |
|
|
993
994
|
| The runtime: a comment's draft is visible text (P108) | the bridge refuses a draft that isn't a string, is blank, past 2,000 characters, or holds what a person can't see (`unseen`), before any handler | `test/runtime.test.ts`: "a draft (P108)"; `leak/served/runtime.spec.ts`: "a comment's draft is the host's to check" | `comment-draft` → that case (all three) |
|
|
995
|
+
| The runtime: a draft is visible text, strictly; the anchor beside it cleaned (P109) | a draft with a joiner (U+200C, U+200D) anywhere but between two letters or marks (first, last, doubled, beside a space or punctuation, in an emoji sequence), a line or paragraph separator, blank-looking text, more than 32 blanks or two blank lines in a row is refused; the label and quote lose what a person can't see, refused if nothing visible is left | `test/runtime.test.ts`: "a draft is visible text, strictly (P109)" | — (unit-tested: the bridge's own check, behind `comment-draft`'s) |
|
|
996
|
+
| The keyboard: the focus guard (P109) | a move of the keyboard from one of the host page's text fields into a display's frame that the person didn't make (no press on the frame, `:active` on Chromium and WebKit, the pointer coming over it on Firefox; no Tab; no gesture the page's own events don't explain) is undone once the move is over; three while typing within 10 s, or five within 2 s, stop the display | `test/focus-guard.test.ts`; `leak/served/runtime.spec.ts`: "a page that takes the keyboard while the person types in the host's composer…", "a page that takes the keyboard back on its own blur keeps none of it…" (GK-1), "a composer the host focuses with focusField…", "the person's own moves into the frame keep the keyboard…" | `focus-guard` → the first (all three) and the next two (Firefox); `focus-guard-watch` (the watch after a take-back, the look at every frame) → those two (Firefox) |
|
|
997
|
+
| The runtime: `comments.open` from the frame the person is in (P109) | its `user-activation` gate also needs the host page's focus in the calling frame (`CapabilitySpec.inFrame`, `Surface.focused`), after the focus guard | `leak/served/runtime.spec.ts`: "comments.open while the person types in the host's composer reaches no handler…" | `comments-in-frame` → that case (all three) |
|
|
998
|
+
| A nested page: Porthole's shell above an opaque page (P111) | the framed address answers the shell alone (its own script by hash, framing and fetching only the sealed prefix); the page is its child, `sandbox="allow-scripts"` in the attribute and its CSP (never `allow-same-origin`: a static check over every sandbox Porthole writes), loaded without a cookie; the shell passes messages by `event.source`, never in its own namespace; the host takes a move into the frame, or a `comments.open`, for the person's only if the shell's activation turned on within the last second with no trusted press or key on the host's page since (or a Tab, the host's move, a press the engine shows) | `test/nested.test.ts`; `leak/served/nested.spec.ts` on full Chromium, the headless shell, WebKit and Firefox | `shell-namespace` → "the shell's words are the shell's alone…" (all three); `shell-host-input` → "a page's focus() just after the person pressed it and went back…" (all three) |
|
|
994
999
|
| The asset library (P089, P091) | `/_blob/<id>` (or the frame's `<sealed base>__porthole/blob/<id>`) for an access to its artifact (a cookie, a sealed `Referer`, the sealed path), then the host's check, the store asked with it; typed by name, never a page, code only where trusted and uploaded code may run (asked at each load; by id alone, every artifact config must, P103), inert CSP, CORP, revalidated; the page's CSP opens `<origin>/_blob/` for images, media, fonts and data, for scripts and styles only where uploads are the admins' | `test/assets.test.ts` (a forged same-origin claim: 401; another artifact's session: 404; revoked: 403; bearer mode; a stricter config turns trusted code into a download, bearer mode too); `leak/served/runtime.spec.ts`: an upload loads in its frame; a set's page loads it; static `/_blob/` in a frame by `Referer` (Chromium, Firefox; WebKit sends only the origin: measured); "a script asset runs as code only if an admin uploaded it"; "scripts load from /_blob/ only where uploads are the admins'"; "an asset reaches only its own artifact's pages"; "an asset opened on its own runs nothing" | `blob-trusted` → the trusted-code case; `blob-script,blob-trusted` (two walls) → that case and the tab's CSP case; `blob-inert` → the opened-on-its-own case (all three; `scripts/controls.ts`) |
|
|
995
1000
|
| Workers (P044, P045) | no Node module in `/server`; D1 tickets taken by one `DELETE … RETURNING` | `test/workers.test.ts` (workerd, no `nodejs_compat`, real D1: once per ticket, a race, anonymous, a revocation, flat names, reserved namespaces) | — |
|
|
996
1001
|
|
|
@@ -1459,6 +1464,17 @@ control the tables above name to the registry):
|
|
|
1459
1464
|
| `live-held-read` | `served/runtime.spec.ts` | `a read above the viewer's level: a result the host pushed is refused as a cold read is` | — | — |
|
|
1460
1465
|
| `db-private` | `served/runtime.spec.ts` | `a person's own data is theirs: another person's is refused, never reaching the service` | — | — |
|
|
1461
1466
|
| `comments-result` | `served/runtime.spec.ts` | `comments are write-only: the composer opens from a click, content hears only that` | — | — |
|
|
1467
|
+
| `focus-guard` | `served/runtime.spec.ts` | `a page that takes the keyboard while the person types in the host's composer gets a key or two at most, and is stopped` | Firefox: `a page that takes the keyboard back on its own blur keeps none of it: the composer keeps its words, and comments.open reaches no handler`, `a composer the host focuses with focusField, beside a page with the person's gesture that takes focus back on its blur, gets their words` | — |
|
|
1468
|
+
| `focus-guard-watch` | `served/runtime.spec.ts` | nothing | Firefox: `a page that takes the keyboard back on its own blur keeps none of it: the composer keeps its words, and comments.open reaches no handler`, `a composer the host focuses with focusField, beside a page with the person's gesture that takes focus back on its blur, gets their words` | no probe can see it on Chromium and WebKit: they blur the host's window on every move into a frame and a take-back lands, and a page can't take focus back from its own blur there (measured) |
|
|
1469
|
+
| `comments-in-frame` | `served/runtime.spec.ts` | `comments.open while the person types in the host's composer reaches no handler, by the page's own call or the shell's; from a press in the frame it does` | — | — |
|
|
1470
|
+
| `cancel-any-mode` | `annotate.spec.ts` | `Escape while selecting text is cancelled, and stays the page's key; with no mode on, a page's own cancel isn't heard (P112)`, `a hostile page fakes reports: the host takes none it didn't ask for, nothing malformed, and not a flood` | — | — |
|
|
1471
|
+
| `track-checks` | `annotate.spec.ts` | `a followed mark's box comes as it moves, for that mark only, at most 60 a second, clamped to the frame, until the host stops (P112)` | — | — |
|
|
1472
|
+
| `order-check` | `annotate.spec.ts` | `every found mark's place in the document comes with its box, offscreen ones too; a place that isn't one is no report (P112)` | — | — |
|
|
1473
|
+
| `hold-click` | `annotate.spec.ts` | `holding a block 500 ms selects it and its release's click never reaches the page; a tap, a moving finger and a mouse are the page's (P112)` | — | — |
|
|
1474
|
+
| `shell-namespace` | `served/nested.spec.ts` | `the shell's words are the shell's alone: a page that says them, to its parent or to the host's window, moves nothing` | — | — |
|
|
1475
|
+
| `file-sandbox` | `served/nested.spec.ts` | `a page's SVG or XML file opened on a tab of its own is an opaque origin, and its script touches nothing of the shell's (P111, after its review)` | — | — |
|
|
1476
|
+
| `shell-stall` | `served/nested.spec.ts` | `a shell's activation seen after a stall is no one's gesture until it goes off (P111, after its review)` | — | — |
|
|
1477
|
+
| `shell-host-input` | `served/nested.spec.ts` | `a page's focus() just after the person pressed it and went back to the host's composer is taken back` | — | — |
|
|
1462
1478
|
| `comment-draft` | `served/runtime.spec.ts` | `a comment's draft is the host's to check: past the limit, holding what a person can't see, or not text, it opens no composer (P108)` | — | — |
|
|
1463
1479
|
| `blob-script` | `served/runtime.spec.ts` | nothing | — | an untrusted script asset is served as a download (`blob-script,blob-trusted`) |
|
|
1464
1480
|
| `blob-trusted` | `served/runtime.spec.ts` | `a script asset runs as code only if an admin uploaded it where uploads are the admins'` | — | — |
|
package/docs/THREAT_MODEL.md
CHANGED
|
@@ -5,13 +5,21 @@ What Porthole protects, from whom, and where that protection ends. For each way
|
|
|
5
5
|
guaranteed. [ADOPTING.md](ADOPTING.md) says how to set each one up, and
|
|
6
6
|
[DESIGN.md](DESIGN.md) lists every defense with the test that proves it.
|
|
7
7
|
|
|
8
|
-
**Status.** This describes Porthole 0.
|
|
9
|
-
|
|
10
|
-
conformance probes' messages and timing, not what they check. P104 (0.9.0's
|
|
11
|
-
a review of its own, and P105, in 0.10.0, is what it led to. 0.11.0
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
**Status.** This describes Porthole 0.14.0 (2026-10-28). A review on 2026-10-19 found gaps, and every decision it led to
|
|
9
|
+
has merged ([§8](#8-fixes-in-flight) lists them). P096 changed the negative-control runner and CI,
|
|
10
|
+
and the shipped conformance probes' messages and timing, not what they check. P104 (0.9.0's
|
|
11
|
+
annotation markers) had a review of its own, and P105, in 0.10.0, is what it led to. 0.11.0 was
|
|
12
|
+
never published (its release stopped at the CI gate), and 0.12.0 carries all of it: draft marks
|
|
13
|
+
(P107, §7 "Drafts": what a page learns from them and who may receive them), an advisory lint
|
|
14
|
+
(P106, no change to isolation), and `comments.open` with a draft (P108, §7: the host's duties
|
|
15
|
+
around it). The review of 0.12.0's drafts led to P109, in 0.13.0: a display can take the keyboard, which
|
|
16
|
+
`createHost` now gives back (§6, §7 "The keyboard"); `comments.open` needs the person in the
|
|
17
|
+
calling frame; a page's draft text is stricter, and the composer it fills is the person's to act
|
|
18
|
+
on (§7). 0.13.0 also makes P106's lint fail soft and read only what it may (P110, no change to
|
|
19
|
+
isolation). 0.14.0 adds a nested page (P111, `nested: true`, S3): the framed address is Porthole's
|
|
20
|
+
shell alone and the page its opaque child, so a realm the page can't reach tells the host when the
|
|
21
|
+
person, not the page, pressed in it (§7 "The keyboard", `comments`); and P112's annotation
|
|
22
|
+
additions for a host's comment modes (hints, as every report is, §7).
|
|
15
23
|
|
|
16
24
|
## 1. Two layers
|
|
17
25
|
|
|
@@ -153,10 +161,28 @@ Whatever the use:
|
|
|
153
161
|
second click lands on the bubble's). Such a view takes no press of any kind for 500 ms after it
|
|
154
162
|
appears or moves (not a `click` only: menu triggers act on `pointerdown`, and menu items click
|
|
155
163
|
themselves on a release), ignores a press that began before that, opens beside the frame rather
|
|
156
|
-
than over the report's box where the layout allows, takes no focus when it opens, and puts
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
arms).
|
|
164
|
+
than over the report's box where the layout allows, takes no focus when it opens, and puts
|
|
165
|
+
nothing one click away that posts, submits, resolves, deletes or discards (a draft's view, P107,
|
|
166
|
+
included: no "Post" or "Submit review" in it). Its menus and popovers are part of it, portaled
|
|
167
|
+
ones too (P105; ADOPTING.md § Annotations has the code: the view `inert` while it arms).
|
|
168
|
+
One exception to "takes no focus" (P112): in a comment mode the person started themselves (the
|
|
169
|
+
host's own control, never a report), a composer their selection opens (`selected`) may take
|
|
170
|
+
focus, with `focusField`, if all it can do is save a draft: nothing in it posts, submits or sends,
|
|
171
|
+
Enter in it only adds the draft to the batch (submitting is only ever the host's own "Submit N"
|
|
172
|
+
control, outside the composer), it shows plainly that it is a draft (so the person can see where
|
|
173
|
+
their keys are going), and the rest of this guard holds (no press for 500 ms, beside the frame). The page still chooses
|
|
174
|
+
when `selected` comes, so what it can do with that moment is put the person's next keys into a
|
|
175
|
+
draft they see and can discard, never send one; outside such a mode, or for a composer that can
|
|
176
|
+
send, it takes no focus.
|
|
177
|
+
- Know that a display can take the keyboard: a page calls `focus()` on its own input whenever it
|
|
178
|
+
likes (on Chromium and WebKit with no gesture), and what the person goes on typing goes to it.
|
|
179
|
+
`createHost` (every `PortholeView` too) gives focus back when it leaves one of the page's text
|
|
180
|
+
fields for a frame without the person's press on the frame or a Tab, tells the display
|
|
181
|
+
(`focusTaken`), and stops a display that keeps doing it (§7 "The keyboard", P109). Move focus
|
|
182
|
+
into a display yourself with `display.focus()`, never the frame's own `focus()`; move it into
|
|
183
|
+
your composer with `focusField(field)`, not the field's own `focus()` (Firefox ignores that while
|
|
184
|
+
a fighting frame holds focus); and with a platform of your own, implement its focus guard
|
|
185
|
+
(`focused`, `onFocusTaken`, `focus`) or accept that a display can read what is typed beside it.
|
|
160
186
|
- List every app origin in `appOrigins` (`hostOrigins` in `/server`): only those may frame content,
|
|
161
187
|
and only those are checked against the content domain for a shared site.
|
|
162
188
|
- Under the app runtime, run `defineRuntimeConformance` with `api` in CI (§7).
|
|
@@ -308,6 +334,30 @@ encrypted into the path, since WebKit keeps no cookie in a frame (P083).
|
|
|
308
334
|
worker; a page's CSP opens its own version's path, not its whole origin.
|
|
309
335
|
- With a per-request check (`authorize`), the host decides again on every request; a deny is a
|
|
310
336
|
403 that says `denied`.
|
|
337
|
+
- A nested page (`nested: true`, P111): the framed address answers Porthole's shell alone, its
|
|
338
|
+
script the only one its CSP runs, framing and fetching only the origin's sealed files' prefix.
|
|
339
|
+
The page is the shell's child, `sandbox="allow-scripts"` (never `allow-same-origin`, held by a
|
|
340
|
+
static check over every sandbox Porthole writes) and the same sandbox in its own CSP, so it is an
|
|
341
|
+
opaque origin in its frame and on a tab; it is loaded, and loads its files, at its sealed address
|
|
342
|
+
without a cookie, and its files then carry `Cross-Origin-Resource-Policy: cross-origin` and
|
|
343
|
+
`Access-Control-Allow-Origin: *` (an opaque page's own loads are cross-origin: the address is
|
|
344
|
+
the access, never the request's origin). So whoever holds a page's sealed address can read its
|
|
345
|
+
files from any origin, a page of their own included, until the address ends (an hour on its own,
|
|
346
|
+
P083): it is a bearer credential, as safe as it is unleaked. Porthole keeps it out of what it
|
|
347
|
+
says: no referrer goes with any load (`Referrer-Policy: no-referrer`, the shell's frame
|
|
348
|
+
`referrerpolicy="no-referrer"`), the host's reports name it as `./` (P083), and the shell's own
|
|
349
|
+
answer is `no-store`. The page itself can read it (its address) and so pass it on by any channel
|
|
350
|
+
it has, as it can pass on its files' bytes. The page has none of the origin's storage, and nothing
|
|
351
|
+
of the shell's realm: messages between them go by `postMessage`, the page's trusted by
|
|
352
|
+
`event.source`, and the shell drops what the page says in the shell's own namespace. Only the
|
|
353
|
+
shell (same-origin) renews the page's address; a module the page loaded keeps one that ends
|
|
354
|
+
within the hour. Every answer below the sealed prefix carries a CSP sandbox, never
|
|
355
|
+
`allow-same-origin` (a page's `allow-scripts`, every other file's runs nothing): a file opened on
|
|
356
|
+
a tab of its own (an SVG or XML file with a script) is opaque, never the shell's origin (negative
|
|
357
|
+
control `file-sandbox`). The sandbox refuses no worker (measured on the four engines): a nested
|
|
358
|
+
page's workers come from Blob URLs (a worker from its set's own script is refused by its opaque
|
|
359
|
+
origin, sandbox or not), and those load the set's scripts. Assets and Porthole's libraries aren't
|
|
360
|
+
served to a nested page yet.
|
|
311
361
|
|
|
312
362
|
**The host must**
|
|
313
363
|
|
|
@@ -542,13 +592,15 @@ wall on three engines, and `defineHostConformance` runs it against a host's own
|
|
|
542
592
|
effects are its own), and group displays by page (S7).
|
|
543
593
|
|
|
544
594
|
**Annotations** (`annotate`, P053, P104, P107). The shell that draws marks and reports anchors shares
|
|
545
|
-
its realm with the content
|
|
595
|
+
its realm with the content (a nested page's too: its marks are drawn by the runtime in the page's
|
|
596
|
+
own frame, below the shell, P111), so:
|
|
546
597
|
|
|
547
598
|
- *What content learns.* Everything the host sends in a `show` is posted into the frame's window,
|
|
548
599
|
where the content can listen: each mark's id, anchor and, where given, `count` (the number on
|
|
549
600
|
its marker). A host gives ids that say nothing (never a person's name or a comment's words), and
|
|
550
601
|
a count only where the page may know how many there are. Who commented and what they wrote stay
|
|
551
|
-
in the host's own UI, outside the frame
|
|
602
|
+
in the host's own UI, outside the frame, and so does what the person types there, within the
|
|
603
|
+
keyboard's limits below (P109).
|
|
552
604
|
- *Drafts* (P107). A mark with `kind: "draft"` (a comment its author hasn't posted) is drawn apart,
|
|
553
605
|
a dashed line and a hollow marker with no number, so the page also learns which of its marks are
|
|
554
606
|
drafts: that the person viewing it is writing a comment there, before they post it. That is new
|
|
@@ -566,7 +618,9 @@ its realm with the content, so:
|
|
|
566
618
|
app runtime below). A host that sends drafts to such a page accepts that its author and other viewers can
|
|
567
619
|
learn of them. A draft carries nothing else: the host drops its count before the frame (control
|
|
568
620
|
`draft-count`), so a page can't read how many drafts are at an anchor unless the host sends a
|
|
569
|
-
mark per draft, and its id is the host's, as any mark's (random, never the draft's words)
|
|
621
|
+
mark per draft, and its id is the host's, as any mark's (random, never the draft's words); the
|
|
622
|
+
draft's words are typed into the host's composer, which the page can try to take the keyboard
|
|
623
|
+
from ("The keyboard" below). A host
|
|
570
624
|
that sends drafts into a frame others see (a shared screen, a frame several viewers share) tells
|
|
571
625
|
that page, and anything it draws for them, what its author hasn't posted.
|
|
572
626
|
- *What content can fake.* Any report: a selection while the host asks for one, where marks are,
|
|
@@ -628,8 +682,82 @@ its realm with the content, so:
|
|
|
628
682
|
follow-up reports, of the marks (while one has a marker) and of the person's selection after a
|
|
629
683
|
scroll, share one clock: at most one a second together, each only when its box moved (P105).
|
|
630
684
|
- So `activated` opens the host's own view of a mark it already shows, placed within the frame's
|
|
631
|
-
box (better: beside it), guarded as §6 says, and never acts on it (no
|
|
632
|
-
an anchor or a rect decides where something is drawn, never who may
|
|
685
|
+
box (better: beside it), guarded as §6 says, and never acts on it (no post, submit, discard,
|
|
686
|
+
resolve, delete or reply); an anchor or a rect decides where something is drawn, never who may
|
|
687
|
+
see or do anything.
|
|
688
|
+
|
|
689
|
+
**The keyboard** (P109). Any display, of any kind and any version, can move the keyboard into its
|
|
690
|
+
frame: `element.focus()` runs in the content's realm, where nothing of Porthole can stop it, and on
|
|
691
|
+
Chromium and WebKit it needs no gesture. What the person goes on typing then goes to the page,
|
|
692
|
+
which can keep it (`db`) or send it out through any egress it has. The page knows when it matters:
|
|
693
|
+
its shell reports `selected` when the host opens a composer on it, and draft marks (P107) say
|
|
694
|
+
where the person is writing. P107 and P108 didn't make this possible; they put the person's
|
|
695
|
+
unposted words beside the frame and tell the page when.
|
|
696
|
+
|
|
697
|
+
- *What holds* (the web platform's focus guard, in every `createHost` display): when focus leaves
|
|
698
|
+
one of the host page's text fields (a text area, an `<input>` that takes text, an editable region,
|
|
699
|
+
in open shadow roots too) for a display's frame, and the person didn't move it there, focus goes
|
|
700
|
+
back to the field once the engine has finished the move, the guard watches that it stays there
|
|
701
|
+
(a page that takes it again on its own blur, which the take-back fires, is caught, as is focus
|
|
702
|
+
left on nothing), and the display hears `focusTaken`. Three such moves within 10 s that came while
|
|
703
|
+
the person typed or that kept focus from staying back, or five within 2 s, stop the display. The
|
|
704
|
+
person moved it if they pressed Tab just before; pressed the frame (on Chromium and WebKit the
|
|
705
|
+
frame element is `:active` as focus moves; on Firefox, which doesn't blur the window or show the
|
|
706
|
+
press, the pointer came over the frame after the field got focus and after the person last
|
|
707
|
+
typed); made a gesture the host's own events don't explain (the page has activation, but no
|
|
708
|
+
key, press or click of its own for longer than activation lasts, and the field has had focus that
|
|
709
|
+
long: a press or an assistive technology's activation in a frame); or the host moved it
|
|
710
|
+
(`display.focus()`).
|
|
711
|
+
Measured on all three engines: a page calling `focus()` every 700 ms down to a busy loop, or
|
|
712
|
+
taking focus back on its own blur, while the person types a sentence gets no key of it on
|
|
713
|
+
Chromium and WebKit and at most one on Firefox before it is stopped or gives up (negative
|
|
714
|
+
controls `focus-guard`, and `focus-guard-watch` on Firefox); a press on the page's own field, a
|
|
715
|
+
Tab into the frame, and an activation in the frame that sends the host no event keep the
|
|
716
|
+
keyboard there. `comments.open` needs that focus in the calling frame, moved there by the
|
|
717
|
+
person, and not just after a press on the host's page (the app runtime, below).
|
|
718
|
+
- *What doesn't*: a page gets the keys typed before focus is back (on Firefox, the keys of an
|
|
719
|
+
animation frame: one in a sentence, measured on a slowed machine too; a few more can be lost to
|
|
720
|
+
nothing while a take-back is fought, and the composer then has focus again); on Firefox a host's plain
|
|
721
|
+
`focus()` doesn't move focus from a frame that holds it with the person's gesture and takes it
|
|
722
|
+
back on its blur (no focus event: the keys go to the frame), so a composer that opens focused
|
|
723
|
+
must use `focusField`; on Firefox a page keeps the keyboard if the pointer came over its frame after
|
|
724
|
+
the person last typed and after the field got focus (a person who typed, moved the pointer over
|
|
725
|
+
the frame, and types on without clicking); moves between two frames, or from what isn't a text
|
|
726
|
+
field, aren't judged (a frame beside another: S7); and a platform of the host's own has no guard
|
|
727
|
+
unless it implements one. The guard can take a person's own move for the page's (a press on
|
|
728
|
+
Firefox with the pointer resting over the frame since before the field got focus; an assistive
|
|
729
|
+
technology's activation within 5 s of their key or press on the page): focus goes back, and
|
|
730
|
+
their next press once the pointer has left the frame and come back, a Tab, or an activation 5 s
|
|
731
|
+
later keeps it.
|
|
732
|
+
- *Full Chromium* (P111, measured on Chromium 153, not the headless shell): a cross-site frame is
|
|
733
|
+
out of process, and the host's page sees nothing of a press in it (no `:active`, no `:hover`, no
|
|
734
|
+
pointer event past the frame's edge). For a served page that isn't nested, a person's real click
|
|
735
|
+
into its field is taken back every time there (the display stopped at the third), and
|
|
736
|
+
`comments.open` from a real click is refused within 5 s of any input on the host's page
|
|
737
|
+
(porthole#53). Nest it.
|
|
738
|
+
- *A nested page* (P111): the guard asks the page's shell, a realm the page can't reach above its
|
|
739
|
+
frame, whose transient activation turns on only from a press or key in the page (activation goes
|
|
740
|
+
up, never down). A move into the frame is the person's if the shell's activation turned on within
|
|
741
|
+
the last second and the host's page had no trusted press or key since; or a Tab, the host's own
|
|
742
|
+
move, or a press the engine shows on the frame element. Nothing else counts: no pointer over the
|
|
743
|
+
frame, no host-wide activation. A move the shell hasn't spoken of yet waits for its word (its next
|
|
744
|
+
frame) at most 500 ms, then is taken back. Measured on full Chromium, the headless shell, WebKit
|
|
745
|
+
and Firefox (`leak/served/nested.spec.ts`): a real click into the page's field keeps the
|
|
746
|
+
keyboard; the page's `focus()` as it loads, on a timer while the person types, right after a
|
|
747
|
+
click on the host's own button, 1.2 to 4.5 s after the person paused typing, and 700 ms after
|
|
748
|
+
they pressed it and went back to the composer is taken back; what a page says in the shell's
|
|
749
|
+
name, to its parent or to the host's window, moves nothing (negative controls `shell-namespace`,
|
|
750
|
+
`shell-host-input`). *What doesn't*: a press in the page within 5 s of the last one turns no
|
|
751
|
+
activation on, so a second move into it after the person went back to the host's page is taken
|
|
752
|
+
back until 5 s after their last press or key in the page, or they Tab in; the page gets the keys
|
|
753
|
+
typed while a move waits for the shell's word; a shell without `navigator.userActivation` leaves
|
|
754
|
+
0.13's rule. A page that holds the thread it shares with its shell (WebKit; Firefox and Chromium
|
|
755
|
+
where the frames share a process) from its own click handler would push the moment the shell sees
|
|
756
|
+
its activation past the person's next keys on the host's page: so the shell looks and beats every
|
|
757
|
+
50 ms and says how long it went without a look, and an activation it reports after a stall of over
|
|
758
|
+
100 ms (its own, or no word heard) is no one's gesture until it lapses (P111, after its review;
|
|
759
|
+
negative control `shell-stall`). The cost: in those engines a page that keeps its thread busy has
|
|
760
|
+
the person's real click taken for uncertain until it is idle.
|
|
633
761
|
|
|
634
762
|
### The app runtime
|
|
635
763
|
|
|
@@ -662,10 +790,23 @@ section.
|
|
|
662
790
|
code-typed asset runs as code only when an admin uploaded it where uploaded code may run, and
|
|
663
791
|
only while the config still lets uploaded code run, asked at every load, in bearer mode too
|
|
664
792
|
(where every artifact config must; P103); anything else is a download.
|
|
665
|
-
- `comments` is write-only: the page learns only whether the composer opened.
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
793
|
+
- `comments` is write-only: the page learns only whether the composer opened. It opens only from
|
|
794
|
+
a gesture with the host page's focus in the calling frame (P109: a press in it or a Tab into it;
|
|
795
|
+
not the person typing in the host's UI, nor a gesture in another display; negative control
|
|
796
|
+
`comments-in-frame`). In a nested page (P111) it opens too while the page's shell saw the
|
|
797
|
+
person's gesture within the last second, with no press or key on the host's page since: a real
|
|
798
|
+
click on the page's button a moment after typing in the host's composer opens it, on full
|
|
799
|
+
Chromium too (porthole#53); with no click it is refused, whatever the page says in the shell's
|
|
800
|
+
name. A draft it gives (P108) is at most 2,000 characters of text a person can
|
|
801
|
+
see (P109): nothing invisible (zero-width characters, bidi and tag characters, controls but a
|
|
802
|
+
new line and a tab; U+200C and U+200D only between two letters or marks, where Persian and the
|
|
803
|
+
Indic scripts need them, never first, last, doubled, beside a space or punctuation, or in an
|
|
804
|
+
emoji sequence; a variation selector after a pictograph is fine), no line or paragraph
|
|
805
|
+
separator, not blank-looking, at most 32 blanks in a row and two blank lines in a row; anything
|
|
806
|
+
else is refused before the handler. A joiner between two letters that shapes nothing still
|
|
807
|
+
draws as nothing (about a bit per letter boundary, measured): accepted, as P100 accepts it. The anchor's
|
|
808
|
+
label and quote reach the handler without what a person can't see, and are refused if nothing
|
|
809
|
+
visible is left.
|
|
669
810
|
- `defineRuntimeConformance` checks the host's handlers, and with `api` its own API for `db`,
|
|
670
811
|
`artifact` and `assets`, with a forged context (a viewer claiming to be the owner, no rules).
|
|
671
812
|
|
|
@@ -682,11 +823,28 @@ section.
|
|
|
682
823
|
(`Refused("conflict")`).
|
|
683
824
|
- Handle abuse on shared pages (S4).
|
|
684
825
|
- Show a comment's draft (P108) whole, as the person's editable plain text in its own composer,
|
|
685
|
-
and post it only on the person's own Send, never on the page's word.
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
826
|
+
and post it only on the person's own Send, never on the page's word. Once posted, the comment is
|
|
827
|
+
the person's: mentions in it act as theirs, which is why they must see it all first. So (P109;
|
|
828
|
+
ADOPTING.md has the code):
|
|
829
|
+
- An open never replaces, appends to or moves what the person has typed, or the place they
|
|
830
|
+
chose: while the composer holds their words, answer `false`, or show the page's words as a
|
|
831
|
+
separate suggestion that takes no focus. (The page knows they are writing anyway: its
|
|
832
|
+
`selected`, and draft marks.)
|
|
833
|
+
- A composer the page filled takes no focus when it opens (keys stay where the person was
|
|
834
|
+
typing: what they type for the page must not land in a postable comment), and doesn't send on
|
|
835
|
+
Enter until the person has focused or edited it themselves: Send is a click until then. It is
|
|
836
|
+
a view the content brought (§6's guard): no press for 500 ms after it opens, Send not focused,
|
|
837
|
+
beside the frame where it can.
|
|
838
|
+
- It says the text is the page's ("Suggested by this page", or the page's name), drawn by the
|
|
839
|
+
host outside the frame, until the person edits it, and never shows it as one of their own
|
|
840
|
+
drafts: the host's own list of drafts is how a person finds theirs, not the frame's markers,
|
|
841
|
+
which a page can draw too.
|
|
842
|
+
- The draft's view (P107) and the composer put nothing one click away that posts, submits or
|
|
843
|
+
discards.
|
|
844
|
+
- Render a page-drafted comment as plain text, or show the person before Send what readers will
|
|
845
|
+
see: markup a markdown renderer hides (an HTML comment, a link definition) is still read by an
|
|
846
|
+
agent. Show the anchor's label and quote as isolated text (`<bdi>`, `dir="auto"`), and hand
|
|
847
|
+
them to a model only as the page's words.
|
|
690
848
|
|
|
691
849
|
**Not guaranteed**
|
|
692
850
|
|
|
@@ -697,14 +855,18 @@ section.
|
|
|
697
855
|
- In bearer mode, assets are served by id alone, without the host's check.
|
|
698
856
|
- A draft is the page's words in the person's composer: a person who posts it without reading
|
|
699
857
|
posts what the page chose, and an agent that reads the comment takes it as theirs. Porthole
|
|
700
|
-
bounds what can hide in it (visible text, 2,000 characters
|
|
701
|
-
person's
|
|
858
|
+
bounds what can hide in it (visible text, 2,000 characters) and when it opens (a gesture with the
|
|
859
|
+
person in the calling frame, P109: before P109, any gesture on the host's page in the last 5 s,
|
|
860
|
+
typing in its own composer included); reading it is the person's. A page can still open the
|
|
861
|
+
composer on the person's own press in its frame, at a moment it chooses (the second click of a
|
|
862
|
+
double click, a field it asked them to type into): the composer's duties above are the bound.
|
|
702
863
|
|
|
703
864
|
## 8. Fixes in flight
|
|
704
865
|
|
|
705
|
-
The decisions below come from the 2026-10-19 review
|
|
706
|
-
|
|
707
|
-
|
|
866
|
+
The decisions below come from the 2026-10-19 review, and all of them have merged. Each row says
|
|
867
|
+
what was wrong, what holds now, and the limit its decision accepts, if any. Later reviews' decisions
|
|
868
|
+
are in the status line and in DECISIONS.md: P105 (after the review of P104), P109 (after the review
|
|
869
|
+
of 0.12.0's drafts), P111 (a nested page, S3; in 0.14.0).
|
|
708
870
|
|
|
709
871
|
| Decision | State | What it closes | Sections |
|
|
710
872
|
| --- | --- | --- | --- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botiverse/porthole",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A host-side sandbox for agent-made HTML: isolation, egress hardening, a themed shell, gated host functions, and the agent manual, from one config.",
|
|
5
5
|
"homepage": "https://github.com/botiverse/porthole#readme",
|
|
6
6
|
"bugs": {
|
package/src/annotate/types.ts
CHANGED
|
@@ -63,8 +63,13 @@ export interface AnnotationRect {
|
|
|
63
63
|
|
|
64
64
|
/** What the person may point at while the host is asking. */
|
|
65
65
|
export interface AnnotateMode {
|
|
66
|
-
/**
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Elements, picked with a click or tap (the one under the pointer is outlined); one pick. Or
|
|
68
|
+
* `"hold"` (P112): a finger held still on a block for 500 ms selects it (reported as `selected`,
|
|
69
|
+
* and the click its release makes never reaches the page); every other tap, and any mouse, is the
|
|
70
|
+
* page's; it lasts until the host stops it.
|
|
71
|
+
*/
|
|
72
|
+
readonly elements?: boolean | "hold";
|
|
68
73
|
/** Text, by selecting it: each settled selection is reported, and its clearing. */
|
|
69
74
|
readonly text?: boolean;
|
|
70
75
|
}
|
|
@@ -106,6 +111,12 @@ export interface AnchorResult {
|
|
|
106
111
|
readonly state: AnchorState;
|
|
107
112
|
/** Where it is now, when attached. */
|
|
108
113
|
readonly rect?: AnnotationRect;
|
|
114
|
+
/**
|
|
115
|
+
* Its place in the document among the found marks, from 0 (P112): where it starts, offscreen
|
|
116
|
+
* marks included, for a host that lists marks in reading order. The content's word: an order to
|
|
117
|
+
* sort by, never a fact.
|
|
118
|
+
*/
|
|
119
|
+
readonly order?: number;
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
/** What the frame reports, once the host has checked it. */
|
|
@@ -118,7 +129,11 @@ export type AnnotationReport =
|
|
|
118
129
|
}
|
|
119
130
|
/** The text selection went away. */
|
|
120
131
|
| { readonly type: "unselected" }
|
|
121
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* The person pressed Escape while picking an element (the pick ends), or while selecting text
|
|
134
|
+
* (P112: the page keeps the key; the host decides what ends). The page's word too: a page can
|
|
135
|
+
* send it, and the host takes it only while it asked for a pick or for text.
|
|
136
|
+
*/
|
|
122
137
|
| { readonly type: "cancelled" }
|
|
123
138
|
/**
|
|
124
139
|
* Where the marked anchors are now: every mark after `show`, the focused one after `focus`,
|
|
@@ -128,6 +143,12 @@ export type AnnotationReport =
|
|
|
128
143
|
* host was last told, at most once a second (P104).
|
|
129
144
|
*/
|
|
130
145
|
| { readonly type: "anchored"; readonly results: readonly AnchorResult[] }
|
|
146
|
+
/**
|
|
147
|
+
* The box of the mark the host follows (`annotations.track`, P112), in the frame's viewport, at
|
|
148
|
+
* an animation frame where it moved: at most 60 a second, for that mark only, clamped to the
|
|
149
|
+
* frame. The content's word: where to put a card beside it, nothing more.
|
|
150
|
+
*/
|
|
151
|
+
| { readonly type: "tracked"; readonly id: string; readonly rect: AnnotationRect }
|
|
131
152
|
/**
|
|
132
153
|
* The person clicked the marker of a mark the host shows with a `count` (P104), or of a draft
|
|
133
154
|
* (P107); `rect` is the marker's box, to open the host's own UI beside it. The content can fake
|
|
@@ -155,6 +176,10 @@ export const ANNOTATE_METHODS = {
|
|
|
155
176
|
anchored: "porthole/annotate.anchored",
|
|
156
177
|
/** Frame → host: a mark's marker was clicked (P104). */
|
|
157
178
|
activated: "porthole/annotate.activated",
|
|
179
|
+
/** Host → frame: follow one mark's box (`{ id }`), or none (`{ id: null }`) (P112). */
|
|
180
|
+
track: "porthole/annotate.track",
|
|
181
|
+
/** Frame → host: the followed mark's box, as it moves (P112). */
|
|
182
|
+
tracked: "porthole/annotate.tracked",
|
|
158
183
|
} as const;
|
|
159
184
|
|
|
160
185
|
/** The most of each part of an anchor or report the host takes. */
|
package/src/annotate/validate.ts
CHANGED
|
@@ -155,7 +155,20 @@ function results(value: unknown): AnchorResult[] | null {
|
|
|
155
155
|
if (rect === null) {
|
|
156
156
|
return null;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
// A place among the marks (P112): a whole number below the most marks a show carries.
|
|
159
|
+
const order = each.order;
|
|
160
|
+
if (
|
|
161
|
+
order !== undefined &&
|
|
162
|
+
!(typeof order === "number" && Number.isInteger(order) && order >= 0 && order < LIMITS.marks)
|
|
163
|
+
) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
out.push({
|
|
167
|
+
id: each.id,
|
|
168
|
+
state: "attached",
|
|
169
|
+
...(rect === undefined ? {} : { rect }),
|
|
170
|
+
...(order === undefined ? {} : { order }),
|
|
171
|
+
});
|
|
159
172
|
}
|
|
160
173
|
return out;
|
|
161
174
|
}
|
|
@@ -183,6 +196,10 @@ export function parseReport(value: unknown): AnnotationReport | null {
|
|
|
183
196
|
const rect = parseRect(value.rect);
|
|
184
197
|
return !markId(value.id) || rect === null ? null : { type: "activated", id: value.id, rect };
|
|
185
198
|
}
|
|
199
|
+
case "tracked": {
|
|
200
|
+
const rect = parseRect(value.rect);
|
|
201
|
+
return !markId(value.id) || rect === null ? null : { type: "tracked", id: value.id, rect };
|
|
202
|
+
}
|
|
186
203
|
default:
|
|
187
204
|
return null;
|
|
188
205
|
}
|
|
@@ -192,7 +209,11 @@ export function parseReport(value: unknown): AnnotationReport | null {
|
|
|
192
209
|
export function annotateMode(mode: AnnotateMode | undefined): Required<AnnotateMode> {
|
|
193
210
|
const elements = mode?.elements ?? true;
|
|
194
211
|
const words = mode?.text ?? true;
|
|
195
|
-
if (
|
|
212
|
+
if (
|
|
213
|
+
(typeof elements !== "boolean" && elements !== "hold") ||
|
|
214
|
+
typeof words !== "boolean" ||
|
|
215
|
+
(elements === false && !words)
|
|
216
|
+
) {
|
|
196
217
|
throw new TypeError("annotations.start: elements, text, or both");
|
|
197
218
|
}
|
|
198
219
|
return { elements, text: words };
|
package/src/bridge/bridge.ts
CHANGED
|
@@ -71,7 +71,8 @@ import type {
|
|
|
71
71
|
* every capability its host function's own rate (P091, P095) → arguments well formed and within
|
|
72
72
|
* their limits → who may (P087: the level of each method the call runs for the viewer, a page's
|
|
73
73
|
* named data with or without a viewer, db's rules) → not muted, if confirm-gated → the own rate
|
|
74
|
-
* of each method it runs (P094: a batch's writes count each) → a user gesture, if gated so
|
|
74
|
+
* of each method it runs (P094: a batch's writes count each) → a user gesture, if gated so (and
|
|
75
|
+
* for `comments`, the host page's focus in the calling frame: P109) → the
|
|
75
76
|
* viewer's consent, if gated so → a person's confirmation, if gated so (at most 10 waiting) →
|
|
76
77
|
* shown to the person, if gated so (P100) → the handler (or, for a read, a result the host already
|
|
77
78
|
* gave for it, or for a stale-allowed one the host's cache).
|
|
@@ -106,6 +107,12 @@ export interface BridgeOptions {
|
|
|
106
107
|
readonly cached?: DataCache;
|
|
107
108
|
/** Whether the embedding page has user activation now; undefined where it can't tell. */
|
|
108
109
|
readonly userActivation?: () => boolean | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the embedding page's focus is in this display's frame now (P109); undefined where it
|
|
112
|
+
* can't tell. A capability whose gesture must be in its frame (`inFrame`: `comments`) is refused
|
|
113
|
+
* without it.
|
|
114
|
+
*/
|
|
115
|
+
readonly focused?: () => boolean | undefined;
|
|
109
116
|
readonly onEvent: (event: BridgeEvent) => void;
|
|
110
117
|
/** The clock, in milliseconds (tests pass their own). */
|
|
111
118
|
readonly now?: () => number;
|
|
@@ -125,6 +132,10 @@ export interface BridgeOptions {
|
|
|
125
132
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
126
133
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
127
134
|
|
|
135
|
+
/** Whether `capability`'s gesture must be in its own frame (P109: the host page's focus there). */
|
|
136
|
+
const inFrame = (capability: CapabilityName): boolean =>
|
|
137
|
+
capabilitySpec(capability).inFrame === true;
|
|
138
|
+
|
|
128
139
|
const MAX_URL = 4_096;
|
|
129
140
|
|
|
130
141
|
/**
|
|
@@ -653,6 +664,11 @@ export function createBridge(options: BridgeOptions): DisplayBridge {
|
|
|
653
664
|
if (activated === false) {
|
|
654
665
|
return refuse<Result>(capability, "no-user-activation");
|
|
655
666
|
}
|
|
667
|
+
// A gesture in this frame, not anywhere on the host's page (P109): the person typing in
|
|
668
|
+
// the host's composer gives its page activation, which a frame's call would borrow.
|
|
669
|
+
if (inFrame(capability) && options.focused?.() === false) {
|
|
670
|
+
return refuse<Result>(capability, "no-user-activation");
|
|
671
|
+
}
|
|
656
672
|
}
|
|
657
673
|
if (gates.includes("consent")) {
|
|
658
674
|
const consent = options.consent;
|
package/src/bridge/unseen.ts
CHANGED
|
@@ -80,3 +80,27 @@ const UNSEEN_EACH = new RegExp(UNSEEN.source, "gu");
|
|
|
80
80
|
export function withoutUnseen(text: string): string {
|
|
81
81
|
return text.replace(UNSEEN_EACH, "");
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
/** A variation selector where an emoji has one: after a pictograph, or in a keycap. */
|
|
85
|
+
const EMOJI_SELECTORS = new RegExp(
|
|
86
|
+
"(?<=\\p{Extended_Pictographic})[\\uFE0E\\uFE0F]|(?<=[0-9#*])[\\uFE0E\\uFE0F](?=\\u20E3)",
|
|
87
|
+
"gu",
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A joiner or non-joiner with a letter or mark on each side (P109): how Persian separates its
|
|
92
|
+
* letters (میخواهم) and the Indic scripts choose a half form or a conjunct (क्ष, എന്റെ). Never
|
|
93
|
+
* first or last, doubled, beside a space, punctuation or a pictograph: there it shapes nothing, and
|
|
94
|
+
* hides text or makes a blank-looking draft.
|
|
95
|
+
*/
|
|
96
|
+
const LETTER_JOINERS = /(?<=[\p{L}\p{M}])[\u200C\u200D](?=[\p{L}\p{M}])/gu;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Whether `text` holds what a person can't see, for text a page puts in the person's own words (a
|
|
100
|
+
* comment's draft, P109): `unseen`'s list, with only a joiner or non-joiner between two letters or
|
|
101
|
+
* marks let by (in any script: a person's text needs them, and one that draws as nothing there is
|
|
102
|
+
* a bit at most), and a variation selector right after a pictograph or in a keycap (❤️, 1️⃣). A
|
|
103
|
+
* joiner between pictographs (an emoji sequence) is refused: it can join any two.
|
|
104
|
+
*/
|
|
105
|
+
export const unseenStrict = (text: string): boolean =>
|
|
106
|
+
UNSEEN.test(text.replace(LETTER_JOINERS, "").replace(EMOJI_SELECTORS, ""));
|
package/src/check/files.ts
CHANGED
|
@@ -272,8 +272,10 @@ export function lintFiles(
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
};
|
|
275
|
-
// A stylesheet a page links or a stylesheet imports, found in the set by its path (P106).
|
|
276
|
-
|
|
275
|
+
// A stylesheet a page links or a stylesheet imports, found in the set by its path (P106). The
|
|
276
|
+
// fewest characters it may hold first: the rule decodes its text only where it may read it, and
|
|
277
|
+
// nothing keeps it after (P110: kept for the set, one page linking 400 sheets of 240 KB held
|
|
278
|
+
// them all, 200 MB, for the 4 MiB the rule reads).
|
|
277
279
|
const stylesheet: LinkedSheet = (href, from) => {
|
|
278
280
|
if (href === "" || elsewhere(href) || href.startsWith("/")) {
|
|
279
281
|
return null;
|
|
@@ -283,13 +285,15 @@ export function lintFiles(
|
|
|
283
285
|
if (sheet === undefined || target === null) {
|
|
284
286
|
return null;
|
|
285
287
|
}
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
288
|
+
// As bytes, at most 3 a character (after a BOM's 3): its fewest characters, and the bytes that
|
|
289
|
+
// hold its first SCANNED.
|
|
290
|
+
return typeof sheet === "string"
|
|
291
|
+
? { path: target, least: sheet.length, text: () => sheet }
|
|
292
|
+
: {
|
|
293
|
+
path: target,
|
|
294
|
+
least: Math.max(0, Math.ceil(sheet.byteLength / 3) - 1),
|
|
295
|
+
text: () => textOf(sheet.subarray(0, 3 * SCANNED + 3)),
|
|
296
|
+
};
|
|
293
297
|
};
|
|
294
298
|
const it = config.mode === "mcp-app" ? "view" : config.mode === "inline" ? "widget" : "page";
|
|
295
299
|
const maxPage = config.limits.maxBytes;
|
|
@@ -378,7 +382,7 @@ export function lintFiles(
|
|
|
378
382
|
severity: "warning",
|
|
379
383
|
message: held.message,
|
|
380
384
|
path: held.path ?? path,
|
|
381
|
-
line: held.line,
|
|
385
|
+
...(held.line === undefined ? {} : { line: held.line }),
|
|
382
386
|
});
|
|
383
387
|
}
|
|
384
388
|
}
|
package/src/check/lint.ts
CHANGED
|
@@ -295,7 +295,7 @@ export function lintPage(
|
|
|
295
295
|
rule: "scroll-lock",
|
|
296
296
|
severity: "warning",
|
|
297
297
|
message: held.message,
|
|
298
|
-
line: held.line,
|
|
298
|
+
...(held.line === undefined ? {} : { line: held.line }),
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
const opens = /target\s*=\s*["']?_blank|\bwindow\s*\.\s*open\s*\(/u.exec(content);
|