question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expect transformCredentialInput to move top-level props of W3C credentials inside vc

See original GitHub issue

Based on my reading of the W3C spec, it seems as though top-level optional props like evidence and credentialSubject should be copied inside the vc claim in the resulting JWT encoded credential.

However, when you pass transformCredentialInput an arg of type CredentialPayload they are copied to the top level of the JWT:

const cred = {
  '@context': ['https://www.w3.org/2018/credentials/v1'],
  credentialSubject: {
    id: 'did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4',
    bar: 'baz',
  },
  evidence: { foo: 'bar' },
  type: ['VerifiableCredential'],
};

transformCredentialInput(cred);

Results in

{
  vc: {
    credentialSubject: { bar: 'baz' },
    '@context': [ 'https://www.w3.org/2018/credentials/v1' ],
    type: [ 'VerifiableCredential' ]
  },
  evidence: { foo: 'bar' },
  sub: 'did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4'
}

Expect

{
  vc: {
    credentialSubject: { bar: 'baz' },
    '@context': [ 'https://www.w3.org/2018/credentials/v1' ],
    type: [ 'VerifiableCredential' ],
    evidence: { foo: 'bar' }
  },
  sub: 'did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4'
}

A workaround is to move the props inside a manually constructed vc object. But then it’s unclear whether all of the props should be manually transformed to match the JwtCredentialPayload type or left for the transformation function to handle.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mirceaniscommented, Apr 20, 2021

yes, and the same for the presentation transforms.

Also it loosely relates to #64 since it relates to JWT-JSON payload conversion.

1reaction
joshbax189commented, Apr 20, 2021

Also, normalizeCredential has the inverse problem:

normalizeCredential({
      vc: {
          credentialSubject: { bar: 'baz' },
          '@context': [ 'https://www w3 org/2018/credentials/v1' ],
          type: [ 'VerifiableCredential' ],
          evidence: { foo: 'bar' }
        },
      sub: 'did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4'
    })

Result

{
  proof: {},
  vc: { evidence: { foo: 'bar' } },
  credentialSubject: {
    bar: 'baz',
    id: 'did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4'
  },
  issuer: {},
  type: [ 'VerifiableCredential' ],
  '@context': [ 'https://www.w3.org/2018/credentials/v1' ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Verifiable Credentials Data Model v1.1 - W3C
This specification provides a mechanism to express these sorts of credentials on the Web in a way that is cryptographically secure, ...
Read more >
Verifiable Credentials Implementation Guidelines 1.0 - W3C
This specification decouples the identity provider concept into two distinct concepts: the issuer and the holder. issuer: A role an entity can ...
Read more >
Verifiable Credentials Use Cases - W3C
A verifiable claim is a qualification, achievement, quality, or piece of information about an entity's background such as a name, government ID, ...
Read more >
Verifiable Credentials Working Group Charter - W3C
The Working Group will maintain the Verifiable Credentials Data Model specification, which provides a mechanism to express a verifiable credential on the Web...
Read more >
Verifiable Credentials Working Group Charter - W3C
Registries for the data model to support extension points in the normative deliverables. Algorithms for the expression and verification of proofs that use ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found