@financial-times/privacy-legislation-client

中文文档
6.23.3发布于 2026/07/24TypeScriptESM + CJS零依赖近 30 天下载 4486

What it is

原始使用文档
文档目录3 节
  1. What it is
  2. Usage
  3. How it works

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

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:

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 for more details

版本与发布记录

@financial-times/privacy-legislation-client 共发布 129 个版本,首次发布于 2020/05/19;过去 12 个月发布了 41 个版本。

版本发布日期距今
6.23.3latest2026/07/243 个月前
6.23.22026/07/213 个月前
6.23.12026/07/173 个月前
6.23.02026/07/134 个月前
6.22.42026/07/104 个月前
6.22.32026/07/094 个月前

其他发布通道:pre-release → 5.2.1-beta.6。

关于 @financial-times/privacy-legislation-client 的常见问题

@financial-times/privacy-legislation-client 是什么?

What it is

如何安装 @financial-times/privacy-legislation-client?

在项目目录运行 npm install @financial-times/privacy-legislation-client,或使用 pnpm add / yarn add / bun add。

@financial-times/privacy-legislation-client 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@financial-times/privacy-legislation-client 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@financial-times/privacy-legislation-client 可以商用吗?

@financial-times/privacy-legislation-client 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@financial-times/privacy-legislation-client 的下载量有多少?

根据 npm 官方下载统计,@financial-times/privacy-legislation-client 在 2026/10/15 – 2026/11/13 这 30 天内被下载 4,486 次,日均约 150 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@financial-times/privacy-legislation-client 还在维护吗?

最新版本 6.23.3 发布于 2026/07/24(3 个月前);至今共发布 129 个版本,其中过去 12 个月发布了 41 个;首次发布于 2020/05/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。