dereferenceDID API Reference

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

Function Signature

function dereferenceDID(
  didUrl: string,
  accept?: DIDResolutionAccept,
  options?: DereferenceDIDOptions,
): Promise<
  | Service
  | VerificationMethod
  | ServiceEndpoint
  | JsonLdVerificationMethod
  | JsonLdService
  | DIDDereferenceResolution
  | Uint8Array
>;

Parameters

The function accepts the following parameters:

  • didUrl: (Required) The DID URL to dereference.

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

  • options: (Optional) The options to use when dereferencing the DID URL.

didUrl Parameter

Name Type Description

didUrl

string

The DID URL string of the Decentralized Identifier to dereference.

accept Parameter

Name Type Description

accept?

Accept

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

options Parameter

Name Type Description

options?

DereferenceDIDOptions

The options to use when dereferencing the DID URL. See DereferenceDIDOptions type for more details.

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

DereferenceDIDOptions 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.

versionId?

string

Optional resolver option. Resolve dereference against a specific topic sequence number.

versionTime?

string

Optional resolver option. Resolve dereference against a specific ISO 8601 timestamp.

Return Value

Upon successful execution, the function returns a Promise that resolves to either a Service, VerificationMethod, or DIDDereferenceResolution object, depending on the provided didUrl and accept values.

Name Type Description

Service

Service

Returned if DID URL has a service fragment or service parameter was provided.

VerificationMethod

VerificationMethod

Returned if DID URL has a verificationMethod fragment.

ServiceEndpoint

ServiceEndpoint

Returned if DID URL has dereference to a service endpoint.

DIDDereferenceResolution

DIDDereferenceResolution

Returned if accept is application/ld+json;profile="https://w3id.org/did-resolution". It contains the dereferenced fragment and additional metadata.

CBOR Response

Uint8Array

Returned if accept is application/did+cbor. It contains the CBOR-encoded dereferenced fragment.

Errors

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

Exception code Description

invalidDidUrl

Unsupported DID method or invalid DID URL.

invalidDidUrl

Unsupported DID URL parameters.

invalidArgument

The versionId or versionTime format is invalid.

notFound

The DID document was not found.

notFound

Fragment not found in DID document.

notFound

Query not found in DID document.

representationNotSupported

Unsupported representation format.

representationNotSupported

Multiple service endpoints are not supported.

representationNotSupported

This service endpoint type is not supported.

Function Implementation

The Hashgraph DID SDK provides dereferenceDID within @swiss-digital-assets-institute/resolver.