Open Vid201 opened 3 years ago
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.
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:
loader, err := jsonld.NewDocumentLoader(dbProvider,
jsonld.WithRemoteDocumentLoader(ld.NewDefaultDocumentLoader(http.DefaultClient)))
You can also add needed contexts thru API, here is an example with JS API.
Cool, thanks for the detailed explanation.
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 2a52bb79077635cffd69021d403a8cdfc3149fe8).