authjs-nuxt icon indicating copy to clipboard operation
authjs-nuxt copied to clipboard

feat: Handle splitted next-auth.session-token cookie

Open jals1212 opened this issue 1 year ago โ€ข 2 comments

๐Ÿ”— Linked issue

#139 #160

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • [x] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [x] โœจ 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

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

jals1212 avatar Feb 16 '24 22:02 jals1212

@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.

AndrewR3K avatar Jul 18 '24 00:07 AndrewR3K

@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.

Hebilicious avatar Jul 19 '24 06:07 Hebilicious