Represents a Decentralized Identifier (DID) along with its DID document, key manager, metadata, and convenience functions.

Constructors

Properties

document: DidDocument

The DID document associated with this DID.

Key Management System (KMS) used to manage the DIDs keys and sign data.

Each DID method requires at least one key be present in the provided keyManager.

metadata: DidMetadata

Represents metadata about a DID resulting from create, update, or deactivate operations.

uri: string

A string representation of the DID.

A DID is a URI composed of three parts: the scheme did:, a method identifier, and a unique, method-specific identifier specified by the DID method.

Methods

  • Converts a BearerDid object to a portable format containing the URI and verification methods associated with the DID.

    This method is useful when you need to represent the key material and metadata associated with a DID in format that can be used independently of the specific DID method implementation. It extracts both public and private keys from the DID's key manager and organizes them into a PortableDid structure.

    Returns Promise<PortableDid>

    A PortableDid containing the URI, DID document, metadata, and optionally private keys associated with the BearerDid.

    Remarks

    If the DID's key manager does not allow private keys to be exported, the PortableDid returned will not contain a privateKeys property. This enables the importing and exporting DIDs that use the same underlying KMS even if the KMS does not support exporting private keys. Examples include hardware security modules (HSMs) and cloud-based KMS services like AWS KMS.

    If the DID's key manager does support exporting private keys, the resulting PortableDid will include a privateKeys property which contains the same number of entries as there are verification methods as the DID document, each with its associated private key and the purpose(s) for which the key can be used (e.g., authentication, assertionMethod, etc.).

    Example

    // Assuming `did` is an instance of BearerDid
    const portableDid = await did.export();
    // portableDid now contains the DID URI, document, metadata, and optionally, private keys.

    Throws

    An error if the DID document does not contain any verification methods or the keys for any verification method are missing in the key manager.

  • Return a Signer that can be used to sign messages, credentials, or arbitrary data.

    If given, the methodId parameter is used to select a key from the verification methods present in the DID Document.

    If methodID is not given, the first verification method intended for signing claims is used.

    Parameters

    • Optional params: {
          methodId: string;
      }

      The parameters for the getSigner operation.

      • methodId: string

        ID of the verification method key that will be used for sign and verify operations. Optional.

    Returns Promise<BearerDidSigner>

    An instantiated Signer that can be used to sign and verify data.