New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@guardian/consent-management-platform

Package Overview
Dependencies
Maintainers
21
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/consent-management-platform

Library of useful utilities for managing consent state across *.theguardian.com

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-81.3%
Maintainers
21
Weekly downloads
 
Created
Source

Welcome to the Consent Management Platform, a library of useful utilities for managing consent state across *.theguardian.com.

What useful utilities does this offer?

cmp

If you need to conditionally run some code based on a user's consent state you can use the cmp module.

This module exposes two functions onGuConsentNotification and onIabConsentNotification.

onGuConsentNotification

This function takes 2 arguments, the first is the purpose name (a string) that is relevant to the code you're running eg. "functional" OR "performance", and the second is a callback (a function).

When onGuConsentNotification is called it will execute the callback immediately, passing it a single argument (a boolean or null) which indicates the user's consent state at that time for the given purpose name.

The cmp module also listens for subsequent changes to the user's consent state (eg. if a user saves an update to their consent via the CMP modal), if this happens it will re-execute the callback, passing it a single argument (a boolean or null) which inidicates the user's updated consent state for the given purpose name.

Example:

import { onGuConsentNotification } from '@guardian/consent-management-platform';

onGuConsentNotification('functional', functionalConsentState => {
    console.log(functionalConsentState); // true || false || null
});
onIabConsentNotification

This function takes 1 argument, a callback (a function).

When onIabConsentNotification is called it will execute the callback immediately, passing it a single argument, an object which reflects the consent granted to the IAB purposes. The signature for this object will be:

{
    [key: number]: boolean | null;
}

The keys in this object will match the IAB purpose IDs from the IAB vendor list.

The cmp module will also listens for subsequent changes to the user's consent state (eg. if a user saves an update to their consent via the CMP modal), if this happens it will re-execute the callback, passing it a single argument, an object which reflects the latest consent granted to the IAB purposes.

Example:

import { onIabConsentNotification } from '@guardian/consent-management-platform';

onIabConsentNotification(iabConsentState => {
    console.log(iabConsentState); // { 0: true || false || null, 1: true || false || null, ... }
});

cmpConfig

The file cmpConfig exposes some useful config variables related to the CMP.

example:
import { cmpConfig } from '@guardian/consent-management-platform';

Developer instructions

If you're looking to develop on the consent-management-platform please read our development instructions document.

FAQs

Package last updated on 10 Sep 2019

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