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

Allow DID parameters for verifiable credentials and presentations #1207

Merged

Conversation

jasny
Copy link
Contributor

@jasny jasny commented Jul 28, 2023

Fixes #1201

{
  credential: {
    issuer: { id: `${identifier.did}?versionTime=${versionTime}` },
    credentialSubject: {
      id: 'did:web:example.com',
      you: 'Rock',
    },
  },
  proofFormat: 'jwt',
}

Remove DID parameters in the issuer and holder properties when looking up the identifier using the DID manager. The DID manager doesn't handle DID parameters like versionTime. When the DID manager is used we should be able to safely ignore them. They're only used when resolving the DID.

What is being changed

Added options property to extractIssuer, with option removeParameters. Added a removeDIDParameters function to credential-utils.

The credentials-w3c, credentials-ld, and credentials-jwt plugins all remove the DID parameters before looking up the identifier via the DID manager. If the DID is resolved, the parameters are not removed.

Modified shortDid to always remove parameters.

Quality

Check all that apply:

  • I want these changes to be integrated
  • I successfully ran pnpm i, pnpm build, pnpm test, pnpm test:browser locally.
  • I allow my PR to be updated by the reviewers (to speed up the review process).
  • I added unit tests.
  • I added integration tests.
  • I did not add automated tests because _________, and I am aware that a PR without tests will likely get rejected.

No tests for:

  • credentials-jwt, because there are no existing tests
  • credentials-ld doesn't mock services, making it hard to test this feature

Remove DID parameters in the `issuer` and `holder` properties when looking up the identifier using the DID manager.
The DID manager doesn't handle DID parameters like `versionTime`. When the DID manager is used we should be able
 to savely ignore them. They're only used when resolving the DID.

Added `options` property to `extractIssuer`, with option `removeParameters`.
Added a `removeDIDParameters` function to credential-utils.

Modified `shortDid` to always remove parameters.

Fixes decentralized-identity#1201
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (7c8c6f1) 84.49% compared to head (eec1b7f) 84.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1207      +/-   ##
==========================================
+ Coverage   84.49%   84.51%   +0.02%     
==========================================
  Files         158      158              
  Lines       16636    16661      +25     
  Branches     1826     1829       +3     
==========================================
+ Hits        14056    14081      +25     
  Misses       2580     2580              
Files Changed Coverage Δ
...es/credential-eip712/src/agent/CredentialEIP712.ts 91.32% <100.00%> (+0.07%) ⬆️
packages/credential-ld/src/action-handler.ts 88.59% <100.00%> (+0.13%) ⬆️
packages/credential-w3c/src/action-handler.ts 82.00% <100.00%> (+0.10%) ⬆️
...ackages/selective-disclosure/src/action-handler.ts 66.56% <100.00%> (ø)
packages/utils/src/credential-utils.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mirceanis mirceanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this looks good and everything seems to work just fine.
I'm a bit concerned that using a regex to strip away the query parameters might lead to some weird corner cases. I'd be more comfortable with using a URL Parser.

@mirceanis
Copy link
Member

We'll merge this as-is since the main use of the url-stripping is for matching against lists of other DIDs.

Thank you for the contribution @jasny

@mirceanis mirceanis merged commit 688f59d into decentralized-identity:next Aug 1, 2023
11 checks passed
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.

[proposal] Support versionTime parameter when issuing a verifiable credential
2 participants