UNPKG

llmverify

Version:

AI Output Verification Toolkit — Local-first LLM safety, hallucination detection, PII redaction, prompt injection defense, and runtime monitoring. Zero telemetry. OWASP LLM Top 10 aligned.

74 lines (73 loc) 1.75 kB
/** * Security Validators and Hardening * * Input validation, regex safety, and security utilities * * @module security/validators */ /** * Maximum input sizes */ export declare const SECURITY_LIMITS: { MAX_CONTENT_LENGTH: number; MAX_REGEX_LENGTH: number; MAX_ARRAY_LENGTH: number; REGEX_TIMEOUT_MS: number; }; /** * Validate and sanitize input string */ export declare function validateInput(input: string, maxLength?: number): string; /** * Safe regex execution with timeout protection */ export declare function safeRegexTest(pattern: RegExp, text: string, timeoutMs?: number): boolean; /** * Sanitize string for safe logging (remove PII) */ export declare function sanitizeForLogging(text: string): string; /** * Validate array input */ export declare function validateArray<T>(arr: T[], maxLength?: number): T[]; /** * Rate limiter class */ export declare class RateLimiter { private requests; private maxRequests; private windowMs; constructor(maxRequests?: number, windowMs?: number); /** * Check if request is allowed */ isAllowed(key: string): boolean; /** * Get remaining requests */ getRemaining(key: string): number; /** * Reset rate limit for key */ reset(key: string): void; /** * Clear all rate limits */ clear(): void; } /** * Sanitize object for safe logging */ export declare function sanitizeObject(obj: any): any; /** * Validate URL */ export declare function validateUrl(url: string): boolean; /** * Escape HTML to prevent XSS */ export declare function escapeHtml(text: string): string; /** * Check for potential injection patterns */ export declare function detectInjection(text: string): boolean;