@financial-times/cmp-client 2.0.4 → 2.0.5-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/client.d.ts +3 -63
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/consent-ready/index.d.ts +5 -0
  4. package/dist/consent-ready/index.d.ts.map +1 -0
  5. package/dist/consent-ready/utils/__fixtures__/strings.d.ts +9 -0
  6. package/dist/consent-ready/utils/__fixtures__/strings.d.ts.map +1 -0
  7. package/dist/consent-ready/utils/__tests__/check-consent.test.d.ts +2 -0
  8. package/dist/consent-ready/utils/__tests__/check-consent.test.d.ts.map +1 -0
  9. package/dist/consent-ready/utils/__tests__/get-parsed-consent.test.d.ts +2 -0
  10. package/dist/consent-ready/utils/__tests__/get-parsed-consent.test.d.ts.map +1 -0
  11. package/dist/consent-ready/utils/__tests__/validators.test.d.ts +2 -0
  12. package/dist/consent-ready/utils/__tests__/validators.test.d.ts.map +1 -0
  13. package/dist/consent-ready/utils/get-consent-payload.d.ts +18 -0
  14. package/dist/consent-ready/utils/get-consent-payload.d.ts.map +1 -0
  15. package/dist/consent-ready/utils/get-parsed-consent.d.ts +14 -0
  16. package/dist/consent-ready/utils/get-parsed-consent.d.ts.map +1 -0
  17. package/dist/consent-ready/utils/has-consent-changed.d.ts +3 -0
  18. package/dist/consent-ready/utils/has-consent-changed.d.ts.map +1 -0
  19. package/dist/consent-ready/utils/validators.d.ts +16 -0
  20. package/dist/consent-ready/utils/validators.d.ts.map +1 -0
  21. package/dist/html/__tests__/cmp-footer-links.test.d.ts +2 -0
  22. package/dist/html/__tests__/cmp-footer-links.test.d.ts.map +1 -0
  23. package/dist/html/cmp-footer-link.d.ts +8 -0
  24. package/dist/html/cmp-footer-link.d.ts.map +1 -0
  25. package/dist/html/cmp-scripts.d.ts +16 -0
  26. package/dist/html/cmp-scripts.d.ts.map +1 -0
  27. package/dist/{client.cjs → index.cjs} +409 -158
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/{client.js → index.js} +408 -157
  31. package/dist/lib/constants.d.ts +13 -0
  32. package/dist/lib/constants.d.ts.map +1 -0
  33. package/dist/{debug.d.ts → lib/debug.d.ts} +12 -13
  34. package/dist/lib/debug.d.ts.map +1 -0
  35. package/dist/{properties.d.ts → lib/properties.d.ts} +17 -19
  36. package/dist/lib/properties.d.ts.map +1 -0
  37. package/dist/utils/dom.d.ts +3 -0
  38. package/dist/utils/dom.d.ts.map +1 -0
  39. package/package.json +20 -30
  40. package/typings/globals.d.ts +20 -0
  41. package/typings/modules.d.ts +1 -0
  42. package/typings/types.d.ts +88 -0
  43. package/dist/debug.cjs +0 -32
  44. package/dist/debug.js +0 -32
  45. package/dist/properties.cjs +0 -21
  46. package/dist/properties.js +0 -21
@@ -0,0 +1,13 @@
1
+ import type { IabCustomCategory } from "../../typings/types.d.ts";
2
+ export declare const SOURCEPOINT_CONSENT_SOURCE = "sourcepoint-cmp";
3
+ export declare const SOURCEPOINT_FOW_SCOPE = "FTPINK";
4
+ export declare const CONSENT_COOKIE_NAME = "FTConsent";
5
+ export declare const SOURCEPOINT_FOW_ID = "sourcepointCmp/VngD.XycZut.595cp9fWdp5XYP9vlFvk";
6
+ export declare const FT_COOKIE_DOMAIN = ".ft.com";
7
+ export declare const FT_CONSENT_PROXY_HOST = "https://consent.ft.com";
8
+ export declare const legislation: {
9
+ CCPA: string;
10
+ GDPR: string;
11
+ };
12
+ export declare const iabCustomCategories: Record<string, IabCustomCategory>;
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAC5D,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,eAAO,MAAM,kBAAkB,oDAAoD,CAAC;AACpF,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAE9D,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAajE,CAAC"}
@@ -1,13 +1,12 @@
1
- export declare const events: {
2
- onMessageChoiceSelect: (...args: unknown[]) => void;
3
- onMessageReady: (...args: unknown[]) => void;
4
- onMessageChoiceError: (...args: unknown[]) => void;
5
- onPrivacyManagerAction: (...args: unknown[]) => void;
6
- onPMCancel: (...args: unknown[]) => void;
7
- onMessageReceiveData: (...args: unknown[]) => void;
8
- onSPPMObjectReady: (...args: unknown[]) => void;
9
- onConsentReady: (...args: unknown[]) => void;
10
- onError: (...args: unknown[]) => void;
11
- };
12
-
13
- export { }
1
+ export declare const events: {
2
+ onMessageChoiceSelect: (...args: unknown[]) => void;
3
+ onMessageReady: (...args: unknown[]) => void;
4
+ onMessageChoiceError: (...args: unknown[]) => void;
5
+ onPrivacyManagerAction: (...args: unknown[]) => void;
6
+ onPMCancel: (...args: unknown[]) => void;
7
+ onMessageReceiveData: (...args: unknown[]) => void;
8
+ onSPPMObjectReady: (...args: unknown[]) => void;
9
+ onConsentReady: (...args: unknown[]) => void;
10
+ onError: (...args: unknown[]) => void;
11
+ };
12
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/lib/debug.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;qCACgB,OAAO,EAAE;8BAGhB,OAAO,EAAE;oCAGH,OAAO,EAAE;sCAGP,OAAO,EAAE;0BAGrB,OAAO,EAAE;oCAGC,OAAO,EAAE;iCAGZ,OAAO,EAAE;8BAGZ,OAAO,EAAE;uBAGhB,OAAO,EAAE;CAG7B,CAAC"}
@@ -1,19 +1,17 @@
1
- export declare const FT_DOTCOM_LOCAL: {
2
- accountId: number;
3
- baseEndpoint: string;
4
- propertyHref: string;
5
- joinHref: boolean;
6
- gdpr: {};
7
- ccpa: {};
8
- };
9
-
10
- export declare const FT_DOTCOM_PROD: {
11
- accountId: number;
12
- baseEndpoint: string;
13
- propertyId: number;
14
- joinHref: boolean;
15
- gdpr: {};
16
- ccpa: {};
17
- };
18
-
19
- export { }
1
+ export declare const FT_DOTCOM_LOCAL: {
2
+ accountId: number;
3
+ baseEndpoint: string;
4
+ propertyHref: string;
5
+ joinHref: boolean;
6
+ gdpr: {};
7
+ ccpa: {};
8
+ };
9
+ export declare const FT_DOTCOM_PROD: {
10
+ accountId: number;
11
+ baseEndpoint: string;
12
+ propertyId: number;
13
+ joinHref: boolean;
14
+ gdpr: {};
15
+ ccpa: {};
16
+ };
17
+ //# sourceMappingURL=properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/lib/properties.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe;;;;;;;CAK3B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;CAK1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function createContentScript(content: string): HTMLScriptElement;
2
+ export declare function createSourceScript(src: string): HTMLScriptElement;
3
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,qBAIlD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,qBAI7C"}
package/package.json CHANGED
@@ -1,50 +1,40 @@
1
1
  {
2
2
  "name": "@financial-times/cmp-client",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-beta.2",
4
4
  "private": false,
5
5
  "type": "module",
6
- "types": "./dist/types.d.ts",
7
6
  "files": [
8
- "dist"
7
+ "dist",
8
+ "typings"
9
9
  ],
10
+ "main": "./dist/index.cjs",
11
+ "module": "./dist/index.js",
10
12
  "exports": {
11
- "./client": {
12
- "import": "./dist/client.js",
13
- "require": "./dist/client.cjs"
14
- },
15
- "./ssr": {
16
- "import": "./dist/ssr.js",
17
- "require": "./dist/ssr.cjs"
18
- },
19
- "./properties": {
20
- "import": "./dist/properties.js",
21
- "require": "./dist/properties.cjs"
22
- },
23
- "./debug": {
24
- "import": "./dist/debug.js",
25
- "require": "./dist/debug.cjs"
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
26
16
  }
27
17
  },
28
18
  "dependencies": {
29
- "@financial-times/privacy-utils": "^2.0.4",
30
- "next-session-client": "^5.0.0",
31
- "react": "^18.2.0",
32
- "react-dom": "^18.2.0"
19
+ "@iabtechlabtcf/core": "^1.5.10",
20
+ "next-session-client": "^5.0.0"
33
21
  },
34
22
  "devDependencies": {
35
- "@types/react": "^18.2.29",
36
- "@types/react-dom": "^18.2.13",
37
- "@vitejs/plugin-react": "^4.1.0",
38
23
  "eslint": "^8.51.0",
39
- "express": "^4.18.2",
24
+ "npm-run-all": "^4.1.5",
40
25
  "typescript": "^5.2.2",
41
26
  "vite": "^4.5.0",
42
- "vite-plugin-dts": "^3.6.0",
43
27
  "vitest": "^0.34.6"
44
28
  },
45
29
  "scripts": {
46
- "lint": "eslint . --ext js,jsx",
47
- "build": "vite build",
48
- "test": "echo 'noop'"
30
+ "lint": "eslint ./src ./typings --ext .ts",
31
+ "checks:lint": "npm run lint",
32
+ "checks:unit": "npm t -- --run",
33
+ "checks:types": "tsc",
34
+ "checks": "run-s checks:*",
35
+ "build:lib": "vite build",
36
+ "build:types": "tsc",
37
+ "build": "run-s build:*",
38
+ "test": "vitest"
49
39
  }
50
40
  }
@@ -0,0 +1,20 @@
1
+ export {};
2
+
3
+ declare global {
4
+ interface Window {
5
+ _sp_: {
6
+ addEventListener: (
7
+ e: string,
8
+ callback: (
9
+ legislation: string,
10
+ _: string,
11
+ consentString: string,
12
+ consentMeta: Record<string, unknown>,
13
+ ) => Promise<void>,
14
+ ) => void;
15
+ };
16
+ _sp_queue: {
17
+ push: (f: () => void) => void;
18
+ };
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ declare module "next-session-client";
@@ -0,0 +1,88 @@
1
+ import type { events } from "../src/lib/debug.ts";
2
+
3
+ import { iabCustomCategories } from "../src/iab.ts";
4
+
5
+ export type SPLifecycleEvents = Partial<typeof events>;
6
+
7
+ export interface SPConfig {
8
+ accountId: number;
9
+ baseEndpoint: string;
10
+ gdpr: Record<string, unknown>;
11
+ ccpa: Record<string, unknown>;
12
+ propertyHref?: string;
13
+ propertyId?: number;
14
+ joinHref?: boolean;
15
+ events?: SPLifecycleEvents;
16
+ authId?: string;
17
+ }
18
+
19
+ export type CMPInitOptions = Partial<{
20
+ propertyConfig: SPConfig;
21
+ userId?: string;
22
+ useFTSession: boolean;
23
+ consentProxyHost: string;
24
+ cookieDomain: string;
25
+ formOfWordsId: string;
26
+ useConsentStore: boolean;
27
+ }>;
28
+
29
+ export interface ConsentPayloadOptions {
30
+ shouldUpdateConsentStore: boolean;
31
+ formOfWordsId: string;
32
+ cookieDomain: string;
33
+ }
34
+
35
+ export interface ConsentCategoryPayload {
36
+ onsite: {
37
+ status: boolean;
38
+ lbi: false;
39
+ source: "sourcepoint-cmp";
40
+ fow?: string;
41
+ };
42
+ }
43
+
44
+ export type ConsentReadyProps = Omit<CMPInitOptions, "propertyConfig" | "useFTSession">;
45
+
46
+ export interface ConsentPayloadOptions {
47
+ shouldUpdateConsentStore: boolean;
48
+ formOfWordsId: string;
49
+ cookieDomain: string;
50
+ }
51
+
52
+ export interface ConsentCategoryPayload {
53
+ onsite: {
54
+ status: boolean;
55
+ lbi: false;
56
+ source: "sourcepoint-cmp";
57
+ fow?: string;
58
+ };
59
+ }
60
+
61
+ export interface IabCustomCategory {
62
+ purposes: number[];
63
+ iabVendors: number[];
64
+ customVendors: number[];
65
+ specialFeatures: number[];
66
+ fowId?: string;
67
+ isLbi?: boolean;
68
+ }
69
+
70
+ export type IabCustomCategoryName = keyof typeof iabCustomCategories;
71
+
72
+ export type Legislation = "gdpr" | "ccpa";
73
+
74
+ export interface RawConsentState {
75
+ gdpr: string | null;
76
+ ccpa: string | null;
77
+ activeLegislation: Legislation;
78
+ tcfCustomVendors?: string;
79
+ }
80
+
81
+ export type IabCustomCategories = Record<IabCustomCategoryName, IabCustomCategory>;
82
+
83
+ export type ParsedConsentState = Record<IabCustomCategoryName, boolean>;
84
+
85
+ export interface ConsentState {
86
+ raw: RawConsentState;
87
+ parsed: ParsedConsentState;
88
+ }
package/dist/debug.cjs DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const events = {
4
- onMessageChoiceSelect: function(...args) {
5
- console.log("[event] onMessageChoiceSelect", args);
6
- },
7
- onMessageReady: function(...args) {
8
- console.log("[event] onMessageReady", args);
9
- },
10
- onMessageChoiceError: function(...args) {
11
- console.log("[event] onMessageChoiceError", args);
12
- },
13
- onPrivacyManagerAction: function(...args) {
14
- console.log("[event] onPrivacyManagerAction", args);
15
- },
16
- onPMCancel: function(...args) {
17
- console.log("[event] onPMCancel", args);
18
- },
19
- onMessageReceiveData: function(...args) {
20
- console.log("[event] onMessageReceiveData", args);
21
- },
22
- onSPPMObjectReady: function(...args) {
23
- console.log("[event] onSPPMObjectReady", args);
24
- },
25
- onConsentReady: function(...args) {
26
- console.log("[event] onConsentReady", args);
27
- },
28
- onError: function(...args) {
29
- console.log("[event] onError", args);
30
- }
31
- };
32
- exports.events = events;
package/dist/debug.js DELETED
@@ -1,32 +0,0 @@
1
- const events = {
2
- onMessageChoiceSelect: function(...args) {
3
- console.log("[event] onMessageChoiceSelect", args);
4
- },
5
- onMessageReady: function(...args) {
6
- console.log("[event] onMessageReady", args);
7
- },
8
- onMessageChoiceError: function(...args) {
9
- console.log("[event] onMessageChoiceError", args);
10
- },
11
- onPrivacyManagerAction: function(...args) {
12
- console.log("[event] onPrivacyManagerAction", args);
13
- },
14
- onPMCancel: function(...args) {
15
- console.log("[event] onPMCancel", args);
16
- },
17
- onMessageReceiveData: function(...args) {
18
- console.log("[event] onMessageReceiveData", args);
19
- },
20
- onSPPMObjectReady: function(...args) {
21
- console.log("[event] onSPPMObjectReady", args);
22
- },
23
- onConsentReady: function(...args) {
24
- console.log("[event] onConsentReady", args);
25
- },
26
- onError: function(...args) {
27
- console.log("[event] onError", args);
28
- }
29
- };
30
- export {
31
- events
32
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const defaults = {
4
- joinHref: true,
5
- gdpr: {},
6
- ccpa: {}
7
- };
8
- const FT_DOTCOM_LOCAL = {
9
- ...defaults,
10
- accountId: 1906,
11
- baseEndpoint: "https://cdn.privacy-mgmt.com",
12
- propertyHref: "https://local.ft.com"
13
- };
14
- const FT_DOTCOM_PROD = {
15
- ...defaults,
16
- accountId: 1906,
17
- baseEndpoint: "https://cdn.privacy-mgmt.com",
18
- propertyId: 31642
19
- };
20
- exports.FT_DOTCOM_LOCAL = FT_DOTCOM_LOCAL;
21
- exports.FT_DOTCOM_PROD = FT_DOTCOM_PROD;
@@ -1,21 +0,0 @@
1
- const defaults = {
2
- joinHref: true,
3
- gdpr: {},
4
- ccpa: {}
5
- };
6
- const FT_DOTCOM_LOCAL = {
7
- ...defaults,
8
- accountId: 1906,
9
- baseEndpoint: "https://cdn.privacy-mgmt.com",
10
- propertyHref: "https://local.ft.com"
11
- };
12
- const FT_DOTCOM_PROD = {
13
- ...defaults,
14
- accountId: 1906,
15
- baseEndpoint: "https://cdn.privacy-mgmt.com",
16
- propertyId: 31642
17
- };
18
- export {
19
- FT_DOTCOM_LOCAL,
20
- FT_DOTCOM_PROD
21
- };