cipher-shield 1.0.0 → 1.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Industrial-grade security middleware for Node.js/Express applications**
4
4
 
5
- [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/OminduDissanayaka/cipher-shield)
5
+ [![Version](https://img.shields.io/badge/version-1.1.0-blue.svg)](https://github.com/OminduDissanayaka/cipher-shield)
6
6
  [![NPM](https://img.shields.io/npm/v/cipher-shield.svg)](https://www.npmjs.com/package/cipher-shield)
7
7
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
8
8
  [![Node.js](https://img.shields.io/badge/node-%3E%3D14.0.0-green.svg)](https://nodejs.org/)
@@ -242,35 +242,27 @@ app.use(cipherShield({
242
242
 
243
243
  ## 🚨 DEFCON System
244
244
 
245
- **Adaptive threat escalation that automatically adjusts security levels.**
245
+ **Adaptive threat escalation that automatically adjusts security levels based on real-time threat patterns.**
246
246
 
247
- Monitors threat patterns and escalates security measures from GREEN (normal) to RED (maximum security) based on detected threats.
247
+ The Cipher Shield DEFCON system monitors incoming traffic and automatically (or manually) escalates protection levels from 5 (Normal) to 1 (Maximum). Each level progressively activates deeper defensive layers.
248
248
 
249
- ### Usage
249
+ ### 🛡️ DEFCON Level Technical Breakdown
250
250
 
251
- ```javascript
252
- app.use(cipherShield({
253
- adaptiveDefcon: true // Enable automatic escalation
254
- }));
255
- ```
251
+ | Level | Posture | Features Activated | Performance Impact |
252
+ |:---:|:---:|:--- |:---:|
253
+ | **5** | **Normal** | Standard Passive Defense (Helmet headers, Security Signatures). | Low (Instant) |
254
+ | **4** | **Guarded** | Enhanced Monitoring & Smart Logging (Recursive masking enabled). | Low (Instant) |
255
+ | **3** | **Elevated** | **AI Gate** Analysis: Full payload scanning via Gemini/OpenAI integration. | Medium (+10-50ms) |
256
+ | **2** | **High Alert** | **Ghost Routes** & **Active Shadow Banning**: Malicious IPs are trapped in honeypots. | High (+100ms+) |
257
+ | **1** | **Maximum** | **Full Lockdown**: Minimal processing, strict authentication, and max-encryption. | Restricted |
256
258
 
257
- ### DEFCON Levels
258
-
259
- - **GREEN**: Normal operation, standard security
260
- - **YELLOW**: Elevated threat, increased monitoring
261
- - **ORANGE**: High threat, reduced AI scanning
262
- - **RED**: Maximum threat, minimal processing
263
-
264
- ### Manual Control
259
+ ### Manual Control Example
265
260
 
266
261
  ```javascript
267
262
  const { defconSystem } = require('cipher-shield');
268
263
 
269
- // Check current status
270
- const status = defconSystem.getStatus();
271
-
272
- // Manual escalation
273
- defconSystem.escalate('DDoS_ATTACK_DETECTED');
264
+ // Manually escalate during a detected brute-force attempt
265
+ defconSystem.escalate('DDoS_ATTACK_DETECTED'); // Moves to higher DEFCON level
274
266
  ```
275
267
 
276
268
  ---
@@ -633,9 +625,9 @@ const shield = cipherShield({
633
625
 
634
626
  ### 🆘 Getting Help
635
627
 
636
- - 📧 **Email**: hellow@omindu.dev
628
+ - 📧 **Email**: support@cipher-shield.com
637
629
  - 🐛 **Issues**: [GitHub Issues](https://github.com/OminduDissanayaka/cipher-shield/issues)
638
- - 📖 **Documentation**: [Website](https://github.com/OminduDissanayaka/cipher-shield)
630
+ - 📖 **Documentation**: [Website](https://cipher-shield.dev)
639
631
 
640
632
  ### 🤝 Contributing
641
633
 
@@ -663,4 +655,3 @@ const shield = cipherShield({
663
655
 
664
656
  **Built with ❤️ by [Omindu Dissanayaka](https://omindu.dev)**
665
657
 
666
-
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * threat detection, adaptive DEFCON escalation, and automated SSL certificate management.
7
7
  *
8
8
  * @module cipher-shield
9
- * @version 1.0.0
9
+ * @version 1.1.0
10
10
  * @author cipher-shield Team
11
11
  * @license MIT
12
12
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cipher-shield",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Advanced active defense middleware for Node.js/Express with AES encryption, honeypot detection, AI threat analysis, and adaptive security. Features 9 AES algorithms, ghost routes, shadow ban, and DEFCON system.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -12,7 +12,7 @@
12
12
  * - Performance optimized for high-throughput scenarios
13
13
  *
14
14
  * @module aesEngine
15
- * @version 1.0.0
15
+ * @version 1.1.0
16
16
  * @author Omindu Dissanayaka
17
17
  * @license MIT
18
18
  */
@@ -366,4 +366,4 @@ module.exports = {
366
366
  getSupportedAlgorithms,
367
367
  getAlgorithmInfo,
368
368
  ALGORITHMS
369
- };
369
+ };
@@ -13,7 +13,7 @@
13
13
  * - Thread-safe operations for concurrent requests
14
14
  *
15
15
  * @module blacklistMem
16
- * @version 1.0.0
16
+ * @version 1.1.0
17
17
  * @author Omindu Dissanayaka
18
18
  * @license MIT
19
19
  */
@@ -507,4 +507,4 @@ module.exports = {
507
507
  getEntry,
508
508
  events, // For advanced monitoring
509
509
  DEFAULT_CONFIG
510
- };
510
+ };
@@ -6,8 +6,11 @@
6
6
  * system to prevent persistent high-security states while maintaining protection.
7
7
  *
8
8
  * DEFCON States:
9
- * - GREEN: Normal operation, all security features active but not aggressive
10
- * - RED: High alert, conservative security measures (may skip resource-intensive checks)
9
+ * - 5 (NORMAL): Standard passive defense, all features available
10
+ * - 4 (GUARDED): Enhanced monitoring and smart logging
11
+ * - 3 (ELEVATED): AI Gate analysis activated
12
+ * - 2 (HIGH_ALERT): Ghost routes and shadow banning active
13
+ * - 1 (MAXIMUM): Full lockdown with minimal processing
11
14
  *
12
15
  * Features:
13
16
  * - Automatic escalation based on threat patterns
@@ -16,7 +19,7 @@
16
19
  * - Performance monitoring and logging
17
20
  *
18
21
  * @module defconSystem
19
- * @version 1.0.0
22
+ * @version 1.1.0
20
23
  * @author Omindu Dissanayaka
21
24
  * @license MIT
22
25
  */
@@ -24,11 +27,14 @@
24
27
  /**
25
28
  * DEFCON security states enumeration
26
29
  * @readonly
27
- * @enum {string}
30
+ * @enum {number}
28
31
  */
29
32
  const DEFCON_STATES = Object.freeze({
30
- GREEN: 'GREEN',
31
- RED: 'RED'
33
+ NORMAL: 5, // Standard Passive Defense
34
+ GUARDED: 4, // Enhanced Monitoring & Smart Logging
35
+ ELEVATED: 3, // AI Gate Analysis
36
+ HIGH_ALERT: 2, // Ghost Routes & Active Shadow Banning
37
+ MAXIMUM: 1 // Full Lockdown
32
38
  });
33
39
 
34
40
  /**
@@ -45,7 +51,7 @@ const DEFAULT_CONFIG = Object.freeze({
45
51
  * Internal state management
46
52
  * @private
47
53
  */
48
- let currentState = DEFCON_STATES.GREEN;
54
+ let currentState = DEFCON_STATES.NORMAL;
49
55
  let escalationCount = 0;
50
56
  let cooldownTimer = null;
51
57
  let lastEscalationTime = null;
@@ -68,7 +74,7 @@ let threatHistory = [];
68
74
  * ```
69
75
  */
70
76
  function initialize() {
71
- currentState = DEFCON_STATES.GREEN;
77
+ currentState = DEFCON_STATES.NORMAL;
72
78
  escalationCount = 0;
73
79
  lastEscalationTime = null;
74
80
  threatHistory = [];
@@ -79,7 +85,7 @@ function initialize() {
79
85
  }
80
86
 
81
87
  if (process.env.NODE_ENV === 'development') {
82
- console.log('[DEFCON] System initialized to GREEN state');
88
+ console.log('[DEFCON] System initialized to NORMAL (5) state');
83
89
  }
84
90
  }
85
91
 
@@ -87,13 +93,13 @@ function initialize() {
87
93
  * Retrieves the current DEFCON security state
88
94
  *
89
95
  * @function getState
90
- * @returns {string} Current DEFCON state ('GREEN' or 'RED')
96
+ * @returns {number} Current DEFCON level (1-5, where 5 is normal, 1 is maximum security)
91
97
  *
92
98
  * @example
93
99
  * ```javascript
94
- * const state = defconSystem.getState();
95
- * if (state === 'RED') {
96
- * // Apply conservative security measures
100
+ * const level = defconSystem.getState();
101
+ * if (level <= 2) {
102
+ * // Apply high security measures
97
103
  * }
98
104
  * ```
99
105
  */
@@ -104,13 +110,12 @@ function getState() {
104
110
  /**
105
111
  * Escalates the threat level based on detected malicious activity
106
112
  *
107
- * Increments the escalation counter and automatically transitions to RED state
108
- * when the threshold is reached. Implements cooldown-based auto-reset to
109
- * prevent indefinite high-security states.
113
+ * Decreases the DEFCON level (5→4→3→2→1) based on escalation thresholds.
114
+ * Implements cooldown-based auto-reset to prevent indefinite high-security states.
110
115
  *
111
116
  * @function escalate
112
117
  * @param {string} reason - Description of the threat that triggered escalation
113
- * @returns {boolean} True if escalation occurred, false if threshold not met
118
+ * @returns {boolean} True if escalation occurred, false if already at maximum
114
119
  *
115
120
  * @example
116
121
  * ```javascript
@@ -143,32 +148,63 @@ function escalate(reason) {
143
148
  threatHistory = threatHistory.slice(-100);
144
149
  }
145
150
 
146
- if (escalationCount >= DEFAULT_CONFIG.ESCALATION_THRESHOLD && currentState === DEFCON_STATES.GREEN) {
147
- currentState = DEFCON_STATES.RED;
151
+ // Progressive escalation based on threat count
152
+ let newState = currentState;
153
+ let escalated = false;
154
+
155
+ if (escalationCount >= DEFAULT_CONFIG.MAX_ESCALATION_COUNT && currentState > DEFCON_STATES.MAXIMUM) {
156
+ newState = DEFCON_STATES.MAXIMUM;
157
+ escalated = true;
158
+ } else if (escalationCount >= DEFAULT_CONFIG.ESCALATION_THRESHOLD * 4 && currentState > DEFCON_STATES.MAXIMUM) {
159
+ newState = DEFCON_STATES.MAXIMUM;
160
+ escalated = true;
161
+ } else if (escalationCount >= DEFAULT_CONFIG.ESCALATION_THRESHOLD * 3 && currentState > DEFCON_STATES.HIGH_ALERT) {
162
+ newState = DEFCON_STATES.HIGH_ALERT;
163
+ escalated = true;
164
+ } else if (escalationCount >= DEFAULT_CONFIG.ESCALATION_THRESHOLD * 2 && currentState > DEFCON_STATES.ELEVATED) {
165
+ newState = DEFCON_STATES.ELEVATED;
166
+ escalated = true;
167
+ } else if (escalationCount >= DEFAULT_CONFIG.ESCALATION_THRESHOLD && currentState > DEFCON_STATES.GUARDED) {
168
+ newState = DEFCON_STATES.GUARDED;
169
+ escalated = true;
170
+ }
171
+
172
+ if (escalated) {
173
+ const previousState = currentState;
174
+ currentState = newState;
148
175
 
149
176
  if (cooldownTimer) {
150
177
  clearTimeout(cooldownTimer);
151
178
  }
152
179
 
180
+ // Set cooldown timer to gradually increase security level back to normal
153
181
  cooldownTimer = setTimeout(() => {
154
- currentState = DEFCON_STATES.GREEN;
155
- escalationCount = Math.floor(escalationCount / 2);
156
- cooldownTimer = null;
182
+ if (currentState < DEFCON_STATES.NORMAL) {
183
+ currentState = Math.min(currentState + 1, DEFCON_STATES.NORMAL);
184
+ escalationCount = Math.floor(escalationCount / 2);
185
+ }
157
186
 
158
- if (process.env.NODE_ENV === 'development') {
159
- console.log(`[DEFCON] Auto-reset to GREEN after ${DEFAULT_CONFIG.ESCALATION_TIMEOUT / 1000}s cooldown`);
187
+ if (currentState === DEFCON_STATES.NORMAL) {
188
+ escalationCount = 0;
189
+ cooldownTimer = null;
190
+ if (process.env.NODE_ENV === 'development') {
191
+ console.log(`[DEFCON] Auto-reset to NORMAL (5) after cooldown`);
192
+ }
193
+ } else {
194
+ // Continue cooldown for next level
195
+ setTimeout(() => {}, DEFAULT_CONFIG.ESCALATION_TIMEOUT);
160
196
  }
161
197
  }, DEFAULT_CONFIG.ESCALATION_TIMEOUT);
162
198
 
163
199
  if (process.env.NODE_ENV === 'development') {
164
- console.warn(`[DEFCON] 🚨 ESCALATED to RED state: ${reason} (${escalationCount}/${DEFAULT_CONFIG.ESCALATION_THRESHOLD})`);
200
+ console.warn(`[DEFCON] 🚨 ESCALATED to Level ${currentState}: ${reason} (${escalationCount} threats)`);
165
201
  }
166
202
 
167
203
  return true;
168
204
  }
169
205
 
170
206
  if (process.env.NODE_ENV === 'development') {
171
- console.log(`[DEFCON] Threat detected: ${reason} (${escalationCount}/${DEFAULT_CONFIG.ESCALATION_THRESHOLD})`);
207
+ console.log(`[DEFCON] Threat detected: ${reason} (${escalationCount} total threats, Level ${currentState})`);
172
208
  }
173
209
 
174
210
  return false;
@@ -182,27 +218,27 @@ function escalate(reason) {
182
218
  * and counter resets.
183
219
  *
184
220
  * @function setState
185
- * @param {string} state - Target state ('GREEN' or 'RED')
186
- * @returns {boolean} True if state was changed, false if invalid state provided
221
+ * @param {number} level - Target DEFCON level (1-5)
222
+ * @returns {boolean} True if state was changed, false if invalid level provided
187
223
  *
188
224
  * @example
189
225
  * ```javascript
190
- * defconSystem.setState('RED'); // Force high alert
191
- * defconSystem.setState('GREEN'); // Reset to normal
226
+ * defconSystem.setState(1); // Force maximum security
227
+ * defconSystem.setState(5); // Reset to normal
192
228
  * ```
193
229
  */
194
- function setState(state) {
195
- if (state !== DEFCON_STATES.GREEN && state !== DEFCON_STATES.RED) {
230
+ function setState(level) {
231
+ if (typeof level !== 'number' || level < 1 || level > 5) {
196
232
  if (process.env.NODE_ENV === 'development') {
197
- console.error(`[DEFCON] Invalid state: ${state}. Must be 'GREEN' or 'RED'`);
233
+ console.error(`[DEFCON] Invalid level: ${level}. Must be a number between 1 and 5`);
198
234
  }
199
235
  return false;
200
236
  }
201
237
 
202
238
  const previousState = currentState;
203
- currentState = state;
239
+ currentState = level;
204
240
 
205
- if (state === DEFCON_STATES.GREEN) {
241
+ if (level === DEFCON_STATES.NORMAL) {
206
242
  escalationCount = 0;
207
243
  lastEscalationTime = null;
208
244
 
@@ -213,7 +249,7 @@ function setState(state) {
213
249
  }
214
250
 
215
251
  if (process.env.NODE_ENV === 'development') {
216
- console.log(`[DEFCON] Manual state change: ${previousState} → ${state}`);
252
+ console.log(`[DEFCON] Manual state change: Level ${previousState} → Level ${level}`);
217
253
  }
218
254
 
219
255
  return true;
@@ -298,4 +334,4 @@ module.exports = {
298
334
  resetCounter,
299
335
  DEFCON_STATES,
300
336
  DEFAULT_CONFIG
301
- };
337
+ };
package/src/magicAuth.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * secure defaults, and Express middleware integration.
6
6
  *
7
7
  * @module MagicAuth
8
- * @version 1.0.0
8
+ * @version 1.1.0
9
9
  * @author Omindu Dissanayaka
10
10
  * @license MIT
11
11
  */
@@ -269,4 +269,4 @@ class MagicAuth {
269
269
  }
270
270
  }
271
271
 
272
- module.exports = MagicAuth;
272
+ module.exports = MagicAuth;
@@ -6,7 +6,7 @@
6
6
  * injection attacks, and security threats.
7
7
  *
8
8
  * @module aiScanner
9
- * @version 1.0.0
9
+ * @version 1.1.0
10
10
  */
11
11
 
12
12
  const { GoogleGenerativeAI } = require('@google/generative-ai');
@@ -479,4 +479,4 @@ module.exports = {
479
479
  clearCache,
480
480
  validateConfig,
481
481
  DEFAULT_CONFIG
482
- };
482
+ };
@@ -17,7 +17,7 @@
17
17
  * - Memory-efficient string operations
18
18
  *
19
19
  * @module ghostHandler
20
- * @version 1.0.0
20
+ * @version 1.1.0
21
21
  * @author Omindu Dissanayaka
22
22
  * @license MIT
23
23
  */
@@ -276,4 +276,4 @@ module.exports = {
276
276
  validatePattern,
277
277
  getPatternStats,
278
278
  clearCache
279
- };
279
+ };
@@ -19,7 +19,7 @@
19
19
  * - Automatically expires via blacklist system
20
20
  *
21
21
  * @module shadowHandler
22
- * @version 1.0.0
22
+ * @version 1.1.0
23
23
  * @author Omindu Dissanayaka
24
24
  * @license MIT
25
25
  */
@@ -32,8 +32,11 @@ const DEFAULT_CONFIG = Object.freeze({
32
32
  MIN_DELAY: 1000,
33
33
  MAX_DELAY: 45000,
34
34
  JITTER_PERCENT: 0.2,
35
- RED_MULTIPLIER: 1.5,
36
- YELLOW_MULTIPLIER: 1.2
35
+ MAXIMUM_MULTIPLIER: 2.0, // Level 1: Maximum security
36
+ HIGH_ALERT_MULTIPLIER: 1.8, // Level 2: High alert
37
+ ELEVATED_MULTIPLIER: 1.5, // Level 3: Elevated
38
+ GUARDED_MULTIPLIER: 1.2, // Level 4: Guarded
39
+ NORMAL_MULTIPLIER: 1.0 // Level 5: Normal
37
40
  });
38
41
 
39
42
  /**
@@ -46,8 +49,11 @@ let stats = {
46
49
  averageDelay: 0,
47
50
  lastDelay: 0,
48
51
  delaysByDefcon: {
49
- GREEN: 0,
50
- RED: 0
52
+ 1: 0, // MAXIMUM
53
+ 2: 0, // HIGH_ALERT
54
+ 3: 0, // ELEVATED
55
+ 4: 0, // GUARDED
56
+ 5: 0 // NORMAL
51
57
  }
52
58
  };
53
59
 
@@ -59,17 +65,23 @@ let stats = {
59
65
  * @param {string} defconState - Current DEFCON state ('GREEN', 'RED', etc.)
60
66
  * @returns {number} Calculated delay with DEFCON multiplier applied
61
67
  */
62
- function calculateAdaptiveDelay(baseDelay, defconState) {
68
+ function calculateAdaptiveDelay(baseDelay, defconLevel) {
63
69
  let multiplier = 1.0;
64
70
 
65
- switch (defconState) {
66
- case 'RED':
67
- multiplier = DEFAULT_CONFIG.RED_MULTIPLIER;
71
+ switch (defconLevel) {
72
+ case 1: // MAXIMUM
73
+ multiplier = DEFAULT_CONFIG.MAXIMUM_MULTIPLIER;
68
74
  break;
69
- case 'YELLOW':
70
- multiplier = DEFAULT_CONFIG.YELLOW_MULTIPLIER;
75
+ case 2: // HIGH_ALERT
76
+ multiplier = DEFAULT_CONFIG.HIGH_ALERT_MULTIPLIER;
71
77
  break;
72
- case 'GREEN':
78
+ case 3: // ELEVATED
79
+ multiplier = DEFAULT_CONFIG.ELEVATED_MULTIPLIER;
80
+ break;
81
+ case 4: // GUARDED
82
+ multiplier = DEFAULT_CONFIG.GUARDED_MULTIPLIER;
83
+ break;
84
+ case 5: // NORMAL
73
85
  default:
74
86
  multiplier = 1.0;
75
87
  break;
@@ -263,4 +275,4 @@ module.exports = {
263
275
  resetStats,
264
276
  validateDelayParams,
265
277
  DEFAULT_CONFIG
266
- };
278
+ };
package/src/shield.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * threat detection with adaptive DEFCON escalation.
7
7
  *
8
8
  * @author Omindu Dissanayaka
9
- * @version 1.0.0
9
+ * @version 1.1.0
10
10
  * @license MIT
11
11
  */
12
12
 
@@ -363,7 +363,7 @@ function validateAndNormalizeConfig(config = {}) {
363
363
  * threat detection, adaptive DEFCON escalation, and automated SSL certificate management.
364
364
  *
365
365
  * @class CipherShield
366
- * @version 1.0.0
366
+ * @version 1.1.0
367
367
  * @author Omindu Dissanayaka
368
368
  * @license MIT
369
369
  */
@@ -496,34 +496,43 @@ class CipherShield {
496
496
 
497
497
  try {
498
498
  if (this.config.ghostRoutes.length > 0) {
499
- const isGhostRoute = ghostHandler.detect(req.path, this.config.ghostRoutes);
499
+ const currentDefcon = this.config.adaptiveDefcon ? defconSystem.getState() : 5;
500
500
 
501
- if (isGhostRoute) {
502
- blacklistMem.add(clientIP, 'ghost_route_access');
501
+ // Ghost Routes activate at DEFCON Level 2 and below (High Alert, Maximum)
502
+ if (currentDefcon <= 2) {
503
+ const isGhostRoute = ghostHandler.detect(req.path, this.config.ghostRoutes);
503
504
 
504
- if (this.config.adaptiveDefcon) {
505
- defconSystem.escalate('GHOST_ROUTE_HIT');
506
- }
505
+ if (isGhostRoute) {
506
+ blacklistMem.add(clientIP, 'ghost_route_access');
507
+
508
+ if (this.config.adaptiveDefcon) {
509
+ defconSystem.escalate('GHOST_ROUTE_HIT');
510
+ }
507
511
 
512
+ }
508
513
  }
509
514
  }
510
515
 
511
516
  if (this.config.shadowBan.enabled && blacklistMem.isBlacklisted(clientIP)) {
512
- const currentDefcon = this.config.adaptiveDefcon ? defconSystem.getState() : 'GREEN';
513
- const shouldBlock = await shadowHandler.delay(
514
- clientIP,
515
- this.config.shadowBan.delayTime,
516
- currentDefcon
517
- );
517
+ const currentDefcon = this.config.adaptiveDefcon ? defconSystem.getState() : 5;
518
518
 
519
- if (shouldBlock) {
520
- const processingTime = Number(process.hrtime.bigint() - startTime) / 1000000;
521
- console.log(`[cipher-shield] Blocked ${clientIP} after ${processingTime.toFixed(2)}ms`);
519
+ // Shadow Ban activates at DEFCON Level 2 and below (High Alert, Maximum)
520
+ if (currentDefcon <= 2) {
521
+ const shouldBlock = await shadowHandler.delay(
522
+ clientIP,
523
+ this.config.shadowBan.delayTime,
524
+ currentDefcon
525
+ );
522
526
 
523
- return res.status(408).json(addSecurityBranding({
524
- error: 'Request Timeout',
525
- message: 'The server timed out waiting for the request'
526
- }, this.config.signature));
527
+ if (shouldBlock) {
528
+ const processingTime = Number(process.hrtime.bigint() - startTime) / 1000000;
529
+ console.log(`[cipher-shield] Blocked ${clientIP} after ${processingTime.toFixed(2)}ms`);
530
+
531
+ return res.status(408).json(addSecurityBranding({
532
+ error: 'Request Timeout',
533
+ message: 'The server timed out waiting for the request'
534
+ }, this.config.signature));
535
+ }
527
536
  }
528
537
  }
529
538
 
@@ -617,9 +626,10 @@ class CipherShield {
617
626
  );
618
627
 
619
628
  if (shouldScanRoute) {
620
- const currentDefcon = this.config.adaptiveDefcon ? defconSystem.getState() : 'GREEN';
629
+ const currentDefcon = this.config.adaptiveDefcon ? defconSystem.getState() : 5;
621
630
 
622
- if (currentDefcon !== 'RED' || !this.config.adaptiveDefcon) {
631
+ // AI Gate activates at DEFCON Level 3 and below (Elevated, High Alert, Maximum)
632
+ if (currentDefcon <= 3 || !this.config.adaptiveDefcon) {
623
633
  try {
624
634
  const aiConfig = {
625
635
  provider: this.config.aiGate.provider,
@@ -691,4 +701,4 @@ class CipherShield {
691
701
  }
692
702
  }
693
703
 
694
- module.exports = CipherShield;
704
+ module.exports = CipherShield;
@@ -6,7 +6,7 @@
6
6
  * like passwords, tokens, and API keys.
7
7
  *
8
8
  * @module SmartLogger
9
- * @version 1.0.0
9
+ * @version 1.1.0
10
10
  * @author Omindu Dissanayaka
11
11
  * @license MIT
12
12
  */
@@ -265,4 +265,4 @@ class SmartLogger {
265
265
  }
266
266
  }
267
267
 
268
- module.exports = SmartLogger;
268
+ module.exports = SmartLogger;
package/src/sslManager.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Supports HTTP-01 challenge automation, secure certificate storage, and auto-renewal.
6
6
  *
7
7
  * @module SSLManager
8
- * @version 1.0.0
8
+ * @version 1.1.0
9
9
  * @author Omindu Dissanayaka
10
10
  * @license MIT
11
11
  */
@@ -342,4 +342,4 @@ class SSLManager {
342
342
  }
343
343
  }
344
344
 
345
- module.exports = SSLManager;
345
+ module.exports = SSLManager;