npm version Node.js TypeScript License

NIS2 Compliance for Express.js

Forensic logging, active defense, and security headers in a single app.use(). Production-ready NIS2 compliance middleware for Node.js applications.

npm install @nis2shield/express-middleware

Quick Start

import express from 'express';
import { nis2Shield } from '@nis2shield/express-middleware';

const app = express();

// One line to NIS2 compliance
app.use(nis2Shield());

app.listen(3000);
Need Enterprise Integrations?

Splunk, Datadog, QRadar connectors + Threat Intelligence + Priority Support

Explore Middleware Pro →

What's Included

v0.4.0 Features

Forensic Logging

Structured JSON logs with HMAC-SHA256 signing. Now with Multi-SIEM support.

Multi-SIEM NEW

Native connectors for Splunk HEC, Datadog, and QRadar (CEF via TCP/UDP).

Session Guard NEW

Anti-hijacking middleware that fingerprints sessions by IP and User-Agent.

Webhooks NEW

Real-time alerts via Slack, Teams, and Discord for critical security events.

Compliance CLI NEW

Audit your app configuration with `npx check-nis2`. Generates HTML/JSON reports.

Active Defense

Rate limiting (Token Bucket), IP blocking, Tor exit node detection, and Geo-blocking.

Security Headers

HSTS, CSP, X-Frame-Options, Referrer-Policy, and Permissions-Policy out-of-the-box.

Full Configuration

import { nis2Shield } from '@nis2shield/express-middleware';

app.use(nis2Shield({
  enabled: true,
  encryptionKey: process.env.NIS2_ENCRYPTION_KEY,
  integrityKey: process.env.NIS2_HMAC_KEY,
  
  logging: {
    enabled: true,
    anonymizeIP: true,
    encryptPII: true,
    piiFields: ['userId', 'email'],
  },
  
  activeDefense: {
    rateLimit: {
      enabled: true,
      windowMs: 60000,
      max: 100,
    },
    blockTor: true,
    sessionGuard: { enabled: true },
  },
  
  webhooks: {
    url: "https://hooks.slack.com/...",
  },
  
  securityHeaders: {
    enabled: true,
    hsts: true,
    csp: "default-src 'self'",
  },
}));

Part of the NIS2 Shield Family

🐍

Django

Python

🍃

Spring Boot

Java

⚛️

React Guard

Frontend

🐳

Infrastructure

Docker/K8s