Messages
The Messages component is the foundation of the Hashgraph DID SDK. It provides a comprehensive set of classes for constructing and handling DID Messages, which facilitate various DID operations on the Hedera network.
Overview
DID Messages are a standardized format for exchanging information about Decentralized Identifiers (DIDs). They are used to perform various DID operations, such as:
-
DID Creation: Registering a new DID on the Hedera network.
-
DID Update: Modifying an existing DID document.
-
DID Deactivation: Revoking a DID.
The DID Messages component provides a set of classes that represent these different DID operations. These classes make it easy to construct and process DID Messages, ensuring that they are correctly formatted and comply with the DID specification.
DID Message Classes
The following classes are exported by @swiss-digital-assets-institute/messages:
-
CreateDidMessage -
UpdateDidMessage -
DeactivateDidMessage
Each class also exposes lifecycle builders for Hedera default and CSM flows.
Usage Examples
Creating a CreateDidMessage
import { CreateDidMessage } from '@swiss-digital-assets-institute/messages';
const message = new CreateDidMessage({
identifierMultibasePublicKey: 'z6Mki...',
didDocumentFields: {
'@context': 'https://www.w3.org/ns/did/v1',
verificationMethod: [
{
id: '#did-root-key',
type: 'Ed25519VerificationKey2020',
controller: '',
publicKeyMultibase: 'z6Mki...',
},
],
capabilityInvocation: ['#did-root-key'],
},
network: 'testnet',
topicId: '0.0.12345',
});
Creating an UpdateDidMessage
import { UpdateDidMessage } from '@swiss-digital-assets-institute/messages';
const message = new UpdateDidMessage({
did: 'did:hedera:testnet:...',
updatedDidDocument: {
'@context': 'https://www.w3.org/ns/did/v1',
id: 'did:hedera:testnet:...',
controller: 'did:hedera:testnet:...',
verificationMethod: [],
},
});