@adtrackify/at-service-common 3.5.18 → 3.5.20
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/dist/cjs/libs/crypto.d.ts +1 -0
- package/dist/cjs/libs/crypto.js +5 -1
- package/dist/cjs/libs/crypto.js.map +1 -1
- package/dist/cjs/libs/emails.d.ts +6 -0
- package/dist/cjs/libs/emails.js +123 -0
- package/dist/cjs/libs/emails.js.map +1 -0
- package/dist/cjs/libs/index.d.ts +1 -0
- package/dist/cjs/libs/index.js +1 -0
- package/dist/cjs/libs/index.js.map +1 -1
- package/dist/cjs/libs/traits.d.ts +4 -0
- package/dist/cjs/libs/traits.js +45 -1
- package/dist/cjs/libs/traits.js.map +1 -1
- package/dist/cjs/services/db/purchased-contacts-db-service.js +1 -1
- package/dist/esm/libs/crypto.d.ts +1 -0
- package/dist/esm/libs/crypto.js +3 -0
- package/dist/esm/libs/crypto.js.map +1 -1
- package/dist/esm/libs/emails.d.ts +6 -0
- package/dist/esm/libs/emails.js +116 -0
- package/dist/esm/libs/emails.js.map +1 -0
- package/dist/esm/libs/index.d.ts +1 -0
- package/dist/esm/libs/index.js +1 -0
- package/dist/esm/libs/index.js.map +1 -1
- package/dist/esm/libs/traits.d.ts +4 -0
- package/dist/esm/libs/traits.js +40 -0
- package/dist/esm/libs/traits.js.map +1 -1
- package/dist/esm/services/db/purchased-contacts-db-service.js +1 -1
- package/package.json +1 -1
package/dist/cjs/libs/crypto.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateSha256Hash = exports.generatePublicKey = void 0;
|
|
6
|
+
exports.generateMd5Hash = exports.generateSha256Hash = exports.generatePublicKey = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
const generatePublicKey = () => {
|
|
9
9
|
const publicKey = crypto_1.default.randomBytes(26);
|
|
@@ -14,4 +14,8 @@ const generateSha256Hash = (input) => {
|
|
|
14
14
|
return crypto_1.default.createHash('sha256').update(input).digest('hex');
|
|
15
15
|
};
|
|
16
16
|
exports.generateSha256Hash = generateSha256Hash;
|
|
17
|
+
const generateMd5Hash = (input) => {
|
|
18
|
+
return crypto_1.default.createHash('md5').update(input).digest('hex');
|
|
19
|
+
};
|
|
20
|
+
exports.generateMd5Hash = generateMd5Hash;
|
|
17
21
|
//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/libs/crypto.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAErB,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,MAAM,SAAS,GAAG,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACzC,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEK,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,OAAO,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B"}
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/libs/crypto.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAErB,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,MAAM,SAAS,GAAG,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACzC,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEK,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,OAAO,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AACK,MAAM,eAAe,GAAG,CAAC,KAAa,EAAU,EAAE;IACvD,OAAO,gBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const normalizeGmailAddress: (email: string) => string;
|
|
2
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
3
|
+
export declare const riskyEmailDomains: string[];
|
|
4
|
+
export declare const disposableEmailDomains: string[];
|
|
5
|
+
export declare const isDisposableEmail: (email: string) => boolean;
|
|
6
|
+
export declare const isYahooEmail: (email: string) => boolean;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isYahooEmail = exports.isDisposableEmail = exports.disposableEmailDomains = exports.riskyEmailDomains = exports.validateEmail = exports.normalizeGmailAddress = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const normalizeGmailAddress = (email) => {
|
|
6
|
+
if (!email || typeof email !== 'string') {
|
|
7
|
+
return email;
|
|
8
|
+
}
|
|
9
|
+
const emailLower = email.toLowerCase().trim();
|
|
10
|
+
if (!emailLower.includes('@gmail.com')) {
|
|
11
|
+
return emailLower;
|
|
12
|
+
}
|
|
13
|
+
const [localPart, domain] = emailLower.split('@');
|
|
14
|
+
if (!localPart || !domain) {
|
|
15
|
+
return emailLower;
|
|
16
|
+
}
|
|
17
|
+
const normalizedLocalPart = localPart.replace(/\./g, '');
|
|
18
|
+
return `${normalizedLocalPart}@${domain}`;
|
|
19
|
+
};
|
|
20
|
+
exports.normalizeGmailAddress = normalizeGmailAddress;
|
|
21
|
+
const validateEmail = (email) => {
|
|
22
|
+
try {
|
|
23
|
+
if (!email || typeof email !== 'string') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const emailStr = String(email).trim().toLowerCase();
|
|
27
|
+
if (emailStr.length === 0) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
31
|
+
const isValid = emailRegex.test(emailStr);
|
|
32
|
+
if (isValid) {
|
|
33
|
+
if (emailStr.includes('..')) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (emailStr.length > 254) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const [localPart] = emailStr.split('@');
|
|
40
|
+
if (localPart && localPart.length > 64) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return isValid;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
helpers_1.Logger.error('Failed to validate email', { email, error });
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.validateEmail = validateEmail;
|
|
52
|
+
exports.riskyEmailDomains = [
|
|
53
|
+
'ymail.com',
|
|
54
|
+
'yahoo.com',
|
|
55
|
+
'yahoo.co.uk',
|
|
56
|
+
'yahoo.co.in',
|
|
57
|
+
'yahoo.co.jp',
|
|
58
|
+
'yahoo.co.kr',
|
|
59
|
+
'aol.com',
|
|
60
|
+
'verizon.net',
|
|
61
|
+
'frontier.com',
|
|
62
|
+
'cox.net',
|
|
63
|
+
'rogers.com',
|
|
64
|
+
'sbcglobal.net',
|
|
65
|
+
'bellsouth.net',
|
|
66
|
+
'att.net',
|
|
67
|
+
'pacbell.net',
|
|
68
|
+
'charter.net',
|
|
69
|
+
'comcast.net',
|
|
70
|
+
'suddenlink.net',
|
|
71
|
+
'centurylink.net',
|
|
72
|
+
'excite.com',
|
|
73
|
+
'geocities.com',
|
|
74
|
+
'prodigy.net',
|
|
75
|
+
'earthlink.net',
|
|
76
|
+
'roadrunner.com',
|
|
77
|
+
'rr.com',
|
|
78
|
+
'cs.com',
|
|
79
|
+
'juno.com',
|
|
80
|
+
'netzero.net',
|
|
81
|
+
'netzero.com',
|
|
82
|
+
'netscape.com',
|
|
83
|
+
'netscape.net',
|
|
84
|
+
'webtv.net',
|
|
85
|
+
'mindspring.com',
|
|
86
|
+
'mac.com',
|
|
87
|
+
'rocketmail.com',
|
|
88
|
+
'yahoo.net',
|
|
89
|
+
'hotmail.com',
|
|
90
|
+
'live.com',
|
|
91
|
+
'msn.com',
|
|
92
|
+
'outlook.com',
|
|
93
|
+
'yahoo.com',
|
|
94
|
+
'yahoo.co.uk',
|
|
95
|
+
'yahoo.co.in',
|
|
96
|
+
'yahoo.co.jp',
|
|
97
|
+
'yahoo.co.kr',
|
|
98
|
+
'icloud.com',
|
|
99
|
+
'facebook.com'
|
|
100
|
+
];
|
|
101
|
+
exports.disposableEmailDomains = [
|
|
102
|
+
'amazom.com',
|
|
103
|
+
'mailinator.com',
|
|
104
|
+
'yopmail.com',
|
|
105
|
+
'maildrop.cc',
|
|
106
|
+
'maildrop.cc',
|
|
107
|
+
'mailnesia.com',
|
|
108
|
+
'guerrillamail.com',
|
|
109
|
+
'guerrillamailblock.com',
|
|
110
|
+
'guerrillamail.org',
|
|
111
|
+
'guerrillamail.net',
|
|
112
|
+
'guerrillamail.biz',
|
|
113
|
+
'guerrillamail.com',
|
|
114
|
+
];
|
|
115
|
+
const isDisposableEmail = (email) => {
|
|
116
|
+
return exports.disposableEmailDomains.some((domain) => email.includes(domain));
|
|
117
|
+
};
|
|
118
|
+
exports.isDisposableEmail = isDisposableEmail;
|
|
119
|
+
const isYahooEmail = (email) => {
|
|
120
|
+
return exports.riskyEmailDomains.some((domain) => email.includes(domain));
|
|
121
|
+
};
|
|
122
|
+
exports.isYahooEmail = isYahooEmail;
|
|
123
|
+
//# sourceMappingURL=emails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emails.js","sourceRoot":"","sources":["../../../src/libs/emails.ts"],"names":[],"mappings":";;;AAAA,wCAAoC;AAG7B,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAG9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtC,OAAO,UAAU,CAAC;KACnB;IAED,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE;QACzB,OAAO,UAAU,CAAC;KACnB;IAGD,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACzD,OAAO,GAAG,mBAAmB,IAAI,MAAM,EAAE,CAAC;AAC5C,CAAC,CAAC;AApBS,QAAA,qBAAqB,yBAoB9B;AAOG,MAAM,aAAa,GAAG,CAAC,KAAa,EAAW,EAAE;IACpD,IAAI;QACF,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACvC,OAAO,KAAK,CAAC;SACd;QAGD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IA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;IAChB,WAAW;IACX,aAAa;IACb,UAAU;IACV,SAAS;IACT,aAAa;IACb,WAAW;IACX,aAAa;IACb,aAAa;IACb,aAAa;IACb,aAAa;IACb,YAAY;IACZ,cAAc;CACf,CAAC;AAEW,QAAA,sBAAsB,GAAG;IACpC,YAAY;IACZ,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,aAAa;IACb,eAAe;IACf,mBAAmB;IACnB,wBAAwB;IACxB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;CACpB,CAAC;AAEK,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAW,EAAE;IAC1D,OAAO,8BAAsB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AACK,MAAM,YAAY,GAAG,CAAC,KAAa,EAAW,EAAE;IACrD,OAAO,yBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}
|
package/dist/cjs/libs/index.d.ts
CHANGED
package/dist/cjs/libs/index.js
CHANGED
|
@@ -30,4 +30,5 @@ __exportStar(require("./numbers.js"), exports);
|
|
|
30
30
|
__exportStar(require("./strings.js"), exports);
|
|
31
31
|
__exportStar(require("./cookie.js"), exports);
|
|
32
32
|
__exportStar(require("./domain.js"), exports);
|
|
33
|
+
__exportStar(require("./emails.js"), exports);
|
|
33
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,8CAA4B;AAC5B,6CAA2B;AAC3B,kDAAgC;AAChC,yDAAuC;AACvC,2CAAyB;AACzB,6DAA2C;AAC3C,uDAAqC;AACrC,mDAAiC;AACjC,2CAAyB;AACzB,8CAA4B;AAC5B,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,8CAA4B;AAC5B,6CAA2B;AAC3B,kDAAgC;AAChC,yDAAuC;AACvC,2CAAyB;AACzB,6DAA2C;AAC3C,uDAAqC;AACrC,mDAAiC;AACjC,2CAAyB;AACzB,8CAA4B;AAC5B,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { CountryCode } from 'libphonenumber-js';
|
|
2
2
|
export declare const safeParsePhone: (input: string, countryCode?: CountryCode) => string | undefined;
|
|
3
|
+
export declare const getMd5Emails: (emails: string[]) => string[];
|
|
4
|
+
export declare const getSha2Emails: (emails: string[]) => string[];
|
|
5
|
+
export declare const getMd5Phones: (phones: string[]) => string[];
|
|
6
|
+
export declare const getSha2Phones: (phones: string[]) => string[];
|
package/dist/cjs/libs/traits.js
CHANGED
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.safeParsePhone = void 0;
|
|
6
|
+
exports.getSha2Phones = exports.getMd5Phones = exports.getSha2Emails = exports.getMd5Emails = exports.safeParsePhone = void 0;
|
|
7
7
|
const libphonenumber_js_1 = __importDefault(require("libphonenumber-js"));
|
|
8
8
|
const helpers_1 = require("../helpers");
|
|
9
|
+
const at_shared_utils_1 = require("@adtrackify/at-shared-utils");
|
|
10
|
+
const crypto_1 = require("./crypto");
|
|
9
11
|
const safeParsePhone = (input, countryCode) => {
|
|
10
12
|
try {
|
|
11
13
|
const phoneNumber = (0, libphonenumber_js_1.default)(input, countryCode);
|
|
@@ -19,4 +21,46 @@ const safeParsePhone = (input, countryCode) => {
|
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
exports.safeParsePhone = safeParsePhone;
|
|
24
|
+
const getMd5Emails = (emails) => {
|
|
25
|
+
try {
|
|
26
|
+
return (0, at_shared_utils_1.getCleanedArray)(emails).map((email) => (0, crypto_1.generateMd5Hash)(email));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
helpers_1.Logger.error('Failed to get md5 emails', { error });
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.getMd5Emails = getMd5Emails;
|
|
34
|
+
const getSha2Emails = (emails) => {
|
|
35
|
+
try {
|
|
36
|
+
return (0, at_shared_utils_1.getCleanedArray)(emails).map((email) => (0, crypto_1.generateSha256Hash)(email));
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
helpers_1.Logger.error('Failed to get sha2 emails', { error });
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.getSha2Emails = getSha2Emails;
|
|
44
|
+
const getMd5Phones = (phones) => {
|
|
45
|
+
try {
|
|
46
|
+
const formattedPhones = (0, at_shared_utils_1.getCleanedArray)(phones.map((phone) => (0, exports.safeParsePhone)(phone)).filter((phone) => phone !== undefined));
|
|
47
|
+
return formattedPhones.map((phone) => (0, crypto_1.generateMd5Hash)(phone));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
helpers_1.Logger.error('Failed to get md5 phones', { error });
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.getMd5Phones = getMd5Phones;
|
|
55
|
+
const getSha2Phones = (phones) => {
|
|
56
|
+
try {
|
|
57
|
+
const formattedPhones = (0, at_shared_utils_1.getCleanedArray)(phones.map((phone) => (0, exports.safeParsePhone)(phone)).filter((phone) => phone !== undefined));
|
|
58
|
+
return formattedPhones.map((phone) => (0, crypto_1.generateSha256Hash)(phone));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
helpers_1.Logger.error('Failed to get sha2 phones', { error });
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.getSha2Phones = getSha2Phones;
|
|
22
66
|
//# sourceMappingURL=traits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../../../src/libs/traits.ts"],"names":[],"mappings":";;;;;;AAAA,0EAAkE;AAClE,wCAAoC;
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../../../src/libs/traits.ts"],"names":[],"mappings":";;;;;;AAAA,0EAAkE;AAClE,wCAAoC;AACpC,iEAA8D;AAC9D,qCAA+D;AAExD,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,WAAyB,EAAsB,EAAE;IAC7F,IAAI;QACF,MAAM,WAAW,GAAG,IAAA,2BAAgB,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACzD,IAAI,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QACzC,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAClC,OAAO,EAAE,CAAC;KACX;IAAC,OAAO,KAAK,EAAE;QACd,gBAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACrE,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB;AAEK,MAAM,YAAY,GAAG,CAAC,MAAgB,EAAY,EAAE;IACzD,IAAI;QACF,OAAO,IA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AQxB;AACM,MAAM,aAAa,GAAG,CAAC,MAAgB,EAAY,EAAE;IAC1D,IAAI;QACF,MAAM,eAAe,GAAG,IAAA,iCAAe,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;QAC7H,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,2BAAkB,EAAC,KAAK,CAAC,CAAC,CAAC;KAClE;IAAC,OAAO,KAAK,EAAE;QACd,gBAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAA;AARY,QAAA,aAAa,iBAQzB"}
|
|
@@ -15,7 +15,7 @@ class PurchasedContactsDbService {
|
|
|
15
15
|
constructor(tableName, purchasedContactsKey, STAGE) {
|
|
16
16
|
this.TABLE_NAME = tableName;
|
|
17
17
|
this.TABLE_KEY = purchasedContactsKey;
|
|
18
|
-
this.IDENTITY_ID_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-
|
|
18
|
+
this.IDENTITY_ID_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-identity-id-pixel-id`;
|
|
19
19
|
this.IP_ADDRESS_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-ip-address-pixel-id`;
|
|
20
20
|
this.EMAIL_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-email-pixel-id`;
|
|
21
21
|
}
|
package/dist/esm/libs/crypto.js
CHANGED
|
@@ -6,4 +6,7 @@ export const generatePublicKey = () => {
|
|
|
6
6
|
export const generateSha256Hash = (input) => {
|
|
7
7
|
return crypto.createHash('sha256').update(input).digest('hex');
|
|
8
8
|
};
|
|
9
|
+
export const generateMd5Hash = (input) => {
|
|
10
|
+
return crypto.createHash('md5').update(input).digest('hex');
|
|
11
|
+
};
|
|
9
12
|
//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/libs/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACzC,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/libs/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACzC,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAU,EAAE;IACvD,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const normalizeGmailAddress: (email: string) => string;
|
|
2
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
3
|
+
export declare const riskyEmailDomains: string[];
|
|
4
|
+
export declare const disposableEmailDomains: string[];
|
|
5
|
+
export declare const isDisposableEmail: (email: string) => boolean;
|
|
6
|
+
export declare const isYahooEmail: (email: string) => boolean;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Logger } from '../helpers';
|
|
2
|
+
export const normalizeGmailAddress = (email) => {
|
|
3
|
+
if (!email || typeof email !== 'string') {
|
|
4
|
+
return email;
|
|
5
|
+
}
|
|
6
|
+
const emailLower = email.toLowerCase().trim();
|
|
7
|
+
if (!emailLower.includes('@gmail.com')) {
|
|
8
|
+
return emailLower;
|
|
9
|
+
}
|
|
10
|
+
const [localPart, domain] = emailLower.split('@');
|
|
11
|
+
if (!localPart || !domain) {
|
|
12
|
+
return emailLower;
|
|
13
|
+
}
|
|
14
|
+
const normalizedLocalPart = localPart.replace(/\./g, '');
|
|
15
|
+
return `${normalizedLocalPart}@${domain}`;
|
|
16
|
+
};
|
|
17
|
+
export const validateEmail = (email) => {
|
|
18
|
+
try {
|
|
19
|
+
if (!email || typeof email !== 'string') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const emailStr = String(email).trim().toLowerCase();
|
|
23
|
+
if (emailStr.length === 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
27
|
+
const isValid = emailRegex.test(emailStr);
|
|
28
|
+
if (isValid) {
|
|
29
|
+
if (emailStr.includes('..')) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (emailStr.length > 254) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const [localPart] = emailStr.split('@');
|
|
36
|
+
if (localPart && localPart.length > 64) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return isValid;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
Logger.error('Failed to validate email', { email, error });
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const riskyEmailDomains = [
|
|
48
|
+
'ymail.com',
|
|
49
|
+
'yahoo.com',
|
|
50
|
+
'yahoo.co.uk',
|
|
51
|
+
'yahoo.co.in',
|
|
52
|
+
'yahoo.co.jp',
|
|
53
|
+
'yahoo.co.kr',
|
|
54
|
+
'aol.com',
|
|
55
|
+
'verizon.net',
|
|
56
|
+
'frontier.com',
|
|
57
|
+
'cox.net',
|
|
58
|
+
'rogers.com',
|
|
59
|
+
'sbcglobal.net',
|
|
60
|
+
'bellsouth.net',
|
|
61
|
+
'att.net',
|
|
62
|
+
'pacbell.net',
|
|
63
|
+
'charter.net',
|
|
64
|
+
'comcast.net',
|
|
65
|
+
'suddenlink.net',
|
|
66
|
+
'centurylink.net',
|
|
67
|
+
'excite.com',
|
|
68
|
+
'geocities.com',
|
|
69
|
+
'prodigy.net',
|
|
70
|
+
'earthlink.net',
|
|
71
|
+
'roadrunner.com',
|
|
72
|
+
'rr.com',
|
|
73
|
+
'cs.com',
|
|
74
|
+
'juno.com',
|
|
75
|
+
'netzero.net',
|
|
76
|
+
'netzero.com',
|
|
77
|
+
'netscape.com',
|
|
78
|
+
'netscape.net',
|
|
79
|
+
'webtv.net',
|
|
80
|
+
'mindspring.com',
|
|
81
|
+
'mac.com',
|
|
82
|
+
'rocketmail.com',
|
|
83
|
+
'yahoo.net',
|
|
84
|
+
'hotmail.com',
|
|
85
|
+
'live.com',
|
|
86
|
+
'msn.com',
|
|
87
|
+
'outlook.com',
|
|
88
|
+
'yahoo.com',
|
|
89
|
+
'yahoo.co.uk',
|
|
90
|
+
'yahoo.co.in',
|
|
91
|
+
'yahoo.co.jp',
|
|
92
|
+
'yahoo.co.kr',
|
|
93
|
+
'icloud.com',
|
|
94
|
+
'facebook.com'
|
|
95
|
+
];
|
|
96
|
+
export const disposableEmailDomains = [
|
|
97
|
+
'amazom.com',
|
|
98
|
+
'mailinator.com',
|
|
99
|
+
'yopmail.com',
|
|
100
|
+
'maildrop.cc',
|
|
101
|
+
'maildrop.cc',
|
|
102
|
+
'mailnesia.com',
|
|
103
|
+
'guerrillamail.com',
|
|
104
|
+
'guerrillamailblock.com',
|
|
105
|
+
'guerrillamail.org',
|
|
106
|
+
'guerrillamail.net',
|
|
107
|
+
'guerrillamail.biz',
|
|
108
|
+
'guerrillamail.com',
|
|
109
|
+
];
|
|
110
|
+
export const isDisposableEmail = (email) => {
|
|
111
|
+
return disposableEmailDomains.some((domain) => email.includes(domain));
|
|
112
|
+
};
|
|
113
|
+
export const isYahooEmail = (email) => {
|
|
114
|
+
return riskyEmailDomains.some((domain) => email.includes(domain));
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=emails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emails.js","sourceRoot":"","sources":["../../../src/libs/emails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAG9C,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iB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC"}
|
package/dist/esm/libs/index.d.ts
CHANGED
package/dist/esm/libs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { CountryCode } from 'libphonenumber-js';
|
|
2
2
|
export declare const safeParsePhone: (input: string, countryCode?: CountryCode) => string | undefined;
|
|
3
|
+
export declare const getMd5Emails: (emails: string[]) => string[];
|
|
4
|
+
export declare const getSha2Emails: (emails: string[]) => string[];
|
|
5
|
+
export declare const getMd5Phones: (phones: string[]) => string[];
|
|
6
|
+
export declare const getSha2Phones: (phones: string[]) => string[];
|
package/dist/esm/libs/traits.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import parsePhoneNumber from 'libphonenumber-js';
|
|
2
2
|
import { Logger } from '../helpers';
|
|
3
|
+
import { getCleanedArray } from '@adtrackify/at-shared-utils';
|
|
4
|
+
import { generateMd5Hash, generateSha256Hash } from './crypto';
|
|
3
5
|
export const safeParsePhone = (input, countryCode) => {
|
|
4
6
|
try {
|
|
5
7
|
const phoneNumber = parsePhoneNumber(input, countryCode);
|
|
@@ -12,4 +14,42 @@ export const safeParsePhone = (input, countryCode) => {
|
|
|
12
14
|
return undefined;
|
|
13
15
|
}
|
|
14
16
|
};
|
|
17
|
+
export const getMd5Emails = (emails) => {
|
|
18
|
+
try {
|
|
19
|
+
return getCleanedArray(emails).map((email) => generateMd5Hash(email));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
Logger.error('Failed to get md5 emails', { error });
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const getSha2Emails = (emails) => {
|
|
27
|
+
try {
|
|
28
|
+
return getCleanedArray(emails).map((email) => generateSha256Hash(email));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
Logger.error('Failed to get sha2 emails', { error });
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const getMd5Phones = (phones) => {
|
|
36
|
+
try {
|
|
37
|
+
const formattedPhones = getCleanedArray(phones.map((phone) => safeParsePhone(phone)).filter((phone) => phone !== undefined));
|
|
38
|
+
return formattedPhones.map((phone) => generateMd5Hash(phone));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
Logger.error('Failed to get md5 phones', { error });
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const getSha2Phones = (phones) => {
|
|
46
|
+
try {
|
|
47
|
+
const formattedPhones = getCleanedArray(phones.map((phone) => safeParsePhone(phone)).filter((phone) => phone !== undefined));
|
|
48
|
+
return formattedPhones.map((phone) => generateSha256Hash(phone));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
Logger.error('Failed to get sha2 phones', { error });
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
};
|
|
15
55
|
//# sourceMappingURL=traits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../../../src/libs/traits.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAiC,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../../../src/libs/traits.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAiC,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,WAAyB,EAAsB,EAAE;IAC7F,IAAI;QACF,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACzD,IAAI,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QACzC,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QA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AAC,KAAK,CAAC,CAAC,CAAC;KAC/D;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAgB,EAAY,EAAE;IAC1D,IAAI;QACF,MAAM,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;QAC7H,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;KAClE;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAA"}
|
|
@@ -12,7 +12,7 @@ export class PurchasedContactsDbService {
|
|
|
12
12
|
constructor(tableName, purchasedContactsKey, STAGE) {
|
|
13
13
|
this.TABLE_NAME = tableName;
|
|
14
14
|
this.TABLE_KEY = purchasedContactsKey;
|
|
15
|
-
this.IDENTITY_ID_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-
|
|
15
|
+
this.IDENTITY_ID_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-identity-id-pixel-id`;
|
|
16
16
|
this.IP_ADDRESS_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-ip-address-pixel-id`;
|
|
17
17
|
this.EMAIL_PIXEL_ID_INDEX_NAME = `${STAGE}-purchased-contacts-gsi-email-pixel-id`;
|
|
18
18
|
}
|