resolveDID API Reference

This document provides a concise API reference for the resolveDID function within the Hedera DID SDK for JavaScript.

Function Signature

function resolveDID(
  did: string,
  accept?: DIDResolutionAccept,
  options?: ResolveDIDOptions,
): Promise<DIDDocument | JsonLdDIDDocument | DIDResolution | Uint8Array>;

Parameters

The function accepts the following parameters:

  • did: (Required) The DID string of the Decentralized Identifier to resolve.

  • accept: (Optional) Specifies the desired format for the DID Document resolution.

  • options: (Optional) Specifies the options for the DID Document resolution.

did Parameter

Name Type Description

did

string

The DID string of the Decentralized Identifier to resolve.

accept Parameter

Name Type Description

accept?

Accept

Specifies the desired format for the DID Document resolution. See Accept type for allowed values.

options Parameter

It is an object that contains the following properties:

Name Type Description

options?

ResolveDIDOptions

Specifies the options for the DID Document resolution. See ResolveDIDOptions type for allowed values.

Data Types

Accept type

Name Type Description

Accept

string

A string literal representing the desired format for DID Document resolution. It must be one of the following:

* application/did+ld+json * application/did+json * application/ld+json;profile="https://w3id.org/did-resolution" * application/did+cbor

ResolveDIDOptions type

Name Type Description

verifier?

Verifier

Specifies the verifier to use for verifying the DID Document signature. See Verifier for more details.

topicReader?

TopicReader

Specifies the topic reader to use for reading messages from the Hedera network. Default is HederaClientTopicReader. See TopicReader for more details.

Return Value

Upon successful execution, the function returns a Promise that resolves to either a DIDDocument object or a DIDResolutionResponse object, depending on the value of the accept parameter.

Name Type Description

DID Document

DIDDocument

Returned if accept is application/did+json or application/did+json. Contains the resolved DID Document. See a full running example for JSON examples in the source code.

LD DID Document

JsonLdDIDDocument

Returned if accept is application/did+ld+json. Contains the resolved DID Document in JSON-LD format. See a full running example for JSON-LD examples in the source code.

DID Resolution Response

DIDResolutionResponse

Returned if accept is application/ld+json;profile="https://w3id.org/did-resolution". Contains the resolved DID Document and additional metadata. See a full running example in the source code.

CBOR Response

Uint8Array

Returned if accept is application/did+cbor. Contains the resolved DID Document in CBOR format. See a full running link: example in the source code.

Errors

The following exceptions may arise during the execution of the resolveDID function:

Exception code Description

invalidDid

Unsupported DID method or invalid DID.

notFound

The DID document was not found.

internalError

Cannot verify signature without a public key or a verifier.

internalError

No public key found in DIDOwner event.

representationNotSupported

Unsupported representation format.

Function Implementation

The Hashgraph DID SDK provides a resolveDID function within its resolver package. For further details, refer to the @hashgraph-did-sdk-js/resolver package documentation.