@botiverse/porthole 0.15.3 → 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 (107) hide show
  1. package/CHANGELOG.md +58 -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 +4 -14
  29. package/dist/isolation/served.js +7 -28
  30. package/dist/isolation/types.d.ts +2 -25
  31. package/dist/isolation/types.js +0 -23
  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 -106
  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/server.js +28 -166
  49. package/dist/server/types.d.ts +7 -7
  50. package/dist/shell/plan.d.ts +0 -5
  51. package/dist/shell/plan.js +2 -4
  52. package/dist/shell/runtime.js +1 -268
  53. package/docs/ADOPTING.md +42 -138
  54. package/docs/ARCHITECTURE.md +0 -33
  55. package/docs/DECISIONS.md +115 -10
  56. package/docs/DESIGN.md +27 -64
  57. package/docs/THREAT_MODEL.md +128 -255
  58. package/package.json +1 -1
  59. package/src/bridge/bridge.ts +1 -17
  60. package/src/check/page.ts +1 -1
  61. package/src/compile/policy.ts +1 -11
  62. package/src/config/capabilities.ts +8 -14
  63. package/src/config/schema.ts +2 -13
  64. package/src/config/validate.ts +0 -28
  65. package/src/conformance/behavior.ts +50 -52
  66. package/src/conformance/clipboard.ts +56 -1
  67. package/src/displays/displays.ts +1 -3
  68. package/src/guide/limits.ts +1 -1
  69. package/src/guide/runtime.ts +1 -1
  70. package/src/host/create-host.ts +6 -52
  71. package/src/host/door.ts +1 -1
  72. package/src/host/locate.ts +2 -2
  73. package/src/host/outcome.ts +8 -21
  74. package/src/host/types.ts +6 -20
  75. package/src/index.ts +2 -4
  76. package/src/isolation/served.ts +6 -34
  77. package/src/isolation/types.ts +2 -31
  78. package/src/platform/focus-field.ts +18 -0
  79. package/src/platform/types.ts +6 -21
  80. package/src/platform/web.ts +8 -129
  81. package/src/presets/presets.ts +0 -3
  82. package/src/react/frame.tsx +0 -10
  83. package/src/runtime/contract.ts +4 -4
  84. package/src/runtime/types.generated.ts +6 -6
  85. package/src/server/files.ts +4 -19
  86. package/src/server/host.ts +1 -1
  87. package/src/server/index.ts +4 -16
  88. package/src/server/naming.ts +1 -1
  89. package/src/server/server.ts +29 -189
  90. package/src/server/types.ts +7 -7
  91. package/src/shell/plan.ts +2 -9
  92. package/src/shell/runtime.ts +1 -268
  93. package/types/runtime/v1/artifact.d.ts +2 -3
  94. package/types/runtime/v1/assets.d.ts +1 -1
  95. package/types/runtime/v1/chat.d.ts +2 -2
  96. package/types/runtime/v1/comments.d.ts +1 -1
  97. package/types/runtime/v1/downloads.d.ts +2 -2
  98. package/types/runtime/v1/links.d.ts +2 -2
  99. package/dist/platform/focus-guard.d.ts +0 -288
  100. package/dist/platform/focus-guard.js +0 -838
  101. package/dist/server/nested.d.ts +0 -66
  102. package/dist/server/nested.js +0 -121
  103. package/dist/shell/frame.d.ts +0 -28
  104. package/dist/shell/frame.js +0 -407
  105. package/src/platform/focus-guard.ts +0 -1114
  106. package/src/server/nested.ts +0 -157
  107. package/src/shell/frame.ts +0 -444
package/CHANGELOG.md CHANGED
@@ -4,6 +4,64 @@
4
4
  section); the reasons for every change are in [docs/DECISIONS.md](docs/DECISIONS.md), by the
5
5
  P-numbers below.
6
6
 
7
+ ## 0.16.0
8
+
9
+ **Breaking.** What guessed at the person's intent is taken out (P149; supersedes P111, P114,
10
+ P120, P122, P136, P148, and parts of P105, P109, P121, P123). It began with a host's report
11
+ that a page's own comment button, pressed by a real person, was refused ("This needs a click"):
12
+ the checks below ran on a guess at where the person was, each release made the guess larger,
13
+ and none of them protected more than the moment a page asks. No isolation wall changes: origins,
14
+ sandboxes, CSP, tickets, the door and every message check are as in 0.15.3.
15
+
16
+ - **No proof of a click is asked, except for `copyText`.** Default gates: `sendPrompt`,
17
+ `openLink` and `downloadFile` are `confirm` and 30 a minute (they had no rate); `comments` is
18
+ 30 a minute alone; `artifact.publish` and `assets.delete` are `confirm`. A page may call them
19
+ as it loads or on a timer: each still ends at the person's confirmation, or at a composer that
20
+ posts nothing by itself, and declines still mute the display. A marker's `activated` is taken
21
+ with or without a gesture (a view it opens still takes no press for 500 ms: that is your
22
+ view's guard, ADOPTING § Annotations). `copyText` keeps its click. The `user-activation` gate
23
+ stays in the vocabulary: name it for any capability (`gates`) or method (`methodGates`) to get
24
+ 0.15's default back for it. `CapabilitySpec.inFrame` is gone.
25
+ **For a host:** remove any `gates` override you wrote only to drop `user-activation`; the
26
+ default is now what you overrode to, plus the rate. A handler for `comments` is asked more
27
+ freely: answer `false` while the person is writing, and space out or refuse a page whose opens
28
+ the person keeps closing. The manual and the typed runtime (`types/runtime/v1`) no longer say
29
+ "call it from a click" for these.
30
+ - **The focus guard is removed.** A display that takes the keyboard keeps it until the person
31
+ clicks back (the accepted risk of THREAT_MODEL §5; the guard could not hold it and refused
32
+ people's own clicks). Gone: the `focusTaken` event, `PortholeFrame`'s and `PortholeView`'s
33
+ `onFocusTaken`, `Surface.onFocusTaken`, the "kept taking the keyboard" content error.
34
+ `display.focus()` is the frame's own `focus()`. `focusField(field)` stays, as a plain helper.
35
+ `Surface.focused`, optional, is read by the find shortcut alone.
36
+ **For a host:** delete your `focusTaken` / `onFocusTaken` handlers. Nothing else to do.
37
+ - **Nested pages are removed** (`nested: true`). The config field is refused as unknown. Gone
38
+ from the main entry: `SHELL_STATE_METHOD`, `SHELL_GESTURE_MS`, `PAGE_SANDBOX_TOKENS`. Gone from
39
+ `/server`: `isNestedLabel`, `nestedLabelOf`, `nestedShellResponse`, `nestedShellCsp`,
40
+ `nestedFileCsp`, `nestedAncestors`, `NESTED_FILE_HEADERS`, `NESTED_FILES_PREFIX`. The
41
+ `porthole-` label prefix stays reserved (`PORTHOLE_LABEL_PREFIX`).
42
+ **For a host that used `nested: true`:** go back to a served page.
43
+ 1. Remove `nested: true` from the kind's options. The page is then framed on its scope's own
44
+ label, as every served artifact is, with `allow-same-origin`: it has that origin's storage
45
+ again (`localStorage` lasts; set `served.storage` as you would for any served kind), and
46
+ the asset library and Porthole's libraries, which nested pages never had.
47
+ 2. A nested page was opaque to its scope's other displays. A served one shares its scope's
48
+ origin with them (THREAT_MODEL S7): if displays in one scope must not reach each other,
49
+ give them different scopes.
50
+ 3. A content Worker of your own: drop the routes for the shell's label
51
+ (`porthole-<…>.<domain>`) and the calls to the helpers above; `/server` users have nothing
52
+ to change. An edge route for that label can go too.
53
+ 4. Do step 1 before you upgrade: 0.15 serves the kind as a served page once the field is
54
+ gone, on both sides, and 0.16.0 refuses a config that still has it.
55
+ - **The page runtime.** The shell runtime every served document inlines is 0.15.2's without the
56
+ nested-only renewal hook (nine lines); `use` and `legacy` are unchanged. A page published
57
+ under 0.15 runs under 0.16 unchanged, and its calls that needed a click no longer need one.
58
+ - **Conformance.** `12.prompt-gesture-confirm` is `12.prompt-confirm` (a prompt on load is
59
+ asked, and a no sends nothing); `12.raw-message` now expects a raw `ui/message` to be asked
60
+ too; `12.raw-copy` is new (a raw copy with no click is refused by the host). 28 negative
61
+ controls are removed with the code they weakened.
62
+ - **The find shortcut in a shadow root.** `focused` reads the `activeElement` of the frame's own
63
+ root, so a display mounted inside a shadow root no longer reads as unfocused.
64
+
7
65
  ## 0.15.3
8
66
 
9
67
  - **A nested page's real presses count, each of them** (P148, amends P111). A nested page's shell
@@ -14,8 +14,7 @@ import type { CapabilityHandlers, Confirm, ConfirmDisplay, Consent, DataCache, H
14
14
  * every capability its host function's own rate (P091, P095) → arguments well formed and within
15
15
  * their limits → who may (P087: the level of each method the call runs for the viewer, a page's
16
16
  * named data with or without a viewer, db's rules) → not muted, if confirm-gated → the own rate
17
- * of each method it runs (P094: a batch's writes count each) → a user gesture, if gated so (and
18
- * for `comments`, the host page's focus in the calling frame: P109) → the
17
+ * of each method it runs (P094: a batch's writes count each) → a user gesture, if gated so → the
19
18
  * viewer's consent, if gated so → a person's confirmation, if gated so (at most 10 waiting) →
20
19
  * shown to the person, if gated so (P100) → the handler (or, for a read, a result the host already
21
20
  * gave for it, or for a stale-allowed one the host's cache).
@@ -67,12 +66,6 @@ export interface BridgeOptions {
67
66
  readonly cached?: DataCache;
68
67
  /** Whether the embedding page has user activation now; undefined where it can't tell. */
69
68
  readonly userActivation?: () => boolean | undefined;
70
- /**
71
- * Whether the embedding page's focus is in this display's frame now (P109); undefined where it
72
- * can't tell. A capability whose gesture must be in its frame (`inFrame`: `comments`) is refused
73
- * without it.
74
- */
75
- readonly focused?: () => boolean | undefined;
76
69
  readonly onEvent: (event: BridgeEvent) => void;
77
70
  /** The clock, in milliseconds (tests pass their own). */
78
71
  readonly now?: () => number;
@@ -13,8 +13,6 @@ import { atLeast, higher } from "../runtime/levels.js";
13
13
  import { isCodeAsset, parseArtifactRequest, parseAssetRequest, parseCommentRequest, } from "../runtime/requests.js";
14
14
  import { defaultReason, isRefused, pendingReason, reasonOf, } from "./refusal.js";
15
15
  const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
16
- /** Whether `capability`'s gesture must be in its own frame (P109: the host page's focus there). */
17
- const inFrame = (capability) => capabilitySpec(capability).inFrame === true;
18
16
  const MAX_URL = 4_096;
19
17
  /**
20
18
  * The most confirmations one display has waiting at once (P095): past it a call is refused as
@@ -452,11 +450,6 @@ export function createBridge(options) {
452
450
  if (activated === false) {
453
451
  return refuse(capability, "no-user-activation");
454
452
  }
455
- // A gesture in this frame, not anywhere on the host's page (P109): the person typing in
456
- // the host's composer gives its page activation, which a frame's call would borrow.
457
- if (inFrame(capability) && options.focused?.() === false) {
458
- return refuse(capability, "no-user-activation");
459
- }
460
453
  }
461
454
  if (gates.includes("consent")) {
462
455
  const consent = options.consent;