authyra 0.3.0
authyra: ^0.3.0 copied to clipboard
The session layer for Dart and Flutter apps with their own backend: persistence, safe token refresh, multi-account and reactive auth state.
Changelog #
All notable changes to the authyra package. All Authyra packages are released together with the same version.
0.3.0 #
A rewrite around one scope: the session layer of apps that talk to their own backend. Nobody used Authyra in production, so this release breaks freely and ships no migration.
Added #
Authyra: one entry point for sessions, replacingAuthyraClient,AuthyraInstance,SessionManagerandAccountManager. Create it withAuthyra(...)andstart(), orAuthyra.initialize(...).- Rotation-safe refresh: at most one refresh in flight per session, shared by every caller, with a compare-and-set on the tokens it replaces.
accessToken({key, rejectedToken}): a valid token for any session, refreshed first when about to expire or after the server rejected it.- Failure model: a refreshable session ends only on
RefreshRevokedException. Other refresh errors keep it and retry with exponential backoff (AuthyraConfig.retryDelay,maxRetryDelay). A session that cannot be refreshed ends when its access token is rejected or expires. - Refresh scheduling ahead of expiry (
AuthyraConfig.refreshThreshold), and before a known refresh-token expiry. - Multi-account:
sessions,switchTo(key),signIn(..., activate: false),signOutAll(). AuthState(AuthUnknown,AuthSignedIn(key, user),AuthSignedOut) andevents(SessionStartedEvent,SessionSwitchedEvent,SessionRefreshedEvent,SessionRefreshFailedEvent,SessionEndedEvent,SignInFailedEvent).AuthPolicy: allow or deny a sign-in, a session start or a switch.AuthTokens, withAuthTokens.expiringIn;AuthSession.providerDatafor credentials that are not session tokens.InMemoryAuthStorage, withentriesfor test assertions.- Sign-out revokes server-side through the provider, wins over an in-flight refresh, and yields to a new sign-in of the same identity.
Changed #
AuthProvideris stateless:signInreturns anAuthSignInResult,refreshreceives the session and returnsAuthTokens.CredentialsProvidertakessignIn,refreshandsignOutcallbacks.- Storage writes complete before memory changes, so a failed write never leaves the app ahead of the device.
Removed #
AuthyraClient,AuthyraInstance,SessionManager,AccountManager,TokenRefresher,AuthConfig,SessionRegistry.AuthyraPluginandAuthCallbacks: useAuthPolicyto gate andeventsto observe.AuthProviderTypeandAuthProvider.type.
0.2.0 #
Published to pub.dev from a state of the repository that has no tag. Superseded by 0.3.0.
0.1.0 - 2026-02-23 #
Added #
AccountManager: high-level multi-account facade withgetAll(),switchTo(),signOut(),signOutAll(), andcleanExpired().SessionManager.cleanExpiredSessions(): atomically prunes expired sessions and persists the full registry in one operation.AuthConfig.copyWith,toJson,fromJson: fully serialisable config withrefreshThresholdandtokenLifetimeDurationDurationgetters.AuthStateextendsEquatable: deduplicates identical consecutive states in streams, preventing unnecessary UI rebuilds.InMemoryStorage: non-persistentAuthStorageimplementation for tests and development.
Changed #
MultiAccountManagerrenamed toAccountManager(deprecated re-export kept until v0.2.0).
Fixed #
AccountManager.cleanExpired(): now delegates toSessionManager.cleanExpiredSessions()instead of overwriting a single session.AccountManager.signOut(): notifies the reactive layer after removing the active account.AuthSession.fromJson():accessTokenandexpiresAtare cast as nullable, fixing crashes in cookie-based flows.SessionRegistryaccount election after expiry removal now orders bylastUsedAt(deterministic).AuthUser.copyWith(): removed phantom parameters (phoneNumber,provider,createdAt) that were silently ignored.
0.0.1 - 2025-01-01 #
Added #
- Initial package scaffold.
AuthyraClient: stateless authentication orchestrator.AuthyraInstance: singleton wrapper with reactive streams.AuthProviderabstract interface withCredentialsProviderimplementation.AuthStorageabstract interface for pluggable session persistence.SessionManagerwith multi-account registry.AuthUser,AuthSession,AuthState,AuthConfig,SessionRegistrymodels