You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authentication for Bun with Laravel-like guards, providers, and unified auth utilities.
Overview
@ninots/auth is the authentication package for the Ninots Framework: guards, user providers, hashing, JWT, OAuth helpers, and encryption.
Session storage lives in @ninots/session. This package only defines a local SessionInterface / AuthSessionStore seam that the app injects (adapter). Zero @ninots/* cross-deps.
Features
Guards: SessionGuard, TokenGuard, RequestGuard
Providers: DatabaseUserProvider
Hashers: BcryptHasher, ArgonHasher
Session seam: SessionInterface / AuthSessionStore (inject from app)
bun add @ninots/auth
# Session drivers (file / cookie / database):
bun add @ninots/session
Quick Start
Basic Session Authentication
import{SessionGuard,DatabaseUserProvider,BcryptHasher,typeAuthSessionStore,}from'@ninots/auth';// App-owned adapter: wrap @ninots/session (or any store) as AuthSessionStoreconstsession: AuthSessionStore=appSessionAdapter;// from your bootstrapconstprovider=newDatabaseUserProvider(connection,newBcryptHasher(),'users');constguard=newSessionGuard('web',provider,session);constauthenticated=awaitguard.attempt({email: 'user@example.com',password: 'secret'},true,// remember me);if(authenticated){constuser=awaitguard.user();console.log(`Welcome, ${user?.getAuthIdentifier()}!`);}
Guards are tested against an in-memory fake implementing SessionInterface (tests/mocks/session.mock.ts).
Changelog highlights
0.2.0
Breaking (SemVer minor in 0.y.z): removed public session stack (SessionManager, Session, file/memory/database drivers). Use @ninots/session + app adapter into AuthSessionStore / SessionInterface.
Added AuthSessionStore type alias for the injected seam.