@kehto/paja 0.18.1 → 0.19.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
@@ -273,16 +273,31 @@ provides local `ready()`, `supports()`, read-only `services`, and one-shot
273
273
  `onReady()`. This is the documented upstream-package-drift exception, not a
274
274
  shim capability.
275
275
 
276
- Before Paja assigns a verified runtime-pointer document to `srcdoc`, it inserts
277
- Kehto's local Class-1 CSP before the host-owned namespace prelude. The policy
278
- denies all defaults; permits inline script/style, WebAssembly compilation through
279
- the narrow `'wasm-unsafe-eval'` source, `data:`/`blob:` images, and `data:` fonts;
280
- keeps JavaScript string evaluation blocked; grants `connect-src` only to the resolved relay and Blossom
281
- origins; explicitly denies worker, child, frame, media, object, manifest,
282
- prefetch, base, and form capabilities; and ends with `frame-ancestors 'self'`.
283
- The NIP-5D verified-srcdoc and opaque-sandbox rules do not mandate this CSP;
284
- it is Kehto policy. Local target-URL authoring mode is intentionally outside
285
- this verified-artifact policy path.
276
+ Before Paja assigns a verified runtime-pointer document to `srcdoc`, it calls
277
+ `@kehto/shell`'s `prepareNappletSrcdoc`. The shell inserts validated CSP first,
278
+ then the mandatory namespace. Defaults permit inline script/style, WASM byte
279
+ compilation, `data:`/`blob:` images and `data:` fonts, and deny other resource
280
+ classes. Paja grants direct connections only to resolved relay and Blossom
281
+ origins plus explicit host grants.
282
+
283
+ Hosts can pass `csp` to `createPajaRuntimeHostConfig`:
284
+
285
+ ```ts
286
+ const config = createPajaRuntimeHostConfig({
287
+ pointer,
288
+ csp: {
289
+ connectOrigins: ['https://api.example'],
290
+ directives: { 'media-src': ['blob:'], 'img-src': ['data:'] },
291
+ },
292
+ });
293
+ ```
294
+
295
+ The shell rejects broad JavaScript evaluation, non-origin connection grants,
296
+ and script policies that block its bootstrap. NIP-5D's CSP recommendations are
297
+ enforced; individual baseline source lists remain configurable. Existing
298
+ artifact CSP is retained. Set `frame-ancestors` on the host HTTP response, not
299
+ in a meta policy. See the [shared policy contract](https://github.com/kehto/web/blob/main/docs/policies/NIP-5D-CONFORMANCE.md#shell-csp-enforcement).
300
+ Local target-URL authoring mode retains its separate development policy and HMR.
286
301
 
287
302
  Environment simulation can be supplied through CLI flags or a JSON config file:
288
303