The DidDhtDocument class provides functionality for interacting with the DID document stored in Mainline DHT in support of DID DHT method create, resolve, update, and deactivate operations.

This class includes methods for retrieving and publishing DID documents to and from the DHT, using DNS packet encoding and DID DHT Gateway or Pkarr Relay servers.

Constructors

Methods

  • Converts a DNS packet to a DID document according to the DID DHT specification.

    Parameters

    • params: {
          didUri: string;
          dnsPacket: Packet;
      }

      The parameters to use when converting a DNS packet to a DID document.

      • didUri: string

        The DID URI of the DID document.

      • dnsPacket: Packet

        The DNS packet to convert to a DID document.

    Returns Promise<DidResolutionResult>

    A Promise resolving to a DidResolutionResult object containing the DID document and its metadata.

  • Retrieves a DID document and its metadata from the DHT network.

    Parameters

    • params: {
          didUri: string;
          gatewayUri: string;
      }

      The parameters for the get operation.

      • didUri: string

        The DID URI containing the Identity Key.

      • gatewayUri: string

        The DID DHT Gateway or Pkarr Relay URI.

    Returns Promise<DidResolutionResult>

    A Promise resolving to a DidResolutionResult object containing the DID document and its metadata.

  • Gets the unique portion of the DID identifier after the last : character. e.g. did:dht:example -> example

    Parameters

    • did: string

      The DID to extract the unique suffix from.

    Returns string

  • Retrieves a signed BEP44 message from a DID DHT Gateway or Pkarr Relay server.

    Parameters

    • params: {
          gatewayUri: string;
          publicKeyBytes: Uint8Array;
      }
      • gatewayUri: string

        The DID DHT Gateway or Pkarr Relay URI.

      • publicKeyBytes: Uint8Array

        The public key bytes of the Identity Key, z-base-32 encoded.

    Returns Promise<Bep44Message>

    A promise resolving to a BEP44 message containing the signed DNS packet.

  • Publishes a signed BEP44 message to a DID DHT Gateway or Pkarr Relay server.

    Parameters

    • params: {
          bep44Message: Bep44Message;
          gatewayUri: string;
      }

      The parameters to use when publishing a signed BEP44 message to a Pkarr relay server.

      • bep44Message: Bep44Message

        The BEP44 message to be published, containing the signed DNS packet.

      • gatewayUri: string

        The DID DHT Gateway or Pkarr Relay URI.

    Returns Promise<boolean>

    A promise resolving to true if the message was successfully published, otherwise false.

  • Publishes a DID document to the DHT network.

    Parameters

    • params: {
          did: BearerDid;
          gatewayUri: string;
      }

      The parameters to use when publishing the DID document to the DHT network.

      • did: BearerDid

        The DID object whose DID document will be published.

      • gatewayUri: string

        The DID DHT Gateway or Pkarr Relay URI.

    Returns Promise<DidRegistrationResult>

    A promise that resolves to a DidRegistrationResult object that contains the result of registering the DID with a DID DHT Gateway or Pkarr relay.

  • Converts a DID document to a DNS packet according to the DID DHT specification.

    Parameters

    • params: {
          authoritativeGatewayUris?: string[];
          didDocument: DidDocument;
          didMetadata: DidMetadata;
          previousDidProof?: PreviousDidProof;
      }

      The parameters to use when converting a DID document to a DNS packet.

      • Optional authoritativeGatewayUris?: string[]

        The URIs of the Authoritative Gateways to generate NS records from.

      • didDocument: DidDocument

        The DID document to convert to a DNS packet.

      • didMetadata: DidMetadata

        The DID metadata to include in the DNS packet.

      • Optional previousDidProof?: PreviousDidProof

        The signature proof that this DID is linked to the given previous DID.

    Returns Promise<Packet>

    A promise that resolves to a DNS packet.