Client-side auth/session library for OSHUN mobile and web surfaces.
The canonical customer auth/session contract now lives in
src/customer-auth-model.ts and src/types.ts.
Includes#
- Canonical customer auth/session model for one OSHUN customer identity across Tara, Veritas, Nyx, Arete, Nisaba, and Metis
- Surface-specific policy publication for web, installable PWA, and mobile transport/storage boundaries
- Typed
AuthClientwith login/logout/refresh/current-user helpers - Email/password and social-provider sign-in support
- Proactive/expired token refresh handling with single-flight refresh protection
- Pluggable
AuthTransportabstraction FetchAuthTransportimplementation for shared HTTP auth calls- Pluggable
SessionStoreabstraction with in-memory and key-value implementations - Secure-session persistence helpers (
SecureSessionStore, browser storage adapter, Expo secure-storage adapter) with token/profile/session-metadata policy checks (expiry windows, payload limits, fail-closed reads) OshunSsoCoordinatorfor single sign-on state shared across Tara, Veritas, Nyx, Arete, and Nisaba- Sync adapters for SSO propagation (
createInMemorySsoSyncAdapter,createBroadcastChannelSsoSyncAdapter) - Shared
OshunProfileStorefor profile identity/stats/domain-state across mobile and web - Shared
OshunPreferencesStorefor theme/language/notification preferences across mobile and web - Shared
OshunPrivacyStorefor privacy settings, consent controls, and consent ledger snapshots - Shared
OshunDataRightsStorefor account data export/deletion request UX state across mobile and web - Shared
OshunBillingStorefor billing status, invoice history, and payment recovery flows across mobile and web - Shared entitlement schema and evaluators for tier/domain/feature access
(
entitlements.ts) - Shared profile-to-entitlements mapping + denial copy helpers for shell
middleware gates (
entitlement-context.ts) - Shared subscription catalog + plan upgrade recommendation helpers for purchase
entry points (
subscription-offers.ts) - Transport security policy controls for HTTPS enforcement, host allowlists, and
certificate pinning strategy hooks (
transport-security.ts) - Session management APIs for device revocation (
listSessions,revokeSession,revokeAllSessions,signOutAll) - Session expiry validation and typed auth errors
Canonical Surface Rules#
web: same-origin BFF session withHttpOnlyrefresh/session cookie; access token is treated as memory-only runtime statepwa: identical auth/session contract to web because the installable PWA is the same browser-origin runtimemobile: bearer access token plus rotating refresh token backed by secure device storage; no plain AsyncStorage session persistence
Nx Targets#
pnpm nx run @oshun/auth-client:buildpnpm nx run @oshun/auth-client:lintpnpm nx run @oshun/auth-client:typecheckpnpm nx run @oshun/auth-client:test