AuthResource on figranium.auth handles server setup, session authentication, and user identity. Use it to initialize a fresh Figranium server, authenticate with email and password, and retrieve the currently logged in user. Session-based methods require new Figranium({ session: true }). For API key authentication details, see Authentication.
Methods
checkSetup
checkSetup
- HTTP endpoint:
GET /api/auth/check-setup
check-setup.ts
setup
setup
checkSetup returns { setupRequired: true }. No credentials are required for this call.- HTTP endpoint:
POST /api/auth/setup
first-setup.ts
login
login
new Figranium({ session: true })). In Node.js, supply a cookie-aware fetch implementation because the default fetch does not preserve cookies.- HTTP endpoint:
POST /api/auth/login
session-login.ts
Session-only endpoints like
login, logout, and me require session: true. API key clients should not call these methods.logout
logout
- HTTP endpoint:
POST /api/auth/logout
logout.ts
me
me
User type is { id?: string; name: string; email: string }.- HTTP endpoint:
GET /api/auth/me
me.ts
Return types
checkSetupreturns{ setupRequired: boolean }setupreturns{ success: boolean }loginreturns{ success: boolean }logoutreturns{ success: boolean }mereturns{ user: User }whereUser = { id?: string; name: string; email: string }
Error handling
All methods throwFigraniumError on failure. Common cases include invalid credentials on login, missing session on me, and calling setup on an already-initialized server. See Errors for details on status codes, error codes, and retry behavior.