Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to keep payload fields when creating JWT VC/VP #431

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

mirceanis
Copy link
Member

During JSON <-> JWT transformation the fields that are mentioned in the vc-data-model encoding are removed by default.

This PR adds the option to keep the JSON fields in the JWT payload when creating verifiable credentials & presentations.

To keep the respective fields (effectively duplicating the data they contain) one can set the removeOriginalFields option to false:

Examples:

const verifiableCredential = await agent.createVerifiableCredential({
  credential: {
    issuer: { id: identifier.did },
    credentialSubject: {
      id: 'did:web:example.com',
      you: 'Rock',
    },
  },
  proofFormat: 'jwt',
  removeOriginalFields: false,
})
const verifiablePresentation = await agent.createVerifiablePresentation({
  presentation: {
    // ...
  },
  proofFormat: 'jwt',
  removeOriginalFields: false,
})

fixes #394

@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #431 (8214247) into next (0bf7b24) will decrease coverage by 1.78%.
The diff coverage is 64.35%.

❗ Current head 8214247 differs from pull request most recent head bc471e2. Consider uploading reports for the commit bc471e2 to get more accurate results

@@            Coverage Diff             @@
##             next     #431      +/-   ##
==========================================
- Coverage   67.58%   65.80%   -1.79%     
==========================================
  Files          62       68       +6     
  Lines        1530     1617      +87     
  Branches      247      265      +18     
==========================================
+ Hits         1034     1064      +30     
- Misses        400      452      +52     
- Partials       96      101       +5     

@mirceanis mirceanis merged commit 43923e1 into next Mar 26, 2021
@mirceanis mirceanis deleted the fix-keep-credential-subject-id branch March 26, 2021 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing credentialSubject.id property in JWT VC
2 participants