@financial-times/cmp-client 2.2.1 → 2.2.3-alpha

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 (66) hide show
  1. package/README.md +91 -35
  2. package/dist/index.cjs +114 -122
  3. package/dist/index.js +114 -122
  4. package/dist/src/client.d.ts.map +1 -0
  5. package/dist/{consent-ready → src/consent-ready}/index.d.ts +1 -1
  6. package/dist/src/consent-ready/index.d.ts.map +1 -0
  7. package/dist/src/consent-ready/utils/__fixtures__/strings.d.ts.map +1 -0
  8. package/dist/src/consent-ready/utils/__tests__/check-consent.test.d.ts.map +1 -0
  9. package/dist/src/consent-ready/utils/__tests__/get-parsed-consent.test.d.ts.map +1 -0
  10. package/dist/src/consent-ready/utils/__tests__/validators.test.d.ts.map +1 -0
  11. package/dist/{consent-ready → src/consent-ready}/utils/get-consent-payload.d.ts +1 -1
  12. package/dist/src/consent-ready/utils/get-consent-payload.d.ts.map +1 -0
  13. package/dist/src/consent-ready/utils/get-parsed-consent.d.ts.map +1 -0
  14. package/dist/src/consent-ready/utils/has-consent-changed.d.ts.map +1 -0
  15. package/dist/src/consent-ready/utils/validators.d.ts.map +1 -0
  16. package/dist/src/html/__tests__/cmp-footer-links.test.d.ts.map +1 -0
  17. package/dist/src/html/__tests__/cmp-scripts.test.d.ts +2 -0
  18. package/dist/src/html/__tests__/cmp-scripts.test.d.ts.map +1 -0
  19. package/dist/src/html/cmp-footer-link.d.ts.map +1 -0
  20. package/dist/src/html/cmp-scripts.d.ts +7 -0
  21. package/dist/src/html/cmp-scripts.d.ts.map +1 -0
  22. package/dist/{index.d.ts → src/index.d.ts} +1 -2
  23. package/dist/src/index.d.ts.map +1 -0
  24. package/dist/src/lib/constants.d.ts.map +1 -0
  25. package/dist/src/lib/debug.d.ts +15 -0
  26. package/dist/src/lib/debug.d.ts.map +1 -0
  27. package/dist/src/lib/properties.d.ts +22 -0
  28. package/dist/src/lib/properties.d.ts.map +1 -0
  29. package/dist/src/utils/dom.d.ts +3 -0
  30. package/dist/src/utils/dom.d.ts.map +1 -0
  31. package/package.json +2 -2
  32. package/typings/globals.d.ts +4 -12
  33. package/typings/types.d.ts +11 -1
  34. package/dist/client.d.ts.map +0 -1
  35. package/dist/consent-ready/index.d.ts.map +0 -1
  36. package/dist/consent-ready/utils/__fixtures__/strings.d.ts.map +0 -1
  37. package/dist/consent-ready/utils/__tests__/check-consent.test.d.ts.map +0 -1
  38. package/dist/consent-ready/utils/__tests__/get-parsed-consent.test.d.ts.map +0 -1
  39. package/dist/consent-ready/utils/__tests__/validators.test.d.ts.map +0 -1
  40. package/dist/consent-ready/utils/get-consent-payload.d.ts.map +0 -1
  41. package/dist/consent-ready/utils/get-parsed-consent.d.ts.map +0 -1
  42. package/dist/consent-ready/utils/has-consent-changed.d.ts.map +0 -1
  43. package/dist/consent-ready/utils/validators.d.ts.map +0 -1
  44. package/dist/html/__tests__/cmp-footer-links.test.d.ts.map +0 -1
  45. package/dist/html/cmp-footer-link.d.ts.map +0 -1
  46. package/dist/html/cmp-scripts.d.ts +0 -16
  47. package/dist/html/cmp-scripts.d.ts.map +0 -1
  48. package/dist/index.d.ts.map +0 -1
  49. package/dist/lib/constants.d.ts.map +0 -1
  50. package/dist/lib/debug.d.ts +0 -12
  51. package/dist/lib/debug.d.ts.map +0 -1
  52. package/dist/lib/properties.d.ts +0 -17
  53. package/dist/lib/properties.d.ts.map +0 -1
  54. package/dist/utils/dom.d.ts +0 -3
  55. package/dist/utils/dom.d.ts.map +0 -1
  56. /package/dist/{client.d.ts → src/client.d.ts} +0 -0
  57. /package/dist/{consent-ready → src/consent-ready}/utils/__fixtures__/strings.d.ts +0 -0
  58. /package/dist/{consent-ready → src/consent-ready}/utils/__tests__/check-consent.test.d.ts +0 -0
  59. /package/dist/{consent-ready → src/consent-ready}/utils/__tests__/get-parsed-consent.test.d.ts +0 -0
  60. /package/dist/{consent-ready → src/consent-ready}/utils/__tests__/validators.test.d.ts +0 -0
  61. /package/dist/{consent-ready → src/consent-ready}/utils/get-parsed-consent.d.ts +0 -0
  62. /package/dist/{consent-ready → src/consent-ready}/utils/has-consent-changed.d.ts +0 -0
  63. /package/dist/{consent-ready → src/consent-ready}/utils/validators.d.ts +0 -0
  64. /package/dist/{html → src/html}/__tests__/cmp-footer-links.test.d.ts +0 -0
  65. /package/dist/{html → src/html}/cmp-footer-link.d.ts +0 -0
  66. /package/dist/{lib → src/lib}/constants.d.ts +0 -0
package/dist/index.js CHANGED
@@ -5,6 +5,87 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
8
+ const version = "2.2.3-alpha";
9
+ const events = {
10
+ onMessageChoiceSelect: (...args) => {
11
+ console.log("[debug] onMessageChoiceSelect", args);
12
+ },
13
+ onMessageReady: (...args) => {
14
+ console.log("[debug] onMessageReady", args);
15
+ },
16
+ onMessageChoiceError: (...args) => {
17
+ console.log("[debug] onMessageChoiceError", args);
18
+ },
19
+ onPrivacyManagerAction: (...args) => {
20
+ console.log("[debug] onPrivacyManagerAction", args);
21
+ },
22
+ onPMCancel: (...args) => {
23
+ console.log("[debug] onPMCancel", args);
24
+ },
25
+ onMessageReceiveData: (...args) => {
26
+ console.log("[debug] onMessageReceiveData", args);
27
+ },
28
+ onSPPMObjectReady: (...args) => {
29
+ console.log("[debug] onSPPMObjectReady", args);
30
+ },
31
+ onConsentReady: async (...args) => {
32
+ const [legislation2, consentUUID, consentString, consentMeta] = args;
33
+ console.log("[debug] onConsentReady", { legislation: legislation2, consentString, consentMeta, consentUUID });
34
+ },
35
+ onError: (...args) => {
36
+ console.log("[debug] onError", args);
37
+ }
38
+ };
39
+ function logCmpEvents() {
40
+ window._sp_queue = window._sp_queue ?? [];
41
+ window._sp_queue.push(() => {
42
+ var _a2, _b2;
43
+ for (const [eventId, eventHandler] of Object.entries(events)) {
44
+ (_b2 = (_a2 = window._sp_).addEventListener) == null ? void 0 : _b2.call(_a2, eventId, eventHandler);
45
+ }
46
+ });
47
+ }
48
+ const debug = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49
+ __proto__: null,
50
+ events,
51
+ logCmpEvents
52
+ }, Symbol.toStringTag, { value: "Module" }));
53
+ const defaults = {
54
+ joinHref: true,
55
+ gdpr: {},
56
+ ccpa: {}
57
+ };
58
+ const FT_DOTCOM_TEST = {
59
+ ...defaults,
60
+ accountId: 1906,
61
+ baseEndpoint: "https://consent-manager.ft.com",
62
+ propertyHref: "https://local.ft.com"
63
+ };
64
+ const FT_DOTCOM_PROD = {
65
+ ...defaults,
66
+ accountId: 1906,
67
+ baseEndpoint: "https://consent-manager.ft.com",
68
+ propertyId: 31642
69
+ };
70
+ const properties = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
71
+ __proto__: null,
72
+ FT_DOTCOM_PROD,
73
+ FT_DOTCOM_TEST
74
+ }, Symbol.toStringTag, { value: "Module" }));
75
+ function updateFooterLinkCMP() {
76
+ const cookieLink = document.querySelector(
77
+ "[href='https://www.ft.com/preferences/manage-cookies']"
78
+ );
79
+ if (cookieLink) {
80
+ cookieLink.href = "#";
81
+ cookieLink.setAttribute("onclick", "window._sp_.gdpr.loadPrivacyManagerModal(827767);");
82
+ cookieLink.dataset.cmpLink = "updated";
83
+ return true;
84
+ } else {
85
+ console.warn("CMP Footer Link was not found and not updated");
86
+ return false;
87
+ }
88
+ }
8
89
  const request = (url, { credentials = "omit" } = {}) => {
9
90
  return fetch(`https://session-next.ft.com${url}`, {
10
91
  credentials,
@@ -111,30 +192,9 @@ const iabCustomCategories = {
111
192
  specialFeatures: []
112
193
  }
113
194
  };
114
- const defaults = {
115
- joinHref: true,
116
- gdpr: {},
117
- ccpa: {}
118
- };
119
- const FT_DOTCOM_LOCAL = {
120
- ...defaults,
121
- accountId: 1906,
122
- baseEndpoint: "https://consent-manager.ft.com",
123
- propertyHref: "https://local.ft.com"
124
- };
125
- const FT_DOTCOM_PROD = {
126
- ...defaults,
127
- accountId: 1906,
128
- baseEndpoint: "https://consent-manager.ft.com",
129
- propertyId: 31642
130
- };
131
- const properties = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
132
- __proto__: null,
133
- FT_DOTCOM_LOCAL,
134
- FT_DOTCOM_PROD
135
- }, Symbol.toStringTag, { value: "Module" }));
136
- function createContentScript(content) {
195
+ function createContentScript(cmpScript, content) {
137
196
  const s = document.createElement("script");
197
+ s.dataset.cmpScript = cmpScript;
138
198
  s.innerHTML = content;
139
199
  return s;
140
200
  }
@@ -143,47 +203,25 @@ function createSourceScript(src) {
143
203
  s.src = src;
144
204
  return s;
145
205
  }
146
- function encodeConfig(obj) {
147
- let str = "";
148
- if (!obj)
149
- return str;
150
- for (const [key, val] of Object.entries(obj)) {
151
- switch (typeof val) {
152
- case "function":
153
- str += `${key}:${val.toString().replace(/"/g, "'").replace(/\s/g, "")},`;
154
- break;
155
- case "string":
156
- str += `${key}:"${val.replace(/"/g, "'").replace(/\s/g, "")}",`;
157
- break;
158
- case "object":
159
- str += `${key}:{${encodeConfig(val)}},`;
160
- break;
161
- default:
162
- str += `${key}:${val},`;
163
- break;
164
- }
165
- }
166
- return str.slice(0, -1);
167
- }
168
- function getSPConfig(config) {
169
- return `window._sp_queue=[];window._sp_={config:{${encodeConfig(config)}}}`;
170
- }
171
206
  const scriptSources = {
172
207
  cmpFrames: "https://consent-manager.ft.com/unified/wrapperMessagingWithoutDetection.js"
173
208
  };
174
209
  const scriptContent = {
175
- getSPConfig,
176
210
  tcfStub: `"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(){var t=function(){var t,e,o=[],n=window,r=n;for(;r;){try{if(r.frames.__tcfapiLocator){t=r;break}}catch(t){}if(r===n.top)break;r=r.parent}t||(!function t(){var e=n.document,o=!!n.frames.__tcfapiLocator;if(!o)if(e.body){var r=e.createElement("iframe");r.style.cssText="display:none",r.name="__tcfapiLocator",e.body.appendChild(r)}else setTimeout(t,5);return!o}(),n.__tcfapi=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(!n.length)return o;"setGdprApplies"===n[0]?n.length>3&&2===parseInt(n[1],10)&&"boolean"==typeof n[3]&&(e=n[3],"function"==typeof n[2]&&n[2]("set",!0)):"ping"===n[0]?"function"==typeof n[2]&&n[2]({gdprApplies:e,cmpLoaded:!1,cmpStatus:"stub"}):o.push(n)},n.addEventListener("message",(function(t){var e="string"==typeof t.data,o={};if(e)try{o=JSON.parse(t.data)}catch(t){}else o=t.data;var n="object"===_typeof(o)&&null!==o?o.__tcfapiCall:null;n&&window.__tcfapi(n.command,n.version,(function(o,r){var a={__tcfapiReturn:{returnValue:o,success:r,callId:n.callId}};t&&t.source&&t.source.postMessage&&t.source.postMessage(e?JSON.stringify(a):a,"*")}),n.parameter)}),!1))};"undefined"!=typeof module?module.exports=t:t()}();`,
177
211
  uspStub: `"use strict";(function () { var e = false; var c = window; var t = document; function r() { if (!c.frames["__uspapiLocator"]) { if (t.body) { var a = t.body; var e = t.createElement("iframe"); e.style.cssText = "display:none"; e.name = "__uspapiLocator"; a.appendChild(e) } else { setTimeout(r, 5) } } } r(); function p() { var a = arguments; __uspapi.a = __uspapi.a || []; if (!a.length) { return __uspapi.a } else if (a[0] === "ping") { a[2]({ gdprAppliesGlobally: e, cmpLoaded: false }, true) } else { __uspapi.a.push([].slice.apply(a)) } } function l(t) { var r = typeof t.data === "string"; try { var a = r ? JSON.parse(t.data) : t.data; if (a.__cmpCall) { var n = a.__cmpCall; c.__uspapi(n.command, n.parameter, function (a, e) { var c = { __cmpReturn: { returnValue: a, success: e, callId: n.callId } }; t.source.postMessage(r ? JSON.stringify(c) : c, "*") }) } } catch (a) { } } if (typeof __uspapi !== "function") { c.__uspapi = p; __uspapi.msgHandler = l; c.addEventListener("message", l, false) } })();`
178
212
  };
179
- function getCmpScripts(config) {
213
+ function getCmpScripts() {
180
214
  const fragment = document.createDocumentFragment();
181
- fragment.appendChild(createContentScript(scriptContent.tcfStub));
182
- fragment.appendChild(createContentScript(scriptContent.uspStub));
183
- fragment.appendChild(createContentScript(scriptContent.getSPConfig(config)));
215
+ fragment.appendChild(createContentScript("tcf", scriptContent.tcfStub));
216
+ fragment.appendChild(createContentScript("usp", scriptContent.uspStub));
184
217
  fragment.appendChild(createSourceScript(scriptSources.cmpFrames));
185
218
  return fragment;
186
219
  }
220
+ function bootstrapCmp(config) {
221
+ window._sp_ = { config };
222
+ window._sp_queue ?? (window._sp_queue = []);
223
+ document.head.appendChild(getCmpScripts());
224
+ }
187
225
  function getConsentPayload(parsedConsent, { shouldUpdateConsentStore, formOfWordsId, cookieDomain }) {
188
226
  const categoryNames = Object.keys(parsedConsent);
189
227
  const data = categoryNames.reduce(
@@ -201,7 +239,7 @@ function getConsentPayload(parsedConsent, { shouldUpdateConsentStore, formOfWord
201
239
  {}
202
240
  );
203
241
  if (!shouldUpdateConsentStore) {
204
- return { data };
242
+ return { data, cookieDomain };
205
243
  } else {
206
244
  return {
207
245
  setConsentCookie: true,
@@ -1245,7 +1283,7 @@ class VendorVectorEncoder {
1245
1283
  }
1246
1284
  return retrString;
1247
1285
  }
1248
- static decode(value, version) {
1286
+ static decode(value, version2) {
1249
1287
  let vector;
1250
1288
  let index = 0;
1251
1289
  const maxId = IntEncoder.decode(value.substr(index, BitLength.maxId), BitLength.maxId);
@@ -1254,7 +1292,7 @@ class VendorVectorEncoder {
1254
1292
  index += BitLength.encodingType;
1255
1293
  if (encodingType === VectorEncodingType.RANGE) {
1256
1294
  vector = new Vector();
1257
- if (version === 1) {
1295
+ if (version2 === 1) {
1258
1296
  if (value.substr(index, 1) === "1") {
1259
1297
  throw new DecodingError("Unable to decode default consent=1");
1260
1298
  }
@@ -1719,12 +1757,12 @@ const _GVL = class _GVL extends Cloneable {
1719
1757
  throw new GVLError("must specify GVL.baseUrl before loading GVL json");
1720
1758
  }
1721
1759
  if (versionOrVendorList > 0) {
1722
- const version = versionOrVendorList;
1723
- if (_GVL.CACHE.has(version)) {
1724
- this.populate(_GVL.CACHE.get(version));
1760
+ const version2 = versionOrVendorList;
1761
+ if (_GVL.CACHE.has(version2)) {
1762
+ this.populate(_GVL.CACHE.get(version2));
1725
1763
  this.readyPromise = Promise.resolve();
1726
1764
  } else {
1727
- url += _GVL.versionedFilename.replace("[VERSION]", String(version));
1765
+ url += _GVL.versionedFilename.replace("[VERSION]", String(version2));
1728
1766
  this.readyPromise = this.fetchJson(url);
1729
1767
  }
1730
1768
  } else {
@@ -2798,7 +2836,7 @@ async function saveConsent(consentEndpoint, payload) {
2798
2836
  }
2799
2837
  function consentReadyHandlerFn(props) {
2800
2838
  const { userId, consentProxyHost, cookieDomain, formOfWordsId, useConsentStore } = props;
2801
- return async function consentReadyHandler(legislation2, _, consentString, consentMeta) {
2839
+ return async function consentReadyHandler(legislation2, _consentUUID, consentString, consentMeta) {
2802
2840
  const activeLegislation = consentMeta.applies ? legislation2 : "gdpr";
2803
2841
  if (activeLegislation !== legislation2 || !consentString) {
2804
2842
  return;
@@ -2835,6 +2873,7 @@ async function initSourcepointCmp({
2835
2873
  formOfWordsId = SOURCEPOINT_FOW_ID,
2836
2874
  useConsentStore = true
2837
2875
  } = {}) {
2876
+ var _a2;
2838
2877
  if (!userId && useFTSession) {
2839
2878
  try {
2840
2879
  const response = await getUuid();
@@ -2849,71 +2888,24 @@ async function initSourcepointCmp({
2849
2888
  if (userId) {
2850
2889
  propertyConfig.authId = userId;
2851
2890
  }
2852
- const scripts = getCmpScripts(propertyConfig);
2853
- document.head.appendChild(scripts);
2854
- window._sp_queue.push(() => {
2855
- window._sp_.addEventListener(
2856
- "onConsentReady",
2857
- consentReadyHandlerFn({
2858
- userId,
2859
- consentProxyHost,
2860
- cookieDomain,
2861
- formOfWordsId,
2862
- useConsentStore
2863
- })
2864
- );
2865
- });
2866
- }
2867
- const events = {
2868
- onMessageChoiceSelect: (...args) => {
2869
- console.log("[event] onMessageChoiceSelect", args);
2870
- },
2871
- onMessageReady: (...args) => {
2872
- console.log("[event] onMessageReady", args);
2873
- },
2874
- onMessageChoiceError: (...args) => {
2875
- console.log("[event] onMessageChoiceError", args);
2876
- },
2877
- onPrivacyManagerAction: (...args) => {
2878
- console.log("[event] onPrivacyManagerAction", args);
2879
- },
2880
- onPMCancel: (...args) => {
2881
- console.log("[event] onPMCancel", args);
2882
- },
2883
- onMessageReceiveData: (...args) => {
2884
- console.log("[event] onMessageReceiveData", args);
2885
- },
2886
- onSPPMObjectReady: (...args) => {
2887
- console.log("[event] onSPPMObjectReady", args);
2888
- },
2889
- onConsentReady: (...args) => {
2890
- console.log("[event] onConsentReady", args);
2891
- },
2892
- onError: (...args) => {
2893
- console.log("[event] onError", args);
2894
- }
2895
- };
2896
- const debug = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2897
- __proto__: null,
2898
- events
2899
- }, Symbol.toStringTag, { value: "Module" }));
2900
- function updateFooterLinkCMP() {
2901
- const cookieLink = document.querySelector(
2902
- "[href='https://www.ft.com/preferences/manage-cookies']"
2903
- );
2904
- if (cookieLink) {
2905
- cookieLink.href = "#";
2906
- cookieLink.setAttribute("onclick", "window._sp_.gdpr.loadPrivacyManagerModal(827767);");
2907
- cookieLink.dataset.cmpLink = "updated";
2908
- return true;
2909
- } else {
2910
- console.warn("CMP Footer Link was not found and not updated");
2911
- return false;
2891
+ if ((_a2 = propertyConfig.events) == null ? void 0 : _a2.onConsentReady) {
2892
+ console.warn("[cmp-client] The supplied 'onConsentReady' event handler will be overwritten.");
2912
2893
  }
2894
+ const events2 = {
2895
+ ...propertyConfig.events ?? {},
2896
+ onConsentReady: consentReadyHandlerFn({
2897
+ userId,
2898
+ consentProxyHost,
2899
+ cookieDomain,
2900
+ formOfWordsId,
2901
+ useConsentStore
2902
+ })
2903
+ };
2904
+ bootstrapCmp({ ...propertyConfig, events: events2 });
2913
2905
  }
2906
+ window.FT_CMP_CLIENT_VERSION = version;
2914
2907
  export {
2915
2908
  debug,
2916
- getCmpScripts,
2917
2909
  initSourcepointCmp,
2918
2910
  properties,
2919
2911
  updateFooterLinkCMP
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS5D,wBAAsB,kBAAkB,CAAC,EACvC,cAA+B,EAC/B,MAAM,EACN,YAAmB,EACnB,gBAAwC,EACxC,YAA+B,EAC/B,aAAkC,EAClC,eAAsB,GACvB,GAAE,cAAmB,iBAkCrB"}
@@ -1,5 +1,5 @@
1
1
  import type { ConsentReadyProps } from "../../typings/types.d.ts";
2
- export declare function consentReadyHandlerFn(props: ConsentReadyProps): (legislation: string, _: string, consentString: string, consentMeta: {
2
+ export declare function consentReadyHandlerFn(props: ConsentReadyProps): (legislation: string, _consentUUID: string, consentString: string, consentMeta: {
3
3
  applies?: boolean;
4
4
  }) => Promise<void>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/consent-ready/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA0B/E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,iBAI7C,MAAM,gBACL,MAAM,iBACL,MAAM,eACR;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,mBAoCrC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../../../../src/consent-ready/utils/__fixtures__/strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,qPACiN,CAAC;AAErP;;GAEG;AACH,eAAO,MAAM,2BAA2B,qPAC4M,CAAC;AAErP,eAAO,MAAM,wBAAwB,obAC8Y,CAAC;AAEpb,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAC3C,eAAO,MAAM,kBAAkB,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-consent.test.d.ts","sourceRoot":"","sources":["../../../../../src/consent-ready/utils/__tests__/check-consent.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parsed-consent.test.d.ts","sourceRoot":"","sources":["../../../../../src/consent-ready/utils/__tests__/get-parsed-consent.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.test.d.ts","sourceRoot":"","sources":["../../../../../src/consent-ready/utils/__tests__/validators.test.ts"],"names":[],"mappings":""}
@@ -4,10 +4,10 @@ import type { ParsedConsentState, ConsentPayloadOptions, ConsentCategoryPayload
4
4
  */
5
5
  export declare function getConsentPayload(parsedConsent: ParsedConsentState, { shouldUpdateConsentStore, formOfWordsId, cookieDomain }: Partial<ConsentPayloadOptions>): {
6
6
  data: Record<string, ConsentCategoryPayload>;
7
+ cookieDomain: string | undefined;
7
8
  setConsentCookie?: undefined;
8
9
  formOfWordsId?: undefined;
9
10
  consentSource?: undefined;
10
- cookieDomain?: undefined;
11
11
  } | {
12
12
  setConsentCookie: boolean;
13
13
  formOfWordsId: string | undefined;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-consent-payload.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/get-consent-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAIhC;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,kBAAkB,EACjC,EAAE,wBAAwB,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,qBAAqB,CAAC;;;;;;;;;;;;EA6B1F"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parsed-consent.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/get-parsed-consent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAOrC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,GAAG,OAAO,CA8B5F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,kBAAkB,CAMrF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-consent-changed.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/has-consent-changed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAoBjE,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,kBAAkB,GAAG,OAAO,CAO5E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAU5D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAO5D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,IAAI,eAAe,CAsBxF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAIrE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmp-footer-links.test.d.ts","sourceRoot":"","sources":["../../../../src/html/__tests__/cmp-footer-links.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cmp-scripts.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmp-scripts.test.d.ts","sourceRoot":"","sources":["../../../../src/html/__tests__/cmp-scripts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmp-footer-link.d.ts","sourceRoot":"","sources":["../../../src/html/cmp-footer-link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAa7C"}
@@ -0,0 +1,7 @@
1
+ import type { SPConfig } from "../../typings/types";
2
+ /**
3
+ * Set up the config and event handlers for the CMP
4
+ * Then add the vendor scripts to the head of the document
5
+ */
6
+ export declare function bootstrapCmp(config: SPConfig): void;
7
+ //# sourceMappingURL=cmp-scripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmp-scripts.d.ts","sourceRoot":"","sources":["../../../src/html/cmp-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAsBpD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,QAK5C"}
@@ -1,6 +1,5 @@
1
- export { initSourcepointCmp } from "./client";
2
1
  export * as debug from "./lib/debug.ts";
3
2
  export * as properties from "./lib/properties.ts";
4
3
  export { updateFooterLinkCMP } from "./html/cmp-footer-link.ts";
5
- export { getCmpScripts } from "./html/cmp-scripts.ts";
4
+ export { initSourcepointCmp } from "./client";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
@@ -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,CAyBjE,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare const events: {
2
+ onMessageChoiceSelect: (...args: never) => void;
3
+ onMessageReady: (...args: never) => void;
4
+ onMessageChoiceError: (...args: never) => void;
5
+ onPrivacyManagerAction: (...args: never) => void;
6
+ onPMCancel: (...args: never) => void;
7
+ onMessageReceiveData: (...args: never) => void;
8
+ onSPPMObjectReady: (...args: never) => void;
9
+ onConsentReady: (legislation: string, consentUUID: string, consentString: string, consentMeta: {
10
+ applies?: boolean | undefined;
11
+ }) => Promise<void>;
12
+ onError: (...args: never) => void;
13
+ };
14
+ export declare function logCmpEvents(): void;
15
+ //# 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,KAAK;8BAGZ,KAAK;oCAGC,KAAK;sCAGH,KAAK;0BAGjB,KAAK;oCAGK,KAAK;iCAGR,KAAK;;kBAQL,OAAO,GAAG,SAAS;;uBAM7B,KAAK;CAGzB,CAAC;AAEF,wBAAgB,YAAY,SAO3B"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This config should only be used to test unregistered properties.
3
+ * Properties on *.ft.com are by default registered.
4
+ * The propertyHref value spoofs the request to Sourcepoint as coming from an FT domain
5
+ */
6
+ export declare const FT_DOTCOM_TEST: {
7
+ accountId: number;
8
+ baseEndpoint: string;
9
+ propertyHref: string;
10
+ joinHref: boolean;
11
+ gdpr: {};
12
+ ccpa: {};
13
+ };
14
+ export declare const FT_DOTCOM_PROD: {
15
+ accountId: number;
16
+ baseEndpoint: string;
17
+ propertyId: number;
18
+ joinHref: boolean;
19
+ gdpr: {};
20
+ ccpa: {};
21
+ };
22
+ //# sourceMappingURL=properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../../src/lib/properties.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;CAK1B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;CAK1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function createContentScript(cmpScript: string, 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,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAKrE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,qBAI7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/cmp-client",
3
- "version": "2.2.1",
3
+ "version": "2.2.3-alpha",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -20,7 +20,7 @@
20
20
  "next-session-client": "^5.0.0"
21
21
  },
22
22
  "devDependencies": {
23
- "eslint": "^8.51.0",
23
+ "eslint": "^8.53.0",
24
24
  "npm-run-all": "^4.1.5",
25
25
  "typescript": "^5.2.2",
26
26
  "vite": "^4.5.0",
@@ -2,19 +2,11 @@ export {};
2
2
 
3
3
  declare global {
4
4
  interface Window {
5
+ FT_CMP_CLIENT_VERSION: string;
5
6
  _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;
7
+ config: SPConfig;
8
+ addEventListener?: (e: string, callback: SPEventCallback) => void;
18
9
  };
10
+ _sp_queue: (() => void)[];
19
11
  }
20
12
  }
@@ -4,6 +4,8 @@ import { iabCustomCategories } from "../src/lib/constants.ts";
4
4
 
5
5
  export type SPLifecycleEvents = Partial<typeof events>;
6
6
 
7
+ export type SPEventId = keyof SPLifecycleEvents;
8
+
7
9
  export interface SPConfig {
8
10
  accountId: number;
9
11
  baseEndpoint: string;
@@ -12,10 +14,17 @@ export interface SPConfig {
12
14
  propertyHref?: string;
13
15
  propertyId?: number;
14
16
  joinHref?: boolean;
15
- events?: SPLifecycleEvents;
17
+ events?: Partial<SPLifecycleEvents>;
16
18
  authId?: string;
17
19
  }
18
20
 
21
+ export type SPEventCallback = (
22
+ legislation: string,
23
+ _: string,
24
+ consentString: string,
25
+ consentMeta: Record<string, unknown>,
26
+ ) => Promise<void>;
27
+
19
28
  export type CMPInitOptions = Partial<{
20
29
  propertyConfig: SPConfig;
21
30
  userId?: string;
@@ -24,6 +33,7 @@ export type CMPInitOptions = Partial<{
24
33
  cookieDomain: string;
25
34
  formOfWordsId: string;
26
35
  useConsentStore: boolean;
36
+ spEventHandlers: [eventId: SPEventId, eventHandler: SPEventCallback][];
27
37
  }>;
28
38
 
29
39
  export interface ConsentPayloadOptions {
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS5D,wBAAsB,kBAAkB,CAAC,EACvC,cAA+B,EAC/B,MAAM,EACN,YAAmB,EACnB,gBAAwC,EACxC,YAA+B,EAC/B,aAAkC,EAClC,eAAsB,GACvB,GAAE,cAAmB,iBAiCrB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consent-ready/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA0B/E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,iBAI7C,MAAM,KAChB,MAAM,iBACM,MAAM,eACR;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,mBAoCrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/__fixtures__/strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,qPACiN,CAAC;AAErP;;GAEG;AACH,eAAO,MAAM,2BAA2B,qPAC4M,CAAC;AAErP,eAAO,MAAM,wBAAwB,obAC8Y,CAAC;AAEpb,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAC3C,eAAO,MAAM,kBAAkB,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-consent.test.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/__tests__/check-consent.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-parsed-consent.test.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/__tests__/get-parsed-consent.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validators.test.d.ts","sourceRoot":"","sources":["../../../../src/consent-ready/utils/__tests__/validators.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-consent-payload.d.ts","sourceRoot":"","sources":["../../../src/consent-ready/utils/get-consent-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAIhC;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,kBAAkB,EACjC,EAAE,wBAAwB,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,qBAAqB,CAAC;;;;;;;;;;;;EA6B1F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-parsed-consent.d.ts","sourceRoot":"","sources":["../../../src/consent-ready/utils/get-parsed-consent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAOrC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,GAAG,OAAO,CA8B5F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,kBAAkB,CAMrF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-consent-changed.d.ts","sourceRoot":"","sources":["../../../src/consent-ready/utils/has-consent-changed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAoBjE,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,kBAAkB,GAAG,OAAO,CAO5E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/consent-ready/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAU5D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAO5D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,IAAI,eAAe,CAsBxF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAIrE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cmp-footer-links.test.d.ts","sourceRoot":"","sources":["../../../src/html/__tests__/cmp-footer-links.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cmp-footer-link.d.ts","sourceRoot":"","sources":["../../src/html/cmp-footer-link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAa7C"}
@@ -1,16 +0,0 @@
1
- import type { SPConfig } from "../../typings/types";
2
- /**
3
- * Utility method to string-encode an object including functions
4
- */
5
- export declare function encodeConfig(obj: Record<string, string | object | null> | object | null): string;
6
- export declare function getSPConfig(config: SPConfig): string;
7
- export declare const scriptSources: {
8
- cmpFrames: string;
9
- };
10
- export declare const scriptContent: {
11
- getSPConfig: typeof getSPConfig;
12
- tcfStub: string;
13
- uspStub: string;
14
- };
15
- export declare function getCmpScripts(config: SPConfig): DocumentFragment;
16
- //# sourceMappingURL=cmp-scripts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cmp-scripts.d.ts","sourceRoot":"","sources":["../../src/html/cmp-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,UA2BvF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,UAE3C;AAED,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAIzB,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,oBAQ7C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1 +0,0 @@
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,CAyBjE,CAAC"}