@emailverifier/sdk 0.1.1

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.
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.disposableDomains = exports.disposableDomainList = exports.freeEmailDomains = exports.freeEmailDomainList = exports.customDisposableDomainList = exports.disposableDataUpdatedAt = void 0;
4
+ const disposable_domains_generated_js_1 = require("./disposable-domains.generated.js");
5
+ Object.defineProperty(exports, "disposableDataUpdatedAt", { enumerable: true, get: function () { return disposable_domains_generated_js_1.disposableDataUpdatedAt; } });
6
+ exports.customDisposableDomainList = [
7
+ '10minutemail.com',
8
+ '10minutemail.net',
9
+ '10minutemail.org',
10
+ '1secmail.com',
11
+ '1secmail.net',
12
+ '1secmail.org',
13
+ '20minutemail.com',
14
+ '33mail.com',
15
+ 'anonbox.net',
16
+ 'burner.kiwi',
17
+ 'byom.de',
18
+ 'cool.fr.nf',
19
+ 'correo-temp.com',
20
+ 'courriel.fr.nf',
21
+ 'dispostable.com',
22
+ 'dropmail.me',
23
+ 'emailfake.com',
24
+ 'emailondeck.com',
25
+ 'fakeinbox.com',
26
+ 'fakemail.net',
27
+ 'getairmail.com',
28
+ 'getnada.com',
29
+ 'grr.la',
30
+ 'guerrillamail.biz',
31
+ 'guerrillamail.com',
32
+ 'guerrillamail.de',
33
+ 'guerrillamail.info',
34
+ 'guerrillamail.net',
35
+ 'guerrillamail.org',
36
+ 'guerrillamailblock.com',
37
+ 'harakirimail.com',
38
+ 'inboxkitten.com',
39
+ 'jetable.fr.nf',
40
+ 'mail-temporaire.fr',
41
+ 'mail.tm',
42
+ 'mail7.io',
43
+ 'mailcatch.com',
44
+ 'maildrop.cc',
45
+ 'mailforspam.com',
46
+ 'mailgen.biz',
47
+ 'mailinator.com',
48
+ 'mailinator.net',
49
+ 'mailinator.org',
50
+ 'mailinator2.com',
51
+ 'mailnesia.com',
52
+ 'mailnull.com',
53
+ 'mailpoof.com',
54
+ 'mega.zik.dj',
55
+ 'mintemail.com',
56
+ 'minuteinbox.com',
57
+ 'moakt.com',
58
+ 'mohmal.com',
59
+ 'moncourrier.fr.nf',
60
+ 'monemail.fr.nf',
61
+ 'monmail.fr.nf',
62
+ 'mytemp.email',
63
+ 'nomail.xl.cx',
64
+ 'nospam.ze.tc',
65
+ 'pokemail.net',
66
+ 'sharklasers.com',
67
+ 'spam.la',
68
+ 'spam4.me',
69
+ 'spamgourmet.com',
70
+ 'spamhereplease.com',
71
+ 'speed.1s.fr',
72
+ 'temp-mail.io',
73
+ 'temp-mail.org',
74
+ 'tempinbox.com',
75
+ 'tempmail.com',
76
+ 'tempmail.io',
77
+ 'tempmail.net',
78
+ 'tempmail.plus',
79
+ 'tempmail.us',
80
+ 'tempmailo.com',
81
+ 'tempmailo.org',
82
+ 'tempr.email',
83
+ 'throwam.com',
84
+ 'throwawaymail.com',
85
+ 'tmpmail.org',
86
+ 'trashmail.com',
87
+ 'trashmail.de',
88
+ 'trashmail.net',
89
+ 'wegwerfmail.de',
90
+ 'yopmail.com',
91
+ 'yopmail.fr',
92
+ 'yopmail.net'
93
+ ];
94
+ exports.freeEmailDomainList = [
95
+ '126.com',
96
+ '139.com',
97
+ '163.com',
98
+ '21cn.com',
99
+ 'abv.bg',
100
+ 'aim.com',
101
+ 'alice.it',
102
+ 'aol.com',
103
+ 'arcor.de',
104
+ 'atlas.cz',
105
+ 'att.net',
106
+ 'azet.sk',
107
+ 'bellsouth.net',
108
+ 'bigpond.com',
109
+ 'bk.ru',
110
+ 'blueyonder.co.uk',
111
+ 'bol.com.br',
112
+ 'btinternet.com',
113
+ 'btopenworld.com',
114
+ 'centrum.cz',
115
+ 'centrum.sk',
116
+ 'centurylink.net',
117
+ 'charter.net',
118
+ 'citromail.hu',
119
+ 'comcast.net',
120
+ 'cox.net',
121
+ 'daum.net',
122
+ 'disroot.org',
123
+ 'duck.com',
124
+ 'earthlink.net',
125
+ 'eclipso.de',
126
+ 'email.cz',
127
+ 'email.it',
128
+ 'fastmail.com',
129
+ 'fastmail.fm',
130
+ 'free.fr',
131
+ 'freemail.gr',
132
+ 'freemail.hu',
133
+ 'freenet.de',
134
+ 'frontier.com',
135
+ 'gazeta.pl',
136
+ 'gmail.com',
137
+ 'gmx.at',
138
+ 'gmx.ch',
139
+ 'gmx.co.uk',
140
+ 'gmx.com',
141
+ 'gmx.de',
142
+ 'gmx.net',
143
+ 'gmx.us',
144
+ 'googlemail.com',
145
+ 'hanmail.net',
146
+ 'hey.com',
147
+ 'hotmail.co.uk',
148
+ 'hotmail.com',
149
+ 'hotmail.com.br',
150
+ 'hotmail.de',
151
+ 'hotmail.es',
152
+ 'hotmail.fr',
153
+ 'hotmail.it',
154
+ 'hushmail.com',
155
+ 'i.ua',
156
+ 'icloud.com',
157
+ 'inbox.lv',
158
+ 'inbox.ru',
159
+ 'indiatimes.com',
160
+ 'interia.pl',
161
+ 'laposte.net',
162
+ 'libero.it',
163
+ 'list.ru',
164
+ 'live.co.uk',
165
+ 'live.com',
166
+ 'live.com.au',
167
+ 'live.fr',
168
+ 'mac.com',
169
+ 'mail.bg',
170
+ 'mail.com',
171
+ 'mail.ee',
172
+ 'mail.ru',
173
+ 'mailbox.org',
174
+ 'mailfence.com',
175
+ 'mailo.com',
176
+ 'mailo.fr',
177
+ 'me.com',
178
+ 'mozmail.com',
179
+ 'msn.com',
180
+ 'naver.com',
181
+ 'o2.pl',
182
+ 'onet.pl',
183
+ 'optonline.net',
184
+ 'optusnet.com.au',
185
+ 'orange.fr',
186
+ 'outlook.co.uk',
187
+ 'outlook.com',
188
+ 'outlook.com.au',
189
+ 'outlook.de',
190
+ 'outlook.es',
191
+ 'outlook.fr',
192
+ 'outlook.in',
193
+ 'pm.me',
194
+ 'poczta.fm',
195
+ 'post.cz',
196
+ 'posteo.de',
197
+ 'privaterelay.appleid.com',
198
+ 'proton.me',
199
+ 'protonmail.ch',
200
+ 'protonmail.com',
201
+ 'qq.com',
202
+ 'rambler.ru',
203
+ 'rediffmail.com',
204
+ 'riseup.net',
205
+ 'rocketmail.com',
206
+ 'rogers.com',
207
+ 'runbox.com',
208
+ 'sapo.pt',
209
+ 'sbcglobal.net',
210
+ 'seznam.cz',
211
+ 'shaw.ca',
212
+ 'simplelogin.com',
213
+ 'sina.com',
214
+ 'sympatico.ca',
215
+ 't-online.de',
216
+ 'talktalk.net',
217
+ 'terra.com.br',
218
+ 'tiscali.co.uk',
219
+ 'tiscali.it',
220
+ 'tlen.pl',
221
+ 'tuta.com',
222
+ 'tuta.io',
223
+ 'tutamail.com',
224
+ 'tutanota.com',
225
+ 'tutanota.de',
226
+ 'tutanota.io',
227
+ 'ukr.net',
228
+ 'uol.com.br',
229
+ 'verizon.net',
230
+ 'virgilio.it',
231
+ 'virginmedia.com',
232
+ 'volny.cz',
233
+ 'wanadoo.fr',
234
+ 'web.de',
235
+ 'windstream.net',
236
+ 'wp.pl',
237
+ 'ya.ru',
238
+ 'yahoo.co.in',
239
+ 'yahoo.co.jp',
240
+ 'yahoo.co.uk',
241
+ 'yahoo.com',
242
+ 'yahoo.com.br',
243
+ 'yahoo.fr',
244
+ 'yandex.com',
245
+ 'yandex.ru',
246
+ 'yeah.net',
247
+ 'ymail.com',
248
+ 'zoho.com',
249
+ 'zohomail.com'
250
+ ];
251
+ exports.freeEmailDomains = new Set(exports.freeEmailDomainList);
252
+ exports.disposableDomainList = [...new Set([
253
+ ...disposable_domains_generated_js_1.upstreamDisposableDomainList,
254
+ ...exports.customDisposableDomainList
255
+ ])].filter(domain => !exports.freeEmailDomains.has(domain)).sort();
256
+ exports.disposableDomains = new Set(exports.disposableDomainList);
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailVerifierError = exports.EmailVerifier = void 0;
4
+ var client_js_1 = require("./client.js");
5
+ Object.defineProperty(exports, "EmailVerifier", { enumerable: true, get: function () { return client_js_1.EmailVerifier; } });
6
+ Object.defineProperty(exports, "EmailVerifierError", { enumerable: true, get: function () { return client_js_1.EmailVerifierError; } });
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.freeEmailDomainList = exports.disposableDomainList = exports.disposableDataUpdatedAt = exports.customDisposableDomainList = exports.maxEmailLength = void 0;
4
+ exports.getDisposableDomainMatch = getDisposableDomainMatch;
5
+ exports.getFreeEmailDomainMatch = getFreeEmailDomainMatch;
6
+ exports.isDisposableDomain = isDisposableDomain;
7
+ exports.isFreeEmailProvider = isFreeEmailProvider;
8
+ exports.isRoleAddress = isRoleAddress;
9
+ exports.analyzeEmail = analyzeEmail;
10
+ const domains_js_1 = require("./data/domains.js");
11
+ const role_addresses_js_1 = require("./role-addresses.js");
12
+ const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
13
+ const domainPattern = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
14
+ const localPartPattern = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/i;
15
+ exports.maxEmailLength = 254;
16
+ const maxLocalPartLength = 64;
17
+ function getRoleLocalPartAliases(localPart) {
18
+ const canonicalLocalPart = localPart.split('+')[0] ?? '';
19
+ const compactLocalPart = canonicalLocalPart.replace(/[._-]+/g, '');
20
+ return canonicalLocalPart === compactLocalPart
21
+ ? [canonicalLocalPart]
22
+ : [canonicalLocalPart, compactLocalPart];
23
+ }
24
+ function hasValidLocalPartDots(localPart) {
25
+ return Boolean(localPart) && !localPart.startsWith('.') && !localPart.endsWith('.') && !localPart.includes('..');
26
+ }
27
+ function normalizeEmailDomain(domain) {
28
+ if (!domain || /[/?:#[\]@]/.test(domain))
29
+ return '';
30
+ try {
31
+ const url = new URL(`http://${domain}`);
32
+ return url.username || url.password || url.port || url.pathname !== '/' || url.search || url.hash
33
+ ? ''
34
+ : url.hostname.toLowerCase();
35
+ }
36
+ catch {
37
+ return '';
38
+ }
39
+ }
40
+ function isSingleEditAway(value, target) {
41
+ if (value === target || Math.abs(value.length - target.length) > 1)
42
+ return false;
43
+ if (value.length === target.length) {
44
+ const differences = [];
45
+ for (let index = 0; index < value.length; index += 1) {
46
+ if (value[index] !== target[index])
47
+ differences.push(index);
48
+ if (differences.length > 2)
49
+ return false;
50
+ }
51
+ return differences.length === 1 || (differences.length === 2
52
+ && differences[1] === differences[0] + 1
53
+ && value[differences[0]] === target[differences[1]]
54
+ && value[differences[1]] === target[differences[0]]);
55
+ }
56
+ const [shorter, longer] = value.length < target.length ? [value, target] : [target, value];
57
+ let shorterIndex = 0;
58
+ let longerIndex = 0;
59
+ let skipped = false;
60
+ while (shorterIndex < shorter.length && longerIndex < longer.length) {
61
+ if (shorter[shorterIndex] === longer[longerIndex]) {
62
+ shorterIndex += 1;
63
+ longerIndex += 1;
64
+ }
65
+ else {
66
+ if (skipped)
67
+ return false;
68
+ skipped = true;
69
+ longerIndex += 1;
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+ function getSuggestedDomain(domain) {
75
+ let suggestion = null;
76
+ for (const providerDomain of domains_js_1.freeEmailDomainList) {
77
+ if (!isSingleEditAway(domain, providerDomain))
78
+ continue;
79
+ // Multiple possible corrections are more confusing than no suggestion.
80
+ if (suggestion)
81
+ return null;
82
+ suggestion = providerDomain;
83
+ }
84
+ return suggestion;
85
+ }
86
+ function getDisposableDomainMatch(domain) {
87
+ const normalizedDomain = domain.trim().toLowerCase();
88
+ if (domains_js_1.disposableDomains.has(normalizedDomain))
89
+ return normalizedDomain;
90
+ const labels = normalizedDomain.split('.');
91
+ for (let index = 1; index < labels.length - 1; index += 1) {
92
+ const parentDomain = labels.slice(index).join('.');
93
+ if (domains_js_1.disposableDomains.has(parentDomain))
94
+ return parentDomain;
95
+ }
96
+ return null;
97
+ }
98
+ function getFreeEmailDomainMatch(domain) {
99
+ const normalizedDomain = domain.trim().toLowerCase();
100
+ return domains_js_1.freeEmailDomains.has(normalizedDomain) ? normalizedDomain : null;
101
+ }
102
+ function isDisposableDomain(domain) {
103
+ return getDisposableDomainMatch(domain) !== null;
104
+ }
105
+ function isFreeEmailProvider(domain) {
106
+ return getFreeEmailDomainMatch(domain) !== null;
107
+ }
108
+ function isRoleAddress(email) {
109
+ const atIndex = email.lastIndexOf('@');
110
+ if (atIndex <= 0 || email.indexOf('@') !== atIndex)
111
+ return false;
112
+ const localPart = email.slice(0, atIndex).toLowerCase();
113
+ return getRoleLocalPartAliases(localPart).some(alias => role_addresses_js_1.roleLocalParts.has(alias));
114
+ }
115
+ function analyzeEmail(input) {
116
+ const email = typeof input === 'string' ? input.trim() : '';
117
+ const atIndex = email.lastIndexOf('@');
118
+ const localPart = atIndex > 0 ? email.slice(0, atIndex) : '';
119
+ const rawDomain = atIndex > 0 && email.indexOf('@') === atIndex ? email.slice(atIndex + 1) : '';
120
+ const domain = normalizeEmailDomain(rawDomain);
121
+ const normalizedEmail = email ? `${localPart}@${domain || rawDomain.toLowerCase()}` : null;
122
+ const localPartLength = Boolean(localPart && localPart.length <= maxLocalPartLength);
123
+ const syntax = emailPattern.test(email)
124
+ && hasValidLocalPartDots(localPart)
125
+ && localPartLength
126
+ && localPartPattern.test(localPart);
127
+ const emailLength = Boolean(email
128
+ && normalizedEmail
129
+ && email.length <= exports.maxEmailLength
130
+ && normalizedEmail.length <= exports.maxEmailLength);
131
+ const domainFormat = Boolean(domain && domainPattern.test(domain));
132
+ const disposable = domain ? isDisposableDomain(domain) : false;
133
+ const freeProvider = domain ? isFreeEmailProvider(domain) : false;
134
+ const roleBased = syntax && isRoleAddress(email);
135
+ const suggestedDomain = freeProvider ? null : getSuggestedDomain(domain);
136
+ const suggestion = syntax && suggestedDomain ? `${localPart}@${suggestedDomain}` : null;
137
+ const reasons = [];
138
+ if (!syntax)
139
+ reasons.push('Email syntax is invalid.');
140
+ if (emailPattern.test(email) && !localPartLength)
141
+ reasons.push('Email local part exceeds the maximum length of 64 characters.');
142
+ if (email && !emailLength)
143
+ reasons.push('Email exceeds the maximum length of 254 characters.');
144
+ if (syntax && emailLength && !domainFormat)
145
+ reasons.push('Email domain format is invalid.');
146
+ if (disposable)
147
+ reasons.push('Domain is a known disposable email provider.');
148
+ if (freeProvider)
149
+ reasons.push('Domain is a mainstream free mailbox provider.');
150
+ if (roleBased)
151
+ reasons.push('Address is role-based and may not identify one person.');
152
+ if (suggestion)
153
+ reasons.push(`Did you mean ${suggestion}?`);
154
+ return {
155
+ email,
156
+ normalizedEmail: syntax && emailLength ? normalizedEmail : null,
157
+ domain: emailLength && domainFormat ? domain : null,
158
+ suggestion,
159
+ checks: {
160
+ syntax,
161
+ emailLength,
162
+ localPartLength,
163
+ domainFormat,
164
+ disposable,
165
+ freeProvider,
166
+ roleBased
167
+ },
168
+ reasons
169
+ };
170
+ }
171
+ var domains_js_2 = require("./data/domains.js");
172
+ Object.defineProperty(exports, "customDisposableDomainList", { enumerable: true, get: function () { return domains_js_2.customDisposableDomainList; } });
173
+ Object.defineProperty(exports, "disposableDataUpdatedAt", { enumerable: true, get: function () { return domains_js_2.disposableDataUpdatedAt; } });
174
+ Object.defineProperty(exports, "disposableDomainList", { enumerable: true, get: function () { return domains_js_2.disposableDomainList; } });
175
+ Object.defineProperty(exports, "freeEmailDomainList", { enumerable: true, get: function () { return domains_js_2.freeEmailDomainList; } });
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}