rednode API - v0.50.0
    Preparing search index...

    Variable secretsConst

    secrets: {
        askShared(
            service: string,
            options?: AskSharedOptions,
        ): Promise<string | null>;
        delete(name: string): Promise<void>;
        get(name: string): Promise<string | null>;
        set(name: string, value: string): Promise<void>;
        shared(service: string): Promise<string | null>;
    } = ...

    Secrets of this package, such as an API key. They are encrypted with the player's Windows account and kept by the REDnode host; a package can read only its own. They never go into the package's folder.

    The player's AI service keys (Anthropic, Google Gemini, OpenAI, ElevenLabs and any other), typed once and shared by every EDGE tool on the PC, are read with secrets.shared and asked for with secrets.askShared: list "keys:<service>" in the manifest's permissions (from REDnode 0.48.0).

    Type Declaration

    • askShared: function
      • One of the player's shared keys, asked for when needed. When the package is allowed and the key is set, it answers at once. Otherwise REDnode's own Key request window asks the player to allow the package and, when no key is saved, to paste one; the package never sees that box. Resolves with the key, or null when the player denies, does not answer within 10 minutes, or the package stops. One window per package and service at a time.

        Parameters

        Returns Promise<string | null>

        // rednode-app.json: "permissions": ["keys:anthropic"]
        import { secrets } from "rednode";

        let key = await secrets.shared("anthropic");
        if (!key) {
        // A key this package kept itself before is offered to the shared store.
        const mine = await secrets.get("anthropic-api-key");
        key = await secrets.askShared("anthropic", { reason: "To answer your questions", offer: mine ?? undefined });
        if (key && mine) await secrets.delete("anthropic-api-key");
        }
    • delete: function
      • Deletes the secret.

        Parameters

        • name: string

        Returns Promise<void>

    • get: function
      • The secret, or null when it is not set.

        Parameters

        • name: string

        Returns Promise<string | null>

    • set: function
      • Sets the secret.

        Parameters

        • name: string
        • value: string

        Returns Promise<void>

    • shared: function
      • One of the player's shared keys, such as "anthropic": the key, or null until the player allows this package to use it, or while none is set. Never asks: use secrets.askShared for that. The manifest must list "keys:<service>".

        Parameters

        • service: string

        Returns Promise<string | null>

        // rednode-app.json: "permissions": ["keys:gemini"]
        const key = await secrets.shared("gemini");
        if (!key) console.log("No Gemini key yet");
    import { secrets } from "rednode";

    await secrets.set("api-key", key);
    const key = await secrets.get("api-key"); // null when not set