Skip to content

Commit 321b2e8

Browse files
feat: Add Hedera module (openwallet-foundation#2405)
* feat: Add Hedera module Signed-off-by: Andrey Kononov <andrey.kononov@dsr-corporation.com> Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> Co-authored-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * docs(changeset): Add Hedera module Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * feat(hedera): Use DID SDK Signer interface Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * chore(hedera): Updates after merging changes from 'main' Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * chore(hedera): Update Hiero DID SDK to 0.1.5 Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * fix(jest): Update snapshot guide links Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * feat(hedera): Support DID record keys removal + refactor PublicJwk usage Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> * chore(hedera): Update package exports Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> --------- Signed-off-by: Andrey Kononov <andrey.kononov@dsr-corporation.com> Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> Co-authored-by: Andrey Kononov <andrey.kononov@dsr-corporation.com>
1 parent a4f443b commit 321b2e8

48 files changed

Lines changed: 4714 additions & 23 deletions

Some content is hidden

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

.changeset/young-readers-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@credo-ts/hedera": minor
3+
---
4+
5+
Add Hedera module

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ See [Supported Features](https://credo.js.org/guides/features) on the Credo webs
5151

5252
- 🏃 **Platform agnostic** - out of the box support for Node.JS and React Native
5353
- 🔒 **DIDComm and AIP** - Support for [DIDComm v1](https://hyperledger.github.io/aries-rfcs/latest/concepts/0005-didcomm/), and both v1 and v2 of the [Aries Interop Profile](https://github.com/hyperledger/aries-rfcs/blob/main/concepts/0302-aries-interop-profile/README.md).
54-
- 🛂 **Extendable [DID](https://www.w3.org/TR/did-core/) resolver and registrar** - out of the box support for `did:web`, `did:key`, `did:jwk`, `did:peer`, `did:sov`, `did:indy` and `did:cheqd`.
54+
- 🛂 **Extendable [DID](https://www.w3.org/TR/did-core/) resolver and registrar** - out of the box support for `did:web`, `did:key`, `did:jwk`, `did:peer`, `did:sov`, `did:indy`, `did:cheqd` and `did:hedera`.
5555
- 🔑 **[OpenID4VC](https://openid.net/sg/openid4vc/)** - support for [OpenID for Verifiable Credential Issuance](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html), [OpenID for Verifiable Presentations](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html) and [Self-Issued OpenID Provider v2](https://openid.net/specs/openid-connect-self-issued-v2-1_0.html).
5656
- 🪪 **Multiple credential formats** - [W3C Verifiable Credential Data Model v1.1](https://www.w3.org/TR/vc-data-model/), [SD-JWT VCs](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-03.html), and [AnonCreds](https://hyperledger.github.io/anoncreds-spec/).
5757
- 🏢 **Multi-tenant** - Optional multi-tenant module for managing multiple tenants under a single agent.
@@ -158,6 +158,14 @@ See [Supported Features](https://credo.js.org/guides/features) on the Credo webs
158158
</a>
159159
</td>
160160
</tr>
161+
<tr>
162+
<td>@credo-ts/hedera</td>
163+
<td>
164+
<a href="https://npmjs.com/package/@credo-ts/hedera">
165+
<img alt="@credo-ts/hedera version" src="https://img.shields.io/npm/v/@credo-ts/hedera"/>
166+
</a>
167+
</td>
168+
</tr>
161169
<tr>
162170
<td><s>@aries-framework/indy-sdk</s> (deprecated, unmaintained after 0.4.x)</td>
163171
<td>

demo/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@
1313
"faber": "ts-node src/FaberInquirer.ts"
1414
},
1515
"dependencies": {
16-
"@hyperledger/indy-vdr-nodejs": "catalog:",
1716
"@hyperledger/anoncreds-nodejs": "catalog:",
17+
"@hyperledger/indy-vdr-nodejs": "catalog:",
1818
"@openwallet-foundation/askar-nodejs": "catalog:",
1919
"inquirer": "^8.2.5"
2020
},
2121
"devDependencies": {
2222
"@credo-ts/anoncreds": "workspace:*",
2323
"@credo-ts/askar": "workspace:*",
24+
"@credo-ts/cheqd": "workspace:*",
2425
"@credo-ts/core": "workspace:*",
2526
"@credo-ts/didcomm": "workspace:*",
27+
"@credo-ts/hedera": "workspace:*",
2628
"@credo-ts/indy-vdr": "workspace:*",
27-
"@credo-ts/cheqd": "workspace:*",
2829
"@credo-ts/node": "workspace:*",
30+
"@hiero-did-sdk/client": "0.1.5",
2931
"@types/figlet": "^1.5.4",
3032
"@types/inquirer": "^8.2.6",
3133
"clear": "^0.1.0",

demo/src/BaseAgent.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ import {
3232
} from '@credo-ts/didcomm'
3333
import { IndyVdrAnonCredsRegistry, IndyVdrIndyDidResolver, IndyVdrModule } from '@credo-ts/indy-vdr'
3434
import { DidCommHttpInboundTransport, agentDependencies } from '@credo-ts/node'
35+
import { HederaNetwork } from '@hiero-did-sdk/client'
3536
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
3637
import { indyVdr } from '@hyperledger/indy-vdr-nodejs'
3738
import { askar } from '@openwallet-foundation/askar-nodejs'
3839

3940
import { AskarModuleConfigStoreOptions } from '@credo-ts/askar'
41+
import { HederaAnonCredsRegistry, HederaDidRegistrar, HederaDidResolver, HederaModule } from '@credo-ts/hedera'
4042
import { greenText } from './OutputClass'
4143

4244
const bcovrin = `{"reqSignature":{},"txn":{"data":{"data":{"alias":"Node1","blskey":"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba","blskey_pop":"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1","client_ip":"138.197.138.255","client_port":9702,"node_ip":"138.197.138.255","node_port":9701,"services":["VALIDATOR"]},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv"},"metadata":{"from":"Th7MpTaRZVRYnPiabds81Y"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62"},"ver":"1"}
@@ -113,7 +115,7 @@ function getAskarAnonCredsIndyModules(
113115
],
114116
}),
115117
anoncreds: new AnonCredsModule({
116-
registries: [new IndyVdrAnonCredsRegistry(), new CheqdAnonCredsRegistry()],
118+
registries: [new IndyVdrAnonCredsRegistry(), new CheqdAnonCredsRegistry(), new HederaAnonCredsRegistry()],
117119
anoncreds,
118120
}),
119121
indyVdr: new IndyVdrModule({
@@ -132,12 +134,23 @@ function getAskarAnonCredsIndyModules(
132134
})
133135
),
134136
dids: new DidsModule({
135-
resolvers: [new IndyVdrIndyDidResolver(), new CheqdDidResolver()],
136-
registrars: [new CheqdDidRegistrar()],
137+
resolvers: [new IndyVdrIndyDidResolver(), new CheqdDidResolver(), new HederaDidResolver()],
138+
registrars: [new CheqdDidRegistrar(), new HederaDidRegistrar()],
137139
}),
138140
askar: new AskarModule({
139141
askar,
140142
store: askarStoreConfig,
141143
}),
144+
hedera: new HederaModule({
145+
networks: [
146+
{
147+
network: (process.env.HEDERA_NETWORK as HederaNetwork) ?? 'testnet',
148+
operatorId: process.env.HEDERA_OPERATOR_ID ?? '0.0.5489553',
149+
operatorKey:
150+
process.env.HEDERA_OPERATOR_KEY ??
151+
'302e020100300506032b6570042204209f54b75b6238ced43e41b1463999cb40bf2f7dd2c9fd4fd3ef780027c016a138',
152+
},
153+
],
154+
}),
142155
} as const
143156
}

demo/src/Faber.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Color, Output, greenText, purpleText, redText } from './OutputClass'
1414
export enum RegistryOptions {
1515
indy = 'did:indy',
1616
cheqd = 'did:cheqd',
17+
hedera = 'did:hedera',
1718
}
1819

1920
export class Faber extends BaseAgent {
@@ -38,11 +39,22 @@ export class Faber extends BaseAgent {
3839
// and store the existing did in the wallet
3940
// indy did is based on private key (seed)
4041
const unqualifiedIndyDid = '2jEvRuKmfBJTRa7QowDpNN'
41-
const cheqdDid = 'did:cheqd:testnet:d37eba59-513d-42d3-8f9f-d1df0548b675'
42-
const indyDid = `did:indy:${indyNetworkConfig.indyNamespace}:${unqualifiedIndyDid}`
43-
const didDocumentRelativeKeyId = registry === RegistryOptions.indy ? '#verkey' : '#key-1'
4442

45-
const did = registry === RegistryOptions.indy ? indyDid : cheqdDid
43+
const rootKeyIds: Record<string, string> = {
44+
[RegistryOptions.indy]: '#verkey',
45+
[RegistryOptions.cheqd]: '#key-1',
46+
[RegistryOptions.hedera]: '#did-root-key',
47+
}
48+
49+
const Dids: Record<string, string> = {
50+
[RegistryOptions.indy]: `did:indy:${indyNetworkConfig.indyNamespace}:${unqualifiedIndyDid}`,
51+
[RegistryOptions.cheqd]: 'did:cheqd:testnet:d37eba59-513d-42d3-8f9f-d1df0548b675',
52+
[RegistryOptions.hedera]: 'did:hedera:testnet:44eesExqdsUvLZ35FpnBPErqRGRnYbzzyG3wgCCYxkmq_0.0.6231121',
53+
}
54+
55+
const didDocumentRelativeKeyId = rootKeyIds[registry]
56+
const did = Dids[registry]
57+
4658
const { privateJwk } = transformPrivateKeyToPrivateJwk({
4759
type: {
4860
crv: 'Ed25519',

demo/src/FaberInquirer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export class FaberInquirer extends BaseInquirer {
9090
}
9191

9292
public async credential() {
93-
const registry = await prompt([this.inquireOptions([RegistryOptions.indy, RegistryOptions.cheqd])])
93+
const registry = await prompt([
94+
this.inquireOptions([RegistryOptions.indy, RegistryOptions.cheqd, RegistryOptions.hedera]),
95+
])
9496
await this.faber.importDid(registry.options)
9597
await this.faber.issueCredential()
9698
const title = 'Is the credential offer accepted?'

packages/anoncreds/src/updates/__tests__/__snapshots__/0.3.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`UpdateAssistant | AnonCreds | v0.3.1 - v0.4 should correctly update the credential exchange records for holders 1`] = `
44
{

packages/anoncreds/src/updates/__tests__/__snapshots__/0.4.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`UpdateAssistant | AnonCreds | v0.4 - v0.5 should correctly update the credential exchange records for holders 1`] = `
44
{

packages/core/src/storage/migration/__tests__/__snapshots__/0.1.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`UpdateAssistant | v0.1 - v0.2 should correctly update credential records and create didcomm records 1`] = `
44
{

packages/core/src/storage/migration/__tests__/__snapshots__/0.2.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`UpdateAssistant | v0.2 - v0.3.1 should correctly update proof records and create didcomm records 1`] = `
44
{

0 commit comments

Comments
 (0)