Text to redact.
OptionalmaskChar?: stringCharacter(s) to use for masked positions, passed through to maskText. Default is '*'.
Optionaltypes?: ("email" | "phone" | "creditCard" | "apiKey")[]Which types to redact. Default is 'email', 'phone', and 'creditCard'. 'apiKey' is opt-in only, given its higher false-positive risk.
The text with each detected match masked in place.
redact('Contact me at jordan@example.com or 555-123-4567');
// 'Contact me at jo**************** or 55**********'
redact('Card: 4111 1111 1111 1111', { types: ['creditCard'] });
// 'Card: ***************1111'
redact('Key: AKIAIOSFODNN7EXAMPLE leaked', { types: ['apiKey'] });
// 'Key: ******************** leaked'
Scans free-form text for embedded PII (emails, phone numbers, credit card numbers) and secrets (API keys/tokens) and masks each match in place, using extractEmails to locate emails and maskText to mask every match — for sanitizing logs, support tickets, or user-generated content before storage or display.
redactis best-effort pattern matching, not a complete PII/secret detector — false negatives are possible, and it shouldn't be relied on as the only safeguard for sensitive data (pair it with review, not use it as a substitute for one).