@nillion/secretvaults
    Preparing search index...

    Class SecretVaultBuilderClient

    Client for performing builder operations on SecretVaults.

    This client handles all builder-specific operations including registration, collection management, data operations, and query execution. It supports automatic handling of concealed data when configured with blindfold.

    const client = await SecretVaultBuilderClient.from({
    keypair: myKeypair,
    urls: {
    chain: "http://rpc.testnet.nilchain-rpc-proxy.nilogy.xyz",
    auth: "https://nilauth.sandbox.app-cluster.sandbox.nilogy.xyz",
    dbs: ["https://nildb-stg-n1.nillion.network", "https://nildb-stg-n2.nillion.network", "https://nildb-stg-n3.nillion.network"]
    }
    });

    Hierarchy

    • SecretVaultBaseClient<NilDbBuilderClient>
      • SecretVaultBuilderClient
    Index

    Constructors

    Accessors

    • get did(): Did

      The DID of the keypair associated with this client.

      Returns Did

    • get id(): string

      Returns string

    • get keypair(): Keypair

      The keypair used by this client for signing.

      Returns Keypair

    • get nodes(): TClient[]

      The array of underlying node clients for the cluster.

      Returns TClient[]

    Methods

    • Creates a new collection on all nodes.

      Parameters

      • body: {
            _id: string;
            name: string;
            schema: Record<string, unknown>;
            type: "standard" | "owned";
        }

      Returns Promise<ByNodeName<string>>

    • Creates a new index on a collection.

      Parameters

      • collection: string & $brand<"Uuid">
      • body: {
            collection: string;
            keys: Record<string, -1 | 1>[];
            name: string;
            ttl?: number;
            unique: boolean;
        }

      Returns Promise<ByNodeName<string>>

    • Creates a new saved query on all nodes.

      Parameters

      • body: {
            _id: string;
            collection: string;
            name: string;
            pipeline: Record<string, unknown>[];
            variables: Record<string, { description?: string; path: string }>;
        }

      Returns Promise<ByNodeName<string>>

    • Creates one or more standard data documents in a collection.

      Parameters

      • options: {
            body: { collection: string; data: Record<string, unknown>[] };
            delegation?: string;
        }

      Returns Promise<
          ByNodeName<
              {
                  data: {
                      created: string[];
                      errors: { document: unknown; error: string }[];
                  };
              },
          >,
      >

    • Deletes a collection its data from all nodes.

      Parameters

      • collection: string & $brand<"Uuid">

      Returns Promise<ByNodeName<string>>

    • Deletes data from a collection based on a filter.

      Parameters

      • body: { collection: string; filter: Record<string, unknown> }

      Returns Promise<ByNodeName<{ data: { acknowledged: boolean; deletedCount: number } }>>

    • Deletes a saved query from all nodes.

      Parameters

      • query: string & $brand<"Uuid">

      Returns Promise<ByNodeName<string>>

    • Drops an index from a collection.

      Parameters

      • collection: string & $brand<"Uuid">
      • index: string

      Returns Promise<ByNodeName<string>>

    • Finds data in a collection, revealing concealed values if a key is configured.

      Parameters

      • body: { collection: string; filter: Record<string, unknown> }

      Returns Promise<{ data: Record<string, unknown>[] }>

    • Deletes all data from a collection.

      Parameters

      • collection: string & $brand<"Uuid">

      Returns Promise<ByNodeName<string>>

    • Retrieves a list of all saved queries.

      Returns Promise<
          ByNodeName<
              {
                  data: {
                      _created: string;
                      _id: string;
                      _updated: string;
                      collection: string;
                      name: string;
                      owner: string & $brand<"Did">;
                      pipeline: Record<string, unknown>[];
                      variables: Record<string, { description?: string; path: string }>;
                  }[];
              },
          >,
      >

    • Retrieves a single saved query by its id.

      Parameters

      • query: string & $brand<"Uuid">

      Returns Promise<
          ByNodeName<
              {
                  data: {
                      _created: string;
                      _id: string;
                      _updated: string;
                      collection: string;
                      name: string;
                      owner: string & $brand<"Did">;
                      pipeline: Record<string, unknown>[];
                      variables: Record<string, { description?: string; path: string }>;
                  };
              },
          >,
      >

    • Retrieves information about each node in the cluster.

      Returns Promise<
          ByNodeName<
              {
                  build: { commit: string; time: string; version: string };
                  maintenance: { active: boolean; started_at: string };
                  public_key: string;
                  started: string;
                  url: string;
              },
          >,
      >

    • Reads the metadata for a single collection.

      Parameters

      • collection: string & $brand<"Uuid">

      Returns Promise<
          {
              data: {
                  _id: string;
                  count: number;
                  first_write: string;
                  indexes: {
                      key: Record<string, string | number>;
                      name: string;
                      unique: boolean;
                      v: number;
                  }[];
                  last_write: string;
                  schema: Record<string, unknown>;
                  size: number;
              };
          },
      >

    • Reads a list of all collections from the cluster.

      Returns Promise<{ data: { id: string; name: string; type: "standard" | "owned" }[] }>

    • Reads the builder's profile from the cluster.

      Returns Promise<
          {
              data: {
                  _created: string;
                  _id: string & $brand<"Did">;
                  _updated: string;
                  collections: string[];
                  name: string;
                  queries: string[];
              };
          },
      >

    • Reads the results of a completed query run from each node.

      Parameters

      Returns Promise<
          ByNodeName<
              {
                  data: {
                      _id: string;
                      completed?: string;
                      errors?: string[];
                      query: string;
                      result?: unknown;
                      started?: string;
                      status: "error"
                      | "pending"
                      | "running"
                      | "complete";
                  };
              },
          >,
      >

    • Fetches a new root NUC token from the configured nilAuth server.

      Returns Promise<void>

    • Registers the builder with all nodes in the cluster.

      Parameters

      • body: { did: string & $brand<"Did">; name: string }

      Returns Promise<ByNodeName<string>>

    • Starts a query execution job.

      Parameters

      • body: { _id: string; variables: Record<string, unknown> }

      Returns Promise<ByNodeName<{ data: string }>>

    • Checks subscription status by the builder's Did.

      Returns Promise<{}>

    • Reads the last N documents from a collection, revealing concealed values if a key is configured.

      Parameters

      • collection: string & $brand<"Uuid">
      • limit: number = 10

      Returns Promise<{ data: Record<string, unknown>[] }>

    • Updates the builder's profile on all nodes.

      Parameters

      • body: { name: string }

      Returns Promise<ByNodeName<string>>

    • Updates documents in a collection, concealing the update payload if a key is configured.

      Parameters

      • body: {
            collection: string;
            filter: Record<string, unknown>;
            update: Record<string, unknown>;
        }

      Returns Promise<
          ByNodeName<
              {
                  data: {
                      acknowledged: boolean;
                      matched: number;
                      modified: number;
                      upserted: number;
                      upserted_id: null
                      | string;
                  };
              },
          >,
      >

    • Creates and initializes a new SecretVaultBuilderClient instance.

      Parameters

      • options: {
            blindfold?: BlindfoldFactoryConfig;
            keypair: Keypair;
            urls: { auth: string; chain: string; dbs: string[] };
        }

        Configuration options for the client

        • Optionalblindfold?: BlindfoldFactoryConfig

          Optional blindfold configuration for concealed data

        • keypair: Keypair

          The builder's keypair for authentication

        • urls: { auth: string; chain: string; dbs: string[] }

          Nillion service URLs configuration from https://docs.nillion.com/build/network-config

          • auth: string

            URL of the nilAuth authentication service

          • chain: string

            URL of the nilChain URL

          • dbs: string[]

            URL Array of nilDB node endpoints

      Returns Promise<SecretVaultBuilderClient>

      A promise that resolves to a configured SecretVaultBuilderClient

      const client = await SecretVaultBuilderClient.from({
      keypair: myKeypair,
      urls: {
      chain: "http://rpc.testnet.nilchain-rpc-proxy.nilogy.xyz",
      auth: "https://nilauth.sandbox.app-cluster.sandbox.nilogy.xyz",
      dbs: ["https://nildb-stg-n1.nillion.network", "https://nildb-stg-n2.nillion.network", "https://nildb-stg-n3.nillion.network"]
      },
      blindfold: {
      // optional blindfold config
      }
      });