@promptaudit/shield 0.0.0-stage → 0.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/LICENSE +9 -0
- package/README.md +70 -2
- package/dist/index.cjs +156 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +114 -0
- package/dist/validators.d.ts +21 -0
- package/package.json +24 -4
- package/src/index.ts +80 -0
- package/src/shield.test.ts +48 -0
- package/src/validators.ts +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PromptAudit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @promptaudit/shield
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Mask personal data and API keys before they reach the LLM. Restore them in the answer. Locally.**
|
|
4
|
+
|
|
5
|
+
   
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @promptaudit/shield
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { withShield } from "@promptaudit/shield";
|
|
13
|
+
|
|
14
|
+
const answer = await withShield(userPrompt, (safe) => llm.complete(safe));
|
|
15
|
+
// The model saw [API_KEY_1], [IBAN_1] … — your user gets the real values back.
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Before / after
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
You wrote: Deploy with key sk-proj-AbC123…xyz and refund Mr. John Miller, IBAN CH93 0076 2011 6238 5295 7
|
|
22
|
+
Model sees: Deploy with key [API_KEY_1] and refund Mr. [NAME_1], IBAN [IBAN_1]
|
|
23
|
+
You get: the model's answer with the original values restored in your process memory
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Why Shield
|
|
27
|
+
|
|
28
|
+
- **Zero dependencies.** One small TypeScript module. Browser, Node, Bun, Deno, edge workers.
|
|
29
|
+
- **Checksum-validated.** IBAN (ISO 7064 Mod 97), cards (Luhn + brand prefix), US SSN (SSA rules), ABA routing (3-7-1). Order and serial numbers are not masked by accident.
|
|
30
|
+
- **Secrets included.** OpenAI/Anthropic `sk-…`, AWS `AKIA…`/`ASIA…`, GitHub `ghp_…`/`github_pat_…`, Slack `xox…-`, JWT and PEM private keys.
|
|
31
|
+
- **Reversible.** Placeholders go out, the map stays in your process memory.
|
|
32
|
+
- **Obfuscation-aware.** Zero-width characters and full-width digits are normalised first.
|
|
33
|
+
- **No network, no telemetry.**
|
|
34
|
+
|
|
35
|
+
## How it compares
|
|
36
|
+
|
|
37
|
+
| | Typical Python NLP stack | Ad-hoc regex snippets | **@promptaudit/shield** |
|
|
38
|
+
| --- | --- | --- | --- |
|
|
39
|
+
| Runtime | Python server | varies | **Browser, Node, Bun, Deno, edge** |
|
|
40
|
+
| Dependencies | NLP models and packages | varies | **0** |
|
|
41
|
+
| Checksum validation | partial | rarely | **IBAN, cards, SSN, ABA** |
|
|
42
|
+
| API keys / secrets | separate tooling | rarely | **built in** |
|
|
43
|
+
| Restore originals | manual | usually one-way | **`unshield()` / `withShield()`** |
|
|
44
|
+
|
|
45
|
+
NLP stacks (e.g. Microsoft Presidio) detect free-text names and addresses, which Shield does not. Choose by need; they can be combined.
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
| Function | Purpose |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| `shield(text, detectors?)` | Returns `{ masked, map, counts }` |
|
|
52
|
+
| `unshield(text, map)` | Restores originals in a model answer |
|
|
53
|
+
| `withShield(prompt, call)` | Mask → call → restore in one step |
|
|
54
|
+
| `DEFAULT_DETECTORS` | Extend with your own `{ category, pattern, validate? }` |
|
|
55
|
+
|
|
56
|
+
## Detected today
|
|
57
|
+
|
|
58
|
+
IBAN · payment card · US SSN · US routing (with keyword) · e-mail · international phone (`+` prefix) · names after Mr./Mrs./Ms./Dr./Prof. · API keys · private keys
|
|
59
|
+
|
|
60
|
+
## Limits (read before production)
|
|
61
|
+
|
|
62
|
+
- Pattern-based, not NER: names without a title, free-text addresses and medical terms are **not** detected.
|
|
63
|
+
- Unknown key formats are not caught.
|
|
64
|
+
- Detection is best-effort. It reduces exposure; it does not guarantee that no personal data leaves your system.
|
|
65
|
+
- No audit trail.
|
|
66
|
+
|
|
67
|
+
## Need proof, not just masking?
|
|
68
|
+
|
|
69
|
+
Shield runs inside your code. Teams that must **prove** what was sent, by whom and when — with browser enforcement for every employee, append-only hash-chained logs and Swiss storage — use the [PromptAudit platform](https://promptaudit.ch).
|
|
70
|
+
|
|
71
|
+
Try it live: https://promptaudit.ch/shield · MIT © PromptAudit
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/index.ts
|
|
40
|
+
var exports_src = {};
|
|
41
|
+
__export(exports_src, {
|
|
42
|
+
DEFAULT_DETECTORS: () => DEFAULT_DETECTORS,
|
|
43
|
+
isCardNumber: () => isCardNumber,
|
|
44
|
+
isValidAbaRouting: () => isValidAbaRouting,
|
|
45
|
+
isValidIban: () => isValidIban,
|
|
46
|
+
isValidLuhn: () => isValidLuhn,
|
|
47
|
+
isValidSsn: () => isValidSsn,
|
|
48
|
+
normalize: () => normalize,
|
|
49
|
+
shield: () => shield,
|
|
50
|
+
unshield: () => unshield,
|
|
51
|
+
withShield: () => withShield
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(exports_src);
|
|
54
|
+
|
|
55
|
+
// src/validators.ts
|
|
56
|
+
var digitsOf = (s) => s.replace(/\D/g, "");
|
|
57
|
+
function isValidIban(raw) {
|
|
58
|
+
const s = raw.replace(/[\s-]/g, "").toUpperCase();
|
|
59
|
+
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(s))
|
|
60
|
+
return false;
|
|
61
|
+
const moved = s.slice(4) + s.slice(0, 4);
|
|
62
|
+
let rem = 0;
|
|
63
|
+
for (const ch of moved) {
|
|
64
|
+
const v = ch >= "A" && ch <= "Z" ? String(ch.charCodeAt(0) - 55) : ch;
|
|
65
|
+
for (const d of v)
|
|
66
|
+
rem = (rem * 10 + Number(d)) % 97;
|
|
67
|
+
}
|
|
68
|
+
return rem === 1;
|
|
69
|
+
}
|
|
70
|
+
function isValidLuhn(raw) {
|
|
71
|
+
const d = digitsOf(raw);
|
|
72
|
+
if (d.length < 13 || d.length > 19)
|
|
73
|
+
return false;
|
|
74
|
+
let sum = 0;
|
|
75
|
+
for (let i = 0;i < d.length; i++) {
|
|
76
|
+
let n = Number(d[d.length - 1 - i]);
|
|
77
|
+
if (i % 2 === 1) {
|
|
78
|
+
n *= 2;
|
|
79
|
+
if (n > 9)
|
|
80
|
+
n -= 9;
|
|
81
|
+
}
|
|
82
|
+
sum += n;
|
|
83
|
+
}
|
|
84
|
+
return sum % 10 === 0;
|
|
85
|
+
}
|
|
86
|
+
function isCardNumber(raw) {
|
|
87
|
+
const d = digitsOf(raw);
|
|
88
|
+
const brand = /^4\d{12}(?:\d{3})?$|^(?:5[1-5]\d{14}|2[2-7]\d{14})$|^3[47]\d{13}$|^3(?:0[0-5]|[68]\d)\d{11}$|^6(?:011|5\d{2})\d{12}$|^35\d{14}$/;
|
|
89
|
+
return brand.test(d) && isValidLuhn(d);
|
|
90
|
+
}
|
|
91
|
+
function isValidSsn(raw) {
|
|
92
|
+
const m = /^(\d{3})-(\d{2})-(\d{4})$/.exec(raw.replace(/\s/g, ""));
|
|
93
|
+
if (!m)
|
|
94
|
+
return false;
|
|
95
|
+
const [, a, g, s] = m;
|
|
96
|
+
if (a === "000" || a === "666" || a.startsWith("9"))
|
|
97
|
+
return false;
|
|
98
|
+
return g !== "00" && s !== "0000";
|
|
99
|
+
}
|
|
100
|
+
function isValidAbaRouting(raw) {
|
|
101
|
+
const d = digitsOf(raw);
|
|
102
|
+
if (d.length !== 9 || /^0{9}$/.test(d))
|
|
103
|
+
return false;
|
|
104
|
+
const n = [...d].map(Number);
|
|
105
|
+
const sum = 3 * (n[0] + n[3] + n[6]) + 7 * (n[1] + n[4] + n[7]) + (n[2] + n[5] + n[8]);
|
|
106
|
+
return sum % 10 === 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/index.ts
|
|
110
|
+
var DEFAULT_DETECTORS = [
|
|
111
|
+
{ category: "PRIVATE_KEY", pattern: /-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g },
|
|
112
|
+
{ category: "API_KEY", pattern: /\bsk-(?:proj-|ant-(?:api\d{2}-)?)?[A-Za-z0-9_-]{20,}/g },
|
|
113
|
+
{ category: "API_KEY", pattern: /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g },
|
|
114
|
+
{ category: "API_KEY", pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{60,})\b/g },
|
|
115
|
+
{ category: "API_KEY", pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}/g },
|
|
116
|
+
{ category: "API_KEY", pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}/g },
|
|
117
|
+
{ category: "EMAIL", pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g },
|
|
118
|
+
{ category: "IBAN", pattern: /\b[A-Z]{2}[ \t-]*\d{2}(?:[ \t-]*[0-9A-Z]){11,30}\b/g, validate: isValidIban },
|
|
119
|
+
{ category: "CREDIT_CARD", pattern: /(?<![\d-])\d(?:[ \t-]?\d){12,18}(?![\d-])/g, validate: isCardNumber },
|
|
120
|
+
{ category: "US_SSN", pattern: /(?<![\d-])\d{3}-\d{2}-\d{4}(?![\d-])/g, validate: isValidSsn },
|
|
121
|
+
{ category: "ROUTING", pattern: /(?<=\b(?:routing|ABA|RTN|transit)(?:[ \t]+(?:number|no\.?|#))?[ \t]*[:#]?[ \t]*)\d{9}\b/gi, validate: isValidAbaRouting },
|
|
122
|
+
{ category: "PHONE", pattern: /(?<![\w+])\+\d{1,3}(?:[ \t.-]?\(?\d{1,4}\)?){2,5}\d(?!\d)/g },
|
|
123
|
+
{ category: "NAME", pattern: /(?<=\b(?:Mr|Mrs|Ms|Dr|Prof)\.?[ \t]+|\bMiss[ \t]+)[A-Z][a-z'-]+(?:[ \t]+[A-Z][a-z'-]+)?/g }
|
|
124
|
+
];
|
|
125
|
+
function normalize(text) {
|
|
126
|
+
return text.replace(/[\u200B-\u200D\u2060\uFEFF]/g, "").replace(/[\uFF01-\uFF5E]/g, (c) => String.fromCharCode(c.charCodeAt(0) - 65248));
|
|
127
|
+
}
|
|
128
|
+
function shield(text, detectors = DEFAULT_DETECTORS) {
|
|
129
|
+
let masked = normalize(text);
|
|
130
|
+
const map = new Map;
|
|
131
|
+
const reverse = new Map;
|
|
132
|
+
const counts = {};
|
|
133
|
+
for (const d of detectors) {
|
|
134
|
+
masked = masked.replace(new RegExp(d.pattern.source, d.pattern.flags), (m) => {
|
|
135
|
+
if (d.validate && !d.validate(m))
|
|
136
|
+
return m;
|
|
137
|
+
const known = reverse.get(m);
|
|
138
|
+
if (known)
|
|
139
|
+
return known;
|
|
140
|
+
const n = (counts[d.category] ?? 0) + 1;
|
|
141
|
+
counts[d.category] = n;
|
|
142
|
+
const ph = `[${d.category}_${n}]`;
|
|
143
|
+
map.set(ph, m);
|
|
144
|
+
reverse.set(m, ph);
|
|
145
|
+
return ph;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return { masked, map, counts };
|
|
149
|
+
}
|
|
150
|
+
function unshield(text, map) {
|
|
151
|
+
return text.replace(/\[[A-Z_]+_\d+\]/g, (ph) => map.get(ph) ?? ph);
|
|
152
|
+
}
|
|
153
|
+
async function withShield(prompt, call) {
|
|
154
|
+
const { masked, map } = shield(prompt);
|
|
155
|
+
return unshield(await call(masked), map);
|
|
156
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { isCardNumber, isValidAbaRouting, isValidIban, isValidLuhn, isValidSsn } from "./validators";
|
|
2
|
+
export type Category = "IBAN" | "CREDIT_CARD" | "US_SSN" | "ROUTING" | "EMAIL" | "PHONE" | "NAME" | "API_KEY" | "PRIVATE_KEY";
|
|
3
|
+
export interface Detector {
|
|
4
|
+
category: Category;
|
|
5
|
+
pattern: RegExp;
|
|
6
|
+
validate?: (match: string) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ShieldResult {
|
|
9
|
+
/** Text safe to send to an LLM. */
|
|
10
|
+
masked: string;
|
|
11
|
+
/** Placeholder -> original. Keep in memory only; never send it anywhere. */
|
|
12
|
+
map: Map<string, string>;
|
|
13
|
+
/** Count per category. */
|
|
14
|
+
counts: Partial<Record<Category, number>>;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_DETECTORS: readonly Detector[];
|
|
17
|
+
/** Removes zero-width chars and folds full-width digits/letters, so obfuscated values are still caught. */
|
|
18
|
+
export declare function normalize(text: string): string;
|
|
19
|
+
export declare function shield(text: string, detectors?: readonly Detector[]): ShieldResult;
|
|
20
|
+
/** Puts originals back into an LLM answer, locally. */
|
|
21
|
+
export declare function unshield(text: string, map: Map<string, string>): string;
|
|
22
|
+
/** Wraps any async LLM call: masks the prompt, calls the model, restores the answer. */
|
|
23
|
+
export declare function withShield(prompt: string, call: (safePrompt: string) => Promise<string>): Promise<string>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/validators.ts
|
|
2
|
+
var digitsOf = (s) => s.replace(/\D/g, "");
|
|
3
|
+
function isValidIban(raw) {
|
|
4
|
+
const s = raw.replace(/[\s-]/g, "").toUpperCase();
|
|
5
|
+
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(s))
|
|
6
|
+
return false;
|
|
7
|
+
const moved = s.slice(4) + s.slice(0, 4);
|
|
8
|
+
let rem = 0;
|
|
9
|
+
for (const ch of moved) {
|
|
10
|
+
const v = ch >= "A" && ch <= "Z" ? String(ch.charCodeAt(0) - 55) : ch;
|
|
11
|
+
for (const d of v)
|
|
12
|
+
rem = (rem * 10 + Number(d)) % 97;
|
|
13
|
+
}
|
|
14
|
+
return rem === 1;
|
|
15
|
+
}
|
|
16
|
+
function isValidLuhn(raw) {
|
|
17
|
+
const d = digitsOf(raw);
|
|
18
|
+
if (d.length < 13 || d.length > 19)
|
|
19
|
+
return false;
|
|
20
|
+
let sum = 0;
|
|
21
|
+
for (let i = 0;i < d.length; i++) {
|
|
22
|
+
let n = Number(d[d.length - 1 - i]);
|
|
23
|
+
if (i % 2 === 1) {
|
|
24
|
+
n *= 2;
|
|
25
|
+
if (n > 9)
|
|
26
|
+
n -= 9;
|
|
27
|
+
}
|
|
28
|
+
sum += n;
|
|
29
|
+
}
|
|
30
|
+
return sum % 10 === 0;
|
|
31
|
+
}
|
|
32
|
+
function isCardNumber(raw) {
|
|
33
|
+
const d = digitsOf(raw);
|
|
34
|
+
const brand = /^4\d{12}(?:\d{3})?$|^(?:5[1-5]\d{14}|2[2-7]\d{14})$|^3[47]\d{13}$|^3(?:0[0-5]|[68]\d)\d{11}$|^6(?:011|5\d{2})\d{12}$|^35\d{14}$/;
|
|
35
|
+
return brand.test(d) && isValidLuhn(d);
|
|
36
|
+
}
|
|
37
|
+
function isValidSsn(raw) {
|
|
38
|
+
const m = /^(\d{3})-(\d{2})-(\d{4})$/.exec(raw.replace(/\s/g, ""));
|
|
39
|
+
if (!m)
|
|
40
|
+
return false;
|
|
41
|
+
const [, a, g, s] = m;
|
|
42
|
+
if (a === "000" || a === "666" || a.startsWith("9"))
|
|
43
|
+
return false;
|
|
44
|
+
return g !== "00" && s !== "0000";
|
|
45
|
+
}
|
|
46
|
+
function isValidAbaRouting(raw) {
|
|
47
|
+
const d = digitsOf(raw);
|
|
48
|
+
if (d.length !== 9 || /^0{9}$/.test(d))
|
|
49
|
+
return false;
|
|
50
|
+
const n = [...d].map(Number);
|
|
51
|
+
const sum = 3 * (n[0] + n[3] + n[6]) + 7 * (n[1] + n[4] + n[7]) + (n[2] + n[5] + n[8]);
|
|
52
|
+
return sum % 10 === 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/index.ts
|
|
56
|
+
var DEFAULT_DETECTORS = [
|
|
57
|
+
{ category: "PRIVATE_KEY", pattern: /-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g },
|
|
58
|
+
{ category: "API_KEY", pattern: /\bsk-(?:proj-|ant-(?:api\d{2}-)?)?[A-Za-z0-9_-]{20,}/g },
|
|
59
|
+
{ category: "API_KEY", pattern: /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g },
|
|
60
|
+
{ category: "API_KEY", pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{60,})\b/g },
|
|
61
|
+
{ category: "API_KEY", pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}/g },
|
|
62
|
+
{ category: "API_KEY", pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}/g },
|
|
63
|
+
{ category: "EMAIL", pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g },
|
|
64
|
+
{ category: "IBAN", pattern: /\b[A-Z]{2}[ \t-]*\d{2}(?:[ \t-]*[0-9A-Z]){11,30}\b/g, validate: isValidIban },
|
|
65
|
+
{ category: "CREDIT_CARD", pattern: /(?<![\d-])\d(?:[ \t-]?\d){12,18}(?![\d-])/g, validate: isCardNumber },
|
|
66
|
+
{ category: "US_SSN", pattern: /(?<![\d-])\d{3}-\d{2}-\d{4}(?![\d-])/g, validate: isValidSsn },
|
|
67
|
+
{ category: "ROUTING", pattern: /(?<=\b(?:routing|ABA|RTN|transit)(?:[ \t]+(?:number|no\.?|#))?[ \t]*[:#]?[ \t]*)\d{9}\b/gi, validate: isValidAbaRouting },
|
|
68
|
+
{ category: "PHONE", pattern: /(?<![\w+])\+\d{1,3}(?:[ \t.-]?\(?\d{1,4}\)?){2,5}\d(?!\d)/g },
|
|
69
|
+
{ category: "NAME", pattern: /(?<=\b(?:Mr|Mrs|Ms|Dr|Prof)\.?[ \t]+|\bMiss[ \t]+)[A-Z][a-z'-]+(?:[ \t]+[A-Z][a-z'-]+)?/g }
|
|
70
|
+
];
|
|
71
|
+
function normalize(text) {
|
|
72
|
+
return text.replace(/[\u200B-\u200D\u2060\uFEFF]/g, "").replace(/[\uFF01-\uFF5E]/g, (c) => String.fromCharCode(c.charCodeAt(0) - 65248));
|
|
73
|
+
}
|
|
74
|
+
function shield(text, detectors = DEFAULT_DETECTORS) {
|
|
75
|
+
let masked = normalize(text);
|
|
76
|
+
const map = new Map;
|
|
77
|
+
const reverse = new Map;
|
|
78
|
+
const counts = {};
|
|
79
|
+
for (const d of detectors) {
|
|
80
|
+
masked = masked.replace(new RegExp(d.pattern.source, d.pattern.flags), (m) => {
|
|
81
|
+
if (d.validate && !d.validate(m))
|
|
82
|
+
return m;
|
|
83
|
+
const known = reverse.get(m);
|
|
84
|
+
if (known)
|
|
85
|
+
return known;
|
|
86
|
+
const n = (counts[d.category] ?? 0) + 1;
|
|
87
|
+
counts[d.category] = n;
|
|
88
|
+
const ph = `[${d.category}_${n}]`;
|
|
89
|
+
map.set(ph, m);
|
|
90
|
+
reverse.set(m, ph);
|
|
91
|
+
return ph;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return { masked, map, counts };
|
|
95
|
+
}
|
|
96
|
+
function unshield(text, map) {
|
|
97
|
+
return text.replace(/\[[A-Z_]+_\d+\]/g, (ph) => map.get(ph) ?? ph);
|
|
98
|
+
}
|
|
99
|
+
async function withShield(prompt, call) {
|
|
100
|
+
const { masked, map } = shield(prompt);
|
|
101
|
+
return unshield(await call(masked), map);
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
DEFAULT_DETECTORS,
|
|
105
|
+
isCardNumber,
|
|
106
|
+
isValidAbaRouting,
|
|
107
|
+
isValidIban,
|
|
108
|
+
isValidLuhn,
|
|
109
|
+
isValidSsn,
|
|
110
|
+
normalize,
|
|
111
|
+
shield,
|
|
112
|
+
unshield,
|
|
113
|
+
withShield
|
|
114
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Globale Erkennungsmuster mit mathematischer Prüfung (reine Funktionen, ohne I/O).
|
|
3
|
+
* Ein Treffer zählt nur, wenn die Prüfsumme stimmt, damit Seriennummern und
|
|
4
|
+
* Bestellnummern nicht fälschlich maskiert werden.
|
|
5
|
+
*/
|
|
6
|
+
export interface GlobalRule {
|
|
7
|
+
label: string;
|
|
8
|
+
pattern: RegExp;
|
|
9
|
+
validate: (match: string) => boolean;
|
|
10
|
+
}
|
|
11
|
+
/** ISO 7064 Mod 97-10 für IBAN (alle Länder). */
|
|
12
|
+
export declare function isValidIban(raw: string): boolean;
|
|
13
|
+
/** Luhn-Prüfung (Mod 10) für Zahlungskarten. */
|
|
14
|
+
export declare function isValidLuhn(raw: string): boolean;
|
|
15
|
+
/** Bekannte Kartenpräfixe (Visa, Mastercard, Amex, Diners, Discover, JCB). */
|
|
16
|
+
export declare function isCardNumber(raw: string): boolean;
|
|
17
|
+
/** US Social Security Number: Bereichs-, Gruppen- und Seriennummer gemäss SSA-Regeln. */
|
|
18
|
+
export declare function isValidSsn(raw: string): boolean;
|
|
19
|
+
/** US ABA Routing Number: Gewichtung 3-7-1, Summe Mod 10 = 0. */
|
|
20
|
+
export declare function isValidAbaRouting(raw: string): boolean;
|
|
21
|
+
export declare const GLOBAL_RULES: readonly GlobalRule[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptaudit/shield",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-dependency, checksum-validated, reversible masking of PII and API keys in LLM prompts and AI agent traffic. Runs 100% locally.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist", "src", "README.md", "LICENSE"],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"keywords": ["ai-guardrails", "pii-masking", "data-masking", "secret-protection", "llm-security", "agent-safety", "redaction", "privacy", "llm", "openai", "anthropic", "zero-dependency", "typescript"],
|
|
20
|
+
"homepage": "https://promptaudit.ch/shield",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rm -rf dist && bun build src/index.ts --outfile dist/index.js --format esm --target browser && bun build src/index.ts --outfile dist/index.cjs --format cjs --target node && bunx tsc src/index.ts --declaration --emitDeclarationOnly --outDir dist --target es2020 --moduleResolution bundler --module esnext --skipLibCheck",
|
|
23
|
+
"test": "bun test",
|
|
24
|
+
"prepublishOnly": "bun run build && bun test"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @promptaudit/shield — zero-dependency, reversible PII masking for LLM prompts.
|
|
3
|
+
* Runs locally (browser, Node, Bun, Deno, edge workers). No network, no telemetry.
|
|
4
|
+
*/
|
|
5
|
+
import { isCardNumber, isValidAbaRouting, isValidIban, isValidSsn } from "./validators";
|
|
6
|
+
|
|
7
|
+
export { isCardNumber, isValidAbaRouting, isValidIban, isValidLuhn, isValidSsn } from "./validators";
|
|
8
|
+
|
|
9
|
+
export type Category = "IBAN" | "CREDIT_CARD" | "US_SSN" | "ROUTING" | "EMAIL" | "PHONE" | "NAME" | "API_KEY" | "PRIVATE_KEY";
|
|
10
|
+
|
|
11
|
+
export interface Detector {
|
|
12
|
+
category: Category;
|
|
13
|
+
pattern: RegExp;
|
|
14
|
+
validate?: (match: string) => boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ShieldResult {
|
|
18
|
+
/** Text safe to send to an LLM. */
|
|
19
|
+
masked: string;
|
|
20
|
+
/** Placeholder -> original. Keep in memory only; never send it anywhere. */
|
|
21
|
+
map: Map<string, string>;
|
|
22
|
+
/** Count per category. */
|
|
23
|
+
counts: Partial<Record<Category, number>>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const DEFAULT_DETECTORS: readonly Detector[] = [
|
|
27
|
+
// Secrets first, so later detectors never split a key.
|
|
28
|
+
{ category: "PRIVATE_KEY", pattern: /-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g },
|
|
29
|
+
{ category: "API_KEY", pattern: /\bsk-(?:proj-|ant-(?:api\d{2}-)?)?[A-Za-z0-9_-]{20,}/g },
|
|
30
|
+
{ category: "API_KEY", pattern: /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g },
|
|
31
|
+
{ category: "API_KEY", pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{60,})\b/g },
|
|
32
|
+
{ category: "API_KEY", pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}/g },
|
|
33
|
+
{ category: "API_KEY", pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}/g },
|
|
34
|
+
{ category: "EMAIL", pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g },
|
|
35
|
+
{ category: "IBAN", pattern: /\b[A-Z]{2}[ \t-]*\d{2}(?:[ \t-]*[0-9A-Z]){11,30}\b/g, validate: isValidIban },
|
|
36
|
+
{ category: "CREDIT_CARD", pattern: /(?<![\d-])\d(?:[ \t-]?\d){12,18}(?![\d-])/g, validate: isCardNumber },
|
|
37
|
+
{ category: "US_SSN", pattern: /(?<![\d-])\d{3}-\d{2}-\d{4}(?![\d-])/g, validate: isValidSsn },
|
|
38
|
+
{ category: "ROUTING", pattern: /(?<=\b(?:routing|ABA|RTN|transit)(?:[ \t]+(?:number|no\.?|#))?[ \t]*[:#]?[ \t]*)\d{9}\b/gi, validate: isValidAbaRouting },
|
|
39
|
+
{ category: "PHONE", pattern: /(?<![\w+])\+\d{1,3}(?:[ \t.-]?\(?\d{1,4}\)?){2,5}\d(?!\d)/g },
|
|
40
|
+
{ category: "NAME", pattern: /(?<=\b(?:Mr|Mrs|Ms|Dr|Prof)\.?[ \t]+|\bMiss[ \t]+)[A-Z][a-z'-]+(?:[ \t]+[A-Z][a-z'-]+)?/g },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/** Removes zero-width chars and folds full-width digits/letters, so obfuscated values are still caught. */
|
|
44
|
+
export function normalize(text: string): string {
|
|
45
|
+
return text
|
|
46
|
+
.replace(/[\u200B-\u200D\u2060\uFEFF]/g, "")
|
|
47
|
+
.replace(/[\uFF01-\uFF5E]/g, (c) => String.fromCharCode(c.charCodeAt(0) - 0xfee0));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function shield(text: string, detectors: readonly Detector[] = DEFAULT_DETECTORS): ShieldResult {
|
|
51
|
+
let masked = normalize(text);
|
|
52
|
+
const map = new Map<string, string>();
|
|
53
|
+
const reverse = new Map<string, string>();
|
|
54
|
+
const counts: Partial<Record<Category, number>> = {};
|
|
55
|
+
for (const d of detectors) {
|
|
56
|
+
masked = masked.replace(new RegExp(d.pattern.source, d.pattern.flags), (m) => {
|
|
57
|
+
if (d.validate && !d.validate(m)) return m;
|
|
58
|
+
const known = reverse.get(m);
|
|
59
|
+
if (known) return known;
|
|
60
|
+
const n = (counts[d.category] ?? 0) + 1;
|
|
61
|
+
counts[d.category] = n;
|
|
62
|
+
const ph = `[${d.category}_${n}]`;
|
|
63
|
+
map.set(ph, m);
|
|
64
|
+
reverse.set(m, ph);
|
|
65
|
+
return ph;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return { masked, map, counts };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Puts originals back into an LLM answer, locally. */
|
|
72
|
+
export function unshield(text: string, map: Map<string, string>): string {
|
|
73
|
+
return text.replace(/\[[A-Z_]+_\d+\]/g, (ph) => map.get(ph) ?? ph);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Wraps any async LLM call: masks the prompt, calls the model, restores the answer. */
|
|
77
|
+
export async function withShield(prompt: string, call: (safePrompt: string) => Promise<string>): Promise<string> {
|
|
78
|
+
const { masked, map } = shield(prompt);
|
|
79
|
+
return unshield(await call(masked), map);
|
|
80
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @ts-nocheck -- run with bun test
|
|
2
|
+
import { describe, expect, test } from "bun:test";
|
|
3
|
+
import { shield, unshield, withShield } from "./index";
|
|
4
|
+
|
|
5
|
+
describe("shield", () => {
|
|
6
|
+
test("masks valid IBAN, card, SSN, routing, email, phone, name", () => {
|
|
7
|
+
const t = "Mr. John Miller, john@acme.com, +41 79 123 45 67, IBAN CH93 0076 2011 6238 5295 7, card 4111 1111 1111 1111, SSN 123-45-6789, routing 021000021";
|
|
8
|
+
const r = shield(t);
|
|
9
|
+
for (const v of ["John Miller", "john@acme.com", "CH93", "4111", "123-45-6789", "021000021", "79 123"]) expect(r.masked).not.toContain(v);
|
|
10
|
+
expect(r.counts).toEqual({ EMAIL: 1, IBAN: 1, CREDIT_CARD: 1, US_SSN: 1, ROUTING: 1, PHONE: 1, NAME: 1 });
|
|
11
|
+
});
|
|
12
|
+
test("leaves checksum-invalid numbers alone", () => {
|
|
13
|
+
expect(shield("order 4111 1111 1111 1112 and CH94 0076 2011 6238 5295 7").masked).toContain("4111 1111 1111 1112");
|
|
14
|
+
expect(shield("CH94 0076 2011 6238 5295 7").counts.IBAN).toBeUndefined();
|
|
15
|
+
expect(shield("SSN 666-45-6789").masked).toContain("666-45-6789");
|
|
16
|
+
});
|
|
17
|
+
test("catches zero-width and full-width obfuscation", () => {
|
|
18
|
+
expect(shield("CH93\u200B0076201162385295 7").counts.IBAN).toBe(1);
|
|
19
|
+
expect(shield("4111111111111111").counts.CREDIT_CARD).toBe(1);
|
|
20
|
+
});
|
|
21
|
+
test("round trip and same value reuses placeholder", async () => {
|
|
22
|
+
const r = shield("a@b.ch then a@b.ch");
|
|
23
|
+
expect(r.masked).toBe("[EMAIL_1] then [EMAIL_1]");
|
|
24
|
+
expect(unshield("Reply to [EMAIL_1]", r.map)).toBe("Reply to a@b.ch");
|
|
25
|
+
const out = await withShield("mail a@b.ch", async (p) => { expect(p).not.toContain("a@b.ch"); return `ok ${p}`; });
|
|
26
|
+
expect(out).toBe("ok mail a@b.ch");
|
|
27
|
+
});
|
|
28
|
+
test("company names without title stay", () => {
|
|
29
|
+
expect(shield("Visit the Apple Store").masked).toBe("Visit the Apple Store");
|
|
30
|
+
});
|
|
31
|
+
test("masks API keys and private keys", () => {
|
|
32
|
+
const aws = "AKIA" + "IOSFODNN7EXAMPLE";
|
|
33
|
+
const gh = "ghp_" + "a".repeat(36);
|
|
34
|
+
const oa = "sk-proj-" + "Ab3_".repeat(8);
|
|
35
|
+
const sl = "xoxb-" + "1234567890-abcdefABCDEF";
|
|
36
|
+
const jwt = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U";
|
|
37
|
+
const pk = "-----BEGIN RSA PRIVATE KEY-----\nMIIBOgIBAAJBAK\n-----END RSA PRIVATE KEY-----";
|
|
38
|
+
const r = shield(`k ${aws} ${gh} ${oa} ${sl} ${jwt}\n${pk}`);
|
|
39
|
+
expect(r.counts.API_KEY).toBe(5);
|
|
40
|
+
expect(r.counts.PRIVATE_KEY).toBe(1);
|
|
41
|
+
for (const v of [aws, gh, oa, sl, jwt, "MIIBOgIBAAJBAK"]) expect(r.masked).not.toContain(v);
|
|
42
|
+
expect(unshield(r.masked, r.map)).toBe(`k ${aws} ${gh} ${oa} ${sl} ${jwt}\n${pk}`);
|
|
43
|
+
});
|
|
44
|
+
test("plain hashes and words stay", () => {
|
|
45
|
+
const sha = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
46
|
+
expect(shield(`sha ${sha} sk-short task-list`).masked).toBe(`sha ${sha} sk-short task-list`);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Globale Erkennungsmuster mit mathematischer Prüfung (reine Funktionen, ohne I/O).
|
|
3
|
+
* Ein Treffer zählt nur, wenn die Prüfsumme stimmt, damit Seriennummern und
|
|
4
|
+
* Bestellnummern nicht fälschlich maskiert werden.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface GlobalRule {
|
|
8
|
+
label: string;
|
|
9
|
+
pattern: RegExp;
|
|
10
|
+
validate: (match: string) => boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const digitsOf = (s: string) => s.replace(/\D/g, "");
|
|
14
|
+
|
|
15
|
+
/** ISO 7064 Mod 97-10 für IBAN (alle Länder). */
|
|
16
|
+
export function isValidIban(raw: string): boolean {
|
|
17
|
+
const s = raw.replace(/[\s-]/g, "").toUpperCase();
|
|
18
|
+
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(s)) return false;
|
|
19
|
+
const moved = s.slice(4) + s.slice(0, 4);
|
|
20
|
+
let rem = 0;
|
|
21
|
+
for (const ch of moved) {
|
|
22
|
+
const v = ch >= "A" && ch <= "Z" ? String(ch.charCodeAt(0) - 55) : ch;
|
|
23
|
+
for (const d of v) rem = (rem * 10 + Number(d)) % 97;
|
|
24
|
+
}
|
|
25
|
+
return rem === 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Luhn-Prüfung (Mod 10) für Zahlungskarten. */
|
|
29
|
+
export function isValidLuhn(raw: string): boolean {
|
|
30
|
+
const d = digitsOf(raw);
|
|
31
|
+
if (d.length < 13 || d.length > 19) return false;
|
|
32
|
+
let sum = 0;
|
|
33
|
+
for (let i = 0; i < d.length; i++) {
|
|
34
|
+
let n = Number(d[d.length - 1 - i]);
|
|
35
|
+
if (i % 2 === 1) { n *= 2; if (n > 9) n -= 9; }
|
|
36
|
+
sum += n;
|
|
37
|
+
}
|
|
38
|
+
return sum % 10 === 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Bekannte Kartenpräfixe (Visa, Mastercard, Amex, Diners, Discover, JCB). */
|
|
42
|
+
export function isCardNumber(raw: string): boolean {
|
|
43
|
+
const d = digitsOf(raw);
|
|
44
|
+
const brand = /^4\d{12}(?:\d{3})?$|^(?:5[1-5]\d{14}|2[2-7]\d{14})$|^3[47]\d{13}$|^3(?:0[0-5]|[68]\d)\d{11}$|^6(?:011|5\d{2})\d{12}$|^35\d{14}$/;
|
|
45
|
+
return brand.test(d) && isValidLuhn(d);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** US Social Security Number: Bereichs-, Gruppen- und Seriennummer gemäss SSA-Regeln. */
|
|
49
|
+
export function isValidSsn(raw: string): boolean {
|
|
50
|
+
const m = /^(\d{3})-(\d{2})-(\d{4})$/.exec(raw.replace(/\s/g, ""));
|
|
51
|
+
if (!m) return false;
|
|
52
|
+
const [, a, g, s] = m as unknown as [string, string, string, string];
|
|
53
|
+
if (a === "000" || a === "666" || a.startsWith("9")) return false;
|
|
54
|
+
return g !== "00" && s !== "0000";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** US ABA Routing Number: Gewichtung 3-7-1, Summe Mod 10 = 0. */
|
|
58
|
+
export function isValidAbaRouting(raw: string): boolean {
|
|
59
|
+
const d = digitsOf(raw);
|
|
60
|
+
if (d.length !== 9 || /^0{9}$/.test(d)) return false;
|
|
61
|
+
const n = [...d].map(Number) as number[];
|
|
62
|
+
const sum = 3 * (n[0]! + n[3]! + n[6]!) + 7 * (n[1]! + n[4]! + n[7]!) + (n[2]! + n[5]! + n[8]!);
|
|
63
|
+
return sum % 10 === 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const GLOBAL_RULES: readonly GlobalRule[] = [
|
|
67
|
+
{ label: "IBAN", pattern: /\b[A-Z]{2}[ \t-]*\d{2}(?:[ \t-]*[0-9A-Z]){11,30}\b/g, validate: isValidIban },
|
|
68
|
+
{ label: "KREDITKARTE", pattern: /(?<![\d-])\d(?:[ \t-]?\d){12,18}(?![\d-])/g, validate: isCardNumber },
|
|
69
|
+
{ label: "US-SSN", pattern: /(?<![\d-])\d{3}-\d{2}-\d{4}(?![\d-])/g, validate: isValidSsn },
|
|
70
|
+
// Routing-Nummern nur mit Bankbegriff davor, sonst zu viele 9-stellige Zahlen.
|
|
71
|
+
{ label: "US-ROUTING", pattern: /(?<=\b(?:routing|ABA|RTN|transit)(?:[ \t]+(?:number|no\.?|#))?[ \t]*[:#]?[ \t]*)\d{9}\b/gi, validate: isValidAbaRouting },
|
|
72
|
+
];
|