decentralized-identity / did-jwt

Create and verify DID verifiable JWT's in Javascript
Apache License 2.0
331 stars 70 forks source link

Add support for issuer as object #281

Closed vijayshiyani closed 1 year ago

vijayshiyani commented 1 year ago

As per the latest W3C VC Data Model specification, the issuer property can be represented as an object that includes an ID and a name. This would allow for more detailed information about the issuer to be included in the JWT.

example -------------- JWT payload ---------------

{
  "vc": {
    "@context": [
      "https://www.w3.org/2018/credentials/v1",
      "https://www.w3.org/2018/credentials/examples/v1"
    ],
    "id": "http://example.edu/credentials/3732",
    "type": [
      "VerifiableCredential",
      "UniversityDegreeCredential"
    ],
    "issuer": {
      "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
      "name": "Example University"
    },
    "issuanceDate": "2010-01-01T19:23:24Z",
    "credentialSubject": {
      "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
      "degree": {
        "type": "BachelorDegree",
        "name": "Bachelor of Science and Arts"
      }
    }
  },
  "iss": {
    "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
    "name": "Example University"
  },
  "nbf": 1262373804,
  "jti": "http://example.edu/credentials/3732",
  "sub": "did:example:ebfeb1f712ebc6f1c276e12ec21"
}

It would be great if the library could be updated to support both string and object formats for the issuer property.

Thank you!

more detail here https://www.w3.org/TR/vc-data-model/#example-usage-of-issuer-expanded-property

mirceanis commented 1 year ago

I think there's a bug in the VC data model example. The issuer property of a VC gets translated to the iss field, which, according to the JWT spec should be a string or URI.

The did-jwt-vc library deals with VC data format and translations between the JWT encoding and the W3C data model. did-jwt-vc uses this library as the base JWT layer. When an issuer with more properties is encountered in did-jwt-vc, only the id property is placed in the iss of the JWT payload. The rest of the object is kept intact.

Going through the VC data model spec now, I see there's no mention of only using the id property. I'm not sure if this was changed recently or if the spec only had stringOrURI issuer properties in an earlier version.

vijayshiyani commented 1 year ago

I agree with the above comment, There appears to be a bug in the VC Data model example. This is supported by information found in the VC JWT documentation, which can be found at the following link: https://w3c.github.io/vc-jwt/#issuer-iss