# text.anonymize Regex-based PII anonymization for plain text. Detects and replaces personally-identifiable patterns with stable tokens of the shape `⟦TYPE_N⟧`, and emits a JSON report describing every redaction so a downstream verify step can audit completeness. ## Capability - `text.anonymize@0.1.0` ## Inputs | Name | Type | Description | | -------------- | ---- | ------------------------------------------------------ | | `text` | text | UTF-8 string to redact. | | `custom_terms` | text | Optional. Newline-separated list of extra bare terms to redact whole-word (case-insensitive). | ## Outputs | Name | Type | Description | | ------------ | ---- | -------------------------------------------------------------------------------------------- | | `anonymized` | text | The input text with PII replaced by `⟦TYPE_N⟧` tokens. | | `report` | json | `{ redactions: [{ type, token, original, offset }…], counts: { TYPE: n, … } }`. | ## Categories detected | Type | Pattern | | --------------- | ---------------------------------------------------------------------- | | `EMAIL` | RFC-5321-ish `local@domain`, IDN domains OK. | | `PHONE` | International (`+49 …`) or German national (`030 …`, `0151-…`) shape. | | `IBAN` | Word-bounded `[A-Z]{2}\d{2}[A-Z0-9]{11,30}`. Structural only — checksum deliberately not computed. | | `BIC` | Word-bounded uppercase alnum, 8 or 11 chars. | | `IPV4` | Four 0..255 octets, dot-separated. | | `GERMAN_TAX_ID` | 11 consecutive digits, word-bounded. | | `CUSTOM` | Every line of `custom_terms` matched whole-word, case-insensitive. | No NER yet. v0.2.0 will add a small ONNX model for name / organisation detection once we have a benchmarked candidate. ## Permissions None. Pure-Rust, regex-only, in-WASM. No filesystem, no network, no LLM call. ## Example flow ```yaml name: redact-case-file inputs: document: bytes steps: - id: extract use: text.extract@^0 with: document: $inputs.document - id: redact use: text.anonymize@^0 with: text: $extract.extracted.pages[*].text custom_terms: | Mustermann Musterfrau outputs: redacted: $redact.anonymized audit_report: $redact.report ``` ## Build ```bash cargo build --release --target wasm32-wasip2 # Output: target/wasm32-wasip2/release/text_anonymize.wasm ```