Changelog - 2026-11-03
Session hooks see every token change, and the unauthenticated rejection is configurable
New Feature EnhancementIn one line. onSessionStarted now fires for a token refreshed by your network service's 401 recovery, onSessionCleared fires for a cleanUp made outside the provider, and a guest app can set what checkAuth and a 401 reject with.
The example is in Guest apps.
What changed
DefaultAuthService.subscribe({ listener })(@venizia/ardor-kernel). It runs after everysaveAuthandcleanUpand returns a function that stops it. A listener that throws is logged and does not break the save.- A token change fires
onSessionStarted.DefaultAuthProviderlistens, so a refresh that saves the new token withsaveAuth, from the provider or from your network service, calls the hook with the newtoken. There is no separate refresh hook. The once-per-change and ordering guarantees are unchanged. - A new reason,
external. AcleanUpmade by other code, such as youronAuthFailure, callsonSessionCleared({ reason: SessionClearReasons.EXTERNAL }).logoutand the 401 branch keeplogoutandunauthorized. unauthenticatedRejection({ reason })(@venizia/ardor-admin). It returns the valuecheckAuth(reasonrejected) and the 401 branch ofcheckError(reasonunauthorized) reject with. The default is the old{ redirectTo: loginPagePath }, so an app that overrides nothing behaves as before.- A 401 can keep the session. When the rejection has
logoutUser: false, the provider does not runcleanUpand does not callonSessionCleared. The revoked token stays stored and keeps going out, so clear or replace it yourself (for example inonAuthFailure), or every request keeps answering 401. dispose(). The provider listens to the auth service from its constructor. Build one provider per service (a second one calls every hook again), and calldispose()on one you discard.- New exports.
IAuthRejection, andSessionClearReasons.EXTERNAL. The admin size limit goes from 10.5 kB to 10.65 kB (a repository gate).
Who is affected
- A guest app with no login page. Override
unauthenticatedRejection.{ message: false }alone still redirects to/login;checkAuthneedsredirectTo: falsetoo. - An app that syncs a socket or a cache in
onSessionStarted. It now also runs after a refresh your network service makes. Make the hook safe to run for a new token. - A token written straight to
localStorage. Still not seen. Save it withDefaultAuthService.saveAuth. - All other apps. No action needed.
See Auth provider and Guest apps.