Skip to content

Commit f5c8dd0

Browse files
committed
Merge branch 'release/1.4.0'
2 parents 0338b42 + acfcb63 commit f5c8dd0

17 files changed

+784
-687
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Notable changes to the project
33

44
## [Unreleased]
5+
## [1.4.0] - 2020-12-1
6+
### Changed
7+
- Remove CMP v1 support
8+
- Reader should also check consent and optout
9+
- Add support to determine TLD for cookies
510

611
## [1.3.3] - 2020-07-27
712
### Changed

karma.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = (config) => {
1818
reporters: ['mocha', 'bamboo'],
1919

2020
browsers: ['ChromeHeadlessNoSandbox'],
21+
//browsers: ['Safari'],
2122
customLaunchers: {
2223
ChromeHeadlessNoSandbox: {
2324
base: 'ChromeHeadless',

package-lock.json

Lines changed: 42 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pubcid",
3-
"version": "1.3.3",
3+
"version": "1.4.0",
44
"description": "Publisher Common ID",
55
"scripts": {
66
"lint": "eslint src/**/*.js",
@@ -34,6 +34,7 @@
3434
"karma-chrome-launcher": "^2.2.0",
3535
"karma-mocha": "^1.3.0",
3636
"karma-mocha-reporter": "^2.2.5",
37+
"karma-safari-applescript-launcher": "^0.1.0",
3738
"karma-sauce-launcher": "^2.0.2",
3839
"karma-sourcemap-loader": "^0.3.7",
3940
"karma-webpack": "^4.0.2",

src/lib/consenthandler/drivers/cmp.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/lib/consenthandler/proxy/proxyFactory.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import {Tcf} from "../drivers/tcf";
2-
import {Cmp} from "../drivers/cmp";
32
import {LocalProxy} from "./localProxy";
43
import {SafeFrameProxy} from "./safeFrameProxy";
54
import {FrameProxy} from "./frameProxy";
65

76
/**
8-
* Figure out which driver to use for the site. TCF driver takes priority over CMP
7+
* Create the driver to use for the site.
98
* @returns {*}
109
*/
1110
export function createProxy() {
1211
let proxy;
1312
proxy = _createProxy(new Tcf());
14-
if (!proxy) {
15-
proxy = _createProxy(new Cmp());
16-
}
1713
return proxy;
1814
}
1915

src/lib/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const COOKIE = 'cookie';
2+
export const LOCAL_STORAGE = 'html5';

src/lib/cookieUtils.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
* Set a cookie
33
* @param {string} name Name of the cookie
44
* @param {string} value Value of the cookie
5-
* @param {number} expires Expiration interval in minutes
6-
* @param {string} domain Domain of the cookie
7-
* @param {string} path Path of the cookie.
8-
* @param {string} sameSite Strict, Lax, or None
5+
* @param {number} [expires] Expiration interval in minutes
6+
* @param {string} [domain] Domain of the cookie
7+
* @param {string} [path] Path of the cookie.
8+
* @param {string} [sameSite] Strict, Lax, or None
99
*/
1010
export function setCookie(name, value, expires, domain = '', path = '/', sameSite) {
11-
if (name) {
12-
const expTime = new Date();
13-
expTime.setTime(expTime.getTime() + expires * 1000 * 60);
11+
if (name) {
12+
let expTime;
13+
if (expires) {
14+
expTime = new Date();
15+
expTime.setTime(expTime.getTime() + expires * 1000 * 60);
16+
}
17+
1418
window.document.cookie = name + '=' + encodeURIComponent(value) +
1519
';path=' + path +
1620
((domain) ? ';domain=' + domain : '') +
17-
';expires=' + expTime.toUTCString() +
21+
((expTime) ? ';expires=' + expTime.toUTCString() : '') +
1822
((sameSite) ? ';SameSite=' + sameSite : '');
1923
}
2024
}
@@ -33,21 +37,27 @@ export function getCookie(name) {
3337
}
3438

3539
/**
36-
* Delete a cookie
40+
* Delete a cookie. Name, domain, and path all have to match in order to delete a cookie correctly.
41+
* SameSite is optional. Firefox complains if sameSite is omitted or None when the connection isn't secure.
3742
* @param {string} name Name of the cookie
43+
* @param {string} [domain] Domain of the cookie
44+
* @param {string} [path] Path of the cookie.
45+
* @param {string} [sameSite] Strict, Lax, or None
3846
*/
39-
export function delCookie(name) {
40-
setCookie(name, '', -1);
47+
export function delCookie(name, domain, path, sameSite) {
48+
setCookie(name, '', -1, domain, path, sameSite);
4149
}
4250

4351
/**
44-
* Delete all cookies
52+
* Delete all cookies. This is a testing aid and shouldn't be used in production.
53+
* @param {string} [domain] Domain of the cookie*
54+
* @param {string} [path] Path of the cookie.
4555
*/
46-
export function clearAllCookies() {
56+
export function clearAllCookies(domain, path) {
4757
document.cookie.split(';').forEach(s=>{
4858
const name = s.split('=')[0];
4959
if (name) {
50-
delCookie(name);
60+
delCookie(name.trim(), domain, path);
5161
}
5262
});
5363
}
@@ -58,4 +68,4 @@ export function clearAllCookies() {
5868
*/
5969
export function isCookieSupported() {
6070
return (window.navigator.cookieEnabled || !!document.cookie.length);
61-
}
71+
}

0 commit comments

Comments
 (0)