ObjectStackObjectStack

Auth

Auth protocol schemas

Authentication Service Protocol

Defines the standard API contracts for Identity, Session Management, and Access Control.

Source: packages/spec/src/api/auth.zod.ts

TypeScript Usage

import { AuthProvider, LoginRequestSchema, LoginType, RefreshTokenRequestSchema, RegisterRequestSchema, SessionSchema, SessionResponseSchema, SessionUserSchema, UserProfileResponseSchema } from '@objectstack/spec/api';
import type { AuthProvider, LoginRequest, LoginType, RefreshTokenRequest, RegisterRequest, Session, SessionResponse, SessionUser, UserProfileResponse } from '@objectstack/spec/api';

// Validate data
const result = AuthProvider.parse(data);

AuthProvider

Allowed Values

  • local
  • google
  • github
  • microsoft
  • ldap
  • saml

LoginRequest

Properties

PropertyTypeRequiredDescription
typeEnum<'email' | 'username' | 'phone' | 'magic-link' | 'social'>optional (default: "email")Login method
emailstringoptionalRequired for email/magic-link
usernamestringoptionalRequired for username login
passwordstringoptionalRequired for password login
providerstringoptionalRequired for social (google, github)
redirectTostringoptionalRedirect URL after successful login

LoginType

Allowed Values

  • email
  • username
  • phone
  • magic-link
  • social

RefreshTokenRequest

Properties

PropertyTypeRequiredDescription
refreshTokenstringRefresh token

RegisterRequest

Properties

PropertyTypeRequiredDescription
emailstring
passwordstring
namestring
imagestringoptional

Session

Properties

PropertyTypeRequiredDescription
idstring
expiresAtstring
tokenstringoptional
ipAddressstringoptional
userAgentstringoptional
userIdstring

SessionResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ session: object; user: object; token?: string }

Nested Shape: SessionResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: SessionResponse.data

PropertyTypeRequiredDescription
session{ id: string; expiresAt: string; token?: string; ipAddress?: string; … }Active Session Info
user{ id: string; email: string; emailVerified: boolean; name: string; … }Current User Details
tokenstringoptionalBearer token if not using cookies

SessionUser

Properties

PropertyTypeRequiredDescription
idstringUser ID
emailstringEmail address
emailVerifiedbooleanoptional (default: false)Is email verified?
namestringDisplay name
imagestringoptionalAvatar URL
usernamestringoptionalUsername (optional)
rolesstring[]optional (default: [])Assigned role IDs
tenantIdstringoptionalCurrent tenant ID
languagestringoptional (default: "en")Preferred language
timezonestringoptionalPreferred timezone
createdAtstringoptional
updatedAtstringoptional

UserProfileResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ id: string; email: string; emailVerified: boolean; name: string; … }

Nested Shape: UserProfileResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: UserProfileResponse.data

PropertyTypeRequiredDescription
idstringUser ID
emailstringEmail address
emailVerifiedbooleanoptional (default: false)Is email verified?
namestringDisplay name
imagestringoptionalAvatar URL
usernamestringoptionalUsername (optional)
rolesstring[]optional (default: [])Assigned role IDs
tenantIdstringoptionalCurrent tenant ID
languagestringoptional (default: "en")Preferred language
timezonestringoptionalPreferred timezone
createdAtstringoptional
updatedAtstringoptional

On this page