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
1. User authenticates → better-auth issues token
2. Token stored in expo-secure-store (encrypted, hardware-backed)
3. Token read from secure store on app launch
4. Token injected into ObjectStackClient via useMemo
5. Client attaches token to all API requests (Authorization header)
6. On sign-out: token cleared from secure store + client rebuilt
Server errors are parsed into user-friendly messages without exposing:
Internal server details
Stack traces
Database error messages
API endpoint paths
// lib/error-handling.tsexportfunctionparseError(error: unknown): ObjectStackError{// Structured error → mapped to user-friendly message// Unknown error → generic "Something went wrong" message// Never exposes raw error to user}
Local Storage Security
SQLite Database
Control
Implementation
Location
App-private directory (OS sandbox)
Journal mode
WAL (Write-Ahead Logging)
Access
Only accessible by this app process
Encryption
Planned (SQLCipher integration)
MMKV Storage
Control
Implementation
Instance ID
objectstack-metadata (isolated namespace)
Content
Non-sensitive metadata only
Access
App-private, OS-sandboxed
Secure Store
Control
Implementation
iOS
Keychain Services (hardware-backed)
Android
Keystore System (hardware-backed)
Content
Auth tokens only
Access
Biometric/passcode required (configurable)
Session Management
Session Lifecycle
App Launch
↓
Check expo-secure-store for token
↓
┌── Token exists? ──┐
│ │
▼ Yes ▼ No
│ │
Validate token Show sign-in
(authClient.useSession)
↓
┌── Valid? ──┐
│ │
▼ Yes ▼ No
│ │
Main app Clear token
Show sign-in
Session Timeout
Policy
Implementation
Token expiry
Handled by better-auth (auto-refresh)
Background timeout
Implemented (Phase 4A.6) — lock screen after inactivity via lib/app-lock.ts
Biometric unlock
Implemented (Phase 4A.6) — Face ID / Fingerprint via lib/biometric-auth.ts
Input Validation
Client-Side Validation
Validation
Location
Implementation
Required fields
FormViewRenderer
Check field.required before submit
Field type
FieldRenderer
Type-appropriate keyboard and format
Email format
FieldRenderer
Email regex validation
URL format
FieldRenderer
URL pattern validation
Number range
FieldRenderer
Min/max bounds check
String length
FieldRenderer
Character limit enforcement
Server-Side Validation
All mutations are validated server-side. Client validation is advisory only — the server is the source of truth.
try{awaitcreate(formData);}catch(err){constparsed=parseError(err);if(parsed.code==="VALIDATION_ERROR"){// Show field-level errors from parsed.details}}
Filter Input Sanitization
Query builder filters are serialized through a type-safe pipeline:
User input → SimpleFilter object → serializeFilter() → ObjectQL AST → Server
No raw user input is sent directly to the server.
Error Handling Security
Principles
Never expose internal details — Error messages shown to users are generic
Never log sensitive data — No tokens, passwords, or PII in logs
Structured errors — All errors go through parseError() pipeline
Error Boundary
// components/common/ErrorBoundary.tsx// Catches React rendering errors// Shows recovery UI with retry button// Prevents crash from exposing app internals
Error Code Mapping
Every server error code is mapped to a safe, user-friendly message:
constERROR_MESSAGES: Record<ObjectStackErrorCode,string>={UNAUTHORIZED: "Your session has expired. Please sign in again.",FORBIDDEN: "You don't have permission to perform this action.",NOT_FOUND: "The requested resource was not found.",// ... (no technical details exposed)};
No sensitive data in local storage (only secure store)
All user input is sanitized before use
Dependencies checked for known vulnerabilities
Release
Dependency vulnerability scan passed
TypeScript strict mode enabled
ESLint security rules passing
No development/debug code in production build
App signing keys properly secured
This document covers the security architecture as of the current implementation. See ARCHITECTURE.md for the overall system architecture and ROADMAP.md for planned security enhancements.