digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

Normalization options differ from pyld #480

Open lemoustachiste opened 2 years ago

lemoustachiste commented 2 years ago

Hi,

I was facing another normalization issue today and I have found that with javascript we use jsonld.normalize with expandContext https://github.com/digitalbazaar/jsonld.js/blob/main/lib/jsonld.js#L536, while pyld does not offer the same option https://github.com/digitalbazaar/pyld/blob/master/lib/pyld/jsonld.py#L247.

We use pyld on the issuing side and jsonld.js on the verification side, so having different options for normalize yields a different result.

Given this context:

[
    "https://www.w3.org/2018/credentials/v1",
    {
      "Blockcerts": {
        "@id": "bc:Blockcerts",
        "@type": "@id"
      }
    },
    "https://w3id.org/blockcerts/v3"
],

With JS, I have this output:

<urn:uuid:41015b98-fc99-447c-b211-ef6782147fb3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/blockcerts#Blockcerts> .

While with PY, I have this one:

<urn:uuid:41015b98-fc99-447c-b211-ef6782147fb3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <bc:Blockcerts> .

So I can stop passing the expandContext option, but I'd like to understand the implication of doing so. And also, why this option is not available in Python?