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

page-integrity-js

v3.0.2

Published

A library for monitoring and controlling DOM mutations and script execution, essential for PCI DSS compliance and security audits

Readme

Page Integrity JS

npm version npm downloads License: MIT TypeScript Node.js Version Security Bundle Size Tests

A powerful JavaScript library for ensuring webpage content integrity by monitoring and controlling script execution. Essential for PCI DSS compliance and security audits.

Features

  • 🔒 Script behavior monitoring and analysis
  • 🛡️ Domain-based script blocking
  • 📊 Detailed script analysis reports
  • ⚡ Lightweight and zero dependencies
  • 🎯 Easy integration with any web application

Installation

npm install page-integrity-js

Quick Start

import { PageIntegrity } from 'page-integrity-js';

// Initialize with configuration
const pageIntegrity = new PageIntegrity({
  strictMode: false,
  allowedDomains: ['trusted.com'],
  blockedDomains: ['malicious.com']
});

// Start monitoring
pageIntegrity.start();

Configuration Options

| Option | Type | Description | Default | |--------|------|-------------|---------| | strictMode | boolean | Enables strict validation mode | false | | whiteListedScripts | string[] | List of script URLs or patterns that are allowed to execute | [] | | blackListedScripts | string[] | List of script URLs or patterns that are blocked from executing | [] | | analysisConfig | AnalysisConfig | Configuration for script analysis | See below | | onBlocked | (info: BlockedEventInfo) => void | Callback function that is called when a script is blocked | undefined |

AnalysisConfig

| Option | Type | Description | Default | |--------|------|-------------|---------| | minScore | number | Minimum threat score to trigger blocking | 0.7 | | maxThreats | number | Maximum number of threats allowed before blocking | 3 | | checkSuspiciousStrings | boolean | Whether to check for suspicious strings | true | | weights | Record<ThreatCategory, number> | Weights for different threat categories | See below |

BlockedEventInfo

The onBlocked callback receives a BlockedEventInfo object with the following properties:

| Property | Type | Description | |----------|------|-------------| | type | string | Type of blocked event (e.g., 'script') | | timestamp | number | Unix timestamp when the event occurred | | url | string | URL of the blocked script | | source | string | Source of the script (e.g., 'external') | | details | object | Additional details about the blocked script |

Example usage of the onBlocked callback:

const pageIntegrity = new PageIntegrity({
  strictMode: true,
  whiteListedScripts: ['trusted-domain.com'],
  blackListedScripts: ['malicious-domain.com'],
  onBlocked: (info) => {
    console.log('Script blocked:', info);
    // You can implement custom logging, analytics, or notifications here
  }
});

Usage Examples

Basic Protection

import { PageIntegrity } from 'page-integrity-js';

const pageIntegrity = new PageIntegrity({
  whitelistedHosts: ['trusted.com'],
  blacklistedHosts: ['malicious.com']
});

pageIntegrity.start();

Advanced Security

import { PageIntegrity } from 'page-integrity-js';

const pageIntegrity = new PageIntegrity({
  strictMode: true,
  whitelistedHosts: ['trusted.com'],
  blacklistedHosts: ['malicious.com'],
  analysisConfig: {
    minScore: 5,
    maxThreats: 2,
    checkSuspiciousStrings: true,
    weights: {
      evasion: 4,
      covertExecution: 4,
      securityBypass: 3,
      maliciousIntent: 3
    },
    scoringRules: {
      minSafeScore: 5,
      maxThreats: 2,
      suspiciousStringWeight: 2
    }
  }
});

pageIntegrity.start();

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.