// Shared types for MyAIDev Method Web Server export interface User { id: string; username: string; email: string; passwordHash: string | null; linuxUsername: string; createdAt: number; updatedAt: number; isActive: boolean; emailVerified: boolean; failedLoginAttempts: number; lastLoginAt: number | null; } export interface Session { id: string; userId: string; tokenHash: string; ipAddress: string | null; userAgent: string | null; createdAt: number; expiresAt: number; isRevoked: boolean; revokedAt: number | null; } export interface OAuth2Provider { id: string; userId: string; provider: "google" | "github" | "microsoft"; providerUserId: string; providerEmail: string | null; accessToken: string | null; refreshToken: string | null; tokenExpiresAt: number | null; createdAt: number; updatedAt: number; } export interface AuditLog { id: string; userId: string | null; action: string; resourceType: string | null; resourceId: string | null; ipAddress: string | null; userAgent: string | null; details: string | null; createdAt: number; } // JWT Payload - compatible with jose library export interface JWTPayload { sub: string; // user id username: string; email: string; iat: number; exp: number; jti: string; // session id [key: string]: unknown; // Index signature for jose compatibility } // API Request/Response types export interface RegisterRequest { username: string; email: string; password: string; } export interface LoginRequest { email: string; password: string; } export interface AuthResponse { user: { id: string; username: string; email: string; emailVerified: boolean; }; token: string; } // Error types export class AuthError { readonly _tag = "AuthError"; constructor( readonly code: string, readonly message: string, readonly cause?: unknown ) {} } export class ValidationError { readonly _tag = "ValidationError"; constructor( readonly field: string, readonly message: string ) {} } export class DatabaseError { readonly _tag = "DatabaseError"; constructor( readonly message: string, readonly cause?: unknown ) {} }