@guardian/consent-management-platform
Advanced tools
Comparing version 3.0.4 to 3.1.0
@@ -1,24 +0,1 @@ | ||
import 'whatwg-fetch'; | ||
import React, { Component } from 'react'; | ||
import { GuPurposeList, FontsContextInterface, ParsedIabVendorList } from './types'; | ||
interface State { | ||
guPurposeList: GuPurposeList; | ||
parsedIabVendorList?: ParsedIabVendorList; | ||
mode: 'banner' | 'modal'; | ||
focusVendors: boolean; | ||
} | ||
interface Props { | ||
onClose: () => void; | ||
source?: string; | ||
variant?: string; | ||
fontFamilies?: FontsContextInterface; | ||
forceModal?: boolean; | ||
} | ||
declare class ConsentManagementPlatform extends Component<Props, State> { | ||
constructor(props: Props); | ||
componentDidMount(): void; | ||
render(): React.ReactNode; | ||
private saveAndCloseClick; | ||
private enableAllAndClose; | ||
} | ||
export { ConsentManagementPlatform }; | ||
export { ConsentManagementPlatform } from './tcf/component/ConsentManagementPlatform'; |
@@ -1,3 +0,11 @@ | ||
export { onGuConsentNotification, onIabConsentNotification } from './core'; | ||
export { setErrorHandler } from './error'; | ||
export { shouldShow } from './cmp-ui'; | ||
import { CcpaPurposeCallback } from './ccpa/core'; | ||
import { IabPurposeCallback as TcfPurposeCallback } from './tcf/core'; | ||
declare type IabPurposeCallback = TcfPurposeCallback | CcpaPurposeCallback; | ||
interface InitOptions { | ||
useCcpa: boolean; | ||
} | ||
export declare const init: (options?: InitOptions) => void; | ||
export declare const onIabConsentNotification: (callback: IabPurposeCallback) => void; | ||
export { setErrorHandler } from './tcf/error'; | ||
export { shouldShow } from './tcf/cmp-ui'; | ||
export { onGuConsentNotification } from './tcf/core'; |
113
lib/index.js
@@ -5,6 +5,84 @@ 'use strict'; | ||
var store = require('./store-bfcf0722.js'); | ||
var store = require('./store-8db4ea43.js'); | ||
/* eslint-disable no-underscore-dangle */ | ||
// https://documentation.sourcepoint.com/web-implementation/sourcepoint-gdpr-and-tcf-v2-support-beta/gdpr-and-tcf-v2-setup-and-configuration#1-two-step-process-to-implement-the-gdpr-and-tcf-v2-code-snippet | ||
var accountId = 1257; | ||
var ccpaStubSrc = "(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) } })();"; | ||
var ccpaStub = document.createElement('script'); | ||
ccpaStub.id = 'sourcepoint-ccpa-stub'; | ||
ccpaStub.innerHTML = ccpaStubSrc; | ||
var ccpaLib = document.createElement('script'); | ||
ccpaLib.id = 'sourcepoint-ccpa-lib'; | ||
ccpaLib.src = 'https://ccpa.sp-prod.net/ccpa.js'; | ||
var init = function init(onCcpaReadyCallback) { | ||
document.head.appendChild(ccpaStub); // make sure nothing else on the page has accidentally | ||
// used the _sp_* name as well | ||
if (window._sp_ccpa) { | ||
throw new Error('Sourcepoint CCPA global (window._sp_ccpa) is already defined!'); | ||
} | ||
window._sp_ccpa = { | ||
config: { | ||
mmsDomain: 'https://message.sp-prod.net', | ||
ccpaOrigin: 'https://ccpa-service.sp-prod.net', | ||
accountId: accountId, | ||
getDnsMsgMms: true, | ||
alwaysDisplayDns: false, | ||
siteHref: window.location.host.indexOf('theguardian.com') !== -1 ? null : 'https://test.theguardian.com', | ||
events: { | ||
onConsentReady: function onConsentReady() { | ||
onCcpaReadyCallback(); | ||
} | ||
} | ||
} | ||
}; | ||
document.body.appendChild(ccpaLib); | ||
}; | ||
var ccpaCallbackList = []; | ||
var initialised = false; | ||
var _ccpaState = false; | ||
var init$1 = function init$1() { | ||
init(runCallbacksOnCcpaReady); | ||
updateCcpaState(); | ||
}; | ||
var onIabConsentNotification = function onIabConsentNotification(callback) { | ||
if (initialised) { | ||
callback(_ccpaState); | ||
} | ||
ccpaCallbackList.push(callback); | ||
}; | ||
var runCallbacksOnCcpaReady = function runCallbacksOnCcpaReady() { | ||
updateCcpaState(); | ||
}; | ||
var updateCcpaState = function updateCcpaState() { | ||
// eslint-disable-next-line no-underscore-dangle | ||
window.__uspapi('getUSPData', 1, function (uspData, success) { | ||
var _uspData$uspString; | ||
// The __uspapi request is asynchorous before it's | ||
// framework is inititalised and synchorous after. | ||
// Therefore we need to guarantee inititalised = true | ||
// only after first receiving the state. | ||
initialised = true; | ||
if (success && (uspData === null || uspData === void 0 ? void 0 : (_uspData$uspString = uspData.uspString) === null || _uspData$uspString === void 0 ? void 0 : _uspData$uspString.charAt(2)) === 'Y') { | ||
_ccpaState = true; | ||
} else { | ||
_ccpaState = false; | ||
} | ||
ccpaCallbackList.forEach(function (cb) { | ||
return cb(_ccpaState); | ||
}); | ||
}); | ||
}; | ||
var initialised$1 = false; | ||
var buildGuRegister = function buildGuRegister() { | ||
@@ -17,3 +95,3 @@ var purposes = store.GU_PURPOSE_LIST.purposes; | ||
return store._objectSpread2({}, register, store._defineProperty({}, purpose.eventId, [])); | ||
return store._objectSpread2(store._objectSpread2({}, register), {}, store._defineProperty({}, purpose.eventId, [])); | ||
}, {}); | ||
@@ -26,6 +104,6 @@ return purposeRegister; | ||
var init = function init() { | ||
if (!initialised) { | ||
var init$2 = function init() { | ||
if (!initialised$1) { | ||
store.registerStateChangeHandler(onStateChange); | ||
initialised = true; | ||
initialised$1 = true; | ||
} | ||
@@ -48,4 +126,4 @@ }; | ||
var onIabConsentNotification = function onIabConsentNotification(callback) { | ||
init(); | ||
var onIabConsentNotification$1 = function onIabConsentNotification(callback) { | ||
init$2(); | ||
@@ -60,3 +138,3 @@ var _getConsentState = store.getConsentState(), | ||
var onGuConsentNotification = function onGuConsentNotification(purposeName, callback) { | ||
init(); | ||
init$2(); | ||
@@ -81,5 +159,22 @@ var _getConsentState2 = store.getConsentState(), | ||
var defaultOptions = { | ||
useCcpa: false | ||
}; | ||
var ccpa = false; | ||
var init$3 = function init() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultOptions; | ||
if (options.useCcpa) { | ||
init$1(); | ||
ccpa = true; | ||
} | ||
}; | ||
var onIabConsentNotification$2 = function onIabConsentNotification$2(callback) { | ||
return ccpa ? onIabConsentNotification(callback) : onIabConsentNotification$1(callback); | ||
}; | ||
exports.setErrorHandler = store.setErrorHandler; | ||
exports.init = init$3; | ||
exports.onGuConsentNotification = onGuConsentNotification; | ||
exports.onIabConsentNotification = onIabConsentNotification; | ||
exports.onIabConsentNotification = onIabConsentNotification$2; | ||
exports.shouldShow = shouldShow; |
{ | ||
"name": "@guardian/consent-management-platform", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"description": "Library of useful utilities for managing consent state across *.theguardian.com", | ||
@@ -11,9 +11,10 @@ "main": "lib/index.js", | ||
"clean": "rm -rf lib/*", | ||
"declaration": "tsc --emitDeclarationOnly -d -m commonjs && mv ./lib/component/ConsentManagementPlatform.d.ts ./lib && sed -i '' 's/\\.\\././g' ./lib/ConsentManagementPlatform.d.ts && rm -rf ./lib/component", | ||
"declaration": "tsc --emitDeclarationOnly --project ./tsconfig.build.json", | ||
"fix": "yarn validate --fix", | ||
"lint": "eslint src/**/*.ts src/**/*.tsx", | ||
"lint": "eslint . --ext=js,ts,tsx", | ||
"prepublishOnly": "yarn build", | ||
"test": "jest --config jestconfig.json", | ||
"test": "jest", | ||
"tsc": "tsc --noEmit", | ||
"validate": "yarn tsc && yarn lint && yarn test" | ||
"validate": "yarn tsc && yarn lint && yarn test", | ||
"dev": "rollup --config dev/rollup.config.js --watch" | ||
}, | ||
@@ -33,11 +34,12 @@ "husky": { | ||
"dependencies": { | ||
"consent-string": "^1.5.1", | ||
"js-cookie": "^2.2.1", | ||
"whatwg-fetch": "^3.0.0" | ||
"consent-string": "1.5.2", | ||
"js-cookie": "2.2.1", | ||
"whatwg-fetch": "3.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@babel/runtime": "^7.2.0", | ||
"@emotion/core": "^10.0.21", | ||
"@guardian/src-button": "^0.16.1", | ||
"@guardian/src-foundations": "^0.16.1", | ||
"@guardian/src-svgs": "0.16.1", | ||
"@guardian/src-button": "^1.0.0", | ||
"@guardian/src-foundations": "^1.0.0", | ||
"@guardian/src-svgs": "^1.0.0", | ||
"emotion-theming": "^10.0.27", | ||
@@ -47,35 +49,42 @@ "react": "^16.10.2" | ||
"devDependencies": { | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/preset-react": "^7.6.3", | ||
"@babel/preset-typescript": "^7.6.0", | ||
"@emotion/babel-preset-css-prop": "^10.0.17", | ||
"@emotion/core": "^10.0.21", | ||
"@guardian/src-button": "^0.16.1", | ||
"@guardian/src-foundations": "^0.16.1", | ||
"@guardian/src-svgs": "0.16.1", | ||
"@types/jest": "^24.0.16", | ||
"@types/js-cookie": "^2.2.2", | ||
"@types/react": "^16.9.9", | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/preset-env": "^7.9.6", | ||
"@babel/preset-react": "^7.9.4", | ||
"@babel/preset-typescript": "^7.9.0", | ||
"@emotion/babel-preset-css-prop": "^10.0.27", | ||
"@emotion/core": "^10.0.28", | ||
"@guardian/src-button": "^1.0.1", | ||
"@guardian/src-foundations": "^1.0.1", | ||
"@guardian/src-svgs": "^1.0.1", | ||
"@rollup/plugin-html": "^0.2.0", | ||
"@types/jest": "^25.2.3", | ||
"@types/js-cookie": "^2.2.6", | ||
"@types/react": "^16.9.35", | ||
"@types/react-dom": "16.9.8", | ||
"@typescript-eslint/eslint-plugin": "^2.1.0", | ||
"@typescript-eslint/parser": "^1.13.0", | ||
"@typescript-eslint/parser": "^2.1.0", | ||
"emotion-theming": "^10.0.27", | ||
"eslint": "^6.3.0", | ||
"eslint-config-airbnb-typescript": "^4.0.1", | ||
"eslint-config-prettier": "^6.0.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jest": "^22.14.1", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-react": "^7.16.0", | ||
"husky": "^3.0.2", | ||
"jest": "^24.8.0", | ||
"prettier": "^1.18.2", | ||
"react": "^16.10.2", | ||
"rollup": "^1.24.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-typescript": "^7.2.1", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jest": "^23.13.1", | ||
"eslint-plugin-jsx-a11y": "6.2.3", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"eslint-plugin-react": "^7.20.0", | ||
"eslint-plugin-react-hooks": "2", | ||
"husky": "^4.2.5", | ||
"jest": "^26.0.1", | ||
"prettier": "^2.0.5", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"rollup": "^2.10.9", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-livereload": "1.3.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "~3.5.3" | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-serve": "^1.0.1", | ||
"typescript": "^3.9.3" | ||
}, | ||
@@ -82,0 +91,0 @@ "files": [ |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
268004
31
4318
10
40
39
+ Added@guardian/src-button@1.9.1(transitive)
+ Added@guardian/src-foundations@1.9.1(transitive)
+ Added@guardian/src-helpers@1.9.1(transitive)
+ Added@guardian/src-icons@1.9.1(transitive)
+ Added@guardian/src-svgs@1.9.1(transitive)
+ Addedwhatwg-fetch@3.0.0(transitive)
- Removed@guardian/src-button@0.16.1(transitive)
- Removed@guardian/src-foundations@0.16.1(transitive)
- Removed@guardian/src-helpers@0.16.1(transitive)
- Removed@guardian/src-svgs@0.16.1(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)
Updatedconsent-string@1.5.2
Updatedjs-cookie@2.2.1
Updatedwhatwg-fetch@3.0.0