@mavogel/awscdk-rootmail 0.1.7 → 0.1.9
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 +10 -10
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +5 -5
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-es/schemas/schemas_0.js +4 -4
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliveryDestinationsCommand.d.ts +1 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/GetDeliveryDestinationCommand.d.ts +1 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/PutAccountPolicyCommand.d.ts +4 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/PutDeliveryDestinationCommand.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/models/models_0.d.ts +80 -36
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/ts3.4/models/models_0.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +1 -1
- package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-route-53/package.json +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +2 -1
- package/node_modules/@aws-sdk/client-s3/dist-es/models/enums.js +1 -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/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/models/enums.d.ts +1 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/enums.d.ts +1 -0
- package/node_modules/@aws-sdk/client-s3/package.json +2 -2
- package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ses/package.json +1 -1
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +9 -3
- package/node_modules/@aws-sdk/client-ssm/dist-es/models/enums.js +4 -0
- package/node_modules/@aws-sdk/client-ssm/dist-es/schemas/schemas_0.js +3 -2
- package/node_modules/@aws-sdk/client-ssm/dist-types/commands/DeleteResourcePolicyCommand.d.ts +6 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/commands/PutResourcePolicyCommand.d.ts +12 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/models/enums.d.ts +12 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/models/models_0.d.ts +20 -1
- package/node_modules/@aws-sdk/client-ssm/dist-types/models/models_1.d.ts +2 -2
- package/node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/models/enums.d.ts +5 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/models/models_0.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/package.json +1 -1
- package/node_modules/@zone-eu/mailsplit/lib/flowed-decoder.js +1 -5
- package/node_modules/@zone-eu/mailsplit/lib/headers.js +35 -25
- package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +126 -79
- package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +27 -5
- package/node_modules/@zone-eu/mailsplit/lib/node-rewriter.js +3 -2
- package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +0 -3
- package/node_modules/@zone-eu/mailsplit/package.json +5 -5
- package/node_modules/libbase64/.github/workflows/release.yaml +12 -10
- package/node_modules/libbase64/.ncurc.js +7 -1
- package/node_modules/libbase64/CHANGELOG.md +7 -0
- package/node_modules/libbase64/lib/libbase64.js +27 -0
- package/node_modules/libbase64/package.json +4 -4
- package/node_modules/libmime/CHANGELOG.md +14 -0
- package/node_modules/libmime/lib/libmime.js +41 -21
- package/node_modules/libmime/package.json +3 -3
- package/node_modules/libqp/.github/workflows/release.yaml +12 -10
- package/node_modules/libqp/CHANGELOG.md +7 -0
- package/node_modules/libqp/lib/libqp.js +6 -4
- package/node_modules/libqp/package.json +2 -2
- package/node_modules/libqp/test/libqp-test.js +71 -14
- package/node_modules/mailparser/.release-please-manifest.json +1 -1
- package/node_modules/mailparser/CHANGELOG.md +42 -0
- package/node_modules/mailparser/README.md +5 -0
- package/node_modules/mailparser/lib/mail-parser.js +107 -32
- package/node_modules/mailparser/lib/simple-parser.js +12 -0
- package/node_modules/mailparser/lib/stream-hash.js +1 -1
- package/node_modules/mailparser/package.json +6 -6
- package/node_modules/nodemailer/CHANGELOG.md +38 -0
- package/node_modules/nodemailer/README.md +1 -1
- package/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +16 -2
- package/node_modules/nodemailer/dist/cjs/addressparser/index.js +147 -28
- package/node_modules/nodemailer/dist/cjs/base64/index.js +2 -1
- package/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +13 -1
- package/node_modules/nodemailer/dist/cjs/dkim/index.js +25 -8
- package/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +10 -1
- package/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +28 -4
- package/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +10 -1
- package/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +3 -0
- package/node_modules/nodemailer/dist/cjs/dkim/sign.js +18 -1
- package/node_modules/nodemailer/dist/cjs/errors.d.ts +3 -2
- package/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +12 -1
- package/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +15 -1
- package/node_modules/nodemailer/dist/cjs/fetch/index.js +39 -64
- package/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +14 -4
- package/node_modules/nodemailer/dist/cjs/json-transport/index.js +2 -0
- package/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +8 -3
- package/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +43 -25
- package/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +11 -4
- package/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +7 -3
- package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +198 -84
- package/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +5 -2
- package/node_modules/nodemailer/dist/cjs/mime-node/index.js +2 -1
- package/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +38 -16
- package/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
- 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/punycode/index.js +1 -0
- package/node_modules/nodemailer/dist/cjs/qp/index.d.ts +2 -0
- package/node_modules/nodemailer/dist/cjs/qp/index.js +10 -1
- package/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +2 -0
- package/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +39 -2
- package/node_modules/nodemailer/dist/cjs/shared/index.d.ts +43 -7
- package/node_modules/nodemailer/dist/cjs/shared/index.js +5 -2
- package/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +2 -1
- package/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +32 -24
- package/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +13 -5
- package/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +23 -11
- package/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +59 -24
- package/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +156 -75
- package/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +12 -4
- package/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +39 -11
- package/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +27 -31
- package/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +19 -6
- package/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +25 -33
- package/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +2 -0
- package/node_modules/nodemailer/dist/cjs/well-known/services.js +6 -0
- package/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +13 -3
- package/node_modules/nodemailer/dist/cjs/xoauth2/index.js +25 -13
- package/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +16 -2
- package/node_modules/nodemailer/dist/esm/addressparser/index.js +147 -27
- package/node_modules/nodemailer/dist/esm/base64/index.js +2 -1
- package/node_modules/nodemailer/dist/esm/dkim/index.d.ts +13 -1
- package/node_modules/nodemailer/dist/esm/dkim/index.js +25 -8
- package/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +10 -1
- package/node_modules/nodemailer/dist/esm/dkim/message-parser.js +30 -5
- package/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +10 -1
- package/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +2 -1
- package/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +3 -0
- package/node_modules/nodemailer/dist/esm/dkim/sign.js +18 -1
- package/node_modules/nodemailer/dist/esm/errors.d.ts +3 -2
- package/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +12 -1
- package/node_modules/nodemailer/dist/esm/fetch/cookies.js +2 -1
- package/node_modules/nodemailer/dist/esm/fetch/index.d.ts +15 -1
- package/node_modules/nodemailer/dist/esm/fetch/index.js +39 -64
- package/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +14 -4
- package/node_modules/nodemailer/dist/esm/json-transport/index.js +2 -0
- package/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +8 -3
- package/node_modules/nodemailer/dist/esm/mailer/index.d.ts +43 -25
- package/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +11 -4
- package/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +7 -3
- package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +198 -84
- package/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +5 -2
- package/node_modules/nodemailer/dist/esm/mime-node/index.js +2 -1
- package/node_modules/nodemailer/dist/esm/nodemailer.d.ts +38 -16
- 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/punycode/index.js +1 -0
- package/node_modules/nodemailer/dist/esm/qp/index.d.ts +2 -0
- package/node_modules/nodemailer/dist/esm/qp/index.js +10 -1
- package/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +2 -0
- package/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +39 -2
- package/node_modules/nodemailer/dist/esm/shared/index.d.ts +43 -7
- package/node_modules/nodemailer/dist/esm/shared/index.js +5 -2
- package/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +2 -1
- package/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +32 -24
- package/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +13 -5
- package/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js +23 -11
- package/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +59 -24
- package/node_modules/nodemailer/dist/esm/smtp-connection/index.js +156 -75
- package/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +12 -4
- package/node_modules/nodemailer/dist/esm/smtp-pool/index.js +39 -11
- package/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js +27 -31
- package/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +19 -6
- package/node_modules/nodemailer/dist/esm/smtp-transport/index.js +25 -33
- package/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +2 -0
- package/node_modules/nodemailer/dist/esm/well-known/services.js +6 -0
- package/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +13 -3
- package/node_modules/nodemailer/dist/esm/xoauth2/index.js +25 -13
- package/node_modules/nodemailer/dist/well-known/services.json +7 -0
- package/node_modules/nodemailer/package.json +16 -12
- package/package.json +18 -16
- package/renovate.json5 +59 -0
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import * as punycode from '../punycode/index.js';
|
|
2
2
|
import * as mimeFuncs from '../mime-funcs/index.js';
|
|
3
3
|
import crypto from 'node:crypto';
|
|
4
|
+
import * as errors from '../errors.js';
|
|
5
|
+
/**
|
|
6
|
+
* Error for a hashAlgo value the crypto module does not know
|
|
7
|
+
*/
|
|
8
|
+
function unsupportedHashAlgoError(hashAlgo) {
|
|
9
|
+
const err = new Error('Unsupported DKIM hash algorithm "' + hashAlgo + '"');
|
|
10
|
+
err.code = errors.ECONFIG;
|
|
11
|
+
return err;
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Returns DKIM signature header line
|
|
6
15
|
*
|
|
7
16
|
* @param headers Parsed headers object from MessageParser
|
|
17
|
+
* @param hashAlgo Hash algorithm the body hash was calculated with, for example "sha256"
|
|
8
18
|
* @param bodyHash Base64 encoded hash of the message
|
|
9
19
|
* @param options DKIM options
|
|
10
20
|
* @param options.domainName Domain name to be signed for
|
|
@@ -25,7 +35,13 @@ function sign(headers, hashAlgo, bodyHash, options) {
|
|
|
25
35
|
const canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields);
|
|
26
36
|
const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
|
|
27
37
|
canonicalizedHeaderData.headers += 'dkim-signature:' + relaxedHeaderLine(dkimHeader);
|
|
28
|
-
|
|
38
|
+
let signer;
|
|
39
|
+
try {
|
|
40
|
+
signer = crypto.createSign(('rsa-' + hashAlgo).toUpperCase());
|
|
41
|
+
}
|
|
42
|
+
catch (_E) {
|
|
43
|
+
throw unsupportedHashAlgoError(hashAlgo);
|
|
44
|
+
}
|
|
29
45
|
// the header lines are 'binary' strings, so this reproduces the original header bytes
|
|
30
46
|
signer.update(canonicalizedHeaderData.headers, 'latin1');
|
|
31
47
|
let signature;
|
|
@@ -38,6 +54,7 @@ function sign(headers, hashAlgo, bodyHash, options) {
|
|
|
38
54
|
return dkimHeader + signature.replace(/(^.{73}|.{75}(?!\r?\n|\r))/g, '$&\r\n ').trim();
|
|
39
55
|
}
|
|
40
56
|
sign.relaxedHeaders = relaxedHeaders;
|
|
57
|
+
sign.unsupportedHashAlgoError = unsupportedHashAlgoError;
|
|
41
58
|
export default sign;
|
|
42
59
|
function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyHash) {
|
|
43
60
|
// the caller supplied tag values are interpolated straight into the tag list, and none of
|
|
@@ -64,9 +64,10 @@ export declare const EFETCH = "EFETCH";
|
|
|
64
64
|
/**
|
|
65
65
|
* An Error together with the properties Nodemailer attaches to the errors it
|
|
66
66
|
* hands to callers. Every property is optional, the set that is present
|
|
67
|
-
* depends on where the error originated.
|
|
67
|
+
* depends on where the error originated. Socket level errors keep the errno
|
|
68
|
+
* and syscall fields Node.js sets on them.
|
|
68
69
|
*/
|
|
69
|
-
export interface NodemailerError extends
|
|
70
|
+
export interface NodemailerError extends NodeJS.ErrnoException {
|
|
70
71
|
/** Nodemailer error code, see ERROR_CODES */
|
|
71
72
|
code?: string | undefined;
|
|
72
73
|
/** SMTP command that was in flight when the server replied with an error */
|
|
@@ -17,13 +17,14 @@ export interface Cookie {
|
|
|
17
17
|
secure?: boolean | undefined;
|
|
18
18
|
httponly?: boolean | undefined;
|
|
19
19
|
}
|
|
20
|
+
type CookieEntry = Cookie;
|
|
20
21
|
/**
|
|
21
22
|
* Creates a biskviit cookie jar for managing cookie values in memory
|
|
22
23
|
*
|
|
23
24
|
* @constructor
|
|
24
25
|
* @param [options] Optional options object
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
declare class Cookies {
|
|
27
28
|
options: CookiesOptions;
|
|
28
29
|
cookies: Cookie[];
|
|
29
30
|
constructor(options?: CookiesOptions);
|
|
@@ -94,3 +95,13 @@ export default class Cookies {
|
|
|
94
95
|
*/
|
|
95
96
|
getPath(pathname?: string | null): string;
|
|
96
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Type aliases in the layout of @types/nodemailer, so `Cookies.Cookie` style references keep working
|
|
100
|
+
*/
|
|
101
|
+
declare namespace Cookies {
|
|
102
|
+
type Options = CookiesOptions;
|
|
103
|
+
type Cookie = CookieEntry;
|
|
104
|
+
}
|
|
105
|
+
/** The same alias as a module level export, for `import * as Cookies` and `import Cookies = require()` */
|
|
106
|
+
export type { CookiesOptions as Options };
|
|
107
|
+
export default Cookies;
|
|
@@ -8,7 +8,7 @@ const SESSION_TIMEOUT = 1800; // 30 min
|
|
|
8
8
|
* @constructor
|
|
9
9
|
* @param [options] Optional options object
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
class Cookies {
|
|
12
12
|
constructor(options) {
|
|
13
13
|
this.options = options || {};
|
|
14
14
|
this.cookies = [];
|
|
@@ -239,3 +239,4 @@ export default class Cookies {
|
|
|
239
239
|
return path;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
+
export default Cookies;
|
|
@@ -25,8 +25,10 @@ export interface FetchOptions {
|
|
|
25
25
|
tls?: {
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
} | undefined;
|
|
28
|
-
/**
|
|
28
|
+
/** Socket inactivity timeout in milliseconds, defaults to 60000, 0 disables it */
|
|
29
29
|
timeout?: number | undefined;
|
|
30
|
+
/** Maximum size of the (decoded) response body in bytes, defaults to 64 MB, Infinity disables the limit */
|
|
31
|
+
maxBytes?: number | undefined;
|
|
30
32
|
/** Maximum number of redirects to follow (default 5) */
|
|
31
33
|
maxRedirects?: number | undefined;
|
|
32
34
|
/** Resolve responses with a status code of 300 or above instead of emitting an error */
|
|
@@ -47,5 +49,17 @@ export interface FetchResponse extends PassThrough {
|
|
|
47
49
|
declare function nmfetch(url: string, options?: FetchOptions): FetchResponse;
|
|
48
50
|
declare namespace nmfetch {
|
|
49
51
|
var Cookies: typeof import("./cookies.js").default;
|
|
52
|
+
var DEFAULT_TIMEOUT: number;
|
|
50
53
|
}
|
|
54
|
+
type CookiesJar = Cookies;
|
|
55
|
+
/**
|
|
56
|
+
* Type aliases in the layout of @types/nodemailer, so `fetch.Options` style references keep working
|
|
57
|
+
*/
|
|
58
|
+
declare namespace nmfetch {
|
|
59
|
+
type Options = FetchOptions;
|
|
60
|
+
type WritableResponse = FetchResponse;
|
|
61
|
+
type Cookies = CookiesJar;
|
|
62
|
+
}
|
|
63
|
+
/** The same aliases as module level exports, for `import * as fetch` and `import fetch = require()` */
|
|
64
|
+
export type { FetchOptions as Options, FetchResponse as WritableResponse, Cookies };
|
|
51
65
|
export default nmfetch;
|
|
@@ -9,6 +9,10 @@ import net from 'node:net';
|
|
|
9
9
|
import * as errors from '../errors.js';
|
|
10
10
|
import { isProtoKey } from '../shared/objects.js';
|
|
11
11
|
const MAX_REDIRECTS = 5;
|
|
12
|
+
// a stalled server would otherwise hold the request, and whatever waits on it, open forever
|
|
13
|
+
const DEFAULT_TIMEOUT = 60 * 1000;
|
|
14
|
+
// the body is usually buffered in memory by the caller, so an unbounded download is refused
|
|
15
|
+
const DEFAULT_MAX_BYTES = 64 * 1024 * 1024;
|
|
12
16
|
// Only genuine TLS settings are taken from options.tls. That object reaches us straight
|
|
13
17
|
// from a user supplied attachment (content.tls), so keys like host, port, path, socketPath
|
|
14
18
|
// or lookup would otherwise repoint the request at a destination that never went through
|
|
@@ -155,14 +159,14 @@ function nmfetch(url, options) {
|
|
|
155
159
|
.join('&'));
|
|
156
160
|
}
|
|
157
161
|
catch (E) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
// the caller attaches its error listener once nmfetch has returned, so
|
|
163
|
+
// the error is emitted on the next tick and the stream is handed back
|
|
164
|
+
// the way every other failure is reported
|
|
161
165
|
finished = true;
|
|
162
166
|
E.code = errors.EFETCH;
|
|
163
167
|
E.sourceUrl = url;
|
|
164
|
-
fetchRes.emit('error', E);
|
|
165
|
-
return
|
|
168
|
+
setImmediate(() => fetchRes.emit('error', E));
|
|
169
|
+
return fetchRes;
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
172
|
else {
|
|
@@ -214,28 +218,22 @@ function nmfetch(url, options) {
|
|
|
214
218
|
});
|
|
215
219
|
return fetchRes;
|
|
216
220
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (finished) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
finished = true;
|
|
223
|
-
req.abort();
|
|
224
|
-
const err = new Error('Request Timeout');
|
|
225
|
-
err.code = errors.EFETCH;
|
|
226
|
-
err.sourceUrl = url;
|
|
227
|
-
fetchRes.emit('error', err);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
req.on('error', (err) => {
|
|
221
|
+
// reports the first failure of this request on fetchRes and releases the request
|
|
222
|
+
const fail = (err, sourceUrl = url) => {
|
|
231
223
|
if (finished) {
|
|
232
224
|
return;
|
|
233
225
|
}
|
|
234
226
|
finished = true;
|
|
235
227
|
err.code = errors.EFETCH;
|
|
236
|
-
err.sourceUrl =
|
|
228
|
+
err.sourceUrl = sourceUrl;
|
|
237
229
|
fetchRes.emit('error', err);
|
|
238
|
-
|
|
230
|
+
req.abort();
|
|
231
|
+
};
|
|
232
|
+
const timeout = typeof options.timeout === 'number' && options.timeout >= 0 ? options.timeout : DEFAULT_TIMEOUT;
|
|
233
|
+
if (timeout) {
|
|
234
|
+
req.setTimeout(timeout, () => fail(new Error('Request Timeout')));
|
|
235
|
+
}
|
|
236
|
+
req.on('error', (err) => fail(err));
|
|
239
237
|
req.on('response', res => {
|
|
240
238
|
let inflate;
|
|
241
239
|
if (finished) {
|
|
@@ -256,13 +254,7 @@ function nmfetch(url, options) {
|
|
|
256
254
|
// redirect
|
|
257
255
|
options.redirects++;
|
|
258
256
|
if (options.redirects > options.maxRedirects) {
|
|
259
|
-
|
|
260
|
-
const err = new Error('Maximum redirect count exceeded');
|
|
261
|
-
err.code = errors.EFETCH;
|
|
262
|
-
err.sourceUrl = url;
|
|
263
|
-
fetchRes.emit('error', err);
|
|
264
|
-
req.abort();
|
|
265
|
-
return;
|
|
257
|
+
return fail(new Error('Maximum redirect count exceeded'));
|
|
266
258
|
}
|
|
267
259
|
// redirect does not include POST body
|
|
268
260
|
options.method = 'GET';
|
|
@@ -282,13 +274,7 @@ function nmfetch(url, options) {
|
|
|
282
274
|
// call: that call gets its own `finished` flag and no handle on this
|
|
283
275
|
// request, so this one would stay open and could emit a second error on
|
|
284
276
|
// the shared fetchRes once it times out. Callers listen with req.once().
|
|
285
|
-
|
|
286
|
-
const err = new Error('Unsupported protocol for URL ' + redirectUrl);
|
|
287
|
-
err.code = errors.EFETCH;
|
|
288
|
-
err.sourceUrl = redirectUrl;
|
|
289
|
-
fetchRes.emit('error', err);
|
|
290
|
-
req.abort();
|
|
291
|
-
return;
|
|
277
|
+
return fail(new Error('Unsupported protocol for URL ' + redirectUrl), redirectUrl);
|
|
292
278
|
}
|
|
293
279
|
// Do not forward credentials when the redirect leaves the original
|
|
294
280
|
// security context: a different host, or a downgrade from https to
|
|
@@ -305,41 +291,33 @@ function nmfetch(url, options) {
|
|
|
305
291
|
}
|
|
306
292
|
});
|
|
307
293
|
}
|
|
294
|
+
// this request is done with, release it so its socket and timeout do not
|
|
295
|
+
// outlive it and report a late error on the shared fetchRes
|
|
296
|
+
finished = true;
|
|
297
|
+
res.resume();
|
|
298
|
+
req.abort();
|
|
308
299
|
return nmfetch(redirectUrl, options);
|
|
309
300
|
}
|
|
310
301
|
fetchRes.statusCode = res.statusCode;
|
|
311
302
|
fetchRes.headers = res.headers;
|
|
312
303
|
if (res.statusCode >= 300 && !options.allowErrorResponse) {
|
|
313
|
-
|
|
314
|
-
const err = new Error('Invalid status code ' + res.statusCode);
|
|
315
|
-
err.code = errors.EFETCH;
|
|
316
|
-
err.sourceUrl = url;
|
|
317
|
-
fetchRes.emit('error', err);
|
|
318
|
-
req.abort();
|
|
319
|
-
return;
|
|
304
|
+
return fail(new Error('Invalid status code ' + res.statusCode));
|
|
320
305
|
}
|
|
321
|
-
res.on('error', (err) =>
|
|
322
|
-
|
|
306
|
+
res.on('error', (err) => fail(err));
|
|
307
|
+
const maxBytes = typeof options.maxBytes === 'number' && options.maxBytes > 0 ? options.maxBytes : DEFAULT_MAX_BYTES;
|
|
308
|
+
const source = inflate || res;
|
|
309
|
+
let received = 0;
|
|
310
|
+
source.on('data', (chunk) => {
|
|
311
|
+
received += chunk.length;
|
|
312
|
+
if (received <= maxBytes || finished) {
|
|
323
313
|
return;
|
|
324
314
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
err.sourceUrl = url;
|
|
328
|
-
fetchRes.emit('error', err);
|
|
329
|
-
req.abort();
|
|
315
|
+
source.unpipe(fetchRes);
|
|
316
|
+
fail(new Error('Response size exceeds the allowed ' + maxBytes + ' bytes'));
|
|
330
317
|
});
|
|
331
318
|
if (inflate) {
|
|
332
319
|
res.pipe(inflate).pipe(fetchRes);
|
|
333
|
-
inflate.on('error', (err) =>
|
|
334
|
-
if (finished) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
finished = true;
|
|
338
|
-
err.code = errors.EFETCH;
|
|
339
|
-
err.sourceUrl = url;
|
|
340
|
-
fetchRes.emit('error', err);
|
|
341
|
-
req.abort();
|
|
342
|
-
});
|
|
320
|
+
inflate.on('error', (err) => fail(err));
|
|
343
321
|
}
|
|
344
322
|
else {
|
|
345
323
|
res.pipe(fetchRes);
|
|
@@ -354,11 +332,7 @@ function nmfetch(url, options) {
|
|
|
354
332
|
req.write(body);
|
|
355
333
|
}
|
|
356
334
|
catch (err) {
|
|
357
|
-
|
|
358
|
-
err.code = errors.EFETCH;
|
|
359
|
-
err.sourceUrl = url;
|
|
360
|
-
fetchRes.emit('error', err);
|
|
361
|
-
return;
|
|
335
|
+
return fail(err);
|
|
362
336
|
}
|
|
363
337
|
}
|
|
364
338
|
req.end();
|
|
@@ -366,4 +340,5 @@ function nmfetch(url, options) {
|
|
|
366
340
|
return fetchRes;
|
|
367
341
|
}
|
|
368
342
|
nmfetch.Cookies = Cookies;
|
|
343
|
+
nmfetch.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
|
369
344
|
export default nmfetch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '../shared/index.js';
|
|
2
2
|
import type { MimeNodeEnvelope } from '../mime-node/index.js';
|
|
3
|
-
import type
|
|
3
|
+
import type MailMessage from '../mailer/mail-message.js';
|
|
4
4
|
import type { default as Mail, SentMessageInfo, SendMailOptions, TransportOptions } from '../mailer/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Options for the JSON transport
|
|
@@ -12,16 +12,23 @@ export interface JSONTransportOptions extends TransportOptions {
|
|
|
12
12
|
skipEncoding?: boolean | undefined;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* The value the JSON transport hands to the send callback
|
|
15
|
+
* The value the JSON transport hands to the send callback. M is the type of the message
|
|
16
|
+
* field: a JSON string by default, the message object itself when skipEncoding is set
|
|
16
17
|
*/
|
|
17
|
-
export interface JSONSentMessageInfo extends SentMessageInfo {
|
|
18
|
+
export interface JSONSentMessageInfo<M = string> extends SentMessageInfo {
|
|
18
19
|
/** The envelope the message was generated with */
|
|
19
20
|
envelope: MimeNodeEnvelope;
|
|
20
21
|
/** Message-ID value of the message */
|
|
21
22
|
messageId: string;
|
|
22
23
|
/** The normalized message as a JSON string, or as the object itself when skipEncoding is set */
|
|
23
|
-
message:
|
|
24
|
+
message: M;
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The value the JSON transport hands to the send callback when skipEncoding is set: the
|
|
28
|
+
* message field holds the message object. Typed loosely so that a transporter created with
|
|
29
|
+
* skipEncoding still fits a variable declared with the plain result type
|
|
30
|
+
*/
|
|
31
|
+
export type JSONSentMessageObjectInfo = JSONSentMessageInfo<any>;
|
|
25
32
|
/**
|
|
26
33
|
* Generates a Transport object to generate JSON output
|
|
27
34
|
*
|
|
@@ -50,5 +57,8 @@ declare namespace JSONTransport {
|
|
|
50
57
|
type Options = JSONTransportOptions;
|
|
51
58
|
type MailOptions = SendMailOptions;
|
|
52
59
|
type SentMessageInfo = JSONSentMessageInfo;
|
|
60
|
+
type SentMessageObjectInfo = JSONSentMessageObjectInfo;
|
|
53
61
|
}
|
|
62
|
+
/** The same aliases as module level exports, for `import * as JSONTransport` and `import JSONTransport = require()` */
|
|
63
|
+
export type { JSONTransportOptions as Options, SendMailOptions as MailOptions, JSONSentMessageInfo as SentMessageInfo, JSONSentMessageObjectInfo as SentMessageObjectInfo };
|
|
54
64
|
export default JSONTransport;
|
|
@@ -48,6 +48,8 @@ class JSONTransport {
|
|
|
48
48
|
}
|
|
49
49
|
delete data.envelope;
|
|
50
50
|
delete data.normalizedHeaders;
|
|
51
|
+
// the message field is the object itself with skipEncoding, the
|
|
52
|
+
// createTransport overload for that option types the result accordingly
|
|
51
53
|
return done(null, {
|
|
52
54
|
envelope,
|
|
53
55
|
messageId,
|
|
@@ -72,6 +72,11 @@ export type MailComposerListHeaderEntry = string | {
|
|
|
72
72
|
export interface MailComposerListHeaders {
|
|
73
73
|
[key: string]: MailComposerListHeaderEntry | (MailComposerListHeaderEntry | MailComposerListHeaderEntry[])[];
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Encoding for the non-ascii header values: quoted-printable ('Q', the default) or base64
|
|
77
|
+
* ('B'). Only the first letter is read, so the short forms work as well
|
|
78
|
+
*/
|
|
79
|
+
export type MailComposerTextEncoding = 'quoted-printable' | 'base64' | 'Q' | 'B';
|
|
75
80
|
/**
|
|
76
81
|
* Mail options, the message data MailComposer builds the MIME tree from. The address
|
|
77
82
|
* fields, subject, messageId, date, inReplyTo and references become headers of the root
|
|
@@ -114,7 +119,7 @@ export interface MailComposerOptions {
|
|
|
114
119
|
/** Content-Transfer-Encoding to force for the text/* nodes that do not set their own */
|
|
115
120
|
encoding?: string | undefined;
|
|
116
121
|
/** Header string encoding, 'Q' (the default) or 'B', 'quoted-printable' and 'base64' are accepted as well */
|
|
117
|
-
textEncoding?:
|
|
122
|
+
textEncoding?: MailComposerTextEncoding | undefined;
|
|
118
123
|
/** Pregenerated rfc822 message, used as is instead of building one */
|
|
119
124
|
raw?: MimeNodeContent | undefined;
|
|
120
125
|
/** Reject content that points to a URL */
|
|
@@ -129,8 +134,6 @@ export interface MailComposerOptions {
|
|
|
129
134
|
baseBoundary?: string | undefined;
|
|
130
135
|
/** 'win' for CRLF and 'linux' for LF line breaks in the generated message, kept as is when not set */
|
|
131
136
|
newline?: string | undefined;
|
|
132
|
-
/** Keep the Bcc header in the generated message, listed for completeness, the transports set it on the message directly */
|
|
133
|
-
keepBcc?: boolean | undefined;
|
|
134
137
|
/** Method to normalize header keys for custom caseing */
|
|
135
138
|
normalizeHeaderKey?: MimeNodeOptions['normalizeHeaderKey'] | undefined;
|
|
136
139
|
/** 'high', 'normal' or 'low', sets the priority headers, read by the mailer */
|
|
@@ -166,4 +169,6 @@ declare class MailComposer {
|
|
|
166
169
|
declare namespace MailComposer {
|
|
167
170
|
type Options = MailComposerOptions;
|
|
168
171
|
}
|
|
172
|
+
/** The same alias as a module level export, for `import * as MailComposer` and `import MailComposer = require()` */
|
|
173
|
+
export type { MailComposerOptions as Options };
|
|
169
174
|
export default MailComposer;
|
|
@@ -4,8 +4,8 @@ import DKIM, { type DKIMOptions } from '../dkim/index.js';
|
|
|
4
4
|
import MailMessage, { type MailDefaults, type SendMailOptions } from './mail-message.js';
|
|
5
5
|
import net from 'node:net';
|
|
6
6
|
import type { ConnectionOptions } from 'node:tls';
|
|
7
|
-
import type { MailComposerAlternative, MailComposerAttachment, MailComposerIcalEvent, MailComposerListHeaderEntry, MailComposerListHeaders } from '../mail-composer/index.js';
|
|
8
|
-
import type { NodemailerError, ResultCallback } from '../errors.js';
|
|
7
|
+
import type { MailComposerAlternative, MailComposerAttachment, MailComposerIcalEvent, MailComposerListHeaderEntry, MailComposerListHeaders, MailComposerTextEncoding } from '../mail-composer/index.js';
|
|
8
|
+
import type { Callback, NodemailerError, ResultCallback } from '../errors.js';
|
|
9
9
|
import type { ParsedUrl } from '../shared/url.js';
|
|
10
10
|
import type { MimeNodeAddress, MimeNodeEnvelope, MimeNodeEnvelopeInput, MimeNodeHeaders, MimeNodeOptions } from '../mime-node/index.js';
|
|
11
11
|
import type { XOAuth2ProvisionCallback } from '../xoauth2/index.js';
|
|
@@ -15,9 +15,10 @@ export type { default as MailMessage } from './mail-message.js';
|
|
|
15
15
|
* The base shape of the object a transport hands back for a sent message. Every bundled
|
|
16
16
|
* transport sets the envelope and the Message-ID, the rest depends on the transport.
|
|
17
17
|
*
|
|
18
|
-
* The index signature keeps a transport specific field readable through this type,
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* The index signature keeps a transport specific field readable through this type, the way
|
|
19
|
+
* the `any` typed result of @types/nodemailer was, and it is also what a result type has
|
|
20
|
+
* to inherit to stay assignable to it, so the result type of a transport outside this
|
|
21
|
+
* package has to extend this interface rather than restate it
|
|
21
22
|
*/
|
|
22
23
|
export interface SentMessageInfo {
|
|
23
24
|
/** The envelope the message was sent with */
|
|
@@ -33,9 +34,9 @@ export interface SentMessageInfo {
|
|
|
33
34
|
/** Last response from the server */
|
|
34
35
|
response?: string | undefined;
|
|
35
36
|
/** The generated message, for the transports that hand it back instead of sending it */
|
|
36
|
-
message?:
|
|
37
|
+
message?: any;
|
|
37
38
|
/** Transport specific fields */
|
|
38
|
-
[key: string]:
|
|
39
|
+
[key: string]: any;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Callback for sendMail, receives the transport result once the transport has taken the
|
|
@@ -43,9 +44,11 @@ export interface SentMessageInfo {
|
|
|
43
44
|
*/
|
|
44
45
|
export type SendMailCallback<T = SentMessageInfo> = (err: NodemailerError | null, info: T) => void;
|
|
45
46
|
/**
|
|
46
|
-
* Callback for verify(), success is true once the transport accepted the configuration
|
|
47
|
+
* Callback for verify(), success is true once the transport accepted the configuration.
|
|
48
|
+
* Declared with a required success value, the way @types/nodemailer declared it, the
|
|
49
|
+
* error path hands over the error alone
|
|
47
50
|
*/
|
|
48
|
-
export type VerifyCallback =
|
|
51
|
+
export type VerifyCallback = Callback<true>;
|
|
49
52
|
/**
|
|
50
53
|
* Callback a plugin calls once it is done, an error aborts the send
|
|
51
54
|
*/
|
|
@@ -60,21 +63,23 @@ export type PluginFunction<T = SentMessageInfo> = (mail: MailMessage<T>, callbac
|
|
|
60
63
|
*/
|
|
61
64
|
export interface GetSocketOptions {
|
|
62
65
|
host?: string | undefined;
|
|
63
|
-
port?: number |
|
|
66
|
+
port?: number | undefined;
|
|
64
67
|
[key: string]: any;
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
|
-
* The result of a getSocket handler, the socket to use for the connection
|
|
70
|
+
* The result of a getSocket handler, the socket to use for the connection. The object is
|
|
71
|
+
* merged into the connection options, so it may carry any of those as well
|
|
68
72
|
*/
|
|
69
73
|
export interface SocketOptions {
|
|
70
74
|
/** An established socket, the proxied connection */
|
|
71
75
|
connection?: net.Socket | undefined;
|
|
76
|
+
[key: string]: any;
|
|
72
77
|
}
|
|
73
78
|
/**
|
|
74
|
-
* Receives the socket options from a getSocket handler,
|
|
75
|
-
* connection
|
|
79
|
+
* Receives the socket options from a getSocket handler, false when a new socket should be
|
|
80
|
+
* opened, or the error that prevented the connection
|
|
76
81
|
*/
|
|
77
|
-
export type GetSocketCallback = (err:
|
|
82
|
+
export type GetSocketCallback = (err: Error | null, socketOptions?: SocketOptions | false) => void;
|
|
78
83
|
/**
|
|
79
84
|
* A socket handler. Mail sets one on the transport as getSocket when a proxy is configured,
|
|
80
85
|
* the SMTP transports call it to get a proxied socket instead of connecting directly
|
|
@@ -101,9 +106,12 @@ export interface MailMeta {
|
|
|
101
106
|
/**
|
|
102
107
|
* A transport as consumed by Mail: any object with a name, a version and a send method
|
|
103
108
|
* works, the rest is optional. Mail forwards its close, isIdle and verify calls to the
|
|
104
|
-
* methods of the same name as they are, so their arguments are up to the transport
|
|
109
|
+
* methods of the same name as they are, so their arguments are up to the transport.
|
|
110
|
+
*
|
|
111
|
+
* D is the options type of the transport, the second type parameter @types/nodemailer
|
|
112
|
+
* declared on Transport, Transporter and Mail
|
|
105
113
|
*/
|
|
106
|
-
export interface Transport<T = SentMessageInfo> {
|
|
114
|
+
export interface Transport<T = SentMessageInfo, D extends TransportOptions = TransportOptions> {
|
|
107
115
|
/** Transport name, used for logging */
|
|
108
116
|
name: string;
|
|
109
117
|
/** Transport version, used for logging */
|
|
@@ -119,7 +127,7 @@ export interface Transport<T = SentMessageInfo> {
|
|
|
119
127
|
/** Registers an event listener, the transport may emit 'log', 'error', 'idle' and 'clear' */
|
|
120
128
|
on?(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
121
129
|
/** The Mail object the transport belongs to, set by Mail */
|
|
122
|
-
mailer?: Mail<T> | undefined;
|
|
130
|
+
mailer?: Mail<T, D> | undefined;
|
|
123
131
|
/** Socket handler for a proxied connection, set by Mail when a proxy is configured */
|
|
124
132
|
getSocket?: GetSocketHandler | undefined;
|
|
125
133
|
}
|
|
@@ -150,22 +158,23 @@ export interface TransportOptions {
|
|
|
150
158
|
attachDataUrls?: boolean | undefined;
|
|
151
159
|
}
|
|
152
160
|
/**
|
|
153
|
-
* The transporter object createTransport returns, a Mail instance wrapping a transport
|
|
161
|
+
* The transporter object createTransport returns, a Mail instance wrapping a transport. D
|
|
162
|
+
* is the options type of the transport, it types the options field of the transporter
|
|
154
163
|
*/
|
|
155
|
-
export type Transporter<T = SentMessageInfo> = Mail<T>;
|
|
164
|
+
export type Transporter<T = SentMessageInfo, D extends TransportOptions = TransportOptions> = Mail<T, D>;
|
|
156
165
|
/**
|
|
157
166
|
* Creates an object for exposing the Mail API
|
|
158
167
|
*
|
|
159
168
|
* @constructor
|
|
160
169
|
* @param transporter Transport object instance to pass the mails to
|
|
161
170
|
*/
|
|
162
|
-
declare class Mail<out T = SentMessageInfo> extends EventEmitter {
|
|
163
|
-
options:
|
|
171
|
+
declare class Mail<out T = SentMessageInfo, out D extends TransportOptions = TransportOptions> extends EventEmitter {
|
|
172
|
+
options: D;
|
|
164
173
|
/** Message defaults given to createTransport, kept public because the DefinitelyTyped typings declared it */
|
|
165
174
|
_defaults: MailDefaults;
|
|
166
175
|
meta: Map<string, any>;
|
|
167
176
|
dkim: DKIM | false;
|
|
168
|
-
transporter: Transport<T>;
|
|
177
|
+
transporter: Transport<T, D>;
|
|
169
178
|
logger: shared.Logger;
|
|
170
179
|
/** Closes the transport, the pooled SMTP transport closes its connections */
|
|
171
180
|
close: () => void;
|
|
@@ -178,15 +187,21 @@ declare class Mail<out T = SentMessageInfo> extends EventEmitter {
|
|
|
178
187
|
};
|
|
179
188
|
/** Socket handler for a proxied connection, set by setupProxy and handed to the transport on the next send */
|
|
180
189
|
getSocket?: GetSocketHandler | false | undefined;
|
|
181
|
-
constructor(transporter: Transport<T>, options?:
|
|
190
|
+
constructor(transporter: Transport<T, D>, options?: D, defaults?: MailDefaults);
|
|
182
191
|
use(step: string, plugin: PluginFunction<T>): this;
|
|
183
192
|
/**
|
|
184
193
|
* Sends an email using the preselected transport object
|
|
185
194
|
*
|
|
186
195
|
* @param data E-data description
|
|
187
|
-
* @
|
|
196
|
+
* @returns Promise that resolves with the result of the send
|
|
188
197
|
*/
|
|
189
198
|
sendMail(data: SendMailOptions): Promise<T>;
|
|
199
|
+
/**
|
|
200
|
+
* Sends an email using the preselected transport object
|
|
201
|
+
*
|
|
202
|
+
* @param data E-data description
|
|
203
|
+
* @param callback Callback to run once the sending succeeded or failed
|
|
204
|
+
*/
|
|
190
205
|
sendMail(data: SendMailOptions, callback: SendMailCallback<T>): void;
|
|
191
206
|
getVersionString(): string;
|
|
192
207
|
/**
|
|
@@ -213,7 +228,10 @@ declare namespace Mail {
|
|
|
213
228
|
type ListHeader = MailComposerListHeaderEntry;
|
|
214
229
|
type ListHeaders = MailComposerListHeaders;
|
|
215
230
|
type Envelope = MimeNodeEnvelopeInput;
|
|
216
|
-
type
|
|
231
|
+
type Connection = SocketOptions;
|
|
232
|
+
type TextEncoding = MailComposerTextEncoding;
|
|
217
233
|
type PluginFunction<T = SentMessageInfo> = MailPluginFunction<T>;
|
|
218
234
|
}
|
|
235
|
+
/** The same aliases as module level exports, for `import * as Mail` and `import Mail = require()` */
|
|
236
|
+
export type { SendMailOptions as Options, MimeNodeAddress as Address, MailComposerAttachment as Attachment, MailComposerAlternative as AttachmentLike, MailComposerAlternative as AmpAttachment, MailComposerIcalEvent as IcalAttachment, MimeNodeHeaders as Headers, MailComposerListHeaderEntry as ListHeader, MailComposerListHeaders as ListHeaders, MimeNodeEnvelopeInput as Envelope, SocketOptions as Connection, MailComposerTextEncoding as TextEncoding };
|
|
219
237
|
export default Mail;
|
|
@@ -3,6 +3,7 @@ import type { MailComposerOptions } from '../mail-composer/index.js';
|
|
|
3
3
|
import type { DKIMOptions } from '../dkim/index.js';
|
|
4
4
|
import type { SMTPEnvelopeDsn } from '../smtp-connection/index.js';
|
|
5
5
|
import type { SMTPTransportAuthOptions } from '../smtp-transport/index.js';
|
|
6
|
+
import type { SESSendEmailRequest } from '../ses-transport/index.js';
|
|
6
7
|
import type { NodemailerError } from '../errors.js';
|
|
7
8
|
import type { ResolveContentOptions } from '../shared/index.js';
|
|
8
9
|
import type Mail from './index.js';
|
|
@@ -14,6 +15,8 @@ import type { SentMessageInfo } from './index.js';
|
|
|
14
15
|
export interface SendMailOptions extends MailComposerOptions {
|
|
15
16
|
/** DKIM signing options for this message, used instead of the ones of the transporter */
|
|
16
17
|
dkim?: DKIMOptions | undefined;
|
|
18
|
+
/** Extra DKIM options for this message, merged over the options of the signer. The SES transport sets skipFields here, the option is not meant for callers */
|
|
19
|
+
_dkim?: DKIMOptions | undefined;
|
|
17
20
|
/** Recipients allowed on this message, 0 disables the limit, defaults to 100000 */
|
|
18
21
|
maxRecipients?: number | undefined;
|
|
19
22
|
/** SMTP transports: DSN parameters for the envelope, sent when the server supports the DSN extension */
|
|
@@ -23,9 +26,7 @@ export interface SendMailOptions extends MailComposerOptions {
|
|
|
23
26
|
/** SMTP transports: per-message authentication settings, used instead of the transport level auth */
|
|
24
27
|
auth?: SMTPTransportAuthOptions | undefined;
|
|
25
28
|
/** SES transport: extra SendEmailCommand parameters merged into the API call */
|
|
26
|
-
ses?:
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
} | undefined;
|
|
29
|
+
ses?: SESSendEmailRequest | undefined;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Default message fields, the third argument of createTransport. Applied to every message
|
|
@@ -71,7 +72,13 @@ export interface MailMessageListHeader {
|
|
|
71
72
|
export default class MailMessage<T = SentMessageInfo> {
|
|
72
73
|
mailer: Mail<T>;
|
|
73
74
|
data: MailMessageData;
|
|
74
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The compiled MIME tree. Set once the compile step is done, so it is null while the
|
|
77
|
+
* 'compile' plugins run and set by the time the 'stream' plugins and the transport see
|
|
78
|
+
* the message. Declared as always set, the way @types/nodemailer declared it, since the
|
|
79
|
+
* plugins that read it are the ones that run after it is set
|
|
80
|
+
*/
|
|
81
|
+
message: MimeNode;
|
|
75
82
|
constructor(mailer: Mail<T>, data?: SendMailOptions);
|
|
76
83
|
resolveContent(data: {
|
|
77
84
|
[key: string]: any;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* A header value split into the value token and its parameters, the result of parseHeaderValue
|
|
3
3
|
*/
|
|
4
4
|
export interface ParsedHeaderValue {
|
|
5
|
-
/** The value ahead of the parameters, for example the content type */
|
|
6
|
-
value: string
|
|
5
|
+
/** The value ahead of the parameters, for example the content type, an empty string when there is none */
|
|
6
|
+
value: string;
|
|
7
7
|
/** Parameter values keyed by lowercase parameter name */
|
|
8
8
|
params: Record<string, string>;
|
|
9
9
|
}
|
|
@@ -25,6 +25,9 @@ export interface EncodedHeaderParam {
|
|
|
25
25
|
/** Parameter value of this part */
|
|
26
26
|
value: string;
|
|
27
27
|
}
|
|
28
|
+
/** The names @types/nodemailer used for the two types above */
|
|
29
|
+
export type HeaderValue = StructuredHeaderValue;
|
|
30
|
+
export type ParsedHeaderParam = EncodedHeaderParam;
|
|
28
31
|
/**
|
|
29
32
|
* Checks if a value is plaintext string (uses only printable 7bit chars)
|
|
30
33
|
*
|
|
@@ -56,6 +59,7 @@ export declare function quoteString(value?: string): string;
|
|
|
56
59
|
* no need to encode the values in any way. If the value is plaintext but has
|
|
57
60
|
* longer lines then allowed, then use format=flowed
|
|
58
61
|
*
|
|
62
|
+
* @param str Multi line string to check
|
|
59
63
|
* @param lineLength Max line length to check for
|
|
60
64
|
* @returns Returns true if there is at least one line longer than lineLength chars
|
|
61
65
|
*/
|
|
@@ -97,9 +101,9 @@ export declare function buildHeaderValue(structured: StructuredHeaderValue): str
|
|
|
97
101
|
* title*0*=utf-8''unicode
|
|
98
102
|
* title*1*=%20string
|
|
99
103
|
*
|
|
104
|
+
* @param key Parameter name the generated keys are built from, for example title
|
|
100
105
|
* @param data String to be encoded
|
|
101
106
|
* @param [maxLength=50] Max length for generated chunks
|
|
102
|
-
* @param [fromCharset='UTF-8'] Source sharacter set
|
|
103
107
|
* @return A list of encoded keys and headers
|
|
104
108
|
*/
|
|
105
109
|
export declare function buildHeaderParam(key: string, data: string | Buffer, maxLength?: number): EncodedHeaderParam[];
|