DIDUpdateBuilder API Reference

This document provides a concise API reference for the DIDUpdateBuilder class within the Hedera DID SDK for JavaScript. The DIDUpdateBuilder class provides a fluent interface to build a DID update operation that can be used to update a DID Document.

Class Diagram

The following class diagram provides a visual representation of the relationships between key classes and interfaces involved in the DIDUpdateBuilder class.

did update builder class diagram

Methods

addAuthenticationMethod

public addAuthenticationMethod(methodOrId: VerificationMethod | string): DIDUpdateBuilder {}

Adds an authentication method to the DID document. If a verification method with the same ID already exists, it will be replaced. A authentication method is a public key that can be used to authenticate the DID subject.

You can provide ID of the existing verification method or the VerificationMethod object itself. Using the ID is useful when you want to use the same verification method in multiple places in the DID document as a reference.

Parameters
  • methodOrId: The VerificationMethod object or the identifier of the verification method as a source.

Returns

The current DIDUpdateBuilder instance for method chaining.

removeAuthenticationMethod

public removeAuthenticationMethod(methodId: string): DIDUpdateBuilder {}

Removes an authentication method from the DID document by its identifier.

Parameters
  • methodId: The identifier of the authentication method to be removed.

Returns

The current DIDUpdateBuilder instance for method chaining.

addAssertionMethod

public addAssertionMethod(methodOrId: VerificationMethod | string): DIDUpdateBuilder {}

Adds an assertion method to the DID document. If a verification method with the same ID already exists, it will be replaced. A assertion method is a public key that can be used to express claims, such as for the purposes of issuing a Verifiable Credential.

You can provide ID of the existing verification method or the VerificationMethod object itself. Using the ID is useful when you want to use the same verification method in multiple places in the DID document as a reference.

Parameters
  • methodOrId: The VerificationMethod object or the identifier of the verification method as a source.

Returns

The current DIDUpdateBuilder instance for method chaining.

removeAssertionMethod

public removeAssertionMethod(methodId: string): DIDUpdateBuilder {}

Removes an assertion method from the DID document by its identifier.

Parameters
  • methodId: The identifier of the assertion method to be removed.

Returns

The current DIDUpdateBuilder instance for method chaining.

addKeyAgreementMethod

public addKeyAgreementMethod(methodOrId: VerificationMethod | string): DIDUpdateBuilder {}

Adds a key agreement method to the DID document. If a verification method with the same ID already exists, it will be replaced. A key agreement method is a public key that can be used to derive a shared secret for secure communication.

You can provide ID of the existing verification method or the VerificationMethod object itself. Using the ID is useful when you want to use the same verification method in multiple places in the DID document as a reference.

Parameters
  • methodOrId: The VerificationMethod object or the identifier of the verification method as a source.

Returns

The current DIDUpdateBuilder instance for method chaining.

removeKeyAgreementMethod

public removeKeyAgreementMethod(methodId: string): DIDUpdateBuilder {}

Removes a key agreement method from the DID document by its identifier.

Parameters
  • methodId: The identifier of the key agreement method to be removed.

Returns

The current DIDUpdateBuilder instance for method chaining.

addCapabilityInvocationMethod

public addCapabilityInvocationMethod(methodOrId: VerificationMethod | string): DIDUpdateBuilder {}

Adds a capability invocation method to the DID document. If a verification method with the same ID already exists, it will be replaced. A capability invocation method is a public key that can be used to invoke a cryptographic capability, such as the authorization to update the DID Document.

You can provide ID of the existing verification method or the VerificationMethod object itself. Using the ID is useful when you want to use the same verification method in multiple places in the DID document as a reference.

Parameters
  • methodOrId: The VerificationMethod object or the identifier of the verification method as a source.

Returns

The current DIDUpdateBuilder instance for method chaining.

removeCapabilityInvocationMethod

public removeCapabilityInvocationMethod(methodId: string): DIDUpdateBuilder {}

Removes a capability invocation method from the DID document by its identifier.

Parameters
  • methodId: The identifier of the capability invocation method to be removed.

Returns

The current DIDUpdateBuilder instance for method chaining.

addCapabilityDelegationMethod

public addCapabilityDelegationMethod(methodOrId: VerificationMethod | string): DIDUpdateBuilder {}

Adds a capability delegation method to the DID document. If a verification method with the same ID already exists, it will be replaced. A capability delegation method is a public key that can be used to delegate authority to another party.

You can provide ID of the existing verification method or the VerificationMethod object itself. Using the ID is useful when you want to use the same verification method in multiple places in the DID document as a reference.

Parameters
  • methodOrId: The VerificationMethod object or the identifier of the verification method as a source.

Returns

The current DIDUpdateBuilder instance for method chaining.

removeCapabilityDelegationMethod

public removeCapabilityDelegationMethod(methodId: string): DIDUpdateBuilder {}

Removes a capability delegation method from the DID document by its identifier.

Parameters
  • methodId: The identifier of the capability delegation method to be removed.

Returns

The current DIDUpdateBuilder instance for method chaining.

addService

public addService(service: Service): DIDUpdateBuilder {}

Adds a service to the DID document. If a service with the same ID already exists, it will be replaced.

Parameters
  • service: The Service object to be added.

Returns

The current DIDUpdateBuilder instance for method chaining.

removeService

public removeService(serviceId: string): DIDUpdateBuilder {}

Removes a service from the DID document by its identifier.

Parameters
  • serviceId: The identifier of the service to be removed.

Returns

The current DIDUpdateBuilder instance for method chaining.

build

public build(): Array<DIDUpdateOperation> {}

Builds the DID update operation based on the added verification methods, services, and other changes.

Returns

A list of DIDUpdateOperation objects representing the changes to the DID document.

These types are used as parameters or return values in the DIDUpdateBuilder methods:

VerificationMethod Type

Name Type Description

id

string

The identifier of the verification method, e.g., #key-1.

controller

string?

The DID that controls the verification method. Default is DID itself.

publicKeyMultibase?

string

The public key in multibase format. Required when creating a new verification method.

Service Type

Name Type Description

id

string

The identifier of the service, e.g., #service-1.

type

string

The type of service, e.g., MessagingService.

serviceEndpoint

string

The service endpoint URL.

Class Implementation

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