digitalbazaar / vc

W3C Verifiable Credentials implementation in JavaScript
BSD 3-Clause "New" or "Revised" License
182 stars 52 forks source link

loading remote context failed #174

Closed abonnivard closed 7 months ago

abonnivard commented 8 months ago

Hi,

I have the following issue when I tried to sign my VC :

  at async Object._createSignData [as createVerifyData] (file:///Users/adrien/Desktop/Cassiope%CC%81/VC/api_sign_vc/node_modules/@digitalbazaar/bbs-2023-cryptosuite/lib/sign.js:84:7) {
  details: {
    code: 'loading remote context failed',
    url: 'https://w3id.org/security/data-integrity/v2',
    cause: Error: Document loader unable to load URL "https://w3id.org/security/data-integrity/v2".
        at documentLoader (file:///Users/adrien/Desktop/Cassiope%CC%81/VC/api_sign_vc/node_modules/@digitalbazaar/vc/lib/documentLoader.js:16:9)
        at /Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld-signatures/lib/documentLoader.js:48:12
        at /Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld-signatures/lib/documentLoader.js:48:12
        at ContextResolver._fetchContext (/Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld/lib/ContextResolver.js:166:25)
        at ContextResolver._resolveRemoteContext (/Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld/lib/ContextResolver.js:117:45)
        at ContextResolver.resolve (/Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld/lib/ContextResolver.js:50:33)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async api.process (/Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld/lib/context.js:87:20)
        at async api.expand (/Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld/lib/expand.js:214:17)
        at async jsonld.expand (/Users/adrien/Desktop/Cassiopé/VC/api_sign_vc/node_modules/jsonld/lib/jsonld.js:322:18)
  }

I don't know how to do to resolve the pb because it's an intern pb form the github project. Any idea ?

Thanks a lot.

BigBlueHat commented 8 months ago

Hey @abonnivard, thanks for asking!

One option for resolving this is with a custom documentLoader: https://github.com/digitalbazaar/vc?tab=readme-ov-file#custom-documentloader

Using that, you can download the context file (essentially caching it), and load it via your custom document loader--thereby avoiding the network dependency (and latency). You'll of course want to separately track future revisions to that context file to be sure you have the latest, but using the custom documentLoader approach means you won't be doing that on every request.

Hope that helps! 🎩

dlongley commented 7 months ago

Closing as the answer has been given here and it seems this has been resolved.