Socket
Socket
Sign inDemoInstall

@didomi/consentwebtoken

Package Overview
Dependencies
1
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @didomi/consentwebtoken

Consent web token implementation for node.js and the browser


Version published
Weekly downloads
229
increased by324.07%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

cwt-node

Build Status Coverage Status

An implementation of the Consent web token specification.

A consent web token is a JWT that has standardized consent claims and that can be used to represent user consent for data privacy regulations like GDPR or ePrivacy.

This library provides easy-to-use functions to:

  • Manage user consent (add, check and remove user consent from a token)
  • Encode/decode a token
  • Sign a token
const { CWT, Purposes } = require('@didomi/consentwebtoken');

// Create a consent web token for a user
const token = new CWT({
  issuer: 'didomi',
  user_id: 'user@domain.com',
  user_id_type: 'email',
});

// Add a few consents
token.setConsentStatus(true, Purposes.Cookies, 'didomi');
token.setConsentStatus(true, Purposes.Cookies, 'liveramp');

// Check what the consent status of a given purpose
token.getConsentStatus(Purposes.Cookies, 'didomi');

// Encode the token for storage
token.toJSON();

Table of Contents

Installation

npm install --save @didomi/consentwebtoken

The package has no peer dependency.

Documentation

The API documentation is available here: https://didomi.github.io/cwt-node/class/src/token.js~CWT.html

A Consent Web Token is a very simple data structure. Example:

{
    user_id: 'user@email.com',
    user_id_type: 'email',
    consents: [
        {
            purpose: 'cookies',
            vendors: [
                {
                  id: '*',
                  status: true
                }
                {
                  id: 'didomi',
                  status: true
                },
                {
                  id: 'other-vendor',
                  status: false
                }
            ]
        }
    ]
}

License

MIT. See LICENSE.

Sponsor

Logo of Didomi

cwt-node is developed and maintained by Didomi, an end-to-end solution for managing data privacy and user consent.

Keywords

FAQs

Last updated on 24 May 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc