auto-smart-security 1.0.8 → 1.0.10

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.
@@ -20,7 +20,10 @@ function applySecurity(app, options) {
20
20
  app.set('trust proxy', options.trustProxy);
21
21
  }
22
22
  /** ================= HELMET ================= */
23
- app.use((0, helmet_1.default)());
23
+ app.use((0, helmet_1.default)({
24
+ crossOriginResourcePolicy: false, // 🔥
25
+ crossOriginOpenerPolicy: false, // disable API
26
+ }));
24
27
  /** ================= BLACKLIST STORE ================= */
25
28
  const blacklist = options.blacklist?.store ??
26
29
  new memory_store_1.MemoryBlacklistStore(options.staticBlacklist, options.blacklistTTL);
@@ -48,10 +51,12 @@ function applySecurity(app, options) {
48
51
  return next();
49
52
  const ip = (0, utils_1.getClientIP)(req);
50
53
  const url = req.originalUrl;
54
+ console.log('url =========>', url, ip, blacklist);
51
55
  /** 1️⃣ Blacklist */
52
56
  if (await blacklist.isBlocked(ip)) {
53
57
  return res.status(403).send('Access denied');
54
58
  }
59
+ console.log('run to here =========>', 1);
55
60
  /** 2️⃣ Bot detection */
56
61
  if (botDetector?.detect(req)) {
57
62
  await blacklist.block(ip);
@@ -63,12 +68,14 @@ function applySecurity(app, options) {
63
68
  });
64
69
  return res.status(403).send('Bot detected');
65
70
  }
71
+ console.log('run to here =========>', 2);
66
72
  /** 3️⃣ Path whitelist */
67
73
  const normalizePath = (url) => url.split('?')[0].replace(/^\/+/, '');
68
74
  const isPathAllowed = (url, whitelist) => {
69
75
  const path = normalizePath(url);
70
- return whitelist.some((p) => path === p || path.startsWith(`${p}/`));
76
+ return whitelist.some((p) => path === p || path.includes(`${p}`));
71
77
  };
78
+ console.log('run to here =========>', 3, options.pathWhitelist, url);
72
79
  if (options.pathWhitelist?.length &&
73
80
  !isPathAllowed(url, options.pathWhitelist)) {
74
81
  await blacklist.block(ip);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-smart-security",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Production-ready security middleware for Express / NestJS",
5
5
  "author": "Hai Vinh <haivinhinspirit@gmail.com>",
6
6
  "main": "dist/index.js",