emailjs 3.8.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -276,7 +276,7 @@ const RANGES = [
276
276
  [0x0a],
277
277
  [0x0d],
278
278
  [0x20, 0x3c],
279
- [0x3e, 0x7e],
279
+ [0x3e, 0x7e], // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
280
280
  ];
281
281
  const LOOKUP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
282
282
  const MAX_CHUNK_LENGTH = 16383; // must be multiple of 3
@@ -883,7 +883,8 @@ class MessageStream extends Stream {
883
883
  const outputData = (attachment, callback) => {
884
884
  var _a, _b;
885
885
  outputBase64(attachment.encoded
886
- ? (_a = attachment.data) !== null && _a !== void 0 ? _a : '' : Buffer.from((_b = attachment.data) !== null && _b !== void 0 ? _b : '').toString('base64'), callback);
886
+ ? (_a = attachment.data) !== null && _a !== void 0 ? _a : ''
887
+ : Buffer.from((_b = attachment.data) !== null && _b !== void 0 ? _b : '').toString('base64'), callback);
887
888
  };
888
889
  /**
889
890
  * @param {Message} message the message to output
@@ -1852,8 +1853,9 @@ class SMTPClient {
1852
1853
  }
1853
1854
  /**
1854
1855
  * @public
1855
- * @param {Message} msg the message to send
1856
- * @param {MessageCallback} callback .
1856
+ * @template {Message | MessageHeaders} T
1857
+ * @param {T} msg the message to send
1858
+ * @param {MessageCallback<T>} callback receiver for the error (if any) as well as the passed-in message / headers
1857
1859
  * @returns {void}
1858
1860
  */
1859
1861
  send(msg, callback) {
@@ -1881,8 +1883,9 @@ class SMTPClient {
1881
1883
  }
1882
1884
  /**
1883
1885
  * @public
1884
- * @param {Message} msg the message to send
1885
- * @returns {Promise<Message>} a promise that resolves to the fully processed message
1886
+ * @template {Message | MessageHeaders} T
1887
+ * @param {T} msg the message to send
1888
+ * @returns {Promise<T>} a promise that resolves to the passed-in message / headers
1886
1889
  */
1887
1890
  sendAsync(msg) {
1888
1891
  return new Promise((resolve, reject) => {
@@ -2119,4 +2122,4 @@ class SMTPClient {
2119
2122
  }
2120
2123
 
2121
2124
  export { AUTH_METHODS, BUFFERSIZE, DEFAULT_TIMEOUT, MIME64CHUNK, MIMECHUNK, Message, SMTPClient, SMTPConnection, SMTPError, SMTPErrorStates, SMTPResponseMonitor, SMTPState, addressparser, getRFC2822Date, getRFC2822DateUTC, isRFC2822Date, mimeEncode, mimeWordEncode };
2122
- //# sourceMappingURL=email.mjs.map
2125
+ //# sourceMappingURL=email.js.map
package/email.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './smtp/address';
2
- export * from './smtp/client';
3
- export * from './smtp/connection';
4
- export * from './smtp/date';
5
- export * from './smtp/error';
6
- export * from './smtp/message';
7
- export * from './smtp/mime';
8
- export * from './smtp/response';
1
+ export * from './smtp/address.js';
2
+ export * from './smtp/client.js';
3
+ export * from './smtp/connection.js';
4
+ export * from './smtp/date.js';
5
+ export * from './smtp/error.js';
6
+ export * from './smtp/message.js';
7
+ export * from './smtp/mime.js';
8
+ export * from './smtp/response.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "emailjs",
3
3
  "description": "send text/html emails and attachments (files, streams and strings) from node.js to any smtp server",
4
- "version": "3.8.1",
4
+ "version": "4.0.0",
5
5
  "author": "eleith",
6
6
  "contributors": [
7
7
  "izuzak",
@@ -17,26 +17,26 @@
17
17
  "type": "module",
18
18
  "devDependencies": {
19
19
  "@ledge/configs": "23.3.23322",
20
- "@rollup/plugin-typescript": "8.3.1",
20
+ "@rollup/plugin-typescript": "8.3.2",
21
21
  "@types/mailparser": "3.4.0",
22
- "@types/node": "17.0.21",
22
+ "@types/node": "12.12.6",
23
23
  "@types/smtp-server": "3.5.7",
24
- "@typescript-eslint/eslint-plugin": "5.15.0",
25
- "@typescript-eslint/parser": "5.15.0",
26
- "ava": "3.15.0",
27
- "eslint": "7.32.0",
24
+ "@typescript-eslint/eslint-plugin": "5.19.0",
25
+ "@typescript-eslint/parser": "5.19.0",
26
+ "ava": "4.2.0",
27
+ "eslint": "8.13.0",
28
28
  "eslint-config-prettier": "8.5.0",
29
29
  "eslint-plugin-prettier": "4.0.0",
30
30
  "mailparser": "3.4.0",
31
- "prettier": "2.6.0",
31
+ "prettier": "2.6.2",
32
32
  "rollup": "2.70.1",
33
33
  "smtp-server": "3.10.0",
34
34
  "ts-node": "10.7.0",
35
35
  "tslib": "2.3.1",
36
- "typescript": "3.8.3"
36
+ "typescript": "4.3.5"
37
37
  },
38
38
  "peerDependencies": {
39
- "typescript": ">=3.8.3"
39
+ "typescript": ">=4.3.5"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "typescript": {
@@ -44,28 +44,25 @@
44
44
  }
45
45
  },
46
46
  "resolutions": {
47
- "nodemailer": "6.7.2"
47
+ "nodemailer": "6.7.3"
48
48
  },
49
49
  "engines": {
50
- "node": ">=10"
50
+ "node": ">=12"
51
51
  },
52
52
  "files": [
53
+ "email.js",
53
54
  "email.ts",
54
- "smtp",
55
- "rollup"
55
+ "smtp"
56
56
  ],
57
- "main": "./rollup/email.cjs",
58
57
  "types": "./email.ts",
59
58
  "exports": {
60
- "import": "./rollup/email.mjs",
61
- "require": "./rollup/email.cjs"
59
+ "default": "./email.js"
62
60
  },
63
61
  "scripts": {
64
62
  "build": "rollup -c rollup.config.ts",
65
63
  "lint": "eslint *.ts \"+(smtp|test)/*.ts\"",
66
- "test": "ava",
67
- "pretest-cjs": "npm run build",
68
- "test-cjs": "npm run test -- --node-arguments='--title=cjs'"
64
+ "pretest": "yarn build",
65
+ "test": "ava"
69
66
  },
70
67
  "license": "MIT"
71
68
  }
package/smtp/client.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { addressparser } from './address';
2
- import type { MessageAttachment, MessageHeaders } from './message';
3
- import { Message } from './message';
4
- import type { SMTPConnectionOptions } from './connection';
5
- import { SMTPConnection, SMTPState } from './connection';
1
+ import { addressparser } from './address.js';
2
+ import type { MessageAttachment, MessageHeaders } from './message.js';
3
+ import { Message } from './message.js';
4
+ import type { SMTPConnectionOptions } from './connection.js';
5
+ import { SMTPConnection, SMTPState } from './connection.js';
6
6
 
7
7
  export type MessageCallback<T = Message | MessageHeaders> = <
8
8
  U extends Error | null,
@@ -45,14 +45,15 @@ export class SMTPClient {
45
45
 
46
46
  /**
47
47
  * @public
48
- * @param {Message} msg the message to send
49
- * @param {MessageCallback} callback .
48
+ * @template {Message | MessageHeaders} T
49
+ * @param {T} msg the message to send
50
+ * @param {MessageCallback<T>} callback receiver for the error (if any) as well as the passed-in message / headers
50
51
  * @returns {void}
51
52
  */
52
- public send(
53
- msg: Message | MessageHeaders,
54
- callback: MessageCallback<Message | MessageHeaders>
55
- ) {
53
+ public send<T extends Message | MessageHeaders>(
54
+ msg: T,
55
+ callback: MessageCallback<T>
56
+ ): void {
56
57
  const message =
57
58
  msg instanceof Message
58
59
  ? msg
@@ -81,10 +82,11 @@ export class SMTPClient {
81
82
 
82
83
  /**
83
84
  * @public
84
- * @param {Message} msg the message to send
85
- * @returns {Promise<Message>} a promise that resolves to the fully processed message
85
+ * @template {Message | MessageHeaders} T
86
+ * @param {T} msg the message to send
87
+ * @returns {Promise<T>} a promise that resolves to the passed-in message / headers
86
88
  */
87
- public sendAsync(msg: Message | MessageHeaders) {
89
+ public sendAsync<T extends Message | MessageHeaders>(msg: T) {
88
90
  return new Promise<Message>((resolve, reject) => {
89
91
  this.send(msg, (err, message) => {
90
92
  if (err != null) {
@@ -5,8 +5,8 @@ import { hostname } from 'os';
5
5
  import { connect, createSecureContext, TLSSocket } from 'tls';
6
6
  import type { ConnectionOptions } from 'tls';
7
7
 
8
- import { SMTPError, SMTPErrorStates } from './error';
9
- import { SMTPResponseMonitor } from './response';
8
+ import { SMTPError, SMTPErrorStates } from './error.js';
9
+ import { SMTPResponseMonitor } from './response.js';
10
10
 
11
11
  /**
12
12
  * @readonly
package/smtp/message.ts CHANGED
@@ -10,9 +10,9 @@ import { hostname } from 'os';
10
10
  import { Stream } from 'stream';
11
11
  import type { Readable } from 'stream';
12
12
 
13
- import { addressparser } from './address';
14
- import { getRFC2822Date } from './date';
15
- import { mimeWordEncode } from './mime';
13
+ import { addressparser } from './address.js';
14
+ import { getRFC2822Date } from './date.js';
15
+ import { mimeWordEncode } from './mime.js';
16
16
 
17
17
  const CRLF = '\r\n' as const;
18
18
 
package/smtp/response.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SMTPError, SMTPErrorStates } from './error';
1
+ import { SMTPError, SMTPErrorStates } from './error.js';
2
2
  import type { Socket } from 'net';
3
3
  import type { TLSSocket } from 'tls';
4
4