zsecure-express
v1.2.0
Published
Enterprise-grade security layer for Express.js with advanced protection, deception, and threat intelligence
Maintainers
Readme
🛡️ zSecure-Express - Ultimate Security for Node.js
NOTE: I am not an experienced professional developer, and whole of this code is generated by free version of AI.
One-line security for your Express apps. Enterprise-grade protection made simple.
zSecure-Express is a comprehensive security middleware suite designed to protect your Node.js/Express applications against a wide range of cyber threats. It combines industry-standard best practices with advanced features like AI-powered anomaly detection and active deception (honeypots).
✨ Features
| Feature | Description |
| --------------------------- | ------------------------------------------------------------------------------- |
| 🛡️ Core Protection | Advanced Helmet Headers, CORS, CSRF, and Rate Limiting. |
| 🧠 AI Anomaly Detection | Machine learning powered analysis to detect unusual traffic patterns. |
| 🍯 Auto Honeypot | Deceptive endpoints (e.g., /wp-admin, /.env) that trap and block attackers. |
| 🌍 Threat Intelligence | Real-time IP reputation checks against known banlists (AbuseIPDB, VirusTotal). |
| 💉 Injection Prevention | Automatic protection against XSS and SQL Injection attacks. |
| 🔌 Plugin System | Extensible architecture with built-in WAF and Audit Log plugins. |
| 📜 Zero Config | Works effectively out of the box with smart defaults. |
🚀 Installation
npm install zsecure-express express
# or
yarn add zsecure-express express⚡ Quick Start
Get full protection in just 5 seconds:
import express from "express";
import { secure } from "zsecure-express";
const app = express();
// 🎉 One line = Full Security
app.use(secure());
app.get("/", (req, res) => {
res.json({ message: "I am secure!" });
});
app.listen(3000, () => {
console.log("Server running on port 3000");
});🎯 Configuration Presets
zSecure comes with optimized presets for common use cases. You don't need to manually configure every option.
import { secure, presets } from "zsecure-express";
// 🏢 Enterprise: Maximum security, strict logging, full threat intel
app.use(secure(presets.enterprise));
// 🔌 API: Optimized for REST/GraphQL (CORS allowed, strict validation)
app.use(secure(presets.api));
// 🛍️ E-commerce: PCI-DSS compliant settings for sensitive transactions
app.use(secure(presets.ecommerce));
// 🍯 Honeypot: Aggressive deception to trap bots
app.use(secure(presets.honeypot));
// 🛠️ Development: Relaxed rules for local testing
app.use(secure(presets.development));🔧 Custom Configuration
You can override any preset or configure individual modules manually.
app.use(
secure({
// Core Modules
rateLimit: {
windowMs: 15 * 60 * 1000,
max: 100,
},
// Advanced Modules
threatIntel: {
enabled: true,
providers: ["abuseipdb"],
},
// Deception
honeypot: {
enabled: true,
endpoints: ["/admin", "/private"],
},
// AI Protection
anomalyDetection: {
enabled: true,
sensitivity: "high",
},
})
);🧩 Modular Usage
If you prefer to use specific middlewares instead of the all-in-one wrapper:
import { helmet, rateLimit, honeywall, xss } from "zsecure-express";
const app = express();
app.use(helmet()); // Secure Headers
app.use(xss()); // XSS Protection
app.use(rateLimit()); // Rate Limiting
app.use(honeywall()); // Honeypot Protection🛠️ Utilities & Plugins
zSecure includes helpful utilities and a plugin system for extending functionality.
Encryption Helper
import { encryption } from "zsecure-express";
const secret = encryption.encrypt("my-secret-data");
const original = encryption.decrypt(secret);Enhanced JWT
import { jwt } from "zsecure-express";
const token = await jwt.sign({ userId: 123 });
const payload = await jwt.verify(token);Plugins
import { secure, SimpleWafPlugin, AuditLogPlugin } from "zsecure-express";
const security = secure();
// Block common malicious patterns
security.use(new SimpleWafPlugin());
// Log all security events
security.use(new AuditLogPlugin({ storage: "file" }));
app.use(security);📊 Monitoring
Access real-time security insights directly from your app.
import { securityMetrics, honeywall } from "zsecure-express";
// View general security stats
app.get("/admin/security/stats", (req, res) => {
res.json(securityMetrics.get());
});
// See who fell for the honeypot
app.get("/admin/security/trapped", (req, res) => {
res.json(honeywall.getInteractions());
});📄 License
MIT © logien
⚠️ Disclaimer
While zSecure-Express provides extensive security layers, no software offers 100% protection. Always follow security best practices, keep your dependencies updated, and perform regular audits.
