-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
- Loading branch information
1 parent
9cb6b83
commit a027c3d
Showing
6 changed files
with
246 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.env | ||
.DS_Store | ||
.idea | ||
**/.idea | ||
**/node_modules | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# did:ethr resolver demo | ||
|
||
This demo assumes you have already executed `eth-anoncreds-rust-demo` which | ||
creates registers `did:ethr` in DID registry. | ||
|
||
This demo resolves the created Did Document for the registered DID using JS `did:ethr` | ||
resolver implementation based on: | ||
- [`did-resolver`](https://github.com/decentralized-identity/did-resolver) | ||
- [`ethr-did-resolver`](https://github.com/decentralized-identity/ethr-did-resolver) | ||
|
||
# Instructions | ||
1. Install dependencies | ||
```sh | ||
npm install | ||
``` | ||
|
||
2. Run demo | ||
``` | ||
DID_REGISTRY_ADDRESS=<your_registry_address> DID=<your_did> npm run demo | ||
``` | ||
|
||
If no env variables are provided, following defaults are used: | ||
- DID_REGISTRY_ADDRESS: `0x5fbdb2315678afecb367f032d93f642f64180aa3` | ||
- DID: `did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266` | ||
|
||
The demo should output resolved DID Document, such as: | ||
```json | ||
|
||
{ | ||
"didDocumentMetadata": { | ||
"versionId": "2", | ||
"updated": "2023-11-21T21:01:40Z" | ||
}, | ||
"didResolutionMetadata": { | ||
"contentType": "application/did+ld+json" | ||
}, | ||
"didDocument": { | ||
"id": "did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", | ||
"verificationMethod": [ | ||
{ | ||
"id": "did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266#controller", | ||
"type": "EcdsaSecp256k1RecoveryMethod2020", | ||
"controller": "did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", | ||
"blockchainAccountId": "eip155:31337:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" | ||
} | ||
], | ||
"authentication": [ | ||
"did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266#controller" | ||
], | ||
"assertionMethod": [ | ||
"did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266#controller" | ||
], | ||
"@context": [ | ||
"https://www.w3.org/ns/did/v1", | ||
"https://w3id.org/security/suites/secp256k1recovery-2020/v2", | ||
"https://w3id.org/security/v3-unstable" | ||
] | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// import {Resolver} from 'did-resolver' | ||
// import {getResolver} from 'ethr-did-resolver' | ||
const { Resolver } = require('did-resolver'); | ||
const { getResolver } = require('ethr-did-resolver'); | ||
|
||
const did_registry_address = process.env.DID_REGISTRY_ADDRESS | "0x5fbdb2315678afecb367f032d93f642f64180aa3" | ||
const did_url = process.env.DID | "did:ethr:gmtest:0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" | ||
|
||
async function run() { | ||
const providerConfig = { | ||
networks: [ | ||
{ name: "gmtest", rpcUrl: "http://localhost:8545", registry: did_registry_address }, | ||
] | ||
} | ||
|
||
const ethrDidResolver = getResolver(providerConfig) | ||
const didResolver = new Resolver(ethrDidResolver) | ||
|
||
const doc = await didResolver.resolve(did_url) | ||
console.log(JSON.stringify(doc, null, 2)) | ||
} | ||
|
||
run() | ||
.catch(err => { | ||
console.error((err)) | ||
}) | ||
.then(() => { | ||
return 0 | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "didethr-resolver", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"demo": "node index.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"did-resolver": "^4.1.0", | ||
"ethr-did-resolver": "^10.0.0" | ||
} | ||
} |