@brilab-mailer/utils 0.0.2-1 → 0.0.2-11
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/decorators/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA"}
|
package/decorators/index.js
CHANGED
|
@@ -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;
|
|
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;AAIzB,qBACa,qBAAsB,YAAW,4BAA4B;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM;IAqB5B,cAAc;CAGf;AAGD,wBAAgB,WAAW,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,CAWpF"}
|
|
@@ -1,14 +1,23 @@
|
|
|
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
|
|
11
|
-
|
|
10
|
+
const USE_CUSTOM_RESOLVER = true;
|
|
11
|
+
let mxRecords = [];
|
|
12
|
+
if (USE_CUSTOM_RESOLVER) {
|
|
13
|
+
const resolver = new Resolver();
|
|
14
|
+
resolver.setServers(['1.1.1.1', '8.8.8.8']);
|
|
15
|
+
mxRecords = await resolver.resolveMx(domain);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
mxRecords = await resolveMx(domain);
|
|
19
|
+
}
|
|
20
|
+
return !!mxRecords?.length;
|
|
12
21
|
}
|
|
13
22
|
catch {
|
|
14
23
|
return false;
|
|
@@ -25,6 +34,7 @@ export { IsRealEmailConstraint };
|
|
|
25
34
|
export function IsRealEmail(validationOptions) {
|
|
26
35
|
return function (target, propertyKey) {
|
|
27
36
|
registerDecorator({
|
|
37
|
+
name: 'IsRealEmail',
|
|
28
38
|
target: target.constructor,
|
|
29
39
|
propertyName: String(propertyKey),
|
|
30
40
|
options: validationOptions,
|