mikenicholson/passport-jwt

Extractor jwtFromRequest should be made asynchronous

eternalmatt opened this issue · 2 comments

I have a requirement to send the users a cookie of a uuid value, which maps to a JWT stored in a database. The database lookup returns on a promise, therefore I need to create an asyncronous jwtFromRequest extractor.

type extractor: (req) => Promise<string | undefined>

Looking at the code, I can see the token is fetched synchronously https://github.com/mikenicholson/passport-jwt/blob/v4.0.0/lib/strategy.js#L93

but if this could be converted to promise style or with an optional done callback, I would much appreciate it. And recommendations on implementation strategy?

implemented in rewrite.

Which rewrite?)