Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@hashgraph/did-sdk-js
Advanced tools
Readme
Support for the Hedera Hashgraph DID Method and Verifiable Credentials on the Hedera JavaScript/TypeScript SDK.
This repository contains the Javascript SDK for managing DID Documents & Verifiable Credentials registry using the Hedera Consensus Service.
did-sdk-js based on did-sdk-java, so both of them contain similar methods and classes.
Identity networks are set of artifacts on Hedera Consensus Service that allow applications to share common channels to publish and resolve DID documents, issue verifiable credentials and control their validity status. These artifacts include:
This SDK is designed to simplify :
The SDK does not impose any particular way of how the DID or verifiable credential documents are constructed. Each appnet creators can choose their best way of creating those documents and as long as these are valid JSON-LD files adhering to W3C standards, they will be handled by the SDK.
npm install --save @hashgraph/did-sdk-js
const client = ... // Client
const identityNetwork = new HcsIdentityNetworkBuilder()
.setNetwork("testnet")
.setAppnetName("MyIdentityAppnet")
.addAppnetDidServer("https://appnet-did-server-url:port/path-to-did-api")
.setPublicKey(publicKey)
.setMaxTransactionFee(new Hbar(2))
.setDidTopicMemo("MyIdentityAppnet DID topic")
.setVCTopicMemo("MyIdentityAppnet VC topic")
.execute(client);
From already instantiated network:
const identityNetwork = ...; //HcsIdentityNetwork
// From a given DID root key:
const didRootKey = ...; //PrivateKey
const hcsDid = identityNetwork.generateDid(didRootKey.publicKey, false);
or:
// Without having a DID root key - it will be generated automatically:
// Here we decided to add DID topic ID parameter `tid` to the DID.
const hcsDidWithDidRootKey = identityNetwork.generateDid(true);
const didRootKeyPrivateKey = hcsDidWithDidRootKey.getPrivateDidRootKey().get();
or by directly constructing HcsDid object:
const didRootKey = HcsDid.generateDidRootKey();
const addressBookFileId = FileId.fromString("<hedera.address-book-file.id>");
const hcsDid = new HcsDid(HederaNetwork.TESTNET, didRootKey.publicKey, addressBookFileId);
Existing Hedera DID strings can be parsed into HcsDid object by calling fromString method:
const didString = "did:hedera:testnet:7c38oC4ytrYDGCqsaZ1AXt7ZPQ8etzfwaxoKjfJNzfoc;hedera:testnet:fid=0.0.1";
const did = HcsDid.fromString(didString);
const client = ...; //Client
const identityNetwork = ...; //HcsIdentityNetwork
const didRootKey = ...; //PrivateKey
const hcsDid = ...; //HcsDid
const didDocument = hcsDid.generateDidDocument().toJson();
// Build and execute transaction
await identityNetwork.createDidTransaction(DidMethodOperation.CREATE)
// Provide DID document as JSON string
.setDidDocument(didDocument)
// Sign it with DID root key
.signMessage(doc => didRootKey.sign(doc))
// Configure ConsensusMessageSubmitTransaction, build it and sign if required by DID topic
.buildAndSignTransaction(tx => tx.setMaxTransactionFee(new Hbar(2)))
// Define callback function when consensus was reached and DID document came back from mirror node
.onMessageConfirmed(msg => {
//DID document published!
})
// Execute transaction
.execute(client);
git clone git@github.com:hashgraph/did-sdk-js.git
First you need install dependencies and build project
npm install
Run build in dev mode (with sourcemap generation and following changes)
npm run build:dev
For run tests you need to create and fill test/variables.js
file before. There is test/variables.js.sample
file as example.
Update the following environment variables with your testnet
account details
You may also edit the following to use a different network (ensure your OPERATOR_ID and OPERATOR_KEY are valid)
testnet
, previewnet
or mainnet
)hedera
or kabuto
(note kabuto
not available on previewnet
))Run tests
npm run test
Licensed under license placeholder.
FAQs
Support for the Hedera Hashgraph DID Method and Verifiable Credentials on the Hedera JavaScript/TypeScript SDK
The npm package @hashgraph/did-sdk-js receives a total of 78 weekly downloads. As such, @hashgraph/did-sdk-js popularity was classified as not popular.
We found that @hashgraph/did-sdk-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.