@kehto/services 0.10.0 → 0.11.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
|
@@ -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
|
|
|
@@ -42,7 +42,7 @@ runtime.registerService(
|
|
|
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
|
|
|
@@ -355,7 +355,7 @@ Each factory returns a `ServiceHandler` registrable via `runtime.registerService
|
|
|
355
355
|
|
|
356
356
|
### Notify NAP
|
|
357
357
|
- `createNotifyService` — canonical `notify.*` envelopes (`notify:send` / `notify:channel`).
|
|
358
|
-
- `createNotificationService` — legacy
|
|
358
|
+
- `createNotificationService` — legacy inc-emit `notifications:*` channel; coexists with `createNotifyService` until retired.
|
|
359
359
|
|
|
360
360
|
### Relay NAP
|
|
361
361
|
- `createRelayPoolService` — `relay.publish`, `relay.publishEncrypted`, `relay.subscribe` fan-out (`relay:read` / `relay:write`).
|
|
@@ -371,8 +371,8 @@ Each factory returns a `ServiceHandler` registrable via `runtime.registerService
|
|
|
371
371
|
### Theme NAP
|
|
372
372
|
- `createThemeService` — `theme.get` + `theme.changed` fan-out (`theme:read`). Returns a `ThemeService` with `publishTheme()` / `setTheme()` utilities for host-side updates.
|
|
373
373
|
|
|
374
|
-
### Audio (legacy
|
|
375
|
-
- `createAudioService` — `audio:*`
|
|
374
|
+
### Audio (legacy inc-emit)
|
|
375
|
+
- `createAudioService` — `audio:*` inc-emit topic handler. Browser-agnostic registry of per-window audio sources; host wires `onChange` to update transport UI.
|
|
376
376
|
|
|
377
377
|
### Types
|
|
378
378
|
`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
|
@@ -5,7 +5,7 @@ export { MediaAction } from '@napplet/nap/media/types';
|
|
|
5
5
|
import { NotifySendMessage } from '@napplet/nap/notify/types';
|
|
6
6
|
import { Theme, ThemeChangedMessage } from '@napplet/nap/theme/types';
|
|
7
7
|
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-
|
|
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-DKIzbiDw.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @kehto/services — Shared types for reference service implementations.
|
|
@@ -171,7 +171,7 @@ declare function createAudioService(options?: AudioServiceOptions): ServiceHandl
|
|
|
171
171
|
declare function createNotificationService(options?: NotificationServiceOptions): ServiceHandler;
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* identity-service.ts — NIP-5D identity
|
|
174
|
+
* identity-service.ts — NIP-5D identity nap reference service.
|
|
175
175
|
*
|
|
176
176
|
* MIGRATION from signer-service (v1.1 -> v1.2):
|
|
177
177
|
* - signer.getPublicKey -> identity.getPublicKey (same shell state)
|
|
@@ -241,7 +241,7 @@ declare function createIdentityService(options: IdentityServiceOptions): Service
|
|
|
241
241
|
*
|
|
242
242
|
* Wraps an existing relay pool implementation (subscribe, publish,
|
|
243
243
|
* selectRelayTier, isAvailable) as a ServiceHandler that receives
|
|
244
|
-
* relay
|
|
244
|
+
* relay NAP envelope messages and manages subscription lifecycle.
|
|
245
245
|
*
|
|
246
246
|
* Handles: relay.subscribe, relay.close, relay.publish, relay.publishEncrypted.
|
|
247
247
|
*
|
|
@@ -470,7 +470,7 @@ interface CoordinatedRelayOptions {
|
|
|
470
470
|
declare function createCoordinatedRelay(options: CoordinatedRelayOptions): ServiceHandler;
|
|
471
471
|
|
|
472
472
|
/**
|
|
473
|
-
* keys-service.ts — NIP-5D keys
|
|
473
|
+
* keys-service.ts — NIP-5D keys NAP reference document-level listener implementation.
|
|
474
474
|
*
|
|
475
475
|
* Handles the 3 napplet -> shell request types from @napplet/nap/keys:
|
|
476
476
|
* - keys.forward -> invokes options.onForward (hotkey passthrough, fire-and-forget)
|
|
@@ -745,7 +745,7 @@ declare function createBrowserMediaBridge(opts?: {
|
|
|
745
745
|
}): HostMediaBridge;
|
|
746
746
|
|
|
747
747
|
/**
|
|
748
|
-
* media-service.ts — NIP-5D media
|
|
748
|
+
* media-service.ts — NIP-5D media NAP reference service (navigator.mediaSession
|
|
749
749
|
* reference implementation).
|
|
750
750
|
*
|
|
751
751
|
* Handles the napplet-owned subset of @napplet/nap/media:
|
|
@@ -777,7 +777,7 @@ declare function createBrowserMediaBridge(opts?: {
|
|
|
777
777
|
* up the active session's owning napplet, invokes the per-window send callback captured
|
|
778
778
|
* at session.create time, and delivers:
|
|
779
779
|
* { type: 'media.command', sessionId, action, value? }
|
|
780
|
-
* where action is the
|
|
780
|
+
* where action is the nap-media MediaAction literal (play|pause|next|prev|seek) and
|
|
781
781
|
* value is the seekTime (seconds) for seek.
|
|
782
782
|
*
|
|
783
783
|
* Silent-audio prime: the browser bridge creates a hidden <audio> element with a
|
|
@@ -793,10 +793,10 @@ declare function createBrowserMediaBridge(opts?: {
|
|
|
793
793
|
* destroyed, the next-most-recently-touched session is promoted automatically.
|
|
794
794
|
*
|
|
795
795
|
* Note: this is SEPARATE from packages/services/src/audio-service.ts, which
|
|
796
|
-
* is the legacy
|
|
797
|
-
* over
|
|
796
|
+
* is the legacy inc-topic-based audio source registry (audio:* topic events
|
|
797
|
+
* over inc.emit). media-service is the canonical @napplet/nap/media NIP-5D
|
|
798
798
|
* path and they coexist — audio-service continues to track audio sources for
|
|
799
|
-
* shell UI, while media-service handles the
|
|
799
|
+
* shell UI, while media-service handles the NAP protocol envelope surface.
|
|
800
800
|
*
|
|
801
801
|
* Shell -> Napplet push types (media.command) are emitted here when
|
|
802
802
|
* bridge.onAction callbacks fire — this is the canonical Phase 27 real backend.
|
|
@@ -872,7 +872,7 @@ interface HostMediaBridge {
|
|
|
872
872
|
/**
|
|
873
873
|
* Set the playback state for a session. Called on media.state reports
|
|
874
874
|
* whenever the session is the active session. State strings match
|
|
875
|
-
*
|
|
875
|
+
* nap-media MediaState.status exactly. Implementations MUST be idempotent.
|
|
876
876
|
*/
|
|
877
877
|
setPlaybackState(sessionId: string, state: 'playing' | 'paused' | 'stopped' | 'buffering'): void;
|
|
878
878
|
/**
|
|
@@ -960,13 +960,13 @@ interface MediaServiceOptions {
|
|
|
960
960
|
hostBridge?: HostMediaBridge;
|
|
961
961
|
}
|
|
962
962
|
/**
|
|
963
|
-
* Create a media
|
|
963
|
+
* Create a media NAP service handler with navigator.mediaSession integration.
|
|
964
964
|
*
|
|
965
965
|
* Implements the 5 napplet->shell media.* request types defined in
|
|
966
966
|
* `@napplet/nap/media`. Only `media.session.create` produces a reply
|
|
967
967
|
* envelope (`media.session.create.result`) — the remaining four
|
|
968
968
|
* (`session.update`, `session.destroy`, `state`, `capabilities`) are
|
|
969
|
-
* fire-and-forget per the
|
|
969
|
+
* fire-and-forget per the NAP spec.
|
|
970
970
|
*
|
|
971
971
|
* Unknown `media.*` actions produce a `<type>.error` envelope so
|
|
972
972
|
* napplets are never left hanging on a malformed request.
|
|
@@ -991,7 +991,7 @@ declare function createMediaService(options?: MediaServiceOptions): ServiceHandl
|
|
|
991
991
|
};
|
|
992
992
|
|
|
993
993
|
/**
|
|
994
|
-
* notify-service.ts — NIP-5D notify
|
|
994
|
+
* notify-service.ts — NIP-5D notify NAP reference service (stub-level).
|
|
995
995
|
*
|
|
996
996
|
* Handles the 5 napplet -> shell request types from `@napplet/nap/notify`:
|
|
997
997
|
* - `notify.send` -> `notify.send.result` (shell-assigned id)
|
|
@@ -1006,12 +1006,12 @@ declare function createMediaService(options?: MediaServiceOptions): ServiceHandl
|
|
|
1006
1006
|
*
|
|
1007
1007
|
* Coexistence note: this is SEPARATE from
|
|
1008
1008
|
* `packages/services/src/notification-service.ts`, which is the legacy
|
|
1009
|
-
*
|
|
1009
|
+
* inc-topic-based notification registry (operates on `inc.emit` topics
|
|
1010
1010
|
* under `notifications:*`). `notify-service.ts` is the canonical
|
|
1011
1011
|
* `@napplet/nap/notify` NIP-5D path and lives alongside the legacy module.
|
|
1012
1012
|
* If the host app registers this service via
|
|
1013
1013
|
* `runtime.registerService('notify', ...)`, @napplet/nap/notify messages
|
|
1014
|
-
* land here; the legacy
|
|
1014
|
+
* land here; the legacy inc-emit topic path remains untouched.
|
|
1015
1015
|
*
|
|
1016
1016
|
* Shell -> napplet push messages (`notify.action`, `notify.clicked`,
|
|
1017
1017
|
* `notify.dismissed`, `notify.controls`) are not emitted by this stub —
|
|
@@ -1074,7 +1074,7 @@ interface NotifyServiceOptions {
|
|
|
1074
1074
|
declare function createNotifyService(options?: NotifyServiceOptions): ServiceHandler;
|
|
1075
1075
|
|
|
1076
1076
|
/**
|
|
1077
|
-
* theme-service.ts — NIP-5D theme
|
|
1077
|
+
* theme-service.ts — NIP-5D theme NAP reference service.
|
|
1078
1078
|
*
|
|
1079
1079
|
* Handles the single napplet->shell request type from @napplet/nap/theme:
|
|
1080
1080
|
* - `theme.get` -> `theme.get.result { theme }` (current theme)
|
|
@@ -1156,7 +1156,7 @@ interface ThemeService {
|
|
|
1156
1156
|
getCurrentTheme: () => Theme;
|
|
1157
1157
|
}
|
|
1158
1158
|
/**
|
|
1159
|
-
* Create a theme service that handles the NIP-5D `theme.*`
|
|
1159
|
+
* Create a theme service that handles the NIP-5D `theme.*` NAP.
|
|
1160
1160
|
*
|
|
1161
1161
|
* Answers `theme.get` with the current theme (default or
|
|
1162
1162
|
* `options.initialTheme`). Exposes `publishTheme(theme)` for the host app to
|
|
@@ -1178,24 +1178,24 @@ interface ThemeService {
|
|
|
1178
1178
|
declare function createThemeService(options?: ThemeServiceOptions): ThemeService;
|
|
1179
1179
|
|
|
1180
1180
|
/**
|
|
1181
|
-
* config-service.ts —
|
|
1181
|
+
* config-service.ts — NAP-CONFIG reference service (9th NAP domain, v1.7 Phase 39).
|
|
1182
1182
|
*
|
|
1183
|
-
* Shell-side reference implementation for the canonical
|
|
1183
|
+
* Shell-side reference implementation for the canonical NAP-CONFIG wire
|
|
1184
1184
|
* protocol (`@napplet/nap/config`, published at `^0.3.0`). Handles the full
|
|
1185
1185
|
* 8-message discriminated union: 5 napplet→shell request types + 3
|
|
1186
1186
|
* shell→napplet result/push types.
|
|
1187
1187
|
*
|
|
1188
1188
|
* ──────────────────────────── SCOPE BOUNDARY (CONFIG-04) ─────────────────────────
|
|
1189
|
-
*
|
|
1189
|
+
* NAP-CONFIG is **shell-managed per-napplet configuration**. Napplets observe
|
|
1190
1190
|
* values via `config.get` (one-shot) or `config.subscribe` (snapshot + live
|
|
1191
1191
|
* push). The shell is the **sole writer** — there is intentionally **NO**
|
|
1192
1192
|
* `config.set` wire message. Napplets cannot mutate configuration values;
|
|
1193
1193
|
* the shell owns persistence and the update flow.
|
|
1194
1194
|
*
|
|
1195
|
-
* Do NOT use this service as a general key-value store.
|
|
1195
|
+
* Do NOT use this service as a general key-value store. NAP-STORAGE
|
|
1196
1196
|
* (`state:read` / `state:write`) remains the general KV surface. Using
|
|
1197
|
-
*
|
|
1198
|
-
* (H-07 in PITFALLS.md) — such state belongs in
|
|
1197
|
+
* NAP-CONFIG to store e.g. `{ lastScrollPosition: 420 }` is an anti-pattern
|
|
1198
|
+
* (H-07 in PITFALLS.md) — such state belongs in NAP-STORAGE.
|
|
1199
1199
|
* ──────────────────────────────────────────────────────────────────────────────────
|
|
1200
1200
|
*
|
|
1201
1201
|
* Host integration: provide `getValues()` returning the current
|
|
@@ -1284,7 +1284,7 @@ interface ConfigServiceOptions {
|
|
|
1284
1284
|
openSettings?: (windowId: string, section: string | undefined) => void;
|
|
1285
1285
|
}
|
|
1286
1286
|
/**
|
|
1287
|
-
*
|
|
1287
|
+
* NAP-CONFIG reference service bundle — `handler` to register with the
|
|
1288
1288
|
* runtime, `publishValues` for the host app to push updates live to all
|
|
1289
1289
|
* subscribed napplets.
|
|
1290
1290
|
*/
|
|
@@ -1302,7 +1302,7 @@ interface ConfigService {
|
|
|
1302
1302
|
publishValues(values: ConfigValues): void;
|
|
1303
1303
|
}
|
|
1304
1304
|
/**
|
|
1305
|
-
* Create a
|
|
1305
|
+
* Create a NAP-CONFIG reference service.
|
|
1306
1306
|
*
|
|
1307
1307
|
* Shell-writes, napplet-reads. Handles the full `@napplet/nap/config` wire
|
|
1308
1308
|
* protocol: `config.get` (correlated snapshot), `config.subscribe` /
|
|
@@ -1320,7 +1320,7 @@ interface ConfigService {
|
|
|
1320
1320
|
*
|
|
1321
1321
|
* @see ConfigServiceOptions for the options shape.
|
|
1322
1322
|
* @see packages/services/src/theme-service.ts for the sibling pattern.
|
|
1323
|
-
* @see SCOPE BOUNDARY comment at the top of this file re:
|
|
1323
|
+
* @see SCOPE BOUNDARY comment at the top of this file re: NAP-STORAGE separation.
|
|
1324
1324
|
*
|
|
1325
1325
|
* @example
|
|
1326
1326
|
* ```ts
|
|
@@ -1339,9 +1339,9 @@ interface ConfigService {
|
|
|
1339
1339
|
declare function createConfigService(options: ConfigServiceOptions): ConfigService;
|
|
1340
1340
|
|
|
1341
1341
|
/**
|
|
1342
|
-
* resource-service.ts —
|
|
1342
|
+
* resource-service.ts — NAP-RESOURCE reference service (10th NAP domain, v1.7 Phase 40).
|
|
1343
1343
|
*
|
|
1344
|
-
* Shell-side reference implementation for the canonical
|
|
1344
|
+
* Shell-side reference implementation for the canonical NAP-RESOURCE wire
|
|
1345
1345
|
* protocol (`internal-resource.ts` in @kehto/shell/src/types; kehto-internal
|
|
1346
1346
|
* model per PROJECT.md Decision #31 — diverges from upstream `@napplet/nap/
|
|
1347
1347
|
* resource` in field names + error vocabulary). Handles the canonical
|
|
@@ -1350,12 +1350,12 @@ declare function createConfigService(options: ConfigServiceOptions): ConfigServi
|
|
|
1350
1350
|
* Outbound: resource.bytes.result, resource.bytes.error
|
|
1351
1351
|
*
|
|
1352
1352
|
* ──────────────────────── SCOPE BOUNDARY (RESOURCE-01) ────────────────────────
|
|
1353
|
-
*
|
|
1353
|
+
* NAP-RESOURCE is an **authenticated fetch proxy** — read-only, atomic.
|
|
1354
1354
|
*
|
|
1355
1355
|
* This service is NOT responsible for:
|
|
1356
1356
|
* - Streaming / chunked responses (host-app concern)
|
|
1357
1357
|
* - Response caching / conditional requests (host-app concern)
|
|
1358
|
-
* - Upload / POST body construction (
|
|
1358
|
+
* - Upload / POST body construction (NAP-RESOURCE v1.7 is read-only)
|
|
1359
1359
|
* - Redirect limits, MIME sniffing, SVG rasterization (host-fetch concern)
|
|
1360
1360
|
* - Private-IP blocking, SSRF mitigation (host-provided-fetch responsibility)
|
|
1361
1361
|
*
|
|
@@ -1374,7 +1374,7 @@ declare function createConfigService(options: ConfigServiceOptions): ConfigServi
|
|
|
1374
1374
|
* const resourceSvc = createResourceService({
|
|
1375
1375
|
* fetch: (url, init) => globalThis.fetch(url, init),
|
|
1376
1376
|
* isOriginGranted: (origin, grants) => grants.includes(origin),
|
|
1377
|
-
* getConnectGrants: (dTag, hash) =>
|
|
1377
|
+
* getConnectGrants: (dTag, hash) => myOriginGrantStore.getOrigins(dTag, hash),
|
|
1378
1378
|
* resolveIdentity: (windowId) => sessionRegistry.getEntryByWindowId(windowId) ?? null,
|
|
1379
1379
|
* });
|
|
1380
1380
|
* runtime.registerService('resource', resourceSvc);
|
|
@@ -1423,8 +1423,8 @@ interface ResourceServiceOptions {
|
|
|
1423
1423
|
* Returns the list of allowed fetch origins for the given napplet identity.
|
|
1424
1424
|
* Called on every `resource.bytes` request — must be synchronous and fast.
|
|
1425
1425
|
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1426
|
+
* Host-supplied grant source (e.g. a static per-dTag allowlist map, or any
|
|
1427
|
+
* other host-controlled policy). Returns an empty array to deny all origins.
|
|
1428
1428
|
*
|
|
1429
1429
|
* H-03 prevention: REQUIRED from day one — factory throws on construction
|
|
1430
1430
|
* if omitted.
|
|
@@ -1452,7 +1452,7 @@ interface ResourceServiceOptions {
|
|
|
1452
1452
|
*/
|
|
1453
1453
|
type ResourceService = ServiceHandler;
|
|
1454
1454
|
/**
|
|
1455
|
-
* Create a
|
|
1455
|
+
* Create a NAP-RESOURCE reference service.
|
|
1456
1456
|
*
|
|
1457
1457
|
* Implements canonical 4-message protocol: `resource.bytes` (napplet → shell
|
|
1458
1458
|
* fetch request), `resource.cancel` (napplet → shell in-flight cancellation),
|
|
@@ -1477,7 +1477,7 @@ type ResourceService = ServiceHandler;
|
|
|
1477
1477
|
* const svc = createResourceService({
|
|
1478
1478
|
* fetch: (url, init) => globalThis.fetch(url, init),
|
|
1479
1479
|
* isOriginGranted: (origin, grants) => grants.includes(origin),
|
|
1480
|
-
* getConnectGrants: (dTag, hash) =>
|
|
1480
|
+
* getConnectGrants: (dTag, hash) => myOriginGrantStore.getOrigins(dTag, hash),
|
|
1481
1481
|
* resolveIdentity: (windowId) => sessionRegistry.getEntryByWindowId(windowId) ?? null,
|
|
1482
1482
|
* });
|
|
1483
1483
|
* runtime.registerService('resource', svc);
|
|
@@ -1690,7 +1690,7 @@ interface RelayListEntry {
|
|
|
1690
1690
|
/**
|
|
1691
1691
|
* Relay pool contract the router drives. Implementors adapt their pool library
|
|
1692
1692
|
* (nostr-tools SimplePool, applesauce-relay, etc.). Unlike the lower-level
|
|
1693
|
-
* relay
|
|
1693
|
+
* relay NAP pool, both methods take an explicit relay-URL set so the router
|
|
1694
1694
|
* controls outbox routing and can attribute events to the relay they arrived on.
|
|
1695
1695
|
*/
|
|
1696
1696
|
interface OutboxRelayPool {
|
|
@@ -1985,7 +1985,7 @@ declare function createHttpUploader(options: HttpUploaderOptions): Uploader;
|
|
|
1985
1985
|
* intent-types.ts — NAP-INTENT (archetype intent dispatch) value types.
|
|
1986
1986
|
*
|
|
1987
1987
|
* Kehto-internal model for the NAP-INTENT wire contract (upstream draft:
|
|
1988
|
-
* napplet/
|
|
1988
|
+
* napplet/naps NAP-INTENT, namespace `window.napplet.intent`). The installed
|
|
1989
1989
|
* `@napplet/core` peer predates these types, so — as with {@link ./cvm-types} —
|
|
1990
1990
|
* kehto defines them here, wire-compatible with the upstream shapes, rather
|
|
1991
1991
|
* than redefining the generic NIP-5D envelope.
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,12 @@ function createAudioService(options) {
|
|
|
14
14
|
return {
|
|
15
15
|
descriptor,
|
|
16
16
|
handleMessage(windowId, message, send) {
|
|
17
|
-
if (message.type !== "
|
|
18
|
-
const
|
|
19
|
-
const topic = typeof
|
|
17
|
+
if (message.type !== "inc.emit") return;
|
|
18
|
+
const incMessage = message;
|
|
19
|
+
const topic = typeof incMessage.topic === "string" ? incMessage.topic : void 0;
|
|
20
20
|
if (!topic?.startsWith("audio:")) return;
|
|
21
21
|
const action = topic.slice(6);
|
|
22
|
-
const payload =
|
|
22
|
+
const payload = incMessage.payload && typeof incMessage.payload === "object" ? incMessage.payload : {};
|
|
23
23
|
switch (action) {
|
|
24
24
|
case "register": {
|
|
25
25
|
const nappletClass = typeof payload.nappletClass === "string" ? payload.nappletClass : "";
|
|
@@ -51,7 +51,7 @@ function createAudioService(options) {
|
|
|
51
51
|
source.muted = muted;
|
|
52
52
|
notify2();
|
|
53
53
|
}
|
|
54
|
-
send({ type: "
|
|
54
|
+
send({ type: "inc.event", topic: "napplet:audio-muted", payload: { muted } });
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
57
|
default:
|
|
@@ -168,13 +168,13 @@ function handleNotifyEnvelope(store, windowId, action, msg, send) {
|
|
|
168
168
|
break;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function handleIncNotification(store, windowId, action, payload, send) {
|
|
172
172
|
switch (action) {
|
|
173
173
|
case "create": {
|
|
174
174
|
const title = typeof payload.title === "string" ? payload.title : "";
|
|
175
175
|
const body = typeof payload.body === "string" ? payload.body : "";
|
|
176
176
|
const notification = createNotification(store, windowId, title, body);
|
|
177
|
-
send({ type: "
|
|
177
|
+
send({ type: "inc.event", topic: "notifications:created", payload: { id: notification.id } });
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
case "dismiss": {
|
|
@@ -189,7 +189,7 @@ function handleIfcNotification(store, windowId, action, payload, send) {
|
|
|
189
189
|
}
|
|
190
190
|
case "list": {
|
|
191
191
|
const windowNotifs = store.notifications.get(windowId) ?? [];
|
|
192
|
-
send({ type: "
|
|
192
|
+
send({ type: "inc.event", topic: "notifications:listed", payload: { notifications: windowNotifs } });
|
|
193
193
|
break;
|
|
194
194
|
}
|
|
195
195
|
default:
|
|
@@ -215,11 +215,11 @@ function createNotificationService(options) {
|
|
|
215
215
|
handleNotifyEnvelope(store, windowId, message.type.slice(7), msg, send);
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
-
if (message.type !== "
|
|
218
|
+
if (message.type !== "inc.emit") return;
|
|
219
219
|
const topic = msg.topic;
|
|
220
220
|
if (!topic?.startsWith("notifications:")) return;
|
|
221
221
|
const payload = msg.payload ?? {};
|
|
222
|
-
|
|
222
|
+
handleIncNotification(store, windowId, topic.slice(14), payload, send);
|
|
223
223
|
},
|
|
224
224
|
onWindowDestroyed(windowId) {
|
|
225
225
|
if (store.notifications.delete(windowId)) {
|
|
@@ -236,7 +236,7 @@ function createIdentityService(options) {
|
|
|
236
236
|
descriptor: {
|
|
237
237
|
name: "identity",
|
|
238
238
|
version: IDENTITY_SERVICE_VERSION,
|
|
239
|
-
description: "NIP-5D identity
|
|
239
|
+
description: "NIP-5D identity NAP reference handler (9 read-only identity queries)"
|
|
240
240
|
},
|
|
241
241
|
handleMessage(_windowId, message, send) {
|
|
242
242
|
const id = message.id ?? "";
|
|
@@ -656,7 +656,7 @@ function createKeysService(options = {}) {
|
|
|
656
656
|
const descriptor = {
|
|
657
657
|
name: "keys",
|
|
658
658
|
version: KEYS_SERVICE_VERSION,
|
|
659
|
-
description: options.hostBridge ? "NIP-5D keys
|
|
659
|
+
description: options.hostBridge ? "NIP-5D keys NAP reference handler (host-bridge delegated)" : "NIP-5D keys NAP reference handler (document-level chord listener)"
|
|
660
660
|
};
|
|
661
661
|
function chordSpecKey(spec) {
|
|
662
662
|
return `${spec.ctrl}|${spec.alt}|${spec.shift}|${spec.meta}|${spec.key}`;
|
|
@@ -979,8 +979,8 @@ function createBrowserMediaBridge(opts = {}) {
|
|
|
979
979
|
}
|
|
980
980
|
function applyActionHandlers(actions = DEFAULT_MEDIA_ACTIONS) {
|
|
981
981
|
if (!ms) return;
|
|
982
|
-
for (const [domAction,
|
|
983
|
-
if (!actions.includes(
|
|
982
|
+
for (const [domAction, napAction] of ACTION_MATRIX) {
|
|
983
|
+
if (!actions.includes(napAction)) {
|
|
984
984
|
try {
|
|
985
985
|
ms.setActionHandler(domAction, null);
|
|
986
986
|
} catch {
|
|
@@ -989,9 +989,9 @@ function createBrowserMediaBridge(opts = {}) {
|
|
|
989
989
|
}
|
|
990
990
|
ms.setActionHandler(domAction, (details) => {
|
|
991
991
|
if (!activeSessionId) return;
|
|
992
|
-
const value =
|
|
992
|
+
const value = napAction === "seek" && typeof details?.seekTime === "number" ? details.seekTime : void 0;
|
|
993
993
|
for (const cb of actionCallbacks) {
|
|
994
|
-
cb(activeSessionId,
|
|
994
|
+
cb(activeSessionId, napAction, value);
|
|
995
995
|
}
|
|
996
996
|
});
|
|
997
997
|
}
|
|
@@ -1275,7 +1275,7 @@ function createMediaService(options = {}) {
|
|
|
1275
1275
|
const descriptor = {
|
|
1276
1276
|
name: "media",
|
|
1277
1277
|
version: MEDIA_SERVICE_VERSION,
|
|
1278
|
-
description: options.hostBridge ? "NIP-5D media
|
|
1278
|
+
description: options.hostBridge ? "NIP-5D media NAP reference handler (host-bridge delegated)" : "NIP-5D media NAP reference handler (navigator.mediaSession mirror)"
|
|
1279
1279
|
};
|
|
1280
1280
|
const bridge = options.hostBridge ?? createBrowserMediaBridge({
|
|
1281
1281
|
mediaSessionTarget: options.mediaSessionTarget,
|
|
@@ -1311,7 +1311,7 @@ function createNotifyService(options = {}) {
|
|
|
1311
1311
|
const descriptor = {
|
|
1312
1312
|
name: "notify",
|
|
1313
1313
|
version: NOTIFY_SERVICE_VERSION,
|
|
1314
|
-
description: "NIP-5D notify
|
|
1314
|
+
description: "NIP-5D notify NAP reference handler (stub)"
|
|
1315
1315
|
};
|
|
1316
1316
|
return {
|
|
1317
1317
|
descriptor,
|
|
@@ -1373,7 +1373,7 @@ function createThemeService(options = {}) {
|
|
|
1373
1373
|
const descriptor = {
|
|
1374
1374
|
name: "theme",
|
|
1375
1375
|
version: THEME_SERVICE_VERSION,
|
|
1376
|
-
description: "NIP-5D theme
|
|
1376
|
+
description: "NIP-5D theme NAP reference handler"
|
|
1377
1377
|
};
|
|
1378
1378
|
const handler = {
|
|
1379
1379
|
descriptor,
|
|
@@ -1475,7 +1475,7 @@ function createConfigService(options) {
|
|
|
1475
1475
|
const descriptor = {
|
|
1476
1476
|
name: "config",
|
|
1477
1477
|
version: CONFIG_SERVICE_VERSION,
|
|
1478
|
-
description: "
|
|
1478
|
+
description: "NAP-CONFIG reference service \u2014 shell-writes, napplet-reads configuration"
|
|
1479
1479
|
};
|
|
1480
1480
|
const handler = {
|
|
1481
1481
|
descriptor,
|
|
@@ -1672,7 +1672,7 @@ function createResourceService(options) {
|
|
|
1672
1672
|
const descriptor = {
|
|
1673
1673
|
name: "resource",
|
|
1674
1674
|
version: RESOURCE_SERVICE_VERSION,
|
|
1675
|
-
description: "
|
|
1675
|
+
description: "NAP-RESOURCE reference service \u2014 shell-proxied authenticated fetch (RESOURCE-01..06)"
|
|
1676
1676
|
};
|
|
1677
1677
|
const handler = {
|
|
1678
1678
|
descriptor,
|