@aldb2b/common 1.0.648 → 1.0.650
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/build/common/const/smtp-codes.d.ts +0 -2
- package/build/common/const/smtp-codes.js +1 -5
- package/build/common/const/smtp-codes.js.map +1 -1
- package/build/common/utils/validate-smtp.js +26 -71
- package/build/common/utils/validate-smtp.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
export declare const smtpCodes: {
|
|
3
2
|
101: string;
|
|
4
3
|
111: string;
|
|
@@ -58,4 +57,3 @@ export declare const smtpCodes: {
|
|
|
58
57
|
555: string;
|
|
59
58
|
556: string;
|
|
60
59
|
};
|
|
61
|
-
export declare const hasCode: (message: Buffer, code: number) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.smtpCodes = void 0;
|
|
4
4
|
exports.smtpCodes = {
|
|
5
5
|
101: 'Invalid SSL or TLS configuration',
|
|
6
6
|
111: 'Error connecting with the remote SMTP server',
|
|
@@ -60,8 +60,4 @@ exports.smtpCodes = {
|
|
|
60
60
|
555: 'Wrong protocol version',
|
|
61
61
|
556: 'Email sent is too large for the recipients email server to process',
|
|
62
62
|
};
|
|
63
|
-
const hasCode = (message, code) => {
|
|
64
|
-
return message.indexOf(`${code}`) === 0 || message.indexOf(`${code}\n`) > -1;
|
|
65
|
-
};
|
|
66
|
-
exports.hasCode = hasCode;
|
|
67
63
|
//# sourceMappingURL=smtp-codes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smtp-codes.js","sourceRoot":"","sources":["../../../src/common/const/smtp-codes.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,GAAG,EAAE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mB;IACxB,GAAG,EAAE,wCAAwC;IAC7C,GAAG,EAAE,2CAA2C;IAChD,GAAG,EAAE,qCAAqC;IAC1C,GAAG,EAAE,uDAAuD;IAC5D,GAAG,EAAE,6BAA6B;IAClC,GAAG,EAAE,sCAAsC;IAC3C,GAAG,EAAE,0CAA0C;IAC/C,GAAG,EAAE,wCAAwC;IAC7C,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,yDAAyD;IAC9D,GAAG,EAAE,uDAAuD;IAC5D,GAAG,EAAE,yDAAyD;IAC9D,GAAG,EAAE,4DAA4D;IACjE,GAAG,EAAE,iCAAiC;IACtC,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,4CAA4C;IACjD,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,iDAAiD;IACtD,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,4DAA4D;IACjE,GAAG,EAAE,sDAAsD;IAC3D,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,wBAAwB;IAC7B,GAAG,EAAE,oEAAoE;CAC1E,CAAA"}
|
|
@@ -1,82 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkSMTP = void 0;
|
|
4
|
-
const
|
|
4
|
+
const telnet_client_1 = require("telnet-client");
|
|
5
5
|
const const_1 = require("../const");
|
|
6
6
|
const checkSMTP = async (sender, recipient, exchange) => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
resolve(msg);
|
|
28
|
-
if (socket.writable && !socket.destroyed) {
|
|
29
|
-
socket.write(`quit\r\n`);
|
|
30
|
-
socket.end();
|
|
31
|
-
socket.destroy();
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
socket.on('success', () => {
|
|
35
|
-
closed = true;
|
|
36
|
-
if (socket.writable && !socket.destroyed) {
|
|
37
|
-
socket.write(`quit\r\n`);
|
|
38
|
-
socket.end();
|
|
39
|
-
socket.destroy();
|
|
40
|
-
}
|
|
41
|
-
resolve();
|
|
42
|
-
});
|
|
43
|
-
const commands = [
|
|
44
|
-
`helo ${exchange}\r\n`,
|
|
45
|
-
`mail from: <${sender}>\r\n`,
|
|
46
|
-
`rcpt to: <${recipient}>\r\n`,
|
|
47
|
-
];
|
|
48
|
-
let i = 0;
|
|
49
|
-
socket.on('next', () => {
|
|
50
|
-
if (i < 3) {
|
|
51
|
-
if (socket.writable) {
|
|
52
|
-
socket.write(commands[i++]);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
socket.emit('fail', 'SMTP communication unexpectedly closed.');
|
|
56
|
-
}
|
|
7
|
+
const commands = [
|
|
8
|
+
`HELO ${exchange}\r\n`,
|
|
9
|
+
`MAIL FROM: <${sender}>\r\n`,
|
|
10
|
+
`RCPT TO: <${recipient}>\r\n`,
|
|
11
|
+
];
|
|
12
|
+
const connection = new telnet_client_1.Telnet();
|
|
13
|
+
const params = {
|
|
14
|
+
host: exchange,
|
|
15
|
+
port: 25,
|
|
16
|
+
shellPrompt: false,
|
|
17
|
+
timeout: const_1.smtpSocketTimeout,
|
|
18
|
+
};
|
|
19
|
+
await connection.connect(params);
|
|
20
|
+
for (let i = 0; i < commands.length; i++) {
|
|
21
|
+
const commandResponse = await connection.exec(commands[i]);
|
|
22
|
+
if (commandResponse.indexOf('220') == -1 &&
|
|
23
|
+
commandResponse.indexOf('250') == -1) {
|
|
24
|
+
const smtpCode = Object.keys(const_1.smtpCodes).find(code => commandResponse.indexOf(code) !== -1);
|
|
25
|
+
if (smtpCode) {
|
|
26
|
+
throw Object.assign({}, const_1.INVALID_SMTP, { message: const_1.smtpCodes[smtpCode] });
|
|
57
27
|
}
|
|
58
28
|
else {
|
|
59
|
-
|
|
29
|
+
throw const_1.INVALID_SMTP;
|
|
60
30
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
socket.on('connect', () => {
|
|
66
|
-
socket.on('data', msg => {
|
|
67
|
-
receivedData = true;
|
|
68
|
-
if ((0, const_1.hasCode)(msg, 220) || (0, const_1.hasCode)(msg, 250)) {
|
|
69
|
-
socket.emit('next', msg);
|
|
70
|
-
}
|
|
71
|
-
else if ((0, const_1.hasCode)(msg, 550)) {
|
|
72
|
-
socket.emit('fail', 'Mailbox not found.');
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
socket.emit('fail');
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await connection.end();
|
|
34
|
+
await connection.destroy();
|
|
80
35
|
};
|
|
81
36
|
exports.checkSMTP = checkSMTP;
|
|
82
37
|
//# sourceMappingURL=validate-smtp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-smtp.js","sourceRoot":"","sources":["../../../src/common/utils/validate-smtp.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"validate-smtp.js","sourceRoot":"","sources":["../../../src/common/utils/validate-smtp.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AACtC,oCAAqE;AAE9D,MAAM,SAAS,GAAG,KAAK,EAC5B,MAAc,EACd,SAAiB,EACjB,QAAgB,EACD,EAAE;IACjB,MAAM,QAAQ,GAAG;QACf,QAAQ,QAAQ,MAAM;QACtB,eAAe,MAAM,OAAO;QAC5B,aAAa,SAAS,OAAO;KAC9B,CAAA;IACD,MAAM,UAAU,GAAG,IAAI,sBAAM,EAAE,CAAA;IAC/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