anonyma 1.0.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 +457 -0
- package/LICENSE +21 -0
- package/README.md +605 -0
- package/dist/crypto.cjs +142 -0
- package/dist/crypto.cjs.map +1 -0
- package/dist/crypto.d.cts +51 -0
- package/dist/crypto.d.ts +51 -0
- package/dist/crypto.js +139 -0
- package/dist/crypto.js.map +1 -0
- package/dist/detectors/index.cjs +1487 -0
- package/dist/detectors/index.cjs.map +1 -0
- package/dist/detectors/index.d.cts +754 -0
- package/dist/detectors/index.d.ts +754 -0
- package/dist/detectors/index.js +1451 -0
- package/dist/detectors/index.js.map +1 -0
- package/dist/index.cjs +2877 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +772 -0
- package/dist/index.d.ts +772 -0
- package/dist/index.js +2850 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.cjs +361 -0
- package/dist/schemas.cjs.map +1 -0
- package/dist/schemas.d.cts +1031 -0
- package/dist/schemas.d.ts +1031 -0
- package/dist/schemas.js +341 -0
- package/dist/schemas.js.map +1 -0
- package/dist/stream.cjs +2315 -0
- package/dist/stream.cjs.map +1 -0
- package/dist/stream.d.cts +76 -0
- package/dist/stream.d.ts +76 -0
- package/dist/stream.js +2311 -0
- package/dist/stream.js.map +1 -0
- package/dist/types-D-9HzVuy.d.cts +553 -0
- package/dist/types-D-9HzVuy.d.ts +553 -0
- package/dist/validators.cjs +186 -0
- package/dist/validators.cjs.map +1 -0
- package/dist/validators.d.cts +136 -0
- package/dist/validators.d.ts +136 -0
- package/dist/validators.js +176 -0
- package/dist/validators.js.map +1 -0
- package/package.json +158 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { A as AnonymizeOptions, a as AnonymizeResult, T as TokenizeOptions, b as TokenizeResult } from './types-D-9HzVuy.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module stream
|
|
5
|
+
* @description Streaming support for anonyma via the WHATWG Streams API.
|
|
6
|
+
*
|
|
7
|
+
* Provides `TransformStream`-based wrappers so anonyma can be used in
|
|
8
|
+
* Node.js stream pipelines and browser fetch-response chains.
|
|
9
|
+
*
|
|
10
|
+
* Requires Node ≥ 18 (global `TransformStream`) or a browser with Streams API.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createAnonymizeStream } from "anonyma/stream";
|
|
15
|
+
* import { createReadStream, createWriteStream } from "node:fs";
|
|
16
|
+
*
|
|
17
|
+
* const readable = ReadableStream.from(lines);
|
|
18
|
+
* const anonymized = readable.pipeThrough(createAnonymizeStream());
|
|
19
|
+
* for await (const chunk of anonymized) {
|
|
20
|
+
* process.stdout.write(chunk);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a `TransformStream` that anonymizes each string chunk it receives.
|
|
27
|
+
*
|
|
28
|
+
* Input chunks are expected to be complete text strings (e.g. lines or
|
|
29
|
+
* paragraphs). For true streaming over arbitrary byte chunks, split on
|
|
30
|
+
* line boundaries before piping.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Anonymization options forwarded to {@link anonymize}.
|
|
33
|
+
* @returns A `TransformStream<string, AnonymizeResult>`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const stream = createAnonymizeStream({ defaultStrategy: { strategy: "mask" } });
|
|
38
|
+
* const reader = readable.pipeThrough(stream).getReader();
|
|
39
|
+
* const { value } = await reader.read();
|
|
40
|
+
* // value: { text: "****", matches: [] }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function createAnonymizeStream(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Create an async-capable `TransformStream` that anonymizes each string chunk.
|
|
46
|
+
* Supports `hash`, `encrypt`, and other async strategies.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Anonymization options forwarded to {@link anonymizeAsync}.
|
|
49
|
+
* @returns A `TransformStream<string, AnonymizeResult>`.
|
|
50
|
+
*/
|
|
51
|
+
declare function createAnonymizeStreamAsync(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a `TransformStream` that tokenizes each string chunk it receives.
|
|
54
|
+
*
|
|
55
|
+
* Note: each chunk gets its **own** token map. If you need a shared map across
|
|
56
|
+
* all chunks, manage the tokenization externally and feed results manually.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Tokenization options forwarded to {@link tokenize}.
|
|
59
|
+
* @returns A `TransformStream<string, TokenizeResult>`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const stream = createTokenizeStream({ categories: ["email"] });
|
|
64
|
+
* const writer = stream.writable.getWriter();
|
|
65
|
+
* const reader = stream.readable.getReader();
|
|
66
|
+
*
|
|
67
|
+
* writer.write("Contact alice@example.com");
|
|
68
|
+
* writer.close();
|
|
69
|
+
*
|
|
70
|
+
* const { value } = await reader.read();
|
|
71
|
+
* // value: { text: "Contact [EMAIL_0001]", mapping: Map { ... } }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function createTokenizeStream(options?: TokenizeOptions): TransformStream<string, TokenizeResult>;
|
|
75
|
+
|
|
76
|
+
export { createAnonymizeStream, createAnonymizeStreamAsync, createTokenizeStream };
|
package/dist/stream.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { A as AnonymizeOptions, a as AnonymizeResult, T as TokenizeOptions, b as TokenizeResult } from './types-D-9HzVuy.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module stream
|
|
5
|
+
* @description Streaming support for anonyma via the WHATWG Streams API.
|
|
6
|
+
*
|
|
7
|
+
* Provides `TransformStream`-based wrappers so anonyma can be used in
|
|
8
|
+
* Node.js stream pipelines and browser fetch-response chains.
|
|
9
|
+
*
|
|
10
|
+
* Requires Node ≥ 18 (global `TransformStream`) or a browser with Streams API.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createAnonymizeStream } from "anonyma/stream";
|
|
15
|
+
* import { createReadStream, createWriteStream } from "node:fs";
|
|
16
|
+
*
|
|
17
|
+
* const readable = ReadableStream.from(lines);
|
|
18
|
+
* const anonymized = readable.pipeThrough(createAnonymizeStream());
|
|
19
|
+
* for await (const chunk of anonymized) {
|
|
20
|
+
* process.stdout.write(chunk);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a `TransformStream` that anonymizes each string chunk it receives.
|
|
27
|
+
*
|
|
28
|
+
* Input chunks are expected to be complete text strings (e.g. lines or
|
|
29
|
+
* paragraphs). For true streaming over arbitrary byte chunks, split on
|
|
30
|
+
* line boundaries before piping.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Anonymization options forwarded to {@link anonymize}.
|
|
33
|
+
* @returns A `TransformStream<string, AnonymizeResult>`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const stream = createAnonymizeStream({ defaultStrategy: { strategy: "mask" } });
|
|
38
|
+
* const reader = readable.pipeThrough(stream).getReader();
|
|
39
|
+
* const { value } = await reader.read();
|
|
40
|
+
* // value: { text: "****", matches: [] }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function createAnonymizeStream(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Create an async-capable `TransformStream` that anonymizes each string chunk.
|
|
46
|
+
* Supports `hash`, `encrypt`, and other async strategies.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Anonymization options forwarded to {@link anonymizeAsync}.
|
|
49
|
+
* @returns A `TransformStream<string, AnonymizeResult>`.
|
|
50
|
+
*/
|
|
51
|
+
declare function createAnonymizeStreamAsync(options?: AnonymizeOptions): TransformStream<string, AnonymizeResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a `TransformStream` that tokenizes each string chunk it receives.
|
|
54
|
+
*
|
|
55
|
+
* Note: each chunk gets its **own** token map. If you need a shared map across
|
|
56
|
+
* all chunks, manage the tokenization externally and feed results manually.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Tokenization options forwarded to {@link tokenize}.
|
|
59
|
+
* @returns A `TransformStream<string, TokenizeResult>`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const stream = createTokenizeStream({ categories: ["email"] });
|
|
64
|
+
* const writer = stream.writable.getWriter();
|
|
65
|
+
* const reader = stream.readable.getReader();
|
|
66
|
+
*
|
|
67
|
+
* writer.write("Contact alice@example.com");
|
|
68
|
+
* writer.close();
|
|
69
|
+
*
|
|
70
|
+
* const { value } = await reader.read();
|
|
71
|
+
* // value: { text: "Contact [EMAIL_0001]", mapping: Map { ... } }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function createTokenizeStream(options?: TokenizeOptions): TransformStream<string, TokenizeResult>;
|
|
75
|
+
|
|
76
|
+
export { createAnonymizeStream, createAnonymizeStreamAsync, createTokenizeStream };
|