Secure text sanitization library for LLM - replaces sensitive data with tagged placeholders.
- Detects and replaces sensitive information:
- Hash values (SHA256, etc.)
- API tokens / secrets
- Email addresses
- Phone numbers
- Personal names (Japanese & English)
- IP addresses
- URLs
- Credit card numbers
- Consistent hash for same values
- Reversible: restore original text with mapping table
pnpm add securetextimport { sanitize, restore } from 'securetext';
const original = "山田太郎のメールは[email protected]です";
// Sanitize
const { sanitizedText, mappingTable } = sanitize(original);
// sanitizedText: "[DELETED:PERSON_NAME:f7a3b2]のメールは[DELETED:EMAIL:c9d1e4]です"
// Restore
const restored = restore(sanitizedText, mappingTable);
// restored: "山田太郎のメールは[email protected]です"MIT