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

secure-test-guard

v1.2.0

Published

Prevents cheating in web quizzes by blocking DevTools, Right-Click, and enforcing Full Screen.

Readme

🛡️ Secure Test Guard

A lightweight TypeScript library to protect web-based quizzes, exams, and assessments from common cheating methods.

npm version npm downloads license


✨ Features

| Feature | Description | |---------|-------------| | 🚫 Block Right-Click | Prevents context menu access | | ⌨️ Block DevTools Shortcuts | Blocks F12, Ctrl+Shift+I, etc. | | 🔐 Secret Toggle | Hidden shortcut for developers/testers | | 📺 Fullscreen Enforcer | Forces users to stay in fullscreen | | ⚙️ Fully Configurable | Customize everything | | 📦 Zero Dependencies | Lightweight and fast | | 🔷 TypeScript First | Full type support |


📦 Installation

npm install secure-test-guard

# secure-test-guard — Quick Reference

🚀 Quick Start

```typescript
import { initSecureTest } from 'secure-test-guard';

// Enable all protections with defaults
const secure = initSecureTest();

// Cleanup when done (e.g., on component unmount)
secure.destroyAll();

📖 Usage Examples

DevTools Guard Only

import { enableDevToolsGuard } from 'secure-test-guard';

const guard = enableDevToolsGuard({
  blockRightClick: true,
  blockShortcuts: true,
  blockF12: true,
  secretKey: { key: 'o', ctrlOrCmd: true, shift: true },
  onToggle: (isLocked) => {
    console.log(`Protection is ${isLocked ? 'ON' : 'OFF'}`);
  }
});

// Manual controls
guard.disable(); // Temporarily disable guard
guard.enable();  // Re-enable guard
guard.toggle();  // Toggle state
guard.isActive(); // Check current state
guard.destroy(); // Remove completely

Fullscreen Enforcer Only

import { enforceFullScreen } from 'secure-test-guard';

const fullscreen = enforceFullScreen({
  title: '📺 Fullscreen Required',
  message: 'Please enable fullscreen to continue your exam.',
  buttonText: 'Enter Fullscreen',
  theme: {
    backgroundColor: '#1e1e2e',
    textColor: '#cdd6f4',
    buttonColor: '#89b4fa',
    buttonTextColor: '#1e1e2e'
  },
  onFullscreenChange: (isFullscreen) => {
    if (!isFullscreen) {
      console.log('User exited fullscreen!');
    }
  }
});

// Manual controls
fullscreen.requestFullscreen(); // Enter fullscreen
fullscreen.exitFullscreen();    // Exit fullscreen
fullscreen.isFullscreen();      // Check status
fullscreen.destroy();           // Remove enforcer

Combined Usage (React Example)

import { useEffect } from 'react';
import { initSecureTest } from 'secure-test-guard';

function QuizPage() {
  useEffect(() => {
    const secure = initSecureTest({
      devTools: {
        blockRightClick: true,
        showAlerts: false,
        onToggle: (locked) => console.log('Guard:', locked)
      },
      fullscreen: {
        title: 'Quiz Mode',
        message: 'Fullscreen is required during the quiz.'
      }
    });

    return () => {
      secure.destroyAll();
    };
  }, []);

  return <div>Your Quiz Content</div>;
}

Disable Specific Feature

const secure = initSecureTest({
  devTools: {
    blockRightClick: true
  },
  fullscreen: false // Disable fullscreen enforcer
});

⌨️ Default Secret Shortcut

| Platform | Shortcut | |---------------|-----------------| | Windows/Linux | Ctrl + Shift + O | | macOS | Cmd + Shift + O |

This unlocks DevTools temporarily for testing/development.


🔧 API Reference

enableDevToolsGuard(options?)

Options

| Option | Type | Default | Description | |----------------------|----------|----------------------------------|--------------------------------------------| | blockRightClick | boolean | true | Block context menu | | blockShortcuts | boolean | true | Block DevTools shortcuts | | blockSave | boolean | true | Block Ctrl+S | | blockViewSource | boolean | true | Block Ctrl+U | | blockF12 | boolean | true | Block F12 key | | enableSecretToggle | boolean | true | Enable secret shortcut | | secretKey | object | { key: 'o', ctrlOrCmd: true, shift: true } | Secret key combo | | showAlerts | boolean | true | Show toggle alerts on toggle | | onToggle | function | - | Callback called when the guard toggles |

Notes:

  • secretKey is an object describing the secret toggle combination. Example: { key: 'o', ctrlOrCmd: true, shift: true }.

enforceFullScreen(options?)

Options

| Option | Type | Default | Description | |------------------|----------|----------------------------------|--------------------------------------------| | title | string | '⚠️ Full Screen Required' | Overlay title | | message | string | '...' | Overlay message | | buttonText | string | 'ENABLE FULL SCREEN' | Button label | | theme | object | See below | Styling options (backgroundColor, textColor, buttonColor, buttonTextColor) | | delay | number | 0 | Delay before showing overlay (ms) | | onFullscreenChange| function| - | Status callback when fullscreen state changes |

Theme example:

{
  backgroundColor: '#1e1e2e',
  textColor: '#cdd6f4',
  buttonColor: '#89b4fa',
  buttonTextColor: '#1e1e2e'
}

⚠️ Important Notes

  • The secret shortcut (default: Ctrl/Cmd + Shift + O) temporarily unlocks DevTools for testing/development. Use with caution in production environments.
  • initSecureTest() returns an object with helpers for both devTools and fullscreen (depending on configuration). Use destroyAll() to clean up everything created by the instance.
  • If you disable fullscreen by passing fullscreen: false, only the devTools guard will be active (if configured).

If you want this file committed to the repository (FrontifybyHB/collage-project), tell me the branch name and commit message and I can prepare the commit for you.