Documentation
    Preparing search index...

    Interface ServiceHandler

    Handler for service-specific messages from napplets. Services receive NIP-5D NappletMessage envelopes and respond via the send callback. The same interface is used for all services regardless of what NAP domain they handle.

    const audioHandler: ServiceHandler = {
    descriptor: { name: 'audio', version: '1.0.0' },
    handleMessage(windowId, message, send) {
    if (message.type === 'inc.emit') {
    // process audio inc event...
    send({ type: 'inc.emit.result', id: (message as any).id });
    }
    },
    };
    interface ServiceHandler {
        descriptor: ServiceDescriptor;
        handleMessage(
            windowId: string,
            message: NappletMessage,
            send: (msg: NappletMessage) => void,
        ): void;
        onWindowDestroyed?(windowId: string): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    descriptor: ServiceDescriptor

    Metadata describing this service.

    Methods

    • Handle a NIP-5D envelope from a napplet.

      Parameters

      • windowId: string

        The requesting napplet's window identifier

      • message: NappletMessage

        NappletMessage JSON envelope (e.g., { type: 'signer.signEvent', id, event })

      • send: (msg: NappletMessage) => void

        Callback to send NappletMessage responses back to the napplet

      Returns void

    • Called when a napplet window is destroyed. Services should clean up any state associated with the window.

      Parameters

      • windowId: string

        The destroyed napplet's window identifier

      Returns void