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: Handle splitted next-auth.session-token cookie #167

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jals1212
Copy link

@jals1212 jals1212 commented Feb 16, 2024

πŸ”— Linked issue

#139
#160

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

  • Module options fills the runtimeConfig (private and public).
  • RuntimeConfig typings updated.
  • useAuth's sessionToken returns the cookie handled by makeSessionCookie (handles splitted session token).
  • NuxtAuthHandler uses getAuthJsSecret if receives no token from AuthConfig.
  • getServerToken uses makeCookiesFromHeaders to manage cookies.
  • Added end edited some utils:
  1. A - getAuthJsSecret: gets the secret from runtime or env vars.
  2. A - getConfigBaseUrl: gets the baseUrl from runtime or env vars.
  3. M - checkOrigin: uses getConfigBaseUrl
  4. M - getServerOrigin: uses getConfigBaseUrl.
  5. A - mergeCookieObject: merges cookies.
  6. A - makeSessionCookie: gets the next-auth.session-token (handles splitted session token).
  7. A - makeCookiesFromHeaders: manage multiple 'set-cookie' and makes native Headers.
  8. M - makeNativeHeaders: made it an utility.
  9. M - makeNativeHeadersFromCookieObject: uses makeNativeHeaders.
  • Added some tests.

Resolves the 'getServerToken returns null issue'.

#139
#160

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@jals1212 jals1212 marked this pull request as ready for review February 19, 2024 18:24
@jals1212 jals1212 changed the title Feature: Feature: Handle splitted next-auth.session-token cookie Feb 19, 2024
Hebilicious
Hebilicious previously approved these changes Feb 20, 2024
Copy link
Owner

@Hebilicious Hebilicious left a comment

Choose a reason for hiding this comment

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

This is looking great !
Thanks for working on this ❀️

@Hebilicious Hebilicious changed the title Feature: Handle splitted next-auth.session-token cookie feat: Handle splitted next-auth.session-token cookie Feb 20, 2024
@AndrewR3K
Copy link

AndrewR3K commented Jul 18, 2024

@Hebilicious Any progress on this PR? I am having the issue with getServerToken returning Null on the current npm version 😿

Thanks for this wonderful package, I hope to continue to use this.

@Hebilicious
Copy link
Owner

@Hebilicious Any progress on this PR? I am having the issue with getServerToken returning Null on the current npm version 😿

Thanks for this wonderful package, I hope to continue to use this.

Hello there.
The problem is that I don't personally use auth.js anymore and I have no easy way to test if this PR will break existing code ...
I'm also no longer maintaining this package, as the auth.js team never moved forward with their plans.
Now issues are piling up and I don't have the time, the incentive or the desire to fix them.
If someone is willing to test this PR, I would merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants