@quba/sensitive-data-protection 0.2.2 → 0.2.4
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/README.md +1 -0
- package/dist/index.cjs +195 -108
- package/dist/index.d.cts +259 -113
- package/dist/index.d.mts +259 -113
- package/dist/index.mjs +189 -109
- package/docs/AllowRule.md +39 -0
- package/docs/DetectRule.md +2 -0
- package/docs/EncryptRule.md +2 -0
- package/docs/EntityBody.md +2 -0
- package/docs/FieldErrorCode.md +1 -1
- package/docs/FileModelResult.md +2 -0
- package/docs/FileRegexResult.md +2 -0
- package/docs/FileResult.md +2 -0
- package/docs/HMACRule.md +2 -0
- package/docs/MaskRule.md +2 -0
- package/docs/ModelEntity.md +2 -0
- package/docs/PolicyDocument.md +4 -0
- package/docs/PolicyDocumentRulesInner.md +2 -0
- package/docs/PseudonymizeRule.md +2 -0
- package/docs/RedactRule.md +2 -0
- package/docs/ReplaceRule.md +2 -0
- package/docs/RuleBody.md +2 -0
- package/docs/SHA256Rule.md +2 -0
- package/docs/SHA512Rule.md +2 -0
- package/docs/SensitiveDataProtectionApi.md +2 -2
- package/package.json +1 -1
package/docs/FileModelResult.md
CHANGED
|
@@ -15,6 +15,7 @@ Name | Type
|
|
|
15
15
|
`input` | string
|
|
16
16
|
`output` | string
|
|
17
17
|
`path` | Array<Array<PathSegment>>
|
|
18
|
+
`action` | [Action](Action.md)
|
|
18
19
|
|
|
19
20
|
## Example
|
|
20
21
|
|
|
@@ -31,6 +32,7 @@ const example = {
|
|
|
31
32
|
"input": null,
|
|
32
33
|
"output": null,
|
|
33
34
|
"path": null,
|
|
35
|
+
"action": null,
|
|
34
36
|
} satisfies FileModelResult
|
|
35
37
|
|
|
36
38
|
console.log(example)
|
package/docs/FileRegexResult.md
CHANGED
|
@@ -14,6 +14,7 @@ Name | Type
|
|
|
14
14
|
`input` | string
|
|
15
15
|
`output` | string
|
|
16
16
|
`path` | Array<Array<PathSegment>>
|
|
17
|
+
`action` | [Action](Action.md)
|
|
17
18
|
|
|
18
19
|
## Example
|
|
19
20
|
|
|
@@ -29,6 +30,7 @@ const example = {
|
|
|
29
30
|
"input": null,
|
|
30
31
|
"output": null,
|
|
31
32
|
"path": null,
|
|
33
|
+
"action": null,
|
|
32
34
|
} satisfies FileRegexResult
|
|
33
35
|
|
|
34
36
|
console.log(example)
|
package/docs/FileResult.md
CHANGED
|
@@ -15,6 +15,7 @@ Name | Type
|
|
|
15
15
|
`input` | string
|
|
16
16
|
`output` | string
|
|
17
17
|
`path` | Array<Array<PathSegment>>
|
|
18
|
+
`action` | [Action](Action.md)
|
|
18
19
|
`content_type` | string
|
|
19
20
|
|
|
20
21
|
## Example
|
|
@@ -32,6 +33,7 @@ const example = {
|
|
|
32
33
|
"input": null,
|
|
33
34
|
"output": null,
|
|
34
35
|
"path": null,
|
|
36
|
+
"action": null,
|
|
35
37
|
"content_type": null,
|
|
36
38
|
} satisfies FileResult
|
|
37
39
|
|
package/docs/HMACRule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
`key` | string
|
|
14
15
|
`length` | number
|
|
15
16
|
|
|
@@ -23,6 +24,7 @@ const example = {
|
|
|
23
24
|
"type": null,
|
|
24
25
|
"entities": null,
|
|
25
26
|
"action": null,
|
|
27
|
+
"when": null,
|
|
26
28
|
"key": null,
|
|
27
29
|
"length": null,
|
|
28
30
|
} satisfies HMACRule
|
package/docs/MaskRule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
`masking_char` | string
|
|
14
15
|
`chars_to_mask` | number
|
|
15
16
|
`from_end` | boolean
|
|
@@ -24,6 +25,7 @@ const example = {
|
|
|
24
25
|
"type": null,
|
|
25
26
|
"entities": null,
|
|
26
27
|
"action": null,
|
|
28
|
+
"when": null,
|
|
27
29
|
"masking_char": null,
|
|
28
30
|
"chars_to_mask": null,
|
|
29
31
|
"from_end": null,
|
package/docs/ModelEntity.md
CHANGED
|
@@ -9,6 +9,7 @@ Name | Type
|
|
|
9
9
|
------------ | -------------
|
|
10
10
|
`type` | string
|
|
11
11
|
`value` | string
|
|
12
|
+
`threshold` | number
|
|
12
13
|
|
|
13
14
|
## Example
|
|
14
15
|
|
|
@@ -19,6 +20,7 @@ import type { ModelEntity } from '@quba/sensitive-data-protection'
|
|
|
19
20
|
const example = {
|
|
20
21
|
"type": null,
|
|
21
22
|
"value": null,
|
|
23
|
+
"threshold": null,
|
|
22
24
|
} satisfies ModelEntity
|
|
23
25
|
|
|
24
26
|
console.log(example)
|
package/docs/PolicyDocument.md
CHANGED
|
@@ -10,6 +10,8 @@ Name | Type
|
|
|
10
10
|
`schema_version` | number
|
|
11
11
|
`name` | string
|
|
12
12
|
`confidence_threshold` | number
|
|
13
|
+
`embedded_rules` | string
|
|
14
|
+
`models` | Array<string>
|
|
13
15
|
`rules` | [Array<PolicyDocumentRulesInner>](PolicyDocumentRulesInner.md)
|
|
14
16
|
|
|
15
17
|
## Example
|
|
@@ -22,6 +24,8 @@ const example = {
|
|
|
22
24
|
"schema_version": null,
|
|
23
25
|
"name": null,
|
|
24
26
|
"confidence_threshold": null,
|
|
27
|
+
"embedded_rules": null,
|
|
28
|
+
"models": null,
|
|
25
29
|
"rules": null,
|
|
26
30
|
} satisfies PolicyDocument
|
|
27
31
|
|
|
@@ -9,6 +9,7 @@ Name | Type
|
|
|
9
9
|
`type` | string
|
|
10
10
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
11
11
|
`action` | [Action](Action.md)
|
|
12
|
+
`when` | string
|
|
12
13
|
`replacement` | string
|
|
13
14
|
`masking_char` | string
|
|
14
15
|
`chars_to_mask` | number
|
|
@@ -27,6 +28,7 @@ const example = {
|
|
|
27
28
|
"type": null,
|
|
28
29
|
"entities": null,
|
|
29
30
|
"action": null,
|
|
31
|
+
"when": null,
|
|
30
32
|
"replacement": null,
|
|
31
33
|
"masking_char": null,
|
|
32
34
|
"chars_to_mask": null,
|
package/docs/PseudonymizeRule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
`tag` | string
|
|
14
15
|
|
|
15
16
|
## Example
|
|
@@ -22,6 +23,7 @@ const example = {
|
|
|
22
23
|
"type": null,
|
|
23
24
|
"entities": null,
|
|
24
25
|
"action": null,
|
|
26
|
+
"when": null,
|
|
25
27
|
"tag": null,
|
|
26
28
|
} satisfies PseudonymizeRule
|
|
27
29
|
|
package/docs/RedactRule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
|
|
14
15
|
## Example
|
|
15
16
|
|
|
@@ -21,6 +22,7 @@ const example = {
|
|
|
21
22
|
"type": null,
|
|
22
23
|
"entities": null,
|
|
23
24
|
"action": null,
|
|
25
|
+
"when": null,
|
|
24
26
|
} satisfies RedactRule
|
|
25
27
|
|
|
26
28
|
console.log(example)
|
package/docs/ReplaceRule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
`replacement` | string
|
|
14
15
|
|
|
15
16
|
## Example
|
|
@@ -22,6 +23,7 @@ const example = {
|
|
|
22
23
|
"type": null,
|
|
23
24
|
"entities": null,
|
|
24
25
|
"action": null,
|
|
26
|
+
"when": null,
|
|
25
27
|
"replacement": null,
|
|
26
28
|
} satisfies ReplaceRule
|
|
27
29
|
|
package/docs/RuleBody.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
`replacement` | string
|
|
14
15
|
`key` | string
|
|
15
16
|
`masking_char` | string
|
|
@@ -28,6 +29,7 @@ const example = {
|
|
|
28
29
|
"type": null,
|
|
29
30
|
"entities": null,
|
|
30
31
|
"action": null,
|
|
32
|
+
"when": null,
|
|
31
33
|
"replacement": null,
|
|
32
34
|
"key": null,
|
|
33
35
|
"masking_char": null,
|
package/docs/SHA256Rule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
|
|
14
15
|
## Example
|
|
15
16
|
|
|
@@ -21,6 +22,7 @@ const example = {
|
|
|
21
22
|
"type": null,
|
|
22
23
|
"entities": null,
|
|
23
24
|
"action": null,
|
|
25
|
+
"when": null,
|
|
24
26
|
} satisfies SHA256Rule
|
|
25
27
|
|
|
26
28
|
console.log(example)
|
package/docs/SHA512Rule.md
CHANGED
|
@@ -10,6 +10,7 @@ Name | Type
|
|
|
10
10
|
`type` | string
|
|
11
11
|
`entities` | [Array<EntityBody>](EntityBody.md)
|
|
12
12
|
`action` | [Action](Action.md)
|
|
13
|
+
`when` | string
|
|
13
14
|
|
|
14
15
|
## Example
|
|
15
16
|
|
|
@@ -21,6 +22,7 @@ const example = {
|
|
|
21
22
|
"type": null,
|
|
22
23
|
"entities": null,
|
|
23
24
|
"action": null,
|
|
25
|
+
"when": null,
|
|
24
26
|
} satisfies SHA512Rule
|
|
25
27
|
|
|
26
28
|
console.log(example)
|
|
@@ -44,7 +44,7 @@ async function example() {
|
|
|
44
44
|
rules: rules_example,
|
|
45
45
|
// number | Minimum score for model detections. Does not affect regex matches. (optional)
|
|
46
46
|
confidence_threshold: 8.14,
|
|
47
|
-
// string | Embedded content (embedded files, OLE objects, a FHIR JSON photo\\\'s base64 `data` on Patient, Practitioner, RelatedPerson or Person). `anonymize` (default): what can be read (an Office or text file; a PNG, JPEG, WebP, BMP or TIFF image where this server reads images) is anonymized as a file of its own and written back, the rest removed. `anonymize_or_keep`: the same, the rest kept unread. `remove`: all removed. `keep`: all kept unread. Thumbnails are always removed; fonts and printer settings always kept; an Office file\\\'s pictures are read and masked where this server reads images, whatever the rule. (optional)
|
|
47
|
+
// string | Embedded content (embedded files, OLE objects, a FHIR JSON photo\\\'s base64 `data` on Patient, Practitioner, RelatedPerson or Person). `anonymize` (default): what can be read (an Office or text file; a PNG, JPEG, WebP, BMP or TIFF image where this server reads images) is anonymized as a file of its own and written back, the rest removed. `anonymize_or_keep`: the same, the rest kept unread. `remove`: all removed. `keep`: all kept unread. Thumbnails are always removed; fonts and printer settings always kept; an Office file\\\'s pictures are read and masked where this server reads images, whatever the rule. A whole file this server can\\\'t read (its format, size or state) follows it too: `anonymize_or_keep` and `keep` return it unchanged with no results; the others refuse it with a 422 on `file`. (optional)
|
|
48
48
|
embedded_rules: embedded_rules_example,
|
|
49
49
|
// string | CSV, TSV and xlsx only: where a table\\\'s headers are, in the data\\\'s order (field 1, column A), so each value is read with its header. (optional)
|
|
50
50
|
table_headers: table_headers_example,
|
|
@@ -74,7 +74,7 @@ example().catch(console.error);
|
|
|
74
74
|
| **file** | `Blob` | The file: docx, xlsx, pptx, csv, tsv, txt, md, log, json, jsonl, xml, html, hl7 (HL7 v2), png, jpg, webp, bmp, tiff (one page) or dcm (DICOM Part 10). Office files, images, DICOM, XML, HTML, HL7 v2 and FHIR JSON are told by their bytes; other text by its part\\\'s `Content-Type` when specific, else its name\\\'s extension. | [Defaults to `undefined`] |
|
|
75
75
|
| **rules** | `string` | The de-identification rules, a JSON array as for `/anonymize`. Omit for the default rules. | [Optional] [Defaults to `undefined`] |
|
|
76
76
|
| **confidence_threshold** | `number` | Minimum score for model detections. Does not affect regex matches. | [Optional] [Defaults to `0.5`] |
|
|
77
|
-
| **embedded_rules** | `anonymize`, `anonymize_or_keep`, `remove`, `keep` | Embedded content (embedded files, OLE objects, a FHIR JSON photo\\\'s base64 `data` on Patient, Practitioner, RelatedPerson or Person). `anonymize` (default): what can be read (an Office or text file; a PNG, JPEG, WebP, BMP or TIFF image where this server reads images) is anonymized as a file of its own and written back, the rest removed. `anonymize_or_keep`: the same, the rest kept unread. `remove`: all removed. `keep`: all kept unread. Thumbnails are always removed; fonts and printer settings always kept; an Office file\\\'s pictures are read and masked where this server reads images, whatever the rule. | [Optional] [Defaults to `'anonymize'`] [Enum: anonymize, anonymize_or_keep, remove, keep] |
|
|
77
|
+
| **embedded_rules** | `anonymize`, `anonymize_or_keep`, `remove`, `keep` | Embedded content (embedded files, OLE objects, a FHIR JSON photo\\\'s base64 `data` on Patient, Practitioner, RelatedPerson or Person). `anonymize` (default): what can be read (an Office or text file; a PNG, JPEG, WebP, BMP or TIFF image where this server reads images) is anonymized as a file of its own and written back, the rest removed. `anonymize_or_keep`: the same, the rest kept unread. `remove`: all removed. `keep`: all kept unread. Thumbnails are always removed; fonts and printer settings always kept; an Office file\\\'s pictures are read and masked where this server reads images, whatever the rule. A whole file this server can\\\'t read (its format, size or state) follows it too: `anonymize_or_keep` and `keep` return it unchanged with no results; the others refuse it with a 422 on `file`. | [Optional] [Defaults to `'anonymize'`] [Enum: anonymize, anonymize_or_keep, remove, keep] |
|
|
78
78
|
| **table_headers** | `none`, `first_row`, `first_column`, `last_column` | CSV, TSV and xlsx only: where a table\\\'s headers are, in the data\\\'s order (field 1, column A), so each value is read with its header. | [Optional] [Defaults to `'none'`] [Enum: none, first_row, first_column, last_column] |
|
|
79
79
|
| **models** | `string` | Ids from `GET /models`, comma-separated (or the field repeated), each type\\\'s in order of preference: the first `ready` text model runs, and, for a file with images (an image, a DICOM file\\\'s pixels, an Office file\\\'s images), the first `ready` image reader. A type named none of runs on the first ready of all, largest first, waiting at startup until one is. None named of a type is ready: a 503, with `Retry-After` while one still loads. An unknown id: a 422. Omit for the defaults. | [Optional] [Defaults to `undefined`] |
|
|
80
80
|
| **dicom_options** | `string` | DICOM only: the options of the Basic Application Level Confidentiality Profile (PS3.15 Annex E) to apply, comma-separated, of: `clean_descriptors`, `retain_longitudinal_full_dates`, `retain_patient_characteristics`, `retain_device_identity`, `retain_institution_identity`, `retain_uids`. Empty for none. `clean_descriptors` scans descriptions and comments with the rules instead of removing them. | [Optional] [Defaults to `'clean_descriptors'`] |
|