llm-entropy-filter 1.1.1 → 1.2.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 +155 -51
- package/LICENSE +93 -93
- package/README.md +297 -352
- package/dist/index.cjs +104 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +104 -70
- package/dist/index.js.map +1 -1
- package/integrations/express.mjs +117 -117
- package/integrations/fastify.mjs +106 -106
- package/integrations/langchain.mjs +98 -98
- package/integrations/vercel-ai-sdk.mjs +44 -44
- package/package.json +99 -97
- package/rulesets/default.js +8 -2
- package/rulesets/default.json +77 -73
- package/rulesets/public-api.js +7 -2
- package/rulesets/public-api.json +179 -27
- package/rulesets/schema +24 -24
- package/rulesets/strict.js +7 -2
- package/rulesets/strict.json +173 -25
- package/rulesets/support.js +7 -2
- package/rulesets/support.json +22 -22
package/rulesets/strict.json
CHANGED
|
@@ -1,25 +1,173 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "strict",
|
|
3
|
-
"version": 1,
|
|
4
|
-
"description": "Aggressive preset for public endpoints and high-abuse environments.",
|
|
5
|
-
"thresholds": { "warn": 0.35, "block": 0.55 },
|
|
6
|
-
"normalization": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "strict",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"description": "Aggressive preset for public endpoints and high-abuse environments.",
|
|
5
|
+
"thresholds": { "warn": 0.35, "block": 0.55 },
|
|
6
|
+
"normalization": {
|
|
7
|
+
"lowercase": true,
|
|
8
|
+
"trim": true,
|
|
9
|
+
"collapse_whitespace": true,
|
|
10
|
+
"unicode_nfkc": true
|
|
11
|
+
},
|
|
12
|
+
"policy": {
|
|
13
|
+
"strong_spam_block": false,
|
|
14
|
+
"block_flags": ["fraud_payment_request", "scam_wfh", "phishing_verify_threat_en", "phishing_2fa_code"]
|
|
15
|
+
},
|
|
16
|
+
"hard_triggers": [
|
|
17
|
+
{
|
|
18
|
+
"id": "shouting",
|
|
19
|
+
"type": "signal",
|
|
20
|
+
"weight": 0.22,
|
|
21
|
+
"patterns": ["[A-ZÁÉÍÓÚÑ]{5,}", "!!+", "\\?\\?+", "¡¡+"]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "money_signal",
|
|
25
|
+
"type": "topic_hint",
|
|
26
|
+
"weight": 0.18,
|
|
27
|
+
"patterns": ["\\$\\d+", "\\b%\\b", "\\bfree\\b", "\\bgratis\\b"]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "links",
|
|
31
|
+
"type": "signal",
|
|
32
|
+
"weight": 0.2,
|
|
33
|
+
"patterns": ["https?://", "www\\.", "\\bbit\\.ly\\b"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "conspiracy_vague",
|
|
37
|
+
"type": "topic_hint",
|
|
38
|
+
"weight": 0.18,
|
|
39
|
+
"patterns": ["\\btodos\\s+lo\\s+esconden\\b", "\\btruth\\s+is\\s+hidden\\b"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "phishing_2fa_code_request_es",
|
|
43
|
+
"type": "topic_hint",
|
|
44
|
+
"weight": 0.60,
|
|
45
|
+
"notes": "ES: solicitud de código de verificación / 2FA (alto riesgo de phishing).",
|
|
46
|
+
"patterns": [
|
|
47
|
+
"\\bc[oó]digo\\s+de\\s+verificaci[oó]n\\b",
|
|
48
|
+
"\\bc[oó]digo\\s+de\\s+seguridad\\b",
|
|
49
|
+
"\\btoken\\s+de\\s+verificaci[oó]n\\b",
|
|
50
|
+
"\\bclave\\s+de\\s+verificaci[oó]n\\b",
|
|
51
|
+
"\\benv[ií]ame\\s+tu\\s+c[oó]digo\\b",
|
|
52
|
+
"\\bm[aá]ndame\\s+tu\\s+c[oó]digo\\b"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "fraud_card_request_es",
|
|
57
|
+
"type": "topic_hint",
|
|
58
|
+
"weight": 0.55,
|
|
59
|
+
"notes": "ES: solicitud de tarjeta/datos bancarios (alto riesgo de fraude).",
|
|
60
|
+
"patterns": [
|
|
61
|
+
"\\b(tarjeta|n[uú]mero\\s+de\\s+tarjeta)\\b",
|
|
62
|
+
"\\b(cv[vv]|cvc)\\b",
|
|
63
|
+
"\\bfecha\\s+de\\s+vencimiento\\b",
|
|
64
|
+
"\\bpor\\s+mensaje\\s+tu\\s+tarjeta\\b",
|
|
65
|
+
"\\bm[aá]ndame\\s+tu\\s+tarjeta\\b",
|
|
66
|
+
"\\benv[ií]ame\\s+tu\\s+tarjeta\\b"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "phish_account_threat_en",
|
|
71
|
+
"type": "topic_hint",
|
|
72
|
+
"weight": 0.35,
|
|
73
|
+
"notes": "EN: verify account + threat of closure (phishing-ish).",
|
|
74
|
+
"patterns": [
|
|
75
|
+
"\\bverify\\s+your\\s+account\\b.*\\b(closed|suspended|disabled)\\b",
|
|
76
|
+
"\\bor\\s+it\\s+will\\s+be\\s+(closed|suspended|disabled)\\b"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "scam_easy_money_es",
|
|
81
|
+
"type": "topic_hint",
|
|
82
|
+
"weight": 0.45,
|
|
83
|
+
"notes": "ES: estafa típica de dinero fácil / desde casa.",
|
|
84
|
+
"patterns": [
|
|
85
|
+
"gana\\s+dinero\\s+desde\\s+casa",
|
|
86
|
+
"sin\\s+esfuerzo",
|
|
87
|
+
"ingresos\\s+pasivos",
|
|
88
|
+
"dinero\\s+f[aá]cil"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"topics": [
|
|
93
|
+
{
|
|
94
|
+
"id": "marketing_spam",
|
|
95
|
+
"weight": 0.45,
|
|
96
|
+
"signals": [
|
|
97
|
+
{
|
|
98
|
+
"id": "cta",
|
|
99
|
+
"weight": 0.22,
|
|
100
|
+
"patterns": ["\\bclick\\b", "\\bclaim\\b", "\\bbuy\\b", "\\bcompra\\b"]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "promo",
|
|
104
|
+
"weight": 0.18,
|
|
105
|
+
"patterns": ["\\bwin\\b", "\\bganaste\\b", "\\bgratis\\b", "\\bfree\\b"]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "coercion",
|
|
111
|
+
"weight": 0.3,
|
|
112
|
+
"signals": [
|
|
113
|
+
{
|
|
114
|
+
"id": "threat",
|
|
115
|
+
"weight": 0.22,
|
|
116
|
+
"patterns": ["\\bor\\s+else\\b", "\\bsi\\s+no\\b", "\\bI\\s+will\\b", "\\bte\\s+voy\\s+a\\b"]
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "conspiracy",
|
|
122
|
+
"weight": 0.25,
|
|
123
|
+
"signals": [
|
|
124
|
+
{
|
|
125
|
+
"id": "hidden",
|
|
126
|
+
"weight": 0.2,
|
|
127
|
+
"patterns": ["\\bocult\\w+\\b", "\\bhidden\\b", "\\bsecret\\b"]
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": "phishing_fraud",
|
|
133
|
+
"weight": 0.45,
|
|
134
|
+
"signals": [
|
|
135
|
+
{
|
|
136
|
+
"id": "verify_account_request",
|
|
137
|
+
"weight": 0.3,
|
|
138
|
+
"patterns": [
|
|
139
|
+
"\\bverify\\s+your\\s+account\\b",
|
|
140
|
+
"\\bconfirm\\s+your\\s+account\\b",
|
|
141
|
+
"\\baccount\\s+will\\s+be\\s+closed\\b",
|
|
142
|
+
"\\bcódigo\\s+de\\s+verificación\\b",
|
|
143
|
+
"\\benvíame\\s+tu\\s+código\\b",
|
|
144
|
+
"\\bconfirma\\s+tu\\s+cuenta\\b"
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "financial_data_request",
|
|
149
|
+
"weight": 0.35,
|
|
150
|
+
"patterns": [
|
|
151
|
+
"\\bmandas\\s+tu\\s+tarjeta\\b",
|
|
152
|
+
"\\benvía\\s+tu\\s+tarjeta\\b",
|
|
153
|
+
"\\bsend\\s+me\\s+your\\s+card\\b",
|
|
154
|
+
"\\btransferencia\\b",
|
|
155
|
+
"\\bwire\\b",
|
|
156
|
+
"\\bdeposito\\b",
|
|
157
|
+
"\\bdepósito\\b"
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"id": "easy_money_scam",
|
|
162
|
+
"weight": 0.25,
|
|
163
|
+
"patterns": [
|
|
164
|
+
"\\bgana\\s+dinero\\s+desde\\s+casa\\b",
|
|
165
|
+
"\\bearn\\s+money\\s+from\\s+home\\b",
|
|
166
|
+
"\\bsin\\s+esfuerzo\\b",
|
|
167
|
+
"\\bno\\s+experience\\s+needed\\b"
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
package/rulesets/support.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
const jsonPath = path.join(path.dirname(new URL(import.meta.url).pathname), "support.json");
|
|
5
|
+
const rules = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
|
|
6
|
+
|
|
7
|
+
export default rules;
|
package/rulesets/support.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "support",
|
|
3
|
-
"version": 1,
|
|
4
|
-
"description": "Customer-support preset: minimizes false positives for normal conversation.",
|
|
5
|
-
"thresholds": { "warn": 0.55, "block": 0.75 },
|
|
6
|
-
"normalization": { "lowercase": true, "trim": true, "collapse_whitespace": true, "unicode_nfkc": true },
|
|
7
|
-
"hard_triggers": [
|
|
8
|
-
{ "id": "links", "type": "signal", "weight": 0.10, "patterns": ["https?://", "www\\."] }
|
|
9
|
-
],
|
|
10
|
-
"topics": [
|
|
11
|
-
{ "id": "marketing_spam", "weight": 0.25, "signals": [
|
|
12
|
-
{ "id": "cta", "weight": 0.12, "patterns": ["\\bclick\\b", "\\bclaim\\b"] },
|
|
13
|
-
{ "id": "promo", "weight": 0.10, "patterns": ["\\bfree\\b", "\\bgratis\\b"] }
|
|
14
|
-
]},
|
|
15
|
-
{ "id": "coercion", "weight": 0.20, "signals": [
|
|
16
|
-
{ "id": "threat", "weight": 0.12, "patterns": ["\\bor\\s+else\\b", "\\bI\\s+will\\b"] }
|
|
17
|
-
]},
|
|
18
|
-
{ "id": "conspiracy", "weight": 0.15, "signals": [
|
|
19
|
-
{ "id": "hidden", "weight": 0.10, "patterns": ["\\btruth\\s+hidden\\b", "\\bverdad\\s+oculta\\b"] }
|
|
20
|
-
]}
|
|
21
|
-
]
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "support",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"description": "Customer-support preset: minimizes false positives for normal conversation.",
|
|
5
|
+
"thresholds": { "warn": 0.55, "block": 0.75 },
|
|
6
|
+
"normalization": { "lowercase": true, "trim": true, "collapse_whitespace": true, "unicode_nfkc": true },
|
|
7
|
+
"hard_triggers": [
|
|
8
|
+
{ "id": "links", "type": "signal", "weight": 0.10, "patterns": ["https?://", "www\\."] }
|
|
9
|
+
],
|
|
10
|
+
"topics": [
|
|
11
|
+
{ "id": "marketing_spam", "weight": 0.25, "signals": [
|
|
12
|
+
{ "id": "cta", "weight": 0.12, "patterns": ["\\bclick\\b", "\\bclaim\\b"] },
|
|
13
|
+
{ "id": "promo", "weight": 0.10, "patterns": ["\\bfree\\b", "\\bgratis\\b"] }
|
|
14
|
+
]},
|
|
15
|
+
{ "id": "coercion", "weight": 0.20, "signals": [
|
|
16
|
+
{ "id": "threat", "weight": 0.12, "patterns": ["\\bor\\s+else\\b", "\\bI\\s+will\\b"] }
|
|
17
|
+
]},
|
|
18
|
+
{ "id": "conspiracy", "weight": 0.15, "signals": [
|
|
19
|
+
{ "id": "hidden", "weight": 0.10, "patterns": ["\\btruth\\s+hidden\\b", "\\bverdad\\s+oculta\\b"] }
|
|
20
|
+
]}
|
|
21
|
+
]
|
|
22
|
+
}
|