-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Token expiration test is not accurate #77
Comments
There's minimal cost in refreshing a token, so it makes sense to refresh if it expires in the next minute (?), rather than waiting for it to expire |
Yes, that's a good point. The token refresh strategy isn't ideal yet. Happy to hear ideas 🙏 |
@thorwebdev I've already got an open PR to set up automatic token refreshes (#78) - I'd be happy to add this
to that PR if it works for you? It'd basically be
|
Thanks @dabarrell, yah, I think that makes sense. I also commented on your PR, thanks for that! One note, we're currently revamping our repo setup (#75) and then are hoping to get this in right after 👍 |
@thorwebdev In that case I'll wait for #75 to be merged to save a messy rebase :) |
🎉 This issue has been resolved in version 1.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The math in at least two pieces of code yields up to 1/2 second expired token because of rounding.
utils/getUser.ts
utils/getAccessToken.ts
const timeNow = Math.round(Date.now() / 1000);
jwtUser.exp < timeNow yields:
I also don't believe it is useful to have a token verified as good from cache if it can expire before even leaving the function call. What good is a token that expires before it can even be used?
The text was updated successfully, but these errors were encountered: