@mavogel/awscdk-rootmail 0.1.4 → 0.1.6
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/.jsii +3 -3
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/node_modules/@aws-sdk/checksums/package.json +2 -2
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +3 -3
- package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-route-53/package.json +3 -3
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +38 -15
- package/node_modules/@aws-sdk/client-s3/dist-es/models/enums.js +7 -0
- package/node_modules/@aws-sdk/client-s3/dist-es/schemas/schemas_0.js +28 -14
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/CopyObjectCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/CreateMultipartUploadCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetBucketInventoryConfigurationCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetBucketNotificationConfigurationCommand.d.ts +3 -3
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetObjectCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetObjectLockConfigurationCommand.d.ts +4 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetObjectRetentionCommand.d.ts +5 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/HeadObjectCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/ListBucketInventoryConfigurationsCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutBucketInventoryConfigurationCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutBucketNotificationConfigurationCommand.d.ts +3 -3
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutObjectCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutObjectLockConfigurationCommand.d.ts +4 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutObjectRetentionCommand.d.ts +5 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/PutPublicAccessBlockCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/models/enums.d.ts +15 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/models/models_0.d.ts +186 -49
- package/node_modules/@aws-sdk/client-s3/dist-types/models/models_1.d.ts +43 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/schemas/schemas_0.d.ts +1 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/commands/PutPublicAccessBlockCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/enums.d.ts +8 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/models_0.d.ts +23 -7
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/models_1.d.ts +14 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/schemas/schemas_0.d.ts +1 -0
- package/node_modules/@aws-sdk/client-s3/package.json +6 -6
- package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ses/package.json +3 -3
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ssm/package.json +3 -3
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +5 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/util/hasOwn.js +3 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/util/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/util/hasOwn.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/util/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/hasOwn.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@zone-eu/mailsplit/package.json +3 -3
- package/node_modules/encoding-japanese/LICENSE +25 -1
- package/node_modules/encoding-japanese/README.md +86 -51
- package/node_modules/encoding-japanese/encoding.js +107 -78
- package/node_modules/encoding-japanese/encoding.min.js +2 -2
- package/node_modules/encoding-japanese/index.d.ts +102 -0
- package/node_modules/encoding-japanese/package.json +26 -17
- package/node_modules/encoding-japanese/src/encoding-convert.js +67 -58
- package/node_modules/encoding-japanese/src/encoding-table.js +1 -0
- package/node_modules/encoding-japanese/src/index.js +1 -1
- package/node_modules/encoding-japanese/src/kana-case-table.js +1 -1
- package/node_modules/encoding-japanese/src/utf8-to-jis-alias-table.js +14 -0
- package/node_modules/encoding-japanese/src/utf8-to-jis-table.js +6 -5
- package/node_modules/encoding-japanese/src/utf8-to-jisx0212-table.js +7 -5
- package/node_modules/libmime/CHANGELOG.md +7 -0
- package/node_modules/libmime/package.json +2 -2
- package/node_modules/mailparser/.release-please-manifest.json +1 -1
- package/node_modules/mailparser/CHANGELOG.md +42 -0
- package/node_modules/mailparser/package.json +5 -5
- package/node_modules/nodemailer/CHANGELOG.md +83 -0
- package/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +1 -3
- package/node_modules/nodemailer/dist/cjs/addressparser/index.js +176 -13
- package/node_modules/nodemailer/dist/cjs/base64/index.d.ts +2 -6
- package/node_modules/nodemailer/dist/cjs/base64/index.js +2 -0
- package/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +4 -4
- package/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +1 -3
- package/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +14 -5
- package/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +3 -22
- package/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +5 -0
- package/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +5 -5
- package/node_modules/nodemailer/dist/cjs/errors.d.ts +8 -8
- package/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +12 -10
- package/node_modules/nodemailer/dist/cjs/fetch/cookies.js +28 -14
- package/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +15 -15
- package/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +2 -2
- package/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +49 -104
- package/node_modules/nodemailer/dist/cjs/mail-composer/index.js +14 -3
- package/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +21 -28
- package/node_modules/nodemailer/dist/cjs/mailer/index.js +19 -5
- package/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +8 -12
- package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +4 -1
- package/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +4 -1
- package/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +37 -191
- package/node_modules/nodemailer/dist/cjs/mime-node/index.js +82 -12
- package/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +1 -3
- package/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +2 -0
- package/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +1 -5
- package/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +1 -0
- package/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +1 -5
- package/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +1 -0
- package/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +2 -2
- package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
- package/node_modules/nodemailer/dist/cjs/qp/index.d.ts +2 -5
- package/node_modules/nodemailer/dist/cjs/qp/index.js +2 -0
- package/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +4 -6
- package/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +2 -2
- package/node_modules/nodemailer/dist/cjs/ses-transport/index.js +5 -1
- package/node_modules/nodemailer/dist/cjs/shared/index.d.ts +31 -37
- package/node_modules/nodemailer/dist/cjs/shared/index.js +19 -7
- package/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +1 -9
- package/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +2 -0
- package/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +65 -403
- package/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +99 -19
- package/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +8 -46
- package/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +13 -2
- package/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +2 -4
- package/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +16 -16
- package/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +3 -3
- package/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +9 -9
- package/node_modules/nodemailer/dist/cjs/well-known/services.js +2 -0
- package/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +18 -18
- package/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +1 -3
- package/node_modules/nodemailer/dist/esm/addressparser/index.js +176 -13
- package/node_modules/nodemailer/dist/esm/base64/index.d.ts +2 -6
- package/node_modules/nodemailer/dist/esm/base64/index.js +2 -0
- package/node_modules/nodemailer/dist/esm/dkim/index.d.ts +4 -4
- package/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +1 -3
- package/node_modules/nodemailer/dist/esm/dkim/message-parser.js +14 -5
- package/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +3 -22
- package/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +5 -0
- package/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +5 -5
- package/node_modules/nodemailer/dist/esm/errors.d.ts +8 -8
- package/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +12 -10
- package/node_modules/nodemailer/dist/esm/fetch/cookies.js +25 -14
- package/node_modules/nodemailer/dist/esm/fetch/index.d.ts +15 -15
- package/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +2 -2
- package/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +49 -104
- package/node_modules/nodemailer/dist/esm/mail-composer/index.js +14 -3
- package/node_modules/nodemailer/dist/esm/mailer/index.d.ts +21 -28
- package/node_modules/nodemailer/dist/esm/mailer/index.js +19 -5
- package/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +8 -12
- package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +4 -1
- package/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +4 -1
- package/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +37 -191
- package/node_modules/nodemailer/dist/esm/mime-node/index.js +82 -12
- package/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +1 -3
- package/node_modules/nodemailer/dist/esm/mime-node/last-newline.js +2 -0
- package/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +1 -5
- package/node_modules/nodemailer/dist/esm/mime-node/le-unix.js +1 -0
- package/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +1 -5
- package/node_modules/nodemailer/dist/esm/mime-node/le-windows.js +1 -0
- package/node_modules/nodemailer/dist/esm/nodemailer.d.ts +2 -2
- package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
- package/node_modules/nodemailer/dist/esm/qp/index.d.ts +2 -5
- package/node_modules/nodemailer/dist/esm/qp/index.js +2 -0
- package/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +4 -6
- package/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +2 -2
- package/node_modules/nodemailer/dist/esm/ses-transport/index.js +5 -1
- package/node_modules/nodemailer/dist/esm/shared/index.d.ts +31 -37
- package/node_modules/nodemailer/dist/esm/shared/index.js +19 -7
- package/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +1 -9
- package/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +2 -0
- package/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +65 -403
- package/node_modules/nodemailer/dist/esm/smtp-connection/index.js +99 -19
- package/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +8 -46
- package/node_modules/nodemailer/dist/esm/smtp-pool/index.js +13 -2
- package/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +2 -4
- package/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +16 -16
- package/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +3 -3
- package/node_modules/nodemailer/dist/esm/well-known/index.d.ts +9 -9
- package/node_modules/nodemailer/dist/esm/well-known/services.js +2 -0
- package/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +18 -18
- package/node_modules/nodemailer/dist/well-known/services.json +2 -2
- package/node_modules/nodemailer/package.json +6 -6
- package/package.json +1 -1
|
@@ -13,6 +13,9 @@ const SOCKET_TIMEOUT = 10 * 60 * 1000; // how much to wait for socket inactivity
|
|
|
13
13
|
const GREETING_TIMEOUT = 30 * 1000; // how much to wait after connection is established but SMTP greeting is not receieved
|
|
14
14
|
const DNS_TIMEOUT = 30 * 1000; // how much to wait for resolveHostname
|
|
15
15
|
const TEARDOWN_NOOP = () => { }; // reusable no-op handler for absorbing errors during socket teardown
|
|
16
|
+
// how many bytes a single server response may occupy while it is still being received.
|
|
17
|
+
// Generous compared to any real reply, it only stops a peer that never completes one
|
|
18
|
+
const MAX_RESPONSE_SIZE = 1024 * 1024;
|
|
16
19
|
/**
|
|
17
20
|
* Re-interpret a server response stored in fake 8-bit byte-container form
|
|
18
21
|
* (the result of chunk.toString('binary') in _onData) as UTF-8.
|
|
@@ -41,11 +44,19 @@ function decodeServerResponse(str) {
|
|
|
41
44
|
* Called with the byte-container form the queue holds (see _onData): the check only looks
|
|
42
45
|
* at leading ASCII digits and '-' of the last line, and a UTF-8 continuation byte is never
|
|
43
46
|
* 0x0A, so line boundaries and the tested prefix are the same before and after decoding.
|
|
44
|
-
* The last line is read with lastIndexOf rather than split() because a queue entry
|
|
45
|
-
*
|
|
47
|
+
* The last line is read with lastIndexOf rather than split() because a queue entry may hold
|
|
48
|
+
* a whole multiline reply and only its final line matters.
|
|
46
49
|
*/
|
|
47
50
|
function isPartialResponse(str) {
|
|
48
|
-
return
|
|
51
|
+
return isPartialLine(str.slice(str.lastIndexOf('\n') + 1));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* True when a single reply line is a continuation ("250-..."). Used where the line is
|
|
55
|
+
* already known to be one line, which skips the scan isPartialResponse needs to find the
|
|
56
|
+
* last line of a whole reply.
|
|
57
|
+
*/
|
|
58
|
+
function isPartialLine(line) {
|
|
59
|
+
return /^\d+-/.test(line);
|
|
49
60
|
}
|
|
50
61
|
/**
|
|
51
62
|
* Generates a SMTP connection object
|
|
@@ -62,6 +73,7 @@ function isPartialResponse(str) {
|
|
|
62
73
|
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
|
|
63
74
|
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
|
|
64
75
|
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
|
|
76
|
+
* * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
|
|
65
77
|
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
|
|
66
78
|
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
|
|
67
79
|
* * **logger** - bunyan compatible logger interface
|
|
@@ -108,6 +120,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
108
120
|
this.secure = !!this.secureConnection;
|
|
109
121
|
this._remainder = '';
|
|
110
122
|
this._responseQueue = [];
|
|
123
|
+
this._responsePartial = false;
|
|
111
124
|
this.lastServerResponse = false;
|
|
112
125
|
this._socket = false;
|
|
113
126
|
this._supportedAuth = [];
|
|
@@ -225,6 +238,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
225
238
|
*
|
|
226
239
|
* @param opts Connection options (modified in place)
|
|
227
240
|
* @param callback Called with resolved data on success
|
|
241
|
+
* @internal
|
|
228
242
|
*/
|
|
229
243
|
_resolveAndConnect(opts, callback) {
|
|
230
244
|
return shared.resolveHostname(opts, (err, resolved) => {
|
|
@@ -250,6 +264,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
250
264
|
*
|
|
251
265
|
* @param opts Connection options
|
|
252
266
|
* @param secure Whether to use TLS
|
|
267
|
+
* @internal
|
|
253
268
|
*/
|
|
254
269
|
_connectToHost(opts, secure) {
|
|
255
270
|
// If the client was closed while DNS resolution was in flight, do not open
|
|
@@ -282,6 +297,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
282
297
|
}
|
|
283
298
|
/**
|
|
284
299
|
* Sets up connection timeout and error handlers
|
|
300
|
+
* @internal
|
|
285
301
|
*/
|
|
286
302
|
_setupConnectionHandlers() {
|
|
287
303
|
this._connectionTimeout = setTimeout(() => {
|
|
@@ -294,6 +310,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
294
310
|
*
|
|
295
311
|
* @param err Error object or message
|
|
296
312
|
* @param code Error code
|
|
313
|
+
* @internal
|
|
297
314
|
*/
|
|
298
315
|
_onConnectionError(err, code) {
|
|
299
316
|
clearTimeout(this._connectionTimeout);
|
|
@@ -617,6 +634,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
617
634
|
* the server is opened
|
|
618
635
|
*
|
|
619
636
|
* @event
|
|
637
|
+
* @internal
|
|
620
638
|
*/
|
|
621
639
|
_onConnect() {
|
|
622
640
|
const socket = this._socket;
|
|
@@ -665,39 +683,71 @@ class SMTPConnection extends EventEmitter {
|
|
|
665
683
|
*
|
|
666
684
|
* @event
|
|
667
685
|
* @param chunk Data chunk coming from the server
|
|
686
|
+
* @internal
|
|
668
687
|
*/
|
|
669
688
|
_onData(chunk) {
|
|
670
689
|
if (this._destroyed || !chunk || !chunk.length) {
|
|
671
690
|
return;
|
|
672
691
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
692
|
+
const maxResponseSize = this.options.maxResponseSize || MAX_RESPONSE_SIZE;
|
|
693
|
+
const data = chunk.toString('binary');
|
|
694
|
+
// A chunk without a line break only extends the line currently being received, so
|
|
695
|
+
// keep it in the remainder and leave that string unflattened. Splitting the whole
|
|
696
|
+
// remainder again on every chunk would rescan everything buffered for that line so
|
|
697
|
+
// far, which is quadratic in the length of a line the peer never terminates
|
|
698
|
+
if (!data.includes('\n')) {
|
|
699
|
+
this._remainder += data;
|
|
700
|
+
if (this._remainder.length > maxResponseSize) {
|
|
701
|
+
return this._onResponseTooLarge();
|
|
702
|
+
}
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
const lines = (this._remainder + data).split(/\r?\n/);
|
|
676
706
|
this._remainder = lines.pop();
|
|
677
707
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
678
|
-
if (this.
|
|
679
|
-
|
|
680
|
-
if (isPartialResponse(lastline)) {
|
|
681
|
-
this._responseQueue[this._responseQueue.length - 1] += '\n' + lines[i];
|
|
682
|
-
continue;
|
|
683
|
-
}
|
|
708
|
+
if (this._responsePartial) {
|
|
709
|
+
this._responseQueue[this._responseQueue.length - 1] += '\n' + lines[i];
|
|
684
710
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (this._responseQueue.length) {
|
|
688
|
-
lastline = this._responseQueue[this._responseQueue.length - 1];
|
|
689
|
-
if (isPartialResponse(lastline)) {
|
|
690
|
-
return;
|
|
711
|
+
else {
|
|
712
|
+
this._responseQueue.push(lines[i]);
|
|
691
713
|
}
|
|
714
|
+
// The line just added is the last line of that queue entry, so it alone decides
|
|
715
|
+
// whether the reply is still partial. Looking for the last line of the accumulated
|
|
716
|
+
// entry instead would rescan a string that grows with every continuation line,
|
|
717
|
+
// which is quadratic in the size of the reply
|
|
718
|
+
this._responsePartial = isPartialLine(lines[i]);
|
|
719
|
+
// Checked as each line lands, so a peer that never completes a reply cannot keep
|
|
720
|
+
// buffering, and the limit does not depend on how it split its bytes into chunks
|
|
721
|
+
if (this._responsePartial && this._responseQueue[this._responseQueue.length - 1].length > maxResponseSize) {
|
|
722
|
+
return this._onResponseTooLarge();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (this._remainder.length > maxResponseSize) {
|
|
726
|
+
return this._onResponseTooLarge();
|
|
727
|
+
}
|
|
728
|
+
if (this._responsePartial) {
|
|
729
|
+
return;
|
|
692
730
|
}
|
|
693
731
|
this._processResponse();
|
|
694
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* Drops a connection whose peer keeps extending a reply it never completes, releasing
|
|
735
|
+
* whatever was buffered for that reply
|
|
736
|
+
* @internal
|
|
737
|
+
*/
|
|
738
|
+
_onResponseTooLarge() {
|
|
739
|
+
this._remainder = '';
|
|
740
|
+
this._responseQueue = [];
|
|
741
|
+
this._responsePartial = false;
|
|
742
|
+
this._onError(new Error('Server response exceeds maximum allowed size'), 'EPROTOCOL', false, 'CONN');
|
|
743
|
+
}
|
|
695
744
|
/**
|
|
696
745
|
* 'error' listener for the socket
|
|
697
746
|
*
|
|
698
747
|
* @event
|
|
699
748
|
* @param err Error object
|
|
700
749
|
* @param type Error name
|
|
750
|
+
* @internal
|
|
701
751
|
*/
|
|
702
752
|
_onError(err, type, data, command) {
|
|
703
753
|
clearTimeout(this._connectionTimeout);
|
|
@@ -719,6 +769,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
719
769
|
this.emit('error', err);
|
|
720
770
|
this.close();
|
|
721
771
|
}
|
|
772
|
+
/** @internal */
|
|
722
773
|
_formatError(message, type, response, command) {
|
|
723
774
|
let err;
|
|
724
775
|
if (/Error\]$/i.test(Object.prototype.toString.call(message))) {
|
|
@@ -747,6 +798,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
747
798
|
* 'close' listener for the socket
|
|
748
799
|
*
|
|
749
800
|
* @event
|
|
801
|
+
* @internal
|
|
750
802
|
*/
|
|
751
803
|
_onClose() {
|
|
752
804
|
let serverResponse = false;
|
|
@@ -776,6 +828,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
776
828
|
* 'end' listener for the socket
|
|
777
829
|
*
|
|
778
830
|
* @event
|
|
831
|
+
* @internal
|
|
779
832
|
*/
|
|
780
833
|
_onEnd() {
|
|
781
834
|
if (this._socket && !this._socket.destroyed) {
|
|
@@ -788,12 +841,14 @@ class SMTPConnection extends EventEmitter {
|
|
|
788
841
|
* 'timeout' listener for the socket
|
|
789
842
|
*
|
|
790
843
|
* @event
|
|
844
|
+
* @internal
|
|
791
845
|
*/
|
|
792
846
|
_onTimeout() {
|
|
793
847
|
return this._onError(new Error('Timeout'), 'ETIMEDOUT', false, 'CONN');
|
|
794
848
|
}
|
|
795
849
|
/**
|
|
796
850
|
* Destroys the client, emits 'end'
|
|
851
|
+
* @internal
|
|
797
852
|
*/
|
|
798
853
|
_destroy() {
|
|
799
854
|
if (this._destroyed) {
|
|
@@ -815,6 +870,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
815
870
|
*
|
|
816
871
|
* @param callback Callback function to run when the connection
|
|
817
872
|
* has been secured
|
|
873
|
+
* @internal
|
|
818
874
|
*/
|
|
819
875
|
_upgradeConnection(callback) {
|
|
820
876
|
// RFC 3207 section 6: the client MUST discard any knowledge obtained from
|
|
@@ -825,6 +881,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
825
881
|
// part of the secured EHLO capabilities). STARTTLS response injection.
|
|
826
882
|
this._remainder = '';
|
|
827
883
|
this._responseQueue = [];
|
|
884
|
+
this._responsePartial = false;
|
|
828
885
|
// do not remove all listeners or it breaks node v0.10 as there's
|
|
829
886
|
// apparently a 'finish' event set that would be cleared as well
|
|
830
887
|
// we can safely keep 'error', 'end', 'close' etc. events
|
|
@@ -875,6 +932,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
875
932
|
}
|
|
876
933
|
/**
|
|
877
934
|
* Processes queued responses from the server
|
|
935
|
+
* @internal
|
|
878
936
|
*/
|
|
879
937
|
_processResponse() {
|
|
880
938
|
if (!this._responseQueue.length) {
|
|
@@ -914,6 +972,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
914
972
|
*
|
|
915
973
|
* @param str String to be sent to the server
|
|
916
974
|
* @param logStr Optional string to be used for logging instead of the actual string
|
|
975
|
+
* @internal
|
|
917
976
|
*/
|
|
918
977
|
_sendCommand(str, logStr) {
|
|
919
978
|
if (this._destroyed) {
|
|
@@ -939,6 +998,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
939
998
|
* {from:'...', to:['...']}
|
|
940
999
|
* or
|
|
941
1000
|
* {from:{address:'...',name:'...'}, to:[address:'...',name:'...']}
|
|
1001
|
+
* @internal
|
|
942
1002
|
*/
|
|
943
1003
|
_setEnvelope(envelope, callback) {
|
|
944
1004
|
const args = [];
|
|
@@ -1035,6 +1095,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1035
1095
|
}
|
|
1036
1096
|
this._sendCommand('MAIL FROM:<' + this._envelope.from + '>' + (args.length ? ' ' + args.join(' ') : ''));
|
|
1037
1097
|
}
|
|
1098
|
+
/** @internal */
|
|
1038
1099
|
_setDsnEnvelope(params) {
|
|
1039
1100
|
let ret = (params.ret || params.return || '').toString().toUpperCase() || null;
|
|
1040
1101
|
if (ret) {
|
|
@@ -1077,6 +1138,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1077
1138
|
orcpt
|
|
1078
1139
|
};
|
|
1079
1140
|
}
|
|
1141
|
+
/** @internal */
|
|
1080
1142
|
_getDsnRcptToArgs() {
|
|
1081
1143
|
const envelope = this._envelope;
|
|
1082
1144
|
const args = [];
|
|
@@ -1092,6 +1154,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1092
1154
|
}
|
|
1093
1155
|
return args.length ? ' ' + args.join(' ') : '';
|
|
1094
1156
|
}
|
|
1157
|
+
/** @internal */
|
|
1095
1158
|
_createSendStream(callback) {
|
|
1096
1159
|
const envelope = this._envelope;
|
|
1097
1160
|
const dataStream = new DataStream();
|
|
@@ -1143,6 +1206,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1143
1206
|
* SMTP session by sending EHLO command
|
|
1144
1207
|
*
|
|
1145
1208
|
* @param str Message from the server
|
|
1209
|
+
* @internal
|
|
1146
1210
|
*/
|
|
1147
1211
|
_actionGreeting(str) {
|
|
1148
1212
|
clearTimeout(this._greetingTimeout);
|
|
@@ -1164,6 +1228,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1164
1228
|
* error, emit 'error', otherwise treat this as an EHLO response
|
|
1165
1229
|
*
|
|
1166
1230
|
* @param str Message from the server
|
|
1231
|
+
* @internal
|
|
1167
1232
|
*/
|
|
1168
1233
|
_actionLHLO(str) {
|
|
1169
1234
|
if (str.charAt(0) !== '2') {
|
|
@@ -1179,6 +1244,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1179
1244
|
* authentication phase.
|
|
1180
1245
|
*
|
|
1181
1246
|
* @param str Message from the server
|
|
1247
|
+
* @internal
|
|
1182
1248
|
*/
|
|
1183
1249
|
_actionEHLO(str) {
|
|
1184
1250
|
let match;
|
|
@@ -1259,6 +1325,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1259
1325
|
* error, emit 'error', otherwise move into the authentication phase.
|
|
1260
1326
|
*
|
|
1261
1327
|
* @param str Message from the server
|
|
1328
|
+
* @internal
|
|
1262
1329
|
*/
|
|
1263
1330
|
_actionHELO(str) {
|
|
1264
1331
|
if (str.charAt(0) !== '2') {
|
|
@@ -1275,6 +1342,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1275
1342
|
* succeedes restart the EHLO
|
|
1276
1343
|
*
|
|
1277
1344
|
* @param str Message from the server
|
|
1345
|
+
* @internal
|
|
1278
1346
|
*/
|
|
1279
1347
|
_actionSTARTTLS(str) {
|
|
1280
1348
|
if (str.charAt(0) !== '2') {
|
|
@@ -1320,6 +1388,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1320
1388
|
* hosts invalidly use a longer message than VXNlcm5hbWU6
|
|
1321
1389
|
*
|
|
1322
1390
|
* @param str Message from the server
|
|
1391
|
+
* @internal
|
|
1323
1392
|
*/
|
|
1324
1393
|
_actionAUTH_LOGIN_USER(str, callback) {
|
|
1325
1394
|
if (!/^334[ -]/.test(str)) {
|
|
@@ -1340,6 +1409,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1340
1409
|
* base64 encoded again.
|
|
1341
1410
|
*
|
|
1342
1411
|
* @param str Message from the server
|
|
1412
|
+
* @internal
|
|
1343
1413
|
*/
|
|
1344
1414
|
_actionAUTH_CRAM_MD5(str, callback) {
|
|
1345
1415
|
const challengeMatch = str.match(/^334\s+(.+)$/);
|
|
@@ -1363,6 +1433,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1363
1433
|
* the user can be considered logged in. Start waiting for a message to send
|
|
1364
1434
|
*
|
|
1365
1435
|
* @param str Message from the server
|
|
1436
|
+
* @internal
|
|
1366
1437
|
*/
|
|
1367
1438
|
_actionAUTH_CRAM_MD5_PASS(str, callback) {
|
|
1368
1439
|
if (!str.match(/^235\s+/)) {
|
|
@@ -1383,6 +1454,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1383
1454
|
* response needs to be base64 encoded password.
|
|
1384
1455
|
*
|
|
1385
1456
|
* @param str Message from the server
|
|
1457
|
+
* @internal
|
|
1386
1458
|
*/
|
|
1387
1459
|
_actionAUTH_LOGIN_PASS(str, callback) {
|
|
1388
1460
|
if (!/^334[ -]/.test(str)) {
|
|
@@ -1401,6 +1473,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1401
1473
|
* the user can be considered logged in. Start waiting for a message to send
|
|
1402
1474
|
*
|
|
1403
1475
|
* @param str Message from the server
|
|
1476
|
+
* @internal
|
|
1404
1477
|
*/
|
|
1405
1478
|
_actionAUTHComplete(str, isRetry, callback) {
|
|
1406
1479
|
if (!callback && typeof isRetry === 'function') {
|
|
@@ -1442,6 +1515,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1442
1515
|
* Handle response for a MAIL FROM: command
|
|
1443
1516
|
*
|
|
1444
1517
|
* @param str Message from the server
|
|
1518
|
+
* @internal
|
|
1445
1519
|
*/
|
|
1446
1520
|
_actionMAIL(str, callback) {
|
|
1447
1521
|
const envelope = this._envelope;
|
|
@@ -1469,6 +1543,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1469
1543
|
* Handle response for a RCPT TO: command
|
|
1470
1544
|
*
|
|
1471
1545
|
* @param str Message from the server
|
|
1546
|
+
* @internal
|
|
1472
1547
|
*/
|
|
1473
1548
|
_actionRCPT(str, callback) {
|
|
1474
1549
|
const envelope = this._envelope;
|
|
@@ -1515,6 +1590,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1515
1590
|
* Handle response for a DATA command
|
|
1516
1591
|
*
|
|
1517
1592
|
* @param str Message from the server
|
|
1593
|
+
* @internal
|
|
1518
1594
|
*/
|
|
1519
1595
|
_actionDATA(str, callback) {
|
|
1520
1596
|
const envelope = this._envelope;
|
|
@@ -1540,6 +1616,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1540
1616
|
* We expect a single response that defines if the sending succeeded or failed
|
|
1541
1617
|
*
|
|
1542
1618
|
* @param str Message from the server
|
|
1619
|
+
* @internal
|
|
1543
1620
|
*/
|
|
1544
1621
|
_actionSMTPStream(str, callback) {
|
|
1545
1622
|
if (Number(str.charAt(0)) !== 2) {
|
|
@@ -1555,6 +1632,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1555
1632
|
* @param recipient The recipient this response applies to
|
|
1556
1633
|
* @param final Is this the final recipient?
|
|
1557
1634
|
* @param str Message from the server
|
|
1635
|
+
* @internal
|
|
1558
1636
|
*/
|
|
1559
1637
|
_actionLMTPStream(recipient, final, str, callback) {
|
|
1560
1638
|
const envelope = this._envelope;
|
|
@@ -1575,6 +1653,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1575
1653
|
return callback(null, str);
|
|
1576
1654
|
}
|
|
1577
1655
|
}
|
|
1656
|
+
/** @internal */
|
|
1578
1657
|
_handleXOauth2Token(isRetry, callback) {
|
|
1579
1658
|
this._auth.oauth2.getToken(isRetry, (err, accessToken) => {
|
|
1580
1659
|
if (err) {
|
|
@@ -1597,7 +1676,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1597
1676
|
/**
|
|
1598
1677
|
*
|
|
1599
1678
|
* @param command
|
|
1600
|
-
* @
|
|
1679
|
+
* @internal
|
|
1601
1680
|
*/
|
|
1602
1681
|
_isDestroyedMessage(command) {
|
|
1603
1682
|
if (this._destroyed) {
|
|
@@ -1612,6 +1691,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
1612
1691
|
}
|
|
1613
1692
|
}
|
|
1614
1693
|
}
|
|
1694
|
+
/** @internal */
|
|
1615
1695
|
_getHostname() {
|
|
1616
1696
|
// defaul hostname is machine hostname or [IP]
|
|
1617
1697
|
let defaultHostname;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import PoolResource from './pool-resource.js';
|
|
3
2
|
import * as shared from '../shared/index.js';
|
|
4
3
|
import type { SMTPTransportOptions, SMTPTransportGetSocketCallback, SMTPTransportSendCallback, SMTPSentMessageInfo } from '../smtp-transport/index.js';
|
|
5
4
|
import type MailMessage from '../mailer/mail-message.js';
|
|
@@ -9,17 +8,17 @@ import type { default as Mail, SendMailOptions, VerifyCallback } from '../mailer
|
|
|
9
8
|
*/
|
|
10
9
|
export interface SMTPPoolOptions extends SMTPTransportOptions {
|
|
11
10
|
/** Set to true to get this pooled transport from createTransport */
|
|
12
|
-
pool?: boolean;
|
|
11
|
+
pool?: boolean | undefined;
|
|
13
12
|
/** Maximum number of open connections, defaults to 5 */
|
|
14
|
-
maxConnections?: number;
|
|
13
|
+
maxConnections?: number | undefined;
|
|
15
14
|
/** Number of messages a connection sends before it is closed and replaced, defaults to 100 */
|
|
16
|
-
maxMessages?: number;
|
|
15
|
+
maxMessages?: number | undefined;
|
|
17
16
|
/** Maximum number of messages to send in rateDelta milliseconds, unlimited when not set */
|
|
18
|
-
rateLimit?: number;
|
|
17
|
+
rateLimit?: number | undefined;
|
|
19
18
|
/** Time window for rateLimit in milliseconds, defaults to 1000 */
|
|
20
|
-
rateDelta?: number;
|
|
19
|
+
rateDelta?: number | undefined;
|
|
21
20
|
/** How many times a message is requeued when its connection closes while sending, unlimited when not set or negative */
|
|
22
|
-
maxRequeues?: number;
|
|
21
|
+
maxRequeues?: number | undefined;
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
24
|
* The pool options once the constructor has applied the defaults
|
|
@@ -47,7 +46,7 @@ export interface SMTPPoolQueueEntry {
|
|
|
47
46
|
/** Callback to run once the message is sent or failed */
|
|
48
47
|
callback: SMTPPoolSendCallback;
|
|
49
48
|
/** Message-ID value without the angle brackets, set when the entry is assigned to a connection */
|
|
50
|
-
messageId?: string;
|
|
49
|
+
messageId?: string | undefined;
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* Rate limiter state of the pool
|
|
@@ -77,16 +76,11 @@ declare class SMTPPool extends EventEmitter {
|
|
|
77
76
|
logger: shared.Logger;
|
|
78
77
|
name: string;
|
|
79
78
|
version: string;
|
|
80
|
-
_rateLimit: SMTPPoolRateLimit;
|
|
81
|
-
_closed: boolean;
|
|
82
|
-
_queue: SMTPPoolQueueEntry[];
|
|
83
|
-
_connections: PoolResource[];
|
|
84
|
-
_connectionCounter: number;
|
|
85
79
|
idling: boolean;
|
|
86
80
|
/**
|
|
87
81
|
* The Mail instance using this transport, assigned by Mail
|
|
88
82
|
*/
|
|
89
|
-
mailer?: Mail<SMTPPoolSentMessageInfo
|
|
83
|
+
mailer?: Mail<SMTPPoolSentMessageInfo> | undefined;
|
|
90
84
|
constructor(options?: SMTPPoolOptions | string);
|
|
91
85
|
/**
|
|
92
86
|
* Placeholder function for creating proxy sockets. This method immediatelly returns
|
|
@@ -108,38 +102,6 @@ declare class SMTPPool extends EventEmitter {
|
|
|
108
102
|
* is closed later
|
|
109
103
|
*/
|
|
110
104
|
close(): void;
|
|
111
|
-
/**
|
|
112
|
-
* Check the queue and available connections. If there is a message to be sent and there is
|
|
113
|
-
* an available connection, then use this connection to send the mail
|
|
114
|
-
*/
|
|
115
|
-
_processMessages(): void;
|
|
116
|
-
/**
|
|
117
|
-
* Creates a new pool resource
|
|
118
|
-
*/
|
|
119
|
-
_createConnection(): PoolResource;
|
|
120
|
-
_shouldRequeuOnConnectionClose(queueEntry: SMTPPoolQueueEntry): boolean;
|
|
121
|
-
_failDeliveryOnConnectionClose(connection: PoolResource): void;
|
|
122
|
-
_requeueEntryOnConnectionClose(connection: PoolResource): void;
|
|
123
|
-
/**
|
|
124
|
-
* Continue to process message if the pool hasn't closed
|
|
125
|
-
*/
|
|
126
|
-
_continueProcessing(): void;
|
|
127
|
-
/**
|
|
128
|
-
* Remove resource from pool
|
|
129
|
-
*
|
|
130
|
-
* @param connection The PoolResource to remove
|
|
131
|
-
*/
|
|
132
|
-
_removeConnection(connection: PoolResource): void;
|
|
133
|
-
/**
|
|
134
|
-
* Checks if connections have hit current rate limit and if so, queues the availability callback
|
|
135
|
-
*
|
|
136
|
-
* @param callback Callback function to run once rate limiter has been cleared
|
|
137
|
-
*/
|
|
138
|
-
_checkRateLimit(callback: () => void): void;
|
|
139
|
-
/**
|
|
140
|
-
* Clears current rate limit limitation and runs paused callback
|
|
141
|
-
*/
|
|
142
|
-
_clearRateLimit(): void;
|
|
143
105
|
/**
|
|
144
106
|
* Returns true if there are free slots in the queue
|
|
145
107
|
*/
|
|
@@ -100,8 +100,10 @@ class SMTPPool extends EventEmitter {
|
|
|
100
100
|
let connection;
|
|
101
101
|
const len = this._connections.length;
|
|
102
102
|
this._closed = true;
|
|
103
|
-
//
|
|
104
|
-
|
|
103
|
+
// release connections gated by the rate limiter so they become
|
|
104
|
+
// available and are torn down below instead of leaking with a
|
|
105
|
+
// cleared timer that never fires
|
|
106
|
+
this._clearRateLimit();
|
|
105
107
|
if (!len && !this._queue.length) {
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
@@ -153,6 +155,7 @@ class SMTPPool extends EventEmitter {
|
|
|
153
155
|
/**
|
|
154
156
|
* Check the queue and available connections. If there is a message to be sent and there is
|
|
155
157
|
* an available connection, then use this connection to send the mail
|
|
158
|
+
* @internal
|
|
156
159
|
*/
|
|
157
160
|
_processMessages() {
|
|
158
161
|
// do nothing if already closed
|
|
@@ -217,6 +220,7 @@ class SMTPPool extends EventEmitter {
|
|
|
217
220
|
}
|
|
218
221
|
/**
|
|
219
222
|
* Creates a new pool resource
|
|
223
|
+
* @internal
|
|
220
224
|
*/
|
|
221
225
|
_createConnection() {
|
|
222
226
|
const connection = new PoolResource(this);
|
|
@@ -309,12 +313,14 @@ class SMTPPool extends EventEmitter {
|
|
|
309
313
|
this._connections.push(connection);
|
|
310
314
|
return connection;
|
|
311
315
|
}
|
|
316
|
+
/** @internal */
|
|
312
317
|
_shouldRequeuOnConnectionClose(queueEntry) {
|
|
313
318
|
if (this.options.maxRequeues === undefined || this.options.maxRequeues < 0) {
|
|
314
319
|
return true;
|
|
315
320
|
}
|
|
316
321
|
return queueEntry.requeueAttempts < this.options.maxRequeues;
|
|
317
322
|
}
|
|
323
|
+
/** @internal */
|
|
318
324
|
_failDeliveryOnConnectionClose(connection) {
|
|
319
325
|
if (connection.queueEntry && connection.queueEntry.callback) {
|
|
320
326
|
try {
|
|
@@ -331,6 +337,7 @@ class SMTPPool extends EventEmitter {
|
|
|
331
337
|
connection.queueEntry = false;
|
|
332
338
|
}
|
|
333
339
|
}
|
|
340
|
+
/** @internal */
|
|
334
341
|
_requeueEntryOnConnectionClose(connection) {
|
|
335
342
|
connection.queueEntry.requeueAttempts += 1;
|
|
336
343
|
this.logger.debug({
|
|
@@ -344,6 +351,7 @@ class SMTPPool extends EventEmitter {
|
|
|
344
351
|
}
|
|
345
352
|
/**
|
|
346
353
|
* Continue to process message if the pool hasn't closed
|
|
354
|
+
* @internal
|
|
347
355
|
*/
|
|
348
356
|
_continueProcessing() {
|
|
349
357
|
if (this._closed) {
|
|
@@ -357,6 +365,7 @@ class SMTPPool extends EventEmitter {
|
|
|
357
365
|
* Remove resource from pool
|
|
358
366
|
*
|
|
359
367
|
* @param connection The PoolResource to remove
|
|
368
|
+
* @internal
|
|
360
369
|
*/
|
|
361
370
|
_removeConnection(connection) {
|
|
362
371
|
const index = this._connections.indexOf(connection);
|
|
@@ -368,6 +377,7 @@ class SMTPPool extends EventEmitter {
|
|
|
368
377
|
* Checks if connections have hit current rate limit and if so, queues the availability callback
|
|
369
378
|
*
|
|
370
379
|
* @param callback Callback function to run once rate limiter has been cleared
|
|
380
|
+
* @internal
|
|
371
381
|
*/
|
|
372
382
|
_checkRateLimit(callback) {
|
|
373
383
|
if (!this._rateLimit.limit) {
|
|
@@ -388,6 +398,7 @@ class SMTPPool extends EventEmitter {
|
|
|
388
398
|
}
|
|
389
399
|
/**
|
|
390
400
|
* Clears current rate limit limitation and runs paused callback
|
|
401
|
+
* @internal
|
|
391
402
|
*/
|
|
392
403
|
_clearRateLimit() {
|
|
393
404
|
clearTimeout(this._rateLimit.timeout);
|
|
@@ -26,9 +26,7 @@ export default class PoolResource extends EventEmitter {
|
|
|
26
26
|
/**
|
|
27
27
|
* Authentication data for the connection, set when the pool options include auth
|
|
28
28
|
*/
|
|
29
|
-
auth?: SMTPTransportAuth;
|
|
30
|
-
_connection: boolean;
|
|
31
|
-
_connected: boolean;
|
|
29
|
+
auth?: SMTPTransportAuth | undefined;
|
|
32
30
|
messages: number;
|
|
33
31
|
available: boolean;
|
|
34
32
|
/**
|
|
@@ -42,7 +40,7 @@ export default class PoolResource extends EventEmitter {
|
|
|
42
40
|
/**
|
|
43
41
|
* The queue entry being sent, assigned by the pool. False once it has been handled
|
|
44
42
|
*/
|
|
45
|
-
queueEntry?: SMTPPoolQueueEntry | false;
|
|
43
|
+
queueEntry?: SMTPPoolQueueEntry | false | undefined;
|
|
46
44
|
constructor(pool: SMTPPool);
|
|
47
45
|
/**
|
|
48
46
|
* Initiates a connection to the SMTP server
|
|
@@ -12,19 +12,19 @@ import type { MimeNodeEnvelope } from '../mime-node/index.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export interface SMTPTransportAuthOptions extends XOAuth2Options {
|
|
14
14
|
/** 'OAuth2' selects XOAUTH2, anything else is a password login, 'LOGIN' when not set */
|
|
15
|
-
type?: string;
|
|
15
|
+
type?: string | undefined;
|
|
16
16
|
/** Username */
|
|
17
|
-
user?: string;
|
|
17
|
+
user?: string | undefined;
|
|
18
18
|
/** Password */
|
|
19
|
-
pass?: string;
|
|
19
|
+
pass?: string | undefined;
|
|
20
20
|
/** SASL method to use, e.g. 'PLAIN', 'LOGIN' or 'CRAM-MD5' */
|
|
21
|
-
method?: string;
|
|
21
|
+
method?: string | undefined;
|
|
22
22
|
/** Extra options for the authentication method, handed to a custom SASL handler */
|
|
23
23
|
options?: {
|
|
24
24
|
[key: string]: any;
|
|
25
|
-
};
|
|
25
|
+
} | undefined;
|
|
26
26
|
/** Service identifier, an OAuth2 login needs either this or a user */
|
|
27
|
-
service?: string;
|
|
27
|
+
service?: string | undefined;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Authentication data built by getAuth() and handed to SMTPConnection#login
|
|
@@ -50,21 +50,21 @@ export type SMTPTransportGetSocket = (options: SMTPTransportOptions, callback: S
|
|
|
50
50
|
*/
|
|
51
51
|
export interface SMTPTransportOptions extends SMTPConnectionOptions, TransportOptions {
|
|
52
52
|
/** Well-known service name, e.g. 'Gmail', fills in host, port and secure */
|
|
53
|
-
service?: string;
|
|
53
|
+
service?: string | undefined;
|
|
54
54
|
/** Connection url, e.g. 'smtps://user:pass@smtp.example.com', parsed into options */
|
|
55
|
-
url?: string;
|
|
55
|
+
url?: string | undefined;
|
|
56
56
|
/** Authentication settings, no authentication when not set */
|
|
57
|
-
auth?: SMTPTransportAuthOptions;
|
|
57
|
+
auth?: SMTPTransportAuthOptions | undefined;
|
|
58
58
|
/** Custom socket provider, e.g. for connecting through a proxy, replaces the getSocket method */
|
|
59
|
-
getSocket?: SMTPTransportGetSocket;
|
|
59
|
+
getSocket?: SMTPTransportGetSocket | undefined;
|
|
60
60
|
/** Authenticate even when the server does not advertise AUTH, and fail verify() when it does but no credentials were given */
|
|
61
|
-
forceAuth?: boolean;
|
|
61
|
+
forceAuth?: boolean | undefined;
|
|
62
62
|
/** Default SASL method for the password logins when the auth settings do not name one */
|
|
63
|
-
authMethod?: string;
|
|
63
|
+
authMethod?: string | undefined;
|
|
64
64
|
/** Logger component name, defaults to 'smtp-transport' */
|
|
65
|
-
component?: string;
|
|
65
|
+
component?: string | undefined;
|
|
66
66
|
/** Set to true to get a pooled transport from createTransport, this transport does not read it */
|
|
67
|
-
pool?: boolean;
|
|
67
|
+
pool?: boolean | undefined;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Result of a sent message, the connection result plus the envelope and the Message-ID
|
|
@@ -97,11 +97,11 @@ declare class SMTPTransport extends EventEmitter {
|
|
|
97
97
|
/**
|
|
98
98
|
* Transport level authentication data, set when the options include auth
|
|
99
99
|
*/
|
|
100
|
-
auth?: SMTPTransportAuth | false;
|
|
100
|
+
auth?: SMTPTransportAuth | false | undefined;
|
|
101
101
|
/**
|
|
102
102
|
* The Mail instance using this transport, assigned by Mail
|
|
103
103
|
*/
|
|
104
|
-
mailer?: Mail<SMTPSentMessageInfo
|
|
104
|
+
mailer?: Mail<SMTPSentMessageInfo> | undefined;
|
|
105
105
|
constructor(options?: SMTPTransportOptions | string);
|
|
106
106
|
/**
|
|
107
107
|
* Placeholder function for creating proxy sockets. This method immediatelly returns
|