Skip to main content

authyra 0.3.0 copy "authyra: ^0.3.0" to clipboard
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, replacing AuthyraClient, AuthyraInstance, SessionManager and AccountManager. Create it with Authyra(...) and start(), or Authyra.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) and events (SessionStartedEvent, SessionSwitchedEvent, SessionRefreshedEvent, SessionRefreshFailedEvent, SessionEndedEvent, SignInFailedEvent).
  • AuthPolicy: allow or deny a sign-in, a session start or a switch.
  • AuthTokens, with AuthTokens.expiringIn; AuthSession.providerData for credentials that are not session tokens.
  • InMemoryAuthStorage, with entries for 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 #

  • AuthProvider is stateless: signIn returns an AuthSignInResult, refresh receives the session and returns AuthTokens.
  • CredentialsProvider takes signIn, refresh and signOut callbacks.
  • 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.
  • AuthyraPlugin and AuthCallbacks: use AuthPolicy to gate and events to observe.
  • AuthProviderType and AuthProvider.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 with getAll(), switchTo(), signOut(), signOutAll(), and cleanExpired().
  • SessionManager.cleanExpiredSessions(): atomically prunes expired sessions and persists the full registry in one operation.
  • AuthConfig.copyWith, toJson, fromJson: fully serialisable config with refreshThreshold and tokenLifetimeDuration Duration getters.
  • AuthState extends Equatable: deduplicates identical consecutive states in streams, preventing unnecessary UI rebuilds.
  • InMemoryStorage: non-persistent AuthStorage implementation for tests and development.

Changed #

  • MultiAccountManager renamed to AccountManager (deprecated re-export kept until v0.2.0).

Fixed #

  • AccountManager.cleanExpired(): now delegates to SessionManager.cleanExpiredSessions() instead of overwriting a single session.
  • AccountManager.signOut(): notifies the reactive layer after removing the active account.
  • AuthSession.fromJson(): accessToken and expiresAt are cast as nullable, fixing crashes in cookie-based flows.
  • SessionRegistry account election after expiry removal now orders by lastUsedAt (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.
  • AuthProvider abstract interface with CredentialsProvider implementation.
  • AuthStorage abstract interface for pluggable session persistence.
  • SessionManager with multi-account registry.
  • AuthUser, AuthSession, AuthState, AuthConfig, SessionRegistry models
1
likes
150
points
211
downloads

Documentation

Documentation
API reference

Publisher

verified publishermeragix.dev

Weekly Downloads

The session layer for Dart and Flutter apps with their own backend: persistence, safe token refresh, multi-account and reactive auth state.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#authentication #session #oauth #security

License

MIT (license)

Dependencies

clock, logging

More

Packages that depend on authyra