@brilab-mailer/utils 0.0.2-3 → 0.0.2-5
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":"is-real-email.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/is-real-email.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAGzB,qBACa,qBAAsB,YAAW,4BAA4B;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"is-real-email.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/is-real-email.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAGzB,qBACa,qBAAsB,YAAW,4BAA4B;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM;IAe5B,cAAc;CAGf;AAED,wBAAgB,WAAW,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,CAWpF"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { registerDecorator, ValidatorConstraint, } from 'class-validator';
|
|
3
|
-
import
|
|
3
|
+
import { Resolver, resolveMx } from 'node:dns/promises';
|
|
4
4
|
let IsRealEmailConstraint = class IsRealEmailConstraint {
|
|
5
5
|
async validate(email) {
|
|
6
6
|
try {
|
|
7
7
|
const domain = email.split('@').at(-1);
|
|
8
8
|
if (!domain)
|
|
9
9
|
return false;
|
|
10
|
-
const
|
|
10
|
+
const resolver = new Resolver();
|
|
11
|
+
resolver.setServers(['1.1.1.1', '8.8.8.8']);
|
|
12
|
+
const USE_RESOLVER = true;
|
|
13
|
+
const service = USE_RESOLVER ? resolver.resolveMx : resolveMx;
|
|
14
|
+
const mxRecords = await service(domain);
|
|
11
15
|
return mxRecords && mxRecords.length > 0;
|
|
12
16
|
}
|
|
13
17
|
catch {
|