fix(jwt): sort chunk cookies by key num index
โ๏ธ Reasoning
What changes are being made? What feature/bug is being fixed here?
I'm adding in a sort function on cookie chunks in the JWT SessionStore value to ensure that when these chunks are received in the wrong order from the browser that they are joined in the correct order and do not cause null sessions or JWE decryption errors in production.
๐งข Checklist
- [ ] Documentation
- [x] Tests
- [x] Ready to be merged
๐ซ Affected issues
- No issue on this repo was found
๐ Resources
- Contributing guidelines
- Code of conduct
- Contributing to Open Source
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
1 Ignored Deployment
| Name | Status | Preview | Updated |
|---|---|---|---|
| next-auth | โฌ๏ธ Ignored (Inspect) | Sep 21, 2022 at 7:42PM (UTC) |
Let's open an issue with a reproduction. We can re-open the PR if the issue is verified. :pray:
Let's open an issue with a reproduction. We can re-open the PR if the issue is verified. :pray:
I can look into creating a reproduction for you but I'm not sure next-auth controls the order of cookies coming in from the browser cookie header. We were seeing intermittent behavior on session calls which caused next-auth to unset the chunk cookies in return. The best way for us to repro was to reorder the cookies header in a curl copied from a session request in the browser.
I was thinking that my unit test would suffice showing the issue because it fails on your current branch without my code change.
Appreciate the attention and help. Thanks!
^ @balazsorban44
Let's open an issue with a reproduction. We can re-open the PR if the issue is verified. ๐
@balazsorban44
I've been using @sidebase/nuxt-auth for a project which uses next-auth under the hood, and yes, I can reproduce this for you.
There's an issue which describes the behaviour in more detail: https://github.com/sidebase/nuxt-auth/issues/293
I've also had this issue using @sidebase/nuxt-auth and have traced the root cause to this module.
Let's open an issue with a reproduction. We can re-open the PR if the issue is verified. ๐
Could we re-open this now the issue is werified?
I see this has been fixed in another PR and merged in the latest versions. Tested this in the @sidebase/nuxt-auth package and everything works as expected with regards to the chunked JWT session cookie.
@codetheorist In which version of @sidebase/nuxt-auth is this working correctly?