@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
|
@@ -51,6 +51,9 @@ const SOCKET_TIMEOUT = 10 * 60 * 1000; // how much to wait for socket inactivity
|
|
|
51
51
|
const GREETING_TIMEOUT = 30 * 1000; // how much to wait after connection is established but SMTP greeting is not receieved
|
|
52
52
|
const DNS_TIMEOUT = 30 * 1000; // how much to wait for resolveHostname
|
|
53
53
|
const TEARDOWN_NOOP = () => { }; // reusable no-op handler for absorbing errors during socket teardown
|
|
54
|
+
// how many bytes a single server response may occupy while it is still being received.
|
|
55
|
+
// Generous compared to any real reply, it only stops a peer that never completes one
|
|
56
|
+
const MAX_RESPONSE_SIZE = 1024 * 1024;
|
|
54
57
|
/**
|
|
55
58
|
* Re-interpret a server response stored in fake 8-bit byte-container form
|
|
56
59
|
* (the result of chunk.toString('binary') in _onData) as UTF-8.
|
|
@@ -79,11 +82,19 @@ function decodeServerResponse(str) {
|
|
|
79
82
|
* Called with the byte-container form the queue holds (see _onData): the check only looks
|
|
80
83
|
* at leading ASCII digits and '-' of the last line, and a UTF-8 continuation byte is never
|
|
81
84
|
* 0x0A, so line boundaries and the tested prefix are the same before and after decoding.
|
|
82
|
-
* The last line is read with lastIndexOf rather than split() because a queue entry
|
|
83
|
-
*
|
|
85
|
+
* The last line is read with lastIndexOf rather than split() because a queue entry may hold
|
|
86
|
+
* a whole multiline reply and only its final line matters.
|
|
84
87
|
*/
|
|
85
88
|
function isPartialResponse(str) {
|
|
86
|
-
return
|
|
89
|
+
return isPartialLine(str.slice(str.lastIndexOf('\n') + 1));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* True when a single reply line is a continuation ("250-..."). Used where the line is
|
|
93
|
+
* already known to be one line, which skips the scan isPartialResponse needs to find the
|
|
94
|
+
* last line of a whole reply.
|
|
95
|
+
*/
|
|
96
|
+
function isPartialLine(line) {
|
|
97
|
+
return /^\d+-/.test(line);
|
|
87
98
|
}
|
|
88
99
|
/**
|
|
89
100
|
* Generates a SMTP connection object
|
|
@@ -100,6 +111,7 @@ function isPartialResponse(str) {
|
|
|
100
111
|
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
|
|
101
112
|
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
|
|
102
113
|
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
|
|
114
|
+
* * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
|
|
103
115
|
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
|
|
104
116
|
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
|
|
105
117
|
* * **logger** - bunyan compatible logger interface
|
|
@@ -146,6 +158,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
146
158
|
this.secure = !!this.secureConnection;
|
|
147
159
|
this._remainder = '';
|
|
148
160
|
this._responseQueue = [];
|
|
161
|
+
this._responsePartial = false;
|
|
149
162
|
this.lastServerResponse = false;
|
|
150
163
|
this._socket = false;
|
|
151
164
|
this._supportedAuth = [];
|
|
@@ -263,6 +276,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
263
276
|
*
|
|
264
277
|
* @param opts Connection options (modified in place)
|
|
265
278
|
* @param callback Called with resolved data on success
|
|
279
|
+
* @internal
|
|
266
280
|
*/
|
|
267
281
|
_resolveAndConnect(opts, callback) {
|
|
268
282
|
return shared.resolveHostname(opts, (err, resolved) => {
|
|
@@ -288,6 +302,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
288
302
|
*
|
|
289
303
|
* @param opts Connection options
|
|
290
304
|
* @param secure Whether to use TLS
|
|
305
|
+
* @internal
|
|
291
306
|
*/
|
|
292
307
|
_connectToHost(opts, secure) {
|
|
293
308
|
// If the client was closed while DNS resolution was in flight, do not open
|
|
@@ -320,6 +335,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
320
335
|
}
|
|
321
336
|
/**
|
|
322
337
|
* Sets up connection timeout and error handlers
|
|
338
|
+
* @internal
|
|
323
339
|
*/
|
|
324
340
|
_setupConnectionHandlers() {
|
|
325
341
|
this._connectionTimeout = setTimeout(() => {
|
|
@@ -332,6 +348,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
332
348
|
*
|
|
333
349
|
* @param err Error object or message
|
|
334
350
|
* @param code Error code
|
|
351
|
+
* @internal
|
|
335
352
|
*/
|
|
336
353
|
_onConnectionError(err, code) {
|
|
337
354
|
clearTimeout(this._connectionTimeout);
|
|
@@ -655,6 +672,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
655
672
|
* the server is opened
|
|
656
673
|
*
|
|
657
674
|
* @event
|
|
675
|
+
* @internal
|
|
658
676
|
*/
|
|
659
677
|
_onConnect() {
|
|
660
678
|
const socket = this._socket;
|
|
@@ -703,39 +721,71 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
703
721
|
*
|
|
704
722
|
* @event
|
|
705
723
|
* @param chunk Data chunk coming from the server
|
|
724
|
+
* @internal
|
|
706
725
|
*/
|
|
707
726
|
_onData(chunk) {
|
|
708
727
|
if (this._destroyed || !chunk || !chunk.length) {
|
|
709
728
|
return;
|
|
710
729
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
730
|
+
const maxResponseSize = this.options.maxResponseSize || MAX_RESPONSE_SIZE;
|
|
731
|
+
const data = chunk.toString('binary');
|
|
732
|
+
// A chunk without a line break only extends the line currently being received, so
|
|
733
|
+
// keep it in the remainder and leave that string unflattened. Splitting the whole
|
|
734
|
+
// remainder again on every chunk would rescan everything buffered for that line so
|
|
735
|
+
// far, which is quadratic in the length of a line the peer never terminates
|
|
736
|
+
if (!data.includes('\n')) {
|
|
737
|
+
this._remainder += data;
|
|
738
|
+
if (this._remainder.length > maxResponseSize) {
|
|
739
|
+
return this._onResponseTooLarge();
|
|
740
|
+
}
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const lines = (this._remainder + data).split(/\r?\n/);
|
|
714
744
|
this._remainder = lines.pop();
|
|
715
745
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
716
|
-
if (this.
|
|
717
|
-
|
|
718
|
-
if (isPartialResponse(lastline)) {
|
|
719
|
-
this._responseQueue[this._responseQueue.length - 1] += '\n' + lines[i];
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
746
|
+
if (this._responsePartial) {
|
|
747
|
+
this._responseQueue[this._responseQueue.length - 1] += '\n' + lines[i];
|
|
722
748
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (this._responseQueue.length) {
|
|
726
|
-
lastline = this._responseQueue[this._responseQueue.length - 1];
|
|
727
|
-
if (isPartialResponse(lastline)) {
|
|
728
|
-
return;
|
|
749
|
+
else {
|
|
750
|
+
this._responseQueue.push(lines[i]);
|
|
729
751
|
}
|
|
752
|
+
// The line just added is the last line of that queue entry, so it alone decides
|
|
753
|
+
// whether the reply is still partial. Looking for the last line of the accumulated
|
|
754
|
+
// entry instead would rescan a string that grows with every continuation line,
|
|
755
|
+
// which is quadratic in the size of the reply
|
|
756
|
+
this._responsePartial = isPartialLine(lines[i]);
|
|
757
|
+
// Checked as each line lands, so a peer that never completes a reply cannot keep
|
|
758
|
+
// buffering, and the limit does not depend on how it split its bytes into chunks
|
|
759
|
+
if (this._responsePartial && this._responseQueue[this._responseQueue.length - 1].length > maxResponseSize) {
|
|
760
|
+
return this._onResponseTooLarge();
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (this._remainder.length > maxResponseSize) {
|
|
764
|
+
return this._onResponseTooLarge();
|
|
765
|
+
}
|
|
766
|
+
if (this._responsePartial) {
|
|
767
|
+
return;
|
|
730
768
|
}
|
|
731
769
|
this._processResponse();
|
|
732
770
|
}
|
|
771
|
+
/**
|
|
772
|
+
* Drops a connection whose peer keeps extending a reply it never completes, releasing
|
|
773
|
+
* whatever was buffered for that reply
|
|
774
|
+
* @internal
|
|
775
|
+
*/
|
|
776
|
+
_onResponseTooLarge() {
|
|
777
|
+
this._remainder = '';
|
|
778
|
+
this._responseQueue = [];
|
|
779
|
+
this._responsePartial = false;
|
|
780
|
+
this._onError(new Error('Server response exceeds maximum allowed size'), 'EPROTOCOL', false, 'CONN');
|
|
781
|
+
}
|
|
733
782
|
/**
|
|
734
783
|
* 'error' listener for the socket
|
|
735
784
|
*
|
|
736
785
|
* @event
|
|
737
786
|
* @param err Error object
|
|
738
787
|
* @param type Error name
|
|
788
|
+
* @internal
|
|
739
789
|
*/
|
|
740
790
|
_onError(err, type, data, command) {
|
|
741
791
|
clearTimeout(this._connectionTimeout);
|
|
@@ -757,6 +807,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
757
807
|
this.emit('error', err);
|
|
758
808
|
this.close();
|
|
759
809
|
}
|
|
810
|
+
/** @internal */
|
|
760
811
|
_formatError(message, type, response, command) {
|
|
761
812
|
let err;
|
|
762
813
|
if (/Error\]$/i.test(Object.prototype.toString.call(message))) {
|
|
@@ -785,6 +836,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
785
836
|
* 'close' listener for the socket
|
|
786
837
|
*
|
|
787
838
|
* @event
|
|
839
|
+
* @internal
|
|
788
840
|
*/
|
|
789
841
|
_onClose() {
|
|
790
842
|
let serverResponse = false;
|
|
@@ -814,6 +866,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
814
866
|
* 'end' listener for the socket
|
|
815
867
|
*
|
|
816
868
|
* @event
|
|
869
|
+
* @internal
|
|
817
870
|
*/
|
|
818
871
|
_onEnd() {
|
|
819
872
|
if (this._socket && !this._socket.destroyed) {
|
|
@@ -826,12 +879,14 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
826
879
|
* 'timeout' listener for the socket
|
|
827
880
|
*
|
|
828
881
|
* @event
|
|
882
|
+
* @internal
|
|
829
883
|
*/
|
|
830
884
|
_onTimeout() {
|
|
831
885
|
return this._onError(new Error('Timeout'), 'ETIMEDOUT', false, 'CONN');
|
|
832
886
|
}
|
|
833
887
|
/**
|
|
834
888
|
* Destroys the client, emits 'end'
|
|
889
|
+
* @internal
|
|
835
890
|
*/
|
|
836
891
|
_destroy() {
|
|
837
892
|
if (this._destroyed) {
|
|
@@ -853,6 +908,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
853
908
|
*
|
|
854
909
|
* @param callback Callback function to run when the connection
|
|
855
910
|
* has been secured
|
|
911
|
+
* @internal
|
|
856
912
|
*/
|
|
857
913
|
_upgradeConnection(callback) {
|
|
858
914
|
// RFC 3207 section 6: the client MUST discard any knowledge obtained from
|
|
@@ -863,6 +919,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
863
919
|
// part of the secured EHLO capabilities). STARTTLS response injection.
|
|
864
920
|
this._remainder = '';
|
|
865
921
|
this._responseQueue = [];
|
|
922
|
+
this._responsePartial = false;
|
|
866
923
|
// do not remove all listeners or it breaks node v0.10 as there's
|
|
867
924
|
// apparently a 'finish' event set that would be cleared as well
|
|
868
925
|
// we can safely keep 'error', 'end', 'close' etc. events
|
|
@@ -913,6 +970,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
913
970
|
}
|
|
914
971
|
/**
|
|
915
972
|
* Processes queued responses from the server
|
|
973
|
+
* @internal
|
|
916
974
|
*/
|
|
917
975
|
_processResponse() {
|
|
918
976
|
if (!this._responseQueue.length) {
|
|
@@ -952,6 +1010,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
952
1010
|
*
|
|
953
1011
|
* @param str String to be sent to the server
|
|
954
1012
|
* @param logStr Optional string to be used for logging instead of the actual string
|
|
1013
|
+
* @internal
|
|
955
1014
|
*/
|
|
956
1015
|
_sendCommand(str, logStr) {
|
|
957
1016
|
if (this._destroyed) {
|
|
@@ -977,6 +1036,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
977
1036
|
* {from:'...', to:['...']}
|
|
978
1037
|
* or
|
|
979
1038
|
* {from:{address:'...',name:'...'}, to:[address:'...',name:'...']}
|
|
1039
|
+
* @internal
|
|
980
1040
|
*/
|
|
981
1041
|
_setEnvelope(envelope, callback) {
|
|
982
1042
|
const args = [];
|
|
@@ -1073,6 +1133,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1073
1133
|
}
|
|
1074
1134
|
this._sendCommand('MAIL FROM:<' + this._envelope.from + '>' + (args.length ? ' ' + args.join(' ') : ''));
|
|
1075
1135
|
}
|
|
1136
|
+
/** @internal */
|
|
1076
1137
|
_setDsnEnvelope(params) {
|
|
1077
1138
|
let ret = (params.ret || params.return || '').toString().toUpperCase() || null;
|
|
1078
1139
|
if (ret) {
|
|
@@ -1115,6 +1176,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1115
1176
|
orcpt
|
|
1116
1177
|
};
|
|
1117
1178
|
}
|
|
1179
|
+
/** @internal */
|
|
1118
1180
|
_getDsnRcptToArgs() {
|
|
1119
1181
|
const envelope = this._envelope;
|
|
1120
1182
|
const args = [];
|
|
@@ -1130,6 +1192,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1130
1192
|
}
|
|
1131
1193
|
return args.length ? ' ' + args.join(' ') : '';
|
|
1132
1194
|
}
|
|
1195
|
+
/** @internal */
|
|
1133
1196
|
_createSendStream(callback) {
|
|
1134
1197
|
const envelope = this._envelope;
|
|
1135
1198
|
const dataStream = new data_stream_js_1.default();
|
|
@@ -1181,6 +1244,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1181
1244
|
* SMTP session by sending EHLO command
|
|
1182
1245
|
*
|
|
1183
1246
|
* @param str Message from the server
|
|
1247
|
+
* @internal
|
|
1184
1248
|
*/
|
|
1185
1249
|
_actionGreeting(str) {
|
|
1186
1250
|
clearTimeout(this._greetingTimeout);
|
|
@@ -1202,6 +1266,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1202
1266
|
* error, emit 'error', otherwise treat this as an EHLO response
|
|
1203
1267
|
*
|
|
1204
1268
|
* @param str Message from the server
|
|
1269
|
+
* @internal
|
|
1205
1270
|
*/
|
|
1206
1271
|
_actionLHLO(str) {
|
|
1207
1272
|
if (str.charAt(0) !== '2') {
|
|
@@ -1217,6 +1282,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1217
1282
|
* authentication phase.
|
|
1218
1283
|
*
|
|
1219
1284
|
* @param str Message from the server
|
|
1285
|
+
* @internal
|
|
1220
1286
|
*/
|
|
1221
1287
|
_actionEHLO(str) {
|
|
1222
1288
|
let match;
|
|
@@ -1297,6 +1363,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1297
1363
|
* error, emit 'error', otherwise move into the authentication phase.
|
|
1298
1364
|
*
|
|
1299
1365
|
* @param str Message from the server
|
|
1366
|
+
* @internal
|
|
1300
1367
|
*/
|
|
1301
1368
|
_actionHELO(str) {
|
|
1302
1369
|
if (str.charAt(0) !== '2') {
|
|
@@ -1313,6 +1380,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1313
1380
|
* succeedes restart the EHLO
|
|
1314
1381
|
*
|
|
1315
1382
|
* @param str Message from the server
|
|
1383
|
+
* @internal
|
|
1316
1384
|
*/
|
|
1317
1385
|
_actionSTARTTLS(str) {
|
|
1318
1386
|
if (str.charAt(0) !== '2') {
|
|
@@ -1358,6 +1426,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1358
1426
|
* hosts invalidly use a longer message than VXNlcm5hbWU6
|
|
1359
1427
|
*
|
|
1360
1428
|
* @param str Message from the server
|
|
1429
|
+
* @internal
|
|
1361
1430
|
*/
|
|
1362
1431
|
_actionAUTH_LOGIN_USER(str, callback) {
|
|
1363
1432
|
if (!/^334[ -]/.test(str)) {
|
|
@@ -1378,6 +1447,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1378
1447
|
* base64 encoded again.
|
|
1379
1448
|
*
|
|
1380
1449
|
* @param str Message from the server
|
|
1450
|
+
* @internal
|
|
1381
1451
|
*/
|
|
1382
1452
|
_actionAUTH_CRAM_MD5(str, callback) {
|
|
1383
1453
|
const challengeMatch = str.match(/^334\s+(.+)$/);
|
|
@@ -1401,6 +1471,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1401
1471
|
* the user can be considered logged in. Start waiting for a message to send
|
|
1402
1472
|
*
|
|
1403
1473
|
* @param str Message from the server
|
|
1474
|
+
* @internal
|
|
1404
1475
|
*/
|
|
1405
1476
|
_actionAUTH_CRAM_MD5_PASS(str, callback) {
|
|
1406
1477
|
if (!str.match(/^235\s+/)) {
|
|
@@ -1421,6 +1492,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1421
1492
|
* response needs to be base64 encoded password.
|
|
1422
1493
|
*
|
|
1423
1494
|
* @param str Message from the server
|
|
1495
|
+
* @internal
|
|
1424
1496
|
*/
|
|
1425
1497
|
_actionAUTH_LOGIN_PASS(str, callback) {
|
|
1426
1498
|
if (!/^334[ -]/.test(str)) {
|
|
@@ -1439,6 +1511,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1439
1511
|
* the user can be considered logged in. Start waiting for a message to send
|
|
1440
1512
|
*
|
|
1441
1513
|
* @param str Message from the server
|
|
1514
|
+
* @internal
|
|
1442
1515
|
*/
|
|
1443
1516
|
_actionAUTHComplete(str, isRetry, callback) {
|
|
1444
1517
|
if (!callback && typeof isRetry === 'function') {
|
|
@@ -1480,6 +1553,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1480
1553
|
* Handle response for a MAIL FROM: command
|
|
1481
1554
|
*
|
|
1482
1555
|
* @param str Message from the server
|
|
1556
|
+
* @internal
|
|
1483
1557
|
*/
|
|
1484
1558
|
_actionMAIL(str, callback) {
|
|
1485
1559
|
const envelope = this._envelope;
|
|
@@ -1507,6 +1581,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1507
1581
|
* Handle response for a RCPT TO: command
|
|
1508
1582
|
*
|
|
1509
1583
|
* @param str Message from the server
|
|
1584
|
+
* @internal
|
|
1510
1585
|
*/
|
|
1511
1586
|
_actionRCPT(str, callback) {
|
|
1512
1587
|
const envelope = this._envelope;
|
|
@@ -1553,6 +1628,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1553
1628
|
* Handle response for a DATA command
|
|
1554
1629
|
*
|
|
1555
1630
|
* @param str Message from the server
|
|
1631
|
+
* @internal
|
|
1556
1632
|
*/
|
|
1557
1633
|
_actionDATA(str, callback) {
|
|
1558
1634
|
const envelope = this._envelope;
|
|
@@ -1578,6 +1654,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1578
1654
|
* We expect a single response that defines if the sending succeeded or failed
|
|
1579
1655
|
*
|
|
1580
1656
|
* @param str Message from the server
|
|
1657
|
+
* @internal
|
|
1581
1658
|
*/
|
|
1582
1659
|
_actionSMTPStream(str, callback) {
|
|
1583
1660
|
if (Number(str.charAt(0)) !== 2) {
|
|
@@ -1593,6 +1670,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1593
1670
|
* @param recipient The recipient this response applies to
|
|
1594
1671
|
* @param final Is this the final recipient?
|
|
1595
1672
|
* @param str Message from the server
|
|
1673
|
+
* @internal
|
|
1596
1674
|
*/
|
|
1597
1675
|
_actionLMTPStream(recipient, final, str, callback) {
|
|
1598
1676
|
const envelope = this._envelope;
|
|
@@ -1613,6 +1691,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1613
1691
|
return callback(null, str);
|
|
1614
1692
|
}
|
|
1615
1693
|
}
|
|
1694
|
+
/** @internal */
|
|
1616
1695
|
_handleXOauth2Token(isRetry, callback) {
|
|
1617
1696
|
this._auth.oauth2.getToken(isRetry, (err, accessToken) => {
|
|
1618
1697
|
if (err) {
|
|
@@ -1635,7 +1714,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1635
1714
|
/**
|
|
1636
1715
|
*
|
|
1637
1716
|
* @param command
|
|
1638
|
-
* @
|
|
1717
|
+
* @internal
|
|
1639
1718
|
*/
|
|
1640
1719
|
_isDestroyedMessage(command) {
|
|
1641
1720
|
if (this._destroyed) {
|
|
@@ -1650,6 +1729,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
1650
1729
|
}
|
|
1651
1730
|
}
|
|
1652
1731
|
}
|
|
1732
|
+
/** @internal */
|
|
1653
1733
|
_getHostname() {
|
|
1654
1734
|
// defaul hostname is machine hostname or [IP]
|
|
1655
1735
|
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
|
*/
|
|
@@ -138,8 +138,10 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
138
138
|
let connection;
|
|
139
139
|
const len = this._connections.length;
|
|
140
140
|
this._closed = true;
|
|
141
|
-
//
|
|
142
|
-
|
|
141
|
+
// release connections gated by the rate limiter so they become
|
|
142
|
+
// available and are torn down below instead of leaking with a
|
|
143
|
+
// cleared timer that never fires
|
|
144
|
+
this._clearRateLimit();
|
|
143
145
|
if (!len && !this._queue.length) {
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
@@ -191,6 +193,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
191
193
|
/**
|
|
192
194
|
* Check the queue and available connections. If there is a message to be sent and there is
|
|
193
195
|
* an available connection, then use this connection to send the mail
|
|
196
|
+
* @internal
|
|
194
197
|
*/
|
|
195
198
|
_processMessages() {
|
|
196
199
|
// do nothing if already closed
|
|
@@ -255,6 +258,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
255
258
|
}
|
|
256
259
|
/**
|
|
257
260
|
* Creates a new pool resource
|
|
261
|
+
* @internal
|
|
258
262
|
*/
|
|
259
263
|
_createConnection() {
|
|
260
264
|
const connection = new pool_resource_js_1.default(this);
|
|
@@ -347,12 +351,14 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
347
351
|
this._connections.push(connection);
|
|
348
352
|
return connection;
|
|
349
353
|
}
|
|
354
|
+
/** @internal */
|
|
350
355
|
_shouldRequeuOnConnectionClose(queueEntry) {
|
|
351
356
|
if (this.options.maxRequeues === undefined || this.options.maxRequeues < 0) {
|
|
352
357
|
return true;
|
|
353
358
|
}
|
|
354
359
|
return queueEntry.requeueAttempts < this.options.maxRequeues;
|
|
355
360
|
}
|
|
361
|
+
/** @internal */
|
|
356
362
|
_failDeliveryOnConnectionClose(connection) {
|
|
357
363
|
if (connection.queueEntry && connection.queueEntry.callback) {
|
|
358
364
|
try {
|
|
@@ -369,6 +375,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
369
375
|
connection.queueEntry = false;
|
|
370
376
|
}
|
|
371
377
|
}
|
|
378
|
+
/** @internal */
|
|
372
379
|
_requeueEntryOnConnectionClose(connection) {
|
|
373
380
|
connection.queueEntry.requeueAttempts += 1;
|
|
374
381
|
this.logger.debug({
|
|
@@ -382,6 +389,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
382
389
|
}
|
|
383
390
|
/**
|
|
384
391
|
* Continue to process message if the pool hasn't closed
|
|
392
|
+
* @internal
|
|
385
393
|
*/
|
|
386
394
|
_continueProcessing() {
|
|
387
395
|
if (this._closed) {
|
|
@@ -395,6 +403,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
395
403
|
* Remove resource from pool
|
|
396
404
|
*
|
|
397
405
|
* @param connection The PoolResource to remove
|
|
406
|
+
* @internal
|
|
398
407
|
*/
|
|
399
408
|
_removeConnection(connection) {
|
|
400
409
|
const index = this._connections.indexOf(connection);
|
|
@@ -406,6 +415,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
406
415
|
* Checks if connections have hit current rate limit and if so, queues the availability callback
|
|
407
416
|
*
|
|
408
417
|
* @param callback Callback function to run once rate limiter has been cleared
|
|
418
|
+
* @internal
|
|
409
419
|
*/
|
|
410
420
|
_checkRateLimit(callback) {
|
|
411
421
|
if (!this._rateLimit.limit) {
|
|
@@ -426,6 +436,7 @@ class SMTPPool extends node_events_1.EventEmitter {
|
|
|
426
436
|
}
|
|
427
437
|
/**
|
|
428
438
|
* Clears current rate limit limitation and runs paused callback
|
|
439
|
+
* @internal
|
|
429
440
|
*/
|
|
430
441
|
_clearRateLimit() {
|
|
431
442
|
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
|