authyra 0.2.0
authyra: ^0.2.0 copied to clipboard
A unified authentication framework for Dart. Secure by default, flexible by design.
Changelog #
All notable changes to the authyra package are documented here.
[Unreleased] #
0.2.0 - 2026-03-24 #
Added #
TokenRefresher: background token-refresh scheduler with configurable check interval, expiry threshold, and linear retry policy. Owned bySessionManager; wired up byAuthyraClientat construction time.SessionManager.refreshActiveSession(): on-demand refresh delegating toTokenRefresherwith the same retry policy.SessionManager.setRefreshCallbacks(onSuccess, onFailure): hook forAuthyraClientto emitTokenRefreshEvent/SessionExpiredEventon refresh outcome.AutthyraClientBuilder: fluent builder for configuring and instantiatingAuthyraClientwith custom providers, storage, config, and event bus.AuthyraPlugin: extension interface for adding cross-cutting behaviour (audit logging, rate limiting, 2FA) viainstall(client)+ optionalonBeforeSignIn/onAfterSignIn/onSessionExpiredhooks. Registered viaAuthyraClient(plugins: [...])orAuthyraClientBuilder.addPlugin().AuthAccountmodel: provider-linked account entry with tokens andproviderData. Full serialisation andEquatable.SessionMetadatamodel: optional device/network context (ipAddress,userAgent,deviceId,country) attached to a session.- Typed
AuthSignInParamshierarchy:CredentialsSignInParams,OAuth2SignInParams,MagicLinkSignInParams,PhoneSignInParams. ReplacesMap<String, dynamic>for provider params. AuthyraClient.events: per-instanceAuthEventBuswith typedon<T>()/off<T>()listeners and a raw broadcaststream.- Auto-refresh in
getSession(): transparently refreshes the token when expiring soon (autoRefresh: true). EmitsSessionExpiredEventand returnsnullon failure. - Test suites for
SessionRegistry,InMemoryStorage,CredentialsProvider,SessionManager, andAuthyraClient(107+ tests).
Changed #
AuthSessionis now a pointer to the activeAuthAccount: token fields (accessToken,refreshToken,expiresAt,providerId) are computed getters delegating toactiveAccount. The new required fieldactiveAccountIdidentifies the active entry inlinkedAccounts. Storage format migrates gracefully from the legacy flat structure.AuthProvider.signInand all callbacks now acceptAuthSignInParams?instead ofMap<String, dynamic>?.AuthSession.linkedProviders: List<String>replaced bylinkedAccounts: List<AuthAccount>. AddedlinkedProviderIdsgetter and updatedhasLinkedProvider().fromJsonmigrates legacy format gracefully.AuthSessiongainsmetadata: SessionMetadata?;copyWith/toJson/fromJsonupdated.AuthEventBusis no longer a singleton — eachAuthyraClientowns its own instance.AuthyraClient.signInauto-generates anAuthAccountwhen the provider doesn't supply one.
Fixed #
AuthEventBus.on<T>(): switched toList<Function>with dynamic dispatch to fix Dart contravariance cast error.getSession()readsactiveSessiondirectly (bypassing expiry guard) before handing off to auto-refresh logic.
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