auto-smart-security 1.0.0 → 1.0.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 CHANGED
@@ -50,7 +50,7 @@ applySecurity(app, {
50
50
  Reason: ${info.reason}
51
51
  IP: ${info.ip}
52
52
  URL: ${info.url}
53
- UA: ${info.ua ?? 'N/A'}`
53
+ UA: ${info.ua ?? 'N/A'}`,
54
54
  );
55
55
  },
56
56
  });
@@ -131,19 +131,36 @@ Using ioredis
131
131
 
132
132
  ```ts
133
133
  import Redis from 'ioredis';
134
- import { RedisBlacklistStore } from 'smart-security/dist/blacklist/redis.store';
134
+ import { RedisBlacklistStore } from 'smart-security';
135
135
 
136
- const redis = new Redis(process.env.REDIS_URL);
136
+ const redis = new Redis({
137
+ host: process.env.REDIS_HOST,
138
+ port: Number(process.env.REDIS_PORT ?? 6379),
139
+ password: process.env.REDIS_PASSWORD || undefined,
140
+ });
137
141
 
138
142
  applySecurity(app, {
139
- pathWhitelist: ['admin/', 'media'],
143
+ mode: process.env.NODE_ENV !== 'development' ? 'dev' : 'prod',
144
+ rateLimit: { max: 120, windowMs: 60_000 },
145
+ bot: { enabled: true },
146
+ blacklistTTL: 10 * 60 * 1000,
147
+ pathWhitelist: ['api', '/media'],
140
148
  blacklist: {
141
149
  store: new RedisBlacklistStore(
142
150
  redis,
143
151
  ['1.2.3.4'], // static blacklist
144
- 600 // TTL in seconds
152
+ 600, // TTL in seconds
145
153
  ),
146
154
  },
155
+ onBlock: (info) => {
156
+ SEND_NOTIFICATION_ERR(
157
+ `[SECURITY]
158
+ Reason: ${info.reason}
159
+ IP: ${info.ip}
160
+ URL: ${info.url}
161
+ UA: ${info.ua ?? 'N/A'}`,
162
+ );
163
+ },
147
164
  });
148
165
  ```
149
166
 
@@ -172,4 +189,10 @@ applySecurity(app, {
172
189
  - Docker / Kubernetes
173
190
  - Cloudflare / Nginx / reverse proxies
174
191
 
175
- ## 🧩 Works With
192
+ ## 📬 Contact
193
+
194
+ If you have questions, suggestions, or want to report security issues, feel free to contact:
195
+
196
+ - **Email:** haivinhinspirit@gmail.com
197
+
198
+ I usually respond within 24–48 hours.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from './apply-security';
2
2
  export * from './types';
3
3
  export * from './utils';
4
+ export * from './blacklist/blacklist.interface';
5
+ export * from './blacklist/memory.store';
6
+ export * from './blacklist/redis.store';
package/dist/index.js CHANGED
@@ -17,3 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./apply-security"), exports);
18
18
  __exportStar(require("./types"), exports);
19
19
  __exportStar(require("./utils"), exports);
20
+ __exportStar(require("./blacklist/blacklist.interface"), exports);
21
+ __exportStar(require("./blacklist/memory.store"), exports);
22
+ __exportStar(require("./blacklist/redis.store"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-smart-security",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Production-ready security middleware for Express / NestJS",
5
5
  "author": "Hai Vinh <haivinhinspirit@gmail.com>",
6
6
  "main": "dist/index.js",