@botiverse/porthole 0.13.0 → 0.14.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/CHANGELOG.md +770 -0
- package/dist/annotate/types.d.ts +36 -4
- package/dist/annotate/types.js +6 -0
- package/dist/annotate/validate.d.ts +2 -1
- package/dist/annotate/validate.js +30 -6
- package/dist/check/page-source.js +1 -1
- package/dist/compile/policy.d.ts +7 -0
- package/dist/compile/policy.js +13 -1
- 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/host/create-host.d.ts +2 -0
- package/dist/host/create-host.js +78 -3
- package/dist/host/pass-on.d.ts +15 -0
- package/dist/host/pass-on.js +65 -0
- package/dist/host/types.d.ts +29 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/isolation/types.d.ts +8 -0
- package/dist/isolation/types.js +8 -0
- package/dist/platform/focus-guard.d.ts +71 -2
- package/dist/platform/focus-guard.js +187 -12
- package/dist/platform/types.d.ts +8 -1
- package/dist/platform/web.js +60 -4
- package/dist/presets/presets.d.ts +2 -0
- package/dist/presets/presets.js +1 -0
- package/dist/react/frame.d.ts +4 -3
- package/dist/server/files.js +19 -3
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/naming.js +4 -0
- package/dist/server/nested.d.ts +59 -0
- package/dist/server/nested.js +96 -0
- package/dist/server/server.js +193 -23
- package/dist/server/types.d.ts +5 -0
- package/dist/shell/annotate.d.ts +4 -3
- package/dist/shell/annotate.js +179 -9
- 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.d.ts +6 -0
- package/dist/shell/runtime.js +60 -15
- package/docs/ADOPTING.md +85 -2
- package/docs/ARCHITECTURE.md +28 -0
- package/docs/DECISIONS.md +416 -1
- package/docs/DESIGN.md +21 -4
- package/docs/THREAT_MODEL.md +102 -5
- package/package.json +6 -5
- package/src/annotate/types.ts +32 -4
- package/src/annotate/validate.ts +34 -8
- package/src/compile/policy.ts +14 -1
- 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/host/create-host.ts +81 -4
- package/src/host/pass-on.ts +73 -0
- package/src/host/types.ts +27 -0
- package/src/index.ts +4 -1
- package/src/isolation/types.ts +12 -0
- package/src/platform/focus-guard.ts +258 -15
- package/src/platform/types.ts +8 -1
- package/src/platform/web.ts +81 -9
- package/src/presets/presets.ts +3 -0
- package/src/react/frame.tsx +4 -3
- package/src/server/files.ts +19 -3
- package/src/server/index.ts +14 -0
- package/src/server/naming.ts +4 -0
- package/src/server/nested.ts +116 -0
- package/src/server/server.ts +224 -21
- package/src/server/types.ts +5 -0
- package/src/shell/annotate.ts +179 -9
- package/src/shell/frame.ts +268 -0
- package/src/shell/plan.ts +2 -1
- package/src/shell/runtime.ts +61 -15
package/dist/compile/policy.d.ts
CHANGED
|
@@ -85,6 +85,13 @@ export declare function sandboxTokens(config: PortholeConfig): string[];
|
|
|
85
85
|
* own documents, and opaque content is never served. Never in a `<meta>` (browsers ignore it there).
|
|
86
86
|
*/
|
|
87
87
|
export declare function servedSandboxDirective(config: PortholeConfig): CspDirective | null;
|
|
88
|
+
/**
|
|
89
|
+
* A nested page's sandbox (P111): its frame's attribute, set by Porthole's shell, and its own CSP
|
|
90
|
+
* header's, so it is an opaque origin in the shell's child frame and on a tab of its own. Scripts
|
|
91
|
+
* only: never `allow-same-origin`, which would give the page its served origin, the shell's, and
|
|
92
|
+
* so the shell's realm (a test holds every sandbox Porthole writes to this).
|
|
93
|
+
*/
|
|
94
|
+
export declare const PAGE_SANDBOX_TOKENS: readonly string[];
|
|
88
95
|
/** A served page's CSP header: the page's directives, then its sandbox (P099). */
|
|
89
96
|
export declare function servedDocumentCsp(config: PortholeConfig, directives: readonly CspDirective[]): string;
|
|
90
97
|
/**
|
package/dist/compile/policy.js
CHANGED
|
@@ -173,6 +173,8 @@ export function sandboxTokens(config) {
|
|
|
173
173
|
case "opaque":
|
|
174
174
|
return ["allow-scripts"];
|
|
175
175
|
case "domain":
|
|
176
|
+
// Nested (P111), this frame holds Porthole's shell, on a label of its own where no content
|
|
177
|
+
// runs with this origin (P114), and the page is the shell's child (`PAGE_SANDBOX_TOKENS`).
|
|
176
178
|
return ["allow-scripts", "allow-same-origin"];
|
|
177
179
|
case "external":
|
|
178
180
|
// The host may add a documented few (popups, modals, downloads), never top navigation.
|
|
@@ -190,8 +192,18 @@ export function sandboxTokens(config) {
|
|
|
190
192
|
* own documents, and opaque content is never served. Never in a `<meta>` (browsers ignore it there).
|
|
191
193
|
*/
|
|
192
194
|
export function servedSandboxDirective(config) {
|
|
193
|
-
|
|
195
|
+
if (config.isolation !== "domain") {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return ["sandbox", ...(config.nested === true ? PAGE_SANDBOX_TOKENS : sandboxTokens(config))];
|
|
194
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* A nested page's sandbox (P111): its frame's attribute, set by Porthole's shell, and its own CSP
|
|
202
|
+
* header's, so it is an opaque origin in the shell's child frame and on a tab of its own. Scripts
|
|
203
|
+
* only: never `allow-same-origin`, which would give the page its served origin, the shell's, and
|
|
204
|
+
* so the shell's realm (a test holds every sandbox Porthole writes to this).
|
|
205
|
+
*/
|
|
206
|
+
export const PAGE_SANDBOX_TOKENS = ["allow-scripts"];
|
|
195
207
|
/** A served page's CSP header: the page's directives, then its sandbox (P099). */
|
|
196
208
|
export function servedDocumentCsp(config, directives) {
|
|
197
209
|
const sandbox = servedSandboxDirective(config);
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -238,6 +238,17 @@ export interface PortholeConfig {
|
|
|
238
238
|
* `db`). Absent: 0.6's frames, globals and manual, exactly.
|
|
239
239
|
*/
|
|
240
240
|
readonly runtime?: RuntimeVersion;
|
|
241
|
+
/**
|
|
242
|
+
* Domain isolation, artifact pages (P111): the address the host frames serves Porthole's shell
|
|
243
|
+
* alone, a document of Porthole's own with no content in it, and the page runs in a child frame
|
|
244
|
+
* of the shell's, sandboxed without `allow-same-origin` (an opaque origin), served from the same
|
|
245
|
+
* origin at its files' sealed address. The shell is then a realm the page can't reach, above the
|
|
246
|
+
* page's frame: it relays the page's messages, and tells the host when its own transient
|
|
247
|
+
* activation turns on (a press in the page activates its ancestors only), which is how the host
|
|
248
|
+
* knows the person, not the page, moved the keyboard into the frame or opened a comment. The
|
|
249
|
+
* page has no storage of its own (an in-memory stand-in) and fetches nothing with a cookie.
|
|
250
|
+
*/
|
|
251
|
+
readonly nested?: true;
|
|
241
252
|
}
|
|
242
253
|
export interface StorageConfig {
|
|
243
254
|
/**
|
package/dist/config/validate.js
CHANGED
|
@@ -270,6 +270,7 @@ export function validateConfig(input, options = {}) {
|
|
|
270
270
|
"storage",
|
|
271
271
|
"errors",
|
|
272
272
|
"runtime",
|
|
273
|
+
"nested",
|
|
273
274
|
], "config");
|
|
274
275
|
if (!MODES.includes(config.mode)) {
|
|
275
276
|
fail("config.mode", `must be one of ${MODES.join(", ")}`);
|
|
@@ -544,6 +545,24 @@ export function validateConfig(input, options = {}) {
|
|
|
544
545
|
fail("config.storage.shared", 'must be a short lowercase noun ("conversation")');
|
|
545
546
|
}
|
|
546
547
|
}
|
|
548
|
+
if (config.nested !== undefined) {
|
|
549
|
+
if (config.nested !== true) {
|
|
550
|
+
fail("config.nested", "must be true, or left out");
|
|
551
|
+
}
|
|
552
|
+
if (config.isolation !== "domain" || config.mode !== "artifact") {
|
|
553
|
+
fail("config.nested", "nests artifact pages served on their own origin (domain isolation)");
|
|
554
|
+
}
|
|
555
|
+
// The page's origin is opaque (P111): nothing of the content origin's own is its.
|
|
556
|
+
if (config.storage !== undefined) {
|
|
557
|
+
fail("config.nested", "a nested page keeps no storage: drop config.storage");
|
|
558
|
+
}
|
|
559
|
+
if (capabilities.assets !== undefined) {
|
|
560
|
+
fail("config.nested", "a nested page can't load its asset library (/_blob/) yet: drop assets");
|
|
561
|
+
}
|
|
562
|
+
if (isObject(config.egress) && config.egress.libraries === true) {
|
|
563
|
+
fail("config.nested", "a nested page can't load Porthole's libraries from its origin yet");
|
|
564
|
+
}
|
|
565
|
+
}
|
|
547
566
|
if (config.errors !== undefined) {
|
|
548
567
|
if (config.errors !== "agent" && config.errors !== "host" && config.errors !== "none") {
|
|
549
568
|
fail("config.errors", 'must be "agent", "host" or "none"');
|