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

Send Accept header to universal resolver #1203

Conversation

jasny
Copy link
Contributor

@jasny jasny commented Jul 22, 2023

Issue

According to the latest draft of the DID Resolution standard (v0.3); if the value of the Accept HTTP header is absent, the HTTP response body should be the DID document and not the DID resolution.

To get the DID resolution as response, you should send the header

Accept: application/ld+json;profile="https://w3id.org/did-resolution"

See https://w3c-ccg.github.io/did-resolution/#bindings-https

Universal Resolver does not follow this part of the standard and returns a DID resolution if the Accept header is omitted. To get a DID document, you must send the header

Accept: application/did+ld+json

Solution

By explicitly sending the Accept header, the UniversalResolver plugin can also be used for other services (like ours) that implement DID Resolution v0.3.

What is being changed

An Accept header is added with the value application/ld+json;profile="https://w3id.org/did-resolution" when doing the HTTP request in resolve.

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 there are no existing tests for this class, and I am aware that a PR without tests will likely get rejected.

Details

screenshot-w3c-ccg github io-2023 07 21-20_32_06

Use `Accept: application/ld+json;profile="https://w3id.org/did-resolution"` to ensure the response is a DID resolution and not a DID document.
@jasny jasny marked this pull request as ready for review July 22, 2023 04:14
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.

looks good, thanks for the addition!

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (6981e68) 84.48% compared to head (f8ce4e5) 84.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1203      +/-   ##
==========================================
- Coverage   84.48%   84.48%   -0.01%     
==========================================
  Files         158      158              
  Lines       16625    16626       +1     
  Branches     1823     1823              
==========================================
  Hits        14046    14046              
- Misses       2579     2580       +1     
Impacted Files Coverage Δ
packages/did-resolver/src/universal-resolver.ts 84.88% <0.00%> (-1.00%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mirceanis mirceanis merged commit c86d918 into decentralized-identity:next Jul 24, 2023
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.

2 participants