@commercetools-frontend/cookie-consent 2.1.9 → 2.2.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/README.md +1 -1
- package/core/dist/commercetools-frontend-cookie-consent-core.cjs.dev.js +8 -4
- package/core/dist/commercetools-frontend-cookie-consent-core.cjs.prod.js +8 -4
- package/core/dist/commercetools-frontend-cookie-consent-core.esm.js +7 -4
- package/package.json +15 -15
- package/react/dist/commercetools-frontend-cookie-consent-react.cjs.dev.js +107 -118
- package/react/dist/commercetools-frontend-cookie-consent-react.cjs.prod.js +100 -111
- package/react/dist/commercetools-frontend-cookie-consent-react.esm.js +107 -118
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ const { givenConsent } = useCookieConsent('performanceCookies', {
|
|
|
81
81
|
|
|
82
82
|
The preferred value of `skipConsent` can be determined for instance by an environment variable and read using the `useSkipCookieConsent` hook.
|
|
83
83
|
|
|
84
|
-
The resulting `givenConsent` value is a boolean which can be passed to any software needing consent for instance FullStory
|
|
84
|
+
The resulting `givenConsent` value is a boolean which can be passed to any software needing consent for instance FullStory. A combination of `@commercetools-frontend/cookie-consent` and `@commercetools-frontend/fullstory` could look like this:
|
|
85
85
|
|
|
86
86
|
```js
|
|
87
87
|
const { givenConsent } = useCookieConsent('performanceCookies');
|
|
@@ -17,6 +17,7 @@ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
|
17
17
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
18
18
|
var _URLSearchParams = require('@babel/runtime-corejs3/core-js-stable/url-search-params');
|
|
19
19
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
20
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
20
21
|
|
|
21
22
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
23
|
|
|
@@ -33,10 +34,11 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
33
34
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
34
35
|
var _URLSearchParams__default = /*#__PURE__*/_interopDefault(_URLSearchParams);
|
|
35
36
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
37
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
36
38
|
|
|
37
39
|
var _context2;
|
|
38
40
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
39
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
41
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context11, _context12; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(t), !0)).call(_context11, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context12 = ownKeys(Object(t))).call(_context12, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
40
42
|
const COOKIE_CONSENT_GROUPS = {
|
|
41
43
|
essentialCookies: 'C0001',
|
|
42
44
|
performanceCookies: 'C0002',
|
|
@@ -91,11 +93,12 @@ function getParsedConsentCookieGroups() {
|
|
|
91
93
|
* This implementation is good enough for the purposes here.
|
|
92
94
|
*/
|
|
93
95
|
function generateUuid(prefix) {
|
|
94
|
-
return prefix ? ((Number(prefix) ^ Math.random() * 16) >> Number(prefix) / 4).toString(16) :
|
|
96
|
+
return prefix ? ((Number(prefix) ^ Math.random() * 16) >> Number(prefix) / 4).toString(16) : "".concat(1e7, "-", 1e3, "-", 4e3, "-", 8e3, "-", 1e11).replace(/[018]/g, generateUuid);
|
|
95
97
|
}
|
|
96
98
|
function generateEncodedConsentGroups(consentGroups) {
|
|
97
99
|
var _context5, _context6;
|
|
98
100
|
return _filterInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = _Object$entries__default["default"](consentGroups)).call(_context6, _ref4 => {
|
|
101
|
+
var _context7;
|
|
99
102
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
100
103
|
consentGroupName = _ref5[0],
|
|
101
104
|
consentGroupValue = _ref5[1];
|
|
@@ -103,7 +106,7 @@ function generateEncodedConsentGroups(consentGroups) {
|
|
|
103
106
|
if (!encodedConsentGroup) {
|
|
104
107
|
return null;
|
|
105
108
|
}
|
|
106
|
-
return
|
|
109
|
+
return _concatInstanceProperty__default["default"](_context7 = "".concat(encodedConsentGroup, ":")).call(_context7, consentGroupValue && '1' || '0');
|
|
107
110
|
})).call(_context5, Boolean).join(',');
|
|
108
111
|
}
|
|
109
112
|
function generateConsentCookie(consentGroups) {
|
|
@@ -125,6 +128,7 @@ function generateConsentCookie(consentGroups) {
|
|
|
125
128
|
return consentCookieValue.toString();
|
|
126
129
|
}
|
|
127
130
|
function setConsentCookie(consentGroups, domain) {
|
|
131
|
+
var _context8, _context9, _context10;
|
|
128
132
|
const expiresAt = new Date();
|
|
129
133
|
expiresAt.setFullYear(expiresAt.getFullYear() + 11);
|
|
130
134
|
let consentCookieDomain;
|
|
@@ -141,7 +145,7 @@ function setConsentCookie(consentGroups, domain) {
|
|
|
141
145
|
} else {
|
|
142
146
|
consentCookieDomain = '.commercetools.com';
|
|
143
147
|
}
|
|
144
|
-
document.cookie =
|
|
148
|
+
document.cookie = _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = _concatInstanceProperty__default["default"](_context10 = "".concat(CONSENT_COOKIE_NAME, "=")).call(_context10, generateConsentCookie(consentGroups), "; domain=")).call(_context9, consentCookieDomain, "; expires=")).call(_context8, expiresAt.toUTCString(), "; SameSite=Lax; path=/; ");
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
exports.CONSENT_COOKIE_NAME = CONSENT_COOKIE_NAME;
|
|
@@ -17,6 +17,7 @@ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
|
17
17
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
18
18
|
var _URLSearchParams = require('@babel/runtime-corejs3/core-js-stable/url-search-params');
|
|
19
19
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
20
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
20
21
|
|
|
21
22
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
23
|
|
|
@@ -33,10 +34,11 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
33
34
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
34
35
|
var _URLSearchParams__default = /*#__PURE__*/_interopDefault(_URLSearchParams);
|
|
35
36
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
37
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
36
38
|
|
|
37
39
|
var _context2;
|
|
38
40
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
39
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
41
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context11, _context12; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(t), !0)).call(_context11, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context12 = ownKeys(Object(t))).call(_context12, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
40
42
|
const COOKIE_CONSENT_GROUPS = {
|
|
41
43
|
essentialCookies: 'C0001',
|
|
42
44
|
performanceCookies: 'C0002',
|
|
@@ -91,11 +93,12 @@ function getParsedConsentCookieGroups() {
|
|
|
91
93
|
* This implementation is good enough for the purposes here.
|
|
92
94
|
*/
|
|
93
95
|
function generateUuid(prefix) {
|
|
94
|
-
return prefix ? ((Number(prefix) ^ Math.random() * 16) >> Number(prefix) / 4).toString(16) :
|
|
96
|
+
return prefix ? ((Number(prefix) ^ Math.random() * 16) >> Number(prefix) / 4).toString(16) : "".concat(1e7, "-", 1e3, "-", 4e3, "-", 8e3, "-", 1e11).replace(/[018]/g, generateUuid);
|
|
95
97
|
}
|
|
96
98
|
function generateEncodedConsentGroups(consentGroups) {
|
|
97
99
|
var _context5, _context6;
|
|
98
100
|
return _filterInstanceProperty__default["default"](_context5 = _mapInstanceProperty__default["default"](_context6 = _Object$entries__default["default"](consentGroups)).call(_context6, _ref4 => {
|
|
101
|
+
var _context7;
|
|
99
102
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
100
103
|
consentGroupName = _ref5[0],
|
|
101
104
|
consentGroupValue = _ref5[1];
|
|
@@ -103,7 +106,7 @@ function generateEncodedConsentGroups(consentGroups) {
|
|
|
103
106
|
if (!encodedConsentGroup) {
|
|
104
107
|
return null;
|
|
105
108
|
}
|
|
106
|
-
return
|
|
109
|
+
return _concatInstanceProperty__default["default"](_context7 = "".concat(encodedConsentGroup, ":")).call(_context7, consentGroupValue && '1' || '0');
|
|
107
110
|
})).call(_context5, Boolean).join(',');
|
|
108
111
|
}
|
|
109
112
|
function generateConsentCookie(consentGroups) {
|
|
@@ -125,6 +128,7 @@ function generateConsentCookie(consentGroups) {
|
|
|
125
128
|
return consentCookieValue.toString();
|
|
126
129
|
}
|
|
127
130
|
function setConsentCookie(consentGroups, domain) {
|
|
131
|
+
var _context8, _context9, _context10;
|
|
128
132
|
const expiresAt = new Date();
|
|
129
133
|
expiresAt.setFullYear(expiresAt.getFullYear() + 11);
|
|
130
134
|
let consentCookieDomain;
|
|
@@ -141,7 +145,7 @@ function setConsentCookie(consentGroups, domain) {
|
|
|
141
145
|
} else {
|
|
142
146
|
consentCookieDomain = '.commercetools.com';
|
|
143
147
|
}
|
|
144
|
-
document.cookie =
|
|
148
|
+
document.cookie = _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = _concatInstanceProperty__default["default"](_context10 = "".concat(CONSENT_COOKIE_NAME, "=")).call(_context10, generateConsentCookie(consentGroups), "; domain=")).call(_context9, consentCookieDomain, "; expires=")).call(_context8, expiresAt.toUTCString(), "; SameSite=Lax; path=/; ");
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
exports.CONSENT_COOKIE_NAME = CONSENT_COOKIE_NAME;
|
|
@@ -13,10 +13,11 @@ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
|
13
13
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
14
14
|
import _URLSearchParams from '@babel/runtime-corejs3/core-js-stable/url-search-params';
|
|
15
15
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
16
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
16
17
|
|
|
17
18
|
var _context2;
|
|
18
19
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context11, _context12; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context11 = ownKeys(Object(t), !0)).call(_context11, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context12 = ownKeys(Object(t))).call(_context12, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
21
|
const COOKIE_CONSENT_GROUPS = {
|
|
21
22
|
essentialCookies: 'C0001',
|
|
22
23
|
performanceCookies: 'C0002',
|
|
@@ -71,11 +72,12 @@ function getParsedConsentCookieGroups() {
|
|
|
71
72
|
* This implementation is good enough for the purposes here.
|
|
72
73
|
*/
|
|
73
74
|
function generateUuid(prefix) {
|
|
74
|
-
return prefix ? ((Number(prefix) ^ Math.random() * 16) >> Number(prefix) / 4).toString(16) :
|
|
75
|
+
return prefix ? ((Number(prefix) ^ Math.random() * 16) >> Number(prefix) / 4).toString(16) : "".concat(1e7, "-", 1e3, "-", 4e3, "-", 8e3, "-", 1e11).replace(/[018]/g, generateUuid);
|
|
75
76
|
}
|
|
76
77
|
function generateEncodedConsentGroups(consentGroups) {
|
|
77
78
|
var _context5, _context6;
|
|
78
79
|
return _filterInstanceProperty(_context5 = _mapInstanceProperty(_context6 = _Object$entries(consentGroups)).call(_context6, _ref4 => {
|
|
80
|
+
var _context7;
|
|
79
81
|
let _ref5 = _slicedToArray(_ref4, 2),
|
|
80
82
|
consentGroupName = _ref5[0],
|
|
81
83
|
consentGroupValue = _ref5[1];
|
|
@@ -83,7 +85,7 @@ function generateEncodedConsentGroups(consentGroups) {
|
|
|
83
85
|
if (!encodedConsentGroup) {
|
|
84
86
|
return null;
|
|
85
87
|
}
|
|
86
|
-
return
|
|
88
|
+
return _concatInstanceProperty(_context7 = "".concat(encodedConsentGroup, ":")).call(_context7, consentGroupValue && '1' || '0');
|
|
87
89
|
})).call(_context5, Boolean).join(',');
|
|
88
90
|
}
|
|
89
91
|
function generateConsentCookie(consentGroups) {
|
|
@@ -105,6 +107,7 @@ function generateConsentCookie(consentGroups) {
|
|
|
105
107
|
return consentCookieValue.toString();
|
|
106
108
|
}
|
|
107
109
|
function setConsentCookie(consentGroups, domain) {
|
|
110
|
+
var _context8, _context9, _context10;
|
|
108
111
|
const expiresAt = new Date();
|
|
109
112
|
expiresAt.setFullYear(expiresAt.getFullYear() + 11);
|
|
110
113
|
let consentCookieDomain;
|
|
@@ -121,7 +124,7 @@ function setConsentCookie(consentGroups, domain) {
|
|
|
121
124
|
} else {
|
|
122
125
|
consentCookieDomain = '.commercetools.com';
|
|
123
126
|
}
|
|
124
|
-
document.cookie =
|
|
127
|
+
document.cookie = _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "".concat(CONSENT_COOKIE_NAME, "=")).call(_context10, generateConsentCookie(consentGroups), "; domain=")).call(_context9, consentCookieDomain, "; expires=")).call(_context8, expiresAt.toUTCString(), "; SameSite=Lax; path=/; ");
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
export { CONSENT_COOKIE_NAME, COOKIE_CONSENT_GROUPS, generateConsentCookie, getParsedConsentCookieGroups, getRawConsentCookie, setConsentCookie };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/cookie-consent",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A package integrating with OneTrust cookie consent",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,28 +22,28 @@
|
|
|
22
22
|
"@babel/core": "^7.22.11",
|
|
23
23
|
"@babel/runtime": "^7.21.0",
|
|
24
24
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
25
|
-
"@commercetools-frontend/application-components": "npm:@commercetools-frontend/application-components@^22.
|
|
26
|
-
"@commercetools-uikit/collapsible-panel": "npm:@commercetools-uikit/collapsible-panel@^19.
|
|
27
|
-
"@commercetools-uikit/design-system": "npm:@commercetools-uikit/design-system@^19.
|
|
28
|
-
"@commercetools-uikit/grid": "npm:@commercetools-uikit/grid@^19.
|
|
29
|
-
"@commercetools-uikit/link": "npm:@commercetools-uikit/link@^19.
|
|
30
|
-
"@commercetools-uikit/primary-button": "npm:@commercetools-uikit/primary-button@^19.
|
|
31
|
-
"@commercetools-uikit/spacings": "npm:@commercetools-uikit/spacings@^19.
|
|
32
|
-
"@commercetools-uikit/text": "npm:@commercetools-uikit/text@^19.
|
|
33
|
-
"@commercetools-uikit/toggle-input": "npm:@commercetools-uikit/toggle-input@^19.
|
|
25
|
+
"@commercetools-frontend/application-components": "npm:@commercetools-frontend/application-components@^22.23.3",
|
|
26
|
+
"@commercetools-uikit/collapsible-panel": "npm:@commercetools-uikit/collapsible-panel@^19.1.0",
|
|
27
|
+
"@commercetools-uikit/design-system": "npm:@commercetools-uikit/design-system@^19.1.0",
|
|
28
|
+
"@commercetools-uikit/grid": "npm:@commercetools-uikit/grid@^19.1.0",
|
|
29
|
+
"@commercetools-uikit/link": "npm:@commercetools-uikit/link@^19.1.0",
|
|
30
|
+
"@commercetools-uikit/primary-button": "npm:@commercetools-uikit/primary-button@^19.1.0",
|
|
31
|
+
"@commercetools-uikit/spacings": "npm:@commercetools-uikit/spacings@^19.1.0",
|
|
32
|
+
"@commercetools-uikit/text": "npm:@commercetools-uikit/text@^19.1.0",
|
|
33
|
+
"@commercetools-uikit/toggle-input": "npm:@commercetools-uikit/toggle-input@^19.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@commercetools-frontend/application-shell": "22.
|
|
37
|
-
"@commercetools-frontend/application-shell-connectors": "22.
|
|
36
|
+
"@commercetools-frontend/application-shell": "22.23.3",
|
|
37
|
+
"@commercetools-frontend/application-shell-connectors": "22.23.3",
|
|
38
38
|
"@emotion/react": "^11.11.1",
|
|
39
39
|
"@testing-library/react": "12.1.5",
|
|
40
40
|
"@testing-library/react-hooks": "8.0.1",
|
|
41
41
|
"@types/jest": "^29.5.2",
|
|
42
|
-
"@types/node": "20.12.
|
|
43
|
-
"@types/react": "17.0.
|
|
42
|
+
"@types/node": "20.12.7",
|
|
43
|
+
"@types/react": "17.0.80",
|
|
44
44
|
"@types/testing-library__jest-dom": "^5.14.6",
|
|
45
45
|
"react": "17.0.2",
|
|
46
|
-
"react-intl": "6.6.
|
|
46
|
+
"react-intl": "6.6.4",
|
|
47
47
|
"typescript": "5.2.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|