Documentation
    Preparing search index...

    Interface Runtime

    The napplet protocol engine — handles NIP-5D NAP domain dispatch, ACL enforcement, subscription lifecycle.

    import { createRuntime } from '@kehto/runtime';

    const runtime = createRuntime(hooks);
    runtime.handleMessage('window-1', { type: 'relay.req', id: 'sub1', filters: [{ kinds: [1] }] });
    interface Runtime {
        aclState: AclStateContainer;
        firewallState: FirewallStateContainer;
        manifestCache: ManifestCache;
        sessionRegistry: SessionRegistry;
        destroy(): void;
        destroyWindow(windowId: string): void;
        handleMessage(windowId: string, msg: unknown): void;
        injectEvent(topic: string, payload: unknown): void;
        registerConsentHandler(handler: ConsentHandler): void;
        registerService(name: string, handler: ServiceHandler): void;
        unregisterService(name: string): void;
    }
    Index

    Properties

    Access the ACL state container.

    firewallState: FirewallStateContainer

    Access the firewall state container (for tests to pre-set policy/rules).

    manifestCache: ManifestCache

    Access the manifest cache.

    sessionRegistry: SessionRegistry

    Access the identity registry (for shell adapter to read napplet session state).

    Methods

    • Clean up all state associated with a napplet window. Removes subscriptions, pending state, and notifies service handlers.

      Parameters

      • windowId: string

        The window to clean up

      Returns void

    • Handle an incoming NIP-5D NappletMessage envelope from a napplet. The caller is responsible for identifying the source (windowId). Legacy NIP-01 arrays are silently dropped (clean break — no dual-mode).

      Parameters

      • windowId: string

        The identifier of the napplet that sent the message

      • msg: unknown

        The raw message (NappletMessage envelopes are processed; other types dropped)

      Returns void

    • Inject a shell-originated event into subscription delivery.

      Parameters

      • topic: string

        The event topic tag value

      • payload: unknown

        The event content

      Returns void

    • Register a service handler dynamically after runtime creation. If a handler is already registered for this name, it is replaced.

      Parameters

      • name: string

        Service name (e.g., 'audio', 'notifications')

      • handler: ServiceHandler

        The service handler implementation

      Returns void

    • Unregister a service handler by name. No-op if the name is not registered.

      Parameters

      • name: string

        Service name to remove

      Returns void