Check if the stored access token is expired or near expiry. Returns `true` if the token expires within the next 30 seconds.
(bundle: &OidcTokenBundle)
| 80 | /// |
| 81 | /// Returns `true` if the token expires within the next 30 seconds. |
| 82 | pub fn is_token_expired(bundle: &OidcTokenBundle) -> bool { |
| 83 | let Some(expires_at) = bundle.expires_at else { |
| 84 | // No expiry info — assume valid. |
| 85 | return false; |
| 86 | }; |
| 87 | let now = std::time::SystemTime::now() |
| 88 | .duration_since(std::time::UNIX_EPOCH) |
| 89 | .unwrap_or_default() |
| 90 | .as_secs(); |
| 91 | now + 30 >= expires_at |
| 92 | } |
| 93 | |
| 94 | #[cfg(test)] |
| 95 | mod tests { |
no outgoing calls
no test coverage detected