@dollhousemcp/mcp-server
Version:
DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.
96 lines • 3.21 kB
TypeScript
/**
* Pattern Decryption Service with LLM Context Protection
*
* Part of Issue #1321 Phase 2: Memory Security Architecture
*
* PURPOSE:
* Provides secure access to decrypt patterns while preventing
* decryption in LLM request contexts. All decryption attempts
* are audited for security monitoring.
*
* SECURITY:
* - Prevents decryption in LLM contexts (blocks pattern leaks to LLM)
* - Requires explicit authorization
* - Audits all decryption attempts
* - Uses ContextTracker to detect execution context
*
* REFACTOR NOTE:
* Converted from static class to instance-based for DI architecture compatibility.
* PatternDecryptor now requires PatternEncryptor and ContextTracker dependencies
* to be injected via constructor for proper DI lifecycle management.
*
* @module PatternDecryptor
*/
import { PatternEncryptor } from './PatternEncryptor.js';
import { ContextTracker } from './ContextTracker.js';
import type { SanitizedPattern } from '../validation/BackgroundValidator.js';
/**
* Decryption attempt metadata for audit logging
*/
export interface DecryptionAttempt {
/** Pattern reference ID */
patternRef: string;
/** Whether decryption was successful */
success: boolean;
/** Timestamp of the attempt */
timestamp: number;
/** Execution context type */
contextType: string;
/** Request ID for correlation */
requestId?: string;
/** Reason for denial (if unsuccessful) */
denialReason?: string;
/** Error message (if failed) */
error?: string;
}
/**
* PatternDecryptor service
*
* Provides controlled access to decrypt encrypted patterns with
* LLM context protection and audit logging.
*
* DI-COMPATIBLE: Instance-based service for dependency injection.
*/
export declare class PatternDecryptor {
private readonly encryptor;
private readonly contextTracker;
private readonly auditLog;
/**
* Create a new PatternDecryptor instance
*
* @param encryptor - PatternEncryptor instance for decryption operations
* @param contextTracker - ContextTracker instance for LLM context detection
*/
constructor(encryptor: PatternEncryptor, contextTracker: ContextTracker);
/**
* Decrypt a sanitized pattern with security checks
*
* This method:
* 1. Checks if in LLM context (denies if true)
* 2. Validates pattern structure
* 3. Audits the decryption attempt
* 4. Decrypts the pattern using PatternEncryptor
*
* @param pattern - Sanitized pattern to decrypt
* @returns Decrypted pattern text
* @throws Error if decryption is not allowed or fails
*/
decryptPattern(pattern: SanitizedPattern): string;
/**
* Get decryption audit log
*
* @param limit - Maximum number of attempts to return
* @returns Array of recent decryption attempts
*/
getAuditLog(limit?: number): DecryptionAttempt[];
/**
* Clear the audit log (useful for testing)
*/
clearAuditLog(): void;
/**
* Dispose of the decryptor and clean up resources
* Implements cleanup for proper DI lifecycle management
*/
dispose(): Promise<void>;
}
//# sourceMappingURL=PatternDecryptor.d.ts.map