Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coding-blocks/monitorer

Package Overview
Dependencies
Maintainers
6
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coding-blocks/monitorer

monitor and restrict activity on a webpage

  • 1.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by850%
Maintainers
6
Weekly downloads
 
Created
Source

Monitorer

Your secret weapon for exam integrity. With precise monitoring, ensure every test is fair and free from dishonesty. Elevate academic standards effortlessly with Monitorer.

Monitorer is your go-to tool for tracking tab-switches, monitoring face presence, spotting multiple faces, and detecting window resizing. Keep exams fair and focused with ease.

⚽️ Playground

https://monitorer-playground.codingblocks.com

🔨 Installation

npm install @coding-blocks/monitorer

🧑‍🔧 Usage

import Monitorer from "@coding-blocks/monitorer";

// create a monitorer instance
const monitorerInstance = new Monitorer();

async function init() {
  // enable the services you want to track
  await monitorerInstance.enable({
    tabSwitch: true,
    noFace: true,
  });
}

// listen for events fired on violation
window.addEventListener("monitorerfault", (e) => {
  if (e.code === "TAB_SWITCHED") {
  }

  if (e.code === "NO_FACE_DETECTED") {
  }
});

init();

🗺️ Guide

Creating Monitorer instance

To use monitorer, you have to create a Monitorer instance

import Monitorer from "@coding-block/monitorer";

const monitorerInstance = new Monitorer();

Enabling Monitorers

You can enable any or all of the four detectors (we call them monitorers) using the enable() method on the Monitorer instance.

  • Tab Switch detection tabSwitch
  • No Face detection noFace
  • Multiple Faces detection multipleFaces
  • Window Resize detection windowResize
  • Right Click detection rightClick
  • Keyboard events detection keyboard
// Enable tab switch and window resize detection
await monitorerInstance.enable({
  tabSwitch: true,
  windowResize: true,
});

To enable all the monitorers, do not pass anything to enable()

// Enable all the monitorers
await monitorerInstance.enable();
API

🚧 enable() is an asynchronous method.

type enable = (options?: MonitorerEnableOptions): Promise<void>;

type MonitorerEnableOptions = {
  tabSwitch?: true;       // enable tab switch detection
  windowResize?: true;    // enable window resize detection
  windowMove?: true;      // enable window move detection
  noFace?: true;          // enable no face detection
  multipleFaces?: true    // enable multiple faces detection
  noise?: {               // enable noise detection
    volume: number
  }
  rightClick?: true       // enable right click detection
  keyboard?: {            // enable keyboard events detection
    copy?: true,          // enable keyboard copy detection
    paste?: true,         // enable keyboard paste detection
    console?: true        // enable keyboard console detection
  }       
}

Listening for Monitorer Events

After enabling monitorers you can listen to thw following events on the window object.

Event nameDescriptionEvent Type
monitorersuccessSuccess eventMonitorerSuccessEvent
monitorerfaultFault event (Dispatched when violation occurs)MonitorerFaultEvent
monitorererrorError event (Dispatched when something went wrong)MonitorerErrorEvent
Example code to listen for monitorersuccess
// javascript
window.addEventListener("monitorersuccess", (e) => {
  console.log(e);
});

// typescript
window.addEventListener("monitorersuccess", ((
  e: CustomEvent<MonitorerSuccessEvent>
) => {
  console.log(e);
}) as EventListener);
API
type MonitorerSuccessEvent = {
  name: "monitorersuccess";
  message: string;
  code: "MONITORER_ENABLED" | "MONITORERE_DISABLED";
};
type MonitorerFaultEvent =
  | {
      name: "monitorerfault";
      code: "TAB_SWITCHED" | "WINDOW_RESIZED";
      message: string;
    }
  | {
      name: "monitorerfault";
      code: "NO_FACE_DETECTED" | "MULTIPLE_FACES_DETECTED";
      message: string;
      imageBlob: Blob | null;
    };
type MonitorerErrorEvent = {
  name: "monitorererror";
  code: string;
  message: string;
};

Disabling Monitorers

Similar to Enabling Monitorers

You can disable any or all of the four detectors (we call them monitorers) using the disable() method on the Monitorer instance.

  • Tab Switch detection tabSwitch
  • No Face detection noFace
  • Multiple Faces detection multipleFaces
  • Window Resize detection windowResize
  • Right Click detection rightClick
  • Keyboard events detection keyboard
// Disable tab switch and window resize detection
monitorerInstance.disable({
  tabSwitch: true,
  windowResize: true,
});

To disable all the monitorers, do not pass anything to disable()

// Disable all the monitorers
monitorerInstance.disable();
API
type disable = (options?: MonitorerDisableOptions): Promise<void>;

type MonitorerDisableOptions = {
  tabSwitch?: true;       // disable tab switch detection
  windowResize?: true;    // disable window resize detection
  windowMove?: true;      // disable window move detection
  noFace?: true;          // disable no face detection
  multipleFaces?: true    // disable multiple faces detection
  noise?: true            // disable noise detection
  rightClick?: true       // disable right click detection
  keyboard?:  true        // disable keyboard event detection
}

Made with ❤️ and 🧠 @CodingBlocks

Keywords

FAQs

Package last updated on 17 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc