Skip to content

Commit d70ae48

Browse files
Support Ed25519VerificationKey2020 multicodec prefix (#23)
Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com>
1 parent bb5b2bf commit d70ae48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+704
-183
lines changed

.changeset/whole-shrimps-cough.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
## Overview
44

55
This directory contains example implementations demonstrating the usage of the SDK. These examples showcase various functionalities of the SDK, such as creating DIDs, updating DID documents, resolving DIDs, and managing keys.
6-
Additionally, there is an E2E demo for recently added Hedera AnonCreds support.
76

87
## Prerequisites
98

109
- Hiero DID SDK: Make sure you have the Hiero DID SDK installed in your project.
1110
- Node.js: Ensure you have Node.js (version 20 or higher) installed on your system.
1211
- Hedera Testnet Account: You'll need a Hedera account on the testnet with some hbars to pay for transaction fees.
1312

13+
## E2E Demos
14+
- **[`did-e2e-demo.ts`](./did-e2e-demo.ts)**: Demonstrates how to create, update, and deactivate a DID. Provides basic interactivity (steps confirmation and user input for DID service endpoint).
15+
- **[`anoncreds-e2e-demo.ts`](./anoncreds-e2e-demo.ts)**: Demonstrates how manage AnonCreds resources on Hedera — create Schema and Credential Definition, create and update Revocation Registry.
16+
- **[`hedera-hcs-service-e2e-demo.ts`](./hedera-hcs-service-e2e-demo.ts)**: Demonstrates how to use the HederaHcsService to create and manage topics, submit and read messages, and upload and retrieve files using Hedera Consensus Service (HCS).
17+
1418
## Examples
1519

1620
The following examples are available in this directory:
@@ -34,7 +38,7 @@ The following examples are available in this directory:
3438
- **[`dereferenceDID-service-endpoint.ts`](./dereferenceDID-service-endpoint.ts)**: Demonstrates how to dereference a service endpoint from a DID document.
3539
- **[`dereferenceDID-with-full-metadata.ts`](./dereferenceDID-with-full-metadata.ts)**: Demonstrates how to dereference a DID fragment with full DID Resolution metadata.
3640
- **[`dereferenceDID-with-topic-reader.ts`](./dereferenceDID-with-topic-reader.ts)**: Demonstrates how to dereference a DID fragment using a custom topic reader.
37-
- - **[`dereferenceDID-with-verifier.ts`](./dereferenceDID-with-verifier.ts)**: Demonstrates how to dereference a DID fragment using a custom verifier.
41+
- **[`dereferenceDID-with-verifier.ts`](./dereferenceDID-with-verifier.ts)**: Demonstrates how to dereference a DID fragment using a custom verifier.
3842

3943
### Registrar package
4044

examples/anoncreds-e2e-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,4 @@ async function main() {
277277
console.log(JSON.stringify(revListResolutionResult.revocationStatusList, null, 2));
278278
}
279279

280-
main();
280+
main().finally(() => client.close());

examples/did-e2e-demo.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { PrivateKey } from '@hashgraph/sdk';
2+
import { createDID, deactivateDID, updateDID } from '@hiero-did-sdk/registrar';
3+
import { resolveDID } from '@hiero-did-sdk/resolver';
4+
import * as readline from 'node:readline';
5+
6+
const readLineInterface = readline.createInterface({
7+
input: process.stdin,
8+
output: process.stdout,
9+
});
10+
11+
const prompt = (text: string) => new Promise((resolve) => readLineInterface.question(text, resolve));
12+
13+
const operatorId = process.env.HEDERA_TESTNET_OPERATOR_ID;
14+
const operatorKey = process.env.HEDERA_TESTNET_OPERATOR_KEY;
15+
16+
const clientOptions = {
17+
network: 'testnet' as const,
18+
accountId: operatorId,
19+
privateKey: operatorKey,
20+
};
21+
22+
async function main() {
23+
const privateKey = await PrivateKey.generateED25519Async();
24+
25+
console.log('Creating new Hedera DID...');
26+
27+
const { did } = await createDID(
28+
{ privateKey },
29+
{
30+
clientOptions,
31+
}
32+
);
33+
34+
console.log(`Hedera DID has been created: ${did}`);
35+
36+
console.log(`Resolving the DID...`);
37+
38+
let didDocument = await resolveDID(did);
39+
40+
console.log('Resolved DID Document:');
41+
console.log(JSON.stringify(didDocument, null, 2));
42+
43+
await prompt('Press enter to proceed with updating the DID...');
44+
const serviceEndpoint = await prompt('Please enter DID service endpoint to add: ');
45+
46+
console.log(`Updating the DID...`);
47+
48+
await updateDID(
49+
{
50+
did,
51+
privateKey,
52+
updates: [
53+
{
54+
operation: 'add-service',
55+
id: '#service-1',
56+
type: 'VerifiableCredentialService',
57+
serviceEndpoint: serviceEndpoint as string,
58+
},
59+
],
60+
},
61+
{
62+
clientOptions,
63+
}
64+
);
65+
66+
console.log('Resolving the updated DID...');
67+
68+
didDocument = await resolveDID(did);
69+
70+
console.log('Resolved updated DID Document:');
71+
console.log(JSON.stringify(didDocument, null, 2));
72+
73+
await prompt('Press enter to proceed with deactivating the DID...');
74+
75+
console.log('Deactivating the DID...');
76+
77+
await deactivateDID({ did, privateKey }, { clientOptions });
78+
79+
console.log('Resolving the deactivated DID...');
80+
81+
didDocument = await resolveDID(did);
82+
83+
console.log('Resolved deactivated DID Document:');
84+
console.log(JSON.stringify(didDocument, null, 2));
85+
}
86+
87+
main().finally(() => readLineInterface.close());

examples/hedara-hcs-service-comprehensive-example.ts renamed to examples/hedera-hcs-service-e2e-demo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* This comprehensive example demonstrates how to use the HederaHcsService
2+
* This E2E demo demonstrates how to use the HederaHcsService
33
* to create and manage topics, submit and read messages, and upload and
4-
* retrieve files in the Hedera Consensus Service (HCS) ecosystem.
4+
* retrieve files in the Hedera Consensus Service (HCS).
55
*
66
* It showcases the main capabilities wrapped via `HederaHcsService`,
77
* including topic lifecycle operations, message publishing and querying,
@@ -51,7 +51,7 @@ async function main() {
5151
console.log('Topic info:', topicInfo);
5252
console.log('');
5353

54-
// 3. Update topic example
54+
// 3. Update topic
5555
await hcsService.updateTopic({
5656
networkName: 'testnet',
5757
topicId,
@@ -111,7 +111,7 @@ async function main() {
111111
console.log('Resolved file content (string):', resolvedFile.toString());
112112
console.log('');
113113

114-
// 8. Delete topic example
114+
// 8. Delete topic
115115
await hcsService.deleteTopic({
116116
networkName: 'testnet',
117117
topicId,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"examples:run": "tsx --env-file examples/.env"
2222
},
2323
"devDependencies": {
24-
"@hashgraph/sdk": "^2.66.0",
24+
"@hashgraph/sdk": "^2.72.0",
2525
"@scure/base": "^1.2.4",
2626
"@antora/cli": "^3.1.10",
27-
"@antora/site-generator-default": "^3.1.10",
27+
"@antora/site-generator-default": "^3.1.12",
2828
"@babel/core": "^7.26.10",
2929
"@babel/preset-env": "^7.26.9",
3030
"@changesets/cli": "^2.29.4",

packages/anoncreds/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @hiero-did-sdk/anoncreds
22

3+
## 0.1.3
4+
5+
### Patch Changes
6+
7+
- bb5b2bf: Fixed an issue where multiple actions to update and deactivate a document's DID could not be performed when using a Client instance
8+
- Updated dependencies [f95ba48]
9+
- Updated dependencies [bb5b2bf]
10+
- @hiero-did-sdk/core@0.1.3
11+
- @hiero-did-sdk/hcs@0.1.3
12+
- @hiero-did-sdk/zstd@0.1.3
13+
314
## 0.1.2
415

516
### Patch Changes

packages/anoncreds/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hiero-did-sdk/anoncreds",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "This package provides implementation of Hedera AnonCreds Registry, following Hedera AnonCreds Method specification.",
55
"author": {
66
"name": "DSR Corporation",

packages/cache/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @hiero-did-sdk/cache
22

3+
## 0.1.3
4+
5+
### Patch Changes
6+
7+
- bb5b2bf: Fixed an issue where multiple actions to update and deactivate a document's DID could not be performed when using a Client instance
8+
- Updated dependencies [f95ba48]
9+
- Updated dependencies [bb5b2bf]
10+
- @hiero-did-sdk/core@0.1.3
11+
312
## 0.1.2
413

514
### Patch Changes

packages/cache/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hiero-did-sdk/cache",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "This package provides caching utilities for the Hiero DID SDK JS.",
55
"author": {
66
"name": "DSR Corporation",

0 commit comments

Comments
 (0)