digitalbazaar / cborld

A Javascript CBOR-LD processor for web browsers and Node.js apps.
https://json-ld.github.io/cbor-ld-spec/
BSD 3-Clause "New" or "Revised" License
16 stars 12 forks source link

Encoding fails with undefined term #60

Open filip26 opened 1 year ago

filip26 commented 1 year ago

Hi, try this example:

{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        "https://www.w3.org/2018/credentials/examples/v1",
        "https://w3id.org/security/suites/ed25519-2020/v1"
    ],
    "id": "http://example.edu/credentials/3732",
    "type": [
        "VerifiableCredential",
        "UniversityDegreeCredential"
    ],
    "issuer": "https://example.edu/issuers/565049",
    "issuanceDate": "2010-01-01T00:00:00Z",
    "credentialSubject": {
        "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
        "degree": {
            "type": "BachelorDegree",
            "name": "Bachelor of Science and Arts"
        }
    }
}

it fails with ERR_UNKNOWN_CBORLD_TERM: ... degree ... but degree is defined in https://www.w3.org/2018/credentials/examples/v1.

aljones15 commented 1 year ago

I believe the context needs to be in the registered contexts here: https://github.com/digitalbazaar/cborld/blob/main/lib/codecs/registeredContexts.js

I could be wrong about this one (haven't worked with cbor much)

https://www.w3.org/2018/credentials/examples/v1

I don't believe has a cbor-ld context yet.

dmitrizagidulin commented 1 year ago

Yeah, so, the VC 1.0 context IS registered with the cborld library, but the VC Examples context is not. (We should probably do that, for this exact reason - so that people can compile the example VC from the spec, to cborld)