Closed m-yahya closed 3 years ago
Hi @m-yahya, thanks for reporting this.
This happens because there is a difference in the config
expected by new EthrDID(config)
and getResolver(config)
EthrDID
looks for chainNameOrId
while getResolver
has 2 different fields: chainId
and name
.
Yes, this is annoying and should probably be fixed in ethr-did-resolver
to make use of a field called chainNameOrId
.
Based on your example, here's a version that works:
const { EthrDID } = require("ethr-did");
const { Resolver } = require("did-resolver");
const { getResolver } = require("ethr-did-resolver");
const rpcUrl = "https://rinkeby.infura.io/v3/<project id>";
const ethrDidResolver = getResolver({ rpcUrl, name: "rinkeby" });
const didResolver = new Resolver(ethrDidResolver);
let createDid = async () => {
const keypair = EthrDID.createKeyPair();
// 1. create did
const ethrDid = new EthrDID({
...keypair,
rpcUrl,
chainNameOrId: "rinkeby"
});
// 2. sign jwt
const jwt = await ethrDid.signJWT({ hello: "world" });
// 3. verify jwt
const { payload, issuer } = await ethrDid.verifyJWT(jwt, didResolver);
console.log(payload);
console.log(issuer);
};
createDid();
I'm closing this. Please reopen if you're still having trouble or if you think there is more to be fixed.
Describe the bug Failed to verify JWT using
ethrDid.verifyJWT()
function. Error message:To Reproduce
$ node index.js
Expected behavior A verified output of JWT
Sample Code
Additional context Dependencies:
any help what I'm missing here? Thanks