(token: string)
| 36 | * @returns The `exp` value in Unix seconds, or `null` if unparseable |
| 37 | */ |
| 38 | export function decodeJwtExpiry(token: string): number | null { |
| 39 | const payload = decodeJwtPayload(token) |
| 40 | if ( |
| 41 | payload !== null && |
| 42 | typeof payload === 'object' && |
| 43 | 'exp' in payload && |
| 44 | typeof payload.exp === 'number' |
| 45 | ) { |
| 46 | return payload.exp |
| 47 | } |
| 48 | return null |
| 49 | } |
| 50 | |
| 51 | /** Refresh buffer: request a new token before expiry. */ |
| 52 | const TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1000 |
no test coverage detected