npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nis2shield/react-guard

v0.2.0

Published

Client-side security telemetry and session protection for NIS2 compliance. Part of the NIS2 Shield ecosystem.

Readme

React NIS2 Guard (@nis2shield/react-guard)

npm version License: MIT React

Client-Side Security Telemetry & Session Protection for NIS2 Compliance.

@nis2shield/react-guard is a React library designed to act as the "sentinel" for your frontend applications. It integrates with django-nis2-shield to provide end-to-end compliance coverage by monitoring client-side anomalies, protecting session data, and enforcing security policies directly in the browser.

✨ Features

  • 🛡️ Session Watchdog: Detects user inactivity and "Tab Napping" (background tab hijacking risks)
  • 📡 Telemetry Engine: Automatically captures React component crashes (AuditBoundary) and sends sanitized reports to your SIEM
  • 🔐 Secure Storage: Drop-in replacement for localStorage/sessionStorage with AES-GCM encryption
  • ⌨️ Secure Input: Pre-configured props to harden input fields against caching and clipboard
  • 🔍 Device Fingerprinting (v0.2.0+): Passive device fingerprint collection for session hijacking detection
  • ⚠️ Security Banner (v0.2.0+): Warns users about insecure connections (HTTP) and outdated browsers

📦 Installation

npm install @nis2shield/react-guard
# or
yarn add @nis2shield/react-guard

🚀 Quick Start

1. Wrap your App

import { Nis2Provider, SessionWatchdog, AuditBoundary } from '@nis2shield/react-guard';

function App() {
  return (
    <Nis2Provider 
      config={{
        auditEndpoint: '/api/nis2/telemetry/',
        idleTimeoutMinutes: 15,
        debug: process.env.NODE_ENV === 'development'
      }}
    >
      <AuditBoundary fallback={<h1>Security Alert</h1>}>
        <SessionWatchdog onIdle={() => window.location.href = '/logout'} />
        <YourMainApp />
      </AuditBoundary>
    </Nis2Provider>
  );
}

2. Protect Sensitive Data

import { useSecureStorage } from '@nis2shield/react-guard';

const UserProfile = () => {
  const { value: iban, setValue: setIban } = useSecureStorage('user_iban', '');

  return (
    <input 
      value={iban} 
      onChange={(e) => setIban(e.target.value)} 
      placeholder="IBAN (Encrypted locally)"
    />
  );
};

3. Harden Input Fields

import { useSecureInput } from '@nis2shield/react-guard';

const PasswordField = () => {
  const secureProps = useSecureInput({ type: 'password' });
  return <input {...secureProps} placeholder="Enter Password" />;
};

4. Report Custom Incidents

import { useNis2Log } from '@nis2shield/react-guard';

const TransferMoney = () => {
  const { logWarning } = useNis2Log();

  const handleTransfer = (amount: number) => {
    if (amount > 10000) {
      logWarning('HIGH_VALUE_TRANSACTION_ATTEMPT', { amount });
    }
  };
};

5. Device Fingerprinting (v0.2.0+)

Collect passive device fingerprints to detect session hijacking:

import { useDeviceFingerprint } from '@nis2shield/react-guard';

const LoginPage = () => {
  const { fingerprint, isLoading, sendToBackend } = useDeviceFingerprint();

  const handleLogin = async () => {
    // Send fingerprint with login for backend validation
    sendToBackend();
    // ... rest of login logic
  };

  return <button onClick={handleLogin} disabled={isLoading}>Login</button>;
};

Collected data:

  • Screen resolution, color depth
  • Timezone, language, platform
  • Hardware concurrency, device memory
  • Canvas fingerprint (SHA-256 hash)
  • WebGL renderer/vendor

🔗 NIS2 Shield Ecosystem

┌─────────────────────────────────────────────────────────────┐
│                        Frontend                              │
│  @nis2shield/react-guard                                    │
│  ├── SessionWatchdog (idle detection)                       │
│  ├── AuditBoundary (crash reports)                         │
│  ├── useDeviceFingerprint (session validation)             │
│  └── → POST /api/nis2/telemetry/                           │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│                        Backend                               │
│  django-nis2-shield                                         │
│  ├── ForensicLogger (HMAC signed logs)                     │
│  ├── RateLimiter, SessionGuard, TorBlocker                 │
│  └── → SIEM (Elasticsearch, Splunk, QRadar, etc.)          │
└─────────────────────────────────────────────────────────────┘

🧪 Development

npm install      # Install dependencies
npm test         # Run test suite (35 tests)
npm run build    # Build for production

📄 License

MIT License - see LICENSE for details.

🤝 Contributing

See CONTRIBUTING.md for guidelines.


Documentation · npm · Changelog