@constructor-io/constructorio-client-javascript 2.49.1 → 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.
- package/lib/utils/helpers.js +20 -12
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/utils/helpers.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
212
|
+
var _url$pathname, _url$search, _url$search$split;
|
|
213
213
|
var url = new URL(urlString);
|
|
214
|
-
var paths =
|
|
215
|
-
var paramValues =
|
|
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
|
|
217
|
+
return (_param$split = param.split('=')) === null || _param$split === void 0 ? void 0 : _param$split[1];
|
|
218
218
|
});
|
|
219
|
-
PII_REGEX.forEach(function (
|
|
219
|
+
PII_REGEX.forEach(function (_ref3) {
|
|
220
|
+
var pattern = _ref3.pattern,
|
|
221
|
+
replaceWith = _ref3.replaceWith;
|
|
220
222
|
paths.forEach(function (path) {
|
|
221
|
-
|
|
223
|
+
var decodedPath = decodeURIComponent(path);
|
|
224
|
+
if (utils.containsPii(decodedPath, pattern)) {
|
|
225
|
+
obfuscatedUrl = obfuscatedUrl.replaceAll(path, replaceWith);
|
|
226
|
+
}
|
|
222
227
|
});
|
|
223
|
-
paramValues.forEach(function (
|
|
224
|
-
|
|
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