@vaporauth/core
v0.2.0
Published
Core JavaScript client for VaporAuth backends
Downloads
541
Readme
@vaporauth/core
Core JavaScript client for VaporAuth backends.
Install
npm i @vaporauth/coreUsage
import { createClient } from '@vaporauth/core';
const auth = createClient({
url: 'https://api.example.com'
});
const signIn = await auth.auth.signInWithPassword({
email: '[email protected]',
password: 'secret'
});
if (signIn.error) {
console.error(signIn.error.message);
}API
createClient({ url, ... })createServer({ url, cookies, fetch, ... })auth.signInWithPassword({ email, password })auth.signOut({ scope?: 'global' | 'local' })auth.getSession()auth.getUser()auth.refreshSession(refreshToken?)auth.setSession(session | null)auth.fetch(input, init?)auth.onAuthStateChange((event, session) => void)
Notes
- Expects backend endpoints:
POST /auth/tokenGET /auth/mePOST /auth/logout
- Includes browser + memory + cookie storage adapters.
- Supports cross-tab sync (
BroadcastChannel+ storage events) and auto-refresh. - SSR-focused wrappers are available in
@vaporauth/ssr.
