@nillion/secretvaults
    Preparing search index...

    Class SecretVaultUserClient

    Client for user operations on SecretVaults.

    This client handles user-specific operations for managing owned documents, including creation, retrieval, updates, and deletion. It supports automatic handling of concealed data when configured with blindfold.

    const client = await SecretVaultUserClient.from({
    keypair: myKeypair,
    baseUrls: [
    'https://nildb-stg-n1.nillion.network',
    'https://nildb-stg-n2.nillion.network',
    'https://nildb-stg-n3.nillion.network',
    ],
    blindfold: { // optional blindfold config }
    })

    Hierarchy

    • SecretVaultBaseClient<NilDbUserClient>
      • SecretVaultUserClient
    Index

    Constructors

    • Parameters

      • options: SecretVaultBaseOptions<NilDbUserClient>

      Returns SecretVaultUserClient

    Accessors

    • get nodes(): TClient[]

      The array of underlying node clients for the cluster.

      Returns TClient[]

    • get signer(): Signer

      The signer used by this client for signing.

      Returns Signer

    Methods

    • Creates one or more data documents owned by the user.

      Parameters

      • body: {
            acl: {
                execute: boolean;
                grantee: string;
                read: boolean;
                write: boolean;
            };
            collection: string;
            data: Record<string, unknown>[];
            owner: string;
        }
      • Optionaloptions: { auth?: AuthContext }

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

    • Deletes a user-owned document from all nodes.

      Parameters

      • params: { collection: string; document: string }
      • Optionaloptions: { auth?: AuthContext }

      Returns Promise<ByNodeName<string>>

    • The DID of the signer associated with this client.

      Returns Promise<Did$1>

    • Returns Promise<string>

    • Grants a given Did access to a given user-owned document.

      Parameters

      • body: {
            acl: {
                execute: boolean;
                grantee: string;
                read: boolean;
                write: boolean;
            };
            collection: string;
            document: string;
        }
      • Optionaloptions: { auth?: AuthContext }

      Returns Promise<ByNodeName<string>>

    • Lists references to all data documents owned by the user.

      Parameters

      • Optionaloptions: {
            auth?: AuthContext;
            pagination?: {
                limit: number;
                offset: number;
                sort?: Record<string, -1 | 1>;
            };
        }

      Returns Promise<
          {
              data: { builder: string; collection: string; document: string }[];
              pagination: {
                  limit: number;
                  offset: number;
                  sort?: Record<string, -1 | 1>;
                  total: number;
              };
          },
      >

    • 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 a single data document, automatically revealing concealed values if a key is configured.

      Parameters

      • params: { collection: string; document: string }
      • Optionaloptions: { auth?: AuthContext }

      Returns Promise<
          {
              data: {
                  _acl: {
                      execute: boolean;
                      grantee: string;
                      read: boolean;
                      write: boolean;
                  }[];
                  _created: string;
                  _id: string;
                  _owner: string;
                  _updated: string;
                  [key: string]: unknown;
              };
          },
      >

    • Reads the user's profile information from the cluster.

      Parameters

      • Optionaloptions: { auth?: AuthContext }

      Returns Promise<
          {
              data: {
                  _created: string;
                  _id: string;
                  _updated: string;
                  data: { collection: string; id: string }[];
                  logs: {
                      acl?: {
                          execute: boolean;
                          grantee: string;
                          read: boolean;
                          write: boolean;
                      };
                      collection: string;
                      op: string;
                      [key: string]: unknown;
                  }[];
              };
          },
      >

    • Revokes access for a given Did to the specified user-owned document.

      Parameters

      • body: { collection: string; document: string; grantee: string }
      • Optionaloptions: { auth?: AuthContext }

      Returns Promise<ByNodeName<string>>

    • Creates and initializes a new SecretVaultUserClient instance.

      Parameters

      • options: { baseUrls: string[]; blindfold?: BlindfoldFactoryConfig; signer: Signer }

      Returns Promise<SecretVaultUserClient>

      // Basic instantiation with an auto-generated key
      const userClient = await SecretVaultUserClient.from({
      signer: Signer.generate(),
      baseUrls: ["http://localhost:40081", "http://localhost:40082"],
      });
      // Advanced: Using a custom signer from a browser wallet
      import { Signer } from "@nillion/nuc";

      // Assumes window.ethereum is available from a browser wallet like MetaMask
      const customSigner = await Signer.fromEip1193Provider(window.ethereum);

      const clientWithSigner = await SecretVaultUserClient.from({
      signer: customSigner,
      baseUrls: ["http://localhost:40081", "http://localhost:40082"],
      });