digitalbazaar / ecdsa-sd-2023-cryptosuite

A selective disclosure Data Integrity cryptosuite based on ECDSA for use with jsonld-signatures.
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

jsonld.ValidationError: Safe mode validation error. #11

Closed OR13 closed 1 year ago

OR13 commented 1 year ago

When processing examples from v2 spec.

Caused by:

https://github.com/digitalbazaar/di-sd-primitives/blob/3c530765e1605b0180ed7b996695a5a60f1fce2c/lib/skolemize.js#L49

Prevents testing of selective disclosure with contexts like:

"@context": [
    "https://www.w3.org/ns/credentials/v2",
    "https://www.w3.org/ns/credentials/examples/v2"
  ],
...
OR13 commented 1 year ago

Digging into the error (which is trapped, and not surfaced for developers)... its caused by this:

    {
      type: [ 'JsonLdEvent' ],
      code: 'invalid @language value',
      level: 'warning',
      message: '@language value must be valid BCP47.',
      details: { language: 'test lang 0' }
    }

The error is accurate, for the example I am using:

Which looks like this:

{
  "@context": [
    "https://www.w3.org/ns/credentials/v2",
    "https://www.w3.org/ns/credentials/examples/v2"
  ],
  "id": "http://university.example/credentials/3732",
  "type": [
    "VerifiableCredential",
    "ExampleDegreeCredential"
  ],
  "issuer": {
    "id": "https://university.example/issuers/565049",
    "name": [
      {
        "value": "test value 0",
        "lang": "test lang 0",
        "dir": "rtl"
      },
      {
        "value": "test value 1",
        "lang": "test lang 1",
        "dir": "ltr"
      },
      {
        "value": "test value 2",
        "lang": "test lang 2",
        "dir": "rtl"
      },
      {
        "value": "test value 3",
        "lang": "test lang 3",
        "dir": "ltr"
      },
      {
        "value": "test value 4",
        "lang": "test lang 4",
        "dir": "rtl"
      }
    ]
  },
  "validFrom": "2015-05-10T12:30:00Z",
  "credentialSubject": {
    "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
    "degree": {
      "type": "ExampleBachelorDegree",
      "subtype": "Bachelor of Science and Arts"
    }
  }
}
OR13 commented 1 year ago

Fixed by adjusting the example to:

{
  "@context": [
    "https://www.w3.org/ns/credentials/v2",
    "https://www.w3.org/ns/credentials/examples/v2"
  ],
  "id": "http://university.example/credentials/3732",
  "type": [
    "VerifiableCredential",
    "ExampleDegreeCredential"
  ],
  "issuer": {
    "id": "https://university.example/issuers/565049",
    "name": [
      {
        "value": "test value 0",
        "lang": "en"
      },
      {
        "value": "test value 1",
        "lang": "en"
      },
      {
        "value": "test value 2",
        "lang": "en"
      },
      {
        "value": "test value 3",
        "lang": "en"
      },
      {
        "value": "test value 4",
        "lang": "en"
      }
    ]
  },
  "validFrom": "2015-05-10T12:30:00Z",
  "credentialSubject": {
    "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
    "degree": {
      "type": "ExampleBachelorDegree",
      "subtype": "Bachelor of Science and Arts"
    }
  }
}