token_manager 0.2.2
token_manager: ^0.2.2 copied to clipboard
Single-flight OAuth/JWT token refresh for Dart: pluggable storage, an observable session state and typed refresh failures.
Changelog #
0.2.2 #
Clearer description, topics and recipes.
0.2.1 #
Internal refactor of the refresh engine; no behaviour change.
- The engine is split into smaller internal classes (refresh policy, serial queue, stored-token loader, session, refresh attempt). The public API and behaviour are unchanged.
- Docs:
TokenManageris also listed under the Streams category.
0.2.0 #
Single-flight refresh with typed failures and an observable session state; the 0.1 API stays available, deprecated.
TokenManager.createwithvalidToken,current,states,logout,authorizeandauthorizeStream.TokenStore<T>,TokenRefresher<T>,TokenInfo<T>,AuthState<T>,RefreshFailure(InvalidGrant,Transient),NotAuthenticated,Clock,InMemoryTokenStore<T>,TokenSetandTokenSetInfo.- Breaking:
setTokens(null)islogout()and also discards an in-flight refresh. - Breaking: the deprecated
tokensStreamnow suppresses consecutive identical tokens (distinct(identical)) and does not re-emit forRefreshingorAuthenticatedtransitions that carry the same tokens. - Breaking: the minimum SDK is 3.10.
- Breaking:
rxdartis no longer a dependency. - Breaking:
skewdefaults to 30 seconds; the oldrefreshThresholddefaulted to 3 minutes. Passskew: Duration(minutes: 3)to keep the old margin. - Breaking: there is no background proactive refresh any more, in the
deprecated API too. Refresh happens on
validToken,authorizeor a rejected token. Legacy users who relied oninfoDelegatefor refresh before expiry lose it until they move tovalidToken. Proactive refresh is planned for a later release. - Breaking:
initialize()no longer rewrites storage; it is a lazy load. It is still required when using the synchronous deprecatedtokensgetter or the 0.1 dio/grpc adapters, which never trigger a load. - Breaking: the deprecated
executeRefresh()no longer swallows non-Exceptionerrors (0.1 usedcatch (e)); aTypeErrorfrom a delegate now propagates. - Breaking: a failed store write after a refresh is not surfaced to the caller: the refreshed tokens stay in memory only and the store keeps the old pair until the next successful write.
- Breaking:
refreshDelayis ignored: there is no retry timer. A transient failure is retried by the next call tovalidToken. - A failed refresh no longer ends in a hang:
InvalidGrantsigns out and any other failure keeps the session. - Fixed: a refresh that failed, or returned a token already close to expiry, could deadlock the manager forever.
- Fixed: a refresh that finished after a login or logout overwrote the new session.
- Fixed: tokens were published before they were persisted.
- Fixed: a storage failure was reported as a refresh failure.
- Deprecated: the
TokenManagerconstructor withstorage,refreshDelegateandinfoDelegate; useTokenManager.create. - Deprecated:
tokens,tokensStream,initialize(),executeRefresh()andwaitForFresh. - Deprecated:
TokenStorage,TokenManagerRefreshDelegate,TokenInfoDelegateandRevokedTokensException.
0.1.0 #
Initial stable package structure for token lifecycle management.
TokenManager<T>with storage-backed state and refresh coordination.TokenStorage<T>,TokenInfoDelegate<T>, andTokenManagerRefreshDelegate<T>.- Public API documentation and usage examples.