@botiverse/porthole 0.15.3 → 0.16.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/annotate/types.d.ts +15 -1
  3. package/dist/annotate/validate.js +19 -1
  4. package/dist/bridge/bridge.d.ts +1 -8
  5. package/dist/bridge/bridge.js +0 -7
  6. package/dist/bridge/types.d.ts +1 -1
  7. package/dist/check/page-source.js +1 -1
  8. package/dist/check/page.js +1 -1
  9. package/dist/compile/policy.d.ts +0 -7
  10. package/dist/compile/policy.js +1 -10
  11. package/dist/config/capabilities.d.ts +8 -14
  12. package/dist/config/capabilities.js +4 -5
  13. package/dist/config/schema.d.ts +2 -13
  14. package/dist/config/validate.js +0 -24
  15. package/dist/conformance/behavior.js +26 -37
  16. package/dist/conformance/clipboard.js +47 -1
  17. package/dist/conformance/harness-source.js +1 -1
  18. package/dist/displays/displays.js +1 -3
  19. package/dist/guide/limits.js +1 -1
  20. package/dist/guide/runtime.js +1 -1
  21. package/dist/host/create-host.d.ts +1 -1
  22. package/dist/host/create-host.js +8 -52
  23. package/dist/host/door.d.ts +1 -1
  24. package/dist/host/locate.d.ts +1 -1
  25. package/dist/host/locate.js +2 -2
  26. package/dist/host/outcome.d.ts +5 -12
  27. package/dist/host/outcome.js +8 -16
  28. package/dist/host/types.d.ts +6 -22
  29. package/dist/index.d.ts +2 -4
  30. package/dist/index.js +2 -4
  31. package/dist/isolation/served.d.ts +4 -14
  32. package/dist/isolation/served.js +7 -28
  33. package/dist/isolation/types.d.ts +2 -25
  34. package/dist/isolation/types.js +0 -23
  35. package/dist/platform/focus-field.d.ts +11 -0
  36. package/dist/platform/focus-field.js +18 -0
  37. package/dist/platform/types.d.ts +7 -23
  38. package/dist/platform/web.js +8 -106
  39. package/dist/presets/presets.d.ts +0 -2
  40. package/dist/presets/presets.js +0 -1
  41. package/dist/react/frame.d.ts +0 -8
  42. package/dist/react/frame.js +0 -4
  43. package/dist/runtime/contract.d.ts +2 -2
  44. package/dist/runtime/contract.js +2 -2
  45. package/dist/runtime/types.generated.js +6 -6
  46. package/dist/server/files.js +7 -23
  47. package/dist/server/host.d.ts +1 -1
  48. package/dist/server/index.d.ts +1 -1
  49. package/dist/server/index.js +4 -6
  50. package/dist/server/naming.js +1 -1
  51. package/dist/server/server.js +28 -166
  52. package/dist/server/types.d.ts +7 -7
  53. package/dist/shell/annotate.d.ts +3 -0
  54. package/dist/shell/annotate.js +15 -5
  55. package/dist/shell/plan.d.ts +0 -5
  56. package/dist/shell/plan.js +2 -4
  57. package/dist/shell/runtime.js +1 -268
  58. package/docs/ADOPTING.md +398 -1081
  59. package/docs/DECISIONS.md +172 -10
  60. package/docs/DESIGN.md +1114 -1388
  61. package/docs/PRINCIPLES.md +85 -1
  62. package/docs/THREAT_MODEL.md +658 -1127
  63. package/package.json +1 -1
  64. package/src/annotate/types.ts +12 -1
  65. package/src/annotate/validate.ts +23 -1
  66. package/src/bridge/bridge.ts +1 -17
  67. package/src/bridge/types.ts +1 -1
  68. package/src/check/page.ts +1 -1
  69. package/src/compile/policy.ts +1 -11
  70. package/src/config/capabilities.ts +8 -14
  71. package/src/config/schema.ts +2 -13
  72. package/src/config/validate.ts +0 -28
  73. package/src/conformance/behavior.ts +50 -52
  74. package/src/conformance/clipboard.ts +56 -1
  75. package/src/displays/displays.ts +1 -3
  76. package/src/guide/limits.ts +1 -1
  77. package/src/guide/runtime.ts +1 -1
  78. package/src/host/create-host.ts +8 -53
  79. package/src/host/door.ts +1 -1
  80. package/src/host/locate.ts +2 -2
  81. package/src/host/outcome.ts +8 -21
  82. package/src/host/types.ts +6 -20
  83. package/src/index.ts +2 -4
  84. package/src/isolation/served.ts +6 -34
  85. package/src/isolation/types.ts +2 -31
  86. package/src/platform/focus-field.ts +18 -0
  87. package/src/platform/types.ts +7 -22
  88. package/src/platform/web.ts +8 -129
  89. package/src/presets/presets.ts +0 -3
  90. package/src/react/frame.tsx +0 -10
  91. package/src/runtime/contract.ts +4 -4
  92. package/src/runtime/types.generated.ts +6 -6
  93. package/src/server/files.ts +4 -19
  94. package/src/server/host.ts +1 -1
  95. package/src/server/index.ts +4 -16
  96. package/src/server/naming.ts +1 -1
  97. package/src/server/server.ts +29 -189
  98. package/src/server/types.ts +7 -7
  99. package/src/shell/annotate.ts +15 -5
  100. package/src/shell/plan.ts +2 -9
  101. package/src/shell/runtime.ts +1 -268
  102. package/types/runtime/v1/artifact.d.ts +2 -3
  103. package/types/runtime/v1/assets.d.ts +1 -1
  104. package/types/runtime/v1/chat.d.ts +2 -2
  105. package/types/runtime/v1/comments.d.ts +1 -1
  106. package/types/runtime/v1/downloads.d.ts +2 -2
  107. package/types/runtime/v1/links.d.ts +2 -2
  108. package/dist/platform/focus-guard.d.ts +0 -288
  109. package/dist/platform/focus-guard.js +0 -838
  110. package/dist/server/nested.d.ts +0 -66
  111. package/dist/server/nested.js +0 -121
  112. package/dist/shell/frame.d.ts +0 -28
  113. package/dist/shell/frame.js +0 -407
  114. package/docs/ARCHITECTURE.md +0 -359
  115. package/docs/OBJECTIVES.md +0 -116
  116. package/src/platform/focus-guard.ts +0 -1114
  117. package/src/server/nested.ts +0 -157
  118. package/src/shell/frame.ts +0 -444
@@ -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,
@@ -108,6 +108,9 @@ export const WORD_LATE = String.raw`(at, now) => {
108
108
  * them placed as the document scrolls, from one report and the followed mark's scroll;
109
109
  * - the last line (P133): where a selection or a mark's words end, in the document's coordinates
110
110
  * too (`lastLineDocumentRect`), so a host places its UI after them;
111
+ * - the point picked (P150): where a pointer picked an element (the click's or tap's point, a held
112
+ * finger's), in the document's coordinates too (`pointDocument`), so a host places its UI by what
113
+ * the person pointed at in an element larger than the frame;
111
114
  * - the selection followed (P138): what the last `selected` reported (the element picked, or the
112
115
  * words selected) is kept while the host follows the selection (`track` with `selection`) or said
113
116
  * at `start` that it will (`keepSelection`, P140), and nothing is kept otherwise; while followed
@@ -389,11 +392,15 @@ export const ANNOTATE_RUNTIME = String.raw`if (declared("annotate")) {
389
392
  return rect === null ? null : inDocument(box(rect), scroll);
390
393
  };
391
394
  // What a selection's report adds to its box (P133): its last line, with the scroll it was
392
- // read at; neither where nothing of it is drawn.
393
- const placeOf = (found) => {
395
+ // read at; neither where nothing of it is drawn. An element's pick by a pointer adds where it
396
+ // was picked (P150): that point in the viewport, in the document by the same scroll.
397
+ const placeOf = (found, point) => {
394
398
  const scroll = scrollOf();
395
399
  const lastLineDocumentRect = lastLineOf(found, scroll);
396
- return lastLineDocumentRect === null ? {} : { lastLineDocumentRect, scroll };
400
+ if (lastLineDocumentRect === null) {
401
+ return {};
402
+ }
403
+ return point ? { lastLineDocumentRect, scroll, pointDocument: { x: point.x + scroll.x, y: point.y + scroll.y } } : { lastLineDocumentRect, scroll };
397
404
  };
398
405
 
399
406
  // The shell's own layer, over the content: marks, the outline of what would be picked.
@@ -1713,7 +1720,7 @@ export const ANNOTATE_RUNTIME = String.raw`if (declared("annotate")) {
1713
1720
  holdSelected(anchor, { element });
1714
1721
  picked = keeping && !followingSelection ? element : null;
1715
1722
  redraw();
1716
- tell(M.selected, Object.assign({ anchor, rect: box(elementRect.call(element)) }, placeOf({ element })));
1723
+ tell(M.selected, Object.assign({ anchor, rect: box(elementRect.call(element)) }, placeOf({ element }, { x, y })));
1717
1724
  }, HOLD_MS),
1718
1725
  };
1719
1726
  }, true);
@@ -1765,7 +1772,10 @@ export const ANNOTATE_RUNTIME = String.raw`if (declared("annotate")) {
1765
1772
  // only for a host that will follow it (P140): for any other it goes with the pick.
1766
1773
  picked = keeping && !followingSelection ? element : null;
1767
1774
  draw();
1768
- tell(M.selected, Object.assign({ anchor, rect: box(elementRect.call(element)) }, placeOf({ element })));
1775
+ // Where it was clicked or tapped (P150), the point the element was found under; a click
1776
+ // from the keyboard (no detail) has no point.
1777
+ const point = event.detail === 0 ? null : { x: event.clientX, y: event.clientY };
1778
+ tell(M.selected, Object.assign({ anchor, rect: box(elementRect.call(element)) }, placeOf({ element }, point)));
1769
1779
  }, true);
1770
1780
  window.addEventListener("keydown", (event) => {
1771
1781
  if (event.key !== "Escape") {
package/src/shell/plan.ts CHANGED
@@ -61,11 +61,6 @@ export interface ShellPlan {
61
61
  * those iframes and removes every other frame-like element. Absent: it removes them all.
62
62
  */
63
63
  readonly nestedFrames?: "own";
64
- /**
65
- * A nested page's (P148): its runtime tells its shell each real press, over the port the shell
66
- * sends it. Absent for every other plan: their runtime listens for no port and tells no press.
67
- */
68
- readonly press?: true;
69
64
  }
70
65
 
71
66
  export function shellPlan(config: PortholeConfig): ShellPlan | null {
@@ -107,15 +102,13 @@ export function shellPlan(config: PortholeConfig): ShellPlan | null {
107
102
  themeVariables: Object.keys(config.theme.variables),
108
103
  themeEvent: config.theme.event,
109
104
  themeDocuments: config.theme.documents ?? "declared",
110
- // An opaque origin has no storage: an opaque frame's, and a nested page's (P111).
111
- storage: config.isolation === "opaque" || config.nested === true ? "memory" : "native",
105
+ // An opaque origin has no storage.
106
+ storage: config.isolation === "opaque" ? "memory" : "native",
112
107
  maxErrorReports: config.limits.maxErrorReports,
113
108
  maxPromptChars: config.limits.maxPromptChars,
114
109
  maxCopyChars: MAX_COPY_CHARS,
115
110
  protocolVersion: MCP_APPS_PROTOCOL_VERSION,
116
111
  // Only where opted into (P128): every other plan is the same as before it.
117
112
  ...(config.nestedFrames === "own" ? { nestedFrames: "own" as const } : {}),
118
- // A nested page's alone (P148): every other plan is the same as before it.
119
- ...(config.nested === true ? { press: true as const } : {}),
120
113
  };
121
114
  }