@kehto/shell 0.1.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 +101 -0
- package/dist/index.d.ts +1617 -0
- package/dist/index.js +1129 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @kehto/shell
|
|
2
|
+
|
|
3
|
+
Browser adapter over @kehto/runtime — ShellBridge, domain proxies, keys-forwarder.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @kehto/shell
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`@kehto/shell` is the browser-specific integration layer for kehto. It wraps `@kehto/runtime` with the window/postMessage transport, localStorage persistence hooks, an audio manager, and the five canonical per-domain proxies defined by NIP-5D.
|
|
14
|
+
|
|
15
|
+
The primary entry point is `createShellBridge()` — it owns the postMessage listener, AUTH handshake, manifest verification, and every dispatch back into the runtime engine.
|
|
16
|
+
|
|
17
|
+
Canonical v1.2 behaviors this package enforces:
|
|
18
|
+
|
|
19
|
+
- 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).
|
|
20
|
+
- `shell.supports(capability)` uses the `perm:<permission>` namespace for sandbox permissions, not the v1.1 bare capability list.
|
|
21
|
+
- Five optional per-domain proxies — `createIdentityProxy`, `createThemeProxy`, `createKeysProxy`, `createMediaProxy`, `createNotifyProxy` — can be composed between napplet and runtime to intercept or augment traffic per NUB. They are NOT wired by default (the runtime already owns 8-domain dispatch); they exist as host-app composition seams.
|
|
22
|
+
- The keys-forwarder pumps host keydown events into `keys.forward` envelopes for napplets that hold the `keys:forward` capability.
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createShellBridge } from '@kehto/shell';
|
|
28
|
+
import { createNotificationService } from '@kehto/services';
|
|
29
|
+
|
|
30
|
+
const bridge = createShellBridge({
|
|
31
|
+
adapter: myShellAdapter,
|
|
32
|
+
hooks: myHooks,
|
|
33
|
+
target: window,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Register a reference service against the underlying runtime.
|
|
37
|
+
bridge.runtime.registerService(
|
|
38
|
+
'notifications',
|
|
39
|
+
createNotificationService({ onChange: updateBadge }),
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Public API
|
|
44
|
+
|
|
45
|
+
### Bridge factory
|
|
46
|
+
- [`createShellBridge`](../../docs/api/functions/_kehto_shell.createShellBridge.html) — primary entry point; returns a `ShellBridge` (exposed `runtime`, `shell.ready`, lifecycle hooks)
|
|
47
|
+
- `ShellBridge` — interface type for the returned bridge
|
|
48
|
+
|
|
49
|
+
### Hooks adapter
|
|
50
|
+
- [`adaptHooks`](../../docs/api/functions/_kehto_shell.adaptHooks.html) — convert a `ShellAdapter` + `BrowserDeps` into the canonical `RuntimeAdapter` hook bag consumed by `@kehto/runtime`
|
|
51
|
+
|
|
52
|
+
### Shell init
|
|
53
|
+
- [`buildShellCapabilities`](../../docs/api/functions/_kehto_shell.buildShellCapabilities.html) — construct the `ShellCapabilities` payload emitted during the `shell.ready` / `shell.init` handshake
|
|
54
|
+
|
|
55
|
+
### Domain proxies (NIP-5D composition seams)
|
|
56
|
+
- [`createIdentityProxy`](../../docs/api/functions/_kehto_shell.createIdentityProxy.html) — intercept `identity.getProfile/getFollows/...` traffic
|
|
57
|
+
- [`createThemeProxy`](../../docs/api/functions/_kehto_shell.createThemeProxy.html) — intercept `theme.get/theme.changed`
|
|
58
|
+
- [`createKeysProxy`](../../docs/api/functions/_kehto_shell.createKeysProxy.html) — intercept `keys.bind/unbind/bindings`
|
|
59
|
+
- [`createMediaProxy`](../../docs/api/functions/_kehto_shell.createMediaProxy.html) — intercept `media.*` playback control
|
|
60
|
+
- [`createNotifyProxy`](../../docs/api/functions/_kehto_shell.createNotifyProxy.html) — intercept `notify.send/list/read/dismiss`
|
|
61
|
+
|
|
62
|
+
### Keys forwarder
|
|
63
|
+
- [`createKeysForwarder`](../../docs/api/functions/_kehto_shell.createKeysForwarder.html) — host-keydown pump into `keys.forward` envelopes; auto-attached by `createShellBridge`, also exported for hosts that manage their own forwarder instance
|
|
64
|
+
|
|
65
|
+
### Session / origin registry
|
|
66
|
+
- `sessionRegistry` — canonical windowId ↔ verified-napplet registry singleton
|
|
67
|
+
- `nappKeyRegistry` — deprecated alias for `sessionRegistry`
|
|
68
|
+
- `originRegistry` — origin-to-windowId map used by proxies and the keys-forwarder
|
|
69
|
+
- `PendingUpdate` — type for pending aggregate-hash change prompts
|
|
70
|
+
|
|
71
|
+
### Manifest cache
|
|
72
|
+
- `manifestCache` — browser-specific manifest cache singleton
|
|
73
|
+
- `ManifestCacheEntry` — manifest cache entry type
|
|
74
|
+
|
|
75
|
+
### Audio manager
|
|
76
|
+
- `audioManager` — browser audio registry singleton (audio element pool)
|
|
77
|
+
- `AudioSource` — per-windowId audio source shape
|
|
78
|
+
|
|
79
|
+
### Topic constants
|
|
80
|
+
- `TOPICS` — canonical shell topic namespace for command routing
|
|
81
|
+
- `TopicKey`, `TopicValue` — typed topic lookup helpers
|
|
82
|
+
|
|
83
|
+
### Types
|
|
84
|
+
Exported for host-app integration: `ShellAdapter`, `ShellCapabilities`, `RelayPoolHooks`, `RelayPoolLike`, `RelayConfigHooks`, `WindowManagerHooks`, `AuthHooks`, `ConfigHooks`, `HotkeyHooks`, `WorkerRelayHooks`, `WorkerRelayLike`, `CryptoHooks`, `DmHooks`, `SessionEntry`, `NappKeyEntry` (deprecated), `AclEntry`, `AclCheckEvent`, `ServiceDescriptor`, `ServiceHandler`, `ServiceRegistry`, `NostrEvent`, `NostrFilter`, `NappletMessage`, `ConsentRequest`, and per-proxy `*Deps`/`*Proxy` interfaces.
|
|
85
|
+
|
|
86
|
+
### Enforcement re-exports (from @kehto/runtime)
|
|
87
|
+
`createEnforceGate`, `createNubEnforceGate`, `formatDenialReason`, plus `EnforceResult`, `EnforceConfig`, `NubEnforceConfig`, `IdentityResolver`, `AclChecker`, `NubMessage`.
|
|
88
|
+
|
|
89
|
+
### Compat re-exports (DRIFT-CORE-06)
|
|
90
|
+
|
|
91
|
+
Retained for v1.1 migration consumers; new integrations should use canonical NIP-5D envelope types from `@napplet/core`. Slated for removal once upstream restores those exports.
|
|
92
|
+
|
|
93
|
+
Re-exported from `@kehto/runtime`: the v1.1 bus-kind enum, auth event kind, shell bridge URI constant, protocol version string, the full capability list, destructive-kind set, and the replay window seconds constant. Re-exported types cover the v1.1 capability union and bus-kind numeric union. See the typedoc API reference below for the exact identifier list.
|
|
94
|
+
|
|
95
|
+
## API Reference
|
|
96
|
+
|
|
97
|
+
Full API reference: [docs/api/@kehto/shell/](../../docs/api/modules/_kehto_shell.html) (generated via `pnpm docs:api`).
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|