Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Error: Dereferencing a URL did not result in a valid JSON-LD context #2853

Open
Vid201 opened this issue Jun 29, 2021 · 2 comments
Open

Error: Dereferencing a URL did not result in a valid JSON-LD context #2853

Vid201 opened this issue Jun 29, 2021 · 2 comments

Comments

@Vid201
Copy link

Vid201 commented Jun 29, 2021

What I'm trying to do

Sign verifiable credential.

Expected result

Signed verifiable credential.

Actual result

{"code":6011,"message":"parse vc : compact JSON-LD document: loading remote context failed: Dereferencing a URL did not result in a valid JSON-LD context: https://www.w3.org/2018/credentials/examples/v1"}

Sample code / test case

curl -k -X POST "https://localhost:8082/verifiable/signcredential" -H "accept:application/json" -H "Content-Type:application/json" -d "{\"created\":\"2021-05-05T10:22:25.999Z\",\"credential\":{\"@context\":[\"https://www.w3.org/2018/credentials/v1\",\"https://www.w3.org/2018/credentials/examples/v1\"],\"credentialSubject\":{\"id\":\"sample-credential-subject-id\"},\"id\":\"http://example.edu/credentials/1872\",\"issuanceDate\":\"2010-01-01T19:23:24Z\",\"issuer\":{\"id\":\"did:example:09s12ec712ebc6f1c671ebfeb1f\",\"name\":\"ExampleUniversity\"},\"referenceNumber\":83294847,\"type\":[\"VerifiableCredential\",\"UniversityDegreeCredential\"]},\"did\":\"did:key:z6Mkf3mSeHmehoXVdXQt1uNimKxD9RqFXHS6EgbVaDx4B5Z5\",\"signatureType\":\"Ed25519Signature2018\"}"

Note: this was working in previous versions (working on commit 2a52bb7).

@aholovko
Copy link
Contributor

aholovko commented Jul 5, 2021

Hi @Vid201,

We have updated the way how JSON-LD contexts are handled by the framework - now contexts are not fetched from the remote sources by default. This is mainly because of performance considerations and for having more control over what external calls are made by the framework.

There is a core set of contexts that the framework embeds, and https://www.w3.org/2018/credentials/examples/v1 is not there.

Depending on how you are using the framework, there are several ways how you can add support for additional contexts.

  1. If you have access to the framework instance, you can initialize it with the custom loader - either the one with needed contexts or the one that enables remote fetching:

    • Check this example on how to create a custom loader with extra contexts and initialize the framework with it
    • For enabling remote fetching (contexts, that are not in a core set, will be resolved from the network), you can use the following code when creating a custom loader:
      loader, err := jsonld.NewDocumentLoader(dbProvider,
        jsonld.WithRemoteDocumentLoader(ld.NewDefaultDocumentLoader(http.DefaultClient)))
      
  2. You can also add needed contexts thru API, here is an example with JS API.

@Vid201
Copy link
Author

Vid201 commented Jul 29, 2021

Cool, thanks for the detailed explanation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants