Documentation
    Preparing search index...

    Interface ServiceRuntimeContext

    Narrow runtime-owned access granted to a registered service.

    The context exposes current immutable identity values and policy-aware target delivery without exposing the mutable session registry, ACL state, adapter hooks, or raw transport.

    interface ServiceRuntimeContext {
        maxPermissionRequirements?: number;
        authorizeOperation?<T>(
            windowId: string,
            operation: string,
            requirements: readonly PermissionRequirement[],
            execute: (signal: ApprovalSignal) => T | Promise<T>,
            signal?: ApprovalSignal,
        ): Promise<ApprovalOutcome<T>>;
        hasCapability(
            windowId: string,
            capability:
                | "relay:read"
                | "relay:write"
                | "cache:read"
                | "cache:write"
                | "hotkey:forward"
                | "state:read"
                | "state:write"
                | "identity:read"
                | "keys:bind"
                | "keys:forward"
                | "media:control"
                | "notify:send"
                | "notify:channel"
                | "theme:read"
                | "config:read"
                | "resource:fetch"
                | "cvm:call"
                | "outbox:read"
                | "outbox:write"
                | "upload:write"
                | "intent:read"
                | "intent:write"
                | "dm:read"
                | "dm:write"
                | "fs:read"
                | "fs:write"
                | "llm:generate",
        ): boolean;
        listWindowIds(): readonly string[];
        resolveDTag(windowId: string): string | undefined;
        sendToEligibleNapplet(windowId: string, message: NappletMessage): boolean;
    }
    Index

    Properties

    maxPermissionRequirements?: number

    Most requirements one authorizeOperation request may carry, from the host's PermissionAdapter.maxRequirements. Present with authorizeOperation; services size their plans to it (kehto/web#514).

    Methods

    • Execute a validated operation under composed interface/resource/network grants. The callback must capture immutable payloads and observe cancellation before any later asynchronous side effect. Absent on hosts awaiting migration. An optional request signal cancels this operation's prompt, queue wait, and active callback without cancelling siblings. A late answer cannot grant access.

      Type Parameters

      • T

      Parameters

      Returns Promise<ApprovalOutcome<T>>

    • Check a capability against the current source-bound ACL grant.

      Parameters

      • windowId: string

        Requesting live window.

      • capability:
            | "relay:read"
            | "relay:write"
            | "cache:read"
            | "cache:write"
            | "hotkey:forward"
            | "state:read"
            | "state:write"
            | "identity:read"
            | "keys:bind"
            | "keys:forward"
            | "media:control"
            | "notify:send"
            | "notify:channel"
            | "theme:read"
            | "config:read"
            | "resource:fetch"
            | "cvm:call"
            | "outbox:read"
            | "outbox:write"
            | "upload:write"
            | "intent:read"
            | "intent:write"
            | "dm:read"
            | "dm:write"
            | "fs:read"
            | "fs:write"
            | "llm:generate"

        Capability to check for that source.

      Returns boolean

      true when the live source currently holds the grant.

    • List current registered window identifiers.

      Returns readonly string[]

      A fresh frozen snapshot of live window identifiers.

    • Resolve a currently registered window to its authenticated napplet dTag.

      Parameters

      • windowId: string

        Internal live window identifier.

      Returns string | undefined

      The authenticated dTag, or undefined when no live session exists.

    • Send a runtime-originated message after current recipient policy checks.

      The target must be a live source-bound session whose immutable environment exposes the domain. Mapped recipient capabilities also require their current ACL grant. GAMEPAD state has no invented recipient capability mapping.

      Parameters

      • windowId: string

        Intended live recipient window.

      • message: NappletMessage

        Runtime-originated NIP-5D envelope.

      Returns boolean

      true only when the message was delivered to the adapter.