@kehto/paja 0.8.0 → 0.10.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/README.md CHANGED
@@ -17,7 +17,8 @@ The target URL is explicit on purpose. Kehto can spawn any framework command and
17
17
  wait for that URL, but it does not guess which URL the framework chose. Loading
18
18
  that URL through Paja as injected `srcdoc` lets Kehto install mandatory
19
19
  `window.napplet.shell` plus enabled optional domains before app code runs. The
20
- shell shim completes `shell.ready` / `shell.init` and caches capability queries,
20
+ Kehto host-owned shell prelude completes `shell.ready` / `shell.init` and caches
21
+ capability queries,
21
22
  while a `<base>` tag keeps the
22
23
  app's own assets and HMR pointed at the target dev server without Vite, Svelte,
23
24
  React, or any other framework lock-in.
@@ -34,13 +35,37 @@ mode. `shell` is the mandatory, non-toggleable handshake domain; the deprecated
34
35
  path remains an upstream compatibility alias to `inc`. The upstream `dm` domain
35
36
  is not advertised until Paja wires a deterministic development DM backend.
36
37
 
38
+ ## Dev-server CORS requirement
39
+
40
+ The target iframe is sandboxed without `allow-same-origin`, so the napplet
41
+ document has an opaque origin and requests its own assets with `Origin: null`.
42
+ `<script type="module">` is always fetched in CORS mode, so a dev server that
43
+ does not allow that origin blocks the napplet's entry module and the frame
44
+ renders blank. Vite's default `server.cors` allowlist covers only `localhost`,
45
+ `127.0.0.1`, and `[::1]` origins, so it rejects `null`:
46
+
47
+ ```js
48
+ // vite.config.js
49
+ export default {
50
+ server: { cors: { origin: '*' } },
51
+ };
52
+ ```
53
+
54
+ Any dev server works as long as it answers `Origin: null` with
55
+ `Access-Control-Allow-Origin: *` or `null`. Paja probes the target on startup
56
+ and logs a `paja.target.cors.error` entry in the message log, plus a console
57
+ warning, when the target would block the sandboxed frame.
58
+
37
59
  The console shows supported interfaces with per-domain injection toggles,
38
60
  runtime ACL controls, signer controls, and a filterable message log with visible
39
61
  error details. Paja auto-connects a browser NIP-07 signer when `window.nostr` is
40
62
  available, can connect to a bunker/NIP-46 URI, and only uses the generated local
41
63
  development signer when the Dev signer button is selected. Every signing or
42
64
  publish operation still uses a browser confirmation prompt. There is no bypass
43
- list.
65
+ list. A denied prompt or a live publish with no accepting relay returns a
66
+ canonical failure and is not added to Paja's in-memory relay view. Paja's
67
+ scoped-relay hook likewise waits for the backend result and returns `false`
68
+ after denial or transport failure.
44
69
 
45
70
  The static Paja Runtime build is served at `/web/paja/` in the GitHub Pages
46
71
  artifact. It uses the same browser host and service adapters, but loads verified
@@ -53,6 +78,47 @@ runtime tabs in local storage so returning to `/web/paja/` restores the previous
53
78
  pointer set. An explicit pointer in the URL still takes precedence over restored
54
79
  tabs.
55
80
 
81
+ ## Installed intent handlers and delivery
82
+
83
+ Paja keeps resolver-verified pointer and manifest facts in an installed catalog,
84
+ separate from the live tab/controller map. A verified install inserts or replaces
85
+ the catalog record; an explicit artifact removal removes it. Closing, reloading,
86
+ or replacing a frame never makes an installed handler unavailable, so a cold
87
+ target can still be selected and started later.
88
+
89
+ Intent selection considers only exact compatible contracts from that catalog.
90
+ Paja can use a compatible user default, ask its host chooser when more than one
91
+ candidate is available, or reject an ambiguity. An explicit handler d-tag is
92
+ accepted only when it is an installed compatible handler and the invoking sender
93
+ has been explicitly authorized for it. It is not a request to deliver to an
94
+ arbitrary running frame.
95
+
96
+ When Paja receives an invocation, it selects and opens or reuses a verified
97
+ target. The controller waits for the target generation's
98
+ registered `MessageEvent.source` to establish its real `shell.ready` session;
99
+ it checks that generation is still current, sends one target-only `inc.event`
100
+ with the selected queryless convention, and returns the final handled target
101
+ identity. A superseded target/source, failed open/readiness, or terminal send is
102
+ handled by the controller's replacement/retry/terminal policy and produces a
103
+ canonical failed `IntentResult`.
104
+
105
+ `@napplet/shim@0.29.0` supplies no generic shell API. Kehto deliberately keeps
106
+ its host-owned mandatory `window.napplet.shell` prelude: it installs the live
107
+ receiver before the one bare `shell.ready`, caches the first `shell.init`, and
108
+ provides local `ready()`, `supports()`, read-only `services`, and one-shot
109
+ `onReady()`. This is the documented upstream-package-drift exception, not a
110
+ shim capability.
111
+
112
+ Before Paja assigns a verified runtime-pointer document to `srcdoc`, it inserts
113
+ Kehto's local Class-1 CSP before the host-owned namespace prelude. The policy
114
+ denies all defaults; permits inline script/style, `data:`/`blob:` images, and
115
+ `data:` fonts; grants `connect-src` only to the resolved relay and Blossom
116
+ origins; explicitly denies worker, child, frame, media, object, manifest,
117
+ prefetch, base, and form capabilities; and ends with `frame-ancestors 'self'`.
118
+ The NIP-5D verified-srcdoc and opaque-sandbox rules do not mandate this CSP;
119
+ it is Kehto policy. Local target-URL authoring mode is intentionally outside
120
+ this verified-artifact policy path.
121
+
56
122
  Environment simulation can be supplied through CLI flags or a JSON config file:
57
123
 
58
124
  ```bash