"use strict"; /** * AeThex SafeInput - PII Detection & Scrubbing * Automatically detects and removes personally identifiable information */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SafeInput = void 0; class SafeInput { /** * Detect PII types in input */ static detectPII(input) { const detected = []; if (this.patterns.phone.test(input)) detected.push('phone'); if (this.patterns.email.test(input)) detected.push('email'); if (this.patterns.ssn.test(input)) detected.push('ssn'); if (this.patterns.credit_card.test(input)) detected.push('credit_card'); if (this.patterns.address.test(input)) detected.push('address'); return detected; } /** * Scrub PII from input */ static scrub(input) { let clean = input; clean = clean.replace(this.patterns.phone, '[PHONE_REDACTED]'); clean = clean.replace(this.patterns.email, '[EMAIL_REDACTED]'); clean = clean.replace(this.patterns.ssn, '[SSN_REDACTED]'); clean = clean.replace(this.patterns.credit_card, '[CARD_REDACTED]'); clean = clean.replace(this.patterns.address, '[ADDRESS_REDACTED]'); return clean; } /** * Validate input for PII */ static validate(input) { const detected = this.detectPII(input); if (detected.length === 0) { return { valid: true, blocked: [], clean: input }; } return { valid: false, blocked: detected, clean: this.scrub(input), message: `Blocked PII types: ${detected.join(', ')}` }; } /** * Check if input is safe */ static isSafe(input) { return this.detectPII(input).length === 0; } } exports.SafeInput = SafeInput; // PII Detection Patterns SafeInput.patterns = { phone: /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b|\(\d{3}\)\s*\d{3}[-.]?\d{4}/g, email: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g, ssn: /\b\d{3}-\d{2}-\d{4}\b/g, credit_card: /\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g, address: /\b\d+\s+[A-Za-z\s]+(?:Street|St|Avenue|Ave|Road|Rd|Lane|Ln|Drive|Dr|Court|Ct|Boulevard|Blvd)\b/gi }; //# sourceMappingURL=SafeInput.js.map