You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for your work facilitating DID management. I followed the tutorial and tried to add the did:ethr:sepolia provider and resolver, but I had some issues.
The following things work:
Creating and resolving identifiers via did:peer (as proposed by the tutorial)
Creating identifiers via did:ethr:sepolia using the package @veramo/did-provider-ethr (see screenshot 1)
The following things fail:
Resolving a DID document via did:ethr:sepolia using the package ethr-did-resolver (see screenshot 2 and 3)
My Approach
Basically, I have additionally installed and imported the following packages:
Then, I extended the agent creation code from the tutorial as follows:
// ...newDIDManager({store: newDIDStore(dbConnection),defaultProvider: "did:ethr:sepolia",providers: {// WORKS! (see screenshot 1)"did:ethr:sepolia": newEthrDIDProvider({defaultKms: "local",network: "sepolia",rpcUrl: "https://sepolia.infura.io/v3/"+INFURA_PROJECT_ID,}),"did:peer": newPeerDIDProvider({defaultKms: "local",}),},}),newDIDResolverPlugin({
...peerDidResolver(),
...webDidResolver(),// THIS IS NOT WORKING (see error logs on screenshot 2 and 3)
...ethrDidResolver({infuraProjectId: INFURA_PROJECT_ID}),}),// ...
After encountering the error message Cannot read property 'getResolver' of undefined, I am not sure if I am using the ethrDidResolver correctly. Can someone help me understand why it is not working?
Full Code
setup.ts
// imports:// Core interfacesimport{createAgent,IDataStore,IDataStoreORM,IDIDManager,IKeyManager}from"@veramo/core";// Core identity manager plugin. This allows you to create and manage DIDs by orchestrating different DID provider packages.// This implements `IDIDManager`import{DIDManager}from"@veramo/did-manager";// Core key manager plugin. DIDs use keys and this key manager is required to know how to work with them.// This implements `IKeyManager`import{KeyManager}from"@veramo/key-manager";// This plugin allows us to create and manage `did:peer` DIDs (used by DIDManager)import{PeerDIDProvider}from"@veramo/did-provider-peer";// A key management system that uses a local database to store keys (used by KeyManager)import{KeyManagementSystem,SecretBox}from"@veramo/kms-local";// Storage plugin using TypeORM to link to a databaseimport{Entities,KeyStore,DIDStore,migrations,PrivateKeyStore}from"@veramo/data-store";// TypeORM is installed with '@veramo/data-store'import{DataSource}from"typeorm";// Core interfacesimport{IResolver}from"@veramo/core";// Core DID resolver plugin. This plugin orchestrates different DID resolver drivers to resolve the corresponding DID Documents for the given DIDs.// This plugin implements `IResolver`import{DIDResolverPlugin}from"@veramo/did-resolver";// the did:peer resolver packageimport{getResolveraspeerDidResolver}from"@veramo/did-provider-peer";// the did:web resolver packageimport{getResolveraswebDidResolver}from"web-did-resolver";// This plugin allows us to issue and verify W3C Verifiable Credentials with JWT proof formatimport{CredentialPlugin,ICredentialIssuer,ICredentialVerifier}from"@veramo/credential-w3c";// CUSTOM IMPORTSimport{EthrDIDProvider}from"@veramo/did-provider-ethr";import{getResolverasethrDidResolver}from"ethr-did-resolver";// CONSTANTS// This is a raw X25519 private key, provided as an example.// You can run `npx @veramo/cli config create-secret-key` in a terminal to generate a new key.// In a production app, this MUST NOT be hardcoded in your source code.constDB_ENCRYPTION_KEY="29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c";constINFURA_PROJECT_ID="<I DON'T WANT TO LEAK MY INFURA PROJECT ID>";// DB setup:letdbConnection=newDataSource({type: "expo",driver: require("expo-sqlite"),database: "veramo.sqlite",migrations: migrations,migrationsRun: true,logging: ["error","info","warn"],entities: Entities,}).initialize();// Veramo agent setupexportconstagent=createAgent<IDIDManager&IKeyManager&IDataStore&IDataStoreORM&IResolver&ICredentialIssuer&ICredentialVerifier>({plugins: [newKeyManager({store: newKeyStore(dbConnection),kms: {local: newKeyManagementSystem(newPrivateKeyStore(dbConnection,newSecretBox(DB_ENCRYPTION_KEY))),},}),newDIDManager({store: newDIDStore(dbConnection),defaultProvider: "did:ethr:sepolia",providers: {"did:ethr:sepolia": newEthrDIDProvider({defaultKms: "local",network: "sepolia",rpcUrl: "https://sepolia.infura.io/v3/"+INFURA_PROJECT_ID,}),"did:peer": newPeerDIDProvider({defaultKms: "local",}),},}),newDIDResolverPlugin({
...peerDidResolver(),
...webDidResolver(),// THIS IS NOT WORKING
...ethrDidResolver({infuraProjectId: INFURA_PROJECT_ID}),}),newCredentialPlugin(),],});
It's a known issue in ethr-did-resolver (decentralized-identity/ethr-did-resolver#186) it's caused by the build process which tries to produce dual ESM/CommonJS artifacts, but then these dual builds are failing with certain setups.
PRs are welcome if you have bandwidth to investigate and propose a fix
pemmenegger
changed the title
How does "ethr-did-resolver" work with react native?
ethr-did-resolver: Cannot read property 'getResolver' of undefined
Apr 10, 2024
Workaround: I solved it by establishing an Express.js API that depends on the package ethr-did-resolver and returns the resolved DID document via an API endpoint.
Hi there,
First of all, thanks for your work facilitating DID management. I followed the tutorial and tried to add the
did:ethr:sepolia
provider and resolver, but I had some issues.The following things work:
did:peer
(as proposed by the tutorial)did:ethr:sepolia
using the package@veramo/did-provider-ethr
(see screenshot 1)The following things fail:
did:ethr:sepolia
using the packageethr-did-resolver
(see screenshot 2 and 3)My Approach
Basically, I have additionally installed and imported the following packages:
Then, I extended the agent creation code from the tutorial as follows:
After encountering the error message
Cannot read property 'getResolver' of undefined
, I am not sure if I am using the ethrDidResolver correctly. Can someone help me understand why it is not working?Full Code
setup.ts
package.json
Screenshots
The text was updated successfully, but these errors were encountered: