Check if the access token is valid and not about to expire.
Decodes the JWT payload, extracts the expiry time, and compares it to the
current time with a 5-minute buffer. If the token is expiring soon, this
function automatically requests a refresh.
Calls are debounced to prevent excessive validation checks; the same token
will not be validated more frequently than CHECK_DEBOUNCE_MS.
Returns Promise<boolean>
true if the token is valid and not expiring soon, false otherwise.
Example
constvalid = awaitisTokenValid(); if (!valid) { // Token is invalid or will expire soon; user should be logged out awaitclearAuthStore(); goto('/login'); }
Check if the access token is valid and not about to expire.
Decodes the JWT payload, extracts the expiry time, and compares it to the current time with a 5-minute buffer. If the token is expiring soon, this function automatically requests a refresh.
Calls are debounced to prevent excessive validation checks; the same token will not be validated more frequently than CHECK_DEBOUNCE_MS.