MCPcopy Index your code
hub / github.com/simstudioai/sim / anonymize

Function anonymize

apps/sim/lib/guardrails/validate_pii.ts:131–146  ·  view source on GitHub ↗

* Mask spans via the Presidio anonymizer service. Omitting `anonymizers` uses the * default `replace` operator, which yields ` `. Throws on failure.

(text: string, spans: AnalyzerSpan[])

Source from the content-addressed store, hash-verified

129 * default `replace` operator, which yields `<ENTITY_TYPE>`. Throws on failure.
130 */
131async function anonymize(text: string, spans: AnalyzerSpan[]): Promise<string> {
132 if (spans.length === 0) return text
133
134 // boundary-raw-fetch: internal call to the Presidio anonymizer service via PII_URL
135 const response = await fetch(`${PII_URL}/anonymize`, {
136 method: 'POST',
137 headers: { 'content-type': 'application/json' },
138 body: JSON.stringify({ text, analyzer_results: spans }),
139 })
140 if (!response.ok) {
141 const detail = await response.text().catch(() => '')
142 throw new Error(`Presidio anonymize failed (${response.status}): ${detail.slice(0, 200)}`)
143 }
144 const data = (await response.json()) as { text: string }
145 return data.text
146}
147
148/**
149 * Validate text for PII using the Presidio service.

Callers 1

validatePIIFunction · 0.70

Calls 1

textMethod · 0.80

Tested by

no test coverage detected