@guardian/consent-management-platform
Advanced tools
Comparing version 0.0.0-beta-20240206103322 to 0.0.0-beta-20240206114722
@@ -0,3 +1,3 @@ | ||
import type { CountryCode } from '@guardian/libs'; | ||
import type { Framework } from './types'; | ||
import type { Country } from './types/countries'; | ||
export declare const getFramework: (countryCode: Country) => Framework; | ||
export declare const getFramework: (countryCode: CountryCode) => Framework; |
import { log, removeCookie, storage } from '@guardian/libs'; | ||
var version = "0.0.0-beta-20240206114722"; | ||
let currentFramework; | ||
@@ -175,3 +177,2 @@ const setCurrentFramework = (framework) => { | ||
const callBackQueue = []; | ||
const finalCallbackQueue = []; | ||
const awaitingUserInteractionInTCFv2 = (state) => state.tcfv2?.eventStatus === 'cmpuishown'; | ||
@@ -235,4 +236,3 @@ const invokeCallback = (callback, state) => { | ||
const invokeCallbacks = () => { | ||
const callbacksToInvoke = callBackQueue.concat(finalCallbackQueue); | ||
if (callbacksToInvoke.length === 0) | ||
if (callBackQueue.length === 0) | ||
return; | ||
@@ -242,13 +242,8 @@ void getConsentState().then((state) => { | ||
return; | ||
callbacksToInvoke.forEach((callback) => invokeCallback(callback, state)); | ||
callBackQueue.forEach((callback) => invokeCallback(callback, state)); | ||
}); | ||
}; | ||
const onConsentChange$1 = (callBack, final = false) => { | ||
const onConsentChange$1 = (callBack) => { | ||
const newCallback = { fn: callBack }; | ||
if (final) { | ||
finalCallbackQueue.push(newCallback); | ||
} | ||
else { | ||
callBackQueue.push(newCallback); | ||
} | ||
callBackQueue.push(newCallback); | ||
void getConsentState() | ||
@@ -283,4 +278,3 @@ .then((consentState) => { | ||
(n.d = function (t, e, r) { | ||
n.o(t, e) || | ||
Object.defineProperty(t, e, { enumerable: !0, get: r }); | ||
n.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: r }); | ||
}), | ||
@@ -297,4 +291,3 @@ (n.r = function (t) { | ||
if ((1 & e && (t = n(t)), 8 & e)) return t; | ||
if (4 & e && 'object' == typeof t && t && t.__esModule) | ||
return t; | ||
if (4 & e && 'object' == typeof t && t && t.__esModule) return t; | ||
var r = Object.create(null); | ||
@@ -324,6 +317,6 @@ if ( | ||
return t.default; | ||
} | ||
} | ||
: function () { | ||
return t; | ||
}; | ||
}; | ||
return n.d(e, 'a', e), e; | ||
@@ -352,5 +345,3 @@ }), | ||
t.exports = function (t) { | ||
return 'object' == typeof t | ||
? null !== t | ||
: 'function' == typeof t; | ||
return 'object' == typeof t ? null !== t : 'function' == typeof t; | ||
}; | ||
@@ -389,5 +380,3 @@ }, | ||
for ( | ||
var n = arguments.length, | ||
r = new Array(n), | ||
o = 0; | ||
var n = arguments.length, r = new Array(n), o = 0; | ||
o < n; | ||
@@ -402,5 +391,3 @@ o++ | ||
'boolean' == typeof r[3] && | ||
((t = r[3]), | ||
'function' == typeof r[2] && | ||
r[2]('set', !0)); | ||
((t = r[3]), 'function' == typeof r[2] && r[2]('set', !0)); | ||
else if ('ping' === r[0]) { | ||
@@ -443,6 +430,3 @@ var i = { | ||
e && (i = JSON.stringify(i)), | ||
t.source.postMessage( | ||
i, | ||
'*', | ||
); | ||
t.source.postMessage(i, '*'); | ||
}, | ||
@@ -492,3 +476,3 @@ o.parameter, | ||
return 'value' in n && (t[e] = n.value), t; | ||
}; | ||
}; | ||
}, | ||
@@ -558,15 +542,7 @@ function (t, e, n) { | ||
var n, o; | ||
if ( | ||
e && | ||
'function' == typeof (n = t.toString) && | ||
!r((o = n.call(t))) | ||
) | ||
if (e && 'function' == typeof (n = t.toString) && !r((o = n.call(t)))) | ||
return o; | ||
if ('function' == typeof (n = t.valueOf) && !r((o = n.call(t)))) | ||
return o; | ||
if ( | ||
!e && | ||
'function' == typeof (n = t.toString) && | ||
!r((o = n.call(t))) | ||
) | ||
if (!e && 'function' == typeof (n = t.toString) && !r((o = n.call(t)))) | ||
return o; | ||
@@ -896,3 +872,3 @@ throw TypeError("Can't convert object to primitive value"); | ||
onConsentChange$1((consentState) => { | ||
if (consentState.tcfv2 || consentState.ccpa || consentState.aus) { | ||
if (consentState.tcfv2 ?? consentState.ccpa ?? consentState.aus) { | ||
resolve(consentState); | ||
@@ -925,7 +901,3 @@ } | ||
ipsos: { | ||
cookies: [ | ||
'DM_SitId1073', | ||
'DM_SitId1073SecId5802', | ||
'DotMetrics.AmpCookie', | ||
], | ||
cookies: ['DM_SitId1073', 'DM_SitId1073SecId5802', 'DotMetrics.AmpCookie'], | ||
localStorage: [ | ||
@@ -1005,3 +977,4 @@ 'DotmetricsSiteData', | ||
if (!isServerSide) { | ||
window.guCmpHotFix ||= {}; | ||
if (typeof window.guCmpHotFix === 'undefined') | ||
window.guCmpHotFix = {}; | ||
} | ||
@@ -1018,7 +991,8 @@ let _willShowPrivacyMessage; | ||
if (window.guCmpHotFix.initialised) { | ||
if (window.guCmpHotFix.cmp?.version !== "0.0.0-beta-20240206103322") | ||
if (window.guCmpHotFix.cmp?.version !== version) { | ||
console.warn('Two different versions of the CMP are running:', [ | ||
"0.0.0-beta-20240206103322", | ||
version, | ||
window.guCmpHotFix.cmp?.version, | ||
]); | ||
} | ||
return; | ||
@@ -1059,3 +1033,3 @@ } | ||
showPrivacyManager, | ||
version: "0.0.0-beta-20240206103322", | ||
version: version, | ||
__isDisabled: isDisabled, | ||
@@ -1062,0 +1036,0 @@ __enable: enable, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var version = "0.0.0-beta-20240206114722"; | ||
let currentFramework; | ||
@@ -180,3 +182,2 @@ const setCurrentFramework = (framework) => { | ||
const callBackQueue = []; | ||
const finalCallbackQueue = []; | ||
const awaitingUserInteractionInTCFv2 = (state) => state.tcfv2?.eventStatus === 'cmpuishown'; | ||
@@ -240,4 +241,3 @@ const invokeCallback = (callback, state) => { | ||
const invokeCallbacks = () => { | ||
const callbacksToInvoke = callBackQueue.concat(finalCallbackQueue); | ||
if (callbacksToInvoke.length === 0) | ||
if (callBackQueue.length === 0) | ||
return; | ||
@@ -247,13 +247,8 @@ void getConsentState().then((state) => { | ||
return; | ||
callbacksToInvoke.forEach((callback) => invokeCallback(callback, state)); | ||
callBackQueue.forEach((callback) => invokeCallback(callback, state)); | ||
}); | ||
}; | ||
const onConsentChange$1 = (callBack, final = false) => { | ||
const onConsentChange$1 = (callBack) => { | ||
const newCallback = { fn: callBack }; | ||
if (final) { | ||
finalCallbackQueue.push(newCallback); | ||
} | ||
else { | ||
callBackQueue.push(newCallback); | ||
} | ||
callBackQueue.push(newCallback); | ||
void getConsentState() | ||
@@ -288,4 +283,3 @@ .then((consentState) => { | ||
(n.d = function (t, e, r) { | ||
n.o(t, e) || | ||
Object.defineProperty(t, e, { enumerable: !0, get: r }); | ||
n.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: r }); | ||
}), | ||
@@ -302,4 +296,3 @@ (n.r = function (t) { | ||
if ((1 & e && (t = n(t)), 8 & e)) return t; | ||
if (4 & e && 'object' == typeof t && t && t.__esModule) | ||
return t; | ||
if (4 & e && 'object' == typeof t && t && t.__esModule) return t; | ||
var r = Object.create(null); | ||
@@ -329,6 +322,6 @@ if ( | ||
return t.default; | ||
} | ||
} | ||
: function () { | ||
return t; | ||
}; | ||
}; | ||
return n.d(e, 'a', e), e; | ||
@@ -357,5 +350,3 @@ }), | ||
t.exports = function (t) { | ||
return 'object' == typeof t | ||
? null !== t | ||
: 'function' == typeof t; | ||
return 'object' == typeof t ? null !== t : 'function' == typeof t; | ||
}; | ||
@@ -394,5 +385,3 @@ }, | ||
for ( | ||
var n = arguments.length, | ||
r = new Array(n), | ||
o = 0; | ||
var n = arguments.length, r = new Array(n), o = 0; | ||
o < n; | ||
@@ -407,5 +396,3 @@ o++ | ||
'boolean' == typeof r[3] && | ||
((t = r[3]), | ||
'function' == typeof r[2] && | ||
r[2]('set', !0)); | ||
((t = r[3]), 'function' == typeof r[2] && r[2]('set', !0)); | ||
else if ('ping' === r[0]) { | ||
@@ -448,6 +435,3 @@ var i = { | ||
e && (i = JSON.stringify(i)), | ||
t.source.postMessage( | ||
i, | ||
'*', | ||
); | ||
t.source.postMessage(i, '*'); | ||
}, | ||
@@ -497,3 +481,3 @@ o.parameter, | ||
return 'value' in n && (t[e] = n.value), t; | ||
}; | ||
}; | ||
}, | ||
@@ -563,15 +547,7 @@ function (t, e, n) { | ||
var n, o; | ||
if ( | ||
e && | ||
'function' == typeof (n = t.toString) && | ||
!r((o = n.call(t))) | ||
) | ||
if (e && 'function' == typeof (n = t.toString) && !r((o = n.call(t)))) | ||
return o; | ||
if ('function' == typeof (n = t.valueOf) && !r((o = n.call(t)))) | ||
return o; | ||
if ( | ||
!e && | ||
'function' == typeof (n = t.toString) && | ||
!r((o = n.call(t))) | ||
) | ||
if (!e && 'function' == typeof (n = t.toString) && !r((o = n.call(t)))) | ||
return o; | ||
@@ -901,3 +877,3 @@ throw TypeError("Can't convert object to primitive value"); | ||
onConsentChange$1((consentState) => { | ||
if (consentState.tcfv2 || consentState.ccpa || consentState.aus) { | ||
if (consentState.tcfv2 ?? consentState.ccpa ?? consentState.aus) { | ||
resolve(consentState); | ||
@@ -930,7 +906,3 @@ } | ||
ipsos: { | ||
cookies: [ | ||
'DM_SitId1073', | ||
'DM_SitId1073SecId5802', | ||
'DotMetrics.AmpCookie', | ||
], | ||
cookies: ['DM_SitId1073', 'DM_SitId1073SecId5802', 'DotMetrics.AmpCookie'], | ||
localStorage: [ | ||
@@ -1010,3 +982,4 @@ 'DotmetricsSiteData', | ||
if (!isServerSide) { | ||
window.guCmpHotFix ||= {}; | ||
if (typeof window.guCmpHotFix === 'undefined') | ||
window.guCmpHotFix = {}; | ||
} | ||
@@ -1023,7 +996,8 @@ let _willShowPrivacyMessage; | ||
if (window.guCmpHotFix.initialised) { | ||
if (window.guCmpHotFix.cmp?.version !== "0.0.0-beta-20240206103322") | ||
if (window.guCmpHotFix.cmp?.version !== version) { | ||
console.warn('Two different versions of the CMP are running:', [ | ||
"0.0.0-beta-20240206103322", | ||
version, | ||
window.guCmpHotFix.cmp?.version, | ||
]); | ||
} | ||
return; | ||
@@ -1064,3 +1038,3 @@ } | ||
showPrivacyManager, | ||
version: "0.0.0-beta-20240206103322", | ||
version: version, | ||
__isDisabled: isDisabled, | ||
@@ -1067,0 +1041,0 @@ __enable: enable, |
@@ -5,3 +5,3 @@ import type { onConsent as OnConsent } from './onConsent'; | ||
export declare const serverSideWarn: () => void; | ||
export declare const serverSideWarnAndReturn: <T extends unknown>(arg: T) => () => T; | ||
export declare const serverSideWarnAndReturn: <T>(arg: T) => () => T; | ||
export declare const cmp: CMP; | ||
@@ -8,0 +8,0 @@ export declare const onConsent: () => ReturnType<typeof OnConsent>; |
@@ -0,5 +1,5 @@ | ||
import type { CountryCode } from '@guardian/libs'; | ||
import type { VendorName } from '../vendors'; | ||
import type { AUSConsentState } from './aus'; | ||
import type { CCPAConsentState } from './ccpa'; | ||
import type { Country } from './countries'; | ||
import type { TCFv2ConsentState } from './tcfv2'; | ||
@@ -20,5 +20,5 @@ export type Framework = 'tcfv2' | 'ccpa' | 'aus'; | ||
pubData?: PubData; | ||
country?: Country; | ||
country?: CountryCode; | ||
}) => void; | ||
export type OnConsentChange = (fn: Callback, final?: boolean) => void; | ||
export type OnConsentChange = (fn: Callback) => void; | ||
export type GetConsentFor = (vendor: VendorName, consent: ConsentState) => boolean; | ||
@@ -25,0 +25,0 @@ export interface ConsentState { |
@@ -1,4 +0,2 @@ | ||
type VendorIDType = { | ||
[key: string]: string[]; | ||
}; | ||
type VendorIDType = Record<string, string[]>; | ||
export declare const TCFV2VendorIDs: VendorIDType; | ||
@@ -5,0 +3,0 @@ export declare const AusVendorIDs: VendorIDType; |
{ | ||
"name": "@guardian/consent-management-platform", | ||
"version": "0.0.0-beta-20240206103322", | ||
"version": "0.0.0-beta-20240206114722", | ||
"description": "Consent management for *.theguardian.com.", | ||
@@ -86,2 +86,3 @@ "homepage": "https://github.com/guardian/consent-management-platform.git", | ||
"rollup-plugin-svelte": "^7.1.6", | ||
"@rollup/plugin-json": "^6.1.0", | ||
"serve": "^14.2.1", | ||
@@ -88,0 +89,0 @@ "start-server-and-test": "~2.0.3", |
@@ -26,3 +26,3 @@ # Consent Management Platform | ||
- [Using Consent](#using-consent) | ||
* [`onConsentChange(callback, final?)`](#onconsentchangecallback-final) | ||
* [`onConsentChange(callback)`](#onconsentchangecallback) | ||
* [`onConsent()`](#onconsent) | ||
@@ -176,3 +176,3 @@ * [`getConsentFor(vendor, consentState)`](#getconsentforvendor-consentstate) | ||
### `onConsentChange(callback, final?)` | ||
### `onConsentChange(callback)` | ||
@@ -189,7 +189,2 @@ returns: `void` | ||
Passing `true` for the optional `final` parameter guarantees that the callback | ||
will be executed after all other callbacks that haven't been registered with the flag when consent state changes. | ||
If more than one callback registered with `final = true`, they will be executed in the order in which they were registered | ||
when consent changes. | ||
#### `callback(consentState)` | ||
@@ -196,0 +191,0 @@ |
95876
51
56
2260
439