decentralized-identity / did-jwt-vc

Create and verify W3C Verifiable Credentials and Presentations in JWT format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolve not found in did-resolver package

kst-howest opened this issue · comments

test.zip
Hi, trying the other code from the Readme.md file, a few other modifications are needed it seems:

import { Issuer } from 'did-jwt-vc/lib/types'
import * as EthrDID from 'ethr-did'
import { VerifiableCredentialPayload } from 'did-jwt-vc/lib/types'
import { createVerifiableCredential } from 'did-jwt-vc'
import { createPresentation } from 'did-jwt-vc'
import { PresentationPayload } from 'did-jwt-vc/lib/types'
import { getResolver } from 'ethr-did-resolver'
import { verifyCredential } from 'did-jwt-vc'

Remaining problem is now:
import { Resolver } from 'did-resolver'
const resolver = new Resolver(getResolver())

TSC doesn't find the Resolver in did-resolver.
Tried a few alternatives import * as Resolver from 'did-resolver' and import { Resolver } from 'did-resolver/lib/resolve' however without any luck.
br, Kris
test.zip

that's weird, did-resolver is also a TS lib and exports that type directly.
which version are you using?

tsc -version > Version 3.7.4

more info on the errors: (replaced my working dir below with "abc")

Executing task: tsc -p /home/abc/tsconfig.json <
src/index.ts:35:17 - error TS1308: 'await' expression is only allowed within an async function.
35 const vcJwt = await createVerifiableCredential(vcPayload, issuer)
~~~~~
src/index.ts:46:17 - error TS1308: 'await' expression is only allowed within an async function.
46 const vpJwt = await createPresentation(vpPayload, issuer)
~~~~~
src/index.ts:49:24 - error TS2351: This expression is not constructable.
Type 'typeof import("/home/abc/node_modules/did-resolver/lib/resolver")' has no construct signatures.

49 const resolver = new Resolver(getResolver())
~~~~~~~~
src/index.ts:52:20 - error TS1308: 'await' expression is only allowed within an async function.

52 const verifiedVC = await verifyCredential(vcJwt, resolver)
~~~~~
Found 4 errors.

I mean which version of did-resolver are you using?
It's easier if you keep track of things with a package.json file.

Also, perhaps it's wise to take care of those await errors too.
A quick fix for those is wrapping your code in an async anonymous function like so:

(async () => {
  //...your code here
})();

Hi, I ran again "npm install did-resolve" and seemed to have updated to
did-resolver@1.1.0
and now it seems working :-)
Thanks for your help and for the async/await advice!

excellent