@botiverse/porthole 0.14.17 → 0.15.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/CHANGELOG.md +55 -0
- package/dist/check/page-source.js +1 -1
- package/dist/conformance/harness-source.js +1 -1
- package/dist/host/pages-of-set.d.ts +3 -1
- package/dist/host/pages-of-set.js +17 -3
- package/dist/isolation/served.d.ts +9 -0
- package/dist/isolation/served.js +23 -0
- package/dist/protocol/mcp-apps.d.ts +5 -3
- package/dist/protocol/mcp-apps.js +5 -3
- package/dist/protocol/shell-adapter.js +5 -0
- package/dist/server/host.d.ts +7 -0
- package/dist/server/host.js +1 -0
- package/dist/server/pages.d.ts +39 -12
- package/dist/server/pages.js +85 -37
- package/dist/server/server.js +168 -40
- package/dist/server/types.d.ts +30 -0
- package/dist/shell/annotate.js +3 -2
- package/dist/shell/find.js +2 -1
- package/dist/shell/frame.d.ts +3 -34
- package/dist/shell/frame.js +26 -14
- package/dist/shell/runtime.d.ts +3 -2
- package/dist/shell/runtime.js +25 -9
- package/docs/ADOPTING.md +18 -4
- package/docs/DECISIONS.md +288 -5
- package/docs/DESIGN.md +6 -1
- package/docs/THREAT_MODEL.md +38 -2
- package/package.json +1 -1
- package/src/host/pages-of-set.ts +18 -3
- package/src/isolation/served.ts +25 -0
- package/src/protocol/mcp-apps.ts +5 -3
- package/src/protocol/shell-adapter.ts +5 -0
- package/src/server/host.ts +8 -0
- package/src/server/pages.ts +129 -56
- package/src/server/server.ts +237 -40
- package/src/server/types.ts +30 -0
- package/src/shell/annotate.ts +3 -2
- package/src/shell/find.ts +2 -1
- package/src/shell/frame.ts +33 -14
- package/src/shell/runtime.ts +25 -9
package/docs/DESIGN.md
CHANGED
|
@@ -1012,6 +1012,7 @@ for that to lapse and click with raw input.
|
|
|
1012
1012
|
| A nested page's shell on a label of its own (P114, porthole#56) | the shell, its page and that page's files are served on `nestedLabelOf(<scope's label>)` (`porthole-<24 base32>`, one per scope), never on the scope's label, where the scope's other displays run content with `allow-same-origin`; that label answers only frame addresses of nested pages, their sealed prefix and status pages (no clean address, entry, asset, library, app, nor another instance's ticket, cookie or sealed address), the scope's label no nested page (a clean address goes on with a one-time ticket); no host's naming makes a `porthole-` label; an entry code is no document's ticket; outside `/server` too (P121), `createHost` refuses a nested page located on any other label, the shell runs on no other origin, and `nestedShellResponse` and `frameShellScript` refuse one; `nestedFileCsp` is the page's and its files' CSP for `/server` and a Worker of a host's own | `test/nested.test.ts`, `test/entry.test.ts` ("… (P114)"; `test/nested.test.ts` "… (P121)"); `leak/served/nested-siblings.spec.ts` (`[nested-siblings]`: a same-scope inline widget and artifact read each other, not the shell; `[nested-label]`: a nested page located on its scope's label is refused, no frame made) on full Chromium, the headless shell, WebKit and Firefox; `leak/kit.spec.ts` and the prod-shape profile (the label through `nodeHost`, and through a TLS edge and DNS) | `shell-label,nested-host-label,nested-shell-origin` (the shell on the scope's label, the host's and the shell's checks out) → `[nested-siblings]`, `[nested-label]` (all three); `nested-host-label` (the host's check out) → `[nested-label]` (all three) |
|
|
1013
1013
|
| 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`) |
|
|
1014
1014
|
| 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) | — |
|
|
1015
|
+
| An embedded document (P143) | grant `embed` (only with the server's `embeds: true`, anonymous, no level or user, an artifact's page that isn't nested; signed into the session as `m` and into the sealed address) → `frame-ancestors *` for that session's answers alone (its document, a file set's pages and files and own frames, assets, renewals, its status and ended-access pages); an embed session's cookie has a name of its own (`e-<key>`) and never stands in for another session; the plan names no host (`origins: []`): the shell asks no host, ends its handshake at once (`"none"`), says nothing to any parent (no `*` notices, no annotation or find report) and hears no one; no door; `statusPage` and `doorStatusResponse` take `embed` (`*`, `data-porthole-hosts="[]"`) | `test/embed.test.ts` (refused without `embeds`, with a viewer, a level or a user, for url mode, a nested display, a served shell or the proxy, at a clean address and at the door; the flag can't be added or stripped, nor a session moved to the other name; **the bound**: 23 kinds of answer under an embed session say `*` and name no host, and the same under a public and a viewer's session are byte for byte what a server without `embeds` answers, on the same server while an embed session of the same artifact exists, and with both cookies sent; the host's check is told `embed`; cookies host-only, never `Domain=`); `test/shell.test.ts` (P143's handshake); `leak/served/embed.spec.ts`: `[embed.loads]`, `[embed.unheard]`, `[embed.untold]`, `[embed.no-escape]`, `[embed.reader-unframeable]` | `embed-ancestors` → `[embed.reader-unframeable]`; `embed-handshake` → `[embed.untold]`; `embed-origins` → `[embed.unheard]` (all three) |
|
|
1015
1016
|
|
|
1016
1017
|
### The clipboard, and copy buttons
|
|
1017
1018
|
|
|
@@ -1590,7 +1591,8 @@ control the tables above name to the registry):
|
|
|
1590
1591
|
| `annotation-rect-clamp` | `annotate.spec.ts` | `a hostile page reports a box outside its frame: the host gets it clamped to the frame's viewport`, `marks: drawn over their anchors, one brought into view, an unfound one orphaned, all cleared`, `following: once a scroll settles, one report with only the marks that moved`, `every attached mark's place in the document comes with the scroll it was read at, offscreen ones too, and the followed mark's as the document scrolls (P132)`, `a selection's and a mark's last line come in the document's coordinates with the scroll, offscreen ones too; rect stays clamped (P133)` | — | — |
|
|
1591
1592
|
| `authorize` | `served/authorize.spec.ts` | `a revoked subject's ticket opens nothing: a page and an app are denied, and the host is told`, `in a tab of its own, a revoked app and page are denied from the next request on`, `a framed page mid-session: its next load after revocation is denied where the engine keeps its cookie` | Chromium, Firefox: `a framed app mid-session: its next request after revocation is denied, and its next load tells the host` | — |
|
|
1592
1593
|
| `url-permissions` | `served/permissions.spec.ts` | `a url-mode frame gets no clipboard writes or full screen unless the host delegates them` | — | — |
|
|
1593
|
-
| `navigate-guard` | `served/live.spec.ts`, `served/files.spec.ts`, `served/served.spec.ts`, `served/tab.spec.ts` | `served.domain.self-navigation`, `served.domain.tab-navigation`, `served.domain.tab-links`, `can't navigate itself away (location): to a site, or to another content origin`, `can't navigate itself away (replace): to a site, or to another content origin`, `can't navigate itself away (open-self): to a site, or to another content origin`, `can't navigate itself away (navigation-api): to a site, or to another content origin`, `a link to another page of the set opens it in the frame; the display goes on`, `a link to another page of the set opens it in the frame when the leaving page's notice is dropped (P098)`, `a link to another page of the set opens it in the frame when the leaving page's notice is late (P098)`, `a page opens nothing else: not a file that isn't a page, not another path of its origin`, `no report, content error or blocked navigation names the frame's sealed address (P083)` | — | — |
|
|
1594
|
+
| `navigate-guard` | `served/live.spec.ts`, `served/files.spec.ts`, `served/served.spec.ts`, `served/tab.spec.ts` | `served.domain.self-navigation`, `served.domain.tab-navigation`, `served.domain.tab-links`, `can't navigate itself away (location): to a site, or to another content origin`, `can't navigate itself away (replace): to a site, or to another content origin`, `can't navigate itself away (open-self): to a site, or to another content origin`, `can't navigate itself away (navigation-api): to a site, or to another content origin`, `a link to another page of the set opens it in the frame; the display goes on`, `a link to another page of the set opens it in the frame when the leaving page's notice is dropped (P098)`, `a link to another page of the set opens it in the frame when the leaving page's notice is late (P098)`, `without the Navigation API, a link to another page of the set opens it in the frame; the display goes on`, `a link down the page scrolls it; the document stays, and so does the display`, `without the Navigation API, a link down the page scrolls it; the document stays, and so does the display`, `a page opens nothing else: not a file that isn't a page, not another path of its origin`, `no report, content error or blocked navigation names the frame's sealed address (P083)` | — | — |
|
|
1595
|
+
| `same-document-notice` | `served/files.spec.ts` | `a link down the page scrolls it; the document stays, and so does the display`, `without the Navigation API, a link down the page scrolls it; the document stays, and so does the display` | — | — |
|
|
1594
1596
|
| `tab-sandbox` | `served/tab.spec.ts` | `served.domain.tab-escapes`, `served.domain.tab-opener`, `a file set's page on a tab of its own opens its own pages, and no window, link in a new window or download`, `a frame's sealed address opened on a tab of its own is sandboxed as its frame is` | — | — |
|
|
1595
1597
|
| `window-open` | `served/tab.spec.ts` | nothing | — | the CSP's sandbox stops a window first (`tab-sandbox,window-open`) |
|
|
1596
1598
|
| `tab-sandbox,window-open` | `served/tab.spec.ts` | `served.domain.tab-escapes`, `served.domain.tab-opener`, `a file set's page on a tab of its own opens its own pages, and no window, link in a new window or download`, `a frame's sealed address opened on a tab of its own is sandboxed as its frame is`, `served.domain.tab-window-open` | — | — |
|
|
@@ -1623,6 +1625,9 @@ control the tables above name to the registry):
|
|
|
1623
1625
|
| `door-status` | `served/siblings-status.spec.ts` | `[sibling-inject]`, `[sibling-reload]`, `[proxy]` | — | WebKit: `[sibling-inject]`, `[sibling-reload]`, `[sibling-wipe]`, `[proxy]` may skip instead, measured (their attack lands only sometimes there) |
|
|
1624
1626
|
| `door-silence` | `served/siblings-status.spec.ts` | `[sibling-wipe]` | — | WebKit: `[sibling-inject]`, `[sibling-reload]`, `[sibling-wipe]`, `[proxy]` may skip instead, measured (their attack lands only sometimes there) |
|
|
1625
1627
|
| `door-opaque` | `served/siblings-status.spec.ts` | `[door-reach]` | — | — |
|
|
1628
|
+
| `embed-ancestors` | `served/embed.spec.ts` | `[embed.reader-unframeable]` | — | — |
|
|
1629
|
+
| `embed-handshake` | `served/embed.spec.ts` | `[embed.untold]` | — | — |
|
|
1630
|
+
| `embed-origins` | `served/embed.spec.ts` | `[embed.unheard]` | — | — |
|
|
1626
1631
|
| `frame-status-order` | `served/outcome.spec.ts` | `a nested page that says it is blocked, through its shell or past it, is told nothing and shown nothing (P124)` | — | — |
|
|
1627
1632
|
| `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` | — | — |
|
|
1628
1633
|
| `shell-focus-held` | `served/nested.spec.ts` | `the host's move takes no keyboard from where the host's page went on to in the same task (P136)`, `a second host's move into a page it just handed the focus to leaves it there: no blur, and its field keeps the keyboard (P136)` | — | — |
|
package/docs/THREAT_MODEL.md
CHANGED
|
@@ -5,7 +5,7 @@ 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.
|
|
8
|
+
**Status.** This describes Porthole 0.15.0 (2026-11-10). A review on 2026-10-19 found gaps, and every decision it led to
|
|
9
9
|
has merged ([§8](#8-fixes-in-flight) lists them). P096 changed the negative-control runner and CI,
|
|
10
10
|
and the shipped conformance probes' messages and timing, not what they check. P104 (0.9.0's
|
|
11
11
|
annotation markers) had a review of its own, and P105, in 0.10.0, is what it led to. 0.11.0 was
|
|
@@ -47,7 +47,20 @@ host that follows none drops `selectionTracked` unread (§7). 0.14.17: P141 lets
|
|
|
47
47
|
origins of an outer page that frames its app (`framedBy`): each may be an ancestor of every frame,
|
|
48
48
|
above the host's own page, so it is in every `frame-ancestors`, and nowhere else; it is never a
|
|
49
49
|
host a frame hears or tells, and a page's `*` fallback is held to a parent named as a host origin
|
|
50
|
-
(§6 "What every host must do", S3).
|
|
50
|
+
(§6 "What every host must do", S3). 0.14.18: P142 keeps a set's pages and links within a page from
|
|
51
|
+
starting the display again where there is no Navigation API, and where WebKit fires a frame's load
|
|
52
|
+
for a link within its document: the arriving page's notice is sent without the API, and a page
|
|
53
|
+
says it stayed; no wall moves, and the limit without the API is P079's, unchanged. 0.15.0: P143
|
|
54
|
+
lets a host that opts in (`embeds`) mint an embed grant: a public artifact page's answers say
|
|
55
|
+
`frame-ancestors *` for that session alone, and the page has no host: it hears no one, tells no
|
|
56
|
+
parent anything, and no capability, runtime host function or door is there (S4, §8). P144, after
|
|
57
|
+
Ferryman's audit of 0.14.17 and 0.14.18 (no P0, no new egress), amends P141: without `framedBy`
|
|
58
|
+
the status, entry and door pages' scripts and the nested page's shell are 0.14.16's again, byte for
|
|
59
|
+
byte (0.14.17 had changed their hashes, not what they do); in the nesting P141 is for (the outer
|
|
60
|
+
page, then the app's page, then content), content can message the outer page and every frame in
|
|
61
|
+
its tree and learn its origin, so the outer page must check every message it takes, and S7's
|
|
62
|
+
egress rule covers its frames (§6 "What every host must do", S7); and `framedBy` is compared with
|
|
63
|
+
the host origins as browsers serialize origins (`https://a.example:443` is `https://a.example`).
|
|
51
64
|
|
|
52
65
|
## 1. Two layers
|
|
53
66
|
|
|
@@ -280,6 +293,14 @@ Whatever the use:
|
|
|
280
293
|
can hear is the content's own word to its parent (`*`), which it must treat as untrusted. Your
|
|
281
294
|
app page's own `frame-ancestors` is yours to set; Porthole never sends it. Name exact origins of
|
|
282
295
|
that one product, and drop them when it stops framing you.
|
|
296
|
+
- In the nesting `framedBy` is for (the outer page, then your app's page, then content), content
|
|
297
|
+
is a descendant of the outer page (P144): it can `postMessage` the outer page (`top`) and every
|
|
298
|
+
frame in its tree, and learn the outer page's origin (measured in Chromium and Firefox). No
|
|
299
|
+
header stops that. Tell the outer page's authors: every message listener on the outer page and in
|
|
300
|
+
each of its frames must check `event.source` and `event.origin`, taking a message only from the
|
|
301
|
+
window and origin it expects (your app's page), and treat any other as content's untrusted word.
|
|
302
|
+
S7's rule now covers the outer page's frames: what content was given can be handed to any frame
|
|
303
|
+
the outer page shows, so the widest network among them is content's way out.
|
|
283
304
|
- Under the app runtime, run `defineRuntimeConformance` with `api` in CI (§7).
|
|
284
305
|
|
|
285
306
|
### S1. Inline widgets in a conversation
|
|
@@ -547,6 +568,12 @@ the attacker (c), and its readers are strangers.
|
|
|
547
568
|
so it is never punycode for another name; pages say `noindex`; a file of a type Porthole
|
|
548
569
|
doesn't know is served as a download.
|
|
549
570
|
- `authorize` is the host's takedown switch.
|
|
571
|
+
- An embedded document (P143, `Grant.embed`, only where the host set `embeds`): its answers say
|
|
572
|
+
`frame-ancestors *` for that session alone, never a reader's; it is anonymous, with no level or
|
|
573
|
+
user, an artifact's page that isn't nested; its plan names no host, so it hears no one, Porthole
|
|
574
|
+
tells no parent anything, no capability or runtime host function runs, and no door is minted. The
|
|
575
|
+
flag is signed into the session and the sealed address. Every other session is unchanged, byte
|
|
576
|
+
for byte, while an embed session of the same artifact exists; cookies stay host-only.
|
|
550
577
|
- A page opened in a tab of its own has its frame's powers and no more (P099): its CSP header
|
|
551
578
|
carries the frame's sandbox (scripts on its own origin; no popups, forms, downloads, browser
|
|
552
579
|
dialogs, or navigation of another window, its opener's included), and its `Permissions-Policy`
|
|
@@ -580,6 +607,10 @@ the attacker (c), and its readers are strangers.
|
|
|
580
607
|
- Check pages for secrets before publishing them: `lintContent` has no rule for credentials.
|
|
581
608
|
- Pass Porthole's `Content-Security-Policy` and `Permissions-Policy` headers on as they are,
|
|
582
609
|
through any edge or proxy: on a tab they are the page's sandbox.
|
|
610
|
+
- For embeds (P143): mint `embed` from one route of yours alone (never a reader's ticket or door),
|
|
611
|
+
keep that route from widening grants, and blank a takedown within a bound you state (your
|
|
612
|
+
`authorize` answers, cached or not). The embedding site sees the page load and hears what the
|
|
613
|
+
page itself posts to its parent or top.
|
|
583
614
|
- Treat a public link's clean address as a tab's (P125): to show what one names in a frame, resolve
|
|
584
615
|
it through your issue endpoint (`client.resolve`, `<PortholeView address>`). Its refusals (signed
|
|
585
616
|
out, denied, not found) are your backend's word, drawn as the fallback with no frame built: keep
|
|
@@ -721,6 +752,10 @@ can be handed to the display with the widest network.
|
|
|
721
752
|
|
|
722
753
|
- Porthole doesn't enforce this: `defineDisplays` takes any kinds together, and
|
|
723
754
|
`frameSources` is the union of all of theirs. Group displays by page yourself.
|
|
755
|
+
- Where another app frames yours (`framedBy`, P141, P144), the page is the outer page's, and its
|
|
756
|
+
frames are in the union too: content can post to the outer page and to every frame in its tree.
|
|
757
|
+
The outer page's own frames, and their network, are its authors' to group, and its listeners must
|
|
758
|
+
check `event.source` and `event.origin` (§6 "What every host must do").
|
|
724
759
|
- An opaque frame also inherits the page's own CSP, so a strict page narrows its opaque frames
|
|
725
760
|
further (P058). A served frame has only its own policy.
|
|
726
761
|
|
|
@@ -1279,6 +1314,7 @@ found P124 held only for a nested display or one alone in its scope; in 0.14.6:
|
|
|
1279
1314
|
| P101 | Merged | Under https Porthole read unprefixed `porthole-*` cookies a sibling label can plant; the entered mark carried no label; url mode checked neither `Origin` nor `Sec-Fetch-Site`. Now only `__Host-` names are read, the mark names its label, and a url-mode app answers its own origin and navigations. | S3, S6 |
|
|
1280
1315
|
| P102 | Merged | This document. | |
|
|
1281
1316
|
| P103 | Merged | A live widget's capabilities could add origins; bearer-mode assets skipped the code re-check; `callTool` had no rate. Now the preset refuses them and its config is frozen, every load asks the current config (its ETag says which answer), and `callTool` has 30 a minute. | S2, S5, §7 |
|
|
1317
|
+
| P143 | Merged (0.15.0) | Embeds: a public grant's documents framed by any page (`frame-ancestors *`) only for a session the host minted with `embed`, never a reader's. Such a frame has no host: it hears no one, Porthole tells no parent anything, no capability or runtime host function runs, no door. Accepted: the embedding site sees the page load and hears what the page itself posts to its parent or top. The host must keep its embed entry from widening grants, and blank takedowns within its stated bound. | S4 |
|
|
1282
1318
|
|
|
1283
1319
|
Open with no decision yet; until then they are the host's to cover:
|
|
1284
1320
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botiverse/porthole",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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/host/pages-of-set.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface FileSetRef {
|
|
|
26
26
|
interface Notice {
|
|
27
27
|
readonly url: string;
|
|
28
28
|
readonly arrived: boolean;
|
|
29
|
+
/** The page is where it was: a navigation within its document (P142). */
|
|
30
|
+
readonly same: boolean;
|
|
29
31
|
/** Whether it names the mounted version (`ok`), another (`other`), or none (a shell before P098). */
|
|
30
32
|
readonly set: "ok" | "other" | "none";
|
|
31
33
|
}
|
|
@@ -42,6 +44,7 @@ function noticeOf(raw: unknown, mounted: FileSetRef): Notice | null {
|
|
|
42
44
|
return {
|
|
43
45
|
url: typeof params.url === "string" ? params.url : "",
|
|
44
46
|
arrived: params.arrived === true,
|
|
47
|
+
same: params.same === true,
|
|
45
48
|
set:
|
|
46
49
|
named === undefined
|
|
47
50
|
? "none"
|
|
@@ -62,7 +65,9 @@ const isHello = (raw: unknown): boolean =>
|
|
|
62
65
|
* A notice (`porthole/navigating`, from the frame's window and content origin: the transport
|
|
63
66
|
* takes nothing else) names a page and the version its files are. The leaving page's notice is
|
|
64
67
|
* taken for the next load within `PAGE_OF_SET_MS`; the arriving page's (`arrived`) too, or for the
|
|
65
|
-
* load it came after. A
|
|
68
|
+
* load it came after. A page whose document stayed (`same`, a navigation within it: WebKit fires
|
|
69
|
+
* the frame's load for one, P142) is taken for the load it came after, or for the next one within
|
|
70
|
+
* `LATE_NOTICE_MS` only. A load no notice explained waits `LATE_NOTICE_MS`, holding the frame
|
|
66
71
|
* (`HELD_MOST` messages each way at most; past them, started again): nothing it says reaches the
|
|
67
72
|
* display (no call is answered, no report taken), nothing is sent to it, and once the wait is
|
|
68
73
|
* over without a notice for the
|
|
@@ -137,21 +142,31 @@ export function pagesOfSet(options: {
|
|
|
137
142
|
}
|
|
138
143
|
const notice = noticeOf(message, set);
|
|
139
144
|
if (notice !== null) {
|
|
140
|
-
if (notice.set === "other" || (notice.arrived && notice.set !== "ok")) {
|
|
145
|
+
if (notice.set === "other" || ((notice.arrived || notice.same) && notice.set !== "ok")) {
|
|
141
146
|
// Another version's page, or one that won't say which: never this display's.
|
|
142
147
|
if (waiting > 0) {
|
|
143
148
|
leave();
|
|
144
149
|
}
|
|
145
150
|
return;
|
|
146
151
|
}
|
|
147
|
-
if (waiting === 0 && notice.url === current) {
|
|
152
|
+
if (waiting === 0 && notice.url === current && !notice.same) {
|
|
148
153
|
// A late copy for the page the frame is on (its leaving page's, or its own): no new page.
|
|
154
|
+
// (A document that stayed says so for each navigation within it, the same address again
|
|
155
|
+
// too: each may come with a load.)
|
|
149
156
|
return;
|
|
150
157
|
}
|
|
151
158
|
if (waiting > 0) {
|
|
152
159
|
if (notice.set === "ok") {
|
|
153
160
|
taken(notice.url);
|
|
154
161
|
}
|
|
162
|
+
} else if (notice.same) {
|
|
163
|
+
// A document that stayed is no page to come: its word is for a load at hand (WebKit fires
|
|
164
|
+
// it with the navigation within the document, before or after the frame's word, P142),
|
|
165
|
+
// and never shortens a page's word already given.
|
|
166
|
+
if (grantUntil <= Date.now()) {
|
|
167
|
+
grantUntil = Date.now() + LATE_NOTICE_MS;
|
|
168
|
+
grantFor = notice.url;
|
|
169
|
+
}
|
|
155
170
|
} else {
|
|
156
171
|
// Either page's notice, for the next load within P084's ten seconds: the host hears the
|
|
157
172
|
// frame's load only once its images and modules have loaded, which can be seconds after
|
package/src/isolation/served.ts
CHANGED
|
@@ -78,6 +78,31 @@ export function hostOriginProblem(origin: unknown): string | null {
|
|
|
78
78
|
return `${JSON.stringify(origin)} is not an exact origin (scheme://host[:port], lowercase, no path)`;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* An origin as a browser serializes it, for comparing two (P144):
|
|
83
|
+
* scheme and host lowercase, and for `http`/`https` a default port dropped, so
|
|
84
|
+
* `https://app.example:443` is `https://app.example`. Any other scheme's origin (a desktop app's) is
|
|
85
|
+
* only lowercased.
|
|
86
|
+
*/
|
|
87
|
+
export function normalOrigin(origin: string): string {
|
|
88
|
+
const lower = origin.toLowerCase();
|
|
89
|
+
if (lower.startsWith("https://") || lower.startsWith("http://")) {
|
|
90
|
+
try {
|
|
91
|
+
const serialized = new URL(lower).origin;
|
|
92
|
+
if (serialized !== "null") {
|
|
93
|
+
return serialized;
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
// Not a URL: compared as it is, lowercase.
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return lower;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Whether `origin` is one of `origins`, compared as browsers serialize them (`normalOrigin`). */
|
|
103
|
+
export const includesOrigin = (origins: readonly string[], origin: string): boolean =>
|
|
104
|
+
origins.some((each) => normalOrigin(each) === normalOrigin(origin));
|
|
105
|
+
|
|
81
106
|
const LOOPBACK_HOST = (host: string): boolean =>
|
|
82
107
|
host === "localhost" || host.endsWith(".localhost") || host === "127.0.0.1" || host === "[::1]";
|
|
83
108
|
|
package/src/protocol/mcp-apps.ts
CHANGED
|
@@ -150,9 +150,11 @@ export const NAVIGATION_BLOCKED_METHOD = "porthole/navigation-blocked";
|
|
|
150
150
|
/**
|
|
151
151
|
* Porthole's own notification from the shell (P084): a page that came with files is opening
|
|
152
152
|
* another page of its set, `{ url }`, in the frame; and, as it arrives, the page a navigation
|
|
153
|
-
* opened says so, `{ url, arrived: true }` (P098)
|
|
154
|
-
*
|
|
155
|
-
*
|
|
153
|
+
* opened says so, `{ url, arrived: true }` (P098), with or without the Navigation API (P142); and a
|
|
154
|
+
* navigation within a page's document, `{ url, same: true }` (P142: WebKit fires the frame's load
|
|
155
|
+
* for one). The host takes the frame's next load (or the load it came after, within
|
|
156
|
+
* `LATE_NOTICE_MS`) for that page rather than for content that left (P031). The content's word: it
|
|
157
|
+
* only spares a restart.
|
|
156
158
|
*/
|
|
157
159
|
export const NAVIGATING_METHOD = "porthole/navigating";
|
|
158
160
|
|
|
@@ -301,6 +301,11 @@ export const shellAdapter: ProtocolAdapter<ShellConnection> = {
|
|
|
301
301
|
calls.unwatch(params);
|
|
302
302
|
return;
|
|
303
303
|
case NAVIGATING_METHOD:
|
|
304
|
+
// A navigation within the page's document (P142): the page, its calls and what it
|
|
305
|
+
// follows stay.
|
|
306
|
+
if (params.same === true) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
304
309
|
// Another page of the set opens in the frame (P084): its next load is that page, which
|
|
305
310
|
// follows nothing yet.
|
|
306
311
|
forget();
|
package/src/server/host.ts
CHANGED
|
@@ -120,6 +120,13 @@ export interface ContentHostOptions<V> {
|
|
|
120
120
|
* own `frame-ancestors` (its page's, which Porthole doesn't send) is the app's to set.
|
|
121
121
|
*/
|
|
122
122
|
readonly framedBy?: readonly string[];
|
|
123
|
+
/**
|
|
124
|
+
* Whether `access` may answer an embed grant (P143, `Grant.embed`): a public artifact page that
|
|
125
|
+
* any site may frame, with no host (`ServerOptions.embeds`). Default false: an embed grant is
|
|
126
|
+
* refused at issue. Only an embed session's answers say `frame-ancestors *`; every other answer
|
|
127
|
+
* is as without it.
|
|
128
|
+
*/
|
|
129
|
+
readonly embeds?: boolean;
|
|
123
130
|
/** At least 32 random bytes (or a string of at least 32 bytes). */
|
|
124
131
|
readonly secret: Uint8Array | string;
|
|
125
132
|
readonly tickets?: TicketStore;
|
|
@@ -692,6 +699,7 @@ export function createContentHost<V>(options: ContentHostOptions<V>): ContentHos
|
|
|
692
699
|
secret,
|
|
693
700
|
hostOrigins: options.appOrigins,
|
|
694
701
|
...(options.framedBy === undefined ? {} : { framedBy: options.framedBy }),
|
|
702
|
+
...(options.embeds === undefined ? {} : { embeds: options.embeds }),
|
|
695
703
|
configs,
|
|
696
704
|
...(options.source === undefined ? {} : { artifacts: { get: options.source } }),
|
|
697
705
|
...(options.assets === undefined
|