juice_auth 0.5.0
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. RefreshTokenEventisResultEvent<AuthSession>andsingleflight(it wasdroppable).await auth.sendForResult(RefreshTokenEvent())returns the refreshed session or throwsNoRefreshTokenError/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.
loginAttemptsstayed 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
unknownfor 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 leavesunknown—unauthenticatedhere — once the restore has answered. Route guards that wait for the session (juice_auth_routing) depend on it; the contract is documented onAuthStatus.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_storageup 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 aresequential. - Replaced the public
refreshInFlightcompleter with framework-levelEventConcurrency.droppable. Overlapping refresh triggers still collapse to one provider call, while consumers continue observingisRefreshingand the resulting session state.
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-refreshTimerpath (scheduleRefresh→TokenExpiryEvent→RefreshTokenEvent), and singleflight collapse of concurrentRefreshTokenEvents into a single provider call.
Changed #
doc/SPEC.mdreconciled 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.0andjuice_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 lifecycleAuthStatewithAuthStatusenum (unknown,unauthenticated,authenticated,sessionExpired)AuthProviderinterface — provider-agnostic contract for auth backendsAuthCredentialshierarchy —EmailCredentials,OAuthCredentials,ApiKeyCredentials,BiometricCredentialsLoginUseCase— authenticates via provider, persists tokens, emits stateLogoutUseCase— atomic cleanup of tokens, storage, and sessionRefreshTokenUseCase— singleflight token refresh withCompleterRestoreSessionUseCase— reads stored tokens on init, refreshes if validAuthConfig— providers map, refresh buffer, rate limiting, storage prefixAuthErrorsealed hierarchy —ProviderAuthError,RefreshFailedError,RateLimitedError, etc.- Rebuild groups —
auth:status,auth:user,auth:session,auth:error - Aviators —
loginSuccess,logoutComplete,sessionExpired - Secure token persistence via
juice_storageStorageBloc - Login rate limiting — configurable max attempts with cooldown