flare-redact 0.6.0 โ 0.6.2
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 +80 -19
- package/dist/bip39.d.ts +4 -0
- package/dist/bip39.d.ts.map +1 -0
- package/dist/bip39.js +2061 -0
- package/dist/bip39.js.map +1 -0
- package/dist/checksums.d.ts +6 -0
- package/dist/checksums.d.ts.map +1 -1
- package/dist/checksums.js +47 -0
- package/dist/checksums.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/detectors.d.ts.map +1 -1
- package/dist/detectors.js +2 -0
- package/dist/detectors.js.map +1 -1
- package/dist/extra.d.ts +8 -0
- package/dist/extra.d.ts.map +1 -0
- package/dist/extra.js +173 -0
- package/dist/extra.js.map +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +40 -44
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +44 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +59 -0
- package/dist/session.js.map +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -14,9 +14,16 @@
|
|
|
14
14
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a>
|
|
15
15
|
<img src="https://img.shields.io/npm/types/flare-redact.svg" alt="TypeScript">
|
|
16
16
|
<img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="Zero dependencies">
|
|
17
|
+
<img src="https://img.shields.io/badge/languages-24-4f46e5" alt="24 languages">
|
|
18
|
+
<img src="https://img.shields.io/badge/detectors-50-4f46e5" alt="50 detectors">
|
|
17
19
|
<img src="https://img.shields.io/badge/runtime-node%20%7C%20browser%20%7C%20edge-blue" alt="Runtimes">
|
|
18
20
|
</p>
|
|
19
21
|
|
|
22
|
+
<p align="center">
|
|
23
|
+
๐ <b>International by default โ 24 languages</b><br>
|
|
24
|
+
๐ฌ๐ง ๐จ๐ณ ๐ฎ๐ณ ๐ช๐ธ ๐ธ๐ฆ ๐ซ๐ท ๐ต๐น ๐ท๐บ ๐ฏ๐ต ๐ฉ๐ช ๐ฐ๐ท ๐น๐ท ๐ฎ๐น ๐ฎ๐ท ๐ต๐ฑ ๐บ๐ฆ ๐ณ๐ฑ ๐ป๐ณ ๐ฎ๐ฉ ๐น๐ญ ๐ฌ๐ท ๐ฎ๐ฑ ๐ฆ๐ฟ ๐ท๐ด
|
|
25
|
+
</p>
|
|
26
|
+
|
|
20
27
|
---
|
|
21
28
|
|
|
22
29
|
Every leaked secret has the same origin story: someone logged an object, and a
|
|
@@ -44,13 +51,13 @@ Nothing to configure. No list of field paths to maintain. No native build step.
|
|
|
44
51
|
> [Jump to it โ](#redact-prompts-before-they-reach-an-llm)
|
|
45
52
|
|
|
46
53
|
<p align="center">
|
|
47
|
-
<img src="assets/
|
|
54
|
+
<img src="assets/demo.svg" alt="Before and after โ secrets and PII masked in a log line, across languages" width="820">
|
|
48
55
|
</p>
|
|
49
56
|
|
|
50
57
|
| | | |
|
|
51
58
|
|---|---|---|
|
|
52
59
|
| ๐ **Content-aware** โ reads values, not just field names | โป๏ธ **Reversible** โ vault: redact โ use โ restore | ๐ญ **Format-preserving** โ emails stay email-shaped |
|
|
53
|
-
| ๐ค **LLM-safe** โ strips secrets before OpenAI/Anthropic | ๐ **
|
|
60
|
+
| ๐ค **LLM-safe** โ strips secrets before OpenAI/Anthropic | ๐ **24 languages** โ plus checksum-validated national IDs | ๐ก๏ธ **ReDoS-safe ยท 0 deps** โ safe on untrusted input |
|
|
54
61
|
|
|
55
62
|
## Contents
|
|
56
63
|
|
|
@@ -59,6 +66,7 @@ Nothing to configure. No list of field paths to maintain. No native build step.
|
|
|
59
66
|
- [Redact prompts before they reach an LLM](#redact-prompts-before-they-reach-an-llm)
|
|
60
67
|
- [Ways to hide a value](#ways-to-hide-a-value)
|
|
61
68
|
- [Reversible redaction](#reversible-redaction)
|
|
69
|
+
- [Build a private chat app](#build-a-private-chat-app)
|
|
62
70
|
- [See what leaks, and why](#see-what-leaks-and-why)
|
|
63
71
|
- [Guard your logger in one line](#guard-your-logger-in-one-line)
|
|
64
72
|
- [One policy, everywhere](#one-policy-everywhere)
|
|
@@ -181,6 +189,40 @@ The same value always gets the same placeholder, so references survive the round
|
|
|
181
189
|
trip. Works on objects too, and `restore()` also takes a plain placeholderโvalue
|
|
182
190
|
map if you persisted one.
|
|
183
191
|
|
|
192
|
+
## Build a private chat app
|
|
193
|
+
|
|
194
|
+
If you're building a chat interface โ over your own local model or any API โ a
|
|
195
|
+
**session** is the drop-in layer. One session holds one vault, so a value keeps
|
|
196
|
+
the same placeholder across every turn: mask the user's message on the way in,
|
|
197
|
+
restore the model's reply on the way out. It's model-agnostic, synchronous, and
|
|
198
|
+
fast enough that the cost vanishes next to inference (a 13 KB message redacts in
|
|
199
|
+
~0.3 ms).
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
import { createSession } from 'flare-redact';
|
|
203
|
+
|
|
204
|
+
const session = createSession({ enable: ['pii'] });
|
|
205
|
+
|
|
206
|
+
// on the way in โ the model only ever sees placeholders
|
|
207
|
+
const prompt = session.redact(userMessage);
|
|
208
|
+
const reply = await myModel.generate(prompt);
|
|
209
|
+
|
|
210
|
+
// on the way out โ the user sees the real values back
|
|
211
|
+
show(session.restore(reply));
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Streaming? Restore token by token, even when a placeholder is split across chunks:
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
const out = session.stream();
|
|
218
|
+
for await (const chunk of modelStream) process(out.push(chunk.text));
|
|
219
|
+
process(out.flush());
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`session.redactMessages([{ role, content }])` masks a whole chat array at once,
|
|
223
|
+
and `session.reset()` starts a fresh conversation. The model never sees the real
|
|
224
|
+
data; your app still works end to end.
|
|
225
|
+
|
|
184
226
|
## See what leaks, and why
|
|
185
227
|
|
|
186
228
|
`scan()` finds secrets without changing the input, and explains every hit in
|
|
@@ -365,18 +407,25 @@ On by default:
|
|
|
365
407
|
| `bearer_token` | `Authorization: Bearer โฆ` |
|
|
366
408
|
| `basic_auth` | `Authorization: Basic โฆ` |
|
|
367
409
|
| `url_credentials` | passwords inside connection strings |
|
|
368
|
-
| `generic_assignment` | `password=`, `api_key: โฆ`, `secret=โฆ` |
|
|
410
|
+
| `generic_assignment` | `password=`, `api_key: โฆ`, `secret=โฆ` (any language) |
|
|
369
411
|
| `email` | email addresses |
|
|
370
412
|
| `credit_card` | card numbers (Luhn-validated) |
|
|
413
|
+
| `iban` | IBANs (mod-97 validated) |
|
|
414
|
+
| `discord_bot_token` / `telegram_bot_token` | chat bot tokens |
|
|
415
|
+
| `shopify_token` / `square_token` | commerce tokens |
|
|
416
|
+
| `digitalocean_token` / `azure_storage_key` | cloud secrets |
|
|
417
|
+
| `sentry_dsn` / `new_relic_key` | observability secrets |
|
|
371
418
|
|
|
372
419
|
Opt in with `enable`:
|
|
373
420
|
|
|
374
|
-
| Detector | Finds |
|
|
421
|
+
| Detector / tag | Finds |
|
|
375
422
|
|---|---|
|
|
376
423
|
| `high_entropy` | long random-looking tokens of *any* format (entropy-based) |
|
|
424
|
+
| `crypto` | Bitcoin & Ethereum addresses, BIP39 seed phrases |
|
|
425
|
+
| `finance` | SWIFT/BIC, US ABA routing numbers |
|
|
426
|
+
| `vehicle` | VINs (checksum-validated) |
|
|
427
|
+
| `network` | IPs, MAC addresses, coordinates, internal URLs |
|
|
377
428
|
| `phone` | E.164 phone numbers |
|
|
378
|
-
| `ipv4` / `ipv6` | IP addresses |
|
|
379
|
-
| `mac_address` | MAC addresses |
|
|
380
429
|
|
|
381
430
|
Plus object values whose **key name** is sensitive (`password`, `token`,
|
|
382
431
|
`authorization`, `cookie`, `cvv`, โฆ) are masked regardless of content.
|
|
@@ -384,9 +433,20 @@ Plus object values whose **key name** is sensitive (`password`, `token`,
|
|
|
384
433
|
## Every language, every country
|
|
385
434
|
|
|
386
435
|
Secrets like API keys and card numbers don't care what language your app is in.
|
|
387
|
-
Neither does this โ but the word-based checks do, so
|
|
388
|
-
|
|
389
|
-
|
|
436
|
+
Neither does this โ but the word-based checks do, so words like *password*,
|
|
437
|
+
*secret*, and *token* are recognized as assignments and as object keys in all
|
|
438
|
+
**24 languages** below:
|
|
439
|
+
|
|
440
|
+
| | | |
|
|
441
|
+
|---|---|---|
|
|
442
|
+
| ๐ฌ๐ง English `password` | ๐จ๐ณ Chinese `ๅฏ็ ` | ๐ฎ๐ณ Hindi `เคชเคพเคธเคตเคฐเฅเคก` |
|
|
443
|
+
| ๐ช๐ธ Spanish `contraseรฑa` | ๐ธ๐ฆ Arabic `ููู
ุฉ ุงูู
ุฑูุฑ` | ๐ซ๐ท French `mot de passe` |
|
|
444
|
+
| ๐ต๐น Portuguese `senha` | ๐ท๐บ Russian `ะฟะฐัะพะปั` | ๐ฏ๐ต Japanese `ใในใฏใผใ` |
|
|
445
|
+
| ๐ฉ๐ช German `passwort` | ๐ฐ๐ท Korean `๋น๋ฐ๋ฒํธ` | ๐น๐ท Turkish `ลifre` |
|
|
446
|
+
| ๐ฎ๐น Italian `segreto` | ๐ฎ๐ท Persian `ุฑู
ุฒ ุนุจูุฑ` | ๐ต๐ฑ Polish `hasลo` |
|
|
447
|
+
| ๐บ๐ฆ Ukrainian `ะฟะฐัะพะปั` | ๐ณ๐ฑ Dutch `wachtwoord` | ๐ป๐ณ Vietnamese `mแบญt khแบฉu` |
|
|
448
|
+
| ๐ฎ๐ฉ Indonesian `kata sandi` | ๐น๐ญ Thai `เธฃเธซเธฑเธชเธเนเธฒเธ` | ๐ฌ๐ท Greek `ฮบฯฮดฮนฮบฯฯ` |
|
|
449
|
+
| ๐ฎ๐ฑ Hebrew `ืกืืกืื` | ๐ฆ๐ฟ Azerbaijani `ลifrษ` | ๐ท๐ด Romanian `parolฤ` |
|
|
390
450
|
|
|
391
451
|
National IDs are opt-in and **checksum-validated**, so a random run of digits is
|
|
392
452
|
never mistaken for one. Enable a whole group or a single country by tag:
|
|
@@ -398,16 +458,17 @@ redact(text, { enable: ['tr', 'de'] }); // just Turkish and German
|
|
|
398
458
|
|
|
399
459
|
| Detector | Country | Validated by |
|
|
400
460
|
|---|---|---|
|
|
401
|
-
| `iban` | international *(on by default)* | ISO 13616 mod-97 |
|
|
402
|
-
| `tr_tckn` | Turkey | TCKN checksum |
|
|
403
|
-
| `de_tax_id` | Germany | ISO 7064 mod-11,10 |
|
|
404
|
-
| `es_dni` | Spain (DNI/NIE) | control letter mod-23 |
|
|
405
|
-
| `it_codice_fiscale` | Italy | odd/even table |
|
|
406
|
-
| `br_cpf` | Brazil | two mod-11 digits |
|
|
407
|
-
| `nl_bsn` | Netherlands | 11-test |
|
|
408
|
-
| `pl_pesel` | Poland | weighted mod-10 |
|
|
409
|
-
| `ca_sin` | Canada | Luhn |
|
|
410
|
-
| `us_ssn` | United States | issued-range rules |
|
|
461
|
+
| `iban` | ๐ international *(on by default)* | ISO 13616 mod-97 |
|
|
462
|
+
| `tr_tckn` | ๐น๐ท Turkey | TCKN checksum |
|
|
463
|
+
| `de_tax_id` | ๐ฉ๐ช Germany | ISO 7064 mod-11,10 |
|
|
464
|
+
| `es_dni` | ๐ช๐ธ Spain (DNI/NIE) | control letter mod-23 |
|
|
465
|
+
| `it_codice_fiscale` | ๐ฎ๐น Italy | odd/even table |
|
|
466
|
+
| `br_cpf` | ๐ง๐ท Brazil | two mod-11 digits |
|
|
467
|
+
| `nl_bsn` | ๐ณ๐ฑ Netherlands | 11-test |
|
|
468
|
+
| `pl_pesel` | ๐ต๐ฑ Poland | weighted mod-10 |
|
|
469
|
+
| `ca_sin` | ๐จ๐ฆ Canada | Luhn |
|
|
470
|
+
| `us_ssn` | ๐บ๐ธ United States | issued-range rules |
|
|
471
|
+
| `uk_nhs` | ๐ฌ๐ง United Kingdom (NHS) | weighted mod-11 |
|
|
411
472
|
|
|
412
473
|
Every algorithm has its own tests against known-valid and known-invalid numbers,
|
|
413
474
|
so enabling them won't turn your logs into a wall of `[REDACTED]`.
|
package/dist/bip39.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bip39.d.ts","sourceRoot":"","sources":["../src/bip39.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAigE1C,CAAC;AAIH,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIjD"}
|