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

Issues with loading certain terms #58

Closed vongohren closed 2 years ago

vongohren commented 2 years ago

The following LD document(VC) has trouble running through a CBOR encode mechanism

"@context": [
      "https://www.w3.org/2018/credentials/v1",
      "https://credreg.net/ctdlasn/schema/context/json"
  ],
  "type": [
      "VerifiableCredential"
  ],
  "issuer": "did:key:z6MkpYpkXs9u5ZzV3nij3AbdmPkwmiBQvxNeNFiRPvNz5ArP",
  "issuanceDate": "2022-05-02T11:03:53Z",
  "credentialSubject": {
      "id": "did:key:z6MkfwmZep5ZvkHfeXszxhxEuvkmGFRc8H9Nv9ZaQG4vhFzZ",
      "schema:hasCredential": {
          "type": "ceterms:MicroCredential",
          "ceterms:name": "Ogi ogi",
          "ceterms:description": "This is a proof that things work!",
          "ceterms:relatedAction": {
              "type": "ceterms:CredentialingAction",
              "ceterms:startDate": "2022-05-02T09:03:48.964Z",
              "ceterms:endDate": "2022-05-04T09:03:48.964Z"
          },
          "ceterms:subject": [
              {
                  "type": "ceterms:CredentialAlignmentObject",
                  "ceterms:targetNodeName": {
                      "en-US": "Making sure you know Javascript"
                  }
              }
          ]
      }
  }

It complains on the schema:hasCredential term. Even if I can run this through a issuance and verification loop using the same documentLoader.

You can run the code under the CBor creat function to test: https://github.com/vongohren/cbor-ld-test

dlongley commented 2 years ago

Currently, CBOR-LD only supports JSON-LD with simple terms (non-CURIEs). This is because simple terms appear in the compression dictionary (the @context), allowing for maximum compression. We're looking into adding support for JSON-LD generally -- where any non-simple term JSON keys will be permitted and transformed, they will just not be highly compressed. This feature hasn't been implemented yet, though.

So, to use CBOR-LD before the above feature is implemented, every (non-keyword) JSON key needs its own term definition in the context.

dlongley commented 2 years ago

I should mention -- even once the above mentioned feature is added, if your use case is to have CBOR-LD travel in a QR code, you will want to use all simple terms anyway. Otherwise, it is very unlikely that your data will be sufficiently compressed to be scannable by common QR code scanners.

vongohren commented 2 years ago

@dlongley thanks for all these clarifying messages! Yeah I understand that we might have to redo our CBOR-LB credential for paper verification. But that should not be a big problem really. Just make sure that reissuances is allowed

vongohren commented 2 years ago

I close this now as most of my questions are resolved