ethr-did: Can NOT verify did:ether JWT token
I try to use Ether-DID library to create new jwt token and after that i can NOT verify it. Here is example code i used.
`const EthrDID = require(‘ethr-did’); const ethrDid = new EthrDID({ provider: web3.currentProvider, address: ‘address’, privateKey: ‘priv-key’ });
var jwt = await ethrDid.signJWT({ claims: { name: ‘Joe Lubin’ } }); //Problem here const { payload, issuer } = ethrDid.verifyJWT(jwt); console.log(payload); // return undefined console.log(issuer); // return undefined`
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 30 (12 by maintainers)
@mirceanis thanks for that information, much appreciated.
Just to be clear, the delay is needed somewhere between
createSigningDelegate()andverifyJWTbecausecreateSigningDelegate()sends a transaction and that block needs to propagate to the node that responds to the calls made byverifyJWT(resolving the DID document).So, if your flow requires some key delegation for signing but not immediately followed by verification, this delay will not be needed.
Also, perhaps it is a timing issue, see #34
you may also want to upgrade to
did-jwt@0.2.0since it fixes an issue with global Bufferit is fixed: we need to use
asyncawaitmethod:const { payload, issuer } = await ethrDid.verifyJWT(jwt);you also need to register the
ethr-did-resolverI see you are already importing it (const registerResolver = require('ethr-did-resolver').default). The missing step is to callregisterResolver({provider : provider, registry : registry})Also, this line seems to be unused:
const keypair = EthrDID.createKeyPair()Unless you intend to sign something with that keypair, you should remove that line to avoid confusion.Someone posted a solution in chat: