Messages API Reference

This document provides a concise API reference for the Messages component within the Hedera DID SDK for JavaScript.

Message Classes

DIDMessage

DIDMessage is the abstract base class for all SDK DID messages. It is implemented in core and extended by concrete message classes in messages.

Class Diagram

did message class diagram

Properties

Name Type Description

proof?

Proof

Cryptographic proof attached to the message.

operation

DIDMessageOperation

Operation type: create, update, or deactivate.

did

string

DID associated with the message.

topicId

string

Hedera topic id where message is published.

payload

string

JSON payload to publish (includes proof). Throws if proof is missing.

Methods

signWith
signWith(signer: Signer, options: SignWithOptions): Promise<void>

Signs the unsecured message and sets proof.

setProof
setProof(
  proof: Proof,
  verifier: Verifier,
  cryptosuites: ProofVerifier[],
  options: VerifierOptions,
): Promise<void>

Validates and attaches a provided proof.

toBytes
abstract toBytes(): string

Serializes the DID Message into a byte array in base64 format.

Returns

The serialized DID Message as a base64-encoded string.

fromBytes
static abstract fromBytes(bytes: string): DIDMessage

Deserializes a DID Message from a byte array in base64 format.

Parameters
  • bytes: The byte array containing the serialized DID Message.

Returns

The deserialized DID Message object.

CreateDidMessage

Represents a DID create operation in DID SDK 2.0.

Name Type Description

identifierMultibasePublicKey?

string

Identifier key used to derive DID id.

didDocumentFields

DIDDocumentFields

Initial DID document fields for creation.

network?

Network

Target Hedera network.

topicId?

string

Existing topic id, if provided.

UpdateDidMessage

Represents a DID update operation in DID SDK 2.0.

Name Type Description

did

string

DID to update.

updatedDidDocument

JsonLdDIDDocument

Full updated DID document.

DeactivateDidMessage

Represents a DID deactivate operation in DID SDK 2.0.

Name Type Description

did

string

DID to deactivate.

Component Implementation

The Hashgraph DID SDK provides the DID Message classes within @swiss-digital-assets-institute/messages. For further details, refer to the Packages Guide.