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
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { P as PiiCategory } from './types-EJTj_BKY.js';
|
|
2
|
+
import { S as StrategySpec, P as PatternSpec, O as OverlapPolicy } from './types-Dtht33aq.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @module compliance/types
|
|
6
|
+
* @description Contracts of the compliance layer exposed as
|
|
7
|
+
* `"anonyma/compliance"`: regulation profiles mapped to legal provisions, the
|
|
8
|
+
* protection each provision requires, and the policy document format. This
|
|
9
|
+
* module contains types only — it has no runtime code.
|
|
10
|
+
*
|
|
11
|
+
* The profiles encode technical measures that the cited provisions call for.
|
|
12
|
+
* They are engineering aids, not legal advice, and using them does not by
|
|
13
|
+
* itself make a system compliant.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Regulations and standards for which a profile is available.
|
|
18
|
+
*/
|
|
19
|
+
type RegulationId = "gdpr" | "lgpd" | "pipeda" | "ccpa" | "hipaa" | "pci-dss";
|
|
20
|
+
/**
|
|
21
|
+
* A pointer to one legal provision or standard requirement.
|
|
22
|
+
*/
|
|
23
|
+
interface LegalReference {
|
|
24
|
+
/** Precise citation, e.g. `"GDPR Art. 32(1)(a)"` or `"45 CFR § 164.514(b)(2)(i)(A)"`. */
|
|
25
|
+
readonly citation: string;
|
|
26
|
+
/** Short description of what the provision says. */
|
|
27
|
+
readonly summary: string;
|
|
28
|
+
/** Link to an official or primary source. */
|
|
29
|
+
readonly url?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Properties a transformed value must have, expressed independently of any
|
|
33
|
+
* strategy name. Every member is a restriction; an empty object means "any
|
|
34
|
+
* transformation that removes the clear value is acceptable".
|
|
35
|
+
*/
|
|
36
|
+
interface ProtectionRequirement {
|
|
37
|
+
/** Nobody — not even the key or vault holder — may be able to restore the value. */
|
|
38
|
+
readonly irreversible?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The output must not be computed from the value (no hash, keyed hash,
|
|
41
|
+
* encryption, or deterministic pseudonym of it).
|
|
42
|
+
*/
|
|
43
|
+
readonly notDerived?: boolean;
|
|
44
|
+
/** When the output is computed from the value, a secret key must be involved. */
|
|
45
|
+
readonly keyed?: boolean;
|
|
46
|
+
/** Maximum number of original characters that may remain visible. */
|
|
47
|
+
readonly maxRevealed?: {
|
|
48
|
+
/** Leading characters. */
|
|
49
|
+
readonly leading: number;
|
|
50
|
+
/** Trailing characters. */
|
|
51
|
+
readonly trailing: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* What a strategy configuration actually does to a value, in the same terms
|
|
56
|
+
* as {@link ProtectionRequirement}.
|
|
57
|
+
*/
|
|
58
|
+
interface StrategyTraits {
|
|
59
|
+
/** Someone holding the right key, vault or mapping can restore the value. */
|
|
60
|
+
readonly reversible: boolean;
|
|
61
|
+
/** The output is computed from the value. */
|
|
62
|
+
readonly derived: boolean;
|
|
63
|
+
/** A secret is involved in computing the output. */
|
|
64
|
+
readonly keyed: boolean;
|
|
65
|
+
/** Equal inputs yield equal outputs, so records can be linked. */
|
|
66
|
+
readonly linkable: boolean;
|
|
67
|
+
/** Original characters left visible; `"all"` when the value may pass through unchanged. */
|
|
68
|
+
readonly revealed: {
|
|
69
|
+
readonly leading: number;
|
|
70
|
+
readonly trailing: number;
|
|
71
|
+
} | "all";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The requirement a regulation places on one category of data.
|
|
75
|
+
*/
|
|
76
|
+
interface CategoryRule {
|
|
77
|
+
/** The category the rule applies to. */
|
|
78
|
+
readonly category: PiiCategory;
|
|
79
|
+
/** The provisions that bring this category into scope. */
|
|
80
|
+
readonly references: readonly LegalReference[];
|
|
81
|
+
/** The minimum protection the transformed value must have. */
|
|
82
|
+
readonly requirement: ProtectionRequirement;
|
|
83
|
+
/** The strategy the built-in preset applies. Satisfies `requirement`. */
|
|
84
|
+
readonly recommended: StrategySpec;
|
|
85
|
+
/** Why this requirement follows from the references. */
|
|
86
|
+
readonly rationale: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A data element the regulation names that the library cannot detect.
|
|
90
|
+
*/
|
|
91
|
+
interface CoverageGap {
|
|
92
|
+
/** The data element, as the regulation names it. */
|
|
93
|
+
readonly element: string;
|
|
94
|
+
/** The provision that names it. */
|
|
95
|
+
readonly reference: LegalReference;
|
|
96
|
+
/** What a deployment has to do about it. */
|
|
97
|
+
readonly mitigation: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Everything the library knows about one regulation.
|
|
101
|
+
*/
|
|
102
|
+
interface RegulationProfile {
|
|
103
|
+
/** Identifier, also usable as a preset name. */
|
|
104
|
+
readonly id: RegulationId;
|
|
105
|
+
/** Full name of the instrument. */
|
|
106
|
+
readonly name: string;
|
|
107
|
+
/** Where it applies. */
|
|
108
|
+
readonly jurisdiction: string;
|
|
109
|
+
/** Edition or consolidated version the profile was written against. */
|
|
110
|
+
readonly edition: string;
|
|
111
|
+
/** Provisions that apply to the processing as a whole (security, erasure, record keeping). */
|
|
112
|
+
readonly references: readonly LegalReference[];
|
|
113
|
+
/** Per-category requirements. */
|
|
114
|
+
readonly rules: readonly CategoryRule[];
|
|
115
|
+
/** Named data elements with no detector. */
|
|
116
|
+
readonly gaps: readonly CoverageGap[];
|
|
117
|
+
/** Whether an audit trail of anonymization operations is expected, and under which provision. */
|
|
118
|
+
readonly auditTrail?: LegalReference;
|
|
119
|
+
/** The provision that grants erasure, when the instrument has one. */
|
|
120
|
+
readonly erasure?: LegalReference;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A policy as written by a user, typically in a JSON file. Everything is plain
|
|
124
|
+
* data.
|
|
125
|
+
*/
|
|
126
|
+
interface PolicyDocument {
|
|
127
|
+
/** Policy format version. */
|
|
128
|
+
readonly version: 1;
|
|
129
|
+
/** Identifier recorded in audit events. */
|
|
130
|
+
readonly id: string;
|
|
131
|
+
/** Human-readable description. */
|
|
132
|
+
readonly description?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Regulations the policy must satisfy. Their categories are merged and, per
|
|
135
|
+
* category, the requirements of all listed regulations apply together.
|
|
136
|
+
*/
|
|
137
|
+
readonly extends?: readonly RegulationId[];
|
|
138
|
+
/** Categories to add to, or remove from, those implied by `extends`. */
|
|
139
|
+
readonly categories?: {
|
|
140
|
+
/** Categories to detect in addition. */
|
|
141
|
+
readonly include?: readonly PiiCategory[];
|
|
142
|
+
/** Categories to stop detecting. Excluding a category a regulation requires is a violation. */
|
|
143
|
+
readonly exclude?: readonly PiiCategory[];
|
|
144
|
+
};
|
|
145
|
+
/** Strategy for categories without a rule. */
|
|
146
|
+
readonly defaultStrategy?: StrategySpec;
|
|
147
|
+
/** Per-category strategies, keyed by category label. */
|
|
148
|
+
readonly rules?: Readonly<Record<string, StrategySpec>>;
|
|
149
|
+
/** Additional regular-expression detectors. */
|
|
150
|
+
readonly patterns?: readonly PatternSpec[];
|
|
151
|
+
/** Detections below this confidence are ignored. */
|
|
152
|
+
readonly minConfidence?: number;
|
|
153
|
+
/** Exact values to leave untouched. */
|
|
154
|
+
readonly allow?: readonly string[];
|
|
155
|
+
/** Use the aggressive variant of the built-in detectors. */
|
|
156
|
+
readonly aggressive?: boolean;
|
|
157
|
+
/** Overlap resolution policy. */
|
|
158
|
+
readonly overlap?: OverlapPolicy;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A problem found while parsing or checking a policy.
|
|
162
|
+
*/
|
|
163
|
+
interface PolicyIssue {
|
|
164
|
+
/**
|
|
165
|
+
* - `"error"`: the document is malformed, or it violates a requirement of a
|
|
166
|
+
* regulation it extends.
|
|
167
|
+
* - `"warning"`: the document is valid but weaker than recommended.
|
|
168
|
+
*/
|
|
169
|
+
readonly severity: "error" | "warning";
|
|
170
|
+
/** JSON Pointer to the offending member of the document. */
|
|
171
|
+
readonly path: string;
|
|
172
|
+
/** Machine-readable issue code. */
|
|
173
|
+
readonly code: string;
|
|
174
|
+
/** Human-readable explanation. Never contains values from the document's `allow` list. */
|
|
175
|
+
readonly message: string;
|
|
176
|
+
/** The provision that is violated, for compliance issues. */
|
|
177
|
+
readonly reference?: LegalReference;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A parsed and checked policy, ready to be compiled into a pipeline.
|
|
181
|
+
*/
|
|
182
|
+
interface Policy {
|
|
183
|
+
/** The policy identifier. */
|
|
184
|
+
readonly id: string;
|
|
185
|
+
/** The regulations the policy extends. */
|
|
186
|
+
readonly regulations: readonly RegulationId[];
|
|
187
|
+
/** The categories the policy detects, in a stable order. */
|
|
188
|
+
readonly categories: readonly PiiCategory[];
|
|
189
|
+
/** The effective strategy for every category in `categories`. */
|
|
190
|
+
readonly strategies: Readonly<Record<string, StrategySpec>>;
|
|
191
|
+
/** The effective default strategy. */
|
|
192
|
+
readonly defaultStrategy: StrategySpec;
|
|
193
|
+
/** The normalised source document. */
|
|
194
|
+
readonly document: PolicyDocument;
|
|
195
|
+
/** Warnings raised while checking. A `Policy` never carries errors. */
|
|
196
|
+
readonly warnings: readonly PolicyIssue[];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type { CategoryRule as C, LegalReference as L, ProtectionRequirement as P, RegulationId as R, StrategyTraits as S, RegulationProfile as a, Policy as b, PolicyIssue as c, PolicyDocument as d, CoverageGap as e };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { P as PiiCategory } from './types-EJTj_BKY.cjs';
|
|
2
|
+
import { S as StrategySpec, P as PatternSpec, O as OverlapPolicy } from './types-CPUhjvl8.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @module compliance/types
|
|
6
|
+
* @description Contracts of the compliance layer exposed as
|
|
7
|
+
* `"anonyma/compliance"`: regulation profiles mapped to legal provisions, the
|
|
8
|
+
* protection each provision requires, and the policy document format. This
|
|
9
|
+
* module contains types only — it has no runtime code.
|
|
10
|
+
*
|
|
11
|
+
* The profiles encode technical measures that the cited provisions call for.
|
|
12
|
+
* They are engineering aids, not legal advice, and using them does not by
|
|
13
|
+
* itself make a system compliant.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Regulations and standards for which a profile is available.
|
|
18
|
+
*/
|
|
19
|
+
type RegulationId = "gdpr" | "lgpd" | "pipeda" | "ccpa" | "hipaa" | "pci-dss";
|
|
20
|
+
/**
|
|
21
|
+
* A pointer to one legal provision or standard requirement.
|
|
22
|
+
*/
|
|
23
|
+
interface LegalReference {
|
|
24
|
+
/** Precise citation, e.g. `"GDPR Art. 32(1)(a)"` or `"45 CFR § 164.514(b)(2)(i)(A)"`. */
|
|
25
|
+
readonly citation: string;
|
|
26
|
+
/** Short description of what the provision says. */
|
|
27
|
+
readonly summary: string;
|
|
28
|
+
/** Link to an official or primary source. */
|
|
29
|
+
readonly url?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Properties a transformed value must have, expressed independently of any
|
|
33
|
+
* strategy name. Every member is a restriction; an empty object means "any
|
|
34
|
+
* transformation that removes the clear value is acceptable".
|
|
35
|
+
*/
|
|
36
|
+
interface ProtectionRequirement {
|
|
37
|
+
/** Nobody — not even the key or vault holder — may be able to restore the value. */
|
|
38
|
+
readonly irreversible?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The output must not be computed from the value (no hash, keyed hash,
|
|
41
|
+
* encryption, or deterministic pseudonym of it).
|
|
42
|
+
*/
|
|
43
|
+
readonly notDerived?: boolean;
|
|
44
|
+
/** When the output is computed from the value, a secret key must be involved. */
|
|
45
|
+
readonly keyed?: boolean;
|
|
46
|
+
/** Maximum number of original characters that may remain visible. */
|
|
47
|
+
readonly maxRevealed?: {
|
|
48
|
+
/** Leading characters. */
|
|
49
|
+
readonly leading: number;
|
|
50
|
+
/** Trailing characters. */
|
|
51
|
+
readonly trailing: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* What a strategy configuration actually does to a value, in the same terms
|
|
56
|
+
* as {@link ProtectionRequirement}.
|
|
57
|
+
*/
|
|
58
|
+
interface StrategyTraits {
|
|
59
|
+
/** Someone holding the right key, vault or mapping can restore the value. */
|
|
60
|
+
readonly reversible: boolean;
|
|
61
|
+
/** The output is computed from the value. */
|
|
62
|
+
readonly derived: boolean;
|
|
63
|
+
/** A secret is involved in computing the output. */
|
|
64
|
+
readonly keyed: boolean;
|
|
65
|
+
/** Equal inputs yield equal outputs, so records can be linked. */
|
|
66
|
+
readonly linkable: boolean;
|
|
67
|
+
/** Original characters left visible; `"all"` when the value may pass through unchanged. */
|
|
68
|
+
readonly revealed: {
|
|
69
|
+
readonly leading: number;
|
|
70
|
+
readonly trailing: number;
|
|
71
|
+
} | "all";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The requirement a regulation places on one category of data.
|
|
75
|
+
*/
|
|
76
|
+
interface CategoryRule {
|
|
77
|
+
/** The category the rule applies to. */
|
|
78
|
+
readonly category: PiiCategory;
|
|
79
|
+
/** The provisions that bring this category into scope. */
|
|
80
|
+
readonly references: readonly LegalReference[];
|
|
81
|
+
/** The minimum protection the transformed value must have. */
|
|
82
|
+
readonly requirement: ProtectionRequirement;
|
|
83
|
+
/** The strategy the built-in preset applies. Satisfies `requirement`. */
|
|
84
|
+
readonly recommended: StrategySpec;
|
|
85
|
+
/** Why this requirement follows from the references. */
|
|
86
|
+
readonly rationale: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A data element the regulation names that the library cannot detect.
|
|
90
|
+
*/
|
|
91
|
+
interface CoverageGap {
|
|
92
|
+
/** The data element, as the regulation names it. */
|
|
93
|
+
readonly element: string;
|
|
94
|
+
/** The provision that names it. */
|
|
95
|
+
readonly reference: LegalReference;
|
|
96
|
+
/** What a deployment has to do about it. */
|
|
97
|
+
readonly mitigation: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Everything the library knows about one regulation.
|
|
101
|
+
*/
|
|
102
|
+
interface RegulationProfile {
|
|
103
|
+
/** Identifier, also usable as a preset name. */
|
|
104
|
+
readonly id: RegulationId;
|
|
105
|
+
/** Full name of the instrument. */
|
|
106
|
+
readonly name: string;
|
|
107
|
+
/** Where it applies. */
|
|
108
|
+
readonly jurisdiction: string;
|
|
109
|
+
/** Edition or consolidated version the profile was written against. */
|
|
110
|
+
readonly edition: string;
|
|
111
|
+
/** Provisions that apply to the processing as a whole (security, erasure, record keeping). */
|
|
112
|
+
readonly references: readonly LegalReference[];
|
|
113
|
+
/** Per-category requirements. */
|
|
114
|
+
readonly rules: readonly CategoryRule[];
|
|
115
|
+
/** Named data elements with no detector. */
|
|
116
|
+
readonly gaps: readonly CoverageGap[];
|
|
117
|
+
/** Whether an audit trail of anonymization operations is expected, and under which provision. */
|
|
118
|
+
readonly auditTrail?: LegalReference;
|
|
119
|
+
/** The provision that grants erasure, when the instrument has one. */
|
|
120
|
+
readonly erasure?: LegalReference;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A policy as written by a user, typically in a JSON file. Everything is plain
|
|
124
|
+
* data.
|
|
125
|
+
*/
|
|
126
|
+
interface PolicyDocument {
|
|
127
|
+
/** Policy format version. */
|
|
128
|
+
readonly version: 1;
|
|
129
|
+
/** Identifier recorded in audit events. */
|
|
130
|
+
readonly id: string;
|
|
131
|
+
/** Human-readable description. */
|
|
132
|
+
readonly description?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Regulations the policy must satisfy. Their categories are merged and, per
|
|
135
|
+
* category, the requirements of all listed regulations apply together.
|
|
136
|
+
*/
|
|
137
|
+
readonly extends?: readonly RegulationId[];
|
|
138
|
+
/** Categories to add to, or remove from, those implied by `extends`. */
|
|
139
|
+
readonly categories?: {
|
|
140
|
+
/** Categories to detect in addition. */
|
|
141
|
+
readonly include?: readonly PiiCategory[];
|
|
142
|
+
/** Categories to stop detecting. Excluding a category a regulation requires is a violation. */
|
|
143
|
+
readonly exclude?: readonly PiiCategory[];
|
|
144
|
+
};
|
|
145
|
+
/** Strategy for categories without a rule. */
|
|
146
|
+
readonly defaultStrategy?: StrategySpec;
|
|
147
|
+
/** Per-category strategies, keyed by category label. */
|
|
148
|
+
readonly rules?: Readonly<Record<string, StrategySpec>>;
|
|
149
|
+
/** Additional regular-expression detectors. */
|
|
150
|
+
readonly patterns?: readonly PatternSpec[];
|
|
151
|
+
/** Detections below this confidence are ignored. */
|
|
152
|
+
readonly minConfidence?: number;
|
|
153
|
+
/** Exact values to leave untouched. */
|
|
154
|
+
readonly allow?: readonly string[];
|
|
155
|
+
/** Use the aggressive variant of the built-in detectors. */
|
|
156
|
+
readonly aggressive?: boolean;
|
|
157
|
+
/** Overlap resolution policy. */
|
|
158
|
+
readonly overlap?: OverlapPolicy;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A problem found while parsing or checking a policy.
|
|
162
|
+
*/
|
|
163
|
+
interface PolicyIssue {
|
|
164
|
+
/**
|
|
165
|
+
* - `"error"`: the document is malformed, or it violates a requirement of a
|
|
166
|
+
* regulation it extends.
|
|
167
|
+
* - `"warning"`: the document is valid but weaker than recommended.
|
|
168
|
+
*/
|
|
169
|
+
readonly severity: "error" | "warning";
|
|
170
|
+
/** JSON Pointer to the offending member of the document. */
|
|
171
|
+
readonly path: string;
|
|
172
|
+
/** Machine-readable issue code. */
|
|
173
|
+
readonly code: string;
|
|
174
|
+
/** Human-readable explanation. Never contains values from the document's `allow` list. */
|
|
175
|
+
readonly message: string;
|
|
176
|
+
/** The provision that is violated, for compliance issues. */
|
|
177
|
+
readonly reference?: LegalReference;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A parsed and checked policy, ready to be compiled into a pipeline.
|
|
181
|
+
*/
|
|
182
|
+
interface Policy {
|
|
183
|
+
/** The policy identifier. */
|
|
184
|
+
readonly id: string;
|
|
185
|
+
/** The regulations the policy extends. */
|
|
186
|
+
readonly regulations: readonly RegulationId[];
|
|
187
|
+
/** The categories the policy detects, in a stable order. */
|
|
188
|
+
readonly categories: readonly PiiCategory[];
|
|
189
|
+
/** The effective strategy for every category in `categories`. */
|
|
190
|
+
readonly strategies: Readonly<Record<string, StrategySpec>>;
|
|
191
|
+
/** The effective default strategy. */
|
|
192
|
+
readonly defaultStrategy: StrategySpec;
|
|
193
|
+
/** The normalised source document. */
|
|
194
|
+
readonly document: PolicyDocument;
|
|
195
|
+
/** Warnings raised while checking. A `Policy` never carries errors. */
|
|
196
|
+
readonly warnings: readonly PolicyIssue[];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type { CategoryRule as C, LegalReference as L, ProtectionRequirement as P, RegulationId as R, StrategyTraits as S, RegulationProfile as a, Policy as b, PolicyIssue as c, PolicyDocument as d, CoverageGap as e };
|