@botiverse/porthole 0.15.2 → 0.16.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/bridge/bridge.d.ts +1 -8
  3. package/dist/bridge/bridge.js +0 -7
  4. package/dist/check/page-source.js +1 -1
  5. package/dist/check/page.js +1 -1
  6. package/dist/compile/policy.d.ts +0 -7
  7. package/dist/compile/policy.js +1 -10
  8. package/dist/config/capabilities.d.ts +8 -14
  9. package/dist/config/capabilities.js +4 -5
  10. package/dist/config/schema.d.ts +2 -13
  11. package/dist/config/validate.js +0 -24
  12. package/dist/conformance/behavior.js +26 -37
  13. package/dist/conformance/clipboard.js +47 -1
  14. package/dist/conformance/harness-source.js +1 -1
  15. package/dist/displays/displays.js +1 -3
  16. package/dist/guide/limits.js +1 -1
  17. package/dist/guide/runtime.js +1 -1
  18. package/dist/host/create-host.d.ts +1 -1
  19. package/dist/host/create-host.js +6 -51
  20. package/dist/host/door.d.ts +1 -1
  21. package/dist/host/locate.d.ts +1 -1
  22. package/dist/host/locate.js +2 -2
  23. package/dist/host/outcome.d.ts +5 -12
  24. package/dist/host/outcome.js +8 -16
  25. package/dist/host/types.d.ts +6 -22
  26. package/dist/index.d.ts +2 -4
  27. package/dist/index.js +2 -4
  28. package/dist/isolation/served.d.ts +9 -14
  29. package/dist/isolation/served.js +17 -31
  30. package/dist/isolation/types.d.ts +2 -19
  31. package/dist/isolation/types.js +0 -17
  32. package/dist/platform/focus-field.d.ts +11 -0
  33. package/dist/platform/focus-field.js +18 -0
  34. package/dist/platform/types.d.ts +6 -22
  35. package/dist/platform/web.js +8 -98
  36. package/dist/presets/presets.d.ts +0 -2
  37. package/dist/presets/presets.js +0 -1
  38. package/dist/react/frame.d.ts +0 -8
  39. package/dist/react/frame.js +0 -4
  40. package/dist/runtime/contract.d.ts +2 -2
  41. package/dist/runtime/contract.js +2 -2
  42. package/dist/runtime/types.generated.js +6 -6
  43. package/dist/server/files.js +7 -23
  44. package/dist/server/host.d.ts +1 -1
  45. package/dist/server/index.d.ts +1 -1
  46. package/dist/server/index.js +4 -6
  47. package/dist/server/naming.js +1 -1
  48. package/dist/server/pages.d.ts +9 -2
  49. package/dist/server/pages.js +28 -8
  50. package/dist/server/server.js +28 -166
  51. package/dist/server/types.d.ts +7 -7
  52. package/dist/shell/plan.js +2 -2
  53. package/dist/shell/runtime.js +1 -9
  54. package/docs/ADOPTING.md +42 -135
  55. package/docs/ARCHITECTURE.md +0 -33
  56. package/docs/DECISIONS.md +296 -9
  57. package/docs/DESIGN.md +27 -50
  58. package/docs/THREAT_MODEL.md +140 -242
  59. package/package.json +1 -1
  60. package/src/bridge/bridge.ts +1 -17
  61. package/src/check/page.ts +1 -1
  62. package/src/compile/policy.ts +1 -11
  63. package/src/config/capabilities.ts +8 -14
  64. package/src/config/schema.ts +2 -13
  65. package/src/config/validate.ts +0 -28
  66. package/src/conformance/behavior.ts +50 -52
  67. package/src/conformance/clipboard.ts +56 -1
  68. package/src/displays/displays.ts +1 -3
  69. package/src/guide/limits.ts +1 -1
  70. package/src/guide/runtime.ts +1 -1
  71. package/src/host/create-host.ts +6 -52
  72. package/src/host/door.ts +1 -1
  73. package/src/host/locate.ts +2 -2
  74. package/src/host/outcome.ts +8 -21
  75. package/src/host/types.ts +6 -20
  76. package/src/index.ts +2 -4
  77. package/src/isolation/served.ts +18 -37
  78. package/src/isolation/types.ts +2 -24
  79. package/src/platform/focus-field.ts +18 -0
  80. package/src/platform/types.ts +6 -21
  81. package/src/platform/web.ts +8 -116
  82. package/src/presets/presets.ts +0 -3
  83. package/src/react/frame.tsx +0 -10
  84. package/src/runtime/contract.ts +4 -4
  85. package/src/runtime/types.generated.ts +6 -6
  86. package/src/server/files.ts +4 -19
  87. package/src/server/host.ts +1 -1
  88. package/src/server/index.ts +4 -16
  89. package/src/server/naming.ts +1 -1
  90. package/src/server/pages.ts +38 -12
  91. package/src/server/server.ts +29 -189
  92. package/src/server/types.ts +7 -7
  93. package/src/shell/plan.ts +2 -2
  94. package/src/shell/runtime.ts +1 -9
  95. package/types/runtime/v1/artifact.d.ts +2 -3
  96. package/types/runtime/v1/assets.d.ts +1 -1
  97. package/types/runtime/v1/chat.d.ts +2 -2
  98. package/types/runtime/v1/comments.d.ts +1 -1
  99. package/types/runtime/v1/downloads.d.ts +2 -2
  100. package/types/runtime/v1/links.d.ts +2 -2
  101. package/dist/platform/focus-guard.d.ts +0 -252
  102. package/dist/platform/focus-guard.js +0 -764
  103. package/dist/server/nested.d.ts +0 -66
  104. package/dist/server/nested.js +0 -120
  105. package/dist/shell/frame.d.ts +0 -28
  106. package/dist/shell/frame.js +0 -338
  107. package/src/platform/focus-guard.ts +0 -999
  108. package/src/server/nested.ts +0 -156
  109. package/src/shell/frame.ts +0 -371
@@ -28,15 +28,8 @@ import {
28
28
  tabOnlyPage,
29
29
  } from "./pages.ts";
30
30
  import { libraryFile } from "./libraries.ts";
31
- import { isNavigation, ownLoad, serveAsset, serveFile, ticketPage } from "./files.ts";
32
- import {
33
- isNestedLabel,
34
- nestedAncestors,
35
- nestedLabelOf,
36
- nestedFileCsp,
37
- nestedShellResponse,
38
- PORTHOLE_LABEL_PREFIX,
39
- } from "./nested.ts";
31
+ import { ownLoad, serveAsset, serveFile, ticketPage } from "./files.ts";
32
+ import { PORTHOLE_LABEL_PREFIX } from "../isolation/served.ts";
40
33
  import { DEFAULT_ENTRY } from "../files/paths.ts";
41
34
  import { isPagePath } from "../files/types.ts";
42
35
  import { isPortholeCookie, setsPortholeCookie } from "./proxy.ts";
@@ -95,10 +88,8 @@ const BASE = /^\/(?:(?!\.{1,2}\/)[A-Za-z0-9._:~-]{1,200}\/){0,16}$/u;
95
88
  const ENTER_PATH = "/__porthole/enter";
96
89
  /** Where a redirect entry's code is redeemed, before its clean address (P068). */
97
90
  const ENTRY_PATH = "/__porthole/entry";
98
- /** How long a nested page's ticket from its clean address to its shell's label lasts (P114). */
99
- const HOP_SECONDS = 60;
100
91
  /**
101
- * A path below a file set's base, as a hop's ticket carries it (P114): a relative path of URL path
92
+ * A path below a file set's base, as a ticket carries it (a page of a set, P125): a relative path of URL path
102
93
  * characters, no empty segment but a last one, no dot segment (encoded or not), no query.
103
94
  */
104
95
  const isPageRest = (rest: unknown): rest is string =>
@@ -373,32 +364,13 @@ export function createServer(options: ServerOptions): PortholeServer {
373
364
  }
374
365
  return label;
375
366
  };
376
- /**
377
- * The label an instance is served on: its scope's, or a nested page's shell's own (P114), on
378
- * which nothing but nested pages' shells, their pages and those pages' files is ever served.
379
- * Every other display of the scope runs agent-made content on the scope's origin with
380
- * `allow-same-origin`: on that origin, the shell's realm (its word to the host, the page's
381
- * sealed address) would be theirs.
382
- */
383
- const labelFor = (instance: InstanceRef): string => {
384
- const label = nameOf(instance.scope);
385
- if (instance.document.kind !== "artifact" || compiledFor(instance)?.config.nested !== true) {
386
- return label;
387
- }
388
- const own = nestedLabelOf(label);
389
- if (isReserved(own)) {
390
- throw new TypeError(
391
- `content.reserved holds ${own}, a nested page's shell's label: reserve no ${PORTHOLE_LABEL_PREFIX} label`,
392
- );
393
- }
394
- return own;
395
- };
396
- /** Whether a request's label may be one this server named (a nested page's shell's, P114). */
367
+ /** The label an instance is served on: its scope's. */
368
+ const labelFor = (instance: InstanceRef): string => nameOf(instance.scope);
369
+ /** Whether a request's label may be one this server named: never one of Porthole's own. */
397
370
  const ours = (label: string): boolean =>
398
371
  !isReserved(label) &&
399
- (isNestedLabel(label) ||
400
- (!label.startsWith(PORTHOLE_LABEL_PREFIX) &&
401
- (content.name === undefined ? LABEL.test(label) : isHostLabel(label))));
372
+ !label.startsWith(PORTHOLE_LABEL_PREFIX) &&
373
+ (content.name === undefined ? LABEL.test(label) : isHostLabel(label));
402
374
  const secure = content.scheme === "https";
403
375
  const defaultPort = secure ? 443 : 80;
404
376
  const portPart =
@@ -408,7 +380,6 @@ export function createServer(options: ServerOptions): PortholeServer {
408
380
  const contentSource = `${content.scheme}://*.${domain}${portPart}`;
409
381
  const sampleHost = `${keys.label("")}.${domain}`;
410
382
  const sampleOrigin = originOfLabel(keys.label(""));
411
- const sampleNestedOrigin = originOfLabel(nestedLabelOf(keys.label("")));
412
383
  const authorize = options.authorize;
413
384
  const authorizeTtl = authorize?.ttlSeconds ?? 0;
414
385
  if (!Number.isInteger(authorizeTtl) || authorizeTtl < 0 || authorizeTtl > 300) {
@@ -618,13 +589,7 @@ export function createServer(options: ServerOptions): PortholeServer {
618
589
  `The config ${JSON.stringify(name)} (${config.mode}, ${config.isolation}) can't serve a ${kind}: it needs ${MODES[kind].join(" or ")} mode with domain isolation`,
619
590
  );
620
591
  }
621
- // A nested page's shell is on a label of its own (P114): its frame source is the same.
622
- const samples = config.nested === true ? [sampleOrigin, sampleNestedOrigin] : [sampleOrigin];
623
- if (
624
- !samples.every((sample) =>
625
- config.contentOrigins.some((source) => originMatchesSource(sample, source)),
626
- )
627
- ) {
592
+ if (!config.contentOrigins.some((source) => originMatchesSource(sampleOrigin, source))) {
628
593
  throw new TypeError(
629
594
  `The config ${JSON.stringify(name)}'s contentOrigins don't include this server's (${contentSource})`,
630
595
  );
@@ -679,8 +644,6 @@ export function createServer(options: ServerOptions): PortholeServer {
679
644
  ): Promise<
680
645
  | {
681
646
  readonly html: string;
682
- /** An artifact's own page, before the shell (a nested page's is made apart, P111). */
683
- readonly document?: string;
684
647
  readonly compiled: CompiledConfig;
685
648
  /** Whether its CSP opens its artifact's asset library (P089): an artifact's page. */
686
649
  readonly assets: boolean;
@@ -715,7 +678,6 @@ export function createServer(options: ServerOptions): PortholeServer {
715
678
  }
716
679
  return {
717
680
  html: config.shellDocument({ origins, document: stored.html, cspMeta: false }),
718
- document: stored.html,
719
681
  compiled: config,
720
682
  assets: true,
721
683
  };
@@ -977,8 +939,8 @@ export function createServer(options: ServerOptions): PortholeServer {
977
939
  }
978
940
 
979
941
  /**
980
- * A taken ticket, if it is good for `label`'s origin: its instance's own (a nested page's shell's,
981
- * P114), or for an entry code (`entry`) its scope's, where a clean address is.
942
+ * A taken ticket, if it is good for `label`'s origin: its instance's own, or for an entry code
943
+ * (`entry`) its scope's, where a clean address is.
982
944
  */
983
945
  async function take(
984
946
  ticket: string | null,
@@ -1149,23 +1111,20 @@ export function createServer(options: ServerOptions): PortholeServer {
1149
1111
  true,
1150
1112
  );
1151
1113
  }
1152
- // In a nested page's frame (P111) its shell frames it and hears it, on this origin; a
1153
- // config without nesting never frames this address but at the host.
1154
1114
  return statusPage(
1155
1115
  401,
1156
1116
  "This has ended",
1157
1117
  "Content here opens for a while. Open it again from the app that showed it.",
1158
- nestedAncestors(origin, frameAncestors),
1118
+ frameAncestors,
1159
1119
  method,
1160
1120
  "session",
1161
- [...options.hostOrigins, origin],
1121
+ options.hostOrigins,
1162
1122
  );
1163
1123
  }
1164
1124
  // An asset of this artifact's library, at the frame's own sealed address (P091): every engine
1165
1125
  // sends a frame's path, where some send no Referer that names it.
1166
1126
  const blob = SEALED_ASSET.exec(rest)?.[1];
1167
1127
  if (blob !== undefined) {
1168
- // A nested page loads no assets (its config refuses them): none on its shell's label (P114).
1169
1128
  const none = () =>
1170
1129
  page(
1171
1130
  404,
@@ -1176,7 +1135,7 @@ export function createServer(options: ServerOptions): PortholeServer {
1176
1135
  undefined,
1177
1136
  access.embed === true,
1178
1137
  );
1179
- if (options.assets === undefined || isNestedLabel(label)) {
1138
+ if (options.assets === undefined) {
1180
1139
  return none();
1181
1140
  }
1182
1141
  return (await assetFor(request, label, access, blob)) ?? none();
@@ -1270,7 +1229,7 @@ export function createServer(options: ServerOptions): PortholeServer {
1270
1229
  "session",
1271
1230
  );
1272
1231
  }
1273
- // A nested page's hop from its clean address (P114): the page below its base it was entered at.
1232
+ // The page below its base the ticket was issued for (a page of a set, P125).
1274
1233
  const asked = cookie === null ? undefined : record?.page;
1275
1234
  const rest = isPageRest(asked) ? asked : undefined;
1276
1235
  return serveAccess(request, access, cookie, undefined, rest);
@@ -1290,8 +1249,7 @@ export function createServer(options: ServerOptions): PortholeServer {
1290
1249
  /**
1291
1250
  * A served display's door (P125): its own ticket's, taken once, for this instance on this
1292
1251
  * origin; then the door's answer for that ticket's grant (`answerDoor`, the one `doorAnswer`
1293
- * gives, P126). No other ticket opens it, and a nested page's shell's label serves none
1294
- * (`serveShellLabel`).
1252
+ * gives, P126). No other ticket opens it.
1295
1253
  */
1296
1254
  async function serveDoor(
1297
1255
  request: Request,
@@ -1312,8 +1270,7 @@ export function createServer(options: ServerOptions): PortholeServer {
1312
1270
  record.embed === true ||
1313
1271
  record.entry !== undefined ||
1314
1272
  record.instance.document.kind === "external" ||
1315
- keys.instanceKey(record.instance) !== key ||
1316
- compiledFor(record.instance)?.config.nested === true
1273
+ keys.instanceKey(record.instance) !== key
1317
1274
  ) {
1318
1275
  return doorSays(401, "session", method);
1319
1276
  }
@@ -1382,7 +1339,7 @@ export function createServer(options: ServerOptions): PortholeServer {
1382
1339
  access: Access,
1383
1340
  cookie: string | null,
1384
1341
  at?: FilesAt,
1385
- /** A nested page's path below its files' base, from its hop's ticket (P114). */
1342
+ /** The page below its files' base its ticket was issued for (a page of a set, P125). */
1386
1343
  pageAt?: string,
1387
1344
  ): Promise<Response> {
1388
1345
  const method = request.method.toUpperCase();
@@ -1420,55 +1377,8 @@ export function createServer(options: ServerOptions): PortholeServer {
1420
1377
  ) {
1421
1378
  return missing();
1422
1379
  }
1423
- // A nested page (P111): the address the host frames (a ticket's, a cookie's, an entered
1424
- // one's) answers Porthole's shell, which frames the page at its sealed files' address; only
1425
- // that address, below the sealed prefix, answers the page and its files, without a cookie.
1426
- const nested = served.compiled.config.nested === true;
1427
- const sealedAt = at !== undefined && at.base.startsWith(FILES_PREFIX);
1428
- if (nested && !sealedAt) {
1429
- if (!isNavigation(request)) {
1430
- return page(404, "Not found", "This page's files are at its own address.", method);
1431
- }
1432
- // Its shell is served on its own label alone (P114): a clean address, entered on the scope's
1433
- // label (P068), goes there with a one-time ticket of its own, for what is left of its session.
1434
- const own = originOfLabel(labelFor(access.instance));
1435
- if (access.origin !== own) {
1436
- return hop(access, own, "files" in served && at !== undefined ? at.rest : "");
1437
- }
1438
- const sealed = await sealFiles(access);
1439
- let rest = "";
1440
- if ("files" in served) {
1441
- const entry = served.files.entry ?? DEFAULT_ENTRY;
1442
- rest =
1443
- pageAt !== undefined
1444
- ? pageAt
1445
- : at !== undefined && at.rest !== ""
1446
- ? at.rest
1447
- : entry.includes("/")
1448
- ? entry
1449
- .split("/")
1450
- .map((segment) => encodeURIComponent(segment))
1451
- .join("/")
1452
- : "";
1453
- }
1454
- const shell = nestedShellResponse(served.compiled, {
1455
- origin: access.origin,
1456
- origins: options.hostOrigins,
1457
- framedBy,
1458
- page: `${access.origin}${sealed.base}${rest}`,
1459
- renew: { url: `${access.origin}${sealed.base}__porthole/renew`, expires: sealed.expires },
1460
- method,
1461
- });
1462
- if (cookie !== null) {
1463
- shell.headers.set("set-cookie", cookie);
1464
- }
1465
- return shell;
1466
- }
1467
- // Below the sealed prefix, a nested page and its files are framed by its shell too. An embed
1468
- // session is never nested (`issue`): its answers are framed by any page (P143).
1469
- const ancestors = nested
1470
- ? nestedAncestors(access.origin, frameAncestors)
1471
- : ancestorsFor(access);
1380
+ // An embed session's answers are framed by any page (P143).
1381
+ const ancestors = ancestorsFor(access);
1472
1382
  // Whom its pages hear and tell: the host origins, or no one for an embed session (P143).
1473
1383
  const hostOrigins = embed ? [] : options.hostOrigins;
1474
1384
  if ("files" in served) {
@@ -1523,55 +1433,14 @@ export function createServer(options: ServerOptions): PortholeServer {
1523
1433
  ? assetCspDirectives(config, cspDirectives, access.origin)
1524
1434
  : cspDirectives;
1525
1435
  const headers = documentHeaders(
1526
- nested ? nestedFileCsp("page", directives) : servedDocumentCsp(config, directives),
1436
+ servedDocumentCsp(config, directives),
1527
1437
  servedPermissionsPolicy(config),
1528
1438
  ancestors,
1529
1439
  );
1530
1440
  if (cookie !== null) {
1531
1441
  headers.set("set-cookie", cookie);
1532
1442
  }
1533
- // A nested page's document takes messages from its shell, on its own origin (P111).
1534
- const html = nested
1535
- ? served.compiled.shellDocument({
1536
- origins: [access.origin],
1537
- document: served.document ?? "",
1538
- cspMeta: false,
1539
- })
1540
- : served.html;
1541
- return new Response(method === "HEAD" ? null : html, { status: 200, headers });
1542
- }
1543
-
1544
- /**
1545
- * A nested page entered at its clean address (P114), whose shell is never served there: on to the
1546
- * shell's own label, with a one-time ticket for the same access (its viewer, its subject, what is
1547
- * left of its session) and the path below its base it was entered at. Only this server's own
1548
- * answer carries the ticket, as `issue`'s frame address does; the host's check already let the
1549
- * request in.
1550
- */
1551
- async function hop(access: Access, own: string, rest: string): Promise<Response> {
1552
- const now = Date.now();
1553
- const ticket = newTicket();
1554
- await tickets.put(ticketId(ticket), {
1555
- instance: access.instance,
1556
- viewer: access.viewer,
1557
- expiresAt: now + HOP_SECONDS * 1_000,
1558
- sessionSeconds: Math.min(
1559
- MAX_SESSION_SECONDS,
1560
- Math.max(1, Math.floor((access.expiresAt - now) / 1_000)),
1561
- ),
1562
- ...(access.anonymous === true ? { anonymous: true } : {}),
1563
- ...(access.subject === undefined ? {} : { subject: access.subject }),
1564
- ...(isPageRest(rest) ? { page: rest } : {}),
1565
- });
1566
- return new Response(null, {
1567
- status: 303,
1568
- headers: {
1569
- location: `${own}${PREFIX}d/${keys.instanceKey(access.instance)}?ticket=${ticket}`,
1570
- "cache-control": "no-store",
1571
- "referrer-policy": "no-referrer",
1572
- "x-robots-tag": "noindex, nofollow",
1573
- },
1574
- });
1443
+ return new Response(method === "HEAD" ? null : served.html, { status: 200, headers });
1575
1444
  }
1576
1445
 
1577
1446
  /**
@@ -2035,29 +1904,6 @@ export function createServer(options: ServerOptions): PortholeServer {
2035
1904
  }
2036
1905
  }
2037
1906
 
2038
- /**
2039
- * A nested page's shell's own label (P114): Porthole's shell at a frame's address, its page and
2040
- * that page's files below the sealed prefix, and Porthole's status pages (and their script).
2041
- * Nothing else: no clean address, entry, asset, library or app, so no agent-made content ever
2042
- * runs on this origin with it (every file below the prefix carries a sandbox without it).
2043
- */
2044
- async function serveShellLabel(request: Request, url: URL, label: string): Promise<Response> {
2045
- const method = request.method.toUpperCase();
2046
- const script = pageScript(url.pathname);
2047
- if (script !== null) {
2048
- return script;
2049
- }
2050
- const document = DOCUMENT_PATH.exec(url.pathname);
2051
- if (document?.[1] !== undefined) {
2052
- return serveDocument(request, url, label, document[1]);
2053
- }
2054
- const sealed = FILES_PATH.exec(url.pathname);
2055
- if (sealed?.[1] !== undefined) {
2056
- return serveSealed(request, url, label, sealed[1], sealed[2]);
2057
- }
2058
- return page(404, "Nothing here", "This address names no content.", method);
2059
- }
2060
-
2061
1907
  /** A grant, checked for an instance (`issue`'s rules, and `doorAnswer`'s, P126). */
2062
1908
  function checkGrant(
2063
1909
  clean: InstanceRef,
@@ -2066,7 +1912,7 @@ export function createServer(options: ServerOptions): PortholeServer {
2066
1912
  const anonymous = grant.anonymous === true;
2067
1913
  // An embedded document (P143): a public page with no host, which any page may frame. Only
2068
1914
  // where the host opted in, and only as narrow as that: anonymous, no level, no user, an
2069
- // artifact's page that isn't nested.
1915
+ // artifact's page.
2070
1916
  // Read as given: a host's grant is checked here, not trusted to its type.
2071
1917
  const asked: unknown = grant.embed;
2072
1918
  const embed = asked !== undefined;
@@ -2084,9 +1930,9 @@ export function createServer(options: ServerOptions): PortholeServer {
2084
1930
  "An embed grant is anonymous, with no viewer, level or user: it has no host to give them to (P143)",
2085
1931
  );
2086
1932
  }
2087
- if (clean.document.kind !== "artifact" || compiledFor(clean)?.config.nested === true) {
1933
+ if (clean.document.kind !== "artifact") {
2088
1934
  throw new TypeError(
2089
- "An embed grant opens an artifact's page that isn't nested: never a url-mode app, a served shell, the sandbox proxy or a nested display (P143)",
1935
+ "An embed grant opens an artifact's page: never a url-mode app, a served shell or the sandbox proxy (P143)",
2090
1936
  );
2091
1937
  }
2092
1938
  }
@@ -2182,11 +2028,11 @@ export function createServer(options: ServerOptions): PortholeServer {
2182
2028
 
2183
2029
  /**
2184
2030
  * Whether an instance's frame has a door (P125): a document framed on its scope's origin, where
2185
- * the scope's other displays run content (a served shell, a page that isn't nested, the sandbox
2186
- * proxy). A nested page's frame is its shell, on a label of its own; a url-mode app has none.
2031
+ * the scope's other displays run content (a served shell, a page, the sandbox proxy). A
2032
+ * url-mode app has none.
2187
2033
  */
2188
2034
  function hasDoor(instance: InstanceRef): boolean {
2189
- return instance.document.kind !== "external" && compiledFor(instance)?.config.nested !== true;
2035
+ return instance.document.kind !== "external";
2190
2036
  }
2191
2037
 
2192
2038
  const underDomain = (host: string): boolean => host === domain || host.endsWith(`.${domain}`);
@@ -2250,7 +2096,6 @@ export function createServer(options: ServerOptions): PortholeServer {
2250
2096
  );
2251
2097
  }
2252
2098
  const { clean, key, ticket, door } = await mint(instance, grant, undefined, below);
2253
- // A nested page's frame is its shell, on the shell's own label (P114).
2254
2099
  const origin = originOfLabel(labelFor(clean));
2255
2100
  const path =
2256
2101
  clean.document.kind === "external"
@@ -2274,9 +2119,7 @@ export function createServer(options: ServerOptions): PortholeServer {
2274
2119
  const clean = cleanInstance(instance);
2275
2120
  check(clean);
2276
2121
  if (!hasDoor(clean)) {
2277
- throw new TypeError(
2278
- "This instance has no door (P125): a nested page's frame is its shell, a url-mode app has none",
2279
- );
2122
+ throw new TypeError("This instance has no door (P125): a url-mode app has none");
2280
2123
  }
2281
2124
  const below = at.page;
2282
2125
  if (below !== undefined && (!isPageRest(below) || clean.document.kind !== "artifact")) {
@@ -2435,9 +2278,6 @@ export function createServer(options: ServerOptions): PortholeServer {
2435
2278
  if (!ours(label)) {
2436
2279
  return page(404, "Nothing here", "This address names no content.", method);
2437
2280
  }
2438
- if (isNestedLabel(label)) {
2439
- return await serveShellLabel(request, url, label);
2440
- }
2441
2281
  if (url.pathname === ENTER_PATH) {
2442
2282
  return await enter(request, url, label);
2443
2283
  }
@@ -80,8 +80,8 @@ export type Grant = (
80
80
  /**
81
81
  * An embedded document (P143): a public page that any site may frame, with no host. Only where
82
82
  * the server opted in (`ServerOptions.embeds`), only with `anonymous: true` and no `level` or
83
- * `user`, and only for an artifact's page that isn't nested (never a url-mode app, a served shell,
84
- * the sandbox proxy or a nested display); anything else throws at `issue`. Carried signed in the
83
+ * `user`, and only for an artifact's page (never a url-mode app, a served shell or the sandbox
84
+ * proxy); anything else throws at `issue`. Carried signed in the
85
85
  * session (and in a frame's sealed files' address), so it is never added to a session or taken
86
86
  * from one. Every answer of such a session says `frame-ancestors *` (no other session's changes),
87
87
  * its shell's plan names no host (it asks no host, hears none and tells no parent anything; the
@@ -113,14 +113,14 @@ export interface TicketRecord {
113
113
  readonly pinned?: boolean;
114
114
  };
115
115
  /**
116
- * A nested page's ticket from its clean address to its shell's own label (P114): the path below
117
- * its files' base the shell opens (the entry page when absent).
116
+ * The page below its files' base the ticket was issued for (a page of a set, P125): the entry
117
+ * page when absent.
118
118
  */
119
119
  readonly page?: string;
120
120
  /**
121
121
  * A door's ticket (P125): `issue` mints one beside the content's, for the same grant and as
122
- * long, for a display whose frame is on its scope's origin (a served shell, a page that isn't
123
- * nested, the sandbox proxy). Taken only at the door (`/__porthole/door/<key>`), never at the
122
+ * long, for a display whose frame is on its scope's origin (a served shell, a page, the sandbox
123
+ * proxy). Taken only at the door (`/__porthole/door/<key>`), never at the
124
124
  * content's address; the door takes no other.
125
125
  */
126
126
  readonly door?: true;
@@ -396,7 +396,7 @@ export interface PortholeServer {
396
396
  * is what `authorize.check` is handed (and gives the method: HEAD has no body, a method other
397
397
  * than GET or HEAD is 405); default, a GET of the door on the instance's origin. Throws, as
398
398
  * `issue` does, for an instance or grant `issue` would refuse, and for an instance with no door
399
- * (a nested page, a url-mode app).
399
+ * (a url-mode app).
400
400
  */
401
401
  doorAnswer(
402
402
  instance: InstanceRef,
package/src/shell/plan.ts CHANGED
@@ -102,8 +102,8 @@ export function shellPlan(config: PortholeConfig): ShellPlan | null {
102
102
  themeVariables: Object.keys(config.theme.variables),
103
103
  themeEvent: config.theme.event,
104
104
  themeDocuments: config.theme.documents ?? "declared",
105
- // An opaque origin has no storage: an opaque frame's, and a nested page's (P111).
106
- storage: config.isolation === "opaque" || config.nested === true ? "memory" : "native",
105
+ // An opaque origin has no storage.
106
+ storage: config.isolation === "opaque" ? "memory" : "native",
107
107
  maxErrorReports: config.limits.maxErrorReports,
108
108
  maxPromptChars: config.limits.maxPromptChars,
109
109
  maxCopyChars: MAX_COPY_CHARS,
@@ -276,8 +276,6 @@ export const SHELL_RUNTIME = String.raw`(() => {
276
276
  // takes the next load for that page, not for content that left). Anything else stays stopped:
277
277
  // another path of the origin, a file that isn't a page, another origin.
278
278
  let navigating = (_url) => {};
279
- // A nested page's files' address renewed by its shell (P111), which the shell's message gives.
280
- let adoptFiles = (_base) => false;
281
279
  let filesBase = plan.files && typeof plan.files.base === "string" ? plan.files.base : null;
282
280
  // Every address the page's files had (P083: a sealed one is renewed): what reports say as "./".
283
281
  const filesBases = filesBase === null ? [] : [filesBase];
@@ -1657,7 +1655,7 @@ export const SHELL_RUNTIME = String.raw`(() => {
1657
1655
  // modules keep the address they loaded from; the server serves their own loads till the session
1658
1656
  // ends.
1659
1657
  const replace = History.prototype.replaceState;
1660
- // The files' origin, read from the address itself: a nested page's own origin is opaque (P111).
1658
+ // The files' origin, read from the address itself.
1661
1659
  const filesOrigin = filesBase === null ? null : new NativeURL(filesBase).origin;
1662
1660
  // A renewed sealed address (P083): one segment under the same origin's sealed prefix, checked
1663
1661
  // through the platform's own functions (content may have replaced a prototype's, and the base
@@ -1677,7 +1675,6 @@ export const SHELL_RUNTIME = String.raw`(() => {
1677
1675
  filesBases.push(base);
1678
1676
  return true;
1679
1677
  };
1680
- adoptFiles = adopt;
1681
1678
  if (filesBase !== null && typeof plan.files.expires === "number") {
1682
1679
  const nativeFetch = window.fetch.bind(window);
1683
1680
  const renewIn = (expires) => Math.max(30000, expires - Date.now() - 300000);
@@ -2247,11 +2244,6 @@ export const SHELL_RUNTIME = String.raw`(() => {
2247
2244
  case "ui/notifications/tool-input":
2248
2245
  void render(params.arguments);
2249
2246
  break;
2250
- case "porthole/files-renewed":
2251
- // From the page's parent only (the listener's check): a nested page's shell renewed its
2252
- // files' sealed address, which this page can't (its loads aren't its origin's own, P111).
2253
- adoptFiles(params.base);
2254
- break;
2255
2247
  case "ui/notifications/host-context-changed":
2256
2248
  applyTheme(params);
2257
2249
  break;
@@ -36,9 +36,8 @@ interface PortholeArtifact {
36
36
  /** The current version and its files (fetch a file by its relative path). Level: view. */
37
37
  get(): Promise<PortholeArtifactVersion>;
38
38
  /**
39
- * Publishes a new version of this artifact, from a click; the app asks the person first. The
40
- * page can't change what it declares. On conflict: get() again, merge, publish again. Level:
41
- * admin.
39
+ * Publishes a new version of this artifact; the app asks the person first. The page can't
40
+ * change what it declares. On conflict: get() again, merge, publish again. Level: admin.
42
41
  */
43
42
  publish(
44
43
  change: PortholeArtifactPublish,
@@ -34,7 +34,7 @@ interface PortholeAssets {
34
34
  * written in the page loads too, except in some browsers' frames (Safari's); this always does.
35
35
  */
36
36
  url(id: string): string;
37
- /** Removes one, from a click; the app asks the person first. Level: admin. */
37
+ /** Removes one; the app asks the person first. Level: admin. */
38
38
  delete(id: string): Promise<boolean>;
39
39
  }
40
40
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  interface PortholeChat {
4
4
  /**
5
- * Sends text to the agent as the person's message ("explain this point"). Call it from a click.
6
- * Resolves true if it was sent. Level: interact.
5
+ * Sends text to the agent as the person's message ("explain this point"); the app asks them
6
+ * first. Resolves true if it was sent. Level: interact.
7
7
  */
8
8
  send(text: string): Promise<boolean>;
9
9
  }
@@ -28,7 +28,7 @@ interface PortholeComments {
28
28
  * Opens the app's comment composer at the anchor (a name alone is { name }), starting with
29
29
  * `options.draft` if given. The person writes and posts it in the app. Resolves true if the
30
30
  * composer opened, false if it didn't (the app may refuse while the person is writing).
31
- * Write-only: a page never reads comments. Call it from a click in the page. Level: view.
31
+ * Write-only: a page never reads comments. Level: view.
32
32
  */
33
33
  open(anchor: PortholeCommentAnchor | string, options?: PortholeCommentOptions): Promise<boolean>;
34
34
  }
@@ -11,8 +11,8 @@ interface PortholeDownload {
11
11
 
12
12
  interface PortholeDownloads {
13
13
  /**
14
- * Hands the person a file to save (<a download> and script-driven saves don't work here).
15
- * Call it from a click. Resolves true if the download started. Level: view.
14
+ * Hands the person a file to save (<a download> and script-driven saves don't work here);
15
+ * the app asks them first. Resolves true if the download started. Level: view.
16
16
  */
17
17
  save(file: PortholeDownload): Promise<boolean>;
18
18
  }
@@ -2,8 +2,8 @@
2
2
 
3
3
  interface PortholeLinks {
4
4
  /**
5
- * Opens an http(s) link outside the page (a click on an <a href> does the same). Call it from
6
- * a click. Resolves true if it opened. Level: view.
5
+ * Opens an http(s) link outside the page (a click on an <a href> does the same); the app asks
6
+ * the person first. Resolves true if it opened. Level: view.
7
7
  */
8
8
  open(url: string): Promise<boolean>;
9
9
  }