@amplitude/analytics-core 2.62.1 → 2.62.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAGzC,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAClD,eAAO,MAAM,SAAS,QAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAGzC,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAClD,eAAO,MAAM,SAAS,QAA2B,CAAC;AAIlD,eAAO,MAAM,WAAW,QAA4C,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,MAAM,GAAG,IAAI,+BAA8B,MAAM,EAAE,KAAQ,MAiCvG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,iCAAiC,MAAM,KAAK,MAAM,kBAAG,MAS7E,CAAC"}
|
|
@@ -7,7 +7,10 @@ exports.MASKED_TEXT_VALUE = '*****';
|
|
|
7
7
|
// Regex patterns for sensitive data
|
|
8
8
|
exports.CC_REGEX = /\b(?:\d[ -]*?){13,16}\b/;
|
|
9
9
|
exports.SSN_REGEX = /(\d{3}-?\d{2}-?\d{4})/g;
|
|
10
|
-
|
|
10
|
+
// [^\s@]+ stops at the next @. In a URL that leaves `@domain` after the first address.
|
|
11
|
+
// Continue through those @ segments so the leftover cannot slide into kept text
|
|
12
|
+
// when the long match is replaced with a short mask.
|
|
13
|
+
exports.EMAIL_REGEX = /[^\s@]+@[^\s@.]+\.[^\s@]+(?:@[^\s@]+)*/g;
|
|
11
14
|
/**
|
|
12
15
|
* Replaces sensitive strings (credit cards, SSNs, emails) and custom patterns with masked text
|
|
13
16
|
* @param text - The text to search for sensitive data
|
|
@@ -21,18 +24,25 @@ var replaceSensitiveString = function (text, additionalMaskTextPatterns) {
|
|
|
21
24
|
return '';
|
|
22
25
|
}
|
|
23
26
|
var result = text;
|
|
24
|
-
//
|
|
25
|
-
|
|
27
|
+
// CC_REGEX is not global: repeated `.test()` calls share lastIndex.
|
|
28
|
+
// A fresh global copy masks every card. One replace would leave later cards,
|
|
29
|
+
// and a card past the cutoff can then slide into the kept autocapture text.
|
|
30
|
+
result = result.replace(new RegExp(exports.CC_REGEX.source, 'g'), exports.MASKED_TEXT_VALUE);
|
|
26
31
|
// Check for social security number
|
|
27
32
|
result = result.replace(exports.SSN_REGEX, exports.MASKED_TEXT_VALUE);
|
|
28
33
|
// Check for email
|
|
29
34
|
result = result.replace(exports.EMAIL_REGEX, exports.MASKED_TEXT_VALUE);
|
|
30
35
|
try {
|
|
31
|
-
// Check for additional mask text patterns
|
|
36
|
+
// Check for additional mask text patterns. Every match is masked, not only the first.
|
|
37
|
+
// A later match can otherwise slide into the kept text once earlier matches shorten the prefix.
|
|
32
38
|
for (var additionalMaskTextPatterns_1 = tslib_1.__values(additionalMaskTextPatterns), additionalMaskTextPatterns_1_1 = additionalMaskTextPatterns_1.next(); !additionalMaskTextPatterns_1_1.done; additionalMaskTextPatterns_1_1 = additionalMaskTextPatterns_1.next()) {
|
|
33
39
|
var pattern = additionalMaskTextPatterns_1_1.value;
|
|
34
40
|
try {
|
|
35
|
-
|
|
41
|
+
var flags = pattern.flags.includes('g') ? pattern.flags : "".concat(pattern.flags, "g");
|
|
42
|
+
// Skip zero-length matches so a pattern like /x*/ does not insert a mask between characters.
|
|
43
|
+
result = result.replace(new RegExp(pattern.source, flags), function (match) {
|
|
44
|
+
return match.length > 0 ? exports.MASKED_TEXT_VALUE : match;
|
|
45
|
+
});
|
|
36
46
|
}
|
|
37
47
|
catch (_b) {
|
|
38
48
|
// ignore invalid pattern
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":";;;;AAAa,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAEzC,oCAAoC;AACvB,QAAA,QAAQ,GAAG,yBAAyB,CAAC;AACrC,QAAA,SAAS,GAAG,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":";;;;AAAa,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAEzC,oCAAoC;AACvB,QAAA,QAAQ,GAAG,yBAAyB,CAAC;AACrC,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAClD,uFAAuF;AACvF,gFAAgF;AAChF,qDAAqD;AACxC,QAAA,WAAW,GAAG,yCAAyC,CAAC;AAErE;;;;;GAKG;AACI,IAAM,sBAAsB,GAAG,UAAC,IAAmB,EAAE,0BAAyC;;IAAzC,2CAAA,EAAA,+BAAyC;IACnG,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,EAAE,CAAC;KACX;IAED,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,oEAAoE;IACpE,6EAA6E;IAC7E,4EAA4E;IAC5E,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,gBAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,yBAAiB,CAAC,CAAC;IAE7E,mCAAmC;IACnC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAS,EAAE,yBAAiB,CAAC,CAAC;IAEtD,kBAAkB;IAClB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAW,EAAE,yBAAiB,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-mask';\nexport const MASKED_TEXT_VALUE = '*****';\n\n// Regex patterns for sensitive data\nexport const CC_REGEX = /\\b(?:\\d[ -]*?){13,16}\\b/;\nexport const SSN_REGEX = /(\\d{3}-?\\d{2}-?\\d{4})/g;\n// [^\\s@]+ stops at the next @. In a URL that leaves `@domain` after the first address.\n// Continue through those @ segments so the leftover cannot slide into kept text\n// when the long match is replaced with a short mask.\nexport const EMAIL_REGEX = /[^\\s@]+@[^\\s@.]+\\.[^\\s@]+(?:@[^\\s@]+)*/g;\n\n/**\n * Replaces sensitive strings (credit cards, SSNs, emails) and custom patterns with masked text\n * @param text - The text to search for sensitive data\n * @param additionalMaskTextPatterns - Optional array of additional regex patterns to mask\n * @returns The text with sensitive data replaced by masked text\n */\nexport const replaceSensitiveString = (text: string | null, additionalMaskTextPatterns: RegExp[] = []): string => {\n if (typeof text !== 'string') {\n return '';\n }\n\n let result = text;\n\n // CC_REGEX is not global: repeated `.test()` calls share lastIndex.\n // A fresh global copy masks every card. One replace would leave later cards,\n // and a card past the cutoff can then slide into the kept autocapture text.\n result = result.replace(new RegExp(CC_REGEX.source, 'g'), MASKED_TEXT_VALUE);\n\n // Check for social security number\n result = result.replace(SSN_REGEX, MASKED_TEXT_VALUE);\n\n // Check for email\n result = result.replace(EMAIL_REGEX, MASKED_TEXT_VALUE);\n\n // Check for additional mask text patterns. Every match is masked, not only the first.\n // A later match can otherwise slide into the kept text once earlier matches shorten the prefix.\n for (const pattern of additionalMaskTextPatterns) {\n try {\n const flags = pattern.flags.includes('g') ? pattern.flags : `${pattern.flags}g`;\n // Skip zero-length matches so a pattern like /x*/ does not insert a mask between characters.\n result = result.replace(new RegExp(pattern.source, flags), (match) =>\n match.length > 0 ? MASKED_TEXT_VALUE : match,\n );\n } catch {\n // ignore invalid pattern\n }\n }\n\n return result;\n};\n\n/**\n * Gets the page title, checking if the title element has data-amp-mask attribute\n * @returns The page title, masked if the title element has data-amp-mask attribute\n */\nexport const getPageTitle = (parseTitleFunction?: (title: string) => string): string => {\n if (typeof document === 'undefined' || !document.title) {\n return '';\n }\n const titleElement = document.querySelector('title');\n if (titleElement && titleElement.hasAttribute(TEXT_MASK_ATTRIBUTE)) {\n return MASKED_TEXT_VALUE;\n }\n return parseTitleFunction ? parseTitleFunction(document.title) : document.title; // document.title is always synced to the first title element\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAGzC,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAClD,eAAO,MAAM,SAAS,QAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAGzC,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAClD,eAAO,MAAM,SAAS,QAA2B,CAAC;AAIlD,eAAO,MAAM,WAAW,QAA4C,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,MAAM,GAAG,IAAI,+BAA8B,MAAM,EAAE,KAAQ,MAiCvG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,iCAAiC,MAAM,KAAK,MAAM,kBAAG,MAS7E,CAAC"}
|
|
@@ -4,7 +4,10 @@ export var MASKED_TEXT_VALUE = '*****';
|
|
|
4
4
|
// Regex patterns for sensitive data
|
|
5
5
|
export var CC_REGEX = /\b(?:\d[ -]*?){13,16}\b/;
|
|
6
6
|
export var SSN_REGEX = /(\d{3}-?\d{2}-?\d{4})/g;
|
|
7
|
-
|
|
7
|
+
// [^\s@]+ stops at the next @. In a URL that leaves `@domain` after the first address.
|
|
8
|
+
// Continue through those @ segments so the leftover cannot slide into kept text
|
|
9
|
+
// when the long match is replaced with a short mask.
|
|
10
|
+
export var EMAIL_REGEX = /[^\s@]+@[^\s@.]+\.[^\s@]+(?:@[^\s@]+)*/g;
|
|
8
11
|
/**
|
|
9
12
|
* Replaces sensitive strings (credit cards, SSNs, emails) and custom patterns with masked text
|
|
10
13
|
* @param text - The text to search for sensitive data
|
|
@@ -18,18 +21,25 @@ export var replaceSensitiveString = function (text, additionalMaskTextPatterns)
|
|
|
18
21
|
return '';
|
|
19
22
|
}
|
|
20
23
|
var result = text;
|
|
21
|
-
//
|
|
22
|
-
|
|
24
|
+
// CC_REGEX is not global: repeated `.test()` calls share lastIndex.
|
|
25
|
+
// A fresh global copy masks every card. One replace would leave later cards,
|
|
26
|
+
// and a card past the cutoff can then slide into the kept autocapture text.
|
|
27
|
+
result = result.replace(new RegExp(CC_REGEX.source, 'g'), MASKED_TEXT_VALUE);
|
|
23
28
|
// Check for social security number
|
|
24
29
|
result = result.replace(SSN_REGEX, MASKED_TEXT_VALUE);
|
|
25
30
|
// Check for email
|
|
26
31
|
result = result.replace(EMAIL_REGEX, MASKED_TEXT_VALUE);
|
|
27
32
|
try {
|
|
28
|
-
// Check for additional mask text patterns
|
|
33
|
+
// Check for additional mask text patterns. Every match is masked, not only the first.
|
|
34
|
+
// A later match can otherwise slide into the kept text once earlier matches shorten the prefix.
|
|
29
35
|
for (var additionalMaskTextPatterns_1 = __values(additionalMaskTextPatterns), additionalMaskTextPatterns_1_1 = additionalMaskTextPatterns_1.next(); !additionalMaskTextPatterns_1_1.done; additionalMaskTextPatterns_1_1 = additionalMaskTextPatterns_1.next()) {
|
|
30
36
|
var pattern = additionalMaskTextPatterns_1_1.value;
|
|
31
37
|
try {
|
|
32
|
-
|
|
38
|
+
var flags = pattern.flags.includes('g') ? pattern.flags : "".concat(pattern.flags, "g");
|
|
39
|
+
// Skip zero-length matches so a pattern like /x*/ does not insert a mask between characters.
|
|
40
|
+
result = result.replace(new RegExp(pattern.source, flags), function (match) {
|
|
41
|
+
return match.length > 0 ? MASKED_TEXT_VALUE : match;
|
|
42
|
+
});
|
|
33
43
|
}
|
|
34
44
|
catch (_b) {
|
|
35
45
|
// ignore invalid pattern
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,IAAM,mBAAmB,GAAG,eAAe,CAAC;AACnD,MAAM,CAAC,IAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC,oCAAoC;AACpC,MAAM,CAAC,IAAM,QAAQ,GAAG,yBAAyB,CAAC;AAClD,MAAM,CAAC,IAAM,SAAS,GAAG,wBAAwB,CAAC;AAClD,MAAM,CAAC,IAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/plugins/helpers.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,IAAM,mBAAmB,GAAG,eAAe,CAAC;AACnD,MAAM,CAAC,IAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC,oCAAoC;AACpC,MAAM,CAAC,IAAM,QAAQ,GAAG,yBAAyB,CAAC;AAClD,MAAM,CAAC,IAAM,SAAS,GAAG,wBAAwB,CAAC;AAClD,uFAAuF;AACvF,gFAAgF;AAChF,qDAAqD;AACrD,MAAM,CAAC,IAAM,WAAW,GAAG,yCAAyC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,IAAM,sBAAsB,GAAG,UAAC,IAAmB,EAAE,0BAAyC;;IAAzC,2CAAA,EAAA,+BAAyC;IACnG,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,EAAE,CAAC;KACX;IAED,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,oEAAoE;IACpE,6EAA6E;IAC7E,4EAA4E;IAC5E,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAA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kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,6DAA6D;AAChJ,CAAC,CAAC","sourcesContent":["export const TEXT_MASK_ATTRIBUTE = 'data-amp-mask';\nexport const MASKED_TEXT_VALUE = '*****';\n\n// Regex patterns for sensitive data\nexport const CC_REGEX = /\\b(?:\\d[ -]*?){13,16}\\b/;\nexport const SSN_REGEX = /(\\d{3}-?\\d{2}-?\\d{4})/g;\n// [^\\s@]+ stops at the next @. In a URL that leaves `@domain` after the first address.\n// Continue through those @ segments so the leftover cannot slide into kept text\n// when the long match is replaced with a short mask.\nexport const EMAIL_REGEX = /[^\\s@]+@[^\\s@.]+\\.[^\\s@]+(?:@[^\\s@]+)*/g;\n\n/**\n * Replaces sensitive strings (credit cards, SSNs, emails) and custom patterns with masked text\n * @param text - The text to search for sensitive data\n * @param additionalMaskTextPatterns - Optional array of additional regex patterns to mask\n * @returns The text with sensitive data replaced by masked text\n */\nexport const replaceSensitiveString = (text: string | null, additionalMaskTextPatterns: RegExp[] = []): string => {\n if (typeof text !== 'string') {\n return '';\n }\n\n let result = text;\n\n // CC_REGEX is not global: repeated `.test()` calls share lastIndex.\n // A fresh global copy masks every card. One replace would leave later cards,\n // and a card past the cutoff can then slide into the kept autocapture text.\n result = result.replace(new RegExp(CC_REGEX.source, 'g'), MASKED_TEXT_VALUE);\n\n // Check for social security number\n result = result.replace(SSN_REGEX, MASKED_TEXT_VALUE);\n\n // Check for email\n result = result.replace(EMAIL_REGEX, MASKED_TEXT_VALUE);\n\n // Check for additional mask text patterns. Every match is masked, not only the first.\n // A later match can otherwise slide into the kept text once earlier matches shorten the prefix.\n for (const pattern of additionalMaskTextPatterns) {\n try {\n const flags = pattern.flags.includes('g') ? pattern.flags : `${pattern.flags}g`;\n // Skip zero-length matches so a pattern like /x*/ does not insert a mask between characters.\n result = result.replace(new RegExp(pattern.source, flags), (match) =>\n match.length > 0 ? MASKED_TEXT_VALUE : match,\n );\n } catch {\n // ignore invalid pattern\n }\n }\n\n return result;\n};\n\n/**\n * Gets the page title, checking if the title element has data-amp-mask attribute\n * @returns The page title, masked if the title element has data-amp-mask attribute\n */\nexport const getPageTitle = (parseTitleFunction?: (title: string) => string): string => {\n if (typeof document === 'undefined' || !document.title) {\n return '';\n }\n const titleElement = document.querySelector('title');\n if (titleElement && titleElement.hasAttribute(TEXT_MASK_ATTRIBUTE)) {\n return MASKED_TEXT_VALUE;\n }\n return parseTitleFunction ? parseTitleFunction(document.title) : document.title; // document.title is always synced to the first title element\n};\n"]}
|