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

Add JWT and DID dereference() #339

Merged
merged 28 commits into from
Dec 11, 2023
Merged

Add JWT and DID dereference() #339

merged 28 commits into from
Dec 11, 2023

Conversation

mistermoe
Copy link
Member

@mistermoe mistermoe commented Dec 7, 2023

What's Changed

@web5/dids

Added DidResolver.dereference here

resolves the DID contained in the DID URL to a DID document, and then extracts and returns the specific part of the document identified by the fragment in the DID URL


Added a DidResource type here which represents all of the resources present in a DID Document e.g. services, verification methods etc.


Added a isVerificationMethod utility function here that acts as a type guard for DidResource

@web5/credentials

Separated all JWT related functionality from VerifiableCredential into a Jwt class here


Handrolled Jwt.verify and dropped did-jwt as a dependency. did-jwt is a chonker and uses a number of deprecated third party libs.


Refactored VerifiableCredential and PresentationExchange methods to consistently use options objects.


Refactored VerifiableCredential methods to consistently be async.


Important

Removed VerifiedJwt type as it's no longer being used anywhere. this type was previously exported which means this is a breaking change for any downstream consumers who were using this type

Warning

  • VerifiableCredential.create is now an async method.
  • VerifiableCredential.verify & VerifiableCredentials.parseJwt method signatures changed to take options object as input.
  • PresentationExchange method signatures changed to take options object as input.

@web5/crypto

Added JwtHeaderParams and JwtPayload types.


Dramatically improves performance of randomUuid() function:

Before:

┌─────────┬───────────────────────┬──────────────┬────────────────────┬───────────┬─────────┐
│ (index) │       Task Name       │   ops/sec    │ Average Time (ns)  │  Margin   │ Samples │
├─────────┼───────────────────────┼──────────────┼────────────────────┼───────────┼─────────┤
│    0    │       'uuidv4'        │ '6,015,626'  │ 166.2337190237164  │ '±2.49%'  │ 601563  │
│    1    │  'utils.randomUuid'   │  '567,477'   │ 1762.1839950610192 │ '±17.89%' │  56748  │
└─────────┴───────────────────────┴──────────────┴────────────────────┴───────────┴─────────┘

After:

┌─────────┬───────────────────────┬──────────────┬────────────────────┬──────────┬─────────┐
│ (index) │       Task Name       │   ops/sec    │ Average Time (ns)  │  Margin  │ Samples │
├─────────┼───────────────────────┼──────────────┼────────────────────┼──────────┼─────────┤
│    0    │       'uuidv4'        │ '6,254,233'  │ 159.89170818373506 │ '±2.22%' │ 625424  │
│    1    │  'utils.randomUuid'   │ '13,852,305' │  72.1901496571959  │ '±1.51%' │ 1385231 │
└─────────┴───────────────────────┴──────────────┴────────────────────┴──────────┴─────────┘

Copy link

codesandbox bot commented Dec 7, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

github-actions bot commented Dec 7, 2023

TBDocs Report

✅ No errors or warnings

@web5/api

  • Project entry file: packages/api/src/index.ts

TBDocs Report Updated at 2023-12-11T19:46:53Z 679e74c

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Merging #339 (679e74c) into main (2a38d1c) will increase coverage by 0.11%.
Report is 1 commits behind head on main.
The diff coverage is 97.04%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
+ Coverage   92.71%   92.82%   +0.11%     
==========================================
  Files          75       76       +1     
  Lines       16838    17267     +429     
  Branches     1577     1607      +30     
==========================================
+ Hits        15611    16028     +417     
- Misses       1201     1212      +11     
- Partials       26       27       +1     
Components Coverage Δ
api 96.94% <ø> (ø)
common 97.78% <ø> (ø)
credentials 94.56% <96.24%> (+0.40%) ⬆️
crypto 100.00% <100.00%> (ø)
dids 91.87% <93.81%> (+0.07%) ⬆️
agent 88.08% <ø> (ø)
identity-agent 56.81% <ø> (ø)
proxy-agent 58.43% <ø> (ø)
user-agent 55.22% <ø> (ø)

@mistermoe mistermoe marked this pull request as ready for review December 7, 2023 19:50
Copy link
Contributor

@nitro-neal nitro-neal 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 to me!

Co-Authored-By: kirahsapong  <[email protected]>
@mistermoe
Copy link
Member Author

@frankhinek is taking a look at some of the tests breaking in @web5/agent due to version discrepancies

@frankhinek frankhinek changed the title Verify jwt Add CompactJwt and DID dereference() Dec 10, 2023
@frankhinek frankhinek added enhancement New feature or request dependencies Pull requests that update a dependency file credentials SSI functionality labels Dec 10, 2023
@frankhinek frankhinek changed the title Add CompactJwt and DID dereference() Add JWT and DID dereference() Dec 11, 2023
@frankhinek frankhinek self-requested a review December 11, 2023 20:18
@mistermoe mistermoe merged commit 78c2de2 into main Dec 11, 2023
29 checks passed
@mistermoe mistermoe deleted the verify-jwt branch December 11, 2023 20:24
LiranCohen pushed a commit that referenced this pull request Jan 9, 2024
* Separate and refactor JWT related functionality
* add `DidResolver.dereference`
---------

Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: Frank Hinek <[email protected]>
Co-authored-by: kirahsapong <[email protected]>
Co-authored-by: nitro-neal <[email protected]>
finn-tbd pushed a commit that referenced this pull request Mar 19, 2024
* Separate and refactor JWT related functionality
* add `DidResolver.dereference`
---------

Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: Frank Hinek <[email protected]>
Co-authored-by: kirahsapong <[email protected]>
Co-authored-by: nitro-neal <[email protected]>
finn-tbd pushed a commit that referenced this pull request Mar 19, 2024
* Separate and refactor JWT related functionality
* add `DidResolver.dereference`
---------

Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: Frank Hinek <[email protected]>
Co-authored-by: kirahsapong <[email protected]>
Co-authored-by: nitro-neal <[email protected]>
finn-tbd pushed a commit that referenced this pull request Mar 19, 2024
* Separate and refactor JWT related functionality
* add `DidResolver.dereference`
---------

Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: Frank Hinek <[email protected]>
Co-authored-by: kirahsapong <[email protected]>
Co-authored-by: nitro-neal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
credentials SSI functionality dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants