Implementing next auth adapter with a cache

so I've implemented an adapter for next auth which would try to cache certain things in memory via the code below and I was wondering if I made any notable or obvious mistakes with my code (if you don't notice any issues or think I did okay you can just react with 👍 if you don't want to send a message)
Solution:
okay so I'm gonna assume that there aren't any security issues with what I wrote, regardless I found some other issues 1. due to the way next-auth calls Adapter functions using the normal method for having a method on a class doesn't work you need to have member variables which are set to arrow functions instead 2. my lazy way of dealing with setTimeout via calling the window version was dumb and I ended up using ReturnType instead 3. setTimeout(at least the one Node provides) doesn't like getting a number that's bigger than a signed 32 bit integer can handle so I had to add a safety guard in the Cache setLifespan to max it out at 2^32 - 1...
Jump to solution
2 Replies
Solution
pagwin
pagwin16mo ago
okay so I'm gonna assume that there aren't any security issues with what I wrote, regardless I found some other issues 1. due to the way next-auth calls Adapter functions using the normal method for having a method on a class doesn't work you need to have member variables which are set to arrow functions instead 2. my lazy way of dealing with setTimeout via calling the window version was dumb and I ended up using ReturnType instead 3. setTimeout(at least the one Node provides) doesn't like getting a number that's bigger than a signed 32 bit integer can handle so I had to add a safety guard in the Cache setLifespan to max it out at 2^32 - 1
pagwin
pagwin16mo ago
the error message for point 1 is 'getSessionAndUser is not a function'(or something similar), just wanted to point that out to seo for Answer Overflow
Want results from more Discord servers?
Add your server