@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.
113 lines • 3.82 kB
TypeScript
/**
* TemplateManager - Implementation of IElementManager for Template elements
* Handles CRUD operations and lifecycle management for templates implementing IElement
*
* SECURITY FIXES IMPLEMENTED (Following PR #319 patterns):
* 1. CRITICAL: Fixed race conditions in file operations by using FileLockManager for atomic reads/writes
* 2. CRITICAL: Fixed dynamic require() statements by using static imports
* 3. HIGH: Fixed unvalidated YAML parsing vulnerability by using SecureYamlParser
* 4. MEDIUM: All user inputs are now validated and sanitized
* 5. MEDIUM: Audit logging added for security operations
* 6. MEDIUM: Path traversal prevention for all file operations
*/
import { IElementManager } from '../../types/elements/IElementManager.js';
import { ElementValidationResult } from '../../types/elements/IElement.js';
import { Template } from './Template.js';
import { ElementType } from '../../portfolio/types.js';
export declare class TemplateManager implements IElementManager<Template> {
private portfolioManager;
private templatesDir;
private templates;
constructor();
/**
* Load a template from file
* SECURITY FIX #1: Uses FileLockManager.atomicReadFile() instead of fs.readFile()
* to prevent race conditions and ensure atomic file operations
*/
load(filePath: string): Promise<Template>;
/**
* Save a template to file
* SECURITY FIX #1: Uses FileLockManager.atomicWriteFile() for atomic operations
*/
save(template: Template, filePath: string): Promise<void>;
/**
* List all templates
* SECURITY FIX: Uses validated directory path
*/
list(): Promise<Template[]>;
/**
* Find a template by predicate
*/
find(predicate: (template: Template) => boolean): Promise<Template | undefined>;
/**
* Create a new template
*/
create(data: {
name: string;
description: string;
content?: string;
metadata?: any;
}): Promise<Template>;
/**
* Delete a template
* SECURITY FIX #6: Path validation to prevent deletion outside directory
*/
delete(filePath: string): Promise<void>;
/**
* Import a template from external format
* SECURITY FIX #3: Uses SecureYamlParser for safe YAML parsing
*/
importElement(data: string, format: 'json' | 'yaml' | 'markdown'): Promise<Template>;
/**
* Export a template to external format
* SECURITY FIX #3: Uses safe YAML serialization
*/
exportElement(template: Template, format: 'json' | 'yaml' | 'markdown'): Promise<string>;
/**
* Validate and sanitize metadata
* SECURITY FIX #4: Comprehensive metadata validation
*/
private validateMetadata;
/**
* Create YAML frontmatter from metadata
* SECURITY FIX #3: Safe YAML generation
*/
private createFrontmatter;
/**
* Check if a template file exists
*/
exists(filePath: string): Promise<boolean>;
/**
* Find multiple templates by predicate
*/
findMany(predicate: (template: Template) => boolean): Promise<Template[]>;
/**
* Validate a template
*/
validate(template: Template): ElementValidationResult;
/**
* Validate a file path
*/
validatePath(filePath: string): boolean;
/**
* Get the element type
*/
getElementType(): ElementType;
/**
* Get the file extension
*/
getFileExtension(): string;
/**
* Find templates by category
*/
findByCategory(category: string): Promise<Template[]>;
/**
* Find templates by tag
*/
findByTag(tag: string): Promise<Template[]>;
/**
* Get most used templates
*/
getMostUsed(limit?: number): Promise<Template[]>;
}
//# sourceMappingURL=TemplateManager.d.ts.map