anonyma 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +273 -144
- package/README.md +427 -143
- package/dist/ai/index.cjs +522 -0
- package/dist/ai/index.cjs.map +1 -0
- package/dist/ai/index.d.cts +322 -0
- package/dist/ai/index.d.ts +322 -0
- package/dist/ai/index.js +505 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/audit/index.cjs +359 -0
- package/dist/audit/index.cjs.map +1 -0
- package/dist/audit/index.d.cts +287 -0
- package/dist/audit/index.d.ts +287 -0
- package/dist/audit/index.js +340 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/chunk-26IHMQHL.cjs +662 -0
- package/dist/chunk-26IHMQHL.cjs.map +1 -0
- package/dist/chunk-2F2GWGTB.js +174 -0
- package/dist/chunk-2F2GWGTB.js.map +1 -0
- package/dist/chunk-2NNMJ55L.cjs +45 -0
- package/dist/chunk-2NNMJ55L.cjs.map +1 -0
- package/dist/chunk-2YG7R4KJ.cjs +114 -0
- package/dist/chunk-2YG7R4KJ.cjs.map +1 -0
- package/dist/chunk-2ZZHLCEJ.js +237 -0
- package/dist/chunk-2ZZHLCEJ.js.map +1 -0
- package/dist/chunk-3CY6ATKS.cjs +308 -0
- package/dist/chunk-3CY6ATKS.cjs.map +1 -0
- package/dist/chunk-3D5ZCJ7R.js +268 -0
- package/dist/chunk-3D5ZCJ7R.js.map +1 -0
- package/dist/chunk-6LDAIJBL.js +103 -0
- package/dist/chunk-6LDAIJBL.js.map +1 -0
- package/dist/chunk-7HK2V5Q4.js +111 -0
- package/dist/chunk-7HK2V5Q4.js.map +1 -0
- package/dist/chunk-AAP472NG.js +177 -0
- package/dist/chunk-AAP472NG.js.map +1 -0
- package/dist/chunk-AP4JIUNW.js +42 -0
- package/dist/chunk-AP4JIUNW.js.map +1 -0
- package/dist/chunk-BBJPQPGP.js +457 -0
- package/dist/chunk-BBJPQPGP.js.map +1 -0
- package/dist/chunk-CRXRJZEV.cjs +82 -0
- package/dist/chunk-CRXRJZEV.cjs.map +1 -0
- package/dist/chunk-E3PICZYI.js +20 -0
- package/dist/chunk-E3PICZYI.js.map +1 -0
- package/dist/chunk-F7O2FA3F.cjs +1255 -0
- package/dist/chunk-F7O2FA3F.cjs.map +1 -0
- package/dist/chunk-FB56NAAH.cjs +243 -0
- package/dist/chunk-FB56NAAH.cjs.map +1 -0
- package/dist/chunk-G4AN7FND.js +1063 -0
- package/dist/chunk-G4AN7FND.js.map +1 -0
- package/dist/chunk-GS3FRH4K.js +294 -0
- package/dist/chunk-GS3FRH4K.js.map +1 -0
- package/dist/chunk-GYMG5OI3.cjs +186 -0
- package/dist/chunk-GYMG5OI3.cjs.map +1 -0
- package/dist/chunk-IHEIYZPL.cjs +301 -0
- package/dist/chunk-IHEIYZPL.cjs.map +1 -0
- package/dist/chunk-IJAMLYOT.cjs +1087 -0
- package/dist/chunk-IJAMLYOT.cjs.map +1 -0
- package/dist/chunk-ISL5B4LU.cjs +181 -0
- package/dist/chunk-ISL5B4LU.cjs.map +1 -0
- package/dist/chunk-JKW36IPT.js +179 -0
- package/dist/chunk-JKW36IPT.js.map +1 -0
- package/dist/chunk-KOCQBDI4.cjs +179 -0
- package/dist/chunk-KOCQBDI4.cjs.map +1 -0
- package/dist/chunk-OGNLB2KA.js +79 -0
- package/dist/chunk-OGNLB2KA.js.map +1 -0
- package/dist/chunk-PKHZ7CVI.js +28 -0
- package/dist/chunk-PKHZ7CVI.js.map +1 -0
- package/dist/chunk-QYD4F6T7.cjs +114 -0
- package/dist/chunk-QYD4F6T7.cjs.map +1 -0
- package/dist/chunk-RCW5IPPR.js +1288 -0
- package/dist/chunk-RCW5IPPR.js.map +1 -0
- package/dist/chunk-RMMKYHUN.cjs +35 -0
- package/dist/chunk-RMMKYHUN.cjs.map +1 -0
- package/dist/chunk-S4BJ2ADB.cjs +22 -0
- package/dist/chunk-S4BJ2ADB.cjs.map +1 -0
- package/dist/chunk-S7NH6CHY.cjs +462 -0
- package/dist/chunk-S7NH6CHY.cjs.map +1 -0
- package/dist/chunk-SIHPDZXA.js +176 -0
- package/dist/chunk-SIHPDZXA.js.map +1 -0
- package/dist/chunk-TW7PM3UJ.cjs +30 -0
- package/dist/chunk-TW7PM3UJ.cjs.map +1 -0
- package/dist/chunk-UA3EOFBS.cjs +1322 -0
- package/dist/chunk-UA3EOFBS.cjs.map +1 -0
- package/dist/chunk-VE4CCW7W.js +32 -0
- package/dist/chunk-VE4CCW7W.js.map +1 -0
- package/dist/chunk-W6RBCHYF.js +651 -0
- package/dist/chunk-W6RBCHYF.js.map +1 -0
- package/dist/chunk-WLJN7GIS.cjs +189 -0
- package/dist/chunk-WLJN7GIS.cjs.map +1 -0
- package/dist/chunk-YMLR375Z.js +1244 -0
- package/dist/chunk-YMLR375Z.js.map +1 -0
- package/dist/compliance/index.cjs +88 -0
- package/dist/compliance/index.cjs.map +1 -0
- package/dist/compliance/index.d.cts +277 -0
- package/dist/compliance/index.d.ts +277 -0
- package/dist/compliance/index.js +47 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/crypto.cjs +12 -136
- package/dist/crypto.cjs.map +1 -1
- package/dist/crypto.d.cts +4 -3
- package/dist/crypto.d.ts +4 -3
- package/dist/crypto.js +3 -137
- package/dist/crypto.js.map +1 -1
- package/dist/detectors/index.cjs +146 -1483
- package/dist/detectors/index.cjs.map +1 -1
- package/dist/detectors/index.d.cts +1 -1
- package/dist/detectors/index.d.ts +1 -1
- package/dist/detectors/index.js +3 -1449
- package/dist/detectors/index.js.map +1 -1
- package/dist/engine/index.cjs +441 -0
- package/dist/engine/index.cjs.map +1 -0
- package/dist/engine/index.d.cts +728 -0
- package/dist/engine/index.d.ts +728 -0
- package/dist/engine/index.js +189 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/hash-2PSYNDMM.cjs +14 -0
- package/dist/hash-2PSYNDMM.cjs.map +1 -0
- package/dist/hash-CELLDNKN.js +5 -0
- package/dist/hash-CELLDNKN.js.map +1 -0
- package/dist/index.cjs +153 -2816
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -11
- package/dist/index.d.ts +93 -11
- package/dist/index.js +13 -2791
- package/dist/index.js.map +1 -1
- package/dist/json-CKDvlRtl.d.ts +147 -0
- package/dist/json-s8ny-RCo.d.cts +147 -0
- package/dist/mcp/index.cjs +751 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +226 -0
- package/dist/mcp/index.d.ts +226 -0
- package/dist/mcp/index.js +744 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/middleware/express.cjs +93 -0
- package/dist/middleware/express.cjs.map +1 -0
- package/dist/middleware/express.d.cts +90 -0
- package/dist/middleware/express.d.ts +90 -0
- package/dist/middleware/express.js +91 -0
- package/dist/middleware/express.js.map +1 -0
- package/dist/middleware/hono.cjs +58 -0
- package/dist/middleware/hono.cjs.map +1 -0
- package/dist/middleware/hono.d.cts +75 -0
- package/dist/middleware/hono.d.ts +75 -0
- package/dist/middleware/hono.js +56 -0
- package/dist/middleware/hono.js.map +1 -0
- package/dist/middleware/index.cjs +24 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +106 -0
- package/dist/middleware/index.d.ts +106 -0
- package/dist/middleware/index.js +15 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/schemas.cjs +5 -5
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +20 -10
- package/dist/schemas.d.ts +20 -10
- package/dist/schemas.js +5 -5
- package/dist/schemas.js.map +1 -1
- package/dist/session-BdRftyZ5.d.cts +102 -0
- package/dist/session-Cs2zlNQp.d.ts +102 -0
- package/dist/stream.cjs +13 -2262
- package/dist/stream.cjs.map +1 -1
- package/dist/stream.d.cts +1 -1
- package/dist/stream.d.ts +1 -1
- package/dist/stream.js +6 -2255
- package/dist/stream.js.map +1 -1
- package/dist/types--tPm_AjY.d.ts +199 -0
- package/dist/types-0BJH_wqc.d.cts +199 -0
- package/dist/types-CPUhjvl8.d.cts +629 -0
- package/dist/types-Dtht33aq.d.ts +629 -0
- package/dist/{types-D-9HzVuy.d.cts → types-EJTj_BKY.d.cts} +38 -7
- package/dist/{types-D-9HzVuy.d.ts → types-EJTj_BKY.d.ts} +38 -7
- package/dist/types-Zt_bZvwS.d.cts +182 -0
- package/dist/types-Zt_bZvwS.d.ts +182 -0
- package/dist/validators.cjs +39 -181
- package/dist/validators.cjs.map +1 -1
- package/dist/validators.js +1 -174
- package/dist/validators.js.map +1 -1
- package/dist/vault/index.cjs +688 -0
- package/dist/vault/index.cjs.map +1 -0
- package/dist/vault/index.d.cts +385 -0
- package/dist/vault/index.d.ts +385 -0
- package/dist/vault/index.js +669 -0
- package/dist/vault/index.js.map +1 -0
- package/package.json +128 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap,
|
|
2
|
-
export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-
|
|
1
|
+
import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap, e as AnonymizerConfig, f as Anonymizer, P as PiiCategory, D as Detector, g as PiiMatch, h as DetokenizeResult, T as TokenizeOptions, b as TokenizeResult, B as BatchResult, C as CompliancePreset, S as StrategyOptions, i as AnonymizationRule, M as MaskOptions, R as RedactOptions, c as PseudonymizeOptions, H as HashOptions, G as GeneralizeOptions, d as SynthesizeOptions } from './types-EJTj_BKY.cjs';
|
|
2
|
+
export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-EJTj_BKY.cjs';
|
|
3
3
|
export { decrypt, encrypt } from './crypto.cjs';
|
|
4
|
+
import { c as PolicyIssue } from './types-0BJH_wqc.cjs';
|
|
5
|
+
import './types-CPUhjvl8.cjs';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* @module anonymize
|
|
@@ -371,19 +373,25 @@ declare function detectBatch(texts: readonly string[], categories?: readonly Pii
|
|
|
371
373
|
|
|
372
374
|
/**
|
|
373
375
|
* @module presets
|
|
374
|
-
* @description Built-in compliance preset configurations for GDPR,
|
|
375
|
-
* PCI-DSS, SOX, and FERPA. Import from `"anonyma"`
|
|
376
|
-
* `preset` option in {@link AnonymizeOptions}.
|
|
376
|
+
* @description Built-in compliance preset configurations for GDPR, LGPD,
|
|
377
|
+
* PIPEDA, CCPA/CPRA, HIPAA, PCI-DSS, SOX, and FERPA. Import from `"anonyma"`
|
|
378
|
+
* or extend using the `preset` option in {@link AnonymizeOptions}.
|
|
379
|
+
*
|
|
380
|
+
* A preset selects the categories that the library can detect for an
|
|
381
|
+
* instrument and the strategy applied to them. The legal provisions behind
|
|
382
|
+
* each category, and the data elements each instrument names that no detector
|
|
383
|
+
* covers, are documented in `"anonyma/compliance"`.
|
|
377
384
|
*
|
|
378
385
|
* @example
|
|
379
386
|
* ```ts
|
|
380
387
|
* import { anonymize } from "anonyma";
|
|
381
388
|
*
|
|
382
|
-
* // Apply HIPAA preset — redacts
|
|
389
|
+
* // Apply HIPAA preset — redacts the Safe Harbor identifiers that have a detector
|
|
383
390
|
* anonymize(text, { preset: "hipaa" });
|
|
384
391
|
*
|
|
385
|
-
* // Extend GDPR preset with API key detection
|
|
386
|
-
*
|
|
392
|
+
* // Extend GDPR preset with API key detection (anonymize() uses the preset's categories)
|
|
393
|
+
* import { compilePipeline } from "anonyma/engine";
|
|
394
|
+
* compilePipeline({ preset: "gdpr", categories: [...getPreset("gdpr").categories, "api-key"] });
|
|
387
395
|
* ```
|
|
388
396
|
*/
|
|
389
397
|
|
|
@@ -537,7 +545,8 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
|
|
|
537
545
|
* `pepper` makes the output specific to your deployment and prevents
|
|
538
546
|
* rainbow-table attacks.
|
|
539
547
|
*
|
|
540
|
-
*
|
|
548
|
+
* Uses the Web Crypto API: `globalThis.crypto` where the runtime exposes it,
|
|
549
|
+
* and Node's own implementation (`node:crypto`) on Node.js 18, which does not.
|
|
541
550
|
*/
|
|
542
551
|
|
|
543
552
|
/**
|
|
@@ -547,7 +556,7 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
|
|
|
547
556
|
* @param options - Hashing configuration.
|
|
548
557
|
* @returns A Promise that resolves to a hex-encoded (possibly truncated) hash.
|
|
549
558
|
*
|
|
550
|
-
* @throws {@link CryptoNotAvailableError} When
|
|
559
|
+
* @throws {@link CryptoNotAvailableError} When the runtime has no Web Crypto API at all.
|
|
551
560
|
* @throws {@link ValidationError} When `truncate` is not a positive integer ≤ 64.
|
|
552
561
|
*
|
|
553
562
|
* @example
|
|
@@ -650,6 +659,7 @@ declare function synthesize(value: string, category: string, options?: Synthesiz
|
|
|
650
659
|
* }
|
|
651
660
|
* ```
|
|
652
661
|
*/
|
|
662
|
+
|
|
653
663
|
/**
|
|
654
664
|
* Base class for all errors thrown by the anonyma library.
|
|
655
665
|
* Consumers can use `err instanceof AnonymaError` to narrowly handle library errors.
|
|
@@ -768,5 +778,77 @@ declare class BatchProcessingError extends AnonymaError {
|
|
|
768
778
|
readonly total: number;
|
|
769
779
|
constructor(succeeded: number, failed: number, total: number);
|
|
770
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* Thrown by a synchronous pipeline entry point when a replacer returns a
|
|
783
|
+
* promise. Use the asynchronous entry point (`transformAsync()`, an async
|
|
784
|
+
* chunk transformer, or an async stream) with that replacer instead.
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```ts
|
|
788
|
+
* throw new AsyncStrategyError("email");
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
declare class AsyncStrategyError extends AnonymaError {
|
|
792
|
+
/** The category whose replacer is asynchronous. */
|
|
793
|
+
readonly category: string;
|
|
794
|
+
constructor(category: string);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Thrown when a key version is unknown, destroyed, malformed, or cannot be
|
|
798
|
+
* derived. The message never contains key material.
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* ```ts
|
|
802
|
+
* throw new KeyManagementError("key version has been destroyed", "k1");
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
declare class KeyManagementError extends AnonymaError {
|
|
806
|
+
/** The key version the error refers to, when there is one. */
|
|
807
|
+
readonly keyId: string | undefined;
|
|
808
|
+
constructor(reason: string, keyId?: string);
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Thrown when a token vault operation fails or would corrupt the vault. The
|
|
812
|
+
* message never contains an original value.
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```ts
|
|
816
|
+
* throw new TokenVaultError("token identifier collision; increase idLength");
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
declare class TokenVaultError extends AnonymaError {
|
|
820
|
+
constructor(reason: string);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Thrown when a policy document is malformed or violates a requirement of a
|
|
824
|
+
* regulation it extends. `issues` lists every problem that was found.
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* ```ts
|
|
828
|
+
* try {
|
|
829
|
+
* parsePolicy(document);
|
|
830
|
+
* } catch (err) {
|
|
831
|
+
* if (err instanceof PolicyError) {
|
|
832
|
+
* for (const issue of err.issues) console.error(issue.path, issue.message);
|
|
833
|
+
* }
|
|
834
|
+
* }
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
837
|
+
declare class PolicyError extends AnonymaError {
|
|
838
|
+
/** Every problem found in the document, errors first. */
|
|
839
|
+
readonly issues: readonly PolicyIssue[];
|
|
840
|
+
constructor(issues: readonly PolicyIssue[]);
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Thrown when the audit chain cannot be extended or does not verify.
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```ts
|
|
847
|
+
* throw new AuditIntegrityError("a sink rejected record 12; the logger is closed");
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
declare class AuditIntegrityError extends AnonymaError {
|
|
851
|
+
constructor(reason: string);
|
|
852
|
+
}
|
|
771
853
|
|
|
772
|
-
export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
|
|
854
|
+
export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, AsyncStrategyError, AuditIntegrityError, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, KeyManagementError, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, PolicyError, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenVaultError, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap,
|
|
2
|
-
export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-
|
|
1
|
+
import { A as AnonymizeOptions, a as AnonymizeResult, F as FieldRuleMap, e as AnonymizerConfig, f as Anonymizer, P as PiiCategory, D as Detector, g as PiiMatch, h as DetokenizeResult, T as TokenizeOptions, b as TokenizeResult, B as BatchResult, C as CompliancePreset, S as StrategyOptions, i as AnonymizationRule, M as MaskOptions, R as RedactOptions, c as PseudonymizeOptions, H as HashOptions, G as GeneralizeOptions, d as SynthesizeOptions } from './types-EJTj_BKY.js';
|
|
2
|
+
export { j as AnonymaPlugin, k as CustomPattern, l as DetectorRegistry, E as EncryptOptions, m as FieldRule, L as Locale, n as StrategyName, o as TokenFormat, V as ValidatorFunction } from './types-EJTj_BKY.js';
|
|
3
3
|
export { decrypt, encrypt } from './crypto.js';
|
|
4
|
+
import { c as PolicyIssue } from './types--tPm_AjY.js';
|
|
5
|
+
import './types-Dtht33aq.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* @module anonymize
|
|
@@ -371,19 +373,25 @@ declare function detectBatch(texts: readonly string[], categories?: readonly Pii
|
|
|
371
373
|
|
|
372
374
|
/**
|
|
373
375
|
* @module presets
|
|
374
|
-
* @description Built-in compliance preset configurations for GDPR,
|
|
375
|
-
* PCI-DSS, SOX, and FERPA. Import from `"anonyma"`
|
|
376
|
-
* `preset` option in {@link AnonymizeOptions}.
|
|
376
|
+
* @description Built-in compliance preset configurations for GDPR, LGPD,
|
|
377
|
+
* PIPEDA, CCPA/CPRA, HIPAA, PCI-DSS, SOX, and FERPA. Import from `"anonyma"`
|
|
378
|
+
* or extend using the `preset` option in {@link AnonymizeOptions}.
|
|
379
|
+
*
|
|
380
|
+
* A preset selects the categories that the library can detect for an
|
|
381
|
+
* instrument and the strategy applied to them. The legal provisions behind
|
|
382
|
+
* each category, and the data elements each instrument names that no detector
|
|
383
|
+
* covers, are documented in `"anonyma/compliance"`.
|
|
377
384
|
*
|
|
378
385
|
* @example
|
|
379
386
|
* ```ts
|
|
380
387
|
* import { anonymize } from "anonyma";
|
|
381
388
|
*
|
|
382
|
-
* // Apply HIPAA preset — redacts
|
|
389
|
+
* // Apply HIPAA preset — redacts the Safe Harbor identifiers that have a detector
|
|
383
390
|
* anonymize(text, { preset: "hipaa" });
|
|
384
391
|
*
|
|
385
|
-
* // Extend GDPR preset with API key detection
|
|
386
|
-
*
|
|
392
|
+
* // Extend GDPR preset with API key detection (anonymize() uses the preset's categories)
|
|
393
|
+
* import { compilePipeline } from "anonyma/engine";
|
|
394
|
+
* compilePipeline({ preset: "gdpr", categories: [...getPreset("gdpr").categories, "api-key"] });
|
|
387
395
|
* ```
|
|
388
396
|
*/
|
|
389
397
|
|
|
@@ -537,7 +545,8 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
|
|
|
537
545
|
* `pepper` makes the output specific to your deployment and prevents
|
|
538
546
|
* rainbow-table attacks.
|
|
539
547
|
*
|
|
540
|
-
*
|
|
548
|
+
* Uses the Web Crypto API: `globalThis.crypto` where the runtime exposes it,
|
|
549
|
+
* and Node's own implementation (`node:crypto`) on Node.js 18, which does not.
|
|
541
550
|
*/
|
|
542
551
|
|
|
543
552
|
/**
|
|
@@ -547,7 +556,7 @@ declare function pseudonymize(value: string, options?: PseudonymizeOptions): str
|
|
|
547
556
|
* @param options - Hashing configuration.
|
|
548
557
|
* @returns A Promise that resolves to a hex-encoded (possibly truncated) hash.
|
|
549
558
|
*
|
|
550
|
-
* @throws {@link CryptoNotAvailableError} When
|
|
559
|
+
* @throws {@link CryptoNotAvailableError} When the runtime has no Web Crypto API at all.
|
|
551
560
|
* @throws {@link ValidationError} When `truncate` is not a positive integer ≤ 64.
|
|
552
561
|
*
|
|
553
562
|
* @example
|
|
@@ -650,6 +659,7 @@ declare function synthesize(value: string, category: string, options?: Synthesiz
|
|
|
650
659
|
* }
|
|
651
660
|
* ```
|
|
652
661
|
*/
|
|
662
|
+
|
|
653
663
|
/**
|
|
654
664
|
* Base class for all errors thrown by the anonyma library.
|
|
655
665
|
* Consumers can use `err instanceof AnonymaError` to narrowly handle library errors.
|
|
@@ -768,5 +778,77 @@ declare class BatchProcessingError extends AnonymaError {
|
|
|
768
778
|
readonly total: number;
|
|
769
779
|
constructor(succeeded: number, failed: number, total: number);
|
|
770
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* Thrown by a synchronous pipeline entry point when a replacer returns a
|
|
783
|
+
* promise. Use the asynchronous entry point (`transformAsync()`, an async
|
|
784
|
+
* chunk transformer, or an async stream) with that replacer instead.
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```ts
|
|
788
|
+
* throw new AsyncStrategyError("email");
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
declare class AsyncStrategyError extends AnonymaError {
|
|
792
|
+
/** The category whose replacer is asynchronous. */
|
|
793
|
+
readonly category: string;
|
|
794
|
+
constructor(category: string);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Thrown when a key version is unknown, destroyed, malformed, or cannot be
|
|
798
|
+
* derived. The message never contains key material.
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* ```ts
|
|
802
|
+
* throw new KeyManagementError("key version has been destroyed", "k1");
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
declare class KeyManagementError extends AnonymaError {
|
|
806
|
+
/** The key version the error refers to, when there is one. */
|
|
807
|
+
readonly keyId: string | undefined;
|
|
808
|
+
constructor(reason: string, keyId?: string);
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Thrown when a token vault operation fails or would corrupt the vault. The
|
|
812
|
+
* message never contains an original value.
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```ts
|
|
816
|
+
* throw new TokenVaultError("token identifier collision; increase idLength");
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
declare class TokenVaultError extends AnonymaError {
|
|
820
|
+
constructor(reason: string);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Thrown when a policy document is malformed or violates a requirement of a
|
|
824
|
+
* regulation it extends. `issues` lists every problem that was found.
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* ```ts
|
|
828
|
+
* try {
|
|
829
|
+
* parsePolicy(document);
|
|
830
|
+
* } catch (err) {
|
|
831
|
+
* if (err instanceof PolicyError) {
|
|
832
|
+
* for (const issue of err.issues) console.error(issue.path, issue.message);
|
|
833
|
+
* }
|
|
834
|
+
* }
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
837
|
+
declare class PolicyError extends AnonymaError {
|
|
838
|
+
/** Every problem found in the document, errors first. */
|
|
839
|
+
readonly issues: readonly PolicyIssue[];
|
|
840
|
+
constructor(issues: readonly PolicyIssue[]);
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Thrown when the audit chain cannot be extended or does not verify.
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```ts
|
|
847
|
+
* throw new AuditIntegrityError("a sink rejected record 12; the logger is closed");
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
declare class AuditIntegrityError extends AnonymaError {
|
|
851
|
+
constructor(reason: string);
|
|
852
|
+
}
|
|
771
853
|
|
|
772
|
-
export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
|
|
854
|
+
export { AllowlistMatchError, AnonymaError, AnonymizationRule, AnonymizeOptions, AnonymizeResult, Anonymizer, AnonymizerConfig, AsyncStrategyError, AuditIntegrityError, BatchProcessingError, BatchResult, CompliancePreset, CryptoNotAvailableError, Detector, DetokenizeResult, EncryptionError, FieldRuleMap, GeneralizeOptions, HashOptions, KeyManagementError, MaskOptions, PRESET_REGISTRY, PiiCategory, PiiMatch, PolicyError, type PresetConfig, PresetNotFoundError, PseudonymizeOptions, RedactOptions, StrategyOptions, SynthesizeOptions, TokenVaultError, TokenizeOptions, TokenizeResult, UnknownCategoryError, UnsupportedStrategyError, ValidationError, anonymize, anonymizeAsync, anonymizeBatch, anonymizeBatchAsync, anonymizeObject, anonymizeRecord, createAnonymizer, detect, detectBatch, detokenize, generalize, getPreset, hasPII, hash, mask, pseudonymize, redact, restoreFromLLM, sanitizeForLLM, synthesize, tokenize, tokenizeAsync, tokenizeBatch };
|