/**
 * Prompt Injection Defense
 * Detects and prevents prompt injection attacks on AI models
 * Vorion Security Platform
 */
import { EventEmitter } from 'events';
import { InjectionDetectionResult, DetectedPattern, InjectionPatternType, PromptTemplate } from './types';
/**
 * Injection detection configuration
 */
export interface InjectionDetectionConfig {
    enabled: boolean;
    strictMode: boolean;
    blockOnDetection: boolean;
    sensitivityLevel: 'low' | 'medium' | 'high';
    customPatterns: InjectionPattern[];
    whitelistedPatterns: string[];
    maxInputLength: number;
    enableContextOverflowDetection: boolean;
    enableEncodingAttackDetection: boolean;
}
/**
 * Custom injection pattern definition
 */
export interface InjectionPattern {
    id: string;
    name: string;
    type: InjectionPatternType;
    pattern: RegExp;
    severity: 'low' | 'medium' | 'high' | 'critical';
    description: string;
    enabled: boolean;
}
/**
 * Prompt template storage interface
 */
export interface TemplateStorage {
    save(template: PromptTemplate): Promise<void>;
    get(templateId: string): Promise<PromptTemplate | null>;
    delete(templateId: string): Promise<void>;
    list(): Promise<PromptTemplate[]>;
}
/**
 * In-memory template storage
 */
export declare class InMemoryTemplateStorage implements TemplateStorage {
    private templates;
    save(template: PromptTemplate): Promise<void>;
    get(templateId: string): Promise<PromptTemplate | null>;
    delete(templateId: string): Promise<void>;
    list(): Promise<PromptTemplate[]>;
}
/**
 * Prompt Injection Detector
 * Analyzes inputs for injection attempts and sanitizes them
 */
export declare class PromptInjectionDetector extends EventEmitter {
    private config;
    private patterns;
    private templateStorage;
    private encodingPatterns;
    constructor(config?: Partial<InjectionDetectionConfig>, templateStorage?: TemplateStorage);
    /**
     * Initialize encoding attack detection patterns
     */
    private initializeEncodingPatterns;
    /**
     * Analyze input for injection attempts
     */
    analyzeInput(input: string): Promise<InjectionDetectionResult>;
    /**
     * Detect encoding-based attacks
     */
    private detectEncodingAttacks;
    /**
     * Detect context overflow attempts
     */
    private detectContextOverflow;
    /**
     * Check if a pattern match is whitelisted
     */
    private isWhitelisted;
    /**
     * Sanitize input by removing or neutralizing detected patterns
     */
    private sanitizeInput;
    /**
     * Neutralize encoding attacks
     */
    private neutralizeEncodingAttacks;
    /**
     * Generate recommendations based on detected patterns
     */
    private generateRecommendations;
    /**
     * Create a safe result for disabled detection
     */
    private createSafeResult;
    /**
     * Add a custom pattern
     */
    addPattern(pattern: InjectionPattern): void;
    /**
     * Remove a pattern by ID
     */
    removePattern(patternId: string): boolean;
    /**
     * Enable or disable a pattern
     */
    setPatternEnabled(patternId: string, enabled: boolean): boolean;
    /**
     * Get all patterns
     */
    getPatterns(): InjectionPattern[];
    /**
     * Update configuration
     */
    updateConfig(updates: Partial<InjectionDetectionConfig>): void;
    /**
     * Create a prompt template
     */
    createTemplate(template: PromptTemplate): Promise<void>;
    /**
     * Get a prompt template
     */
    getTemplate(templateId: string): Promise<PromptTemplate | null>;
    /**
     * Validate and render a template with variables
     */
    renderTemplate(templateId: string, variables: Record<string, unknown>): Promise<{
        rendered: string;
        validationErrors: string[];
    }>;
    /**
     * Check a template constraint
     */
    private checkConstraint;
    /**
     * Test input against specific pattern types
     */
    testForPatternType(input: string, type: InjectionPatternType): Promise<DetectedPattern[]>;
    /**
     * Get detection statistics
     */
    getStatistics(): {
        totalPatterns: number;
        enabledPatterns: number;
        patternsByType: Record<string, number>;
        patternsBySeverity: Record<string, number>;
    };
}
export default PromptInjectionDetector;
//# sourceMappingURL=prompt-injection.d.ts.map