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: jwt utilities #1973

Merged
merged 1 commit into from
Apr 8, 2024
Merged

feat: jwt utilities #1973

merged 1 commit into from
Apr 8, 2024

Conversation

davidyuk
Copy link
Member

@davidyuk davidyuk commented Apr 5, 2024

This PR is supported by the Æternity Foundation

based on #1967

@davidyuk davidyuk added this to the v13.3.0 milestone Apr 5, 2024
@davidyuk davidyuk requested review from thepiwo and CedrikNikita April 5, 2024 06:50
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 80.38%. Comparing base (677bcf5) to head (c747ce6).
Report is 1 commits behind head on develop.

Files Patch % Lines
src/utils/jwt.ts 94.59% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1973      +/-   ##
===========================================
+ Coverage    80.28%   80.38%   +0.09%     
===========================================
  Files          103      104       +1     
  Lines         3530     3568      +38     
  Branches       758      767       +9     
===========================================
+ Hits          2834     2868      +34     
- Misses         382      383       +1     
- Partials       314      317       +3     

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

const payload = JSON.parse(this.payloadAsJson);
if (!this.includeSubJwk) payload.sub_jwk = undefined;
// TODO: expose account used in aepp-wallet connection
return signJwt(payload, this.aeSdk._resolveAccount(this.aeSdk.address));
Copy link
Member Author

@davidyuk davidyuk Apr 5, 2024

Choose a reason for hiding this comment

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

I will figure out a fix for this later 😢

payload.sub_jwk = {
kty: 'OKP',
crv: 'Ed25519',
x: toBase64Url(decode(account.address)),
Copy link
Member Author

Choose a reason for hiding this comment

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

https://datatracker.ietf.org/doc/html/draft-ietf-jose-cfrg-curves-06#section-2
is it based on something like this? In the next chapter "Ed25519" defined, but I can't find it in "JSON Web Elliptic Curve" registry.
Initially I found "sub_jwk" in https://www.iana.org/assignments/jwt/jwt.xhtml

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've exported the jwk key via the jose library and that was the format

Copy link
Collaborator

@thepiwo thepiwo left a comment

Choose a reason for hiding this comment

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

looks very good to me, tried and compared it with other libraries and matches expected outputs

@davidyuk davidyuk merged commit 73eddfc into develop Apr 8, 2024
5 checks passed
@davidyuk davidyuk deleted the feature/jwt-sign branch April 8, 2024 00:33
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.

3 participants