@brilab-mailer/utils 0.0.1-beta.0
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/README.md +7 -0
- package/decorators/index.d.ts +2 -0
- package/decorators/index.d.ts.map +1 -0
- package/decorators/index.js +1 -0
- package/decorators/is-real-email.decorator.d.ts +7 -0
- package/decorators/is-real-email.decorator.d.ts.map +1 -0
- package/decorators/is-real-email.decorator.js +35 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-real-email.decorator.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
export declare class IsRealEmailConstraint implements ValidatorConstraintInterface {
|
|
3
|
+
validate(email: string): Promise<boolean>;
|
|
4
|
+
defaultMessage(): string;
|
|
5
|
+
}
|
|
6
|
+
export declare function IsRealEmail(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|
|
7
|
+
//# sourceMappingURL=is-real-email.decorator.d.ts.map
|
|
@@ -0,0 +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;IAW5B,cAAc;CAGf;AAED,wBAAgB,WAAW,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,IAC9C,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { registerDecorator, ValidatorConstraint, } from 'class-validator';
|
|
3
|
+
import * as dns from 'node:dns/promises';
|
|
4
|
+
let IsRealEmailConstraint = class IsRealEmailConstraint {
|
|
5
|
+
async validate(email) {
|
|
6
|
+
try {
|
|
7
|
+
const domain = email.split('@').at(-1);
|
|
8
|
+
if (!domain)
|
|
9
|
+
return false;
|
|
10
|
+
const mxRecords = await dns.resolveMx(domain);
|
|
11
|
+
return mxRecords && mxRecords.length > 0;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
defaultMessage() {
|
|
18
|
+
return 'This email cannot receive messages (invalid domain)';
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
IsRealEmailConstraint = __decorate([
|
|
22
|
+
ValidatorConstraint({ async: true })
|
|
23
|
+
], IsRealEmailConstraint);
|
|
24
|
+
export { IsRealEmailConstraint };
|
|
25
|
+
export function IsRealEmail(validationOptions) {
|
|
26
|
+
return function (object, propertyName) {
|
|
27
|
+
registerDecorator({
|
|
28
|
+
target: object.constructor,
|
|
29
|
+
propertyName: propertyName,
|
|
30
|
+
options: validationOptions,
|
|
31
|
+
constraints: [],
|
|
32
|
+
validator: IsRealEmailConstraint,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './decorators/index.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brilab-mailer/utils",
|
|
3
|
+
"version": "0.0.1-beta.0",
|
|
4
|
+
"author": "Bohdan Radchenko <radchenkobs@gmail.com>",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"import": "./index.js",
|
|
14
|
+
"default": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"**/*",
|
|
19
|
+
"!**/*.tsbuildinfo"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"directory": "dist"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@nestjs/common": "^10.0.0",
|
|
28
|
+
"@nestjs/config": "^3.0.0",
|
|
29
|
+
"class-validator": "^0.14.2"
|
|
30
|
+
}
|
|
31
|
+
}
|