flare-redact 0.8.0 → 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 +87 -0
- package/MIGRATION.md +58 -0
- package/README.md +238 -59
- package/SECURITY.md +32 -0
- package/bench/adversarial-runtime.mjs +23 -0
- package/bench/performance.mjs +36 -0
- package/bin/flare-redact.mjs +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +122 -32
- package/dist/cli.js.map +1 -1
- package/dist/crypto.d.ts +6 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +128 -0
- package/dist/crypto.js.map +1 -0
- package/dist/csv.d.ts +3 -3
- package/dist/csv.js +3 -3
- package/dist/detectors.d.ts +17 -7
- package/dist/detectors.d.ts.map +1 -1
- package/dist/detectors.js +59 -35
- package/dist/detectors.js.map +1 -1
- package/dist/engine.d.ts +46 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +179 -25
- package/dist/engine.js.map +1 -1
- package/dist/graph.d.ts +9 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +94 -0
- package/dist/graph.js.map +1 -0
- package/dist/http.d.ts +5 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +54 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +20 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +306 -54
- package/dist/index.js.map +1 -1
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +92 -54
- package/dist/llm.js.map +1 -1
- package/dist/secure-vault.d.ts +26 -0
- package/dist/secure-vault.d.ts.map +1 -0
- package/dist/secure-vault.js +137 -0
- package/dist/secure-vault.js.map +1 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +3 -29
- package/dist/session.js.map +1 -1
- package/dist/stream.d.ts +5 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +68 -8
- package/dist/stream.js.map +1 -1
- package/dist/tool.d.ts +30 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +37 -0
- package/dist/tool.js.map +1 -0
- package/dist/transforms.d.ts +12 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/transforms.js +91 -0
- package/dist/transforms.js.map +1 -0
- package/dist/vault.d.ts +14 -3
- package/dist/vault.d.ts.map +1 -1
- package/dist/vault.js +72 -38
- package/dist/vault.js.map +1 -1
- package/package.json +17 -4
package/dist/tool.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { redact } from './index.js';
|
|
2
|
+
import { createVault } from './vault.js';
|
|
3
|
+
/** One-way redaction for logging or persisting a tool call safely. */
|
|
4
|
+
export function redactToolCall(call, opts = {}) {
|
|
5
|
+
return redact(call, opts);
|
|
6
|
+
}
|
|
7
|
+
/** One-way redaction for logging or persisting a tool/MCP result safely. */
|
|
8
|
+
export function redactToolResult(result, opts = {}) {
|
|
9
|
+
return redact(result, opts);
|
|
10
|
+
}
|
|
11
|
+
/** One-way redaction for an arbitrary JSON-RPC/MCP message. */
|
|
12
|
+
export function redactMcpMessage(message, opts = {}) {
|
|
13
|
+
return redact(message, opts);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reversible boundary for agent loops:
|
|
17
|
+
*
|
|
18
|
+
* model tool call -> restoreForTool -> execute -> redactForModel -> model
|
|
19
|
+
*/
|
|
20
|
+
export function createToolBoundary(opts = {}) {
|
|
21
|
+
let vault = createVault(opts);
|
|
22
|
+
return {
|
|
23
|
+
redactForModel: (result) => vault.redact(result),
|
|
24
|
+
restoreForTool: (call) => vault.restore(call),
|
|
25
|
+
restoreForApp: (output) => vault.restore(output),
|
|
26
|
+
get vault() {
|
|
27
|
+
return vault;
|
|
28
|
+
},
|
|
29
|
+
get size() {
|
|
30
|
+
return vault.size;
|
|
31
|
+
},
|
|
32
|
+
reset() {
|
|
33
|
+
vault = createVault(opts);
|
|
34
|
+
},
|
|
35
|
+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AC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Detector } from './detectors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic, keyed, shape-preserving pseudonymization. This is deliberately
|
|
4
|
+
* not called format-preserving encryption: it is not reversible and does not
|
|
5
|
+
* implement NIST FF1.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pseudonymize(value: string, secret: string): string;
|
|
8
|
+
/** @deprecated Use pseudonymize(). This alias never represented encryption. */
|
|
9
|
+
export declare function fpe(value: string, secret: string): string;
|
|
10
|
+
/** Produce a deterministic, type-consistent synthetic value for local test data. */
|
|
11
|
+
export declare function surrogate(value: string, detector: Detector, secret: string): string;
|
|
12
|
+
//# sourceMappingURL=transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAgB/C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQlE;AAED,+EAA+E;AAC/E,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAmDD,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASnF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { deriveBytes, hmacFingerprint } from './crypto.js';
|
|
2
|
+
const LOWER = 'abcdefghijklmnopqrstuvwxyz';
|
|
3
|
+
const UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
4
|
+
const DIGITS = '0123456789';
|
|
5
|
+
const GIVEN_NAMES = ['Alex', 'Avery', 'Casey', 'Emery', 'Jordan', 'Morgan', 'Riley', 'Robin'];
|
|
6
|
+
const FAMILY_NAMES = ['Arden', 'Blake', 'Hayes', 'Lane', 'Parker', 'Reed', 'Shaw', 'Vale'];
|
|
7
|
+
const STREETS = ['Cedar', 'Harbor', 'Juniper', 'Maple', 'Orchard', 'River', 'Willow', 'Summit'];
|
|
8
|
+
function alphabetFor(ch) {
|
|
9
|
+
if (ch >= '0' && ch <= '9')
|
|
10
|
+
return DIGITS;
|
|
11
|
+
if (ch >= 'a' && ch <= 'z')
|
|
12
|
+
return LOWER;
|
|
13
|
+
if (ch >= 'A' && ch <= 'Z')
|
|
14
|
+
return UPPER;
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Deterministic, keyed, shape-preserving pseudonymization. This is deliberately
|
|
19
|
+
* not called format-preserving encryption: it is not reversible and does not
|
|
20
|
+
* implement NIST FF1.
|
|
21
|
+
*/
|
|
22
|
+
export function pseudonymize(value, secret) {
|
|
23
|
+
const bytes = deriveBytes(secret, `pseudonym:${value}`, value.length);
|
|
24
|
+
let out = '';
|
|
25
|
+
for (let i = 0; i < value.length; i++) {
|
|
26
|
+
const alphabet = alphabetFor(value[i]);
|
|
27
|
+
out += alphabet ? alphabet[bytes[i] % alphabet.length] : value[i];
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/** @deprecated Use pseudonymize(). This alias never represented encryption. */
|
|
32
|
+
export function fpe(value, secret) {
|
|
33
|
+
return pseudonymize(value, secret);
|
|
34
|
+
}
|
|
35
|
+
function digitSurrogate(value, secret) {
|
|
36
|
+
const bytes = deriveBytes(secret, `digits:${value}`, value.length);
|
|
37
|
+
let out = '';
|
|
38
|
+
for (let i = 0; i < value.length; i++) {
|
|
39
|
+
out += /\d/.test(value[i]) ? DIGITS[bytes[i] % 10] : value[i];
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function luhnCheckDigit(prefix) {
|
|
44
|
+
const digits = prefix.replace(/\D/g, '');
|
|
45
|
+
let sum = 0;
|
|
46
|
+
let double = true;
|
|
47
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
48
|
+
let n = Number(digits[i]);
|
|
49
|
+
if (double) {
|
|
50
|
+
n *= 2;
|
|
51
|
+
if (n > 9)
|
|
52
|
+
n -= 9;
|
|
53
|
+
}
|
|
54
|
+
sum += n;
|
|
55
|
+
double = !double;
|
|
56
|
+
}
|
|
57
|
+
return String((10 - (sum % 10)) % 10);
|
|
58
|
+
}
|
|
59
|
+
function cardSurrogate(value, secret) {
|
|
60
|
+
const shaped = digitSurrogate(value, secret);
|
|
61
|
+
const lastDigitIndex = shaped.search(/\d(?=\D*$)/);
|
|
62
|
+
if (lastDigitIndex < 0)
|
|
63
|
+
return shaped;
|
|
64
|
+
const prefix = shaped.slice(0, lastDigitIndex);
|
|
65
|
+
return prefix + luhnCheckDigit(prefix) + shaped.slice(lastDigitIndex + 1);
|
|
66
|
+
}
|
|
67
|
+
function emailSurrogate(value, secret) {
|
|
68
|
+
const tag = hmacFingerprint(secret, `email:${value}`, 6);
|
|
69
|
+
return `user_${tag}@example.invalid`;
|
|
70
|
+
}
|
|
71
|
+
function personSurrogate(value, secret) {
|
|
72
|
+
const bytes = deriveBytes(secret, `person:${value}`, 2);
|
|
73
|
+
return `${GIVEN_NAMES[bytes[0] % GIVEN_NAMES.length]} ${FAMILY_NAMES[bytes[1] % FAMILY_NAMES.length]}`;
|
|
74
|
+
}
|
|
75
|
+
function addressSurrogate(value, secret) {
|
|
76
|
+
const bytes = deriveBytes(secret, `address:${value}`, 3);
|
|
77
|
+
const number = 100 + ((bytes[0] << 8 | bytes[1]) % 9800);
|
|
78
|
+
return `${number} ${STREETS[bytes[2] % STREETS.length]} Street`;
|
|
79
|
+
}
|
|
80
|
+
/** Produce a deterministic, type-consistent synthetic value for local test data. */
|
|
81
|
+
export function surrogate(value, detector, secret) {
|
|
82
|
+
switch (detector.id) {
|
|
83
|
+
case 'email': return emailSurrogate(value, secret);
|
|
84
|
+
case 'credit_card': return cardSurrogate(value, secret);
|
|
85
|
+
case 'phone': return digitSurrogate(value, secret);
|
|
86
|
+
case 'person_name': return personSurrogate(value, secret);
|
|
87
|
+
case 'street_address': return addressSurrogate(value, secret);
|
|
88
|
+
default: return pseudonymize(value, secret);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=transforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.js","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,KAAK,GAAG,4BAA4B,CAAC;AAC3C,MAAM,KAAK,GAAG,4BAA4B,CAAC;AAC3C,MAAM,MAAM,GAAG,YAAY,CAAC;AAC5B,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9F,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3F,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEhG,SAAS,WAAW,CAAC,EAAU;IAC7B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG;QAAE,OAAO,MAAM,CAAC;IAC1C,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG;QA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AAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1D,KAAK,gBAAgB,CAAC,CAAC,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO,CAAC,CAAC,OAAO,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
package/dist/vault.d.ts
CHANGED
|
@@ -7,15 +7,26 @@ export interface Vault {
|
|
|
7
7
|
}
|
|
8
8
|
export interface VaultOptions extends RedactOptions {
|
|
9
9
|
placeholder?: (detectorId: string, index: number) => string;
|
|
10
|
+
/** Human-readable counters are predictable; use only for trusted local flows. */
|
|
11
|
+
placeholderStyle?: 'opaque' | 'readable';
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* Build a single-pass restorer from placeholder→original entries. Longest
|
|
13
|
-
* placeholders match first
|
|
15
|
+
* placeholders match first so prefix-like custom tokens cannot clobber peers.
|
|
14
16
|
*/
|
|
15
17
|
export declare function buildRestore(entries: Array<[string, string]>): (text: string) => string;
|
|
18
|
+
export interface IncrementalRestorer {
|
|
19
|
+
push(chunk: string): string;
|
|
20
|
+
flush(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Restore placeholders across arbitrary stream chunk boundaries. This uses the
|
|
24
|
+
* actual placeholder strings, so custom formats do not need square brackets.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildStreamRestore(entries: Array<[string, string]>): IncrementalRestorer;
|
|
16
27
|
/**
|
|
17
|
-
* A reversible redactor. `redact()` swaps each secret for a stable
|
|
18
|
-
*
|
|
28
|
+
* A reversible redactor. `redact()` swaps each secret for a stable opaque
|
|
29
|
+
* placeholder and remembers the mapping; `restore()` puts the originals back.
|
|
19
30
|
* The same value always gets the same placeholder, so references survive a
|
|
20
31
|
* round trip — send the redacted text to an LLM, then restore its answer.
|
|
21
32
|
*/
|
package/dist/vault.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,KAAK;IACpB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5D,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC1C;AAaD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAMvF;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,KAAK,IAAI,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAkCxF;AAuBD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,GAAE,YAAiB,GAAG,KAAK,CAgD1D;AAED,wFAAwF;AACxF,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CASpG"}
|
package/dist/vault.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { resolveDetectors, keyMatcher, allowMatcher, scanString, } from './engine.js';
|
|
2
|
+
import { mapGraph } from './graph.js';
|
|
2
3
|
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4
|
+
function opaqueToken() {
|
|
5
|
+
const provider = globalThis.crypto;
|
|
6
|
+
if (!provider?.getRandomValues)
|
|
7
|
+
throw new Error('Web Crypto is required to create opaque vault placeholders.');
|
|
8
|
+
const bytes = provider.getRandomValues(new Uint8Array(12));
|
|
9
|
+
let out = '';
|
|
10
|
+
for (const byte of bytes)
|
|
11
|
+
out += byte.toString(16).padStart(2, '0');
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* Build a single-pass restorer from placeholder→original entries. Longest
|
|
5
|
-
* placeholders match first
|
|
16
|
+
* placeholders match first so prefix-like custom tokens cannot clobber peers.
|
|
6
17
|
*/
|
|
7
18
|
export function buildRestore(entries) {
|
|
8
19
|
if (!entries.length)
|
|
@@ -12,22 +23,56 @@ export function buildRestore(entries) {
|
|
|
12
23
|
const re = new RegExp(sorted.map(([ph]) => escapeRe(ph)).join('|'), 'g');
|
|
13
24
|
return (text) => text.replace(re, (m) => lookup.get(m) ?? m);
|
|
14
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Restore placeholders across arbitrary stream chunk boundaries. This uses the
|
|
28
|
+
* actual placeholder strings, so custom formats do not need square brackets.
|
|
29
|
+
*/
|
|
30
|
+
export function buildStreamRestore(entries) {
|
|
31
|
+
const restoreText = buildRestore(entries);
|
|
32
|
+
const placeholders = entries.map(([placeholder]) => placeholder);
|
|
33
|
+
let buffer = '';
|
|
34
|
+
const pendingPrefixLength = () => {
|
|
35
|
+
let keep = 0;
|
|
36
|
+
for (const placeholder of placeholders) {
|
|
37
|
+
const limit = Math.min(buffer.length, placeholder.length - 1);
|
|
38
|
+
for (let length = limit; length > keep; length--) {
|
|
39
|
+
if (buffer.endsWith(placeholder.slice(0, length))) {
|
|
40
|
+
keep = length;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return keep;
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
push(chunk) {
|
|
49
|
+
buffer += chunk;
|
|
50
|
+
const keep = pendingPrefixLength();
|
|
51
|
+
const emitEnd = buffer.length - keep;
|
|
52
|
+
const emit = buffer.slice(0, emitEnd);
|
|
53
|
+
buffer = buffer.slice(emitEnd);
|
|
54
|
+
return restoreText(emit);
|
|
55
|
+
},
|
|
56
|
+
flush() {
|
|
57
|
+
const out = restoreText(buffer);
|
|
58
|
+
buffer = '';
|
|
59
|
+
return out;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
15
63
|
function walkStrings(value, fn) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
64
|
+
return mapGraph(value, fn);
|
|
65
|
+
}
|
|
66
|
+
function redactGraph(value, redactString, matchKey, allow, mint) {
|
|
67
|
+
return mapGraph(value, redactString, (key, raw) => {
|
|
68
|
+
if (matchKey(key) && !allow(raw))
|
|
69
|
+
return mint(raw, 'sensitive_key');
|
|
70
|
+
return redactString(raw);
|
|
71
|
+
});
|
|
27
72
|
}
|
|
28
73
|
/**
|
|
29
|
-
* A reversible redactor. `redact()` swaps each secret for a stable
|
|
30
|
-
*
|
|
74
|
+
* A reversible redactor. `redact()` swaps each secret for a stable opaque
|
|
75
|
+
* placeholder and remembers the mapping; `restore()` puts the originals back.
|
|
31
76
|
* The same value always gets the same placeholder, so references survive a
|
|
32
77
|
* round trip — send the redacted text to an LLM, then restore its answer.
|
|
33
78
|
*/
|
|
@@ -35,7 +80,9 @@ export function createVault(opts = {}) {
|
|
|
35
80
|
const dets = resolveDetectors(opts);
|
|
36
81
|
const allow = allowMatcher(opts);
|
|
37
82
|
const matchKey = keyMatcher(opts);
|
|
38
|
-
const fmt = opts.placeholder ?? (
|
|
83
|
+
const fmt = opts.placeholder ?? (opts.placeholderStyle === 'readable'
|
|
84
|
+
? ((id, n) => `[${id.toUpperCase()}_${n}]`)
|
|
85
|
+
: ((id) => `[FR_${id.toUpperCase()}_${opaqueToken()}]`));
|
|
39
86
|
const origToPh = new Map();
|
|
40
87
|
const phToOrig = new Map();
|
|
41
88
|
const counts = new Map();
|
|
@@ -46,12 +93,16 @@ export function createVault(opts = {}) {
|
|
|
46
93
|
const n = (counts.get(detId) ?? 0) + 1;
|
|
47
94
|
counts.set(detId, n);
|
|
48
95
|
const ph = fmt(detId, n);
|
|
96
|
+
const collision = phToOrig.get(ph);
|
|
97
|
+
if (collision !== undefined && collision !== value) {
|
|
98
|
+
throw new Error(`Placeholder generator produced a duplicate token for ${detId}.`);
|
|
99
|
+
}
|
|
49
100
|
origToPh.set(value, ph);
|
|
50
101
|
phToOrig.set(ph, value);
|
|
51
102
|
return ph;
|
|
52
103
|
};
|
|
53
104
|
const redactStr = (text) => {
|
|
54
|
-
const hits = scanString(text, dets, allow);
|
|
105
|
+
const hits = scanString(text, dets, allow, opts);
|
|
55
106
|
if (!hits.length)
|
|
56
107
|
return text;
|
|
57
108
|
let out = '';
|
|
@@ -63,25 +114,8 @@ export function createVault(opts = {}) {
|
|
|
63
114
|
}
|
|
64
115
|
return out + text.slice(cursor);
|
|
65
116
|
};
|
|
66
|
-
const redactWalk = (value) => {
|
|
67
|
-
if (typeof value === 'string')
|
|
68
|
-
return redactStr(value);
|
|
69
|
-
if (Array.isArray(value))
|
|
70
|
-
return value.map(redactWalk);
|
|
71
|
-
if (value && typeof value === 'object') {
|
|
72
|
-
const out = {};
|
|
73
|
-
for (const [k, v] of Object.entries(value)) {
|
|
74
|
-
if (typeof v === 'string' && matchKey(k) && !allow(v))
|
|
75
|
-
out[k] = mint(v, 'sensitive_key');
|
|
76
|
-
else
|
|
77
|
-
out[k] = redactWalk(v);
|
|
78
|
-
}
|
|
79
|
-
return out;
|
|
80
|
-
}
|
|
81
|
-
return value;
|
|
82
|
-
};
|
|
83
117
|
return {
|
|
84
|
-
redact: (input) =>
|
|
118
|
+
redact: (input) => redactGraph(input, redactStr, matchKey, allow, mint),
|
|
85
119
|
restore: (input) => walkStrings(input, buildRestore([...phToOrig])),
|
|
86
120
|
entries: () => [...phToOrig],
|
|
87
121
|
get size() {
|
|
@@ -91,10 +125,10 @@ export function createVault(opts = {}) {
|
|
|
91
125
|
}
|
|
92
126
|
/** Put originals back into any text/object using a vault or a placeholder→value map. */
|
|
93
127
|
export function restore(input, source) {
|
|
94
|
-
const entries =
|
|
95
|
-
? source
|
|
96
|
-
: source
|
|
97
|
-
?
|
|
128
|
+
const entries = source instanceof Map
|
|
129
|
+
? [...source]
|
|
130
|
+
: typeof source.entries === 'function'
|
|
131
|
+
? source.entries()
|
|
98
132
|
: Object.entries(source);
|
|
99
133
|
if (!entries.length)
|
|
100
134
|
return input;
|
package/dist/vault.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,UAAU,GAEX,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,UAAU,GAEX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QA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CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flare-redact",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Local, zero-dependency secret and PII redaction with contextual findings, secure reversible vaults, and LLM adapters.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"types": "./dist/llm.d.ts",
|
|
20
20
|
"default": "./dist/llm.js"
|
|
21
21
|
},
|
|
22
|
+
"./tool": {
|
|
23
|
+
"types": "./dist/tool.d.ts",
|
|
24
|
+
"default": "./dist/tool.js"
|
|
25
|
+
},
|
|
22
26
|
"./session": {
|
|
23
27
|
"types": "./dist/session.d.ts",
|
|
24
28
|
"default": "./dist/session.js"
|
|
@@ -50,12 +54,19 @@
|
|
|
50
54
|
"files": [
|
|
51
55
|
"dist",
|
|
52
56
|
"bin",
|
|
57
|
+
"bench/performance.mjs",
|
|
58
|
+
"bench/adversarial-runtime.mjs",
|
|
53
59
|
"README.md",
|
|
60
|
+
"CHANGELOG.md",
|
|
61
|
+
"MIGRATION.md",
|
|
62
|
+
"SECURITY.md",
|
|
54
63
|
"LICENSE"
|
|
55
64
|
],
|
|
56
65
|
"scripts": {
|
|
57
66
|
"build": "tsc",
|
|
58
67
|
"test": "npm run build && node --test",
|
|
68
|
+
"benchmark": "npm run build && node bench/performance.mjs",
|
|
69
|
+
"benchmark:adversarial": "npm run build && node bench/adversarial-runtime.mjs",
|
|
59
70
|
"prepublishOnly": "npm run build"
|
|
60
71
|
},
|
|
61
72
|
"keywords": [
|
|
@@ -113,7 +124,9 @@
|
|
|
113
124
|
"anonymization",
|
|
114
125
|
"pseudonymization",
|
|
115
126
|
"tokenization",
|
|
116
|
-
"
|
|
127
|
+
"surrogate-data",
|
|
128
|
+
"hmac",
|
|
129
|
+
"aes-gcm",
|
|
117
130
|
"i18n",
|
|
118
131
|
"multi-language",
|
|
119
132
|
"national-id",
|
|
@@ -137,7 +150,7 @@
|
|
|
137
150
|
"url": "https://github.com/umudhasanli/flare-redact/issues"
|
|
138
151
|
},
|
|
139
152
|
"engines": {
|
|
140
|
-
"node": ">=
|
|
153
|
+
"node": ">=20"
|
|
141
154
|
},
|
|
142
155
|
"devDependencies": {
|
|
143
156
|
"@types/node": "^20.0.0",
|