@kehto/services 0.10.1 → 0.11.1
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 +10 -8
- package/dist/cvm-nostr-transport.d.ts +1 -1
- package/dist/{cvm-service-CXcOVQ0m.d.ts → cvm-service-DKIzbiDw.d.ts} +2 -2
- package/dist/index.d.ts +106 -43
- package/dist/index.js +204 -133
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Current draft posture:
|
|
|
22
22
|
|
|
23
23
|
- The v1.1 signer service is deleted outright. Its responsibilities split into two: read-only identity lookups go through `createIdentityService` (`getPublicKey`, `getRelays`, `getProfile`, `getFollows`, `getList`, `getZaps`, `getMutes`, `getBlocked`, `getBadges`); signing happens inside the shell as part of `relay.publish` / `relay.publishEncrypted` and is never exposed to napplets.
|
|
24
24
|
- `createKeysService` and `createMediaService` ship real reference backends as of v1.4 (see the dedicated sections below). `createKeysService` attaches a document-level `keydown` listener by default and delivers `keys.action` push envelopes to registered napplets; `createMediaService` mirrors session metadata and playback state to `navigator.mediaSession` and emits `media.command` push envelopes on OS transport events. Both accept a host-bridge option (`HostKeysBridge` / `HostMediaBridge`) so Electron / Tauri / native shells can swap in OS-level backends without re-implementing the wire-protocol bookkeeping.
|
|
25
|
-
- `createNotifyService` (NIP-5D `notify.*` NAP) coexists with the legacy `createNotificationService` (
|
|
25
|
+
- `createNotifyService` (NIP-5D `notify.*` NAP) coexists with the legacy `createNotificationService` (inc-emit `notifications:*` channel). Both may be registered simultaneously while hosts migrate.
|
|
26
26
|
|
|
27
27
|
## Quick Start
|
|
28
28
|
|
|
@@ -36,13 +36,13 @@ import {
|
|
|
36
36
|
runtime.registerService(
|
|
37
37
|
'identity',
|
|
38
38
|
createIdentityService({
|
|
39
|
-
|
|
40
|
-
getRelays: () => signer.getRelays(),
|
|
39
|
+
getSigner: () => signer,
|
|
41
40
|
getProfile: (pk) => nostrClient.fetchProfile(pk),
|
|
41
|
+
getFollows: (pk) => contactListCache.getFollows(pk),
|
|
42
42
|
}),
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
// Notification service — legacy
|
|
45
|
+
// Notification service — legacy inc-emit channel, browser badge fan-out.
|
|
46
46
|
runtime.registerService(
|
|
47
47
|
'notifications',
|
|
48
48
|
createNotificationService({ onChange: (list) => updateBadge(list) }),
|
|
@@ -256,7 +256,7 @@ export interface HostMediaBridge {
|
|
|
256
256
|
/**
|
|
257
257
|
* Set the playback state for a session. Called on media.state reports
|
|
258
258
|
* whenever the session is the active session. State strings match
|
|
259
|
-
*
|
|
259
|
+
* nap-media MediaState.status exactly. Implementations MUST be idempotent.
|
|
260
260
|
*/
|
|
261
261
|
setPlaybackState(sessionId: string, state: 'playing' | 'paused' | 'stopped' | 'buffering'): void;
|
|
262
262
|
|
|
@@ -353,9 +353,11 @@ Each factory returns a `ServiceHandler` registrable via `runtime.registerService
|
|
|
353
353
|
### Identity NAP
|
|
354
354
|
- `createIdentityService` — `identity.*` reads (`identity:read`). No signing surface; shell mediates signing internally.
|
|
355
355
|
|
|
356
|
+
`createIdentityService` uses `getSigner()` for `identity.getPublicKey` and `identity.getRelays`. Hosts may also pass optional read-only provider hooks for `getProfile`, `getFollows`, `getList`, `getZaps`, `getMutes`, `getBlocked`, and `getBadges`. These hooks receive the current signer pubkey (or `""` when no signer is connected) and return the payload portion of the corresponding `.result` envelope. Kehto does not query relays itself; the hooks are for hosts that already maintain profile, contact-list, list, zap, moderation, or badge data.
|
|
357
|
+
|
|
356
358
|
### Notify NAP
|
|
357
359
|
- `createNotifyService` — canonical `notify.*` envelopes (`notify:send` / `notify:channel`).
|
|
358
|
-
- `createNotificationService` — legacy
|
|
360
|
+
- `createNotificationService` — legacy inc-emit `notifications:*` channel; coexists with `createNotifyService` until retired.
|
|
359
361
|
|
|
360
362
|
### Relay NAP
|
|
361
363
|
- `createRelayPoolService` — `relay.publish`, `relay.publishEncrypted`, `relay.subscribe` fan-out (`relay:read` / `relay:write`).
|
|
@@ -371,8 +373,8 @@ Each factory returns a `ServiceHandler` registrable via `runtime.registerService
|
|
|
371
373
|
### Theme NAP
|
|
372
374
|
- `createThemeService` — `theme.get` + `theme.changed` fan-out (`theme:read`). Returns a `ThemeService` with `publishTheme()` / `setTheme()` utilities for host-side updates.
|
|
373
375
|
|
|
374
|
-
### Audio (legacy
|
|
375
|
-
- `createAudioService` — `audio:*`
|
|
376
|
+
### Audio (legacy inc-emit)
|
|
377
|
+
- `createAudioService` — `audio:*` inc-emit topic handler. Browser-agnostic registry of per-window audio sources; host wires `onChange` to update transport UI.
|
|
376
378
|
|
|
377
379
|
### Types
|
|
378
380
|
`AudioSource`, `AudioServiceOptions`, `Notification`, `NotificationServiceOptions`, `IdentityServiceOptions`, `RelayPoolServiceOptions`, `CacheServiceOptions`, `CoordinatedRelayOptions`, `KeysServiceOptions`, `MediaServiceOptions`, `NotifyServiceOptions`, `ThemeServiceOptions`, `ThemeService`.
|
|
@@ -4,11 +4,11 @@ import { ServiceHandler } from '@kehto/runtime';
|
|
|
4
4
|
* cvm-types.ts — NAP-CVM (ContextVM bridge) wire + MCP value types.
|
|
5
5
|
*
|
|
6
6
|
* Kehto-internal model for the NAP-CVM wire contract (upstream draft:
|
|
7
|
-
* napplet/
|
|
7
|
+
* napplet/naps NAP-CVM, namespace `window.napplet.cvm`). The literal `type`
|
|
8
8
|
* strings and field names below MUST match the upstream `@napplet/nap/cvm`
|
|
9
9
|
* envelopes byte-for-byte so the shim client interoperates; the types live
|
|
10
10
|
* here (not imported from `@napplet/core`) per the same convention as
|
|
11
|
-
*
|
|
11
|
+
* NAP-RESOURCE (PROJECT.md Decision #31) to avoid a peer-dependency version
|
|
12
12
|
* bump.
|
|
13
13
|
*
|
|
14
14
|
* ContextVM transports MCP JSON-RPC over Nostr (kind 25910), optionally
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ServiceHandler, Signer } from '@kehto/runtime';
|
|
2
|
+
import { IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage } from '@napplet/nap/identity/types';
|
|
2
3
|
import { NostrFilter, NostrEvent, EventTemplate } from '@napplet/core';
|
|
3
4
|
import { MediaMetadata, MediaAction } from '@napplet/nap/media/types';
|
|
4
5
|
export { MediaAction } from '@napplet/nap/media/types';
|
|
5
6
|
import { NotifySendMessage } from '@napplet/nap/notify/types';
|
|
6
7
|
import { Theme, ThemeChangedMessage } from '@napplet/nap/theme/types';
|
|
7
8
|
import { ConfigSchemaErrorCode, ConfigValues, NappletConfigSchema } from '@napplet/nap/config/types';
|
|
8
|
-
export { a as CvmCloseMessage, b as CvmCloseResultMessage, c as CvmDiscoverMessage, d as CvmDiscoverQuery, e as CvmDiscoverResultMessage, f as CvmEventMessage, g as CvmInboundMessage, h as CvmOutboundMessage, i as CvmRequestMessage, j as CvmRequestOptions, k as CvmRequestResultMessage, l as CvmServer, m as CvmServerRef, n as CvmService, o as CvmServiceOptions, C as CvmTransport, p as CvmTransportError, M as McpContentBlock, q as McpMessage, r as McpTool, s as McpToolResult, t as createCvmService } from './cvm-service-
|
|
9
|
+
export { a as CvmCloseMessage, b as CvmCloseResultMessage, c as CvmDiscoverMessage, d as CvmDiscoverQuery, e as CvmDiscoverResultMessage, f as CvmEventMessage, g as CvmInboundMessage, h as CvmOutboundMessage, i as CvmRequestMessage, j as CvmRequestOptions, k as CvmRequestResultMessage, l as CvmServer, m as CvmServerRef, n as CvmService, o as CvmServiceOptions, C as CvmTransport, p as CvmTransportError, M as McpContentBlock, q as McpMessage, r as McpTool, s as McpToolResult, t as createCvmService } from './cvm-service-DKIzbiDw.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @kehto/services — Shared types for reference service implementations.
|
|
@@ -171,7 +172,7 @@ declare function createAudioService(options?: AudioServiceOptions): ServiceHandl
|
|
|
171
172
|
declare function createNotificationService(options?: NotificationServiceOptions): ServiceHandler;
|
|
172
173
|
|
|
173
174
|
/**
|
|
174
|
-
* identity-service.ts — NIP-5D identity
|
|
175
|
+
* identity-service.ts — NIP-5D identity nap reference service.
|
|
175
176
|
*
|
|
176
177
|
* MIGRATION from signer-service (v1.1 -> v1.2):
|
|
177
178
|
* - signer.getPublicKey -> identity.getPublicKey (same shell state)
|
|
@@ -189,11 +190,12 @@ declare function createNotificationService(options?: NotificationServiceOptions)
|
|
|
189
190
|
*
|
|
190
191
|
* Handles 9 identity.* request types from @napplet/nap/identity. getPublicKey
|
|
191
192
|
* and getRelays return real values sourced from hooks.auth.getSigner(); the
|
|
192
|
-
* remaining
|
|
193
|
-
*
|
|
194
|
-
* runtime.registerService('identity', realHandler).
|
|
193
|
+
* remaining read-only queries can be backed by optional host providers. When a
|
|
194
|
+
* provider is absent, the service keeps returning spec-shaped empty results.
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
|
+
/** A value that may be returned synchronously or through a Promise. */
|
|
198
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
197
199
|
/**
|
|
198
200
|
* Options for creating the identity service.
|
|
199
201
|
*
|
|
@@ -212,14 +214,75 @@ interface IdentityServiceOptions {
|
|
|
212
214
|
* availability can change dynamically.
|
|
213
215
|
*/
|
|
214
216
|
getSigner: () => Signer | null;
|
|
217
|
+
/**
|
|
218
|
+
* Optional host-backed profile lookup for the current user.
|
|
219
|
+
*
|
|
220
|
+
* Kehto does not query relays itself; hosts that already maintain kind-0
|
|
221
|
+
* metadata can provide it here without replacing the whole identity service.
|
|
222
|
+
*
|
|
223
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
224
|
+
* @param message - Original identity.getProfile request envelope.
|
|
225
|
+
* @returns Profile metadata, or null when unavailable.
|
|
226
|
+
*/
|
|
227
|
+
getProfile?: (pubkey: string, message: IdentityGetProfileMessage) => MaybePromise<IdentityGetProfileResultMessage['profile']>;
|
|
228
|
+
/**
|
|
229
|
+
* Optional host-backed follow-list lookup for the current user.
|
|
230
|
+
*
|
|
231
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
232
|
+
* @param message - Original identity.getFollows request envelope.
|
|
233
|
+
* @returns Hex-encoded followed pubkeys.
|
|
234
|
+
*/
|
|
235
|
+
getFollows?: (pubkey: string, message: IdentityGetFollowsMessage) => MaybePromise<IdentityGetFollowsResultMessage['pubkeys']>;
|
|
236
|
+
/**
|
|
237
|
+
* Optional host-backed categorized-list lookup for the current user.
|
|
238
|
+
*
|
|
239
|
+
* @param listType - Requested list category from the wire envelope.
|
|
240
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
241
|
+
* @param message - Original identity.getList request envelope.
|
|
242
|
+
* @returns List entries.
|
|
243
|
+
*/
|
|
244
|
+
getList?: (listType: string, pubkey: string, message: IdentityGetListMessage) => MaybePromise<IdentityGetListResultMessage['entries']>;
|
|
245
|
+
/**
|
|
246
|
+
* Optional host-backed zap receipt lookup for the current user.
|
|
247
|
+
*
|
|
248
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
249
|
+
* @param message - Original identity.getZaps request envelope.
|
|
250
|
+
* @returns Zap receipts.
|
|
251
|
+
*/
|
|
252
|
+
getZaps?: (pubkey: string, message: IdentityGetZapsMessage) => MaybePromise<IdentityGetZapsResultMessage['zaps']>;
|
|
253
|
+
/**
|
|
254
|
+
* Optional host-backed mute-list lookup for the current user.
|
|
255
|
+
*
|
|
256
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
257
|
+
* @param message - Original identity.getMutes request envelope.
|
|
258
|
+
* @returns Hex-encoded muted pubkeys.
|
|
259
|
+
*/
|
|
260
|
+
getMutes?: (pubkey: string, message: IdentityGetMutesMessage) => MaybePromise<IdentityGetMutesResultMessage['pubkeys']>;
|
|
261
|
+
/**
|
|
262
|
+
* Optional host-backed block-list lookup for the current user.
|
|
263
|
+
*
|
|
264
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
265
|
+
* @param message - Original identity.getBlocked request envelope.
|
|
266
|
+
* @returns Hex-encoded blocked pubkeys.
|
|
267
|
+
*/
|
|
268
|
+
getBlocked?: (pubkey: string, message: IdentityGetBlockedMessage) => MaybePromise<IdentityGetBlockedResultMessage['pubkeys']>;
|
|
269
|
+
/**
|
|
270
|
+
* Optional host-backed badge lookup for the current user.
|
|
271
|
+
*
|
|
272
|
+
* @param pubkey - Current signer pubkey, or "" when no signer is connected.
|
|
273
|
+
* @param message - Original identity.getBadges request envelope.
|
|
274
|
+
* @returns Badges awarded to the user.
|
|
275
|
+
*/
|
|
276
|
+
getBadges?: (pubkey: string, message: IdentityGetBadgesMessage) => MaybePromise<IdentityGetBadgesResultMessage['badges']>;
|
|
215
277
|
}
|
|
216
278
|
/**
|
|
217
279
|
* Create an identity service that handles NIP-5D identity.* envelope messages.
|
|
218
280
|
*
|
|
219
281
|
* Supports the 9 read-only identity.* request types from @napplet/nap/identity.
|
|
220
282
|
* The two nostr-info queries (getPublicKey, getRelays) resolve through the
|
|
221
|
-
* caller-supplied signer; the remaining
|
|
222
|
-
*
|
|
283
|
+
* caller-supplied signer; the remaining read-only queries resolve through
|
|
284
|
+
* optional host providers or return default/empty payloads with spec-correct
|
|
285
|
+
* envelope shapes so napplets always receive a result envelope.
|
|
223
286
|
*
|
|
224
287
|
* @param options - Identity service configuration (getSigner)
|
|
225
288
|
* @returns A ServiceHandler ready for runtime.registerService('identity', handler)
|
|
@@ -241,7 +304,7 @@ declare function createIdentityService(options: IdentityServiceOptions): Service
|
|
|
241
304
|
*
|
|
242
305
|
* Wraps an existing relay pool implementation (subscribe, publish,
|
|
243
306
|
* selectRelayTier, isAvailable) as a ServiceHandler that receives
|
|
244
|
-
* relay
|
|
307
|
+
* relay NAP envelope messages and manages subscription lifecycle.
|
|
245
308
|
*
|
|
246
309
|
* Handles: relay.subscribe, relay.close, relay.publish, relay.publishEncrypted.
|
|
247
310
|
*
|
|
@@ -470,7 +533,7 @@ interface CoordinatedRelayOptions {
|
|
|
470
533
|
declare function createCoordinatedRelay(options: CoordinatedRelayOptions): ServiceHandler;
|
|
471
534
|
|
|
472
535
|
/**
|
|
473
|
-
* keys-service.ts — NIP-5D keys
|
|
536
|
+
* keys-service.ts — NIP-5D keys NAP reference document-level listener implementation.
|
|
474
537
|
*
|
|
475
538
|
* Handles the 3 napplet -> shell request types from @napplet/nap/keys:
|
|
476
539
|
* - keys.forward -> invokes options.onForward (hotkey passthrough, fire-and-forget)
|
|
@@ -745,7 +808,7 @@ declare function createBrowserMediaBridge(opts?: {
|
|
|
745
808
|
}): HostMediaBridge;
|
|
746
809
|
|
|
747
810
|
/**
|
|
748
|
-
* media-service.ts — NIP-5D media
|
|
811
|
+
* media-service.ts — NIP-5D media NAP reference service (navigator.mediaSession
|
|
749
812
|
* reference implementation).
|
|
750
813
|
*
|
|
751
814
|
* Handles the napplet-owned subset of @napplet/nap/media:
|
|
@@ -777,7 +840,7 @@ declare function createBrowserMediaBridge(opts?: {
|
|
|
777
840
|
* up the active session's owning napplet, invokes the per-window send callback captured
|
|
778
841
|
* at session.create time, and delivers:
|
|
779
842
|
* { type: 'media.command', sessionId, action, value? }
|
|
780
|
-
* where action is the
|
|
843
|
+
* where action is the nap-media MediaAction literal (play|pause|next|prev|seek) and
|
|
781
844
|
* value is the seekTime (seconds) for seek.
|
|
782
845
|
*
|
|
783
846
|
* Silent-audio prime: the browser bridge creates a hidden <audio> element with a
|
|
@@ -793,10 +856,10 @@ declare function createBrowserMediaBridge(opts?: {
|
|
|
793
856
|
* destroyed, the next-most-recently-touched session is promoted automatically.
|
|
794
857
|
*
|
|
795
858
|
* Note: this is SEPARATE from packages/services/src/audio-service.ts, which
|
|
796
|
-
* is the legacy
|
|
797
|
-
* over
|
|
859
|
+
* is the legacy inc-topic-based audio source registry (audio:* topic events
|
|
860
|
+
* over inc.emit). media-service is the canonical @napplet/nap/media NIP-5D
|
|
798
861
|
* path and they coexist — audio-service continues to track audio sources for
|
|
799
|
-
* shell UI, while media-service handles the
|
|
862
|
+
* shell UI, while media-service handles the NAP protocol envelope surface.
|
|
800
863
|
*
|
|
801
864
|
* Shell -> Napplet push types (media.command) are emitted here when
|
|
802
865
|
* bridge.onAction callbacks fire — this is the canonical Phase 27 real backend.
|
|
@@ -872,7 +935,7 @@ interface HostMediaBridge {
|
|
|
872
935
|
/**
|
|
873
936
|
* Set the playback state for a session. Called on media.state reports
|
|
874
937
|
* whenever the session is the active session. State strings match
|
|
875
|
-
*
|
|
938
|
+
* nap-media MediaState.status exactly. Implementations MUST be idempotent.
|
|
876
939
|
*/
|
|
877
940
|
setPlaybackState(sessionId: string, state: 'playing' | 'paused' | 'stopped' | 'buffering'): void;
|
|
878
941
|
/**
|
|
@@ -960,13 +1023,13 @@ interface MediaServiceOptions {
|
|
|
960
1023
|
hostBridge?: HostMediaBridge;
|
|
961
1024
|
}
|
|
962
1025
|
/**
|
|
963
|
-
* Create a media
|
|
1026
|
+
* Create a media NAP service handler with navigator.mediaSession integration.
|
|
964
1027
|
*
|
|
965
1028
|
* Implements the 5 napplet->shell media.* request types defined in
|
|
966
1029
|
* `@napplet/nap/media`. Only `media.session.create` produces a reply
|
|
967
1030
|
* envelope (`media.session.create.result`) — the remaining four
|
|
968
1031
|
* (`session.update`, `session.destroy`, `state`, `capabilities`) are
|
|
969
|
-
* fire-and-forget per the
|
|
1032
|
+
* fire-and-forget per the NAP spec.
|
|
970
1033
|
*
|
|
971
1034
|
* Unknown `media.*` actions produce a `<type>.error` envelope so
|
|
972
1035
|
* napplets are never left hanging on a malformed request.
|
|
@@ -991,7 +1054,7 @@ declare function createMediaService(options?: MediaServiceOptions): ServiceHandl
|
|
|
991
1054
|
};
|
|
992
1055
|
|
|
993
1056
|
/**
|
|
994
|
-
* notify-service.ts — NIP-5D notify
|
|
1057
|
+
* notify-service.ts — NIP-5D notify NAP reference service (stub-level).
|
|
995
1058
|
*
|
|
996
1059
|
* Handles the 5 napplet -> shell request types from `@napplet/nap/notify`:
|
|
997
1060
|
* - `notify.send` -> `notify.send.result` (shell-assigned id)
|
|
@@ -1006,12 +1069,12 @@ declare function createMediaService(options?: MediaServiceOptions): ServiceHandl
|
|
|
1006
1069
|
*
|
|
1007
1070
|
* Coexistence note: this is SEPARATE from
|
|
1008
1071
|
* `packages/services/src/notification-service.ts`, which is the legacy
|
|
1009
|
-
*
|
|
1072
|
+
* inc-topic-based notification registry (operates on `inc.emit` topics
|
|
1010
1073
|
* under `notifications:*`). `notify-service.ts` is the canonical
|
|
1011
1074
|
* `@napplet/nap/notify` NIP-5D path and lives alongside the legacy module.
|
|
1012
1075
|
* If the host app registers this service via
|
|
1013
1076
|
* `runtime.registerService('notify', ...)`, @napplet/nap/notify messages
|
|
1014
|
-
* land here; the legacy
|
|
1077
|
+
* land here; the legacy inc-emit topic path remains untouched.
|
|
1015
1078
|
*
|
|
1016
1079
|
* Shell -> napplet push messages (`notify.action`, `notify.clicked`,
|
|
1017
1080
|
* `notify.dismissed`, `notify.controls`) are not emitted by this stub —
|
|
@@ -1074,7 +1137,7 @@ interface NotifyServiceOptions {
|
|
|
1074
1137
|
declare function createNotifyService(options?: NotifyServiceOptions): ServiceHandler;
|
|
1075
1138
|
|
|
1076
1139
|
/**
|
|
1077
|
-
* theme-service.ts — NIP-5D theme
|
|
1140
|
+
* theme-service.ts — NIP-5D theme NAP reference service.
|
|
1078
1141
|
*
|
|
1079
1142
|
* Handles the single napplet->shell request type from @napplet/nap/theme:
|
|
1080
1143
|
* - `theme.get` -> `theme.get.result { theme }` (current theme)
|
|
@@ -1156,7 +1219,7 @@ interface ThemeService {
|
|
|
1156
1219
|
getCurrentTheme: () => Theme;
|
|
1157
1220
|
}
|
|
1158
1221
|
/**
|
|
1159
|
-
* Create a theme service that handles the NIP-5D `theme.*`
|
|
1222
|
+
* Create a theme service that handles the NIP-5D `theme.*` NAP.
|
|
1160
1223
|
*
|
|
1161
1224
|
* Answers `theme.get` with the current theme (default or
|
|
1162
1225
|
* `options.initialTheme`). Exposes `publishTheme(theme)` for the host app to
|
|
@@ -1178,24 +1241,24 @@ interface ThemeService {
|
|
|
1178
1241
|
declare function createThemeService(options?: ThemeServiceOptions): ThemeService;
|
|
1179
1242
|
|
|
1180
1243
|
/**
|
|
1181
|
-
* config-service.ts —
|
|
1244
|
+
* config-service.ts — NAP-CONFIG reference service (9th NAP domain, v1.7 Phase 39).
|
|
1182
1245
|
*
|
|
1183
|
-
* Shell-side reference implementation for the canonical
|
|
1246
|
+
* Shell-side reference implementation for the canonical NAP-CONFIG wire
|
|
1184
1247
|
* protocol (`@napplet/nap/config`, published at `^0.3.0`). Handles the full
|
|
1185
1248
|
* 8-message discriminated union: 5 napplet→shell request types + 3
|
|
1186
1249
|
* shell→napplet result/push types.
|
|
1187
1250
|
*
|
|
1188
1251
|
* ──────────────────────────── SCOPE BOUNDARY (CONFIG-04) ─────────────────────────
|
|
1189
|
-
*
|
|
1252
|
+
* NAP-CONFIG is **shell-managed per-napplet configuration**. Napplets observe
|
|
1190
1253
|
* values via `config.get` (one-shot) or `config.subscribe` (snapshot + live
|
|
1191
1254
|
* push). The shell is the **sole writer** — there is intentionally **NO**
|
|
1192
1255
|
* `config.set` wire message. Napplets cannot mutate configuration values;
|
|
1193
1256
|
* the shell owns persistence and the update flow.
|
|
1194
1257
|
*
|
|
1195
|
-
* Do NOT use this service as a general key-value store.
|
|
1258
|
+
* Do NOT use this service as a general key-value store. NAP-STORAGE
|
|
1196
1259
|
* (`state:read` / `state:write`) remains the general KV surface. Using
|
|
1197
|
-
*
|
|
1198
|
-
* (H-07 in PITFALLS.md) — such state belongs in
|
|
1260
|
+
* NAP-CONFIG to store e.g. `{ lastScrollPosition: 420 }` is an anti-pattern
|
|
1261
|
+
* (H-07 in PITFALLS.md) — such state belongs in NAP-STORAGE.
|
|
1199
1262
|
* ──────────────────────────────────────────────────────────────────────────────────
|
|
1200
1263
|
*
|
|
1201
1264
|
* Host integration: provide `getValues()` returning the current
|
|
@@ -1284,7 +1347,7 @@ interface ConfigServiceOptions {
|
|
|
1284
1347
|
openSettings?: (windowId: string, section: string | undefined) => void;
|
|
1285
1348
|
}
|
|
1286
1349
|
/**
|
|
1287
|
-
*
|
|
1350
|
+
* NAP-CONFIG reference service bundle — `handler` to register with the
|
|
1288
1351
|
* runtime, `publishValues` for the host app to push updates live to all
|
|
1289
1352
|
* subscribed napplets.
|
|
1290
1353
|
*/
|
|
@@ -1302,7 +1365,7 @@ interface ConfigService {
|
|
|
1302
1365
|
publishValues(values: ConfigValues): void;
|
|
1303
1366
|
}
|
|
1304
1367
|
/**
|
|
1305
|
-
* Create a
|
|
1368
|
+
* Create a NAP-CONFIG reference service.
|
|
1306
1369
|
*
|
|
1307
1370
|
* Shell-writes, napplet-reads. Handles the full `@napplet/nap/config` wire
|
|
1308
1371
|
* protocol: `config.get` (correlated snapshot), `config.subscribe` /
|
|
@@ -1320,7 +1383,7 @@ interface ConfigService {
|
|
|
1320
1383
|
*
|
|
1321
1384
|
* @see ConfigServiceOptions for the options shape.
|
|
1322
1385
|
* @see packages/services/src/theme-service.ts for the sibling pattern.
|
|
1323
|
-
* @see SCOPE BOUNDARY comment at the top of this file re:
|
|
1386
|
+
* @see SCOPE BOUNDARY comment at the top of this file re: NAP-STORAGE separation.
|
|
1324
1387
|
*
|
|
1325
1388
|
* @example
|
|
1326
1389
|
* ```ts
|
|
@@ -1339,9 +1402,9 @@ interface ConfigService {
|
|
|
1339
1402
|
declare function createConfigService(options: ConfigServiceOptions): ConfigService;
|
|
1340
1403
|
|
|
1341
1404
|
/**
|
|
1342
|
-
* resource-service.ts —
|
|
1405
|
+
* resource-service.ts — NAP-RESOURCE reference service (10th NAP domain, v1.7 Phase 40).
|
|
1343
1406
|
*
|
|
1344
|
-
* Shell-side reference implementation for the canonical
|
|
1407
|
+
* Shell-side reference implementation for the canonical NAP-RESOURCE wire
|
|
1345
1408
|
* protocol (`internal-resource.ts` in @kehto/shell/src/types; kehto-internal
|
|
1346
1409
|
* model per PROJECT.md Decision #31 — diverges from upstream `@napplet/nap/
|
|
1347
1410
|
* resource` in field names + error vocabulary). Handles the canonical
|
|
@@ -1350,12 +1413,12 @@ declare function createConfigService(options: ConfigServiceOptions): ConfigServi
|
|
|
1350
1413
|
* Outbound: resource.bytes.result, resource.bytes.error
|
|
1351
1414
|
*
|
|
1352
1415
|
* ──────────────────────── SCOPE BOUNDARY (RESOURCE-01) ────────────────────────
|
|
1353
|
-
*
|
|
1416
|
+
* NAP-RESOURCE is an **authenticated fetch proxy** — read-only, atomic.
|
|
1354
1417
|
*
|
|
1355
1418
|
* This service is NOT responsible for:
|
|
1356
1419
|
* - Streaming / chunked responses (host-app concern)
|
|
1357
1420
|
* - Response caching / conditional requests (host-app concern)
|
|
1358
|
-
* - Upload / POST body construction (
|
|
1421
|
+
* - Upload / POST body construction (NAP-RESOURCE v1.7 is read-only)
|
|
1359
1422
|
* - Redirect limits, MIME sniffing, SVG rasterization (host-fetch concern)
|
|
1360
1423
|
* - Private-IP blocking, SSRF mitigation (host-provided-fetch responsibility)
|
|
1361
1424
|
*
|
|
@@ -1374,7 +1437,7 @@ declare function createConfigService(options: ConfigServiceOptions): ConfigServi
|
|
|
1374
1437
|
* const resourceSvc = createResourceService({
|
|
1375
1438
|
* fetch: (url, init) => globalThis.fetch(url, init),
|
|
1376
1439
|
* isOriginGranted: (origin, grants) => grants.includes(origin),
|
|
1377
|
-
* getConnectGrants: (dTag, hash) =>
|
|
1440
|
+
* getConnectGrants: (dTag, hash) => myOriginGrantStore.getOrigins(dTag, hash),
|
|
1378
1441
|
* resolveIdentity: (windowId) => sessionRegistry.getEntryByWindowId(windowId) ?? null,
|
|
1379
1442
|
* });
|
|
1380
1443
|
* runtime.registerService('resource', resourceSvc);
|
|
@@ -1423,8 +1486,8 @@ interface ResourceServiceOptions {
|
|
|
1423
1486
|
* Returns the list of allowed fetch origins for the given napplet identity.
|
|
1424
1487
|
* Called on every `resource.bytes` request — must be synchronous and fast.
|
|
1425
1488
|
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1489
|
+
* Host-supplied grant source (e.g. a static per-dTag allowlist map, or any
|
|
1490
|
+
* other host-controlled policy). Returns an empty array to deny all origins.
|
|
1428
1491
|
*
|
|
1429
1492
|
* H-03 prevention: REQUIRED from day one — factory throws on construction
|
|
1430
1493
|
* if omitted.
|
|
@@ -1452,7 +1515,7 @@ interface ResourceServiceOptions {
|
|
|
1452
1515
|
*/
|
|
1453
1516
|
type ResourceService = ServiceHandler;
|
|
1454
1517
|
/**
|
|
1455
|
-
* Create a
|
|
1518
|
+
* Create a NAP-RESOURCE reference service.
|
|
1456
1519
|
*
|
|
1457
1520
|
* Implements canonical 4-message protocol: `resource.bytes` (napplet → shell
|
|
1458
1521
|
* fetch request), `resource.cancel` (napplet → shell in-flight cancellation),
|
|
@@ -1477,7 +1540,7 @@ type ResourceService = ServiceHandler;
|
|
|
1477
1540
|
* const svc = createResourceService({
|
|
1478
1541
|
* fetch: (url, init) => globalThis.fetch(url, init),
|
|
1479
1542
|
* isOriginGranted: (origin, grants) => grants.includes(origin),
|
|
1480
|
-
* getConnectGrants: (dTag, hash) =>
|
|
1543
|
+
* getConnectGrants: (dTag, hash) => myOriginGrantStore.getOrigins(dTag, hash),
|
|
1481
1544
|
* resolveIdentity: (windowId) => sessionRegistry.getEntryByWindowId(windowId) ?? null,
|
|
1482
1545
|
* });
|
|
1483
1546
|
* runtime.registerService('resource', svc);
|
|
@@ -1690,7 +1753,7 @@ interface RelayListEntry {
|
|
|
1690
1753
|
/**
|
|
1691
1754
|
* Relay pool contract the router drives. Implementors adapt their pool library
|
|
1692
1755
|
* (nostr-tools SimplePool, applesauce-relay, etc.). Unlike the lower-level
|
|
1693
|
-
* relay
|
|
1756
|
+
* relay NAP pool, both methods take an explicit relay-URL set so the router
|
|
1694
1757
|
* controls outbox routing and can attribute events to the relay they arrived on.
|
|
1695
1758
|
*/
|
|
1696
1759
|
interface OutboxRelayPool {
|
|
@@ -1985,7 +2048,7 @@ declare function createHttpUploader(options: HttpUploaderOptions): Uploader;
|
|
|
1985
2048
|
* intent-types.ts — NAP-INTENT (archetype intent dispatch) value types.
|
|
1986
2049
|
*
|
|
1987
2050
|
* Kehto-internal model for the NAP-INTENT wire contract (upstream draft:
|
|
1988
|
-
* napplet/
|
|
2051
|
+
* napplet/naps NAP-INTENT, namespace `window.napplet.intent`). The installed
|
|
1989
2052
|
* `@napplet/core` peer predates these types, so — as with {@link ./cvm-types} —
|
|
1990
2053
|
* kehto defines them here, wire-compatible with the upstream shapes, rather
|
|
1991
2054
|
* than redefining the generic NIP-5D envelope.
|
|
@@ -2338,4 +2401,4 @@ interface ManifestArchetypeInput {
|
|
|
2338
2401
|
*/
|
|
2339
2402
|
declare function manifestToIntentCatalogEntry(manifest: ManifestArchetypeInput): IntentCatalogEntry;
|
|
2340
2403
|
|
|
2341
|
-
export { type AudioServiceOptions, type AudioSource, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentAvailability, type IntentBehavior, type IntentCandidate, type IntentCatalogEntry, type IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type ManifestArchetypeInput, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceService, type ResourceServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadRail, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, createAudioService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createConfigService, createCoordinatedRelay, createHttpUploader, createIdentityService, createIntentService, createKeysService, createMediaService, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createThemeService, createUploadService, manifestToIntentCatalogEntry };
|
|
2404
|
+
export { type AudioServiceOptions, type AudioSource, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentAvailability, type IntentBehavior, type IntentCandidate, type IntentCatalogEntry, type IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type ManifestArchetypeInput, type MaybePromise, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceService, type ResourceServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadRail, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, createAudioService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createConfigService, createCoordinatedRelay, createHttpUploader, createIdentityService, createIntentService, createKeysService, createMediaService, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createThemeService, createUploadService, manifestToIntentCatalogEntry };
|