diff --git a/package-lock.json b/package-lock.json index 792a8127..4240a430 100644 --- a/package-lock.json +++ b/package-lock.json @@ -190,14 +190,18 @@ } }, "@iabtcf/cmpapi": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@iabtcf/cmpapi/-/cmpapi-1.0.1.tgz", - "integrity": "sha512-VhJBOqvdgAyiFaNuRp0Kzc3/yGo2pM4QUJ0I6L/2VfT/CP7Q3Mkeg4Q2sLIlj/eDsrHavpKoi/aXyY/3Q8zd0w==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@iabtcf/cmpapi/-/cmpapi-1.1.4.tgz", + "integrity": "sha512-knwTKljpUsnas0g71JP2IyKDzfiWR5O8VkXErdN88gS06ETO5o8F7wFEVr6y0DE4z0z2UrDIy+m+8vDaEYDang==" }, "@iabtcf/core": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@iabtcf/core/-/core-1.0.1.tgz", - "integrity": "sha512-LQg9+QYlRGumWCRpF/UxDCFHsRBNuzDQcCeUDSxdDDbjIffrAVQEp/wAdPeXxmO3T7ArCKWydRenHtxJEYhpgQ==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@iabtcf/core/-/core-1.1.4.tgz", + "integrity": "sha512-Q0xy1W2JaKUpb/lYu3792UrdZZSmotsnwGEc6+k44PtURtO/JNFqXiMFA28CEpVb5t2fKwYGgxhH/RXImEzPhA==", + "requires": { + "global": "^4.4.0", + "typescript": "3.7" + } }, "@sinonjs/commons": { "version": "1.8.1", @@ -4119,6 +4123,11 @@ } } }, + "dom-walk": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", + "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==" + }, "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", @@ -5363,6 +5372,15 @@ "is-glob": "^2.0.0" } }, + "global": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", + "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "requires": { + "min-document": "^2.19.0", + "process": "^0.11.10" + } + }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", @@ -8076,6 +8094,14 @@ "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", "dev": true }, + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "requires": { + "dom-walk": "^0.1.0" + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -11493,8 +11519,7 @@ "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" }, "process-nextick-args": { "version": "2.0.1", @@ -13957,6 +13982,11 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "3.7.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz", + "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==" + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", diff --git a/package.json b/package.json index 7b925981..1537a9f6 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,8 @@ "webpack-dev-server": "^2.4.4" }, "dependencies": { - "@iabtcf/cmpapi": "^1.0.1-4", - "@iabtcf/core": "^1.0.1-4", + "@iabtcf/cmpapi": "^1.1.4", + "@iabtcf/core": "^1.1.4", "classnames": "^2.2.5", "codemirror": "^5.34.0", "core-js": "^2.5.3", diff --git a/src/docs/components/docs/cmpApi.jsx b/src/docs/components/docs/cmpApi.jsx index 8b9078ae..601d7597 100644 --- a/src/docs/components/docs/cmpApi.jsx +++ b/src/docs/components/docs/cmpApi.jsx @@ -28,17 +28,6 @@ const commands = [ resultDescription: 'Object containing consent data for vendor IDs requested' } }, - { - command: 'getConsentFieldsV1', - parameters: [{ - type: 'parameter (Object)', - description: 'Object that contains established consents' - }], - callback: { - resultType: 'result (Object, Boolean)', - resultDescription: 'Object containing consent data in TCF v1.1 format' - } - }, { command: 'getVendorList', parameters: [{ diff --git a/src/docs/components/nav/nav.jsx b/src/docs/components/nav/nav.jsx index 7a9b0bfc..eff0f67b 100644 --- a/src/docs/components/nav/nav.jsx +++ b/src/docs/components/nav/nav.jsx @@ -9,26 +9,20 @@ import EventListeners from '../examples/basic/eventListeners'; import CustomEventListeners from '../examples/basic/customEventListeners'; import ConsentData from '../examples/basic/consentData'; import ShowConsent from '../examples/basic/showConsent'; -import IFrame from '../examples/iframe'; import VendorList from '../examples/basic/vendorList'; import RequireConsent from '../examples/advanced/requireConsent'; import InspectVendorConsent from '../examples/advanced/inspectVendorConsent'; import AdAfterConsent from '../examples/advanced/adAfterConsent'; -import VendorCookieEncoder from '../tools/vendorCookieEncoder'; -import PublisherCookieEncoder from '../tools/publisherCookieEncoder'; -import VendorCookieDecoder from '../tools/vendorCookieDecoder'; -import PublisherCookieDecoder from '../tools/publisherCookieDecoder'; -import VendorListBuilder from '../tools/vendorListBuilder/vendorListBuilder'; import Intro from '../intro/intro'; import Configration from '../docs/configuration'; import QuickStart from '../docs/quickstart'; -import IabToolRedirect from '../tools/iabToolRedirect' +import IabToolRedirect from '../tools/iabToolRedirect'; export const navItems = [ { title: 'Intro', items: [ - { to: '/', title: 'Introduction To GDPR', component: Intro }, + { to: '/', title: 'Introduction To GDPR', component: Intro } ] }, { @@ -37,18 +31,18 @@ export const navItems = [ { to: '/quickstart', title: 'Quick Start', component: QuickStart }, { to: '/setup', title: 'Setup Script', component: Setup }, { to: '/config', title: 'Configuration', component: Configration }, - { to: '/cmp-api', title: 'CMP API', component: CmpApi }, + { to: '/cmp-api', title: 'CMP API', component: CmpApi } ] }, { title: 'Basic Examples', items: [ - { to: '/basic/ping', title: 'Ping', component: Ping}, - { to: '/basic/show', title: 'Show Consent Tool', component: ShowConsent}, - { to: '/basic/events', title: 'Event Listeners', component: EventListeners}, - { to: '/basic/custom-events', title: 'Custom Event Listeners', component: CustomEventListeners}, + { to: '/basic/ping', title: 'Ping', component: Ping }, + { to: '/basic/show', title: 'Show Consent Tool', component: ShowConsent }, + { to: '/basic/events', title: 'Event Listeners', component: EventListeners }, + { to: '/basic/custom-events', title: 'Custom Event Listeners', component: CustomEventListeners }, { to: '/basic/data', title: 'Get Consent Data', component: ConsentData }, - { to: '/basic/list', title: 'Get Vendor List', component: VendorList }, + { to: '/basic/list', title: 'Get Vendor List', component: VendorList } ] }, // { @@ -64,28 +58,29 @@ export const navItems = [ title: 'Advanced Examples', items: [ { to: '/advanced/require-consent', title: 'Require Consent', component: RequireConsent }, - { to: '/advanced/inspect-vendor-consent', title: 'Inspect Vendor Consent', component: InspectVendorConsent }, - { to: '/advanced/ad-after-consent', title: 'Load Ad After Consent', component: AdAfterConsent }, + { + to: '/advanced/inspect-vendor-consent', + title: 'Inspect Vendor Consent', + component: InspectVendorConsent + }, + { to: '/advanced/ad-after-consent', title: 'Load Ad After Consent', component: AdAfterConsent } ] }, { title: 'Tools (TCF v2.0)', items: [ - {to: '/tools/v2/encode', title: 'Encode Consent Cookie ', component: () => }, - {to: '/tools/v2/decode', title: 'Decode Consent Cookie ', component: () => }, + { + to: '/tools/v2/encode', + title: 'Encode Consent Cookie ', + component: () => + }, + { + to: '/tools/v2/decode', + title: 'Decode Consent Cookie ', + component: () => + } ] - }, - { - title: 'Tools (TCF v1.1)', - items: [ - {to: '/tools/vendor-list-builder', title: 'Vendor List Builder', component: VendorListBuilder}, - {to: '/tools/vendor-cookie-encoder', title: 'Encode Vendor Cookie', component: VendorCookieEncoder}, - {to: '/tools/vendor-cookie-decoder', title: 'Decode Vendor Cookie', component: VendorCookieDecoder}, - {to: '/tools/publisher-cookie-encoder', title: 'Encode Publisher Cookie', component: PublisherCookieEncoder}, - {to: '/tools/publisher-cookie-decoder', title: 'Decode Publisher Cookie', component: PublisherCookieDecoder} - ] - } -]; + }]; export default class Nav extends Component { @@ -93,11 +88,11 @@ export default class Nav extends Component { this.props.toggleMenu(false); }; - render(props) { - const {menuExpanded, toggleMenu} = props; + render (props) { + const { menuExpanded, toggleMenu } = props; return ( -
+
Menu
@@ -108,7 +103,8 @@ export default class Nav extends Component { {group.title} {group.items.map(({ to, title, external }) => ( external ? ({title}) : - ({title}) + ({title}) ))}
))} diff --git a/src/docs/components/tools/cookieDecoder.jsx b/src/docs/components/tools/cookieDecoder.jsx deleted file mode 100644 index a70a410a..00000000 --- a/src/docs/components/tools/cookieDecoder.jsx +++ /dev/null @@ -1,85 +0,0 @@ -import { h, Component } from 'preact'; -import style from './coder.less'; -import { Controlled as CodeMirror } from 'react-codemirror2'; - -import { - decodeCookieValue, - decodeCookieBitValue -} from '../../../lib/cookie/cookieDecodeHelpers'; - -export default class CookieDecoder extends Component { - constructor(props) { - super(props); - this.state = { - bitString: '', - b64: '' - }; - } - - decodeB64 = (e) => { - const input = e.target.value; - this.setState({ - b64: input, - decodedB64: decodeCookieValue(input, this.props.versionMap) - }); - }; - - decodeBits = (e) => { - const input = e.target.value; - this.setState({ - bitString: input, - decodedBits: decodeCookieBitValue(input, this.props.versionMap) - }); - }; - - render(props, state) { - const {title} = props; - const { bitString, b64, decodedBits, decodedB64 } = state; - - return ( -
- {title} Binary Cookie Value - - {bitString && - - } - - {title} Base64 Cookie Value - - {b64 && - - } -
- ); - } -} diff --git a/src/docs/components/tools/cookieEncoder.jsx b/src/docs/components/tools/cookieEncoder.jsx deleted file mode 100644 index 86b3c366..00000000 --- a/src/docs/components/tools/cookieEncoder.jsx +++ /dev/null @@ -1,257 +0,0 @@ -import { h, Component } from 'preact'; -import * as _ from 'lodash'; -import classnames from 'classnames'; -import style from './coder.less'; -import Checkbox from '../checkbox/checkbox'; -import { - encodeField, - encodeDataToBits, - encodeCookieValue -} from '../../../lib/cookie/cookieEncodeHelpers'; - - -export default class CookieEncoder extends Component { - constructor(props) { - super(props); - - this.state = { - selectedCookieVersion: 1 - }; - this.initVersion(); - } - - initVersion = () => { - const { versionMap } = this.props; - const { selectedCookieVersion } = this.state; - const fieldDefinitions = versionMap[selectedCookieVersion].fields; - - // Add some default values - const decodedObject = {}; - fieldDefinitions.map(field => this.setDefaultValues(decodedObject, field)); - - this.setState({ decodedObject }); - }; - - setDefaultValues = (decodedObject, { name, type, fields }) => { - switch (type) { - case 'bool': - decodedObject[name] = false; - break; - case 'int': - decodedObject[name] = 1; - break; - case 'date': - decodedObject[name] = new Date(); - break; - case 'list': - decodedObject[name] = []; - fields.map(listField => this.setDefaultValues(decodedObject[name], listField)); - break; - } - }; - - handleInputChanged = (field, objectPath) => { - return (e) => { - const { name, type } = field; - const text = e.target.value; - const decodedObject = { - ...this.state.decodedObject - }; - const propertyPath = _.filter([objectPath, name]).join('.'); - _.set(decodedObject, propertyPath, _.get(decodedObject, propertyPath, '')); - - switch (type) { - case 'bool': { - _.set(decodedObject, propertyPath, e.target.checked); - break; - } - case 'int': { - const parsedInt = parseInt(text, 10); - if (!isNaN(parsedInt)) { - _.set(decodedObject, propertyPath, parsedInt); - } - break; - } - case 'date': { - const parsedDate = new Date(text); - if (parsedDate) { - _.set(decodedObject, propertyPath, parsedDate); - } - break; - } - case 'bits': { - if (text.match(/^[01]+$/)) { - _.set(decodedObject, propertyPath, text); - } - break; - } - case '6bitchar': { - if (text.match(/[A-z]*/)) { - _.set(decodedObject, propertyPath, text); - } - break; - } - } - - this.setState({ - decodedObject - }); - }; - }; - - handleCookieVersionChange = (field) => { - return (event) => { - const cookieVersion = event.target.value; - this.setState({ - selectedCookieVersion: cookieVersion, - }); - this.initVersion(); - this.handleInputChanged(field)(event); - }; - }; - - lookupFieldObject = (field, objectPath) => { - const { decodedObject } = this.state; - let fieldObject = decodedObject; - if (!_.isNil(objectPath)) { - fieldObject = _.get(decodedObject, objectPath); - if (_.isNil(fieldObject)) { - fieldObject = {}; - _.set(decodedObject, objectPath, fieldObject); - } - } - return fieldObject; - }; - - renderInput = (field, objectPath) => { - const {versionMap} = this.props; - const { name, type, validator } = field; - const { decodedObject } = this.state; - const propertyPath = _.filter([objectPath, name]).join('.'); - const fieldObject = this.lookupFieldObject(field, objectPath); - const isDisabled = validator && !validator(fieldObject); - - // Special case for 'cookieVersion' which needs to be of a defined version - if (name === 'cookieVersion') { - return ( - - ); - } - - // Render generic fields as correct inputs - switch (type) { - case 'bool': - return ; - case '6bitchar': - case 'int': - case 'bits': - return ; - case 'date': - return ; - default: - return ''; - } - }; - - getBitCount = ({ numBits }) => { - const { decodedObject } = this.state; - if (typeof numBits === 'function') { - return numBits(decodedObject); - } - if (typeof numBits === 'number') { - return numBits; - } - return '(variable)'; - }; - - renderInputRow = (field, objectPath) => { - const { name, type, validator } = field; - const fieldObject = this.lookupFieldObject(field, objectPath); - const isDisabled = validator && !validator(fieldObject); - const indent = (objectPath || '').split('.').length * 15; - - return ( - - {name} - {type} - {this.getBitCount(field)} - {this.renderInput(field, objectPath)} - {type !== 'list' ? encodeField({ - input: fieldObject, - field - }) : ''} - - ); - }; - - renderFieldInputs = (fields, objectPath) => { - return ( - - - - - - - - - - - - {fields.reduce((rows, field) => { - const fieldObject = this.lookupFieldObject(field, objectPath); - rows.push(this.renderInputRow(field, objectPath)); - if (field.type === 'list') { - const { name, listCount, validator } = field; - if (!validator || validator(fieldObject)) { - const listEntryCount = typeof listCount === 'function' ? - listCount(fieldObject) : typeof listCount === 'number' ? listCount : 0; - - for (let i = 0; i < listEntryCount; i++) { - _.forEach(field.fields, f => { - rows.push(this.renderInputRow(f, _.filter([objectPath, name, `[${i}]`]).join('.'))); - }); - } - } - } - return rows; - }, [])} - -
FieldTypeNumber BitsValueBinary
- ); - }; - - render(props, state) { - const { title, versionMap } = props; - const { decodedObject, selectedCookieVersion } = state; - const fieldDefinitions = versionMap[selectedCookieVersion].fields; - const bitString = encodeDataToBits(decodedObject, versionMap); - const b64String = encodeCookieValue(decodedObject, versionMap); - - return ( -
- {title} - {this.renderFieldInputs(fieldDefinitions)} - Binary Cookie Value -
{bitString}
- Base64 Encoded Cookie Value -
{b64String}
-
- ); - } -} diff --git a/src/docs/components/tools/publisherCookieDecoder.jsx b/src/docs/components/tools/publisherCookieDecoder.jsx deleted file mode 100644 index 51f5177b..00000000 --- a/src/docs/components/tools/publisherCookieDecoder.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import { h, Component } from 'preact'; -import CookieDecoder from './cookieDecoder'; - -import { - publisherVersionMap, -} from '../../../lib/cookie/definitions'; - -export default class PublisherCookieDecoder extends Component { - - render() { - - return ( - - ); - } -} diff --git a/src/docs/components/tools/publisherCookieEncoder.jsx b/src/docs/components/tools/publisherCookieEncoder.jsx deleted file mode 100644 index 3bd72f31..00000000 --- a/src/docs/components/tools/publisherCookieEncoder.jsx +++ /dev/null @@ -1,19 +0,0 @@ -import { h, Component } from 'preact'; - -import { - publisherVersionMap, -} from '../../../lib/cookie/definitions'; -import CookieEncoder from './cookieEncoder'; - - -export default class PublisherCookieEncoder extends Component { - - render() { - - return ( - - ); - } -} diff --git a/src/docs/components/tools/vendorCookieDecoder.jsx b/src/docs/components/tools/vendorCookieDecoder.jsx deleted file mode 100644 index 7f0b1f0d..00000000 --- a/src/docs/components/tools/vendorCookieDecoder.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import { h, Component } from 'preact'; -import CookieDecoder from './cookieDecoder'; - -import { - vendorVersionMap, -} from '../../../lib/cookie/definitions'; - -export default class VendorCookieDecoder extends Component { - - render() { - - return ( - - ); - } -} diff --git a/src/docs/components/tools/vendorCookieEncoder.jsx b/src/docs/components/tools/vendorCookieEncoder.jsx deleted file mode 100644 index 186e7daf..00000000 --- a/src/docs/components/tools/vendorCookieEncoder.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import { h, Component } from 'preact'; - -import { - vendorVersionMap, -} from '../../../lib/cookie/definitions'; -import CookieEncoder from './cookieEncoder'; - - -export default class VendorCookieEncoder extends Component { - - render() { - return ( - - ); - } -} diff --git a/src/docs/components/tools/vendorListBuilder/vendorListBuilder.jsx b/src/docs/components/tools/vendorListBuilder/vendorListBuilder.jsx deleted file mode 100644 index 08af034c..00000000 --- a/src/docs/components/tools/vendorListBuilder/vendorListBuilder.jsx +++ /dev/null @@ -1,224 +0,0 @@ -import { h, Component } from 'preact'; -import style from './vendorListBuilder.less'; -import Switch from '../../../../components/switch/switch'; - -const PRIMARY_COLOR = '#2abbb0'; -const GLOBAL_LIST_LOCATION = 'https://vendorlist.consensu.org/vendorlist.json'; - -export default class VendorListBuilder extends Component { - constructor(props) { - super(props); - this.state = { - isLoading: true, - isError: false - }; - } - - fetchGlobalVendorList = () => { - fetch(GLOBAL_LIST_LOCATION) - .then(res => res.json()) - .then(list => { - const {vendorListVersion, lastUpdated, vendors, purposes} = list; - this.setState({ - vendorList: list, - vendorListVersion, - lastUpdated, - vendors, - purposes, - selectedPurposeIds: new Set(purposes.map(({id}) => id)), - selectedVendorIds: new Set(vendors.map(({id}) => id)), - isLoading: false, - isError: false - }); - }) - .catch(() => { - this.setState({ - isLoading: false, - isError: true - }); - }); - }; - - handleSelectPurpose = id => { - return event => { - const {selectedPurposeIds} = this.state; - if (selectedPurposeIds.has(id)) { - selectedPurposeIds.delete(id); - } - else { - selectedPurposeIds.add(id); - } - this.setState({selectedPurposeIds}); - }; - }; - handleSelectAllPurposes = all => { - return event => { - const {purposes} = this.state; - if (all) { - this.setState({selectedPurposeIds: new Set(purposes.map(({id}) => id))}); - } - else { - this.setState({selectedPurposeIds: new Set()}); - } - }; - }; - - handleSelectVendor = id => { - return event => { - const {selectedVendorIds} = this.state; - if (selectedVendorIds.has(id)) { - selectedVendorIds.delete(id); - } - else { - selectedVendorIds.add(id); - } - this.setState({selectedVendorIds}); - }; - }; - handleSelectAllVendors = all => { - return event => { - const {vendors} = this.state; - if (all) { - this.setState({selectedVendorIds: new Set(vendors.map(({id}) => id))}); - } - else { - this.setState({selectedVendorIds: new Set()}); - } - }; - }; - - generateList = () => { - const { - vendorList, - vendorListVersion, - purposes, - vendors, - selectedPurposeIds, - selectedVendorIds - } = this.state; - - const json = JSON.stringify(Object.assign({}, vendorList, { - version, - purposes: purposes.filter(({id}) => selectedPurposeIds.has(id)), - vendors: vendors.filter(({id}) => selectedVendorIds.has(id)) - }), null, 2); - - const dataUrl = `data:text/csv;charset=utf-8,${encodeURIComponent(json)}`; - - const downloadLink = document.createElement('a'); - downloadLink.download = 'vendorlist.json'; - downloadLink.href = dataUrl; - downloadLink.click(); - }; - - componentWillMount() { - this.fetchGlobalVendorList(); - } - - render(props, state) { - - const { - isLoading, - isError, - vendorListVersion, - lastUpdated, - purposes, - vendors, - selectedPurposeIds, - selectedVendorIds - } = state; - - return ( -
- {isLoading ? -
- Loading Global Vendor List... -
: -
- {isError ? -
- Failed loading the global vendor list from: {GLOBAL_LIST_LOCATION} -
: -
-
-
- Vendor List Version: - {vendorListVersion} -
-
- Last Updated: - {lastUpdated} -
-
- -
-
-
- Purposes: - - - - - - - - - - {purposes.map(({id, name}) => ( - - - - - - ))} - -
IDName - All / None -
{id}{name} - -
-
-
- Vendors: - - - - - - - - - - {vendors.map(({id, name}) => ( - - - - - - ))} - -
IDName - All / None -
{id}{name} - -
-
-
- -
-
- } -
- } -
- ); - } -} diff --git a/src/docs/components/tools/vendorListBuilder/vendorListBuilder.less b/src/docs/components/tools/vendorListBuilder/vendorListBuilder.less deleted file mode 100644 index 2b66bff2..00000000 --- a/src/docs/components/tools/vendorListBuilder/vendorListBuilder.less +++ /dev/null @@ -1,53 +0,0 @@ -@import '../../../style/variables'; - -.vendorListBuilder { - width: 100%; - - a { - cursor: pointer; - } - .field { - font-weight: bold; - padding: 10px 5px 10px 0; - } - - .generate { - display: flex; - justify-content: flex-end; - flex: 1; - } - .controls { - display: flex; - } - .version { - padding-right: 20px; - } - .purposes, .vendors { - padding-bottom: 20px; - table { - width: 100%; - border-collapse: collapse; - - thead tr { - background: @color-background-gray; - th { - white-space: nowrap; - text-align: left; - } - } - tr { - border: 1px solid @color-background-gray; - } - td, th { - padding: 10px; - vertical-align: top; - } - - .include { - width: 100px; - color: @color-primary; - text-align: center; - } - } - } -} diff --git a/src/lib/commands.js b/src/lib/commands.js index c63fd2dd..f4ed7196 100644 --- a/src/lib/commands.js +++ b/src/lib/commands.js @@ -1,7 +1,6 @@ import { TCModel, GVL } from "@iabtcf/core"; import config from "./config"; import { - encodeVendorConsentData, encodeConsentData } from "./cookie/cookie"; import { @@ -14,8 +13,6 @@ import { SECTION_VENDORS } from "./store"; -const arrayFrom = require('core-js/library/fn/array/from'); - const createCommands = (store, cmpManager) => { /** * Converts vector to consent object @@ -30,109 +27,6 @@ const createCommands = (store, cmpManager) => { return obj; }; - /** - * Build consent fields object v1 from data that has already been persisted. - */ - const getConsentFieldsObject = () => { - let created, lastUpdated; - - const { - persistedConsentData, - persistedConsentString - } = store; - - const { - cmpId = store.tcModel.cmpId, - cmpVersion = store.tcModel.cmpVersion, - consentScreen = store.tcModel.consentScreen, - } = persistedConsentData; - - if (persistedConsentString) { - created = persistedConsentData.created; - lastUpdated = persistedConsentData.lastUpdated; - } - const consentLanguage = 'PL'; - return { - cmpId, - cmpVersion, - consentLanguage, - consentScreen, - created, - lastUpdated, - }; - }; - - const generateConsentStringV1 = (data = {}, callback) => { - const { - persistedConsentData, - } = store; - - const { - created, - lastUpdated, - consentScreen, - cmpVersion, - cmpId = CMP_ID - } = persistedConsentData; - - const { - selectedVendorIds = [], - selectedPurposeIds = [], - maxVendorId, - vendorListVersion, - cookieVersion - } = data; - - const consentLanguage = 'PL'; - const consentData = { - cmpId, - maxVendorId, - cookieVersion, - cmpVersion, - vendorListVersion, - created, - lastUpdated, - consentLanguage, - consentScreen, - selectedVendorIds: new Set(arrayFrom(selectedVendorIds)), - selectedPurposeIds: new Set(arrayFrom(selectedPurposeIds)) - }; - - const valid = (data = {}) => [ - 'cmpId', 'cmpVersion', 'consentLanguage', 'consentScreen', 'cookieVersion', 'created', 'lastUpdated', - 'maxVendorId', 'selectedPurposeIds', 'selectedVendorIds', 'vendorListVersion' - ].every(prop => data.hasOwnProperty(prop)); - - callback(valid(consentData) ? encodeVendorConsentData(consentData) : undefined); - }; - - /** - * Generates v1.1 compatible TC String - */ - const getConsentFieldsV1 = (callback, params) => { - if (!params || !params.hasOwnProperty('cookieVersion') || !params.hasOwnProperty('vendorListVersion')) { - return callback ({}, false); - } - - const data = getConsentFieldsObject(); - - generateConsentStringV1({ - ...data, - ...params - }, (metadata) => { - const consent = { - metadata, - gdprApplies: config.gdprApplies, - hasGlobalScope: config.storeConsentGlobally, - ...data, - cookieVersion: params.cookieVersion, - vendorListVersion: params.vendorListVersion - }; - - callback(consent, true); - }); - }; - /** * Generates consent object based on input params: consents and vendor list */ @@ -324,7 +218,6 @@ const createCommands = (store, cmpManager) => { return { getConsentObject, - getConsentFieldsV1, getVendorListVersion, showConsentTool, showConsentDetailView, diff --git a/src/lib/commands.test.js b/src/lib/commands.test.js index 6bfdd290..66bd2726 100644 --- a/src/lib/commands.test.js +++ b/src/lib/commands.test.js @@ -256,172 +256,6 @@ describe('commands', () => { }); }); - describe('getConsentFieldsV1', () => { - it('should return empty object and false when invoked without vendor list', (done) => { - const consents = {}; - - commands.getConsentFieldsV1((tcData, success) => { - expect(tcData).to.deep.equal({}); - expect(success).to.be.false; - done(); - }, consents); - }); - - - it('should return empty object and false when invoked with undefined', (done) => { - commands.getConsentFieldsV1((tcData, success) => { - expect(tcData).to.deep.equal({}); - expect(success).to.be.false; - done(); - }, undefined); - }); - - it('should return consent object without any consents when invoked with proper object but without any consents', (done) => { - const consents = { - "selectedPurposeIds": [], - "selectedVendorIds": [], - "vendorListVersion": 179, - "cookieVersion": 1, - "cmpVersion": 1 - }; - - commands.getConsentFieldsV1((tcData, success) => { - expect(tcData.metadata).not.to.be.undefined; - expect(success).to.be.true; - expect(tcData.gdprApplies).to.be.true; - expect(tcData.hasGlobalScope).to.be.false; - expect(tcData.cmpId).to.be.equal(CMP_ID); - expect(tcData.cmpVersion).to.be.equal(CMP_VERSION); - expect(tcData.created).to.be.undefined; - expect(tcData.lastUpdated).to.be.undefined; - expect(tcData.cookieVersion).to.equal(1); - expect(tcData.vendorListVersion).to.equal(consents.vendorListVersion); - done(); - }, consents); - }); - - it('should return consent object without any consents when invoked with proper object', (done) => { - const consents = { - "maxVendorId": 200, - "selectedPurposeIds": [1, 2, 3, 4, 5], - "selectedVendorIds": [2,3,4,100, 157], - "vendorListVersion": 179, - "cookieVersion": 1, - "cmpVersion": 1 - }; - - commands.getConsentFieldsV1((tcData, success) => { - expect(tcData.metadata).not.to.be.undefined; - expect(success).to.be.true; - expect(tcData.gdprApplies).to.be.true; - expect(tcData.hasGlobalScope).to.be.false; - expect(tcData.cmpId).to.be.equal(CMP_ID); - expect(tcData.cmpVersion).to.be.equal(CMP_VERSION); - expect(tcData.created).to.be.undefined; - expect(tcData.lastUpdated).to.be.undefined; - expect(tcData.cookieVersion).to.equal(1); - expect(tcData.vendorListVersion).to.equal(consents.vendorListVersion); - done(); - }, consents); - }); - - it('should return consent object with corresponded values when invoked with proper object also when consent was persisted before', (done) => { - const consents = { - "maxVendorId": 200, - "selectedPurposeIds": [1, 2, 3, 4, 5], - "selectedVendorIds": [2,3,4,100, 157], - "vendorListVersion": 179, - "cookieVersion": 1, - "cmpVersion": 1 - }; - - const tcModel = new TCModel(); - tcModel.cmpId = 280; - tcModel.cmpVersion = 2; - tcModel.gvl = new GVL(VENDOR_LIST); - - setTimeout(() => { - tcModel.purposeConsents.set(PURPOSE_CONSENTS); - tcModel.purposeLegitimateInterests.set(PURPOSE_LEGITIMATE_INTERESTS); - tcModel.vendorConsents.set(VENDOR_CONSENTS); - tcModel.vendorLegitimateInterests.set(VENDOR_LEGITIMATE_INTERESTS); - tcModel.publisherConsents.set(PUBLISHER_CONSENTS); - tcModel.publisherLegitimateInterests.set(PUBLISHER_LEGITIMATE_INTERESTS); - tcModel.specialFeatureOptins.set(SPECIAL_FEATURE_OPT_INS); - - // creating consent - const encoded = encodeConsentData(tcModel); - const localStore = new Store({ - cmpId: CMP_ID, - consentString: encoded - }); - const localCommands = createCommands(localStore); - const cmpApi = new CmpApi(280, 2, localCommands); - store.setCmpApi(cmpApi); - store.updateVendorList(VENDOR_LIST); - - setTimeout(() => { - const now = new Date(); - localCommands.getConsentFieldsV1((tcData, success) => { - expect(tcData.metadata).not.to.be.undefined; - expect(success).to.be.true; - expect(tcData.gdprApplies).to.be.true; - expect(tcData.hasGlobalScope).to.be.false; - expect(tcData.cmpId).to.be.equal(CMP_ID); - expect(tcData.cmpVersion).to.be.equal(CMP_VERSION); - expect(tcData.created).not.to.be.undefined; - expect(tcData.lastUpdated).not.to.be.undefined; - expect(tcData.cookieVersion).to.equal(1); - expect(tcData.vendorListVersion).to.equal(consents.vendorListVersion); - expect(tcData.created).to.be.beforeTime(now); - expect(tcData.lastUpdated).to.be.beforeTime(now); - done(); - }, consents, VENDOR_LIST); - }, 100); - - }, 0); - }); - - - it('getVendorListVersion - should return null if transparency was not established', () => { - commands.getVendorListVersion((vendorListVersion) => { - expect(vendorListVersion).to.be.null; - }); - }); - - it('getVendorListVersion - should return vendor list version if transparency was established', () => { - const tcModel = new TCModel(); - tcModel.cmpId = 280; - tcModel.cmpVersion = 2; - tcModel.gvl = new GVL(VENDOR_LIST); - - setTimeout(() => { - tcModel.purposeConsents.set(PURPOSE_CONSENTS); - tcModel.purposeLegitimateInterests.set(PURPOSE_LEGITIMATE_INTERESTS); - tcModel.vendorConsents.set(VENDOR_CONSENTS); - tcModel.vendorLegitimateInterests.set(VENDOR_LEGITIMATE_INTERESTS); - tcModel.publisherConsents.set(PUBLISHER_CONSENTS); - tcModel.publisherLegitimateInterests.set(PUBLISHER_LEGITIMATE_INTERESTS); - tcModel.specialFeatureOptins.set(SPECIAL_FEATURE_OPT_INS); - - // creating consent - const encoded = encodeConsentData(tcModel); - const localStore = new Store({ - cmpId: CMP_ID, - consentString: encoded - }); - - const localCommands = createCommands(localStore); - const cmpApi = new CmpApi(280, 2, localCommands); - store.setCmpApi(cmpApi); - store.updateVendorList(VENDOR_LIST); - - localCommands.getVendorListVersion((vendorListVersion) => { - expect(vendorListVersion).to.equal(100); - }); - }, 0); - }); - }); describe('additional functions', () => { let callbackExecuted, store, cmpManager, commands; diff --git a/src/lib/cookie/cookie.js b/src/lib/cookie/cookie.js index 169e7c6c..7cb1adf1 100644 --- a/src/lib/cookie/cookie.js +++ b/src/lib/cookie/cookie.js @@ -1,15 +1,9 @@ import Promise from 'promise-polyfill'; import log from '../log'; import { TCString, VendorVectorEncoder, IntEncoder, BitLength } from '@iabtcf/core'; -import { - padRight, - encodeVendorCookieValue -} from './cookieEncodeHelpers'; -const arrayFrom = require('core-js/library/fn/array/from'); const CONSENT_COOKIE = 'adpconsent'; const CONSENT_COOKIE_MAX_AGE = 33696000; -const MAX_PURPOSE_V1_ID = 5; function readCookie(name) { const value = `; ${document.cookie}`; @@ -65,74 +59,6 @@ const writeConsentCookie = (encodedConsent) => { return Promise.resolve(writeCookie(CONSENT_COOKIE, encodedConsent, CONSENT_COOKIE_MAX_AGE, '/')); }; -const encodePurposeIdsToBits = (selectedPurposeIds = new Set()) => { - const maxPurposeId = Math.max(0, - ...arrayFrom(selectedPurposeIds), - MAX_PURPOSE_V1_ID); - let purposeString = ''; - for (let id = 1; id <= maxPurposeId; id++) { - purposeString += (selectedPurposeIds.has(id) ? '1' : '0'); - } - return purposeString; -}; - -const encodeVendorIdsToBits = (maxVendorId, selectedVendorIds = new Set()) => { - let vendorString = ''; - for (let id = 1; id <= maxVendorId; id++) { - vendorString += (selectedVendorIds.has(id) ? '1' : '0'); - } - return padRight(vendorString, Math.max(0, maxVendorId - vendorString.length)); -}; - -const convertVendorsToRanges = (maxVendorId, selectedIds) => { - let range = []; - const ranges = []; - for (let id = 1; id <= maxVendorId; id++) { - if (selectedIds.has(id)) { - range.push(id); - } - - // If the range has ended or at the end of vendors add entry to the list - if ((!selectedIds.has(id) || id === maxVendorId) && range.length) { - const startVendorId = range.shift(); - const endVendorId = range.pop(); - range = []; - ranges.push({ - isRange: typeof endVendorId === 'number', - startVendorId, - endVendorId - }); - } - } - return ranges; -}; - -const encodeVendorConsentData = (vendorData) => { - const { selectedPurposeIds, selectedVendorIds, maxVendorId } = vendorData; - - // Encode the data with and without ranges and return the smallest encoded payload - const noRangesData = encodeVendorCookieValue({ - ...vendorData, - maxVendorId, - purposeIdBitString: encodePurposeIdsToBits(selectedPurposeIds), - isRange: false, - vendorIdBitString: encodeVendorIdsToBits(maxVendorId, selectedVendorIds) - }); - - const vendorRangeList = convertVendorsToRanges(maxVendorId, selectedVendorIds); - const rangesData = encodeVendorCookieValue({ - ...vendorData, - maxVendorId, - purposeIdBitString: encodePurposeIdsToBits(selectedPurposeIds), - isRange: true, - defaultConsent: false, - numEntries: vendorRangeList.length, - vendorRangeList - }); - - return noRangesData.length < rangesData.length ? noRangesData : rangesData; -}; - const applyDecodeFix = () => { const decode = VendorVectorEncoder.decode; VendorVectorEncoder.decode = function (...args) { @@ -151,8 +77,6 @@ export { encodeConsentData, readConsentCookie, writeConsentCookie, - encodeVendorConsentData, - convertVendorsToRanges, applyDecodeFix, CONSENT_COOKIE }; diff --git a/src/lib/cookie/cookie.test.js b/src/lib/cookie/cookie.test.js index 71ea5365..f37b2e1e 100644 --- a/src/lib/cookie/cookie.test.js +++ b/src/lib/cookie/cookie.test.js @@ -5,8 +5,6 @@ import { encodeConsentData, writeConsentCookie, readConsentCookie, - convertVendorsToRanges, - encodeVendorConsentData, applyDecodeFix, CONSENT_COOKIE } from './cookie'; @@ -21,63 +19,6 @@ import { VENDOR_LIST } from "../../../test/constants"; import { GVL, TCModel, VendorVectorEncoder } from "@iabtcf/core"; -import {decodeVendorCookieValue, decodeBitsToIds, decodePublisherCookieValue} from "./cookieDecodeHelpers"; -import {encodePublisherCookieValue, encodeVendorCookieValue} from "./cookieEncodeHelpers"; - -function decodeVendorConsentData(cookieValue) { - const { - cookieVersion, - cmpId, - cmpVersion, - consentScreen, - consentLanguage, - vendorListVersion, - purposeIdBitString, - maxVendorId, - created, - lastUpdated, - isRange, - defaultConsent, - vendorIdBitString, - vendorRangeList - } = decodeVendorCookieValue(cookieValue); - - const cookieData = { - cookieVersion, - cmpId, - cmpVersion, - consentScreen, - consentLanguage, - vendorListVersion, - selectedPurposeIds: decodeBitsToIds(purposeIdBitString), - maxVendorId, - created, - lastUpdated - }; - - if (isRange) { - const idMap = vendorRangeList.reduce((acc, {isRange, startVendorId, endVendorId}) => { - const lastVendorId = isRange ? endVendorId : startVendorId; - for (let i = startVendorId; i <= lastVendorId; i++) { - acc[i] = true; - } - return acc; - }, {}); - - cookieData.selectedVendorIds = new Set(); - for (let i = 0; i <= maxVendorId; i++) { - if ((defaultConsent && !idMap[i]) || - (!defaultConsent && idMap[i])) { - cookieData.selectedVendorIds.add(i); - } - } - } - else { - cookieData.selectedVendorIds = decodeBitsToIds(vendorIdBitString); - } - - return cookieData; -} function vectorToObject(set) { let obj = {}; @@ -235,193 +176,4 @@ describe('cookie', () => { }); }, 0); }); - - it('It should return undefined when decoding v1 cookie', () => { - const cookie_v1 = 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'; - const decoded = decodeConsentData(cookie_v1); - expect(decoded).to.be.undefined; - }); - - it('encodes and decodes the vendor cookie object back to original value', () => { - - const aDate = new Date('2018-07-15 PDT'); - const vendorConsentData = { - cookieVersion: 1, - cmpId: 1, - cmpVersion: 1, - consentScreen: 2, - consentLanguage: 'DE', - vendorListVersion: 1, - maxVendorId: Math.max(...Object.values(VENDOR_LIST.vendors).map(vendor => vendor.id)), - created: aDate, - lastUpdated: aDate, - selectedPurposeIds: new Set([1, 2]), - selectedVendorIds: new Set([1, 2, 4]) - }; - - const encodedString = encodeVendorConsentData({...vendorConsentData, VENDOR_LIST}); - const decoded = decodeVendorConsentData(encodedString); - - expect(decoded).to.deep.equal(vendorConsentData); - }); - - it('converts selected vendor list to a range', () => { - const maxVendorId = Math.max(...Object.values(VENDOR_LIST.vendors).map(vendor => vendor.id)); - const ranges = convertVendorsToRanges(maxVendorId, new Set([2, 3, 4])); - - expect(ranges).to.deep.equal([{ - isRange: true, - startVendorId: 2, - endVendorId: 4 - }]); - }); - - it('converts selected vendor list to multiple ranges', () => { - const maxVendorId = Math.max(...Object.values(VENDOR_LIST.vendors).map(vendor => vendor.id)); - const ranges = convertVendorsToRanges(maxVendorId, new Set([2, 3, 5, 6, 10])); - - expect(ranges).to.deep.equal([ - { - isRange: true, - startVendorId: 2, - endVendorId: 3 - }, - { - isRange: true, - startVendorId: 5, - endVendorId: 6 - }, - { - isRange: false, - startVendorId: 10, - endVendorId: undefined - } - ]); - }); -}); - -describe('cookie common', () => { - it('encodes and decodes the vendor cookie value with ranges back to original value', () => { - - const aDate = new Date('2018-07-15 PDT'); - - const consentData = { - cookieVersion: 1, - created: aDate, - lastUpdated: aDate, - cmpId: 1, - cmpVersion: 1, - consentScreen: 1, - consentLanguage: 'EN', - vendorListVersion: 1, - purposeIdBitString: '111000001010101010001101', - maxVendorId: 5, - isRange: true, - defaultConsent: false, - numEntries: 2, - vendorRangeList: [ - { - isRange: true, - startVendorId: 2, - endVendorId: 4 - }, - { - isRange: false, - startVendorId: 1 - } - ] - }; - - const bitString = encodeVendorCookieValue(consentData); - const decoded = decodeVendorCookieValue(bitString); - - expect(decoded).to.deep.equal(consentData); - }); - - it('encodes and decodes the vendor cookie value with range ranges back to original value', () => { - - const aDate = new Date('2018-07-15 PDT'); - - const consentData = { - cookieVersion: 1, - created: aDate, - lastUpdated: aDate, - cmpId: 1, - cmpVersion: 1, - consentScreen: 1, - consentLanguage: 'EN', - vendorListVersion: 1, - purposeIdBitString: '111000001010101010001101', - maxVendorId: 5, - isRange: true, - defaultConsent: false, - numEntries: 2, - vendorRangeList: [ - { - isRange: false, - startVendorId: 2 - }, - { - isRange: false, - startVendorId: 1 - } - ] - }; - - const bitString = encodeVendorCookieValue(consentData); - const decoded = decodeVendorCookieValue(bitString); - - expect(decoded).to.deep.equal(consentData); - }); - - it('encodes and decodes the vendor cookie value without ranges back to original value', () => { - - const aDate = new Date('2018-07-15 PDT'); - - const consentData = { - cookieVersion: 1, - created: aDate, - lastUpdated: aDate, - cmpId: 1, - cmpVersion: 1, - consentScreen: 1, - consentLanguage: 'EN', - vendorListVersion: 1, - purposeIdBitString: '000000001010101010001100', - maxVendorId: 5, - isRange: false, - vendorIdBitString: '10011', - }; - - const bitString = encodeVendorCookieValue(consentData); - const decoded = decodeVendorCookieValue(bitString); - - expect(decoded).to.deep.equal(consentData); - }); - - - it('encodes and decodes the publisher cookie value without ranges back to original value', () => { - - const aDate = new Date('2018-07-15 PDT'); - - const consentData = { - cookieVersion: 1, - created: aDate, - lastUpdated: aDate, - cmpId: 1, - cmpVersion: 0, - consentScreen: 0, - consentLanguage: 'AA', - vendorListVersion: 1, - publisherPurposeVersion: 1, - numCustomPurposes: 4, - standardPurposeIdBitString: '000000001010101010001100', - customPurposeIdBitString: '1011', - }; - - const bitString = encodePublisherCookieValue(consentData); - const decoded = decodePublisherCookieValue(bitString); - - expect(decoded).to.deep.equal(consentData); - }); }); diff --git a/src/lib/cookie/cookieDecodeHelpers.js b/src/lib/cookie/cookieDecodeHelpers.js deleted file mode 100644 index a7a940de..00000000 --- a/src/lib/cookie/cookieDecodeHelpers.js +++ /dev/null @@ -1,168 +0,0 @@ -import log from '../log'; -import { - NUM_BITS_VERSION, - vendorVersionMap, - publisherVersionMap -} from './definitions'; - -import { - padRight, - padLeft, SIX_BIT_ASCII_OFFSET, -} from "./cookieEncodeHelpers"; - -const decodeBitsToInt = (bitString, start, length) => parseInt(bitString.substr(start, length), 2); - -const decodeBitsToDate = (bitString, start, length) => new Date(decodeBitsToInt(bitString, start, length) * 100); - -const decodeBitsToBool = (bitString, start) => parseInt(bitString.substr(start, 1), 2) === 1; - -const decode6BitCharacters = (bitString, start, length) => { - let decoded = ''; - let decodeStart = start; - while (decodeStart < start + length) { - decoded += String.fromCharCode(SIX_BIT_ASCII_OFFSET + decodeBitsToInt(bitString, decodeStart, 6)); - decodeStart += 6; - } - return decoded; -}; - -const decodeField = ({ input, output, startPosition, field }) => { - const { type, numBits, decoder, validator, listCount } = field; - if (typeof validator === 'function') { - if (!validator(output)) { - // Not decoding this field so make sure we start parsing the next field at - // the same point - return {newPosition: startPosition}; - } - } - if (typeof decoder === 'function') { - return decoder(input, output, startPosition); - } - - const bitCount = typeof numBits === 'function' ? numBits(output) : numBits; - const listEntryCount = typeof listCount === 'function' ? - listCount(output) : typeof listCount === 'number' ? listCount : 0; - - switch (type) { - case 'int': - return { fieldValue: decodeBitsToInt(input, startPosition, bitCount) }; - case 'bool': - return { fieldValue: decodeBitsToBool(input, startPosition) }; - case 'date': - return { fieldValue: decodeBitsToDate(input, startPosition, bitCount) }; - case 'bits': - return { fieldValue: input.substr(startPosition, bitCount) }; - case '6bitchar': - return { fieldValue: decode6BitCharacters(input, startPosition, bitCount) }; - case 'list': - return new Array(listEntryCount).fill().reduce((acc) => { - const { decodedObject, newPosition } = decodeFields({ - input, - fields: field.fields, - startPosition: acc.newPosition - }); - return { - fieldValue: [...acc.fieldValue, decodedObject], - newPosition - }; - }, { fieldValue: [], newPosition: startPosition }); - default: - log.warn(`Cookie definition field found without decoder or type: ${name}`); - return {}; - } -}; - -const decodeFields = ({ input, fields, startPosition = 0 }) => { - let position = startPosition; - const decodedObject = fields.reduce((acc, field) => { - const { name, numBits } = field; - const { fieldValue, newPosition } = decodeField({ - input, - output: acc, - startPosition: position, - field - }); - if (fieldValue !== undefined) { - acc[name] = fieldValue; - } - if (newPosition !== undefined) { - position = newPosition; - } - else if (typeof numBits === 'number') { - position += numBits; - } - return acc; - }, {}); - return { - decodedObject, - newPosition: position - }; -}; - -/** - * Decode the (URL safe Base64) value of a cookie into an object. - */ -const decodeCookieValue = (cookieValue, definitionMap) => { - - // Replace safe characters - const unsafe = cookieValue - .replace(/-/g, '+') - .replace(/_/g, '/') + '=='.substring(0, (3 * cookieValue.length) % 4); - - const bytes = atob(unsafe); - - let inputBits = ''; - for (let i = 0; i < bytes.length; i++) { - const bitString = bytes.charCodeAt(i).toString(2); - inputBits += padLeft(bitString, 8 - bitString.length); - } - - return decodeCookieBitValue(inputBits, definitionMap); -}; - -const decodeCookieBitValue = (bitString, definitionMap) => { - const cookieVersion = decodeBitsToInt(bitString, 0, NUM_BITS_VERSION); - if (typeof cookieVersion !== 'number') { - log.error('Could not find cookieVersion to decode'); - return {}; - } - else if (!vendorVersionMap[cookieVersion]) { - log.error(`Could not find definition to decode cookie version ${cookieVersion}`); - return {}; - } - const cookieFields = definitionMap[cookieVersion].fields; - const { decodedObject } = decodeFields({ input: bitString, fields: cookieFields }); - return decodedObject; -}; - - -const decodeVendorCookieValue = (cookieValue) => { - return decodeCookieValue(cookieValue, vendorVersionMap); -}; - -const decodePublisherCookieValue = (cookieValue) => { - return decodeCookieValue(cookieValue, publisherVersionMap); -}; - -const decodeBitsToIds = (bitString) => { - return bitString.split('').reduce((acc, bit, index) => { - if (bit === '1') { - acc.add(index + 1); - } - return acc; - }, new Set()); -}; - -export { - padRight, - padLeft, - decodeBitsToInt, - decodeBitsToDate, - decodeBitsToBool, - decodeCookieValue, - decodeCookieBitValue, - decodeVendorCookieValue, - decodePublisherCookieValue, - decode6BitCharacters, - decodeBitsToIds, -}; diff --git a/src/lib/cookie/cookieDecodeHelpers.test.js b/src/lib/cookie/cookieDecodeHelpers.test.js deleted file mode 100644 index d37d8435..00000000 --- a/src/lib/cookie/cookieDecodeHelpers.test.js +++ /dev/null @@ -1,69 +0,0 @@ -import { expect } from 'chai'; - -import { - decodeBitsToInt, - decodeBitsToDate, - decodeBitsToBool, - decodeVendorCookieValue, - decode6BitCharacters -} from './cookieDecodeHelpers'; - -import { - encodeIntToBits, - encodeDateToBits, - encodeBoolToBits, - encode6BitCharacters, -} from "./cookieEncodeHelpers"; - -describe('cookieutils', () => { - describe('decodeBitsToInt', () => { - it('decodes a bit string to original encoded value', () => { - const bitString = encodeIntToBits(123); - const decoded = decodeBitsToInt(bitString, 0, bitString.length); - expect(decoded).to.equal(123); - }); - }); - - describe('decodeBitsToDate', () => { - it('decodes a bit string to original encoded value', () => { - const now = new Date('2018-07-15 PDT'); - const bitString = encodeDateToBits(now); - const decoded = decodeBitsToDate(bitString, 0, bitString.length); - expect(decoded.getTime()).to.equal(now.getTime()); - }); - }); - - describe('decodeBitsToBool', () => { - it('decodes a bit string to original encoded "true" value', () => { - const bitString = encodeBoolToBits(true); - const decoded = decodeBitsToBool(bitString, 0, bitString.length); - expect(decoded).to.equal(true); - }); - it('decodes a bit string to original encoded "false" value', () => { - const bitString = encodeBoolToBits(false); - const decoded = decodeBitsToBool(bitString, 0, bitString.length); - expect(decoded).to.equal(false); - }); - }); - - describe('decode6BitCharacters', () => { - it('decodes a bit string to original encoded value', () => { - const string = 'STUFF'; - const bitString = encode6BitCharacters(string); - const decoded = decode6BitCharacters(bitString, 0, bitString.length); - expect(decoded).to.equal(string); - }); - it('decodes a bit string that is longer than length', () => { - const string = 'STUFF'; - const bitString = encode6BitCharacters(string); - const decoded = decode6BitCharacters(bitString, 0, 12); - expect(decoded).to.equal('ST'); - }); - }); - - it('fails to decode an invalid cookie version', () => { - const bitString = encodeIntToBits(999, 6); - const decoded = decodeVendorCookieValue(bitString); - expect(decoded).to.be.empty; - }); -}); diff --git a/src/lib/cookie/cookieEncodeHelpers.js b/src/lib/cookie/cookieEncodeHelpers.js deleted file mode 100644 index 1c8907c2..00000000 --- a/src/lib/cookie/cookieEncodeHelpers.js +++ /dev/null @@ -1,163 +0,0 @@ -import {vendorVersionMap, publisherVersionMap} from "./definitions"; -import log from "../log"; - -const SIX_BIT_ASCII_OFFSET = 65; - -const repeat = (count, string='0') => { - let padString = ''; - for (let i = 0; i < count; i++) { - padString += string; - } - return padString; -}; - -const padRight = (string, padding) => string + repeat(Math.max(0, padding)); - -const padLeft = (string, padding) => repeat(Math.max(0, padding)) + string; - -const encodeIntToBits = (number, numBits) => { - let bitString = ''; - if (typeof number === 'number' && !isNaN(number)) { - bitString = parseInt(number, 10).toString(2); - } - - // Pad the string if not filling all bits - if (numBits >= bitString.length) { - bitString = padLeft(bitString, numBits - bitString.length); - } - - // Truncate the string if longer than the number of bits - if (bitString.length > numBits) { - bitString = bitString.substring(0, numBits); - } - return bitString; -}; - -/** - * Encodes each character of a string in 6 bits starting - * with [aA]=0 through [zZ]=25 - */ -const encode6BitCharacters = (string, numBits) => { - const encoded = typeof string !== 'string' ? '' : string.split('').map(char => { - const int = Math.max(0, char.toUpperCase().charCodeAt(0) - SIX_BIT_ASCII_OFFSET); - return encodeIntToBits(int > 25 ? 0 : int, 6); - }).join(''); - return padRight(encoded, numBits).substr(0, numBits); -}; - -const encodeBoolToBits = (value) => encodeIntToBits(value === true ? 1 : 0, 1); - -const encodeDateToBits = (date, numBits) => { - if (date instanceof Date) { - return encodeIntToBits(date.getTime() / 100, numBits); - } - return encodeIntToBits(date, numBits); -}; - -const encodeField = ({ input, field }) => { - const { name, type, numBits, encoder, validator } = field; - if (typeof validator === 'function') { - if (!validator(input)) { - return ''; - } - } - if (typeof encoder === 'function') { - return encoder(input); - } - - const bitCount = typeof numBits === 'function' ? numBits(input) : numBits; - - const inputValue = input[name]; - const fieldValue = inputValue === null || inputValue === undefined ? '' : inputValue; - switch (type) { - case 'int': - return encodeIntToBits(fieldValue, bitCount); - case 'bool': - return encodeBoolToBits(fieldValue); - case 'date': - return encodeDateToBits(fieldValue, bitCount); - case 'bits': - return padRight(fieldValue, bitCount - fieldValue.length).substring(0, bitCount); - case '6bitchar': - return encode6BitCharacters(fieldValue, bitCount); - case 'list': - return fieldValue.reduce((acc, listValue) => acc + encodeFields({ - input: listValue, - fields: field.fields - }), ''); - default: - log.warn(`Cookie definition field found without encoder or type: ${name}`); - return ''; - } -}; - -const encodeFields = ({ input, fields }) => { - return fields.reduce((acc, field) => { - acc += encodeField({ input, field }); - return acc; - }, ''); -}; - -/** - * Encode the data properties to a bit string. Encoding will encode - * either `selectedVendorIds` or the `vendorRangeList` depending on - * the value of the `isRange` flag. - */ -const encodeDataToBits = (data, definitionMap) => { - const { cookieVersion } = data; - - if (typeof cookieVersion !== 'number') { - log.error('Could not find cookieVersion to encode'); - } - else if (!definitionMap[cookieVersion]) { - log.error(`Could not find definition to encode cookie version ${cookieVersion}`); - } - else { - const cookieFields = definitionMap[cookieVersion].fields; - return encodeFields({ input: data, fields: cookieFields }); - } -}; - -/** - * Take all fields required to encode the cookie and produce the - * URL safe Base64 encoded value. - */ -const encodeCookieValue = (data, definitionMap) => { - const binaryValue = encodeDataToBits(data, definitionMap); - if (binaryValue) { - - // Pad length to multiple of 8 - const paddedBinaryValue = padRight(binaryValue, 7 - (binaryValue.length + 7) % 8); - - // Encode to bytes - let bytes = ''; - for (let i = 0; i < paddedBinaryValue.length; i += 8) { - bytes += String.fromCharCode(parseInt(paddedBinaryValue.substr(i, 8), 2)); - } - - // Make base64 string URL friendly - return btoa(bytes) - .replace(/\+/g, '-') - .replace(/\//g, '_') - .replace(/=+$/, ''); - } -}; - -const encodeVendorCookieValue = (vendorData) => encodeCookieValue(vendorData, vendorVersionMap); - -const encodePublisherCookieValue = (publisherData) => encodeCookieValue(publisherData, publisherVersionMap); - -export { - padRight, - padLeft, - encodeVendorCookieValue, - encodePublisherCookieValue, - encodeIntToBits, - encodeBoolToBits, - encodeDateToBits, - encode6BitCharacters, - encodeField, - encodeDataToBits, - encodeCookieValue, - SIX_BIT_ASCII_OFFSET -}; diff --git a/src/lib/cookie/cookieEncodeHelpers.test.js b/src/lib/cookie/cookieEncodeHelpers.test.js deleted file mode 100644 index b0ef7b2c..00000000 --- a/src/lib/cookie/cookieEncodeHelpers.test.js +++ /dev/null @@ -1,84 +0,0 @@ -import { expect } from 'chai'; - -import { - encodeIntToBits, - encodeBoolToBits, - encodeDateToBits, - encode6BitCharacters, - encodeVendorCookieValue, -} from './cookieEncodeHelpers'; - -describe('cookieutils', () => { - describe('encodeIntToBits', () => { - it('encodes an integer to a bit string', () => { - const bitString = encodeIntToBits(123); - expect(bitString).to.equal('1111011'); - }); - it('encodes an integer to a bit string with padding', () => { - const bitString = encodeIntToBits(123, 12); - expect(bitString).to.equal('000001111011'); - }); - - }); - - describe('encodeBoolToBits', () => { - it('encodes a "true" boolean to a bit string', () => { - const bitString = encodeBoolToBits(true); - expect(bitString).to.equal('1'); - }); - it('encode a "false" boolean to a bit string', () => { - const bitString = encodeBoolToBits(false); - expect(bitString).to.equal('0'); - }); - }); - - describe('encodeDateToBits', () => { - it('encode a date to a bit string', () => { - const date = new Date(1512661975200); - const bitString = encodeDateToBits(date); - expect(bitString).to.equal('1110000101100111011110011001101000'); - }); - it('encode a date to a bit string with padding', () => { - const date = new Date(1512661975200); - const bitString = encodeDateToBits(date, 36); - expect(bitString).to.equal('001110000101100111011110011001101000'); - }); - }); - - describe('encode6BitCharacters', () => { - it('encode a 6bitchar string to a bit string', () => { - const bitString = encode6BitCharacters('hello'); - expect(bitString).to.equal('000111000100001011001011001110'); - }); - }); - - it('fails to encode a cookie version that does not exist', () => { - const aDate = new Date('2018-07-15 PDT'); - - const consentData = { - cookieVersion: 999, - created: aDate, - lastUpdated: aDate, - cmpId: 1, - vendorListVersion: 1, - }; - - const bitString = encodeVendorCookieValue(consentData); - expect(bitString).to.be.undefined; - }); - - it('fails to encode an invalid cookie version', () => { - const aDate = new Date('2018-07-15 PDT'); - - const consentData = { - cookieVersion: 'hello', - created: aDate, - lastUpdated: aDate, - cmpId: 1, - vendorListVersion: 1, - }; - - const bitString = encodeVendorCookieValue(consentData); - expect(bitString).to.be.undefined; - }); -}); diff --git a/src/lib/cookie/definitions/index.js b/src/lib/cookie/definitions/index.js deleted file mode 100644 index be0dc9f4..00000000 --- a/src/lib/cookie/definitions/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import vendor1 from './vendor/version1'; -import publisher1 from './publisher/version1'; - -const NUM_BITS_VERSION = 6; - -const vendorVersionList = [ - vendor1 -]; - -const vendorVersionMap = vendorVersionList.reduce((acc, definition) => { - acc[definition.version] = definition; - return acc; -}, {}); - -const publisherVersionList = [ - publisher1 -]; - -const publisherVersionMap = publisherVersionList.reduce((acc, definition) => { - acc[definition.version] = definition; - return acc; -}, {}); - -export { - NUM_BITS_VERSION, - vendorVersionList, - vendorVersionMap, - publisherVersionList, - publisherVersionMap -}; diff --git a/src/lib/cookie/definitions/publisher/version1.js b/src/lib/cookie/definitions/publisher/version1.js deleted file mode 100644 index 9738589c..00000000 --- a/src/lib/cookie/definitions/publisher/version1.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - version: 1, - fields: [ - { name: 'cookieVersion', type: 'int', numBits: 6 }, - { name: 'created', type: 'date', numBits: 36 }, - { name: 'lastUpdated', type: 'date', numBits: 36 }, - { name: 'cmpId', type: 'int', numBits: 12 }, - { name: 'cmpVersion', type: 'int', numBits: 12 }, - { name: 'consentScreen', type: 'int', numBits: 6 }, - { name: 'consentLanguage', type: '6bitchar', numBits: 12 }, - { name: 'vendorListVersion', type: 'int', numBits: 12 }, - { name: 'publisherPurposeVersion', type: 'int', numBits: 12 }, - { name: 'standardPurposeIdBitString', type: 'bits', numBits: 24 }, - { name: 'numCustomPurposes', type: 'int', numBits: 6 }, - { - name: 'customPurposeIdBitString', - type: 'bits', - numBits: (decodedObject) => decodedObject.numCustomPurposes - } - ] -}; - diff --git a/src/lib/cookie/definitions/vendor/version1.js b/src/lib/cookie/definitions/vendor/version1.js deleted file mode 100644 index e67a111c..00000000 --- a/src/lib/cookie/definitions/vendor/version1.js +++ /dev/null @@ -1,59 +0,0 @@ -export default { - version: 1, - fields: [ - { name: 'cookieVersion', type: 'int', numBits: 6 }, - { name: 'created', type: 'date', numBits: 36 }, - { name: 'lastUpdated', type: 'date', numBits: 36 }, - { name: 'cmpId', type: 'int', numBits: 12 }, - { name: 'cmpVersion', type: 'int', numBits: 12 }, - { name: 'consentScreen', type: 'int', numBits: 6 }, - { name: 'consentLanguage', type: '6bitchar', numBits: 12 }, - { name: 'vendorListVersion', type: 'int', numBits: 12 }, - { name: 'purposeIdBitString', type: 'bits', numBits: 24 }, - { name: 'maxVendorId', type: 'int', numBits: 16 }, - { name: 'isRange', type: 'bool', numBits: 1 }, - { - name: 'vendorIdBitString', - type: 'bits', - numBits: (decodedObject) => decodedObject.maxVendorId, - validator: (decodedObject) => !decodedObject.isRange, - }, - { - name: 'defaultConsent', - type: 'bool', - numBits: 1, - validator: (decodedObject) => decodedObject.isRange, - }, - { - name: 'numEntries', - numBits: 12, - type: 'int', - validator: (decodedObject) => decodedObject.isRange, - }, - { - name: 'vendorRangeList', - type: 'list', - listCount: (decodedObject) => decodedObject.numEntries, - validator: (decodedObject) => decodedObject.isRange, - fields: [ - { - name: 'isRange', - type: 'bool', - numBits: 1 - }, - { - name: 'startVendorId', - type: 'int', - numBits: 16 - }, - { - name: 'endVendorId', - type: 'int', - numBits: 16, - validator: (decodedObject) => decodedObject.isRange - } - ] - } - ] -}; - diff --git a/src/lib/store.js b/src/lib/store.js index 8b293816..3212441c 100644 --- a/src/lib/store.js +++ b/src/lib/store.js @@ -16,12 +16,12 @@ export const TAB_PUBLISHER_INFO = 0; export const TAB_CONSENTS = 1; export default class Store { - constructor({ - cmpId, - cmpVersion = 2, - cookieVersion = 2, - consentString - } = {}) { + constructor ({ + cmpId, + cmpVersion = 2, + cookieVersion = 2, + consentString + } = {}) { // Keep track of data that has already been persisted const consentLanguage = findLocale().substr(0, 2).toUpperCase(); const publisherCountryCode = config.publisherCountryCode; @@ -108,7 +108,7 @@ export default class Store { } catch (err) { log.error('Failed writing external consent data', err); } - } else { + } else { writeConsentCookie(encodedConsent); } @@ -117,7 +117,7 @@ export default class Store { }; filterVendorConsents = (vendors) => { - const {vendorConsents, vendorLegitimateInterests} = this.tcModel; + const { vendorConsents, vendorLegitimateInterests } = this.tcModel; const availableIds = new Set(); for (let key in vendors) { @@ -149,7 +149,7 @@ export default class Store { }; selectVendor = (vendorId, isSelected) => { - const {vendorConsents} = this.tcModel; + const { vendorConsents } = this.tcModel; if (isSelected) { vendorConsents.set(vendorId); } else { @@ -159,7 +159,7 @@ export default class Store { }; selectVendors = (vendorIds, isSelected) => { - const {vendorConsents} = this.tcModel; + const { vendorConsents } = this.tcModel; if (isSelected) { vendorIds.forEach(id => { vendorConsents.set(id); @@ -179,7 +179,7 @@ export default class Store { }; selectVendorLegitimateInterests = (vendorId, isSelected, update = true) => { - const {vendorLegitimateInterests} = this.tcModel; + const { vendorLegitimateInterests } = this.tcModel; const hasLegInts = this.vendorList.vendors[vendorId].legIntPurposes.length > 0; if (hasLegInts) { @@ -201,7 +201,7 @@ export default class Store { selectAllVendorLegitimateInterests = (isSelected, update = true) => { - const {vendorLegitimateInterests} = this.tcModel; + const { vendorLegitimateInterests } = this.tcModel; const vendorsWithLegIntsIds = this.getVendorsWithLegIntsIds(); vendorsWithLegIntsIds.forEach(id => { @@ -227,8 +227,8 @@ export default class Store { }; selectPurpose = (purposeId, isSelected) => { - const {contractPurposeIds} = config; - const {purposeConsents} = this.tcModel; + const { contractPurposeIds } = config; + const { purposeConsents } = this.tcModel; if (contractPurposeIds.includes(purposeId)) { return; @@ -249,7 +249,7 @@ export default class Store { }; selectPurposeLegitimateInterests = (purposeId, isSelected) => { - const {purposeLegitimateInterests} = this.tcModel; + const { purposeLegitimateInterests } = this.tcModel; if (isSelected) { purposeLegitimateInterests.set(purposeId); } else { @@ -281,8 +281,8 @@ export default class Store { }; selectPublisherPurpose = (purposeId, isSelected) => { - const {contractPurposeIds} = config; - const {publisherConsents} = this.tcModel; + const { contractPurposeIds } = config; + const { publisherConsents } = this.tcModel; if (contractPurposeIds.includes(purposeId)) { return; @@ -297,13 +297,13 @@ export default class Store { }; selectAllPublisherPurposes = (isSelected, update = true) => { - const {purposes = {}} = this.vendorList || {}; + const { purposes = {} } = this.vendorList || {}; const operation = isSelected ? 'set' : 'unset'; - const {legIntPurposeIds, contractPurposeIds} = config; + const { legIntPurposeIds, contractPurposeIds } = config; const publisherLegalBasedPurposes = [...legIntPurposeIds, ...contractPurposeIds]; - const availablePurposes = Object.values(purposes).map(({id}) => id).filter((purposeId) => !publisherLegalBasedPurposes.includes(purposeId)); + const availablePurposes = Object.values(purposes).map(({ id }) => id).filter((purposeId) => !publisherLegalBasedPurposes.includes(purposeId)); - Object.values(purposes).forEach(({id}) => { + Object.values(purposes).forEach(({ id }) => { if (availablePurposes.includes(id)) { this.tcModel.publisherConsents[operation](id); } @@ -315,10 +315,10 @@ export default class Store { }; setAllContractPurposes = (update) => { - const {purposes = {}} = this.vendorList || {}; - const {contractPurposeIds} = config; + const { purposes = {} } = this.vendorList || {}; + const { contractPurposeIds } = config; - Object.values(purposes).forEach(({id}) => { + Object.values(purposes).forEach(({ id }) => { if (contractPurposeIds.includes(id)) { this.tcModel.publisherConsents.set(id); this.tcModel.vendorConsents.set(id); @@ -331,7 +331,7 @@ export default class Store { }; selectPublisherLegitimateInterests = (purposeId, isSelected) => { - const {publisherLegitimateInterests} = this.tcModel; + const { publisherLegitimateInterests } = this.tcModel; if (isSelected) { publisherLegitimateInterests.set(purposeId); } else { @@ -341,11 +341,11 @@ export default class Store { }; selectAllPublisherLegitimateInterests = (isSelected, update) => { - const {purposes = {}} = this.vendorList || {}; - const {legIntPurposeIds} = config; + const { purposes = {} } = this.vendorList || {}; + const { legIntPurposeIds } = config; const operation = isSelected ? 'set' : 'unset'; - Object.values(purposes).forEach(({id}) => { + Object.values(purposes).forEach(({ id }) => { if (legIntPurposeIds.includes(id)) { this.tcModel.publisherLegitimateInterests[operation](id); } diff --git a/src/lib/store.test.js b/src/lib/store.test.js index 3b97f689..084de239 100644 --- a/src/lib/store.test.js +++ b/src/lib/store.test.js @@ -231,43 +231,30 @@ describe('store', () => { }); }); - it('remove consents for vendors removed from current vendor list while user save consent', (done) => { - const tcModel = new TCModel(); - tcModel.cmpId = 280; - tcModel.cmpVersion = 2; - tcModel.gvl = new GVL(VENDOR_LIST); - - setTimeout(() => { - tcModel.vendorConsents.set([3, 9]); - tcModel.vendorLegitimateInterests.set([2, 9]); - - const encoded = encodeConsentData(tcModel); - - const store = new Store({ - cmpId: 280, - consentString: encoded, - }); - - store.setCmpApi(cmpApi); - store.updateVendorList(VENDOR_LIST); + it('remove consents for vendors removed from current vendor list while user save consent', () => { + const persistedConsentCookie = 'CO-jkXPO-jkXPEYACAENBkCAAAAAAAAAAAAAAFCCAAoAQAAA.IAFPHAAA.YAAAAAAAAAAA'; - const persistedConsentData = store.persistedConsentData; + const store = new Store({ + cmpId: 280, + consentString: persistedConsentCookie, + }); + store.setCmpApi(cmpApi); + store.updateVendorList(VENDOR_LIST); - expect(persistedConsentData.vendorConsents.has(9)).to.be.true; - expect(persistedConsentData.vendorLegitimateInterests.has(9)).to.be.true; + const persistedConsentData = store.persistedConsentData; - store.persist(); + expect(persistedConsentData.vendorConsents.has(9)).to.be.true; + expect(persistedConsentData.vendorLegitimateInterests.has(9)).to.be.true; - expect(persistedConsentData.vendorConsents.has(9)).to.be.false; - expect(persistedConsentData.vendorLegitimateInterests.has(9)).to.be.false; + store.persist(); - done(); - }); + expect(persistedConsentData.vendorConsents.has(9)).to.be.false; + expect(persistedConsentData.vendorLegitimateInterests.has(9)).to.be.false; }); it('selects vendor IDs', () => { const store = new Store({ - cmpId: CMP_ID, + cmpId: CMP_ID }); store.setCmpApi(cmpApi); diff --git a/test/constants.js b/test/constants.js index f06c5441..20dd1da0 100644 --- a/test/constants.js +++ b/test/constants.js @@ -1,7 +1,7 @@ const PURPOSE_CONSENTS = [1, 3, 5, 7, 9]; const PURPOSE_LEGITIMATE_INTERESTS = [2, 4, 6, 8, 10]; const VENDOR_CONSENTS = [1, 2, 3, 4, 8]; -const VENDOR_LEGITIMATE_INTERESTS = [1, 2, 3, 4]; +const VENDOR_LEGITIMATE_INTERESTS = [1, 3]; const PUBLISHER_CONSENTS = [2, 4, 6, 8, 10]; const PUBLISHER_LEGITIMATE_INTERESTS = [1, 3, 5, 7, 9]; const SPECIAL_FEATURE_OPT_INS = [1, 2, 3]; diff --git a/webpack.config.babel.js b/webpack.config.babel.js index 1a7b8847..7cff8feb 100644 --- a/webpack.config.babel.js +++ b/webpack.config.babel.js @@ -170,7 +170,6 @@ module.exports = [ { entry: { cmp: './index.js', - cookie: './lib/cookie/cookieDecodeHelpers.js', portal: './docs/assets/portal.js' },