ISO 8601 expiry timestamp (or empty string).
Consider the session expired aheadMs milliseconds
before its real expiry (default 0 = real expiry).
Optionalzone: string
IANA timezone for offset-less inputs; defaults to the runtime system zone.
true if the expiry is past (or within aheadMs) or cannot be parsed, false otherwise.
Check whether an ISO 8601 expiry timestamp has passed or is malformed.
Semantics:
false(no expiry recorded yet, e.g. fresh instance)true(defensive: corruption is treated as expired so the caller reauthenticates instead of silently trusting stale state)truefalse(subject toaheadMsbelow)Pre-emptive refresh: pass
aheadMs > 0to treat a token as expired while it still has that much lifetime left. This letsensureSessionrenew the session before the real expiry tick, so no request ever pays the full re-auth round-trip in its critical path. The common value is 5 minutes (5 * 60 * 1000).Offset-less ISO strings — the format some upstreams persist their expiry in — are interpreted in the supplied
zone. Without a zone, the runtime's system timezone is used. Strings with an explicitZor±HH:MMoffset are parsed as absoluteTemporal.Instants, ignoringzone.