-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
perf: replace jsonwebtoken with jose #8217
perf: replace jsonwebtoken with jose #8217
Conversation
The jose package has 0 dependencies and is tree shakable ESM. So we get lower actual bundle size and get rid of 10 dependencies.
@AlessioGr On the quest for lower bundle size this will reduce payload bundle size from 4,008 KB to 3,824 KB (4.6% reduction). In addition there are some security concerns with the lodash packages included in jsonwebtoken. Ref the comment here: auth0/node-jsonwebtoken#933 (comment) All in all jose seems more modern, updated and is ESM. I have used it successfully in other projects instead of jsonwebtoken. I have also checked that the generated token with my change is same as before using the debugger on https://jwt.io/ |
Hey @andershermansen good PR! We will review shortly. I think we will be able to merge it. THANK YOU!!! |
@jmikrut @AlessioGr Any concerns about the change? Or just still waiting for code review? |
No concerns atm, just need to find time to review |
I reviewed this PR. Code wise it all seems fine. I don't see a lot of difference between the two packages though: https://bundlephobia.com/package/[email protected] https://bundlephobia.com/package/[email protected]. |
@DanRibbens The payload package will still be reduced by 4,6% if this is included if my calculations are correct. I have calculated it like this: and the last commit before it (6d1a287): File sizes:
That is a 92kB reduction in size. (92 / 2020 = 4,6%) Jose is fully ESM and tree shakable while jsonwebtoken is not. You also get rid of 10 dependencies, some of which are discouraged and will not be updated by loadash in newer versions. See https://lodash.com/per-method-packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 This is included in version v3.0.0-beta.117 |
Can we get the For context I am using a custom passkeys authentication and I would prefer not to duplicate internal payload code since it might break in between updates. |
I would also love to see jwtSign exported, or better yet, payload Local API to support an operation for verifyToken() |
The jose package has 0 dependencies and is tree shakable ESM.
So we get lower bundle size and get rid of 10 dependencies.