@constructor-io/constructorio-client-javascript 2.49.0 → 2.49.2

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.
@@ -15,7 +15,8 @@ var Recommendations = require('./modules/recommendations');
15
15
  var Tracker = require('./modules/tracker');
16
16
  var EventDispatcher = require('./utils/event-dispatcher');
17
17
  var helpers = require('./utils/helpers');
18
- var packageVersion = require('./version');
18
+ var _require = require('./version'),
19
+ packageVersion = _require["default"];
19
20
  var Quizzes = require('./modules/quizzes');
20
21
  var Assistant = require('./modules/assistant');
21
22
 
@@ -8,14 +8,14 @@ var store = require('./store');
8
8
  var purchaseEventStorageKey = '_constructorio_purchase_order_ids';
9
9
  var PII_REGEX = [{
10
10
  pattern: /[\w\-+\\.]+@([\w-]+\.)+[\w-]{2,4}/,
11
- replaceBy: '<email_omitted>'
11
+ replaceWith: '<email_omitted>'
12
12
  }, {
13
13
  pattern: /^(?:\+\d{11,12}|\+\d{1,3}\s\d{3}\s\d{3}\s\d{3,4}|\(\d{3}\)\d{7}|\(\d{3}\)\s\d{3}\s\d{4}|\(\d{3}\)\d{3}-\d{4}|\(\d{3}\)\s\d{3}-\d{4})$/,
14
- replaceBy: '<phone_omitted>'
14
+ replaceWith: '<phone_omitted>'
15
15
  }, {
16
16
  pattern: /^(?:4[0-9]{15}|(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$/,
17
17
  // Visa, Mastercard, Amex, Discover, JCB and Diners Club, regex source: https://www.regular-expressions.info/creditcard.html
18
- replaceBy: '<credit_omitted>'
18
+ replaceWith: '<credit_omitted>'
19
19
  }
20
20
  // Add more PII REGEX
21
21
  ];
@@ -24,7 +24,7 @@ var utils = {
24
24
  trimNonBreakingSpaces: function trimNonBreakingSpaces(string) {
25
25
  return string.replace(/\s/g, ' ').trim();
26
26
  },
27
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
27
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986
28
28
  encodeURIComponentRFC3986: function encodeURIComponentRFC3986(string) {
29
29
  return encodeURIComponent(string).replace(/[!'()*]/g, function (c) {
30
30
  return "%".concat(c.charCodeAt(0).toString(16).toUpperCase());
@@ -209,19 +209,27 @@ var utils = {
209
209
  obfuscatePiiRequest: function obfuscatePiiRequest(urlString) {
210
210
  var obfuscatedUrl = urlString;
211
211
  try {
212
- var _decodeURI, _decodeURIComponent;
212
+ var _url$pathname, _url$search, _url$search$split;
213
213
  var url = new URL(urlString);
214
- var paths = (_decodeURI = decodeURI(url === null || url === void 0 ? void 0 : url.pathname)) === null || _decodeURI === void 0 ? void 0 : _decodeURI.split('/');
215
- var paramValues = (_decodeURIComponent = decodeURIComponent(url === null || url === void 0 ? void 0 : url.search)) === null || _decodeURIComponent === void 0 ? void 0 : _decodeURIComponent.split('&').map(function (param) {
214
+ var paths = url === null || url === void 0 ? void 0 : (_url$pathname = url.pathname) === null || _url$pathname === void 0 ? void 0 : _url$pathname.split('/');
215
+ var paramValues = url === null || url === void 0 ? void 0 : (_url$search = url.search) === null || _url$search === void 0 ? void 0 : (_url$search$split = _url$search.split('&')) === null || _url$search$split === void 0 ? void 0 : _url$search$split.map(function (param) {
216
216
  var _param$split;
217
- return param === null || param === void 0 ? void 0 : (_param$split = param.split('=')) === null || _param$split === void 0 ? void 0 : _param$split[1];
217
+ return (_param$split = param.split('=')) === null || _param$split === void 0 ? void 0 : _param$split[1];
218
218
  });
219
- PII_REGEX.forEach(function (regex) {
219
+ PII_REGEX.forEach(function (_ref3) {
220
+ var pattern = _ref3.pattern,
221
+ replaceWith = _ref3.replaceWith;
220
222
  paths.forEach(function (path) {
221
- if (utils.containsPii(path, regex.pattern)) obfuscatedUrl = obfuscatedUrl.replaceAll(path, regex.replaceBy);
223
+ var decodedPath = decodeURIComponent(path);
224
+ if (utils.containsPii(decodedPath, pattern)) {
225
+ obfuscatedUrl = obfuscatedUrl.replaceAll(path, replaceWith);
226
+ }
222
227
  });
223
- paramValues.forEach(function (param) {
224
- if (utils.containsPii(param, regex.pattern)) obfuscatedUrl = obfuscatedUrl.replaceAll(param, regex.replaceBy);
228
+ paramValues.forEach(function (paramValue) {
229
+ var decodedParamValue = decodeURIComponent(paramValue);
230
+ if (utils.containsPii(decodedParamValue, pattern)) {
231
+ obfuscatedUrl = obfuscatedUrl.replaceAll(decodedParamValue, replaceWith);
232
+ }
225
233
  });
226
234
  });
227
235
  } catch (e) {
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = '2.49.0';
7
+ var _default = '2.49.2';
8
8
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.49.0",
3
+ "version": "2.49.2",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",