Made getToken async by providing it callback capability
skyless opened this issue · comments
Hello!
I hope I'll be doing this right... Unless I'm mistaken, I didn't find any related issues/requests.
Describe the problem you'd like to have solved
While trying to implement a JWS into a JWE, I faced the issue that getToken function have to be async since I first have to asynchronously decrypt the JWT with the help of another library (jose), and only then I can return the contained JWS from whatever attribute.
Example:
getToken: async (req) => {
const { payload } = await jwtDecrypt(req.cookies['jwt_name'], Buffer.from('secret'));
return payload.claim;
},
Describe the ideal solution
From this library
token = await options.getToken(req);
or, I assume, rather provide a callback function by wrapping this call inside async.waterfall
.
Alternatives and current work-arounds
Except doing it without express-jwt, I'm not sure any workaround could be possible. But I'm not even sure this could be something already out of scope for this library anyway.
Additional context
None as far as I know.
done in v7