-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can NOT verify did:ether JWT token #22
Comments
same here :-( Output: undefined |
The error also happens in the method verifyJWT() of 'did-jwt' library. |
Someone posted a solution in chat:
|
I am not able to sole it does anyone have any idea about this error while calling verifyJWT? thanks alot!! |
The did-jwt lib is being refactored to use a local configuration instead of a global.
|
The root cause is that this library is not installing the |
@mirceanis
Dependencies: |
you also need to register the Also, this line seems to be unused: |
@mirceanis thank you very much for your support.
|
it is fixed: |
you may also want to upgrade to |
@mirceanis
The error is: |
you are experiencing this bug: decentralized-identity/did-jwt#14 to fix it add //....
const signer = didJWT.SimpleSigner('0x92dd08591c87f6b860fd2bb4895d593f9f240a6f289883a7d5d625494eaeda1d')
//.....
// inside the async function
let jwt = '';
didJWT.createJWT({ aud: 'did:ethr:0x07b3fae112f54be9c1bd4477565e0366c41fc2f3', exp: 1957463421, name: 'uPort Developer' },
{ alg: `ES256K-R`, issuer: 'did:ethr:0x07b3fae112f54be9c1bd4477565e0366c41fc2f3', signer }).then(jwt => {
console.log(jwt); // this works fine
didJWT.verifyJWT(jwt, { audience: 'did:ethr:0x07b3fae112f54be9c1bd4477565e0366c41fc2f3' }).then((verifiedRespone) => {
console.log(verifiedRespone);
});
}); |
it throws the error :
|
what network are you on? if you are using ganache, there seem to be some issues that prevent ethr-did-registry from working correctly (#33 (comment)) |
yes, this is ganache. |
I tested it with EWF Volta chain (https://energyweb.atlassian.net/wiki/spaces/EWF/pages/703201459/Volta+Connecting+to+Remote+RPC) running on my machine, but still the same error: |
|
@m-yahya please post an example of an invalid JWT, as well as the registry address you are using on volta |
Also, perhaps it is a timing issue, see #34 |
Closing this since the original error ( |
we need a delay before executing verification.
|
Just to be clear, the delay is needed somewhere between So, if your flow requires some key delegation for signing but not immediately followed by verification, this delay will not be needed. |
I hate to drag this up again but when I call verifyJWT I still get: Error: Unsupported DID method: 'ethr' I have created my EthrDID and registered my ethrDidResolver. I have even verified that the
The signJWT returns a JWT as expected:
But the line below fails: This is doing my head in! |
Hi Frank, did you manage to resolve this? I'm currently having the same issue. |
@gdollard try passing the resolver to the verify method const didResolver = new Resolver(ethrDidResolver)
const {payload, issuer} = await ethrDid.verifyJWT(helloJWT, didResolver).then(...) |
@mirceanis thanks for the reply. I am now getting the following error: "mnidOrDid.match is not a function" using the following code:
|
OK, I have modified my code to directly use did-jwt for JWT creation verification. I understand ethr-did provides a layer of abstraction from this but I was having so many problems, mainly due to the data I was passing it was easier to debug from this lower level. I discovered my problem may have been due to the keyPair object I was using. I was hoping to use a key pair from one of my accounts via my web3 instance but for some reason JWT doesn't like it. When I use the object returned by EtherDID.createKeyPair() it works! I'm going to investigate further because surely this should work with my own correctly created account keyPair (as exported from my MetaMask account). |
web3 signatures are different from JWT signatures, even if the same private key is in use so it wouldn't work with only your web3 provider. For reference, in pseudocode web3 signatures are computed as As a side-note, unfortunately there's not enough bandwidth now to investigate the issues you are facing, not even to update docs for this library. PRs are still welcome, of course. |
@mirceanis thanks for that information, much appreciated. |
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`
The text was updated successfully, but these errors were encountered: