token_keeper 1.0.0 copy "token_keeper: ^1.0.0" to clipboard
token_keeper: ^1.0.0 copied to clipboard

Auth tokens, handled. Pure-Dart token manager with single-flight refresh, proactive expiry handling, Result-based APIs, event stream and a Dio interceptor for drop-in 401 retry.

Changelog #

All notable changes to this package will be documented in this file. The format follows Keep a Changelog and this project adheres to Semantic Versioning.

1.0.0 — 2026-05-02 #

Added #

  • Token model with JSON, equality, expiry helpers, and copyWith.
  • Result<T> / Success<T> / Failure<T> sealed types with FailureType enum (unauthorized, network, unknown).
  • TokenStorage interface plus InMemoryTokenStorage implementation.
  • TokenKeeper core with:
    • single-flight refresh (one in-flight refresh per keeper, even under 50+ concurrent calls),
    • proactive refresh via proactiveWindow,
    • withValidToken with bounded one-shot retry on unauthorized,
    • getValidToken, forceRefresh, setTokens, clear, peek,
    • lifecycle event stream (TokenRefreshedEvent, TokenClearedEvent, RefreshFailedEvent).
  • TokenKeeperInterceptor for Dio with attach + 401-refresh-and-retry.
  • RefreshRetryPolicy with built-in exponential backoff factory.
  • Pluggable TokenKeeperLogger and Clock / FixedClock for tests.
  • 37 unit tests covering single-flight, proactive refresh, retry policy, events, interceptor 401 handling, and edge cases.
0
likes
0
points
359
downloads

Publisher

verified publisherhimanshulahoti.is-a.dev

Weekly Downloads

Auth tokens, handled. Pure-Dart token manager with single-flight refresh, proactive expiry handling, Result-based APIs, event stream and a Dio interceptor for drop-in 401 retry.

Repository (GitHub)
View/report issues

Topics

#authentication #token #oauth #dio #interceptor

License

unknown (license)

Dependencies

dio, equatable, meta

More

Packages that depend on token_keeper