secure_token_manager 0.1.0
secure_token_manager: ^0.1.0 copied to clipboard
A production-grade, platform-aware secure authentication token lifecycle manager for Flutter with single-flight concurrent refresh protection.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.1.0 - 2026-09-24 #
Added #
- Core
TokenDatamodel with secret redaction intoString(), JSON serialization, and immutable value equality. ClockandSystemClockabstractions for deterministic expiration testing.TokenStorageinterface andMemoryTokenStorageimplementation for testing and development.- Platform-aware
SecureTokenStorageimplementation leveraging:- Android KeyStore (AES-GCM encryption with RSA-OAEP key wrapping).
- Apple iOS & macOS Keychain Services (
KeychainAccessibility.first_unlock). - Windows Data Protection API (DPAPI).
- Linux Secret Service API (
libsecret).
- Explicit web platform boundary throwing
PlatformNotSupportedExceptionto prevent insecurelocalStoragefallbacks. - Single-flight
RefreshCoordinatorprotecting against concurrent refresh race conditions and the thundering herd problem. - Monotonically increasing session epoch guard preventing logout race conditions (stale in-flight refresh response discarding).
- Comprehensive error taxonomy with
TokenExceptionand concrete typed exceptions distinguishing transient network errors from authentication-invalidating errors. - Reactive
AuthStatesealed class hierarchy (unknown,unauthenticated,authenticated,refreshing,error). - Non-sensitive
AuthEventstream for APM, Crashlytics, and analytics monitoring. - Zero-dependency architecture decoupled from any specific HTTP client (Dio, Chopper,
package:http). - Complete interactive example Flutter application demonstrating concurrent requests, single-flight refresh protection, and logout race handling.
- Comprehensive test suite with 59 tests covering concurrency, storage failures, leeway skew, and lifecycle transitions.