🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@posthog/browser-common

Package Overview
Dependencies
Maintainers
22
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@posthog/browser-common - npm Package Compare versions

Comparing version
0.3.0
to
0.3.1
+1
-1
dist/config.js

@@ -29,3 +29,3 @@ "use strict";

});
const packageVersion = "0.3.0";
const packageVersion = "0.3.1";
const Config = {

@@ -32,0 +32,0 @@ DEBUG: false,

@@ -1,2 +0,2 @@

const packageVersion = "0.3.0";
const packageVersion = "0.3.1";
const Config = {

@@ -3,0 +3,0 @@ DEBUG: false,

@@ -337,6 +337,56 @@ "use strict";

const anchoredCCRegex = new RegExp(`^(?:${coreCCPattern})$`);
const unanchoredCCRegex = new RegExp(coreCCPattern);
const networkCCCandidateRegex = /(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g;
const networkCCLengths = [
16,
15,
14,
13
];
const coreSSNPattern = "\\d{3}-?\\d{2}-?\\d{4}";
const anchoredSSNRegex = new RegExp(`^(${coreSSNPattern})$`);
const unanchoredSSNRegex = new RegExp(`(${coreSSNPattern})`);
const networkSSNPattern = "(?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4}";
const networkSSNCandidateRegex = new RegExp(`(^|[^0-9])(${networkSSNPattern})(?=$|([^0-9]))`, 'g');
const identifierCharacterRegex = /[0-9A-Za-z_]/;
function passesLuhnCheck(value) {
let sum = 0;
let shouldDouble = false;
for(let i = value.length - 1; i >= 0; i--){
let digit = value.charCodeAt(i) - 48;
if (shouldDouble) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
shouldDouble = !shouldDouble;
}
return sum % 10 === 0;
}
function containsCreditCardNumber(value) {
networkCCCandidateRegex.lastIndex = 0;
let match;
while(match = networkCCCandidateRegex.exec(value)){
const matchedCandidate = match[2];
if (!matchedCandidate) continue;
const candidate = matchedCandidate.replace(/[- ]/g, '');
for(let start = 0; start < candidate.length; start++)for (const length of networkCCLengths){
const end = start + length;
if (end <= candidate.length) {
const possibleCardNumber = candidate.slice(start, end);
if (anchoredCCRegex.test(possibleCardNumber) && passesLuhnCheck(possibleCardNumber)) return true;
}
}
}
return false;
}
function containsSSN(value) {
networkSSNCandidateRegex.lastIndex = 0;
let match;
while(match = networkSSNCandidateRegex.exec(value)){
const characterBefore = match[1];
const characterAfter = match[3];
if (characterBefore && characterAfter && identifierCharacterRegex.test(characterBefore) && identifierCharacterRegex.test(characterAfter)) continue;
return true;
}
return false;
}
function shouldCaptureValue(value, anchorRegexes = true) {

@@ -346,6 +396,6 @@ if ((0, core_namespaceObject.isNullish)(value)) return false;

value = (0, core_namespaceObject.trim)(value);
const ccRegex = anchorRegexes ? anchoredCCRegex : unanchoredCCRegex;
if (ccRegex.test((value || '').replace(/[- ]/g, ''))) return false;
const ssnRegex = anchorRegexes ? anchoredSSNRegex : unanchoredSSNRegex;
if (ssnRegex.test(value)) return false;
const containsCreditCard = anchorRegexes ? anchoredCCRegex.test((value || '').replace(/[- ]/g, '')) : containsCreditCardNumber(value);
if (containsCreditCard) return false;
const containsSocialSecurityNumber = anchorRegexes ? anchoredSSNRegex.test(value) : containsSSN(value);
if (containsSocialSecurityNumber) return false;
}

@@ -352,0 +402,0 @@ return true;

@@ -289,6 +289,56 @@ import { each, entries } from "./general-utils.mjs";

const anchoredCCRegex = new RegExp(`^(?:${coreCCPattern})$`);
const unanchoredCCRegex = new RegExp(coreCCPattern);
const networkCCCandidateRegex = /(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g;
const networkCCLengths = [
16,
15,
14,
13
];
const coreSSNPattern = "\\d{3}-?\\d{2}-?\\d{4}";
const anchoredSSNRegex = new RegExp(`^(${coreSSNPattern})$`);
const unanchoredSSNRegex = new RegExp(`(${coreSSNPattern})`);
const networkSSNPattern = "(?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4}";
const networkSSNCandidateRegex = new RegExp(`(^|[^0-9])(${networkSSNPattern})(?=$|([^0-9]))`, 'g');
const identifierCharacterRegex = /[0-9A-Za-z_]/;
function passesLuhnCheck(value) {
let sum = 0;
let shouldDouble = false;
for(let i = value.length - 1; i >= 0; i--){
let digit = value.charCodeAt(i) - 48;
if (shouldDouble) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
shouldDouble = !shouldDouble;
}
return sum % 10 === 0;
}
function containsCreditCardNumber(value) {
networkCCCandidateRegex.lastIndex = 0;
let match;
while(match = networkCCCandidateRegex.exec(value)){
const matchedCandidate = match[2];
if (!matchedCandidate) continue;
const candidate = matchedCandidate.replace(/[- ]/g, '');
for(let start = 0; start < candidate.length; start++)for (const length of networkCCLengths){
const end = start + length;
if (end <= candidate.length) {
const possibleCardNumber = candidate.slice(start, end);
if (anchoredCCRegex.test(possibleCardNumber) && passesLuhnCheck(possibleCardNumber)) return true;
}
}
}
return false;
}
function containsSSN(value) {
networkSSNCandidateRegex.lastIndex = 0;
let match;
while(match = networkSSNCandidateRegex.exec(value)){
const characterBefore = match[1];
const characterAfter = match[3];
if (characterBefore && characterAfter && identifierCharacterRegex.test(characterBefore) && identifierCharacterRegex.test(characterAfter)) continue;
return true;
}
return false;
}
function shouldCaptureValue(value, anchorRegexes = true) {

@@ -298,6 +348,6 @@ if (isNullish(value)) return false;

value = trim(value);
const ccRegex = anchorRegexes ? anchoredCCRegex : unanchoredCCRegex;
if (ccRegex.test((value || '').replace(/[- ]/g, ''))) return false;
const ssnRegex = anchorRegexes ? anchoredSSNRegex : unanchoredSSNRegex;
if (ssnRegex.test(value)) return false;
const containsCreditCard = anchorRegexes ? anchoredCCRegex.test((value || '').replace(/[- ]/g, '')) : containsCreditCardNumber(value);
if (containsCreditCard) return false;
const containsSocialSecurityNumber = anchorRegexes ? anchoredSSNRegex.test(value) : containsSSN(value);
if (containsSocialSecurityNumber) return false;
}

@@ -304,0 +354,0 @@ return true;

{
"name": "@posthog/browser-common",
"version": "0.3.0",
"version": "0.3.1",
"description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",

@@ -68,4 +68,4 @@ "license": "MIT",

"dependencies": {
"@posthog/core": "^1.46.0",
"@posthog/types": "^1.399.0"
"@posthog/types": "^1.399.0",
"@posthog/core": "^1.46.0"
},

@@ -72,0 +72,0 @@ "devDependencies": {