Skip to main content

juice_auth 0.5.0 copy "juice_auth: ^0.5.0" to clipboard
juice_auth: ^0.5.0 copied to clipboard

Authentication lifecycle management for Juice applications. Provider-agnostic login, token refresh, session persistence, and reactive auth state.

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.5.0 - 2026-11-10 #

Changed #

  • Requires juice ^2.1.0.
  • RefreshTokenEvent is ResultEvent<AuthSession> and singleflight (it was droppable). await auth.sendForResult(RefreshTokenEvent()) returns the refreshed session or throws NoRefreshTokenError / RefreshFailedError; a refresh requested while one runs joins it — one provider call, every caller answered. refreshToken() is unchanged.
  • The token-refresh timer is the bloc's own keyed sendAfter.

Fixed #

  • A login cooldown that had run out never cleared. loginAttempts stayed at the maximum, so the first attempt after every cooldown armed the next one and no attempt reached the provider again. An expired cooldown now clears itself and the count before the attempt proceeds. The attempt after the Nth failure still arms the cooldown without reaching the provider.
  • A failed restore whose cleanup also failed left the status unknown for ever. When reading the stored session threw and clearing the stale tokens then threw too, the restore ended without emitting. The cleanup is now guarded and recorded, and the status always leaves unknown — unauthenticated here — once the restore has answered. Route guards that wait for the session (juice_auth_routing) depend on it; the contract is documented on AuthStatus.unknown.

0.4.0 - 2026-10-14 #

Changed #

  • Requires juice ^2.0.0. No API change in this package: the bump carries the core's breaking set (doc/guides/upgrading-to-2.0.md).
  • Accepts juice_storage up to <4.0.0 (3.0.0 is its 2.0-wave bump; same API).

0.3.0 - 2026-08-12 #

Changed #

  • Requires juice ^1.6.0.
  • Declared concurrency for every auth event. Initialization, login, logout, refresh, and token-expiry handoff are droppable; user updates are sequential.
  • Replaced the public refreshInFlight completer with framework-level EventConcurrency.droppable. Overlapping refresh triggers still collapse to one provider call, while consumers continue observing isRefreshing and the resulting session state.

0.2.2 - 2026-06-16 #

Changed #

  • Allow juice_storage 2.0.0 (Hive CE migration). No API change.

0.2.1 - 2026-05-28 #

Added #

  • Tests covering the README's previously-unverified refresh-scheduling claims: the past-window immediate-fire branch of scheduleRefresh, the auto-refresh Timer path (scheduleRefresh → TokenExpiryEvent → RefreshTokenEvent), and singleflight collapse of concurrent RefreshTokenEvents into a single provider call.

Changed #

  • doc/SPEC.md reconciled with the shipping implementation; added an Implementation Notes section documenting intentional divergences (code is the source of truth).

0.2.0 - 2026-04-18 #

Changed #

  • Updated dependencies to juice: ^1.4.0 and juice_storage: ^1.2.0
  • Refreshed README examples to use the current AuthBloc.withConfig(..., storageBloc: ...) setup pattern

0.1.0 - 2026-02-14 #

Added #

  • Initial release of juice_auth
  • AuthBloc — primary bloc managing authentication lifecycle
  • AuthState with AuthStatus enum (unknown, unauthenticated, authenticated, sessionExpired)
  • AuthProvider interface — provider-agnostic contract for auth backends
  • AuthCredentials hierarchy — EmailCredentials, OAuthCredentials, ApiKeyCredentials, BiometricCredentials
  • LoginUseCase — authenticates via provider, persists tokens, emits state
  • LogoutUseCase — atomic cleanup of tokens, storage, and session
  • RefreshTokenUseCase — singleflight token refresh with Completer
  • RestoreSessionUseCase — reads stored tokens on init, refreshes if valid
  • AuthConfig — providers map, refresh buffer, rate limiting, storage prefix
  • AuthError sealed hierarchy — ProviderAuthError, RefreshFailedError, RateLimitedError, etc.
  • Rebuild groups — auth:status, auth:user, auth:session, auth:error
  • Aviators — loginSuccess, logoutComplete, sessionExpired
  • Secure token persistence via juice_storage StorageBloc
  • Login rate limiting — configurable max attempts with cooldown
0
likes
150
points
102
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Authentication lifecycle management for Juice applications. Provider-agnostic login, token refresh, session persistence, and reactive auth state.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#authentication #bloc #state-management #token #session

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

flutter, juice, juice_storage

More

Packages that depend on juice_auth