@datadome/service-worker-plugin

1.0.0 • Public • Published

DataDome Service Worker Plugin

Overview

This package overrides the global fetch function to hook requests and display challenges for blocked requests.

Installation

Prerequisites

  • Have the JS Tag set up on your app

Step 1: Install the Package

Install the package using the command:

npm i @datadome/service-worker-plugin

Step 2: Import the Plugin in Your Service Worker

Import the package into your service worker script.

For ES Modules

import '@datadome/service-worker-plugin';

For CommonJS

require('@datadome/service-worker-plugin');

Step 3: Configure the JS Tag

To enable the JS Tag to listen to the service worker, update its configuration to include the enableServiceWorkerPlugin option:

<script>
  window.ddjskey = 'YOUR_DATADOME_JS_KEY';
  window.ddoptions = {
      enableServiceWorkerPlugin: true,
  };
</script>

How it works

The fetch override is applied when the service worker is activated. The interception of requests and responses will be enabled as soon as the service worker is installed and ready to handle fetch events.

Readme

Keywords

none

Package Sidebar

Install

npm i @datadome/service-worker-plugin

Weekly Downloads

1

Version

1.0.0

License

none

Unpacked Size

7.96 kB

Total Files

3

Last publish

Collaborators

  • catap
  • devdatadome
  • darahak-datadome
  • mguichard
  • daniel_francois_dd
  • lauredg
  • ghada_datadome
  • kireyin-datadome
  • lriberon
  • rajyvan
  • jordan-fokoua