Skip to main content

Compliance presets

A preset chooses which categories are detected and how each one is replaced, for the data a regulation names.

PresetCoversDefault strategy
gdprPersonal, financial and health data, and online identifiers (EU GDPR)pseudonymize
lgpdPersonal data, including the CPF (Brazil, LGPD)redact
pipedaPersonal information, including the Social Insurance Number (Canada)redact
hipaaThe HIPAA Safe Harbor identifiers that can be detected in textredact
ccpaConsumer identifiers, financial and health data, online activity, API keysredact
pci-dssCard and bank account numbers, cardholder name and contact detailsredact; card and account numbers keep the last 4
soxFinancial and corporate officer identifiers for audit trailsredact
ferpaStudent data: name, contact details, date of birth, SSN, national IDredact

Presets in the reference shows, category by category, what each preset does; it is generated from the code.

import { anonymize, getPreset } from "anonyma";

anonymize(text, { preset: "hipaa" });

getPreset("hipaa").categories; // ["name", "address", "date-of-birth", "phone", ...]
What a preset cannot do

A preset covers what the library can detect. Some data that a regulation names has no detector — for HIPAA, ZIP codes, dates other than birth dates, device identifiers and photographs; for PCI DSS, card verification codes. REGULATIONS[id].gaps in anonyma/compliance lists them, with the provision that names each one, and the regulations page shows them. A preset is a technical measure; it does not make a system compliant on its own.

Several regulations at once​

Health records of Brazilian patients fall under LGPD and HIPAA. A list of presets applies all of them: every category of every preset is detected, and each category gets the most protective of the presets' strategies — one that cannot be reversed, links nothing and reveals less wins; between equals, the preset listed first.

import { anonymize, combinePresets, createAnonymizer } from "anonyma";

anonymize(text, { preset: ["lgpd", "hipaa"] });
const anonymizer = createAnonymizer({ preset: ["lgpd", "hipaa"] });

// What a combination does:
combinePresets(["pci-dss", "hipaa"]).rules; // [] — HIPAA's redaction beats PCI DSS's mask

The recipe Several regulations at once goes further, with validating detectors and signed receipts.

Changing a preset​

In anonymize(), rules replace the preset's rules and its list of categories (see Per-category rules). To add a category to a preset, or change the strategy of one, compile a pipeline:

import { getPreset } from "anonyma";
import { compilePipeline } from "anonyma/engine";

const gdprWithKeys = compilePipeline({
preset: "gdpr",
categories: [...getPreset("gdpr").categories, "api-key"],
rules: { email: { strategy: "mask", keepTrailing: 12 } },
});

For a policy that your organisation maintains, checked against the regulations it extends, see Regulations and policies.