/** * Type definitions for Firefox Relay MCP Server * * This module contains all type definitions used throughout the application, * following golden-standard programming practices for maximal type safety * and programmatic excellence. */ import type { z } from 'zod/v4'; /** * Firefox Relay API response for a relay address (email mask) */ export interface FirefoxRelayAddress { id: number; address: string; domain: string; full_address: string; enabled: boolean; description: string; generated_for: string; block_list_emails: boolean; used_on: string | null; mask_type: string; created_at: string; last_modified_at: string; last_used_at: string | null; num_forwarded: number; num_blocked: number; num_level_one_trackers_blocked: number; num_replied: number; num_spam: number; } /** * Request payload for creating a new Firefox Relay address */ export interface CreateRelayAddressRequest { description?: string; enabled?: boolean; generated_for?: string; block_list_emails?: boolean; used_on?: string; } /** * Response from Firefox Relay API for creating a new address */ export interface CreateRelayAddressResponse { id: number; address: string; domain: string; full_address: string; enabled: boolean; description: string; generated_for: string; block_list_emails: boolean; used_on: string | null; mask_type: string; created_at: string; last_modified_at: string; last_used_at: string | null; } /** * Update request for a Firefox Relay address */ export interface UpdateRelayAddressRequest { description?: string; enabled?: boolean; block_list_emails?: boolean; used_on?: string; } /** * Database schema for storing Firefox Relay email addresses */ export interface DatabaseRelayAddress { id: number; relay_id: number; full_address: string; description: string; enabled: boolean; created_at: string; last_modified_at: string; last_used_at: string | null; num_forwarded: number; num_blocked: number; num_replied: number; num_spam: number; } /** * Database schema for email logs */ export interface DatabaseEmailLog { id: number; relay_address_id: number; email_id: string; sender: string; recipient: string; subject: string; received_at: string; read_at: string | null; body: string | null; body_encrypted: boolean; otp_code: string | null; is_otp: boolean; headers: string | null; headers_encrypted: boolean; size: number; } /** * Database schema for API key management */ export interface DatabaseApiKey { id: number; key_hash: string; description: string; created_at: string; last_used_at: string | null; is_active: boolean; permissions: string[]; } /** * Database schema for audit logs */ export interface DatabaseAuditLog { id: number; timestamp: string; action: string; user_id: string | null; target_id: string | null; target_type: string | null; details: string | null; details_encrypted: boolean; ip_address: string | null; user_agent: string | null; } /** * Configuration for the MCP Server */ export interface McpServerConfig { name: string; version: string; apiKey: string; databasePath: string; encryptionKey: string; port: number; host: string; enableLogging: boolean; logLevel: 'debug' | 'info' | 'warn' | 'error'; } /** * Context for MCP tool execution */ export interface ToolExecutionContext { toolName: string; requestId: string; timestamp: string; userId: string | null; sessionId: string | null; } /** * Result returned by an MCP tool handler */ export interface ToolResult { content: Array<{ type: 'text'; text: string; }>; isError: boolean; } /** * Internal definition of an MCP tool, used to register tools with the server */ export interface MCPTool { name: string; description: string; inputSchema: z.ZodTypeAny; handler: (input: unknown, context?: Record) => Promise; } /** * Extracted OTP information from an email */ export interface OtpExtractionResult { code: string | null; provider: string | null; type: string | null; expiresAt: string | null; confidence: number; } /** * Email content for processing */ export interface EmailContent { id: string; from: string; to: string[]; subject: string; body: string; html: string | null; headers: Record; receivedAt: string; attachments: EmailAttachment[]; } /** * Email attachment information */ export interface EmailAttachment { id: string; filename: string; contentType: string; size: number; } /** * Result of processing an email */ export interface ProcessedEmail { email: EmailContent; otpInfo: OtpExtractionResult | null; isOtpEmail: boolean; extractedLinks: string[]; securityFlags: SecurityFlag[]; } /** * Security flags for email content */ export type SecurityFlag = 'phishing_suspected' | 'malware_detected' | 'spam_patterns' | 'unencrypted_sensitive_data' | 'suspicious_links' | 'mismatched_sender' | 'otp_security_warning' | 'otp_in_subject'; /** * Standard response wrapper for API operations */ export interface ApiResponse { success: boolean; data: T | null; error: ApiError | null; timestamp: string; requestId: string; } /** * Error type for API operations */ export interface ApiError { code: string; message: string; details: Record | null; timestamp: string; } /** * Paginated response wrapper */ export interface PaginatedResponse { items: T[]; total: number; page: number; pageSize: number; hasMore: boolean; nextCursor: string | null; previousCursor: string | null; } /** * Schema for validating email addresses */ export interface EmailValidationResult { isValid: boolean; email: string; domain: string; localPart: string; errors: string[]; } /** * Schema for rate limiting */ export interface RateLimitStatus { requestsMade: number; requestsAllowed: number; resetAt: string; isLimited: boolean; } /** * Result of a database operation */ export type DatabaseResult = Promise<{ success: boolean; data?: T; error?: Error; }>; /** * Callback for logging operations */ export type Logger = { debug: (message: string, context?: Record) => void; info: (message: string, context?: Record) => void; warn: (message: string, context?: Record) => void; error: (message: string, context?: Record) => void; }; /** * Empty object type */ export type EmptyObject = Record; /** * Make all properties optional */ export type PartialBy = Omit & Partial>; /** * Remove undefined from type */ export type WithoutUndefined = { [P in keyof T]: Exclude; }; /** * Default configuration values */ export declare const DEFAULT_CONFIG: Partial; /** * Firefox Relay API constants */ export declare const FIREFOX_RELAY_CONSTANTS: { BASE_URL: string; AUTH_HEADER: string; AUTH_PREFIX: string; USER_AGENT: string; TIMEOUT_MS: number; RATE_LIMIT_DELAY: number; MAX_RETRIES: number; }; /** * Database constants */ export declare const DATABASE_CONSTANTS: { PRAGMA_JOURNAL_MODE: string; PRAGMA_SYNCHRONOUS: string; PRAGMA_FOREIGN_KEYS: string; ENCRYPTION_ALGORITHM: string; KEY_DERIVATION_ITERATIONS: number; }; /** * Security constants */ export declare const SECURITY_CONSTANTS: { MAX_EMAIL_BODY_SIZE: number; MAX_ATTACHMENT_SIZE: number; MAX_SUBJECT_LENGTH: number; MAX_SENDER_LENGTH: number; MAX_RECIPIENTS: number; OTP_PATTERN: RegExp; SUSPICIOUS_DOMAINS: string[]; }; //# sourceMappingURL=index.d.ts.map