Skip to content

About

Pure, deterministic, dependency-free de-identification engine (Excisor). HIPAA/FERPA/GDPR detection, mask/placeholder/safe-harbor transforms, batch redaction certificates. Apache-2.0.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

@simdad/wordlist-core

A pure, deterministic, dependency-free de-identification engine (the Excisor engine). Give it text, get back text with the identifying information detected and replaced — the same input always produces byte-identical output, so a CI gate or an extraction check can trust it.

License: Apache-2.0

  • Zero runtime dependencies. No network, no globals, no clock. Just the JS/Node standard library.
  • Deterministic. Same (text, options) ⇒ identical spans and identical output, every run.
  • Local by design. Nothing is uploaded anywhere; your originals are never modified.
  • Two detection lanes + optional NER, four+ transform modes, checksum validators, and a batch mode that emits a redaction certificate.

This engine supports HIPAA Safe-Harbor de-identification (45 CFR 164.514(b)(2)). It is not an Expert Determination (45 CFR 164.514(a)) — that judgment remains yours.

Install

npm install @simdad/wordlist-core

Quick start

import { detect, transform } from '@simdad/wordlist-core';

const text = 'Email [email protected] or call 555-123-4567. DOB 1980-04-12.';

const spans = detect(text, { profile: 'hipaa' });
const { text: safe } = transform(text, spans, 'mask');
// safe → "Email [REDACTED: email] or call [REDACTED: phone]. DOB [REDACTED: date]."

The two calls are the whole story: detect finds identifiers (as non-overlapping spans, in document order), transform replaces them. Everything else is options and reporting.

The three layers

Layer 1 — detection

Structured (shape) detection catches the Safe-Harbor identifiers no one types into a list — email, phone, fax, SSN, ITIN, dates, account/credit-card/IBAN numbers, URLs, IPs, ZIPs, MRNs, ages — selected by a profile:

type Profile = 'hipaa' | 'ferpa' | 'gdpr' | 'off';
detect(text, { profile: 'ferpa' });

Wordlist (literal) detection finds caller-supplied terms (codenames, known names, banned words):

import { deidentify, mark } from '@simdad/wordlist-core';

const wordlist = [{ term: 'Project Aurora', category: 'codename' }];
mark('Project Aurora ships Q3', wordlist);
// [{ term: 'Project Aurora', start: 0, end: 14, matched: 'Project Aurora', category: 'codename' }]

deidentify('Project Aurora ships Q3', wordlist);
// { text: '«CODENAME_001» ships Q3', mapping: { '«CODENAME_001»': 'Project Aurora' }, replacements: 1 }

Use both at once — they merge into one overlap-resolved span list:

detect(text, { profile: 'hipaa', wordlist });

Layer 2 — optional NER (off by default)

Free-text person/org/location detection is off the lean path: the core bundles no model and takes no onnxruntime dependency. With no backend wired, detection is shape-only (no error). To enable it, register a backend and use the async path:

import { setNerBackend, detectAsync } from '@simdad/wordlist-core';

setNerBackend(myNerDetector);                       // you supply this
await detectAsync(text, { profile: 'hipaa', includeNer: true });

If you wire a model, you own its license hygiene (see NOTICE: use an Apache-2.0 GLiNER v2.1+ model; reject v1 / Pile-NER weights).

Layer 3 — transform

type TransformMode = 'mask' | 'placeholder' | 'generalize' | 'safe-harbor' | 'pseudonym';
Mode Result Reversible?
mask labelled mask [REDACTED: email] no
placeholder stable «EMAIL_001» per distinct identifier yes — via mapping
generalize Safe-Harbor coarsening (date → year, ZIP → 3-digit) no
safe-harbor strict superset of generalize (restricted ZIP → 000XX, age > 89 → 90+) no
pseudonym «EMAIL~<digest>» via a caller-supplied keyed function only with the key
const { text: masked } = transform(text, spans, 'placeholder');
// masked → "Email «EMAIL_001» ..."; then:
const { mapping } = transform(text, spans, 'placeholder');
// mapping → { '«EMAIL_001»': 'jane@example.com' }

The placeholder/pseudonym reversal mapping re-links identities. Treat it as a secret — store it in a keystore or password manager, never beside the de-identified output, never share it.

pseudonym keeps the engine key-free — you inject the keyed digest so tokens are stable across documents without storing any mapping:

import { createHmac } from 'node:crypto';
transform(text, spans, 'pseudonym', {
  pseudonymize: (value, prefix) =>
    createHmac('sha256', myKey).update(`${prefix}:${value}`).digest('hex').slice(0, 12),
});

Coverage report (audit trail)

A per-document, clock-free record of which lanes ran and what was found — a technical trail that supports Safe-Harbor:

import { generateCoverageReport, formatCoverageReport } from '@simdad/wordlist-core';

const report = generateCoverageReport(text, spans, { profile: 'hipaa' });
console.log(formatCoverageReport(report));

Checksum validators

Exported so you can offer "validate this span" affordances or reuse them on your own fields:

import { luhnValid, ibanValid, deaValid, npiValid, vinValid, mbiValid, itinValid } from '@simdad/wordlist-core';

luhnValid('4111111111111111'); // true

Batch mode

Pure engine half — you own I/O, hashing, and the clock (injected, so the engine stays deterministic):

import { processBatch, formatCertificate } from '@simdad/wordlist-core';
import { createHash } from 'node:crypto';

const { items, summary } = processBatch(
  [{ name: 'notes.txt', kind: 'text', content }],   // kind: 'text' | 'csv' (CSV is de-identified cell-by-cell)
  { profile: 'hipaa', mode: 'mask' },
  { timestamp: new Date().toISOString(), hash: (c) => createHash('sha256').update(c).digest('hex') },
);

for (const item of items) {
  writeOutput(item.name, item.result.output);        // your I/O
  writeCert(item.name, formatCertificate(item.certificate));
}
console.log(summary); // { documents, totalReplacements, countsByCategory, flagged }

CLI

The package ships a deid command:

# Single file (or stdin) → de-identified text on stdout
deid notes.txt --profile hipaa --mode mask > notes.deid.txt
cat notes.txt | deid --report > safe.txt

# Extra literal terms, one per line
deid notes.txt --wordlist codenames.txt

# Batch: writes <file>.deid + <file>.cert.txt beside every .txt/.md/.csv, plus a summary.
# Originals are never touched; re-running skips the tool's own outputs.
deid --batch ./records --profile hipaa --mode safe-harbor

Flags: --profile hipaa|ferpa|gdpr (default hipaa), --mode mask|placeholder|generalize|safe-harbor (default mask), --wordlist <file>, --report, --batch <dir>, --help.

Guarantees and honest limits

  • Your originals are never modified. Every mode returns a new string (and the CLI/batch writes copies).
  • Deterministic, so it is safe inside CI gates and reproducible pipelines.
  • NER is off by default — without a wired backend, free-text names/orgs are not caught by shape alone.
  • Supports, does not certify. This is a mechanical Safe-Harbor aid, not a HIPAA Expert Determination.
  • The reversal mapping is sensitive — handle it like a credential.

License

Apache-2.0 © 2026 SIM DAD LLC. Dependency-free; see NOTICE.

About

Pure, deterministic, dependency-free de-identification engine (Excisor). HIPAA/FERPA/GDPR detection, mask/placeholder/safe-harbor transforms, batch redaction certificates. Apache-2.0.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages