@kehto/shell 0.16.2 → 0.16.5

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
@@ -21,7 +21,7 @@ The primary entry point is `createShellBridge()` — it owns the postMessage lis
21
21
  Current draft behaviors this package enforces:
22
22
 
23
23
  - The shell does not inject a host-provided nostr object into napplets — NIP-5D explicitly forbids napplet-visible signing. Napplets call `relay.publish` / `relay.publishEncrypted` and the shell mediates the signing flow internally (NIP-44 default, NIP-04 opt-in for encrypted envelopes).
24
- - `injectNappletNamespacePrelude()` implements the current draft NIP-5D injected-domain bootstrap: hosts prepend a `window.napplet` prelude to `srcdoc` outside the verified artifact bytes, so available NAP domain objects exist before napplet-authored scripts run. Assigned namespaces are filtered back to the explicit bare-domain allowlist; the playground does not inject `shell`.
24
+ - `injectNappletNamespacePrelude()` implements the current draft NIP-5D injected-domain bootstrap: hosts prepend a `window.napplet` prelude to `srcdoc` outside the verified artifact bytes, so callable NAP domain interfaces exist before napplet-authored scripts run. Assigned namespaces are filtered back to the explicit bare-domain allowlist; the playground does not inject `shell`.
25
25
  - Legacy `window.napplet.shell.supports()` compatibility is not the current NIP-5D availability primitive. New host and napplet availability checks should use injected `window.napplet.<domain>` presence and leave per-domain semantic checks to the matching NAP.
26
26
  - Five optional per-domain proxies — `createIdentityProxy`, `createThemeProxy`, `createKeysProxy`, `createMediaProxy`, `createNotifyProxy` — can be composed between napplet and runtime to intercept or augment traffic per NAP. They are NOT wired by default (Kehto's runtime already owns dispatch for the currently supported domains); they exist as host-app composition seams.
27
27
  - The keys-forwarder pumps host keydown events into `keys.forward` envelopes for napplets that hold the `keys:forward` capability.
@@ -69,7 +69,7 @@ const bridge = createShellBridge({
69
69
 
70
70
  ### Shell init
71
71
  - `buildShellCapabilities` — construct the current draft `ShellCapabilities` payload emitted during the `shell.ready` / `shell.init` handshake
72
- - `injectNappletNamespacePrelude` — insert a host-owned NIP-5D `window.napplet` domain-availability prelude into verified HTML before authored scripts
72
+ - `injectNappletNamespacePrelude` — insert a host-owned NIP-5D `window.napplet` callable-domain prelude into verified HTML before authored scripts
73
73
  - `renderNappletNamespacePrelude` — render only the bootstrap `<script>` for hosts that already own HTML insertion
74
74
 
75
75
  ### Domain proxies (NIP-5D composition seams)
package/dist/index.d.ts CHANGED
@@ -266,17 +266,16 @@ interface UnroutedMessageInfo {
266
266
  * `window.napplet.<domain>` presence; this shape remains for older consumers
267
267
  * that still read shell.init capability metadata.
268
268
  *
269
- * Per canonical NIP-5D (https://github.com/nostr-protocol/nips/pull/2303/),
270
- * supports() distinguishes two namespaces:
269
+ * Current availability is the injected `window.napplet.<domain>` namespace.
270
+ * Compatibility supports() helpers should treat only NAP domains and protocols
271
+ * as advertised capabilities:
271
272
  *
272
273
  * - Bare names for NAP-capability lookups, resolved against the `naps`
273
274
  * array — e.g. `supports('relay')`, `supports('identity')`.
274
- * - The `perm:<permission>` prefix for sandbox-permission lookups, resolved
275
- * against the `sandbox` array — e.g. `supports('perm:popups')`,
276
- * `supports('perm:modals')`.
277
275
  *
278
- * The two namespaces do not cross: a bare-name lookup never matches a sandbox
279
- * entry and a `perm:`-prefixed lookup never matches a NAP entry.
276
+ * The sandbox array remains for older payload readers, but Kehto emits it empty.
277
+ * NIP-5D no longer blesses additional browser sandbox tokens as interoperability
278
+ * requirements or napplet-visible capabilities.
280
279
  *
281
280
  * ## Compatibility NAP-SHELL shape
282
281
  *
@@ -289,10 +288,7 @@ interface UnroutedMessageInfo {
289
288
  * includes `'NAP-01'`
290
289
  *
291
290
  * `domains` and `protocols` are emitted as a superset alongside the
292
- * `naps`/`sandbox` fields for back-compat. The compatibility helper has no
293
- * special `perm:` logic: `supports('perm:popups')` is an ordinary bare-domain
294
- * membership check, so Kehto's `perm:`-prefixed sandbox entries are folded into
295
- * `domains` (empty by default, preserving the default-empty sandbox behavior).
291
+ * `naps`/`sandbox` fields for back-compat.
296
292
  */
297
293
  interface ShellCapabilities {
298
294
  /**
@@ -301,8 +297,7 @@ interface ShellCapabilities {
301
297
  * `'inc'`, `'theme'`, etc. — with the same conditional entries as `naps`
302
298
  * (`relay`/`outbox` when a relay pool is wired, `upload`/`intent` under their
303
299
  * hooks). Carries NO `inc:NAP-NN` protocol strings (those live in
304
- * `protocols`). Any `perm:<x>` sandbox entries are appended here too, since
305
- * legacy supports helpers resolve `supports('perm:<x>')` against this list.
300
+ * `protocols`).
306
301
  */
307
302
  domains: string[];
308
303
  /**
@@ -325,16 +320,11 @@ interface ShellCapabilities {
325
320
  */
326
321
  naps: string[];
327
322
  /**
328
- * Sandbox permissions under the `perm:<permission>` namespace. Each entry
329
- * MUST begin with the literal prefix `'perm:'` — e.g. `'perm:popups'`,
330
- * `'perm:modals'`, `'perm:downloads'`. Napplets call
331
- * `shell.supports('perm:<permission>')` to check sandbox entitlements.
323
+ * Empty compatibility field for older `shell.init` payload consumers.
332
324
  *
333
- * The `perm:` prefix is what separates sandbox permissions from NAP
334
- * capabilities; bare-name entries here violate the NIP-5D contract and will
335
- * be unreachable through `supports()` (see the living NIP-5D at
336
- * https://github.com/nostr-protocol/nips/pull/2303/). NAP-capability lookups (on `naps`) retain the bare-name
337
- * convention and do NOT use the `perm:` prefix.
325
+ * Current NIP-5D keeps the web sandbox baseline narrow: hosted napplet iframes
326
+ * use `allow-scripts`, never `allow-same-origin`, and do not receive optional
327
+ * browser sandbox relaxations as advertised capabilities.
338
328
  */
339
329
  sandbox: string[];
340
330
  }
@@ -1191,42 +1181,37 @@ declare function adaptHooks(shellHooks: ShellAdapter, deps: BrowserDeps): Runtim
1191
1181
  * `link` appended when hooks.link.isAvailable();
1192
1182
  * `common` appended when hooks.common.isAvailable().
1193
1183
  *
1194
- * Sandbox permissions are left empty by default — host apps may extend after
1195
- * construction. Sandbox entries (and any host-app extensions) MUST use the
1196
- * canonical `perm:<permission>` form — e.g. `'perm:popups'`, `'perm:modals'`,
1197
- * `'perm:downloads'`. Napplets rely on the `perm:` prefix to distinguish
1198
- * sandbox permissions from NAP-capability lookups; see the living NIP-5D at
1199
- * https://github.com/nostr-protocol/nips/pull/2303/
1184
+ * The sandbox array is retained as an always-empty compatibility field. Current
1185
+ * NIP-5D defines only the `allow-scripts` baseline and does not make additional
1186
+ * browser sandbox tokens a napplet capability surface.
1200
1187
  *
1201
1188
  * ### domains array + protocols map (compatibility NAP-SHELL)
1202
1189
  * The structured shape older shell capability consumers read:
1203
1190
  *
1204
1191
  * - `domains` — bare NAP domain names (the `naps` set MINUS the `inc:NAP-NN`
1205
1192
  * protocol strings) with the same conditional entries (relay/outbox under
1206
- * `hooks.relayPool`, upload/intent/link/common under their hooks). Any `perm:<x>`
1207
- * sandbox entries are appended here too — legacy supports helpers resolve
1208
- * `supports('perm:<x>')` as a plain `domains` membership check.
1193
+ * `hooks.relayPool`, upload/intent/link/common under their hooks).
1209
1194
  * - `protocols` — `{ inc: ['NAP-01'..'NAP-06'] }`, derived from
1210
1195
  * `NAP_INC_PROTOCOLS` by stripping the `inc:` prefix.
1211
1196
  *
1212
1197
  * Emitted as a superset alongside `naps`/`sandbox` for back-compat.
1213
1198
  *
1214
1199
  * @param hooks - The ShellAdapter provided by the host app
1215
- * @returns ShellCapabilities with domains/protocols (compatibility shape) plus
1216
- * naps (NAP vocab) and sandbox (perm:-prefixed) arrays
1200
+ * @returns ShellCapabilities with domains/protocols (compatibility shape), naps
1201
+ * (NAP vocab), and an empty sandbox compatibility array
1217
1202
  * @example
1218
1203
  * ```ts
1219
1204
  * const caps = buildShellCapabilities(hooks);
1220
1205
  * // caps.domains => ['relay','outbox','identity','storage','inc','theme','keys','media','notify','config','resource','cvm']
1221
1206
  * // (relay + outbox present when hooks.relayPool is provided; 'upload'/'intent'
1222
- * // appended under their hooks; perm:<x> sandbox entries appended when extended)
1207
+ * // appended under their hooks)
1223
1208
  * // caps.protocols => { inc: ['NAP-01','NAP-02','NAP-03','NAP-04','NAP-05','NAP-06'] }
1224
1209
  * // caps.naps => ['relay','outbox','identity','storage','inc','theme','keys','media','notify','config','resource','cvm',
1225
1210
  * // 'inc:NAP-01','inc:NAP-02','inc:NAP-03','inc:NAP-04','inc:NAP-05','inc:NAP-06']
1226
1211
  * // (relay + outbox present when hooks.relayPool is provided; 'upload'
1227
1212
  * // appended when hooks.upload is provided; 'intent' appended when
1228
1213
  * // hooks.intent.isAvailable() is true)
1229
- * // caps.sandbox => [] // host app may extend with 'perm:popups', etc.
1214
+ * // caps.sandbox => [] // retained for compatibility; not a NAP capability surface
1230
1215
  * ```
1231
1216
  */
1232
1217
  declare function buildShellCapabilities(hooks: ShellAdapter): ShellCapabilities;