(token: string, bufferSeconds = 24 * 60 * 60)
| 35 | } |
| 36 | |
| 37 | export function isTokenExpired(token: string, bufferSeconds = 24 * 60 * 60): boolean { |
| 38 | const decoded = decodeToken(token) |
| 39 | |
| 40 | if (!decoded?.exp) { |
| 41 | return true |
| 42 | } |
| 43 | |
| 44 | const expiresAt = decoded.exp |
| 45 | const bufferTime = Math.floor(Date.now() / 1000) + bufferSeconds |
| 46 | return expiresAt < bufferTime |
| 47 | } |
| 48 | |
| 49 | export function isTokenValid(token: string): boolean { |
| 50 | return !isTokenExpired(token, 0) |
no test coverage detected