kernl API
    Preparing search index...

    Interface KernelContext

    What the kernel hands a module at setup. Everything is the shell's own: one store, one pool, the relay tiers, the host's storage. A module signs an applet's write through KernelContext.sign, which puts one that replaces or erases the person's record to them first, and the host's own writes with KernelContext.signer (D-065). It never holds kehto's bridge (D-061). Accessors are read when called, so a module may keep them for later.

    interface KernelContext {
        eventStore: EventStore;
        host: Pick<
            KernlHost,
            "storage"
            | "openApplet"
            | "focusApplet"
            | "notify"
            | "now"
            | "openLink",
        >;
        identity: ModuleIdentity;
        pool: RelayPool;
        replaceableLoader: AddressPointerLoader;
        secrets: SecretsProvider;
        storage: StorageLike;
        tiers: RelayTiers;
        appletOf(windowId: string): AppletSummary | undefined;
        applets(): ReadonlyMap<
            string,
            { summary: AppletSummary; windowId: string },
        >;
        ask<K extends keyof AskKinds>(ask: Ask<K>): Promise<AskAnswer<K>>;
        canAsk(kind: keyof AskKinds): boolean;
        find<T>(id: string): T | undefined;
        holds(windowId: string, domain: string): boolean;
        isFocused(windowId: string): boolean;
        loadReplaceable(pointer: ReplaceablePointer): Promise<void>;
        sign(windowId: string, template: EventTemplate): Promise<NostrEvent>;
        signer(): ISigner | undefined;
        use<T>(id: string): T;
    }
    Index
    eventStore: EventStore
    host: Pick<
        KernlHost,
        "storage"
        | "openApplet"
        | "focusApplet"
        | "notify"
        | "now"
        | "openLink",
    >

    The host's effects a module may use. Questions go through KernelContext.ask.

    identity: ModuleIdentity
    pool: RelayPool
    replaceableLoader: AddressPointerLoader

    The shell's replaceable loader, which asks the cache module first when it is loaded.

    Where passwords and keys of services the shell signs in to for the person are kept (D-052).

    storage: StorageLike

    The host's storage. A module keeps its own keys under kernl:<module id>:.

    tiers: RelayTiers
    • The verified applet a window runs, or undefined.

      Parameters

      • windowId: string

      Returns AppletSummary | undefined

    • The applets running now, by window id.

      Returns ReadonlyMap<string, { summary: AppletSummary; windowId: string }>

    • Put a question to the person through the host's renderer for its kind, and resolve with their answer: the kind's refusal when nothing draws it, the renderer fails, or the asking window has closed. Rejects invalid:ask-undeclared:<kind> for a kind the module did not declare in KernlModule.asks (D-067).

      Type Parameters

      Parameters

      Returns Promise<AskAnswer<K>>

    • Whether the host draws a kind, for a module that offers something only when it can be asked about.

      Parameters

      Returns boolean

    • Another module's api, or undefined when nothing by that id is loaded. Read when called.

      Type Parameters

      • T

      Parameters

      • id: string

      Returns T | undefined

    • Whether a window's applet holds a domain the person granted, and is not blocked. Read-only: only the person grants.

      Parameters

      • windowId: string
      • domain: string

      Returns boolean

    • Whether a window is the focused one, as the guard sees it.

      Parameters

      • windowId: string

      Returns boolean

    • Load a replaceable event into the store from the cache and the lookup relays. Never rejects.

      Parameters

      Returns Promise<void>

    • Sign a template for a window, after the person's consent when it replaces or erases their record. Rejects with denied:read-only when the identity cannot sign, before anyone is asked. A write an applet asked for goes through this, never through KernelContext.signer.

      Parameters

      • windowId: string
      • template: EventTemplate

      Returns Promise<NostrEvent>

    • The active identity's signer, or none for a read-only or signed-out session, for a write the host started for the person, such as saving their relay list from settings (D-065). The key stays inside the signer.

      Returns ISigner | undefined

    • Another module's api, such as use<Profiles>('profiles'). Throws invalid:module-missing:<id> when nothing by that id is loaded.

      Type Parameters

      • T

      Parameters

      • id: string

      Returns T