Skip to content

@kehto/services

Reference service handlers for Kehto runtime implementations.

Alpha status: Kehto is an early runtime implementation for a draft NIP-5D protocol. Service envelopes and NAP contracts are not final.

Install

bash
pnpm add @kehto/services @kehto/runtime @napplet/core @napplet/nap

Manifest Facts

FieldValue
Sourcepackages/services/package.json, packages/services/src/index.ts
Version0.20.0
Runtime entry./dist/index.js
Types entry./dist/index.d.ts
Dependencies@kehto/runtime
Side effectsfalse

Peer Dependencies

PackageRange
@napplet/core>=0.31.0 <0.32.0
@napplet/nap>=0.31.0 <0.32.0

Primary APIs

AreaExports
Direct-domain notificationscreateNotifyService, NotifyServiceOptions
IdentitycreateIdentityService, IdentityServiceOptions
Relay/cache/countcreateRelayPoolService, RelayPoolServiceOptions, createCacheService, CacheServiceOptions, HostCacheBridge, createCoordinatedRelay, CoordinatedRelayOptions, createCountService, CountServiceOptions, CountRequest, CountResult
KeyscreateKeysService, KeysServiceOptions, HostKeysBridge, HostKeyEvent
MediacreateMediaService, createBrowserMediaBridge, MediaServiceOptions, HostMediaBridge, MediaAction
Notify/theme/config/resourcecreateNotifyService, NotifyServiceOptions, createThemeService, ThemeServiceOptions, ThemeService, createConfigService, ConfigServiceOptions, ConfigService, ConfigSchemaValidation, createResourceService, ResourceServiceOptions, ResourceService
OutboxcreateOutboxService, createRelayPoolOutboxRouter, OutboxRouter, StreamingOutboxRouter, OutboxQueryStream, OutboxQueryStreamSink
Shell-mediated helperscreateLinkService, LinkServiceOptions, LinkOpenContext, createCommonService, CommonServiceOptions, CommonServiceContext, createListsService, ListsServiceOptions, ListsServiceContext, createSerialService, SerialServiceOptions, SerialServiceContext, createBleService, BleServiceOptions, BleServiceContext, createWebrtcService, WebrtcServiceOptions, WebrtcServiceContext
DMcreateDmService, createNip17DmAdapter, createNdrDmAdapter, createNdrRelayTransport, createCordnDmAdapter, createCordnRelayCoordinatorClient, DmServiceOptions, DmAdapter, DmRelayPool, Nip17DmAdapterOptions, NdrDmAdapterOptions, NdrRelayTransportOptions, CordnDmAdapterOptions, CordnRelayCoordinatorOptions
FScreateFsService, FsServiceError, FsServiceOptions, FsBackend, FsBackendWatch, FsBackendChange

Scope Boundaries

  • Provides reference service handlers that host apps register with runtime.registerService().
  • The runtime selects a handler by the exact message.type domain (for example, notify.create selects notify). INC topics are opaque, queryless identities matched only by exact equality; they never select a service handler. The runtime attaches the sender to delivered INC events from the authenticated endpoint, so a service must not fabricate an INC delivery.
  • Host apps provide backing bridges/callbacks for browser, native, signer, relay, fetch, notification, and media behavior.
  • Relay services receive runtime-signed events and always settle publish calls with the NAP-RELAY result shape: { ok: true, event, eventId } on success or { ok: false, error } on failure. Relay subscribe adapters can provide observed source URLs as a second callback argument; those become event sidecar hints instead of treating every requested relay as an observed source.
  • createCountService() implements the NAP-COUNT count.query service shape. Backends count NIP-01 filter matches through relay COUNT support, local indexes, or caches and may return exact counts, approximate/HLL metadata, relays, or refusal errors such as unsupported-filter and too-expensive; they must not return matching events.
  • BLE and WebRTC hook contexts expose emit(...) so host bridges can send runtime-owned event envelopes back to the requesting napplet.
  • NAP-DM support keeps request correlation, per-window subscriptions, and packaged message shapes in createDmService; the concrete NIP-17 adapter verifies gift wraps and hydrates encrypted relay history, while NDR and Cordn specifics remain behind structural adapters.
  • NAP-FS support keeps same-id results and per-window watch ownership in createFsService; injected backends own real persistence, virtual-path policy, picker mediation, byte validation, revisions, mutation atomicity, and watch observation.
  • createRelayPoolOutboxRouter() starts validated relay hints or fallback reads before asynchronous NIP-65 discovery settles. Its host-side queryStream() emits verified results incrementally and exposes the existing aggregate through result; the draft NAP-OUTBOX wire query remains one-shot.
  • Does not create a runtime or shell bridge by itself.

API Reference