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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@paginar/gppstring

v1.2.0

Published

A client library to construct IAB's Global Privacy Platform (GPP) strings

Downloads

7

Readme

This library is DEPRECATED and will not be maintained

Please use https://github.com/IABTechLab/iabgpp-es instead

Purpose

A client library to construct IAB's Global Privacy Platform (GPP) strings

This library includes support for:

| Section ID | Client-side API Prefix | Description | Supported | | ---------- | ---------------------- | ----------------------------------------- | --------- | | 1 | tcfeuv1 | EU TCF v1 section (deprecated) | N/A | | 2 | tcfeuv2 | EU TCF v2 section | Not yet | | 3 | GPP | Header section (REQUIRED, see note below) | Not yet | | 4 | -- | GPP signal integrity section | Not yet | | 5 | tcfca | Canadian TCF section | Not yet | | 6 | uspv1 | USPrivacy String (Unencoded Format) | Yes | | 7 | usnat | US - national section | Not yet | | 8 | usca | US - California section | Yes | | 9 | usva | US - Virginia section | Not yet | | 10 | usco | US - Colorado section | Not yet | | 11 | usut | US - Utah section | Not yet | | 12 | usct | US - Connecticut section | Not yet |

Getting started

Installation

Before we get started, you'll need to install Node and Yarn or npm, and create a directory for your project. Then, install the library using Yarn:

yarn add @paginar/gppstring

Or when using npm run:

npm install @paginar/gppstring

The library can be used in CommonJS & ES6/ESM environments. To use the CJS version:

let {
  UspcaSection,
  GPPString,
} = require("@paginar/gppstring/dist/cjs/index.cjs");

To use the ESM version:

import { UspcaSection, GPPString } from "@paginar/gppstring/dist/esm/index.mjs";

Creating a GPP string

In order to create a GPP string, you first need to create & configure each of the Sections you want to support.

For example if your application needs to support CPRA (for details see the California's privacy rights act spec) you would build a uspca section object, assigning the appropiate values to each user consent

import { UspcaSection, GPPString } from "@paginar/gppstring/dist/esm/index.mjs";

let uspca = new UspcaSection.Builder()
  .setSaleOptOutNotice(0)
  .setSharingOptOutNotice(1)
  .setSensitiveDataLimitUseNotice(1)
  .setSaleOptOut(1)
  .setSharingOptOut(1)
  .setSensitiveDataProcessing([0, 0, 0, 0, 0, 0, 0, 0, 0])
  .setKnownChildSensitiveDataConsents([0, 0])
  .setPersonalDataConsents(0)
  .setMspaCoveredTransaction(0)
  .setMspaOptOutOptionMode(0)
  .setMspaServiceProviderMode(0)
  .build();

let gppString = new GPPString.Builder().addSection(uspca).build();
console.log(gppString.encode2Base64Websafe())

In the console you should see the output as a base64-websafe string: "DBABBa~BAAAAAAA"

Examples

See the /examples folder for CommonJS & ESM examples. Also most source files have Jest tests (/src/**/*.test.js) files which should prove useful.

Caveats

  • The base64-websafe encoding does not match 100% the examples given in the spec. This may be due to an improper padding (we are splicing the bit string into 6 bit chars, and padding the remainder with "0").
    • 0000110000010000000000010011 > DBABM (not DBABMA)
    • 000011000001000000000010001101011 > DBACNY (not DBACNYA)
    • 000011000001000000000001100011110000 > DBABdq (not DBABjw)

To do

  • Add all other sections
  • Add console logging (with different log levels)
  • Create the localStorage key names (ie IABGPP_8_String)
  • GPP String decoder function to assist in debugging? (:thumbsdown:)

Contributors

  • Juan de Tomaso https://github.com/juandeto