@commercetools-frontend/cookie-consent 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/dist/commercetools-frontend-cookie-consent-core.cjs.dev.js +25 -27
- package/core/dist/commercetools-frontend-cookie-consent-core.cjs.prod.js +25 -27
- package/core/dist/commercetools-frontend-cookie-consent-core.esm.js +25 -27
- package/package.json +23 -16
- package/react/dist/commercetools-frontend-cookie-consent-react.cjs.dev.js +340 -358
- package/react/dist/commercetools-frontend-cookie-consent-react.cjs.prod.js +326 -350
- package/react/dist/commercetools-frontend-cookie-consent-react.esm.js +341 -359
|
@@ -39,47 +39,45 @@ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInsta
|
|
|
39
39
|
var _context2;
|
|
40
40
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
41
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context10, _context11; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
42
|
-
|
|
42
|
+
const COOKIE_CONSENT_GROUPS = {
|
|
43
43
|
essentialCookies: 'C0001',
|
|
44
44
|
performanceCookies: 'C0002',
|
|
45
45
|
functionalCookies: 'C0003',
|
|
46
46
|
targetingCookies: 'C0004',
|
|
47
47
|
socialMediaCookies: 'C0005'
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
const CONSENT_COOKIE_NAME = 'OptanonConsent';
|
|
50
50
|
function getRawConsentCookie() {
|
|
51
51
|
var _context;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CONSENT_COOKIE_NAME;
|
|
53
|
+
const escapedCookies = decodeURIComponent(document.cookie);
|
|
54
|
+
const consentCookie = _findInstanceProperty__default["default"](_context = escapedCookies.split('; ')).call(_context, rawCookie => {
|
|
55
|
+
const _rawCookie$split = rawCookie.split('='),
|
|
56
56
|
_rawCookie$split2 = _slicedToArray(_rawCookie$split, 1),
|
|
57
57
|
cookieName = _rawCookie$split2[0];
|
|
58
58
|
return cookieName === name;
|
|
59
59
|
});
|
|
60
60
|
return consentCookie;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
return [consentGroup, false];
|
|
64
|
-
}));
|
|
62
|
+
const defaultConsentGroups = _Object$fromEntries__default["default"](_mapInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](COOKIE_CONSENT_GROUPS)).call(_context2, consentGroup => [consentGroup, false]));
|
|
65
63
|
function getParsedConsentCookieGroups() {
|
|
66
64
|
var _context3;
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
let cookieValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getRawConsentCookie();
|
|
66
|
+
let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
69
67
|
skipConsent = _ref.skipConsent;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
let parsedConsentCookieGroups = {};
|
|
69
|
+
const encodedConsentGroupToConsentGroup = _Object$fromEntries__default["default"](_mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](COOKIE_CONSENT_GROUPS)).call(_context3, _ref2 => {
|
|
70
|
+
let _ref3 = _slicedToArray(_ref2, 2),
|
|
73
71
|
encodedConsentGroupName = _ref3[0],
|
|
74
72
|
decodedConsentGroupName = _ref3[1];
|
|
75
73
|
return [decodedConsentGroupName, encodedConsentGroupName];
|
|
76
74
|
}));
|
|
77
75
|
try {
|
|
78
76
|
var _context4;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const parsedConsentCookieValue = new _URLSearchParams__default["default"](cookieValue);
|
|
78
|
+
const rawConsentCookieGroups = parsedConsentCookieValue.get('groups');
|
|
79
|
+
const parsedConsentCookieGroupEntries = rawConsentCookieGroups && _mapInstanceProperty__default["default"](_context4 = rawConsentCookieGroups.split(',')).call(_context4, consentGroup => {
|
|
80
|
+
const _consentGroup$split = consentGroup.split(':'),
|
|
83
81
|
_consentGroup$split2 = _slicedToArray(_consentGroup$split, 2),
|
|
84
82
|
encodedConsentGroupName = _consentGroup$split2[0],
|
|
85
83
|
consentGroupValue = _consentGroup$split2[1];
|
|
@@ -99,12 +97,12 @@ function generateUuid(prefix) {
|
|
|
99
97
|
}
|
|
100
98
|
function generateEncodedConsentGroups(consentGroups) {
|
|
101
99
|
var _context5, _context6;
|
|
102
|
-
return _filterInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = _Object$entries__default["default"](consentGroups)).call(_context6,
|
|
100
|
+
return _filterInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = _Object$entries__default["default"](consentGroups)).call(_context6, _ref4 => {
|
|
103
101
|
var _context7;
|
|
104
|
-
|
|
102
|
+
let _ref5 = _slicedToArray(_ref4, 2),
|
|
105
103
|
consentGroupName = _ref5[0],
|
|
106
104
|
consentGroupValue = _ref5[1];
|
|
107
|
-
|
|
105
|
+
const encodedConsentGroup = COOKIE_CONSENT_GROUPS[consentGroupName];
|
|
108
106
|
if (!encodedConsentGroup) {
|
|
109
107
|
return null;
|
|
110
108
|
}
|
|
@@ -112,9 +110,9 @@ function generateEncodedConsentGroups(consentGroups) {
|
|
|
112
110
|
})).call(_context5, Boolean).join(',');
|
|
113
111
|
}
|
|
114
112
|
function generateConsentCookie(consentGroups) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
const existingConsentGroups = getParsedConsentCookieGroups();
|
|
114
|
+
const encodedConsentGroups = generateEncodedConsentGroups(_objectSpread(_objectSpread({}, existingConsentGroups), consentGroups));
|
|
115
|
+
const consentValues = {
|
|
118
116
|
isGpcEnabled: '0',
|
|
119
117
|
datestamp: new Date().toString(),
|
|
120
118
|
version: '202209.1.0',
|
|
@@ -126,13 +124,13 @@ function generateConsentCookie(consentGroups) {
|
|
|
126
124
|
groups: encodedConsentGroups,
|
|
127
125
|
AwaitingReconsent: 'false'
|
|
128
126
|
};
|
|
129
|
-
|
|
127
|
+
const consentCookieValue = new _URLSearchParams__default["default"](consentValues);
|
|
130
128
|
return consentCookieValue.toString();
|
|
131
129
|
}
|
|
132
130
|
function setConsentCookie(consentGroups) {
|
|
133
131
|
var _context8, _context9;
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
let domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.commercetools.com';
|
|
133
|
+
const expiresAt = new Date();
|
|
136
134
|
expiresAt.setFullYear(expiresAt.getFullYear() + 11);
|
|
137
135
|
document.cookie = _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "".concat(CONSENT_COOKIE_NAME, "=").concat(generateConsentCookie(consentGroups), "; domain=")).call(_context9, domain, "; expires=")).call(_context8, expiresAt.toUTCString(), "; SameSite=Lax; path=/; ");
|
|
138
136
|
}
|
|
@@ -39,47 +39,45 @@ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInsta
|
|
|
39
39
|
var _context2;
|
|
40
40
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
41
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context10, _context11; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
42
|
-
|
|
42
|
+
const COOKIE_CONSENT_GROUPS = {
|
|
43
43
|
essentialCookies: 'C0001',
|
|
44
44
|
performanceCookies: 'C0002',
|
|
45
45
|
functionalCookies: 'C0003',
|
|
46
46
|
targetingCookies: 'C0004',
|
|
47
47
|
socialMediaCookies: 'C0005'
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
const CONSENT_COOKIE_NAME = 'OptanonConsent';
|
|
50
50
|
function getRawConsentCookie() {
|
|
51
51
|
var _context;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CONSENT_COOKIE_NAME;
|
|
53
|
+
const escapedCookies = decodeURIComponent(document.cookie);
|
|
54
|
+
const consentCookie = _findInstanceProperty__default["default"](_context = escapedCookies.split('; ')).call(_context, rawCookie => {
|
|
55
|
+
const _rawCookie$split = rawCookie.split('='),
|
|
56
56
|
_rawCookie$split2 = _slicedToArray(_rawCookie$split, 1),
|
|
57
57
|
cookieName = _rawCookie$split2[0];
|
|
58
58
|
return cookieName === name;
|
|
59
59
|
});
|
|
60
60
|
return consentCookie;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
return [consentGroup, false];
|
|
64
|
-
}));
|
|
62
|
+
const defaultConsentGroups = _Object$fromEntries__default["default"](_mapInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](COOKIE_CONSENT_GROUPS)).call(_context2, consentGroup => [consentGroup, false]));
|
|
65
63
|
function getParsedConsentCookieGroups() {
|
|
66
64
|
var _context3;
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
let cookieValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getRawConsentCookie();
|
|
66
|
+
let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
69
67
|
skipConsent = _ref.skipConsent;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
let parsedConsentCookieGroups = {};
|
|
69
|
+
const encodedConsentGroupToConsentGroup = _Object$fromEntries__default["default"](_mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](COOKIE_CONSENT_GROUPS)).call(_context3, _ref2 => {
|
|
70
|
+
let _ref3 = _slicedToArray(_ref2, 2),
|
|
73
71
|
encodedConsentGroupName = _ref3[0],
|
|
74
72
|
decodedConsentGroupName = _ref3[1];
|
|
75
73
|
return [decodedConsentGroupName, encodedConsentGroupName];
|
|
76
74
|
}));
|
|
77
75
|
try {
|
|
78
76
|
var _context4;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const parsedConsentCookieValue = new _URLSearchParams__default["default"](cookieValue);
|
|
78
|
+
const rawConsentCookieGroups = parsedConsentCookieValue.get('groups');
|
|
79
|
+
const parsedConsentCookieGroupEntries = rawConsentCookieGroups && _mapInstanceProperty__default["default"](_context4 = rawConsentCookieGroups.split(',')).call(_context4, consentGroup => {
|
|
80
|
+
const _consentGroup$split = consentGroup.split(':'),
|
|
83
81
|
_consentGroup$split2 = _slicedToArray(_consentGroup$split, 2),
|
|
84
82
|
encodedConsentGroupName = _consentGroup$split2[0],
|
|
85
83
|
consentGroupValue = _consentGroup$split2[1];
|
|
@@ -99,12 +97,12 @@ function generateUuid(prefix) {
|
|
|
99
97
|
}
|
|
100
98
|
function generateEncodedConsentGroups(consentGroups) {
|
|
101
99
|
var _context5, _context6;
|
|
102
|
-
return _filterInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = _Object$entries__default["default"](consentGroups)).call(_context6,
|
|
100
|
+
return _filterInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = _Object$entries__default["default"](consentGroups)).call(_context6, _ref4 => {
|
|
103
101
|
var _context7;
|
|
104
|
-
|
|
102
|
+
let _ref5 = _slicedToArray(_ref4, 2),
|
|
105
103
|
consentGroupName = _ref5[0],
|
|
106
104
|
consentGroupValue = _ref5[1];
|
|
107
|
-
|
|
105
|
+
const encodedConsentGroup = COOKIE_CONSENT_GROUPS[consentGroupName];
|
|
108
106
|
if (!encodedConsentGroup) {
|
|
109
107
|
return null;
|
|
110
108
|
}
|
|
@@ -112,9 +110,9 @@ function generateEncodedConsentGroups(consentGroups) {
|
|
|
112
110
|
})).call(_context5, Boolean).join(',');
|
|
113
111
|
}
|
|
114
112
|
function generateConsentCookie(consentGroups) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
const existingConsentGroups = getParsedConsentCookieGroups();
|
|
114
|
+
const encodedConsentGroups = generateEncodedConsentGroups(_objectSpread(_objectSpread({}, existingConsentGroups), consentGroups));
|
|
115
|
+
const consentValues = {
|
|
118
116
|
isGpcEnabled: '0',
|
|
119
117
|
datestamp: new Date().toString(),
|
|
120
118
|
version: '202209.1.0',
|
|
@@ -126,13 +124,13 @@ function generateConsentCookie(consentGroups) {
|
|
|
126
124
|
groups: encodedConsentGroups,
|
|
127
125
|
AwaitingReconsent: 'false'
|
|
128
126
|
};
|
|
129
|
-
|
|
127
|
+
const consentCookieValue = new _URLSearchParams__default["default"](consentValues);
|
|
130
128
|
return consentCookieValue.toString();
|
|
131
129
|
}
|
|
132
130
|
function setConsentCookie(consentGroups) {
|
|
133
131
|
var _context8, _context9;
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
let domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.commercetools.com';
|
|
133
|
+
const expiresAt = new Date();
|
|
136
134
|
expiresAt.setFullYear(expiresAt.getFullYear() + 11);
|
|
137
135
|
document.cookie = _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "".concat(CONSENT_COOKIE_NAME, "=").concat(generateConsentCookie(consentGroups), "; domain=")).call(_context9, domain, "; expires=")).call(_context8, expiresAt.toUTCString(), "; SameSite=Lax; path=/; ");
|
|
138
136
|
}
|
|
@@ -18,47 +18,45 @@ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
|
|
|
18
18
|
var _context2;
|
|
19
19
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context10, _context11; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
|
|
21
|
+
const COOKIE_CONSENT_GROUPS = {
|
|
22
22
|
essentialCookies: 'C0001',
|
|
23
23
|
performanceCookies: 'C0002',
|
|
24
24
|
functionalCookies: 'C0003',
|
|
25
25
|
targetingCookies: 'C0004',
|
|
26
26
|
socialMediaCookies: 'C0005'
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
const CONSENT_COOKIE_NAME = 'OptanonConsent';
|
|
29
29
|
function getRawConsentCookie() {
|
|
30
30
|
var _context;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CONSENT_COOKIE_NAME;
|
|
32
|
+
const escapedCookies = decodeURIComponent(document.cookie);
|
|
33
|
+
const consentCookie = _findInstanceProperty(_context = escapedCookies.split('; ')).call(_context, rawCookie => {
|
|
34
|
+
const _rawCookie$split = rawCookie.split('='),
|
|
35
35
|
_rawCookie$split2 = _slicedToArray(_rawCookie$split, 1),
|
|
36
36
|
cookieName = _rawCookie$split2[0];
|
|
37
37
|
return cookieName === name;
|
|
38
38
|
});
|
|
39
39
|
return consentCookie;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
return [consentGroup, false];
|
|
43
|
-
}));
|
|
41
|
+
const defaultConsentGroups = _Object$fromEntries(_mapInstanceProperty(_context2 = _Object$keys(COOKIE_CONSENT_GROUPS)).call(_context2, consentGroup => [consentGroup, false]));
|
|
44
42
|
function getParsedConsentCookieGroups() {
|
|
45
43
|
var _context3;
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
let cookieValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getRawConsentCookie();
|
|
45
|
+
let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
48
46
|
skipConsent = _ref.skipConsent;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
let parsedConsentCookieGroups = {};
|
|
48
|
+
const encodedConsentGroupToConsentGroup = _Object$fromEntries(_mapInstanceProperty(_context3 = _Object$entries(COOKIE_CONSENT_GROUPS)).call(_context3, _ref2 => {
|
|
49
|
+
let _ref3 = _slicedToArray(_ref2, 2),
|
|
52
50
|
encodedConsentGroupName = _ref3[0],
|
|
53
51
|
decodedConsentGroupName = _ref3[1];
|
|
54
52
|
return [decodedConsentGroupName, encodedConsentGroupName];
|
|
55
53
|
}));
|
|
56
54
|
try {
|
|
57
55
|
var _context4;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const parsedConsentCookieValue = new _URLSearchParams(cookieValue);
|
|
57
|
+
const rawConsentCookieGroups = parsedConsentCookieValue.get('groups');
|
|
58
|
+
const parsedConsentCookieGroupEntries = rawConsentCookieGroups && _mapInstanceProperty(_context4 = rawConsentCookieGroups.split(',')).call(_context4, consentGroup => {
|
|
59
|
+
const _consentGroup$split = consentGroup.split(':'),
|
|
62
60
|
_consentGroup$split2 = _slicedToArray(_consentGroup$split, 2),
|
|
63
61
|
encodedConsentGroupName = _consentGroup$split2[0],
|
|
64
62
|
consentGroupValue = _consentGroup$split2[1];
|
|
@@ -78,12 +76,12 @@ function generateUuid(prefix) {
|
|
|
78
76
|
}
|
|
79
77
|
function generateEncodedConsentGroups(consentGroups) {
|
|
80
78
|
var _context5, _context6;
|
|
81
|
-
return _filterInstanceProperty(_context5 = _mapInstanceProperty(_context6 = _Object$entries(consentGroups)).call(_context6,
|
|
79
|
+
return _filterInstanceProperty(_context5 = _mapInstanceProperty(_context6 = _Object$entries(consentGroups)).call(_context6, _ref4 => {
|
|
82
80
|
var _context7;
|
|
83
|
-
|
|
81
|
+
let _ref5 = _slicedToArray(_ref4, 2),
|
|
84
82
|
consentGroupName = _ref5[0],
|
|
85
83
|
consentGroupValue = _ref5[1];
|
|
86
|
-
|
|
84
|
+
const encodedConsentGroup = COOKIE_CONSENT_GROUPS[consentGroupName];
|
|
87
85
|
if (!encodedConsentGroup) {
|
|
88
86
|
return null;
|
|
89
87
|
}
|
|
@@ -91,9 +89,9 @@ function generateEncodedConsentGroups(consentGroups) {
|
|
|
91
89
|
})).call(_context5, Boolean).join(',');
|
|
92
90
|
}
|
|
93
91
|
function generateConsentCookie(consentGroups) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
const existingConsentGroups = getParsedConsentCookieGroups();
|
|
93
|
+
const encodedConsentGroups = generateEncodedConsentGroups(_objectSpread(_objectSpread({}, existingConsentGroups), consentGroups));
|
|
94
|
+
const consentValues = {
|
|
97
95
|
isGpcEnabled: '0',
|
|
98
96
|
datestamp: new Date().toString(),
|
|
99
97
|
version: '202209.1.0',
|
|
@@ -105,13 +103,13 @@ function generateConsentCookie(consentGroups) {
|
|
|
105
103
|
groups: encodedConsentGroups,
|
|
106
104
|
AwaitingReconsent: 'false'
|
|
107
105
|
};
|
|
108
|
-
|
|
106
|
+
const consentCookieValue = new _URLSearchParams(consentValues);
|
|
109
107
|
return consentCookieValue.toString();
|
|
110
108
|
}
|
|
111
109
|
function setConsentCookie(consentGroups) {
|
|
112
110
|
var _context8, _context9;
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
let domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.commercetools.com';
|
|
112
|
+
const expiresAt = new Date();
|
|
115
113
|
expiresAt.setFullYear(expiresAt.getFullYear() + 11);
|
|
116
114
|
document.cookie = _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = "".concat(CONSENT_COOKIE_NAME, "=").concat(generateConsentCookie(consentGroups), "; domain=")).call(_context9, domain, "; expires=")).call(_context8, expiresAt.toUTCString(), "; SameSite=Lax; path=/; ");
|
|
117
115
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/cookie-consent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A package integrating with OneTrust cookie consent",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/commercetools-frontend-cookie-consent.cjs.js",
|
|
@@ -13,30 +13,34 @@
|
|
|
13
13
|
"LICENSE",
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"typecheck": "tsc --noEmit"
|
|
18
|
-
},
|
|
19
16
|
"dependencies": {
|
|
17
|
+
"@babel/core": "^7.21.0",
|
|
20
18
|
"@babel/runtime": "^7.21.0",
|
|
21
19
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
22
|
-
"@commercetools-frontend/application-components": "^21.
|
|
23
|
-
"@commercetools-uikit/collapsible-panel": "^15.
|
|
24
|
-
"@commercetools-uikit/design-system": "^15.
|
|
25
|
-
"@commercetools-uikit/grid": "^15.
|
|
26
|
-
"@commercetools-uikit/link": "^15.
|
|
27
|
-
"@commercetools-uikit/primary-button": "^15.
|
|
28
|
-
"@commercetools-uikit/spacings": "^15.
|
|
29
|
-
"@commercetools-uikit/text": "^15.
|
|
30
|
-
"@commercetools-uikit/toggle-input": "^15.
|
|
31
|
-
"@emotion/react": "^11.10.6"
|
|
20
|
+
"@commercetools-frontend/application-components": "^21.24.1",
|
|
21
|
+
"@commercetools-uikit/collapsible-panel": "^15.14.0",
|
|
22
|
+
"@commercetools-uikit/design-system": "^15.14.0",
|
|
23
|
+
"@commercetools-uikit/grid": "^15.14.0",
|
|
24
|
+
"@commercetools-uikit/link": "^15.14.0",
|
|
25
|
+
"@commercetools-uikit/primary-button": "^15.14.0",
|
|
26
|
+
"@commercetools-uikit/spacings": "^15.14.0",
|
|
27
|
+
"@commercetools-uikit/text": "^15.14.0",
|
|
28
|
+
"@commercetools-uikit/toggle-input": "^15.14.0"
|
|
32
29
|
},
|
|
33
30
|
"devDependencies": {
|
|
34
|
-
"@
|
|
31
|
+
"@commercetools-frontend/application-shell": "21.24.1",
|
|
32
|
+
"@commercetools-frontend/application-shell-connectors": "21.24.1",
|
|
33
|
+
"@types/node": "18.15.10",
|
|
34
|
+
"@types/react": "17.0.54",
|
|
35
|
+
"@emotion/react": "11.10.6",
|
|
36
|
+
"react": "17.0.2",
|
|
37
|
+
"react-intl": "5.25.1",
|
|
35
38
|
"typescript": "4.9.5"
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
41
|
"@commercetools-frontend/application-shell": "21.x",
|
|
39
42
|
"@commercetools-frontend/application-shell-connectors": "21.x",
|
|
43
|
+
"@emotion/react": "11.x",
|
|
40
44
|
"react": "17.x",
|
|
41
45
|
"react-intl": "5.x"
|
|
42
46
|
},
|
|
@@ -48,5 +52,8 @@
|
|
|
48
52
|
"./core/index.ts",
|
|
49
53
|
"./react/index.ts"
|
|
50
54
|
]
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
51
58
|
}
|
|
52
|
-
}
|
|
59
|
+
}
|