@brabander/auth-core
v0.0.2
Published
This library was generated with [Nx](https://nx.dev).
Readme
auth-core
This library was generated with Nx.
Framework-agnostic session domain model (AuthSession, isSessionActive)
and a SessionStore contract for reading and writing the current session.
Concrete implementations (e.g. backed by localStorage) live in a
platform-specific adapter, see @brabander/auth-react.
This package does not verify credentials or perform a login — that is application-specific and out of scope here. It only defines what a session looks like and how to persist one.
Gebruik
AuthSession beschrijft een sessie (token + optionele expiresAt).
isSessionActive bepaalt of zo'n sessie nog geldig is:
import { AuthSession, isSessionActive } from '@brabander/auth-core';
const session: AuthSession = { token: 'abc123', expiresAt: null };
isSessionActive(session); // true — verloopt nooit
const expiredSession: AuthSession = {
token: 'abc123',
expiresAt: '2026-01-01T00:00:00.000Z',
};
isSessionActive(expiredSession); // false zodra expiresAt in het verleden ligtSessionStore is het platform-agnostische contract voor het opslaan/lezen
van een sessie (getSession, setSession, clearSession, subscribe).
Deze package bevat zelf geen implementatie — zie @brabander/auth-react
voor een concrete, localStorage-backed adapter plus React-hook/context.
Running unit tests
Run nx test auth-core to execute the unit tests via Vitest.
