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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nesgaurd/nesgaurd-js

v1.0.0

Published

Protect your website from malicious script modifications and supply chain attacks with NESGuard SRI monitoring

Readme

NESGuard JavaScript SRI Protection

A JavaScript client for adding Subresource Integrity (SRI) protection to your web applications, providing real-time script tampering detection and enhanced security against supply chain attacks.

Test Coverage npm version License: MIT

What is NESGuard?

NESGuard is a comprehensive Subresource Integrity (SRI) monitoring platform that protects your website from malicious script modifications, supply chain attacks, and third-party script compromises. This package is the JavaScript client that integrates with the NESGuard monitoring service.

How It Works

  1. You integrate this client into your website
  2. The client monitors scripts for integrity changes
  3. When changes are detected, you're alerted in real-time
  4. The NESGuard desktop agent provides detailed forensic information

Complete Setup Guide

Step 1: Create a NESGuard Account

Before using this package, you need to:

  1. Visit nesgaurd.com to create an account
  2. Generate an Agency ID from your dashboard
  3. Download and install the NESGuard Desktop Agent for your operating system (available for Windows, macOS, and Linux)
  4. Configure the desktop agent with your Agency ID and API credentials

Step 2: Install the JavaScript Package

npm install @nesgaurd/nesgaurd-js

Or include via CDN:

<script src="https://cdn.jsdelivr.net/npm/@nesgaurd/nesgaurd-js/dist/nesgaurd.min.js"></script>

Step 3: Set Up Your Website Integration

import NESGuard from '@nesgaurd/nesgaurd-js';

// Initialize NESGuard client
const nesguard = new NESGuard({
  agencyId: 'your-agency-id', // Get this from your NESGuard dashboard
  apiUrl: 'https://nesgaurd.com/api' // Optional, defaults to production API
});

// Setup script monitoring
nesguard.setup();

Step 4: Configure the Desktop Agent

  1. Open the NESGuard Desktop Agent
  2. Enter your Agency ID and API credentials
  3. Configure monitoring preferences and alert thresholds
  4. Set up notification channels (email, SMS, webhook)

Security Features

NESGuard JS includes advanced security measures:

  • Real-time script integrity monitoring
  • Automatic SRI attribute management
  • Instant alerts for script modifications
  • Protection against supply chain attacks
  • Code obfuscation to protect against reverse engineering
  • Domain locking to prevent unauthorized usage
  • Self-defending code to prevent tampering
  • Debug protection to hinder analysis attempts
  • 100% test coverage for reliability

Dashboard and Monitoring

The NESGuard platform provides:

  • Real-time monitoring dashboard
  • Detailed script integrity history
  • Threat intelligence and analytics
  • Forensic information for compromise investigation
  • Team collaboration features
  • API for custom integrations

Visit nesgaurd.com/dashboard after setting up your account to access these features.

Configuration Options

When initializing NESGuard, you can provide several configuration options:

const nesguard = new NESGuard({
  agencyId: 'your-agency-id',          // Required: Your unique agency identifier
  apiUrl: 'https://nesgaurd.com/api',  // Optional: API endpoint for NESGuard service
  scripts: [                           // Optional: Additional scripts to monitor
    'https://example.com/script.js',
    '/local/script.js'
  ],
  autoDetect: true,                    // Optional: Auto-detect scripts on page (default: true)
  interval: 900000,                    // Optional: Monitoring interval in ms (default: 15min)
  onDetection: (event) => {            // Optional: Callback when integrity violation detected
    console.error('Script integrity violation:', event);
  }
});

Methods

setup()

Sets up SRI protection by scanning the page for scripts and registering them with the NESGuard service.

nesguard.setup();

addScript(url, options)

Manually add a script to monitor.

nesguard.addScript('https://example.com/script.js', {
  interval: 60000, // Check every minute
  critical: true   // Mark as critical script
});

removeScript(url)

Stop monitoring a specific script.

nesguard.removeScript('https://example.com/script.js');

checkScript(url)

Force an immediate integrity check of a script.

nesguard.checkScript('https://example.com/script.js')
  .then(result => {
    console.log('Script integrity status:', result.isValid);
  });

Setup Wizard

NESGuard includes a setup wizard to help you configure which scripts to monitor:

import { NESGuardWizard } from '@nesgaurd/nesgaurd-js';

// Launch the setup wizard
NESGuardWizard.launch({
  agencyId: 'your-agency-id',
  onComplete: (config) => {
    // Save configuration and initialize NESGuard
    localStorage.setItem('nesguard-config', JSON.stringify(config));
    const nesguard = new NESGuard(config);
    nesguard.setup();
  }
});

CDN Usage

When using the CDN version, the code is already built, bundled, and obfuscated:

<!-- Include the script -->
<script src="https://cdn.jsdelivr.net/npm/@nesgaurd/nesgaurd-js/dist/nesgaurd.min.js"></script>

<!-- Use it in your code -->
<script>
  document.addEventListener('DOMContentLoaded', () => {
    // Initialize NESGuard
    const nesguard = new NESGuard({
      agencyId: 'your-agency-id'
    });
    
    // Setup protection
    nesguard.setup()
      .then(() => {
        console.log('NESGuard protection active');
      });
  });
</script>

CMS Integrations

Drupal Integration

// In your Drupal theme's JavaScript
import NESGuard from '@nesgaurd/nesgaurd-js';

document.addEventListener('DOMContentLoaded', () => {
  const agencyId = drupalSettings.nesguard?.agencyId;
  
  if (agencyId) {
    const nesguard = new NESGuard({ 
      agencyId,
      apiUrl: drupalSettings.nesguard?.apiUrl || 'https://nesgaurd.com/api'
    });
    nesguard.setup();
  }
});

WordPress Integration

// In your WordPress theme or plugin
document.addEventListener('DOMContentLoaded', () => {
  if (typeof nesguardSettings !== 'undefined') {
    const nesguard = new NESGuard({ 
      agencyId: nesguardSettings.agencyId,
      apiUrl: nesguardSettings.apiUrl || 'https://nesgaurd.com/api'
    });
    nesguard.setup();
  }
});

Advanced: WebSocket Monitoring

For real-time notifications:

import { NESGuardSocket } from '@nesgaurd/nesgaurd-js';

const socket = new NESGuardSocket({
  agencyId: 'your-agency-id',
  token: 'your-jwt-token' // Get this from your authentication system
});

socket.connect();

socket.on('threat', (data) => {
  console.error('Threat detected:', data);
});

License

MIT