The main Web5 API interface. It manages the creation of a DID if needed, the connection to the local DWN and all the web5 main foundational APIs such as VC, syncing, etc.

Constructors

Properties

agent: Web5Agent

A Web5Agent instance that handles DIDs, DWNs and VCs requests. The agent manages the user keys and identities, and is responsible to sign and verify messages.

did: DidApi

Exposed instance to the DID APIs, allow users to create and resolve DIDs

dwn: DwnApi

Exposed instance to the DWN APIs, allow users to read/write records

vc: VcApi

Exposed instance to the VC APIs, allow users to issue, present and verify VCs

Methods

  • Cleans up the DID, Keys and Identity. Primarily used by a failed WalletConnect import. Does not throw on error, but logs to console.

    Parameters

    • __namedParameters: {
          identity: BearerIdentity;
          userAgent: Web5UserAgent<LocalKeyManager>;
      }
      • identity: BearerIdentity
      • userAgent: Web5UserAgent<LocalKeyManager>

    Returns Promise<void>

  • Connects to a Web5Agent. Defaults to creating a local Web5UserAgent if one isn't provided.

    If walletConnectOptions are provided, a WalletConnect flow will be initiated to import a delegated DID from an external wallet. If there is a failure at any point during connecting and processing grants, all created DIDs and Identities as well as the provided grants will be cleaned up and an error thrown. This allows for subsequent Connect attempts to be made without any errors.

    Parameters

    Returns Promise<Web5ConnectResult>

    A promise that resolves to a Web5 instance and the connected DID.

  • A static method to process connected grants for a delegate DID.

    This will store the grants as the DWN owner to be used later when impersonating the connected DID.

    Parameters

    • __namedParameters: {
          agent: Web5Agent;
          delegateDid: string;
          grants: DataEncodedRecordsWriteMessage[];
      }
      • agent: Web5Agent
      • delegateDid: string
      • grants: DataEncodedRecordsWriteMessage[]

    Returns Promise<string[]>