@glubean/redaction 0.1.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/dist/adapter.d.ts +41 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +111 -0
- package/dist/adapter.js.map +1 -0
- package/dist/defaults.d.ts +29 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +110 -0
- package/dist/defaults.js.map +1 -0
- package/dist/engine.d.ts +48 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +174 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/aws-keys.d.ts +6 -0
- package/dist/plugins/aws-keys.d.ts.map +1 -0
- package/dist/plugins/aws-keys.js +11 -0
- package/dist/plugins/aws-keys.js.map +1 -0
- package/dist/plugins/bearer.d.ts +8 -0
- package/dist/plugins/bearer.d.ts.map +1 -0
- package/dist/plugins/bearer.js +19 -0
- package/dist/plugins/bearer.js.map +1 -0
- package/dist/plugins/credit-card.d.ts +6 -0
- package/dist/plugins/credit-card.d.ts.map +1 -0
- package/dist/plugins/credit-card.js +15 -0
- package/dist/plugins/credit-card.js.map +1 -0
- package/dist/plugins/email.d.ts +6 -0
- package/dist/plugins/email.d.ts.map +1 -0
- package/dist/plugins/email.js +19 -0
- package/dist/plugins/email.js.map +1 -0
- package/dist/plugins/github-tokens.d.ts +6 -0
- package/dist/plugins/github-tokens.d.ts.map +1 -0
- package/dist/plugins/github-tokens.js +17 -0
- package/dist/plugins/github-tokens.js.map +1 -0
- package/dist/plugins/hex-keys.d.ts +7 -0
- package/dist/plugins/hex-keys.d.ts.map +1 -0
- package/dist/plugins/hex-keys.js +12 -0
- package/dist/plugins/hex-keys.js.map +1 -0
- package/dist/plugins/ip-address.d.ts +6 -0
- package/dist/plugins/ip-address.d.ts.map +1 -0
- package/dist/plugins/ip-address.js +18 -0
- package/dist/plugins/ip-address.js.map +1 -0
- package/dist/plugins/jwt.d.ts +9 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +13 -0
- package/dist/plugins/jwt.js.map +1 -0
- package/dist/plugins/mod.d.ts +29 -0
- package/dist/plugins/mod.d.ts.map +1 -0
- package/dist/plugins/mod.js +65 -0
- package/dist/plugins/mod.js.map +1 -0
- package/dist/plugins/sensitive-keys.d.ts +19 -0
- package/dist/plugins/sensitive-keys.d.ts.map +1 -0
- package/dist/plugins/sensitive-keys.js +56 -0
- package/dist/plugins/sensitive-keys.js.map +1 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearer.d.ts","sourceRoot":"","sources":["../../src/plugins/bearer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnD,eAAO,MAAM,YAAY,EAAE,eAU1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bearer token plugin — detects "Bearer <token>" patterns.
|
|
3
|
+
*
|
|
4
|
+
* Common in Authorization headers and log messages.
|
|
5
|
+
*/
|
|
6
|
+
import { genericPartialMask } from "../engine.js";
|
|
7
|
+
const BEARER_SOURCE = "\\bBearer\\s+[a-zA-Z0-9._-]+";
|
|
8
|
+
export const bearerPlugin = {
|
|
9
|
+
name: "bearer",
|
|
10
|
+
matchValue: () => new RegExp(BEARER_SOURCE, "gi"),
|
|
11
|
+
partialMask: (match) => {
|
|
12
|
+
if (match.toLowerCase().startsWith("bearer ")) {
|
|
13
|
+
const token = match.slice(7);
|
|
14
|
+
return "Bearer " + genericPartialMask(token);
|
|
15
|
+
}
|
|
16
|
+
return genericPartialMask(match);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=bearer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearer.js","sourceRoot":"","sources":["../../src/plugins/bearer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,aAAa,GAAG,8BAA8B,CAAC;AAErD,MAAM,CAAC,MAAM,YAAY,GAAoB;IAC3C,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC;IACjD,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE;QAC7B,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7B,OAAO,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credit-card.d.ts","sourceRoot":"","sources":["../../src/plugins/credit-card.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,eAAO,MAAM,gBAAgB,EAAE,eAS9B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credit card plugin — detects 16-digit card numbers (with optional separators).
|
|
3
|
+
*/
|
|
4
|
+
const CC_SOURCE = "\\b\\d{4}[- ]?\\d{4}[- ]?\\d{4}[- ]?\\d{4}\\b";
|
|
5
|
+
export const creditCardPlugin = {
|
|
6
|
+
name: "creditCard",
|
|
7
|
+
matchValue: () => new RegExp(CC_SOURCE, "g"),
|
|
8
|
+
partialMask: (match) => {
|
|
9
|
+
// PCI standard: show only last 4 digits
|
|
10
|
+
const digits = match.replace(/\D/g, "");
|
|
11
|
+
const last4 = digits.slice(-4);
|
|
12
|
+
return "****-****-****-" + last4;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=credit-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credit-card.js","sourceRoot":"","sources":["../../src/plugins/credit-card.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,SAAS,GAAG,+CAA+C,CAAC;AAElE,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC/C,IAAI,EAAE,YAAY;IAClB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;IAC5C,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE;QAC7B,wCAAwC;QACxC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,iBAAiB,GAAG,KAAK,CAAC;IACnC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/plugins/email.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,eAAO,MAAM,WAAW,EAAE,eAYzB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email plugin — detects standard email addresses.
|
|
3
|
+
*/
|
|
4
|
+
const EMAIL_SOURCE = "\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\\b";
|
|
5
|
+
export const emailPlugin = {
|
|
6
|
+
name: "email",
|
|
7
|
+
matchValue: () => new RegExp(EMAIL_SOURCE, "g"),
|
|
8
|
+
partialMask: (match) => {
|
|
9
|
+
// u***@***.com
|
|
10
|
+
const atIdx = match.indexOf("@");
|
|
11
|
+
if (atIdx <= 0)
|
|
12
|
+
return "***@***";
|
|
13
|
+
const dotIdx = match.lastIndexOf(".");
|
|
14
|
+
const user = match.slice(0, atIdx);
|
|
15
|
+
const domainSuffix = dotIdx > atIdx ? match.slice(dotIdx) : "";
|
|
16
|
+
return user[0] + "***@***" + domainSuffix;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/plugins/email.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E,MAAM,CAAC,MAAM,WAAW,GAAoB;IAC1C,IAAI,EAAE,OAAO;IACb,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC;IAC/C,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE;QAC7B,eAAe;QACf,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,KAAK,IAAI,CAAC;YAAE,OAAO,SAAS,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC5C,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-tokens.d.ts","sourceRoot":"","sources":["../../src/plugins/github-tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,eAAO,MAAM,kBAAkB,EAAE,eAWhC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub token plugin — detects ghp_, gho_, ghu_, ghs_, ghr_ prefixed tokens.
|
|
3
|
+
*/
|
|
4
|
+
const GITHUB_SOURCE = "\\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\\b";
|
|
5
|
+
export const githubTokensPlugin = {
|
|
6
|
+
name: "githubTokens",
|
|
7
|
+
matchValue: () => new RegExp(GITHUB_SOURCE, "g"),
|
|
8
|
+
partialMask: (match) => {
|
|
9
|
+
// ghp_ prefix is meaningful, show prefix + last 3
|
|
10
|
+
const prefixEnd = match.indexOf("_");
|
|
11
|
+
if (prefixEnd > 0 && prefixEnd < 4) {
|
|
12
|
+
return match.slice(0, prefixEnd + 1) + "***" + match.slice(-3);
|
|
13
|
+
}
|
|
14
|
+
return match.slice(0, 4) + "***" + match.slice(-3);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=github-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-tokens.js","sourceRoot":"","sources":["../../src/plugins/github-tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,aAAa,GAAG,kDAAkD,CAAC;AAEzE,MAAM,CAAC,MAAM,kBAAkB,GAAoB;IACjD,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC;IAChD,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE;QAC7B,kDAAkD;QAClD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-keys.d.ts","sourceRoot":"","sources":["../../src/plugins/hex-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnD,eAAO,MAAM,aAAa,EAAE,eAI3B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hex keys plugin — detects long hex strings (32+ chars) that are
|
|
3
|
+
* likely API keys, hashes, or secrets.
|
|
4
|
+
*/
|
|
5
|
+
import { genericPartialMask } from "../engine.js";
|
|
6
|
+
const HEX_SOURCE = "\\b[a-f0-9]{32,}\\b";
|
|
7
|
+
export const hexKeysPlugin = {
|
|
8
|
+
name: "hexKeys",
|
|
9
|
+
matchValue: () => new RegExp(HEX_SOURCE, "gi"),
|
|
10
|
+
partialMask: genericPartialMask,
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=hex-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-keys.js","sourceRoot":"","sources":["../../src/plugins/hex-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC5C,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC;IAC9C,WAAW,EAAE,kBAAkB;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-address.d.ts","sourceRoot":"","sources":["../../src/plugins/ip-address.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnD,eAAO,MAAM,eAAe,EAAE,eAW7B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IP address plugin — detects IPv4 addresses.
|
|
3
|
+
*/
|
|
4
|
+
import { genericPartialMask } from "../engine.js";
|
|
5
|
+
const IP_SOURCE = "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b";
|
|
6
|
+
export const ipAddressPlugin = {
|
|
7
|
+
name: "ipAddress",
|
|
8
|
+
matchValue: () => new RegExp(IP_SOURCE, "g"),
|
|
9
|
+
partialMask: (match) => {
|
|
10
|
+
// Show first two octets: 192.168.*.*
|
|
11
|
+
const parts = match.split(".");
|
|
12
|
+
if (parts.length === 4) {
|
|
13
|
+
return parts[0] + "." + parts[1] + ".*.*";
|
|
14
|
+
}
|
|
15
|
+
return genericPartialMask(match);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=ip-address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-address.js","sourceRoot":"","sources":["../../src/plugins/ip-address.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,SAAS,GAAG,iDAAiD,CAAC;AAEpE,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,IAAI,EAAE,WAAW;IACjB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;IAC5C,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE;QAC7B,qCAAqC;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;QAC5C,CAAC;QACD,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT plugin — detects JSON Web Tokens in string values.
|
|
3
|
+
*
|
|
4
|
+
* Matches the standard `header.payload.signature` format where
|
|
5
|
+
* header and payload start with base64url-encoded `{"` (= `eyJ`).
|
|
6
|
+
*/
|
|
7
|
+
import type { RedactionPlugin } from "../types.js";
|
|
8
|
+
export declare const jwtPlugin: RedactionPlugin;
|
|
9
|
+
//# sourceMappingURL=jwt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/plugins/jwt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,eAAO,MAAM,SAAS,EAAE,eAIvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT plugin — detects JSON Web Tokens in string values.
|
|
3
|
+
*
|
|
4
|
+
* Matches the standard `header.payload.signature` format where
|
|
5
|
+
* header and payload start with base64url-encoded `{"` (= `eyJ`).
|
|
6
|
+
*/
|
|
7
|
+
const JWT_SOURCE = "\\beyJ[a-zA-Z0-9_-]*\\.eyJ[a-zA-Z0-9_-]*\\.[a-zA-Z0-9_-]*";
|
|
8
|
+
export const jwtPlugin = {
|
|
9
|
+
name: "jwt",
|
|
10
|
+
matchValue: () => new RegExp(JWT_SOURCE, "g"),
|
|
11
|
+
partialMask: (match) => match.slice(0, 3) + "***" + match.slice(-3),
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=jwt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/plugins/jwt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,UAAU,GAAG,2DAA2D,CAAC;AAE/E,MAAM,CAAC,MAAM,SAAS,GAAoB;IACxC,IAAI,EAAE,KAAK;IACX,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IAC7C,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC5E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module plugins
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all built-in plugins and provides `createBuiltinPlugins()`
|
|
5
|
+
* factory that assembles the plugin list from a RedactionConfig.
|
|
6
|
+
*/
|
|
7
|
+
import type { RedactionConfig, RedactionPlugin } from "../types.js";
|
|
8
|
+
import { sensitiveKeysPlugin } from "./sensitive-keys.js";
|
|
9
|
+
import { jwtPlugin } from "./jwt.js";
|
|
10
|
+
import { bearerPlugin } from "./bearer.js";
|
|
11
|
+
import { awsKeysPlugin } from "./aws-keys.js";
|
|
12
|
+
import { githubTokensPlugin } from "./github-tokens.js";
|
|
13
|
+
import { emailPlugin } from "./email.js";
|
|
14
|
+
import { ipAddressPlugin } from "./ip-address.js";
|
|
15
|
+
import { creditCardPlugin } from "./credit-card.js";
|
|
16
|
+
import { hexKeysPlugin } from "./hex-keys.js";
|
|
17
|
+
export { awsKeysPlugin, bearerPlugin, creditCardPlugin, emailPlugin, githubTokensPlugin, hexKeysPlugin, ipAddressPlugin, jwtPlugin, sensitiveKeysPlugin, };
|
|
18
|
+
/**
|
|
19
|
+
* Create the full plugin list from a RedactionConfig.
|
|
20
|
+
*
|
|
21
|
+
* Order: sensitive-keys plugin first (key-level), then enabled pattern
|
|
22
|
+
* plugins (value-level), then user custom patterns.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const plugins = createBuiltinPlugins(DEFAULT_CONFIG);
|
|
26
|
+
* const engine = new RedactionEngine({ config: DEFAULT_CONFIG, plugins });
|
|
27
|
+
*/
|
|
28
|
+
export declare function createBuiltinPlugins(config: RedactionConfig): RedactionPlugin[];
|
|
29
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/plugins/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,SAAS,EACT,mBAAmB,GACpB,CAAC;AAcF;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,eAAe,GACtB,eAAe,EAAE,CA6BnB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module plugins
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all built-in plugins and provides `createBuiltinPlugins()`
|
|
5
|
+
* factory that assembles the plugin list from a RedactionConfig.
|
|
6
|
+
*/
|
|
7
|
+
import { sensitiveKeysPlugin } from "./sensitive-keys.js";
|
|
8
|
+
import { jwtPlugin } from "./jwt.js";
|
|
9
|
+
import { bearerPlugin } from "./bearer.js";
|
|
10
|
+
import { awsKeysPlugin } from "./aws-keys.js";
|
|
11
|
+
import { githubTokensPlugin } from "./github-tokens.js";
|
|
12
|
+
import { emailPlugin } from "./email.js";
|
|
13
|
+
import { ipAddressPlugin } from "./ip-address.js";
|
|
14
|
+
import { creditCardPlugin } from "./credit-card.js";
|
|
15
|
+
import { hexKeysPlugin } from "./hex-keys.js";
|
|
16
|
+
export { awsKeysPlugin, bearerPlugin, creditCardPlugin, emailPlugin, githubTokensPlugin, hexKeysPlugin, ipAddressPlugin, jwtPlugin, sensitiveKeysPlugin, };
|
|
17
|
+
/** Map of pattern name → plugin for built-in patterns. */
|
|
18
|
+
const PATTERN_PLUGINS = {
|
|
19
|
+
jwt: jwtPlugin,
|
|
20
|
+
bearer: bearerPlugin,
|
|
21
|
+
awsKeys: awsKeysPlugin,
|
|
22
|
+
githubTokens: githubTokensPlugin,
|
|
23
|
+
email: emailPlugin,
|
|
24
|
+
ipAddress: ipAddressPlugin,
|
|
25
|
+
creditCard: creditCardPlugin,
|
|
26
|
+
hexKeys: hexKeysPlugin,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Create the full plugin list from a RedactionConfig.
|
|
30
|
+
*
|
|
31
|
+
* Order: sensitive-keys plugin first (key-level), then enabled pattern
|
|
32
|
+
* plugins (value-level), then user custom patterns.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const plugins = createBuiltinPlugins(DEFAULT_CONFIG);
|
|
36
|
+
* const engine = new RedactionEngine({ config: DEFAULT_CONFIG, plugins });
|
|
37
|
+
*/
|
|
38
|
+
export function createBuiltinPlugins(config) {
|
|
39
|
+
const plugins = [];
|
|
40
|
+
// Key-level plugin always first
|
|
41
|
+
plugins.push(sensitiveKeysPlugin(config.sensitiveKeys));
|
|
42
|
+
// Add enabled pattern plugins
|
|
43
|
+
const patternFlags = config.patterns;
|
|
44
|
+
for (const [name, plugin] of Object.entries(PATTERN_PLUGINS)) {
|
|
45
|
+
if (patternFlags[name] === true) {
|
|
46
|
+
plugins.push(plugin);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Add user custom patterns
|
|
50
|
+
for (const custom of config.patterns.custom ?? []) {
|
|
51
|
+
try {
|
|
52
|
+
// Validate regex compiles
|
|
53
|
+
new RegExp(custom.regex, "g");
|
|
54
|
+
plugins.push({
|
|
55
|
+
name: custom.name,
|
|
56
|
+
matchValue: () => new RegExp(custom.regex, "g"),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Skip invalid regex patterns — per arch doc, CLI warns but doesn't abort
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return plugins;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=mod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/plugins/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,SAAS,EACT,mBAAmB,GACpB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,eAAe,GAAoC;IACvD,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,kBAAkB;IAChC,KAAK,EAAE,WAAW;IAClB,SAAS,EAAE,eAAe;IAC1B,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,aAAa;CACvB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAuB;IAEvB,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,gCAAgC;IAChC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAExD,8BAA8B;IAC9B,MAAM,YAAY,GAAG,MAAM,CAAC,QAA8C,CAAC;IAC3E,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAC7D,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAChC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QAClD,IAAI,CAAC;YACH,0BAA0B;YAC1B,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;aAChD,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,0EAA0E;QAC5E,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive-keys plugin — key-level redaction.
|
|
3
|
+
*
|
|
4
|
+
* Checks if a JSON key or header name matches one of the configured
|
|
5
|
+
* sensitive keys (case-insensitive substring match).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // "x-authorization-token" matches "authorization"
|
|
9
|
+
* // "X-Api-Key" matches "api-key" (after lowercasing)
|
|
10
|
+
*/
|
|
11
|
+
import type { RedactionPlugin, SensitiveKeysConfig } from "../types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Create a sensitive-keys plugin from config.
|
|
14
|
+
*
|
|
15
|
+
* Key matching uses case-insensitive substring — "x-authorization-token"
|
|
16
|
+
* matches "authorization".
|
|
17
|
+
*/
|
|
18
|
+
export declare function sensitiveKeysPlugin(config: SensitiveKeysConfig): RedactionPlugin;
|
|
19
|
+
//# sourceMappingURL=sensitive-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-keys.d.ts","sourceRoot":"","sources":["../../src/plugins/sensitive-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA4BxE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,mBAAmB,GAC1B,eAAe,CAgBjB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive-keys plugin — key-level redaction.
|
|
3
|
+
*
|
|
4
|
+
* Checks if a JSON key or header name matches one of the configured
|
|
5
|
+
* sensitive keys (case-insensitive substring match).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // "x-authorization-token" matches "authorization"
|
|
9
|
+
* // "X-Api-Key" matches "api-key" (after lowercasing)
|
|
10
|
+
*/
|
|
11
|
+
import { BUILT_IN_SENSITIVE_KEYS } from "../defaults.js";
|
|
12
|
+
/**
|
|
13
|
+
* Build the sensitive key set from config.
|
|
14
|
+
* If useBuiltIn is true, starts with BUILT_IN_SENSITIVE_KEYS,
|
|
15
|
+
* adds `additional`, removes `excluded`.
|
|
16
|
+
*/
|
|
17
|
+
function buildKeySet(config) {
|
|
18
|
+
const keys = new Set();
|
|
19
|
+
if (config.useBuiltIn) {
|
|
20
|
+
for (const k of BUILT_IN_SENSITIVE_KEYS) {
|
|
21
|
+
keys.add(k);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (const k of config.additional ?? []) {
|
|
25
|
+
keys.add(k.toLowerCase());
|
|
26
|
+
}
|
|
27
|
+
for (const k of config.excluded ?? []) {
|
|
28
|
+
keys.delete(k.toLowerCase());
|
|
29
|
+
}
|
|
30
|
+
return keys;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a sensitive-keys plugin from config.
|
|
34
|
+
*
|
|
35
|
+
* Key matching uses case-insensitive substring — "x-authorization-token"
|
|
36
|
+
* matches "authorization".
|
|
37
|
+
*/
|
|
38
|
+
export function sensitiveKeysPlugin(config) {
|
|
39
|
+
const keys = buildKeySet(config);
|
|
40
|
+
return {
|
|
41
|
+
name: "sensitive-keys",
|
|
42
|
+
isKeySensitive: (key) => {
|
|
43
|
+
const lower = key.toLowerCase();
|
|
44
|
+
// Exact match first (fast path)
|
|
45
|
+
if (keys.has(lower))
|
|
46
|
+
return true;
|
|
47
|
+
// Substring match
|
|
48
|
+
for (const sensitive of keys) {
|
|
49
|
+
if (lower.includes(sensitive))
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sensitive-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-keys.js","sourceRoot":"","sources":["../../src/plugins/sensitive-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;;GAIG;AACH,SAAS,WAAW,CAAC,MAA2B;IAC9C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,uBAAuB,EAAE,CAAC;YACxC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA2B;IAE3B,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,cAAc,EAAE,CAAC,GAAW,EAAuB,EAAE;YACnD,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;YAChC,gCAAgC;YAChC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACjC,kBAAkB;YAClB,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;oBAAE,OAAO,IAAI,CAAC;YAC7C,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the Glubean Redaction Engine.
|
|
5
|
+
*
|
|
6
|
+
* These types are pure TypeScript with no runtime-specific dependencies,
|
|
7
|
+
* enabling consumption by both Deno (oss CLI/runner) and Node.js (server).
|
|
8
|
+
*
|
|
9
|
+
* The generic parameters on RedactionConfig allow the server to extend
|
|
10
|
+
* base types with premium scopes and patterns without modifying this package.
|
|
11
|
+
*/
|
|
12
|
+
/** Which data areas the engine should scan for sensitive content. */
|
|
13
|
+
export interface RedactionScopes {
|
|
14
|
+
requestHeaders: boolean;
|
|
15
|
+
requestQuery: boolean;
|
|
16
|
+
requestBody: boolean;
|
|
17
|
+
responseHeaders: boolean;
|
|
18
|
+
responseBody: boolean;
|
|
19
|
+
consoleOutput: boolean;
|
|
20
|
+
errorMessages: boolean;
|
|
21
|
+
/** Whether to redact sensitive data in step return state values. */
|
|
22
|
+
returnState: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A user-defined regex pattern for value-level redaction. */
|
|
25
|
+
export interface CustomPattern {
|
|
26
|
+
name: string;
|
|
27
|
+
regex: string;
|
|
28
|
+
}
|
|
29
|
+
/** Built-in pattern toggles. Each key enables/disables a specific detector. */
|
|
30
|
+
export interface PatternsConfig {
|
|
31
|
+
jwt: boolean;
|
|
32
|
+
bearer: boolean;
|
|
33
|
+
awsKeys: boolean;
|
|
34
|
+
githubTokens: boolean;
|
|
35
|
+
email: boolean;
|
|
36
|
+
ipAddress: boolean;
|
|
37
|
+
creditCard: boolean;
|
|
38
|
+
hexKeys: boolean;
|
|
39
|
+
custom: CustomPattern[];
|
|
40
|
+
}
|
|
41
|
+
/** Configuration for key-based redaction (header names, JSON keys, etc.). */
|
|
42
|
+
export interface SensitiveKeysConfig {
|
|
43
|
+
/** Whether to include the built-in sensitive keys list. */
|
|
44
|
+
useBuiltIn: boolean;
|
|
45
|
+
/** Additional keys to treat as sensitive. */
|
|
46
|
+
additional: string[];
|
|
47
|
+
/** Keys to exclude from the built-in list. */
|
|
48
|
+
excluded: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Core redaction configuration. Extensible via generics so the server
|
|
52
|
+
* can add premium scopes and patterns without modifying oss code.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Server extends base config:
|
|
56
|
+
* interface ServerScopes extends RedactionScopes { webhookPayloads: boolean; }
|
|
57
|
+
* type ServerConfig = RedactionConfig<ServerScopes>;
|
|
58
|
+
*/
|
|
59
|
+
export interface RedactionConfig<TScopes extends RedactionScopes = RedactionScopes, TPatterns extends PatternsConfig = PatternsConfig> {
|
|
60
|
+
scopes: TScopes;
|
|
61
|
+
sensitiveKeys: SensitiveKeysConfig;
|
|
62
|
+
patterns: TPatterns;
|
|
63
|
+
replacementFormat: "simple" | "labeled" | "partial";
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Context passed to each plugin — describes what is being redacted
|
|
67
|
+
* and where in the data tree the engine currently is.
|
|
68
|
+
*/
|
|
69
|
+
export interface RedactionContext {
|
|
70
|
+
/** Data scope: "requestHeaders", "responseBody", "consoleOutput", etc. */
|
|
71
|
+
scope: string;
|
|
72
|
+
/** Key path from root, e.g. ["data", "user", "email"] */
|
|
73
|
+
path: readonly string[];
|
|
74
|
+
/** Current key name (last element of path), or empty string for root values. */
|
|
75
|
+
key: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A single redaction plugin.
|
|
79
|
+
*
|
|
80
|
+
* Plugins are composable units that detect one category of sensitive data.
|
|
81
|
+
* The engine calls plugins in registration order; first match wins for
|
|
82
|
+
* key-level redaction, all patterns are applied for value-level (multi-pass).
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const myPlugin: RedactionPlugin = {
|
|
87
|
+
* name: "my-pattern",
|
|
88
|
+
* matchValue: () => new RegExp("secret_[a-z]+", "g"),
|
|
89
|
+
* partialMask: (match) => match.slice(0, 3) + "***" + match.slice(-3),
|
|
90
|
+
* };
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export interface RedactionPlugin {
|
|
94
|
+
/** Unique identifier, used in labeled replacement: [REDACTED:<name>] */
|
|
95
|
+
readonly name: string;
|
|
96
|
+
/**
|
|
97
|
+
* Key-level check: should the value at this key be fully redacted
|
|
98
|
+
* without inspecting its content?
|
|
99
|
+
*
|
|
100
|
+
* Return `true` to redact, `undefined` to defer to the next plugin.
|
|
101
|
+
*/
|
|
102
|
+
isKeySensitive?(key: string, ctx: RedactionContext): boolean | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Value-level check: return a RegExp that matches sensitive patterns
|
|
105
|
+
* in the string value. The engine replaces all matches.
|
|
106
|
+
*
|
|
107
|
+
* Return `undefined` to skip this plugin for the given value.
|
|
108
|
+
* The regex MUST use the global flag (/g).
|
|
109
|
+
*
|
|
110
|
+
* IMPORTANT: return a NEW RegExp instance every call to avoid
|
|
111
|
+
* stale lastIndex in concurrent use.
|
|
112
|
+
*/
|
|
113
|
+
matchValue?(value: string, ctx: RedactionContext): RegExp | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Custom partial-mask strategy for this plugin's matches.
|
|
116
|
+
* Called when replacementFormat is "partial".
|
|
117
|
+
*
|
|
118
|
+
* If not provided, the engine applies a generic mask (first 3 + last 3 chars).
|
|
119
|
+
*/
|
|
120
|
+
partialMask?(match: string): string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Result of a redaction operation.
|
|
124
|
+
*/
|
|
125
|
+
export interface RedactionResult {
|
|
126
|
+
/** The redacted value (deep clone, original untouched). */
|
|
127
|
+
value: unknown;
|
|
128
|
+
/** Whether any redaction occurred. */
|
|
129
|
+
redacted: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Per-field redaction details (for local debugging only).
|
|
132
|
+
*
|
|
133
|
+
* INVARIANT: details are EPHEMERAL — they must NEVER be persisted,
|
|
134
|
+
* uploaded, or included in any share/server payload. The `original`
|
|
135
|
+
* field contains plaintext secrets and exists solely for local
|
|
136
|
+
* --verbose output where the developer wants to see what was redacted.
|
|
137
|
+
*/
|
|
138
|
+
details: Array<{
|
|
139
|
+
path: string;
|
|
140
|
+
plugin: string;
|
|
141
|
+
original?: string;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,oEAAoE;IACpE,WAAW,EAAE,OAAO,CAAC;CACtB;AAID,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAID,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,UAAU,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAID;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe,CAC9B,OAAO,SAAS,eAAe,GAAG,eAAe,EACjD,SAAS,SAAS,cAAc,GAAG,cAAc;IAEjD,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,mBAAmB,CAAC;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;CACrD;AAID;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,cAAc,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAC;IAEzE;;;;;;;;;OASG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAAC;IAEtE;;;;;OAKG;IACH,WAAW,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACrC;AAID;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,KAAK,EAAE,OAAO,CAAC;IACf,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrE"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the Glubean Redaction Engine.
|
|
5
|
+
*
|
|
6
|
+
* These types are pure TypeScript with no runtime-specific dependencies,
|
|
7
|
+
* enabling consumption by both Deno (oss CLI/runner) and Node.js (server).
|
|
8
|
+
*
|
|
9
|
+
* The generic parameters on RedactionConfig allow the server to extend
|
|
10
|
+
* base types with premium scopes and patterns without modifying this package.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glubean/redaction",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^22.0.0"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.build.json",
|
|
19
|
+
"test": "vitest run"
|
|
20
|
+
}
|
|
21
|
+
}
|