Messages API Reference
This document provides a concise API reference for the Messages component within the Hedera DID SDK for JavaScript.
Message Classes
DIDMessage
Represents an abstract DID Message. All other DID Message classes inherit from this class. It streamlines common functionality for DID Messages, such as signing and verifying messages.
Properties
Name | Type | Description |
---|---|---|
signature |
|
The signature of the DID Message. |
operation |
|
The operation of the DID Message, such as "create", "update", or "revoke". |
did |
|
The DID string of the Decentralized Identifier. |
message |
|
The message object. It varies depending on the operation and message type. Includes the encoded event and other message-specific data. |
topicId |
|
The ID of the Hedera topic associated with the DID. |
messageBytes |
|
The byte array of the message. It is used for signing and verifying the message. |
payload |
|
The actual content of the message that is published to the Hedera topic. It contains the message and the signature in a base64-encoded string. It may throw an error if the message is not signed. |
Methods
signWith
signWith(signer: Signer): Promise<void>
Signs the DID Message with the provided signer.
- Parameters
-
-
signer
: The signer object used to sign the DID Message.
-
setSignature
setSignature(
signature: Uint8Array,
verifier: Verifier,
): Promise<void>
Sets the signature of the DID Message and verifies the signature with the provided verifier.
- Parameters
-
-
signature
: The signature to set. -
verifier
: The verifier object used to verify the signature.
-
- Errors
-
The following exceptions may arise during the execution of the
setSignature
function:
Exception code | Description |
---|---|
|
The signature is invalid. |
DIDOwnerMessage
Represents a DID Owner message, used for creating and managing DID ownership.
This class encapsulate the DIDOwner
event payload from Hedera Hashgraph DID Method Specification.
Properties
Name | Type | Description |
---|---|---|
publicKey |
|
The public key of the DID owner, in the form of a PublicKey object. |
timestamp |
|
The timestamp of the DID Owner message creation. |
network |
|
The network on which the DID Owner message is created. |
controller |
|
The DID that controls the DID owner. |
Methods
setTopicId
setTopicId(topicId: string): void;
Sets the topic ID of the Hedera topic associated with the DID Owner message. It also performs the verification of the topic ID.
- Parameters
-
-
topicId
: The ID of the Hedera topic associated with the DID Owner message.
-
DIDAddVerificationMethodMessage
Represents a DID Add Verification Method message, used for adding verification methods or a verification relationship to a DID Document.
Verification relationships are used to associate a verification method with a specific property in the DID Document, such as "assertionMethod" or "authentication".
This class encapsulate the VerificationMethod
and VerificationRelationship
event payload from Hedera Hashgraph DID Method Specification.
Properties
Name | Type | Description |
---|---|---|
controller |
|
The DID that controls the verification method. |
property |
|
The property to which the verification method will be added (e.g., "verificationMethod", "authentication"). |
publicKeyMultibase |
|
The multibase-encoded public key of the verification method. |
id |
|
The identifier of the verification method (e.g., "#key-1"). |
timestamp |
|
The timestamp of the DID Add Verification Method message creation. |
DIDRemoveVerificationMethodMessage
Represents a DID Remove Verification Method message, used for removing verification methods or a verification relationship from a DID Document.
This class encapsulate the VerificationMethod
and VerificationRelationship
event payload from Hedera Hashgraph DID Method Specification.
Properties
Name | Type | Description |
---|---|---|
property |
|
The property from which the verification method will be removed (e.g., "verificationMethod", "authentication"). |
id |
|
The identifier of the verification method to be removed (e.g., "#key-1"). |
timestamp |
|
The timestamp of the DID Remove Verification Method message creation. |
DIDAddServiceMessage
Represents a DID Add Service message, used for adding a service to a DID Document.
This class encapsulate the Service
event payload from Hedera Hashgraph DID Method Specification.
Component Implementation
The Hashgraph DID SDK provides the DID Message classes within its messages
package. For further details, refer to the @hashgraph-did-sdk-js/messages
package documentation.