useAuth
Session state on top of src/lib/authToken.ts. The access token lives in memory only, so script on the page cannot read it from storage; the refresh token is an httpOnly cookie the server reads. Nothing touches localStorage.
Install: pnpm add-composable useAuth
Lifecycle showcase
Sign in and out to see the reactive state. A reload starts signed out: call refresh() on boot to restore the session from the cookie.
API
user(Ref<TUser | null>): The signed-in user. Cleared whenever the token is, from anywhere.token(ComputedRef<string | null>): The in-memory access token, read from authToken.ts.isAuthenticated(ComputedRef<boolean>): A token is held. Follows clearAuthToken() calls made elsewhere, such as the app’s onUnauthorized.loading(Ref<boolean>): login() or fetchUser() is in flight.login((credentials) => Promise<data>): POSTs to the login route with credentials, then stores the returned token and user.setSession((accessToken, user?) => void): Stores a session your own code obtained (SSO callback, invite link).fetchUser(() => Promise<TUser | null>): Loads the user from the me route. Signs out if that fails.refresh(() => Promise<boolean>): Trades the refresh cookie for a new access token. Shares one request with the axios interceptor.logout(() => Promise<void>): Signs out here and asks the server to drop the refresh cookie.configureAuth((paths: Partial<AuthEndpoints>) => void): Separate export. Points login, refresh, logout and me at your routes; call once in main.ts.