open-index/open-npm huggingface dataset:
npm package: @financial-times/privacy-legislation-client
Description: ## What it is
Latest version: 6.10.0

# Privacy Legislation Client

## What it is

A module that reports which privacy-related legislation applies in the user's current
location.

Available for both server and client: see [example](../../examples/legislation-client/README.md)

## Usage

Typical usage would be to add the module to your app, call the imported method
and then update the UI in line with any applicable legal requirements:

```js
import { fetchLegislation, buildConsentPageUrl } from "@financial-times/privacy-legislation-client";

function onPageLoad() {
  /**
   * `legislation`: a Set of applicable laws: "ccpa", "gdpr", etc
   * `region`: Identifies countries or subdivisions - "GB", "US-CA"
   */ 
  const { legislation, region } = await fetchLegislation();

  // Contruct a standardised URL for the Consent Page, embedding legislation  & referrer
  const url = buildConsentPageUrl({ url: "...", legislation })

  if(legislation.has("ccpa")) {
    insertCCPALink(url)
  }

  if(legislation.has("gdpr")) {
    ...
  }
}
```

## How it works

This module is a lightweight wrapper over the Fetch API that hits
`https://privacy.ft.com/api/v1/compliance-region.json`, and exposes the comma-delimted response as a property called `legislation` in the form of a `Set`.

The abstraction allows us to change implementation details like the API's URL, version, etc. without impacting consumers

See the [legislation-api](../../vcl/legislation-api/README.md) for more details
npm package: @financial-times/privacy-utils
Description: A set of utilities to help with managing a user's privacy preferences
Latest version: 2.0.4
Deprecated: This package is no longer supported

# Privacy Utils

## What it is

A module that exports a set of useful helper functions and types for working with privacy legislations and framework

Functions will generally be available for both server-side and client-side code

## Usage

Example usage to check consent for a particular custom purpose:

1. Make sure you have created/updated the custom purpose in `src/packages/privacy-utils/src/custom-purposes.ts`
2. Install, import and use helper function

```js
import { checkConsentFor } from "@financial-times/privacy-utils";

const cookieConsent = getCookieValue("FTConsentV2");

const { gdpr, ccpa, leg: activeLegislation } = cookieConsent;

const consentState = {
  gdpr,
  ccpa,
  activeLegislation,
};

const canRunPermutive = checkConsentFor("permutive", consentState); // boolean
```

### CMP footer link util function

This package exposes a simple util function that is designed to work the FT.com footer. This function
will use a querySelector to find and update the legacy 'Manage Cookie' link so that it works with
the new CMP behavior. The new behavior will open the CMP Modal; whereas the legacy behavior is to
take the user to the Manage Cookies Page.

#### Example usage

```js
import { updateFooterLinkCMP } from "@financial-times/privacy-utils";
...
 if (flagsClient.get('adsDisableInternalCMP')) {
  updateFooterLinkCMP();
 }
```