/** * User & Authentication Domain Types * Defines user profiles, roles, permissions, and authentication */ import type { Email, Timestamp, UUID } from './common'; /** * User role within the system */ export type UserRole = 'admin' | 'owner' | 'editor' | 'viewer' | 'guest'; /** * Permission on a specific resource */ export type Permission = 'read' | 'write' | 'delete' | 'share' | 'invite' | 'manage_permissions' | 'manage_team' | 'manage_billing'; /** * User profile information */ export interface UserProfile { id: UUID; email: Email; name: string; displayName: string; avatar?: string; bio?: string; timezone: string; locale: string; phone?: string; createdAt: Timestamp; updatedAt: Timestamp; } /** * User account with authentication details */ export interface User extends UserProfile { username: string; role: UserRole; emailVerified: boolean; emailVerificationToken?: string; emailVerificationExpiresAt?: Timestamp; passwordHash: string; passwordChangedAt: Timestamp; passwordResetToken?: string; passwordResetExpiresAt?: Timestamp; twoFactorEnabled: boolean; twoFactorSecret?: string; lastLoginAt?: Timestamp; loginAttempts: number; lockoutUntil?: Timestamp; status: 'active' | 'inactive' | 'suspended' | 'deleted'; preferences: UserPreferences; } /** * User preferences and settings */ export interface UserPreferences { theme: 'light' | 'dark' | 'auto'; notifications: { email: boolean; push: boolean; inApp: boolean; collaborationUpdates: boolean; }; privacy: { profilePublic: boolean; showOnlineStatus: boolean; allowMessages: boolean; }; editor: { fontSize: number; fontFamily: string; lineHeight: number; autoSave: boolean; autoSaveInterval: number; }; } /** * Minimal user information for display */ export interface UserSummary { id: UUID; name: string; displayName: string; avatar?: string; email: Email; status: 'online' | 'away' | 'offline'; } /** * Authentication token with metadata */ export interface AuthToken { token: string; type: 'access' | 'refresh'; expiresAt: Timestamp; issuedAt: Timestamp; userId: UUID; } /** * Session information */ export interface Session { id: UUID; userId: UUID; token: string; refreshToken: string; userAgent: string; ipAddress: string; deviceName: string; expiresAt: Timestamp; createdAt: Timestamp; lastActivityAt: Timestamp; isRevoked: boolean; } /** * Role with specific permissions */ export interface RoleDefinition { role: UserRole; permissions: Permission[]; description: string; isSystem: boolean; } /** * User role assignment in a context (e.g., workspace, document) */ export interface UserRoleAssignment { userId: UUID; role: UserRole; assignedAt: Timestamp; assignedBy: UUID; expiresAt?: Timestamp; } /** * Invitation to join a workspace/team */ export interface Invitation { id: UUID; email: Email; role: UserRole; invitedBy: UUID; context: 'workspace' | 'team' | 'document'; contextId: UUID; token: string; status: 'pending' | 'accepted' | 'expired' | 'declined'; createdAt: Timestamp; expiresAt: Timestamp; acceptedAt?: Timestamp; } /** * Type guard to check if a user has a specific role */ export declare function hasRole(user: User, role: UserRole): boolean; /** * Type guard to check if a user has a specific permission */ export declare function hasPermission(permissions: Permission[], permission: Permission): boolean; //# sourceMappingURL=user.d.ts.map