mailsure 0.0.1 → 1.0.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.
- package/CHANGELOG.md +25 -0
- package/README.md +266 -4
- package/dist/chunk-Y3744BYV.js +1043 -0
- package/dist/dns.cjs +1018 -0
- package/dist/dns.d.cts +40 -0
- package/dist/dns.d.ts +40 -0
- package/dist/dns.js +73 -0
- package/dist/index.cjs +1065 -0
- package/dist/index.d.cts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +28 -0
- package/package.json +52 -9
- package/index.d.ts +0 -1
- package/index.js +0 -2
package/dist/dns.cjs
ADDED
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/dns.ts
|
|
21
|
+
var dns_exports = {};
|
|
22
|
+
__export(dns_exports, {
|
|
23
|
+
checkDeliverable: () => checkDeliverable,
|
|
24
|
+
hasMx: () => hasMx
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(dns_exports);
|
|
27
|
+
var import_promises = require("node:dns/promises");
|
|
28
|
+
var import_node_url = require("node:url");
|
|
29
|
+
|
|
30
|
+
// src/data.ts
|
|
31
|
+
var POPULAR_DOMAINS = [
|
|
32
|
+
"gmail.com",
|
|
33
|
+
"yahoo.com",
|
|
34
|
+
"hotmail.com",
|
|
35
|
+
"outlook.com",
|
|
36
|
+
"icloud.com",
|
|
37
|
+
"googlemail.com",
|
|
38
|
+
"yahoo.co.in",
|
|
39
|
+
"yahoo.in",
|
|
40
|
+
"rediffmail.com",
|
|
41
|
+
"live.com",
|
|
42
|
+
"msn.com",
|
|
43
|
+
"aol.com",
|
|
44
|
+
"me.com",
|
|
45
|
+
"mac.com",
|
|
46
|
+
"protonmail.com",
|
|
47
|
+
"proton.me",
|
|
48
|
+
"pm.me",
|
|
49
|
+
"zoho.com",
|
|
50
|
+
"zohomail.com",
|
|
51
|
+
"zohomail.in",
|
|
52
|
+
"ymail.com",
|
|
53
|
+
"yahoo.co.uk",
|
|
54
|
+
"hotmail.co.uk",
|
|
55
|
+
"live.co.uk",
|
|
56
|
+
"gmx.com",
|
|
57
|
+
"gmx.de",
|
|
58
|
+
"gmx.net",
|
|
59
|
+
"mail.com",
|
|
60
|
+
"yandex.com",
|
|
61
|
+
"yandex.ru",
|
|
62
|
+
"mail.ru",
|
|
63
|
+
"qq.com",
|
|
64
|
+
"163.com",
|
|
65
|
+
"126.com",
|
|
66
|
+
"naver.com",
|
|
67
|
+
"hey.com",
|
|
68
|
+
"fastmail.com",
|
|
69
|
+
"tutanota.com",
|
|
70
|
+
"tuta.io",
|
|
71
|
+
"web.de",
|
|
72
|
+
"orange.fr",
|
|
73
|
+
"comcast.net",
|
|
74
|
+
"verizon.net",
|
|
75
|
+
"att.net",
|
|
76
|
+
"btinternet.com",
|
|
77
|
+
"sky.com"
|
|
78
|
+
];
|
|
79
|
+
var FREE_DOMAINS = [
|
|
80
|
+
...POPULAR_DOMAINS,
|
|
81
|
+
// Google, Microsoft, Apple, Yahoo regional and legacy domains
|
|
82
|
+
"hotmail.fr",
|
|
83
|
+
"hotmail.de",
|
|
84
|
+
"hotmail.it",
|
|
85
|
+
"hotmail.es",
|
|
86
|
+
"hotmail.ca",
|
|
87
|
+
"hotmail.com.au",
|
|
88
|
+
"hotmail.co.in",
|
|
89
|
+
"outlook.in",
|
|
90
|
+
"outlook.fr",
|
|
91
|
+
"outlook.de",
|
|
92
|
+
"outlook.co.uk",
|
|
93
|
+
"live.in",
|
|
94
|
+
"live.ca",
|
|
95
|
+
"live.fr",
|
|
96
|
+
"live.de",
|
|
97
|
+
"live.it",
|
|
98
|
+
"live.com.au",
|
|
99
|
+
"windowslive.com",
|
|
100
|
+
"passport.com",
|
|
101
|
+
"yahoo.ca",
|
|
102
|
+
"yahoo.fr",
|
|
103
|
+
"yahoo.de",
|
|
104
|
+
"yahoo.it",
|
|
105
|
+
"yahoo.es",
|
|
106
|
+
"yahoo.com.au",
|
|
107
|
+
"yahoo.com.br",
|
|
108
|
+
"yahoo.co.jp",
|
|
109
|
+
"yahoo.com.sg",
|
|
110
|
+
"yahoo.com.ph",
|
|
111
|
+
"yahoo.co.id",
|
|
112
|
+
"rocketmail.com",
|
|
113
|
+
"aim.com",
|
|
114
|
+
"protonmail.ch",
|
|
115
|
+
"proton.ch",
|
|
116
|
+
"tutanota.de",
|
|
117
|
+
"tuta.com",
|
|
118
|
+
"tutamail.com",
|
|
119
|
+
"rediff.com",
|
|
120
|
+
// Other webmail
|
|
121
|
+
"email.com",
|
|
122
|
+
"usa.com",
|
|
123
|
+
"gmx.us",
|
|
124
|
+
"gmx.co.uk",
|
|
125
|
+
"gmx.at",
|
|
126
|
+
"gmx.ch",
|
|
127
|
+
"hushmail.com",
|
|
128
|
+
"mailfence.com",
|
|
129
|
+
"posteo.de",
|
|
130
|
+
"posteo.net",
|
|
131
|
+
"mailbox.org",
|
|
132
|
+
"runbox.com",
|
|
133
|
+
"disroot.org",
|
|
134
|
+
"inbox.com",
|
|
135
|
+
"zoho.in",
|
|
136
|
+
"ya.ru",
|
|
137
|
+
"yandex.by",
|
|
138
|
+
"yandex.kz",
|
|
139
|
+
"yandex.ua",
|
|
140
|
+
"inbox.ru",
|
|
141
|
+
"list.ru",
|
|
142
|
+
"bk.ru",
|
|
143
|
+
"rambler.ru",
|
|
144
|
+
"daum.net",
|
|
145
|
+
"hanmail.net",
|
|
146
|
+
"sina.com",
|
|
147
|
+
"sina.cn",
|
|
148
|
+
"sohu.com",
|
|
149
|
+
"yeah.net",
|
|
150
|
+
"foxmail.com",
|
|
151
|
+
"libero.it",
|
|
152
|
+
"virgilio.it",
|
|
153
|
+
"tiscali.it",
|
|
154
|
+
"laposte.net",
|
|
155
|
+
"free.fr",
|
|
156
|
+
"sfr.fr",
|
|
157
|
+
"wanadoo.fr",
|
|
158
|
+
"t-online.de",
|
|
159
|
+
"freenet.de",
|
|
160
|
+
"seznam.cz",
|
|
161
|
+
"wp.pl",
|
|
162
|
+
"o2.pl",
|
|
163
|
+
"interia.pl",
|
|
164
|
+
"onet.pl",
|
|
165
|
+
"bol.com.br",
|
|
166
|
+
"uol.com.br",
|
|
167
|
+
"terra.com.br",
|
|
168
|
+
"abv.bg",
|
|
169
|
+
"ukr.net",
|
|
170
|
+
// ISPs
|
|
171
|
+
"sbcglobal.net",
|
|
172
|
+
"bellsouth.net",
|
|
173
|
+
"cox.net",
|
|
174
|
+
"charter.net",
|
|
175
|
+
"earthlink.net",
|
|
176
|
+
"juno.com",
|
|
177
|
+
"optonline.net",
|
|
178
|
+
"frontier.com",
|
|
179
|
+
"windstream.net",
|
|
180
|
+
"shaw.ca",
|
|
181
|
+
"rogers.com",
|
|
182
|
+
"sympatico.ca",
|
|
183
|
+
"bigpond.com",
|
|
184
|
+
"optusnet.com.au",
|
|
185
|
+
"xtra.co.nz",
|
|
186
|
+
"virginmedia.com",
|
|
187
|
+
"ntlworld.com",
|
|
188
|
+
"talktalk.net",
|
|
189
|
+
"blueyonder.co.uk"
|
|
190
|
+
];
|
|
191
|
+
var DISPOSABLE_DOMAINS = [
|
|
192
|
+
// Mailinator and its alternate domains
|
|
193
|
+
"mailinator.com",
|
|
194
|
+
"mailinator.net",
|
|
195
|
+
"mailinator.org",
|
|
196
|
+
"mailinator2.com",
|
|
197
|
+
"mailinater.com",
|
|
198
|
+
"notmailinator.com",
|
|
199
|
+
"binkmail.com",
|
|
200
|
+
"bobmail.info",
|
|
201
|
+
"chammy.info",
|
|
202
|
+
"devnullmail.com",
|
|
203
|
+
"letthemeatspam.com",
|
|
204
|
+
"mailismagic.com",
|
|
205
|
+
"monumentmail.com",
|
|
206
|
+
"reallymymail.com",
|
|
207
|
+
"safetymail.info",
|
|
208
|
+
"sendspamhere.com",
|
|
209
|
+
"sogetthis.com",
|
|
210
|
+
"spamhereplease.com",
|
|
211
|
+
"spamherelots.com",
|
|
212
|
+
"spamthisplease.com",
|
|
213
|
+
"streetwisemail.com",
|
|
214
|
+
"suremail.info",
|
|
215
|
+
"thisisnotmyrealemail.com",
|
|
216
|
+
"tradermail.info",
|
|
217
|
+
"veryrealemail.com",
|
|
218
|
+
"zippymail.info",
|
|
219
|
+
"putthisinyourspamdatabase.com",
|
|
220
|
+
"mailtothis.com",
|
|
221
|
+
"uggsrock.com",
|
|
222
|
+
// 10 Minute Mail and similar
|
|
223
|
+
"10minutemail.com",
|
|
224
|
+
"10minutemail.net",
|
|
225
|
+
"10minutemail.org",
|
|
226
|
+
"10minutemail.de",
|
|
227
|
+
"10minutemail.co.uk",
|
|
228
|
+
"20minutemail.com",
|
|
229
|
+
"zehnminutenmail.de",
|
|
230
|
+
"minuteinbox.com",
|
|
231
|
+
"10mail.org",
|
|
232
|
+
"mvrht.com",
|
|
233
|
+
"mvrht.net",
|
|
234
|
+
// Guerrilla Mail
|
|
235
|
+
"guerrillamail.com",
|
|
236
|
+
"guerrillamail.net",
|
|
237
|
+
"guerrillamail.org",
|
|
238
|
+
"guerrillamail.biz",
|
|
239
|
+
"guerrillamail.de",
|
|
240
|
+
"guerrillamail.info",
|
|
241
|
+
"guerrillamailblock.com",
|
|
242
|
+
"grr.la",
|
|
243
|
+
"sharklasers.com",
|
|
244
|
+
"pokemail.net",
|
|
245
|
+
"spam4.me",
|
|
246
|
+
// YOPmail and its alternate domains
|
|
247
|
+
"yopmail.com",
|
|
248
|
+
"yopmail.net",
|
|
249
|
+
"yopmail.fr",
|
|
250
|
+
"cool.fr.nf",
|
|
251
|
+
"jetable.fr.nf",
|
|
252
|
+
"courriel.fr.nf",
|
|
253
|
+
"moncourrier.fr.nf",
|
|
254
|
+
"monemail.fr.nf",
|
|
255
|
+
"monmail.fr.nf",
|
|
256
|
+
"nospam.ze.tc",
|
|
257
|
+
"nomail.xl.cx",
|
|
258
|
+
"mega.zik.dj",
|
|
259
|
+
"speed.1s.fr",
|
|
260
|
+
// Temp Mail family
|
|
261
|
+
"temp-mail.org",
|
|
262
|
+
"temp-mail.io",
|
|
263
|
+
"temp-mail.ru",
|
|
264
|
+
"tempmail.com",
|
|
265
|
+
"tempmail.net",
|
|
266
|
+
"tempmailo.com",
|
|
267
|
+
"tempail.com",
|
|
268
|
+
"tempr.email",
|
|
269
|
+
"tempinbox.com",
|
|
270
|
+
"tempinbox.co.uk",
|
|
271
|
+
"tempemail.net",
|
|
272
|
+
"tempmailaddress.com",
|
|
273
|
+
"temporary-mail.net",
|
|
274
|
+
"temporaryemail.net",
|
|
275
|
+
"temporaryinbox.com",
|
|
276
|
+
"tempomail.fr",
|
|
277
|
+
"tempsky.com",
|
|
278
|
+
"tempymail.com",
|
|
279
|
+
"tempalias.com",
|
|
280
|
+
"tmpmail.org",
|
|
281
|
+
"tmpmail.net",
|
|
282
|
+
"mytemp.email",
|
|
283
|
+
"mail-temporaire.fr",
|
|
284
|
+
// 1secmail
|
|
285
|
+
"1secmail.com",
|
|
286
|
+
"1secmail.org",
|
|
287
|
+
"1secmail.net",
|
|
288
|
+
"esiix.com",
|
|
289
|
+
"wwjmp.com",
|
|
290
|
+
"xojxe.com",
|
|
291
|
+
"yoggm.com",
|
|
292
|
+
// Fake Mail Generator
|
|
293
|
+
"fakemailgenerator.com",
|
|
294
|
+
"armyspy.com",
|
|
295
|
+
"cuvox.de",
|
|
296
|
+
"dayrep.com",
|
|
297
|
+
"einrot.com",
|
|
298
|
+
"fleckens.hu",
|
|
299
|
+
"gustr.com",
|
|
300
|
+
"jourrapide.com",
|
|
301
|
+
"rhyta.com",
|
|
302
|
+
"superrito.com",
|
|
303
|
+
"teleworm.us",
|
|
304
|
+
// Trash Mail family
|
|
305
|
+
"trashmail.com",
|
|
306
|
+
"trashmail.net",
|
|
307
|
+
"trashmail.de",
|
|
308
|
+
"trashmail.me",
|
|
309
|
+
"trashmail.at",
|
|
310
|
+
"trashmail.io",
|
|
311
|
+
"trashmail.ws",
|
|
312
|
+
"trash-mail.at",
|
|
313
|
+
"trash-mail.com",
|
|
314
|
+
"trash-mail.de",
|
|
315
|
+
"trashmailer.com",
|
|
316
|
+
"trashymail.com",
|
|
317
|
+
"trashymail.net",
|
|
318
|
+
"mytrashmail.com",
|
|
319
|
+
"trashdevil.com",
|
|
320
|
+
"trashdevil.de",
|
|
321
|
+
"mailtrash.net",
|
|
322
|
+
"kurzepost.de",
|
|
323
|
+
"objectmail.com",
|
|
324
|
+
"proxymail.eu",
|
|
325
|
+
"rcpt.at",
|
|
326
|
+
"wegwerfmail.de",
|
|
327
|
+
"wegwerfmail.net",
|
|
328
|
+
"wegwerfmail.org",
|
|
329
|
+
"wegwerfemail.de",
|
|
330
|
+
"sofort-mail.de",
|
|
331
|
+
// Jetable
|
|
332
|
+
"jetable.org",
|
|
333
|
+
"jetable.net",
|
|
334
|
+
"jetable.com",
|
|
335
|
+
// Spam Gourmet and other forwarding throwaways
|
|
336
|
+
"spamgourmet.com",
|
|
337
|
+
"spamgourmet.net",
|
|
338
|
+
"spamgourmet.org",
|
|
339
|
+
// Other well-known services
|
|
340
|
+
"maildrop.cc",
|
|
341
|
+
"getnada.com",
|
|
342
|
+
"nada.email",
|
|
343
|
+
"dispostable.com",
|
|
344
|
+
"throwawaymail.com",
|
|
345
|
+
"throwawayemailaddress.com",
|
|
346
|
+
"fakeinbox.com",
|
|
347
|
+
"mailnesia.com",
|
|
348
|
+
"mintemail.com",
|
|
349
|
+
"mohmal.com",
|
|
350
|
+
"emailondeck.com",
|
|
351
|
+
"burnermail.io",
|
|
352
|
+
"discard.email",
|
|
353
|
+
"discardmail.com",
|
|
354
|
+
"discardmail.de",
|
|
355
|
+
"mailcatch.com",
|
|
356
|
+
"mailexpire.com",
|
|
357
|
+
"mailnull.com",
|
|
358
|
+
"spamex.com",
|
|
359
|
+
"mailforspam.com",
|
|
360
|
+
"0-mail.com",
|
|
361
|
+
"0815.ru",
|
|
362
|
+
"anonbox.net",
|
|
363
|
+
"emailfake.com",
|
|
364
|
+
"generator.email",
|
|
365
|
+
"harakirimail.com",
|
|
366
|
+
"inboxkitten.com",
|
|
367
|
+
"mailpoof.com",
|
|
368
|
+
"moakt.com",
|
|
369
|
+
"moakt.cc",
|
|
370
|
+
"dropmail.me",
|
|
371
|
+
"emltmp.com",
|
|
372
|
+
"mailsac.com",
|
|
373
|
+
"getairmail.com",
|
|
374
|
+
"mailmetrash.com",
|
|
375
|
+
"kasmail.com",
|
|
376
|
+
"filzmail.com",
|
|
377
|
+
"spambog.com",
|
|
378
|
+
"spambog.de",
|
|
379
|
+
"spambog.ru",
|
|
380
|
+
"deadaddress.com",
|
|
381
|
+
"mailmoat.com",
|
|
382
|
+
"spamfree24.org",
|
|
383
|
+
"spamdecoy.net",
|
|
384
|
+
"spamspot.com",
|
|
385
|
+
"spaml.com",
|
|
386
|
+
"spaml.de",
|
|
387
|
+
"fakemail.net",
|
|
388
|
+
"inboxbear.com",
|
|
389
|
+
"crazymailing.com",
|
|
390
|
+
"disbox.net",
|
|
391
|
+
"disbox.org",
|
|
392
|
+
"dodgeit.com",
|
|
393
|
+
"dodgit.com",
|
|
394
|
+
"getonemail.com",
|
|
395
|
+
"haltospam.com",
|
|
396
|
+
"mailin8r.com",
|
|
397
|
+
"mailscrap.com",
|
|
398
|
+
"mailzilla.com",
|
|
399
|
+
"nobulk.com",
|
|
400
|
+
"noclickemail.com",
|
|
401
|
+
"nogmailspam.info",
|
|
402
|
+
"nomail2me.com",
|
|
403
|
+
"nospamfor.us",
|
|
404
|
+
"nowmymail.com",
|
|
405
|
+
"pookmail.com",
|
|
406
|
+
"quickinbox.com",
|
|
407
|
+
"spamavert.com",
|
|
408
|
+
"spambox.info",
|
|
409
|
+
"spambox.us",
|
|
410
|
+
"spamcero.com",
|
|
411
|
+
"spamcorptastic.com",
|
|
412
|
+
"spamday.com",
|
|
413
|
+
"spamify.com",
|
|
414
|
+
"spaminator.de",
|
|
415
|
+
"spammotel.com",
|
|
416
|
+
"spamtrail.com",
|
|
417
|
+
"twinmail.de",
|
|
418
|
+
"wh4f.org",
|
|
419
|
+
"willselfdestruct.com",
|
|
420
|
+
"wuzup.net",
|
|
421
|
+
"wuzupmail.net",
|
|
422
|
+
"yuurok.com",
|
|
423
|
+
"zoemail.org",
|
|
424
|
+
"smashmail.de",
|
|
425
|
+
"mt2014.com",
|
|
426
|
+
"mt2015.com",
|
|
427
|
+
"thankyou2010.com",
|
|
428
|
+
"trash2009.com",
|
|
429
|
+
"mailto.plus",
|
|
430
|
+
"fexpost.com",
|
|
431
|
+
"fexbox.org",
|
|
432
|
+
"rover.info",
|
|
433
|
+
"chitthi.in",
|
|
434
|
+
"fextemp.com",
|
|
435
|
+
"merepost.com",
|
|
436
|
+
"incognitomail.com"
|
|
437
|
+
];
|
|
438
|
+
var ROLE_LOCAL_PARTS = [
|
|
439
|
+
"abuse",
|
|
440
|
+
"accounts",
|
|
441
|
+
"accounting",
|
|
442
|
+
"admin",
|
|
443
|
+
"administrator",
|
|
444
|
+
"all",
|
|
445
|
+
"billing",
|
|
446
|
+
"careers",
|
|
447
|
+
"compliance",
|
|
448
|
+
"contact",
|
|
449
|
+
"contactus",
|
|
450
|
+
"contact-us",
|
|
451
|
+
"customercare",
|
|
452
|
+
"customerservice",
|
|
453
|
+
"customer-service",
|
|
454
|
+
"devnull",
|
|
455
|
+
"dns",
|
|
456
|
+
"enquiries",
|
|
457
|
+
"enquiry",
|
|
458
|
+
"everyone",
|
|
459
|
+
"feedback",
|
|
460
|
+
"finance",
|
|
461
|
+
"ftp",
|
|
462
|
+
"hello",
|
|
463
|
+
"help",
|
|
464
|
+
"helpdesk",
|
|
465
|
+
"hostmaster",
|
|
466
|
+
"hr",
|
|
467
|
+
"info",
|
|
468
|
+
"inquiries",
|
|
469
|
+
"inquiry",
|
|
470
|
+
"it",
|
|
471
|
+
"jobs",
|
|
472
|
+
"legal",
|
|
473
|
+
"list",
|
|
474
|
+
"mail",
|
|
475
|
+
"mailer-daemon",
|
|
476
|
+
"marketing",
|
|
477
|
+
"media",
|
|
478
|
+
"news",
|
|
479
|
+
"newsletter",
|
|
480
|
+
"no-reply",
|
|
481
|
+
"noreply",
|
|
482
|
+
"do-not-reply",
|
|
483
|
+
"donotreply",
|
|
484
|
+
"null",
|
|
485
|
+
"office",
|
|
486
|
+
"orders",
|
|
487
|
+
"postmaster",
|
|
488
|
+
"press",
|
|
489
|
+
"privacy",
|
|
490
|
+
"recruitment",
|
|
491
|
+
"root",
|
|
492
|
+
"sales",
|
|
493
|
+
"security",
|
|
494
|
+
"service",
|
|
495
|
+
"staff",
|
|
496
|
+
"support",
|
|
497
|
+
"sysadmin",
|
|
498
|
+
"team",
|
|
499
|
+
"tech",
|
|
500
|
+
"webmaster",
|
|
501
|
+
"www"
|
|
502
|
+
];
|
|
503
|
+
var TWO_LEVEL_SUFFIXES = [
|
|
504
|
+
"co.in",
|
|
505
|
+
"net.in",
|
|
506
|
+
"org.in",
|
|
507
|
+
"firm.in",
|
|
508
|
+
"gen.in",
|
|
509
|
+
"ind.in",
|
|
510
|
+
"ac.in",
|
|
511
|
+
"edu.in",
|
|
512
|
+
"gov.in",
|
|
513
|
+
"res.in",
|
|
514
|
+
"co.uk",
|
|
515
|
+
"org.uk",
|
|
516
|
+
"me.uk",
|
|
517
|
+
"ac.uk",
|
|
518
|
+
"gov.uk",
|
|
519
|
+
"ltd.uk",
|
|
520
|
+
"plc.uk",
|
|
521
|
+
"com.au",
|
|
522
|
+
"net.au",
|
|
523
|
+
"org.au",
|
|
524
|
+
"edu.au",
|
|
525
|
+
"co.nz",
|
|
526
|
+
"org.nz",
|
|
527
|
+
"co.za",
|
|
528
|
+
"co.jp",
|
|
529
|
+
"ne.jp",
|
|
530
|
+
"or.jp",
|
|
531
|
+
"ac.jp",
|
|
532
|
+
"com.br",
|
|
533
|
+
"com.cn",
|
|
534
|
+
"com.sg",
|
|
535
|
+
"com.my",
|
|
536
|
+
"com.ph",
|
|
537
|
+
"co.id",
|
|
538
|
+
"com.mx",
|
|
539
|
+
"com.ar",
|
|
540
|
+
"com.tr",
|
|
541
|
+
"com.hk",
|
|
542
|
+
"com.tw",
|
|
543
|
+
"co.kr",
|
|
544
|
+
"com.pk",
|
|
545
|
+
"com.bd",
|
|
546
|
+
"com.np",
|
|
547
|
+
"com.lk",
|
|
548
|
+
"co.il"
|
|
549
|
+
];
|
|
550
|
+
var SECOND_LEVEL_LABELS = [
|
|
551
|
+
"co",
|
|
552
|
+
"com",
|
|
553
|
+
"net",
|
|
554
|
+
"org",
|
|
555
|
+
"ac",
|
|
556
|
+
"edu",
|
|
557
|
+
"gov",
|
|
558
|
+
"ne",
|
|
559
|
+
"or"
|
|
560
|
+
];
|
|
561
|
+
var TLD_TYPOS = {
|
|
562
|
+
con: "com",
|
|
563
|
+
cmo: "com",
|
|
564
|
+
ocm: "com",
|
|
565
|
+
comm: "com",
|
|
566
|
+
vom: "com",
|
|
567
|
+
xom: "com",
|
|
568
|
+
cpm: "com",
|
|
569
|
+
cim: "com",
|
|
570
|
+
coom: "com",
|
|
571
|
+
comn: "com",
|
|
572
|
+
ccom: "com",
|
|
573
|
+
conm: "com",
|
|
574
|
+
copm: "com",
|
|
575
|
+
clm: "com",
|
|
576
|
+
nte: "net",
|
|
577
|
+
ner: "net",
|
|
578
|
+
nett: "net",
|
|
579
|
+
nwt: "net",
|
|
580
|
+
ogr: "org",
|
|
581
|
+
orgg: "org",
|
|
582
|
+
rog: "org",
|
|
583
|
+
prg: "org",
|
|
584
|
+
irg: "org",
|
|
585
|
+
"co.inn": "co.in",
|
|
586
|
+
"co.ukk": "co.uk"
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
// src/syntax.ts
|
|
590
|
+
var MAX_TOTAL = 254;
|
|
591
|
+
var MAX_LOCAL = 64;
|
|
592
|
+
var MAX_DOMAIN = 253;
|
|
593
|
+
var MAX_LABEL = 63;
|
|
594
|
+
var ATOM_SPECIALS = "!#$%&'*+/=?^_`{|}~-";
|
|
595
|
+
var UNICODE_WORD = /[\p{L}\p{M}\p{N}]/u;
|
|
596
|
+
var ALPHA_ONLY = /^[a-z]+$/;
|
|
597
|
+
var UNICODE_LETTERS = /^[\p{L}\p{M}]+$/u;
|
|
598
|
+
function isAsciiAlnum(c) {
|
|
599
|
+
return c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122;
|
|
600
|
+
}
|
|
601
|
+
function utf8Length(s) {
|
|
602
|
+
let n = 0;
|
|
603
|
+
for (let i = 0; i < s.length; i++) {
|
|
604
|
+
const c = s.charCodeAt(i);
|
|
605
|
+
if (c < 128) n += 1;
|
|
606
|
+
else if (c < 2048) n += 2;
|
|
607
|
+
else if (c >= 55296 && c <= 56319) {
|
|
608
|
+
n += 4;
|
|
609
|
+
i++;
|
|
610
|
+
} else n += 3;
|
|
611
|
+
}
|
|
612
|
+
return n;
|
|
613
|
+
}
|
|
614
|
+
function validDotAtom(local, unicode) {
|
|
615
|
+
if (local.length === 0) return false;
|
|
616
|
+
let prevDot = true;
|
|
617
|
+
for (const ch of local) {
|
|
618
|
+
const c = ch.codePointAt(0);
|
|
619
|
+
if (ch === ".") {
|
|
620
|
+
if (prevDot) return false;
|
|
621
|
+
prevDot = true;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
prevDot = false;
|
|
625
|
+
if (c < 128) {
|
|
626
|
+
if (isAsciiAlnum(c) || ATOM_SPECIALS.includes(ch)) continue;
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
if (!unicode || !UNICODE_WORD.test(ch)) return false;
|
|
630
|
+
}
|
|
631
|
+
return !prevDot;
|
|
632
|
+
}
|
|
633
|
+
function validQuotedContent(content, unicode) {
|
|
634
|
+
for (let i = 0; i < content.length; i++) {
|
|
635
|
+
const c = content.charCodeAt(i);
|
|
636
|
+
if (c === 92) {
|
|
637
|
+
const n = content.charCodeAt(i + 1);
|
|
638
|
+
if (!(n === 9 || n >= 32 && n <= 126)) return false;
|
|
639
|
+
i++;
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
if (c === 34) return false;
|
|
643
|
+
if (c === 32 || c === 9) continue;
|
|
644
|
+
if (c < 32 || c === 127) return false;
|
|
645
|
+
if (c >= 128) {
|
|
646
|
+
if (!unicode) return false;
|
|
647
|
+
if (c >= 128 && c <= 159) return false;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
function validIpv4(s) {
|
|
653
|
+
const parts = s.split(".");
|
|
654
|
+
if (parts.length !== 4) return false;
|
|
655
|
+
for (const p of parts) {
|
|
656
|
+
if (p.length === 0 || p.length > 3) return false;
|
|
657
|
+
for (let i = 0; i < p.length; i++) {
|
|
658
|
+
const c = p.charCodeAt(i);
|
|
659
|
+
if (c < 48 || c > 57) return false;
|
|
660
|
+
}
|
|
661
|
+
if (p.length > 1 && p[0] === "0") return false;
|
|
662
|
+
if (Number(p) > 255) return false;
|
|
663
|
+
}
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
function validHexGroups(groups) {
|
|
667
|
+
for (const g of groups) {
|
|
668
|
+
if (g.length === 0 || g.length > 4) return false;
|
|
669
|
+
for (let i = 0; i < g.length; i++) {
|
|
670
|
+
const c = g.charCodeAt(i);
|
|
671
|
+
const hex = c >= 48 && c <= 57 || c >= 97 && c <= 102 || c >= 65 && c <= 70;
|
|
672
|
+
if (!hex) return false;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
function validIpv6(input) {
|
|
678
|
+
if (input.length < 2 || input.length > 45) return false;
|
|
679
|
+
let s = input;
|
|
680
|
+
const lastColon = s.lastIndexOf(":");
|
|
681
|
+
if (lastColon < 0) return false;
|
|
682
|
+
const tail = s.slice(lastColon + 1);
|
|
683
|
+
if (tail.includes(".")) {
|
|
684
|
+
if (!validIpv4(tail)) return false;
|
|
685
|
+
s = s.slice(0, lastColon + 1) + "0:0";
|
|
686
|
+
}
|
|
687
|
+
const halves = s.split("::");
|
|
688
|
+
if (halves.length > 2) return false;
|
|
689
|
+
if (halves.length === 2) {
|
|
690
|
+
const left = halves[0] === "" ? [] : halves[0].split(":");
|
|
691
|
+
const right = halves[1] === "" ? [] : halves[1].split(":");
|
|
692
|
+
return validHexGroups(left) && validHexGroups(right) && left.length + right.length <= 7;
|
|
693
|
+
}
|
|
694
|
+
const groups = s.split(":");
|
|
695
|
+
return groups.length === 8 && validHexGroups(groups);
|
|
696
|
+
}
|
|
697
|
+
function validAddressLiteral(domain) {
|
|
698
|
+
const inner = domain.slice(1, -1);
|
|
699
|
+
if (/^ipv6:/i.test(inner)) return validIpv6(inner.slice(5));
|
|
700
|
+
return validIpv4(inner);
|
|
701
|
+
}
|
|
702
|
+
function validLabel(label, unicode) {
|
|
703
|
+
if (label.length === 0 || label.length > MAX_LABEL) return false;
|
|
704
|
+
if (label[0] === "-" || label[label.length - 1] === "-") return false;
|
|
705
|
+
for (const ch of label) {
|
|
706
|
+
const c = ch.codePointAt(0);
|
|
707
|
+
if (c < 128) {
|
|
708
|
+
if (isAsciiAlnum(c) || ch === "-") continue;
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
if (!unicode || !UNICODE_WORD.test(ch)) return false;
|
|
712
|
+
}
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
function validTld(tld, unicode) {
|
|
716
|
+
if (tld.startsWith("xn--")) return tld.length > 4;
|
|
717
|
+
if (ALPHA_ONLY.test(tld)) return tld.length >= 2;
|
|
718
|
+
return unicode && UNICODE_LETTERS.test(tld) && tld.length >= 2;
|
|
719
|
+
}
|
|
720
|
+
function parseAddress(input, options = {}) {
|
|
721
|
+
if (typeof input !== "string") return { email: "", local: "", domain: "", reason: "empty" };
|
|
722
|
+
const s = input.trim();
|
|
723
|
+
if (s.length === 0) return { email: "", local: "", domain: "", reason: "empty" };
|
|
724
|
+
const unicode = options.allowUnicode !== false;
|
|
725
|
+
if (s.length > MAX_TOTAL * 4) return { email: s, local: "", domain: "", reason: "too-long" };
|
|
726
|
+
let local;
|
|
727
|
+
let domain;
|
|
728
|
+
let quoted = false;
|
|
729
|
+
if (s[0] === '"') {
|
|
730
|
+
let i = 1;
|
|
731
|
+
let closed = -1;
|
|
732
|
+
while (i < s.length) {
|
|
733
|
+
const c = s[i];
|
|
734
|
+
if (c === "\\") {
|
|
735
|
+
i += 2;
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
if (c === '"') {
|
|
739
|
+
closed = i;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
i++;
|
|
743
|
+
}
|
|
744
|
+
if (closed < 0 || s[closed + 1] !== "@") return { email: s, local: "", domain: "", reason: "syntax" };
|
|
745
|
+
local = s.slice(0, closed + 1);
|
|
746
|
+
domain = s.slice(closed + 2);
|
|
747
|
+
quoted = true;
|
|
748
|
+
} else {
|
|
749
|
+
const at = s.indexOf("@");
|
|
750
|
+
if (at < 0) return { email: s, local: "", domain: "", reason: "syntax" };
|
|
751
|
+
local = s.slice(0, at);
|
|
752
|
+
domain = s.slice(at + 1);
|
|
753
|
+
}
|
|
754
|
+
const literal = domain.length > 2 && domain[0] === "[" && domain[domain.length - 1] === "]";
|
|
755
|
+
if (!literal) domain = domain.toLowerCase();
|
|
756
|
+
const email = `${local}@${domain}`;
|
|
757
|
+
const base = { email, local, domain };
|
|
758
|
+
if (domain.includes("@")) return { ...base, reason: "syntax" };
|
|
759
|
+
if (local.length === 0) return { ...base, reason: "syntax" };
|
|
760
|
+
if (utf8Length(email) > MAX_TOTAL || utf8Length(local) > MAX_LOCAL) return { ...base, reason: "too-long" };
|
|
761
|
+
const localOk = quoted ? validQuotedContent(local.slice(1, -1), unicode) : validDotAtom(local, unicode);
|
|
762
|
+
if (!localOk) return { ...base, reason: "syntax" };
|
|
763
|
+
if (domain.length === 0) return { ...base, reason: "domain" };
|
|
764
|
+
if (literal) {
|
|
765
|
+
return options.allowIp === true && validAddressLiteral(domain) ? base : { ...base, reason: "domain" };
|
|
766
|
+
}
|
|
767
|
+
if (utf8Length(domain) > MAX_DOMAIN) return { ...base, reason: "too-long" };
|
|
768
|
+
const labels = domain.split(".");
|
|
769
|
+
for (const label of labels) {
|
|
770
|
+
if (!validLabel(label, unicode)) return { ...base, reason: "domain" };
|
|
771
|
+
}
|
|
772
|
+
if (labels.length < 2) return { ...base, reason: "domain" };
|
|
773
|
+
if (!validTld(labels[labels.length - 1], unicode)) return { ...base, reason: "tld" };
|
|
774
|
+
return base;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// src/suggest.ts
|
|
778
|
+
function editDistance(a, b, max = Infinity) {
|
|
779
|
+
if (a === b) return 0;
|
|
780
|
+
if (Math.abs(a.length - b.length) > max) return max + 1;
|
|
781
|
+
const n = a.length;
|
|
782
|
+
const m = b.length;
|
|
783
|
+
if (n === 0) return m;
|
|
784
|
+
if (m === 0) return n;
|
|
785
|
+
let prev2 = new Array(m + 1).fill(0);
|
|
786
|
+
let prev = new Array(m + 1);
|
|
787
|
+
let cur = new Array(m + 1);
|
|
788
|
+
for (let j = 0; j <= m; j++) prev[j] = j;
|
|
789
|
+
for (let i = 1; i <= n; i++) {
|
|
790
|
+
cur[0] = i;
|
|
791
|
+
let rowMin = i;
|
|
792
|
+
for (let j = 1; j <= m; j++) {
|
|
793
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
794
|
+
let v = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + cost);
|
|
795
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
796
|
+
v = Math.min(v, prev2[j - 2] + 1);
|
|
797
|
+
}
|
|
798
|
+
cur[j] = v;
|
|
799
|
+
if (v < rowMin) rowMin = v;
|
|
800
|
+
}
|
|
801
|
+
if (rowMin > max) return max + 1;
|
|
802
|
+
const t = prev2;
|
|
803
|
+
prev2 = prev;
|
|
804
|
+
prev = cur;
|
|
805
|
+
cur = t;
|
|
806
|
+
}
|
|
807
|
+
return prev[m];
|
|
808
|
+
}
|
|
809
|
+
var TWO_LEVEL = new Set(TWO_LEVEL_SUFFIXES);
|
|
810
|
+
var SECOND_LEVEL = new Set(SECOND_LEVEL_LABELS);
|
|
811
|
+
function splitDomain(domain) {
|
|
812
|
+
const labels = domain.split(".");
|
|
813
|
+
if (labels.length < 2) return { name: domain, suffix: "" };
|
|
814
|
+
if (labels.length >= 3) {
|
|
815
|
+
const last2 = labels.slice(-2).join(".");
|
|
816
|
+
if (TWO_LEVEL.has(last2) || SECOND_LEVEL.has(labels[labels.length - 2])) {
|
|
817
|
+
return { name: labels.slice(0, -2).join("."), suffix: last2 };
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return { name: labels.slice(0, -1).join("."), suffix: labels[labels.length - 1] };
|
|
821
|
+
}
|
|
822
|
+
function nameBudget(length) {
|
|
823
|
+
if (length <= 3) return 0;
|
|
824
|
+
if (length <= 5) return 1;
|
|
825
|
+
return 2;
|
|
826
|
+
}
|
|
827
|
+
var cache = /* @__PURE__ */ new Map();
|
|
828
|
+
function known(domain) {
|
|
829
|
+
let k = cache.get(domain);
|
|
830
|
+
if (!k) {
|
|
831
|
+
const { name, suffix } = splitDomain(domain);
|
|
832
|
+
k = { domain, name, suffix, flat: domain.split(".").join("") };
|
|
833
|
+
if (cache.size < 1e3) cache.set(domain, k);
|
|
834
|
+
}
|
|
835
|
+
return k;
|
|
836
|
+
}
|
|
837
|
+
var MAX_FUZZY_LENGTH = 64;
|
|
838
|
+
function suggestDomain(domain, providers, exact) {
|
|
839
|
+
if (!domain || domain.length > 253 || exact(domain)) return void 0;
|
|
840
|
+
const list = providers.map(known);
|
|
841
|
+
if (!domain.includes(".")) {
|
|
842
|
+
if (domain.length > MAX_FUZZY_LENGTH) return void 0;
|
|
843
|
+
const budget = nameBudget(domain.length);
|
|
844
|
+
let best;
|
|
845
|
+
let bestScore = Infinity;
|
|
846
|
+
for (const k of list) {
|
|
847
|
+
if (k.name.includes(".")) continue;
|
|
848
|
+
const score = Math.min(editDistance(domain, k.name, budget), editDistance(domain, k.flat, budget));
|
|
849
|
+
if (score <= budget && score < bestScore) {
|
|
850
|
+
best = k;
|
|
851
|
+
bestScore = score;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return best?.domain;
|
|
855
|
+
}
|
|
856
|
+
const { name, suffix } = splitDomain(domain);
|
|
857
|
+
const fixedSuffix = TLD_TYPOS[suffix] ?? suffix;
|
|
858
|
+
const badTld = !/^[a-z]{2,}$/.test(suffix.split(".").pop() ?? "") && !suffix.startsWith("xn--");
|
|
859
|
+
if (!name.includes(".") && name.length <= MAX_FUZZY_LENGTH) {
|
|
860
|
+
const budget = nameBudget(name.length);
|
|
861
|
+
let best;
|
|
862
|
+
let bestScore = Infinity;
|
|
863
|
+
for (const k of list) {
|
|
864
|
+
if (k.name.includes(".")) continue;
|
|
865
|
+
const dName = editDistance(name, k.name, budget);
|
|
866
|
+
if (dName > budget) continue;
|
|
867
|
+
const dSuffix = fixedSuffix === k.suffix ? suffix === k.suffix ? 0 : 1 : editDistance(suffix, k.suffix, 2);
|
|
868
|
+
const suffixBudget = dName === 0 && badTld ? 2 : 1;
|
|
869
|
+
if (dSuffix > suffixBudget || dName + dSuffix > 2) continue;
|
|
870
|
+
const score = dName + dSuffix;
|
|
871
|
+
if (score > 0 && score < bestScore) {
|
|
872
|
+
best = k;
|
|
873
|
+
bestScore = score;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
if (best) return best.domain;
|
|
877
|
+
}
|
|
878
|
+
if (fixedSuffix !== suffix) {
|
|
879
|
+
const fixed = `${name}.${fixedSuffix}`;
|
|
880
|
+
return fixed === domain ? void 0 : fixed;
|
|
881
|
+
}
|
|
882
|
+
return void 0;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// src/index.ts
|
|
886
|
+
var DISPOSABLE = new Set(DISPOSABLE_DOMAINS);
|
|
887
|
+
var FREE = new Set(FREE_DOMAINS);
|
|
888
|
+
var POPULAR = new Set(POPULAR_DOMAINS);
|
|
889
|
+
var ROLES = new Set(ROLE_LOCAL_PARTS);
|
|
890
|
+
function lower(list) {
|
|
891
|
+
if (!Array.isArray(list)) return [];
|
|
892
|
+
const out = [];
|
|
893
|
+
for (const d of list) if (typeof d === "string" && d.trim()) out.push(d.trim().toLowerCase());
|
|
894
|
+
return out;
|
|
895
|
+
}
|
|
896
|
+
function matchesDomainList(domain, builtIn, extra) {
|
|
897
|
+
if (!domain || domain.length > 253) return false;
|
|
898
|
+
let d = domain;
|
|
899
|
+
for (let i = 0; i < 127; i++) {
|
|
900
|
+
if (builtIn.has(d) || extra.includes(d)) return true;
|
|
901
|
+
const dot = d.indexOf(".");
|
|
902
|
+
if (dot < 0) return false;
|
|
903
|
+
d = d.slice(dot + 1);
|
|
904
|
+
if (!d.includes(".")) return false;
|
|
905
|
+
}
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
function disposableDomain(domain, extra = []) {
|
|
909
|
+
return matchesDomainList(domain, DISPOSABLE, extra);
|
|
910
|
+
}
|
|
911
|
+
function roleLocal(local) {
|
|
912
|
+
if (!local) return false;
|
|
913
|
+
let l = local.toLowerCase();
|
|
914
|
+
const plus = l.indexOf("+");
|
|
915
|
+
if (plus > 0) l = l.slice(0, plus);
|
|
916
|
+
return ROLES.has(l);
|
|
917
|
+
}
|
|
918
|
+
function suggestFor(local, domain, extraDomains, extraDisposable) {
|
|
919
|
+
const providers = extraDomains.length ? [...POPULAR_DOMAINS, ...extraDomains] : POPULAR_DOMAINS;
|
|
920
|
+
const exact = (d) => POPULAR.has(d) || FREE.has(d) || extraDomains.includes(d) || disposableDomain(d, extraDisposable);
|
|
921
|
+
const fixed = suggestDomain(domain, providers, exact);
|
|
922
|
+
return fixed ? `${local}@${fixed}` : void 0;
|
|
923
|
+
}
|
|
924
|
+
function check(email, options = {}) {
|
|
925
|
+
try {
|
|
926
|
+
return checkUnsafe(email, options ?? {});
|
|
927
|
+
} catch {
|
|
928
|
+
return { valid: false, email: "", local: "", domain: "", reason: "syntax", disposable: false, role: false, free: false };
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
function checkUnsafe(email, options) {
|
|
932
|
+
const parsed = parseAddress(email, options);
|
|
933
|
+
const { local, domain } = parsed;
|
|
934
|
+
const extraDomains = lower(options.domains);
|
|
935
|
+
const extraDisposable = lower(options.disposableDomains);
|
|
936
|
+
const result = {
|
|
937
|
+
valid: false,
|
|
938
|
+
email: parsed.email,
|
|
939
|
+
local,
|
|
940
|
+
domain,
|
|
941
|
+
disposable: disposableDomain(domain, extraDisposable),
|
|
942
|
+
role: roleLocal(local),
|
|
943
|
+
free: FREE.has(domain)
|
|
944
|
+
};
|
|
945
|
+
if (local && domain && (!parsed.reason || parsed.reason === "domain" || parsed.reason === "tld")) {
|
|
946
|
+
const suggestion = suggestFor(local, domain, extraDomains, extraDisposable);
|
|
947
|
+
if (suggestion) result.suggestion = suggestion;
|
|
948
|
+
}
|
|
949
|
+
if (parsed.reason) result.reason = parsed.reason;
|
|
950
|
+
else if (result.disposable && options.allowDisposable === false) result.reason = "disposable";
|
|
951
|
+
else if (result.role && options.allowRole === false) result.reason = "role";
|
|
952
|
+
else result.valid = true;
|
|
953
|
+
return result;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// src/dns.ts
|
|
957
|
+
var TIMED_OUT = /* @__PURE__ */ Symbol("timeout");
|
|
958
|
+
var NO_RECORDS = /* @__PURE__ */ new Set(["ENOTFOUND", "ENODATA", "NXDOMAIN", "ENONAME"]);
|
|
959
|
+
function codeOf(error) {
|
|
960
|
+
return typeof error === "object" && error !== null && "code" in error ? String(error.code) : "";
|
|
961
|
+
}
|
|
962
|
+
function withTimeout(promise, ms) {
|
|
963
|
+
let timer;
|
|
964
|
+
const timeout = new Promise((resolve) => {
|
|
965
|
+
timer = setTimeout(() => resolve(TIMED_OUT), ms);
|
|
966
|
+
timer.unref?.();
|
|
967
|
+
});
|
|
968
|
+
return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
|
|
969
|
+
}
|
|
970
|
+
function domainFrom(input) {
|
|
971
|
+
const s = input.trim();
|
|
972
|
+
let d = s.slice(s.lastIndexOf("@") + 1).toLowerCase();
|
|
973
|
+
if (d.endsWith(".")) d = d.slice(0, -1);
|
|
974
|
+
if (!d || d.length > 253 || d.startsWith("[")) return "";
|
|
975
|
+
if (!check(`x@${d}`).valid) return "";
|
|
976
|
+
return (0, import_node_url.domainToASCII)(d);
|
|
977
|
+
}
|
|
978
|
+
async function lookup(run, ms) {
|
|
979
|
+
try {
|
|
980
|
+
const r = await withTimeout(run(), ms);
|
|
981
|
+
if (r === TIMED_OUT) return { state: "unknown", records: [] };
|
|
982
|
+
return { state: r.length > 0 ? "yes" : "no", records: r };
|
|
983
|
+
} catch (error) {
|
|
984
|
+
return { state: NO_RECORDS.has(codeOf(error)) ? "no" : "unknown", records: [] };
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
async function hasMx(domainOrEmail, options = {}) {
|
|
988
|
+
try {
|
|
989
|
+
if (typeof domainOrEmail !== "string") return false;
|
|
990
|
+
const domain = domainFrom(domainOrEmail);
|
|
991
|
+
if (!domain) return false;
|
|
992
|
+
const timeout = typeof options.timeout === "number" && options.timeout > 0 ? options.timeout : 5e3;
|
|
993
|
+
const resolver = options.resolver ?? new import_promises.Resolver({ timeout, tries: 2 });
|
|
994
|
+
const mx = await lookup(() => resolver.resolveMx(domain), timeout);
|
|
995
|
+
if (mx.state === "yes") {
|
|
996
|
+
const real = mx.records.filter((r) => r && typeof r.exchange === "string" && r.exchange !== "" && r.exchange !== ".");
|
|
997
|
+
return real.length > 0;
|
|
998
|
+
}
|
|
999
|
+
if (mx.state === "unknown") return null;
|
|
1000
|
+
const [a, aaaa] = await Promise.all([
|
|
1001
|
+
lookup(() => resolver.resolve4(domain), timeout),
|
|
1002
|
+
lookup(() => resolver.resolve6(domain), timeout)
|
|
1003
|
+
]);
|
|
1004
|
+
if (a.state === "yes" || aaaa.state === "yes") return true;
|
|
1005
|
+
if (a.state === "unknown" || aaaa.state === "unknown") return null;
|
|
1006
|
+
return false;
|
|
1007
|
+
} catch {
|
|
1008
|
+
return null;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
async function checkDeliverable(email, options = {}) {
|
|
1012
|
+
const result = check(email, options);
|
|
1013
|
+
if (!result.valid) return { ...result, mx: null };
|
|
1014
|
+
if (result.domain.startsWith("[")) return { ...result, mx: null };
|
|
1015
|
+
const mx = await hasMx(result.domain, options);
|
|
1016
|
+
if (mx === false) return { ...result, valid: false, reason: "mx", mx };
|
|
1017
|
+
return { ...result, mx };
|
|
1018
|
+
}
|