@bobfrankston/mailx 1.0.12 → 1.0.14

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.
Files changed (172) hide show
  1. package/bin/mailx.js +52 -28
  2. package/client/app.js +113 -30
  3. package/client/components/folder-tree.js +84 -3
  4. package/client/components/message-list.js +164 -10
  5. package/client/components/message-viewer.js +130 -13
  6. package/client/compose/compose.html +4 -4
  7. package/client/compose/compose.js +53 -34
  8. package/client/index.html +50 -21
  9. package/client/lib/api-client.js +112 -31
  10. package/client/lib/mailxapi.js +123 -0
  11. package/client/package.json +1 -1
  12. package/client/styles/components.css +206 -16
  13. package/client/styles/layout.css +2 -1
  14. package/killmail.cmd +6 -0
  15. package/launch.ps1 +47 -5
  16. package/launcher/bin/mailx-app-linux +0 -0
  17. package/launcher/bin/mailx-app.exe +0 -0
  18. package/launcher/builder/build-config.json +11 -0
  19. package/launcher/builder/postinstall.js +81 -0
  20. package/package.json +2 -4
  21. package/packages/mailx-api/index.js +125 -29
  22. package/packages/mailx-core/index.d.ts +129 -0
  23. package/packages/mailx-core/index.js +323 -0
  24. package/packages/mailx-core/ipc.d.ts +13 -0
  25. package/packages/mailx-core/ipc.js +56 -0
  26. package/packages/mailx-core/package.json +18 -0
  27. package/packages/mailx-imap/index.d.ts +7 -1
  28. package/packages/mailx-imap/index.js +89 -14
  29. package/packages/mailx-server/index.js +42 -31
  30. package/packages/mailx-server/package.json +1 -2
  31. package/packages/mailx-settings/index.d.ts +1 -1
  32. package/packages/mailx-settings/index.js +21 -12
  33. package/packages/mailx-store/db.d.ts +6 -2
  34. package/packages/mailx-store/db.js +78 -16
  35. package/packages/mailx-store/file-store.d.ts +2 -8
  36. package/packages/mailx-store/file-store.js +7 -31
  37. package/packages/mailx-types/index.d.ts +3 -1
  38. package/.tswalk.json +0 -7396
  39. package/launcher/release.cmd +0 -4
  40. package/mailx.json +0 -9
  41. package/packages/mailx-api/node_modules/nodemailer/.ncurc.js +0 -9
  42. package/packages/mailx-api/node_modules/nodemailer/.prettierignore +0 -8
  43. package/packages/mailx-api/node_modules/nodemailer/.prettierrc +0 -12
  44. package/packages/mailx-api/node_modules/nodemailer/.prettierrc.js +0 -10
  45. package/packages/mailx-api/node_modules/nodemailer/.release-please-config.json +0 -9
  46. package/packages/mailx-api/node_modules/nodemailer/LICENSE +0 -16
  47. package/packages/mailx-api/node_modules/nodemailer/README.md +0 -86
  48. package/packages/mailx-api/node_modules/nodemailer/SECURITY.txt +0 -22
  49. package/packages/mailx-api/node_modules/nodemailer/eslint.config.js +0 -88
  50. package/packages/mailx-api/node_modules/nodemailer/lib/addressparser/index.js +0 -383
  51. package/packages/mailx-api/node_modules/nodemailer/lib/base64/index.js +0 -139
  52. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/index.js +0 -253
  53. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  54. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  55. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  56. package/packages/mailx-api/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  57. package/packages/mailx-api/node_modules/nodemailer/lib/fetch/index.js +0 -280
  58. package/packages/mailx-api/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  59. package/packages/mailx-api/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
  60. package/packages/mailx-api/node_modules/nodemailer/lib/mailer/index.js +0 -441
  61. package/packages/mailx-api/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
  62. package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  63. package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
  64. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
  65. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
  66. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
  67. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
  68. package/packages/mailx-api/node_modules/nodemailer/lib/nodemailer.js +0 -157
  69. package/packages/mailx-api/node_modules/nodemailer/lib/punycode/index.js +0 -460
  70. package/packages/mailx-api/node_modules/nodemailer/lib/qp/index.js +0 -227
  71. package/packages/mailx-api/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  72. package/packages/mailx-api/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
  73. package/packages/mailx-api/node_modules/nodemailer/lib/shared/index.js +0 -754
  74. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  75. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  76. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
  77. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
  78. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
  79. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
  80. package/packages/mailx-api/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  81. package/packages/mailx-api/node_modules/nodemailer/lib/well-known/index.js +0 -47
  82. package/packages/mailx-api/node_modules/nodemailer/lib/well-known/services.json +0 -611
  83. package/packages/mailx-api/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
  84. package/packages/mailx-api/node_modules/nodemailer/package.json +0 -47
  85. package/packages/mailx-imap/node_modules/nodemailer/.ncurc.js +0 -9
  86. package/packages/mailx-imap/node_modules/nodemailer/.prettierignore +0 -8
  87. package/packages/mailx-imap/node_modules/nodemailer/.prettierrc +0 -12
  88. package/packages/mailx-imap/node_modules/nodemailer/.prettierrc.js +0 -10
  89. package/packages/mailx-imap/node_modules/nodemailer/.release-please-config.json +0 -9
  90. package/packages/mailx-imap/node_modules/nodemailer/LICENSE +0 -16
  91. package/packages/mailx-imap/node_modules/nodemailer/README.md +0 -86
  92. package/packages/mailx-imap/node_modules/nodemailer/SECURITY.txt +0 -22
  93. package/packages/mailx-imap/node_modules/nodemailer/eslint.config.js +0 -88
  94. package/packages/mailx-imap/node_modules/nodemailer/lib/addressparser/index.js +0 -383
  95. package/packages/mailx-imap/node_modules/nodemailer/lib/base64/index.js +0 -139
  96. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/index.js +0 -253
  97. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  98. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  99. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  100. package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  101. package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/index.js +0 -280
  102. package/packages/mailx-imap/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  103. package/packages/mailx-imap/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
  104. package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/index.js +0 -441
  105. package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
  106. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  107. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
  108. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
  109. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
  110. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
  111. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
  112. package/packages/mailx-imap/node_modules/nodemailer/lib/nodemailer.js +0 -157
  113. package/packages/mailx-imap/node_modules/nodemailer/lib/punycode/index.js +0 -460
  114. package/packages/mailx-imap/node_modules/nodemailer/lib/qp/index.js +0 -227
  115. package/packages/mailx-imap/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  116. package/packages/mailx-imap/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
  117. package/packages/mailx-imap/node_modules/nodemailer/lib/shared/index.js +0 -754
  118. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  119. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  120. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
  121. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
  122. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
  123. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
  124. package/packages/mailx-imap/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  125. package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/index.js +0 -47
  126. package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/services.json +0 -611
  127. package/packages/mailx-imap/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
  128. package/packages/mailx-imap/node_modules/nodemailer/package.json +0 -47
  129. package/packages/mailx-send/node_modules/nodemailer/.ncurc.js +0 -9
  130. package/packages/mailx-send/node_modules/nodemailer/.prettierignore +0 -8
  131. package/packages/mailx-send/node_modules/nodemailer/.prettierrc +0 -12
  132. package/packages/mailx-send/node_modules/nodemailer/.prettierrc.js +0 -10
  133. package/packages/mailx-send/node_modules/nodemailer/.release-please-config.json +0 -9
  134. package/packages/mailx-send/node_modules/nodemailer/LICENSE +0 -16
  135. package/packages/mailx-send/node_modules/nodemailer/README.md +0 -86
  136. package/packages/mailx-send/node_modules/nodemailer/SECURITY.txt +0 -22
  137. package/packages/mailx-send/node_modules/nodemailer/eslint.config.js +0 -88
  138. package/packages/mailx-send/node_modules/nodemailer/lib/addressparser/index.js +0 -383
  139. package/packages/mailx-send/node_modules/nodemailer/lib/base64/index.js +0 -139
  140. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/index.js +0 -253
  141. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  142. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  143. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  144. package/packages/mailx-send/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  145. package/packages/mailx-send/node_modules/nodemailer/lib/fetch/index.js +0 -280
  146. package/packages/mailx-send/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  147. package/packages/mailx-send/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
  148. package/packages/mailx-send/node_modules/nodemailer/lib/mailer/index.js +0 -441
  149. package/packages/mailx-send/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
  150. package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  151. package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
  152. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
  153. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
  154. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
  155. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
  156. package/packages/mailx-send/node_modules/nodemailer/lib/nodemailer.js +0 -157
  157. package/packages/mailx-send/node_modules/nodemailer/lib/punycode/index.js +0 -460
  158. package/packages/mailx-send/node_modules/nodemailer/lib/qp/index.js +0 -227
  159. package/packages/mailx-send/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  160. package/packages/mailx-send/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
  161. package/packages/mailx-send/node_modules/nodemailer/lib/shared/index.js +0 -754
  162. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  163. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  164. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
  165. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
  166. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
  167. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
  168. package/packages/mailx-send/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  169. package/packages/mailx-send/node_modules/nodemailer/lib/well-known/index.js +0 -47
  170. package/packages/mailx-send/node_modules/nodemailer/lib/well-known/services.json +0 -611
  171. package/packages/mailx-send/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
  172. package/packages/mailx-send/node_modules/nodemailer/package.json +0 -47
@@ -1,427 +0,0 @@
1
- 'use strict';
2
-
3
- const Stream = require('stream').Stream;
4
- const nmfetch = require('../fetch');
5
- const crypto = require('crypto');
6
- const shared = require('../shared');
7
-
8
- /**
9
- * XOAUTH2 access_token generator for Gmail.
10
- * Create client ID for web applications in Google API console to use it.
11
- * See Offline Access for receiving the needed refreshToken for an user
12
- * https://developers.google.com/accounts/docs/OAuth2WebServer#offline
13
- *
14
- * Usage for generating access tokens with a custom method using provisionCallback:
15
- * provisionCallback(user, renew, callback)
16
- * * user is the username to get the token for
17
- * * renew is a boolean that if true indicates that existing token failed and needs to be renewed
18
- * * callback is the callback to run with (error, accessToken [, expires])
19
- * * accessToken is a string
20
- * * expires is an optional expire time in milliseconds
21
- * If provisionCallback is used, then Nodemailer does not try to attempt generating the token by itself
22
- *
23
- * @constructor
24
- * @param {Object} options Client information for token generation
25
- * @param {String} options.user User e-mail address
26
- * @param {String} options.clientId Client ID value
27
- * @param {String} options.clientSecret Client secret value
28
- * @param {String} options.refreshToken Refresh token for an user
29
- * @param {String} options.accessUrl Endpoint for token generation, defaults to 'https://accounts.google.com/o/oauth2/token'
30
- * @param {String} options.accessToken An existing valid accessToken
31
- * @param {String} options.privateKey Private key for JSW
32
- * @param {Number} options.expires Optional Access Token expire time in ms
33
- * @param {Number} options.timeout Optional TTL for Access Token in seconds
34
- * @param {Function} options.provisionCallback Function to run when a new access token is required
35
- */
36
- class XOAuth2 extends Stream {
37
- constructor(options, logger) {
38
- super();
39
-
40
- this.options = options || {};
41
-
42
- if (options && options.serviceClient) {
43
- if (!options.privateKey || !options.user) {
44
- setImmediate(() => this.emit('error', new Error('Options "privateKey" and "user" are required for service account!')));
45
- return;
46
- }
47
-
48
- let serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600);
49
- this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60;
50
- }
51
-
52
- this.logger = shared.getLogger(
53
- {
54
- logger
55
- },
56
- {
57
- component: this.options.component || 'OAuth2'
58
- }
59
- );
60
-
61
- this.provisionCallback = typeof this.options.provisionCallback === 'function' ? this.options.provisionCallback : false;
62
-
63
- this.options.accessUrl = this.options.accessUrl || 'https://accounts.google.com/o/oauth2/token';
64
- this.options.customHeaders = this.options.customHeaders || {};
65
- this.options.customParams = this.options.customParams || {};
66
-
67
- this.accessToken = this.options.accessToken || false;
68
-
69
- if (this.options.expires && Number(this.options.expires)) {
70
- this.expires = this.options.expires;
71
- } else {
72
- let timeout = Math.max(Number(this.options.timeout) || 0, 0);
73
- this.expires = (timeout && Date.now() + timeout * 1000) || 0;
74
- }
75
-
76
- this.renewing = false; // Track if renewal is in progress
77
- this.renewalQueue = []; // Queue for pending requests during renewal
78
- }
79
-
80
- /**
81
- * Returns or generates (if previous has expired) a XOAuth2 token
82
- *
83
- * @param {Boolean} renew If false then use cached access token (if available)
84
- * @param {Function} callback Callback function with error object and token string
85
- */
86
- getToken(renew, callback) {
87
- if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) {
88
- this.logger.debug(
89
- {
90
- tnx: 'OAUTH2',
91
- user: this.options.user,
92
- action: 'reuse'
93
- },
94
- 'Reusing existing access token for %s',
95
- this.options.user
96
- );
97
- return callback(null, this.accessToken);
98
- }
99
-
100
- // check if it is possible to renew, if not, return the current token or error
101
- if (!this.provisionCallback && !this.options.refreshToken && !this.options.serviceClient) {
102
- if (this.accessToken) {
103
- this.logger.debug(
104
- {
105
- tnx: 'OAUTH2',
106
- user: this.options.user,
107
- action: 'reuse'
108
- },
109
- 'Reusing existing access token (no refresh capability) for %s',
110
- this.options.user
111
- );
112
- return callback(null, this.accessToken);
113
- }
114
- this.logger.error(
115
- {
116
- tnx: 'OAUTH2',
117
- user: this.options.user,
118
- action: 'renew'
119
- },
120
- 'Cannot renew access token for %s: No refresh mechanism available',
121
- this.options.user
122
- );
123
- return callback(new Error("Can't create new access token for user"));
124
- }
125
-
126
- // If renewal already in progress, queue this request instead of starting another
127
- if (this.renewing) {
128
- return this.renewalQueue.push({ renew, callback });
129
- }
130
-
131
- this.renewing = true;
132
-
133
- // Handles token renewal completion - processes queued requests and cleans up
134
- const generateCallback = (err, accessToken) => {
135
- this.renewalQueue.forEach(item => item.callback(err, accessToken));
136
- this.renewalQueue = [];
137
- this.renewing = false;
138
-
139
- if (err) {
140
- this.logger.error(
141
- {
142
- err,
143
- tnx: 'OAUTH2',
144
- user: this.options.user,
145
- action: 'renew'
146
- },
147
- 'Failed generating new Access Token for %s',
148
- this.options.user
149
- );
150
- } else {
151
- this.logger.info(
152
- {
153
- tnx: 'OAUTH2',
154
- user: this.options.user,
155
- action: 'renew'
156
- },
157
- 'Generated new Access Token for %s',
158
- this.options.user
159
- );
160
- }
161
- // Complete original request
162
- callback(err, accessToken);
163
- };
164
-
165
- if (this.provisionCallback) {
166
- this.provisionCallback(this.options.user, !!renew, (err, accessToken, expires) => {
167
- if (!err && accessToken) {
168
- this.accessToken = accessToken;
169
- this.expires = expires || 0;
170
- }
171
- generateCallback(err, accessToken);
172
- });
173
- } else {
174
- this.generateToken(generateCallback);
175
- }
176
- }
177
-
178
- /**
179
- * Updates token values
180
- *
181
- * @param {String} accessToken New access token
182
- * @param {Number} timeout Access token lifetime in seconds
183
- *
184
- * Emits 'token': { user: User email-address, accessToken: the new accessToken, timeout: TTL in seconds}
185
- */
186
- updateToken(accessToken, timeout) {
187
- this.accessToken = accessToken;
188
- timeout = Math.max(Number(timeout) || 0, 0);
189
- this.expires = (timeout && Date.now() + timeout * 1000) || 0;
190
-
191
- this.emit('token', {
192
- user: this.options.user,
193
- accessToken: accessToken || '',
194
- expires: this.expires
195
- });
196
- }
197
-
198
- /**
199
- * Generates a new XOAuth2 token with the credentials provided at initialization
200
- *
201
- * @param {Function} callback Callback function with error object and token string
202
- */
203
- generateToken(callback) {
204
- let urlOptions;
205
- let loggedUrlOptions;
206
- if (this.options.serviceClient) {
207
- // service account - https://developers.google.com/identity/protocols/OAuth2ServiceAccount
208
- let iat = Math.floor(Date.now() / 1000); // unix time
209
- let tokenData = {
210
- iss: this.options.serviceClient,
211
- scope: this.options.scope || 'https://mail.google.com/',
212
- sub: this.options.user,
213
- aud: this.options.accessUrl,
214
- iat,
215
- exp: iat + this.options.serviceRequestTimeout
216
- };
217
- let token;
218
- try {
219
- token = this.jwtSignRS256(tokenData);
220
- } catch (_err) {
221
- return callback(new Error("Can't generate token. Check your auth options"));
222
- }
223
-
224
- urlOptions = {
225
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
226
- assertion: token
227
- };
228
-
229
- loggedUrlOptions = {
230
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
231
- assertion: tokenData
232
- };
233
- } else {
234
- if (!this.options.refreshToken) {
235
- return callback(new Error("Can't create new access token for user"));
236
- }
237
-
238
- // web app - https://developers.google.com/identity/protocols/OAuth2WebServer
239
- urlOptions = {
240
- client_id: this.options.clientId || '',
241
- client_secret: this.options.clientSecret || '',
242
- refresh_token: this.options.refreshToken,
243
- grant_type: 'refresh_token'
244
- };
245
-
246
- loggedUrlOptions = {
247
- client_id: this.options.clientId || '',
248
- client_secret: (this.options.clientSecret || '').substr(0, 6) + '...',
249
- refresh_token: (this.options.refreshToken || '').substr(0, 6) + '...',
250
- grant_type: 'refresh_token'
251
- };
252
- }
253
-
254
- Object.keys(this.options.customParams).forEach(key => {
255
- urlOptions[key] = this.options.customParams[key];
256
- loggedUrlOptions[key] = this.options.customParams[key];
257
- });
258
-
259
- this.logger.debug(
260
- {
261
- tnx: 'OAUTH2',
262
- user: this.options.user,
263
- action: 'generate'
264
- },
265
- 'Requesting token using: %s',
266
- JSON.stringify(loggedUrlOptions)
267
- );
268
-
269
- this.postRequest(this.options.accessUrl, urlOptions, this.options, (error, body) => {
270
- let data;
271
-
272
- if (error) {
273
- return callback(error);
274
- }
275
-
276
- try {
277
- data = JSON.parse(body.toString());
278
- } catch (E) {
279
- return callback(E);
280
- }
281
-
282
- if (!data || typeof data !== 'object') {
283
- this.logger.debug(
284
- {
285
- tnx: 'OAUTH2',
286
- user: this.options.user,
287
- action: 'post'
288
- },
289
- 'Response: %s',
290
- (body || '').toString()
291
- );
292
- return callback(new Error('Invalid authentication response'));
293
- }
294
-
295
- let logData = {};
296
- Object.keys(data).forEach(key => {
297
- if (key !== 'access_token') {
298
- logData[key] = data[key];
299
- } else {
300
- logData[key] = (data[key] || '').toString().substr(0, 6) + '...';
301
- }
302
- });
303
-
304
- this.logger.debug(
305
- {
306
- tnx: 'OAUTH2',
307
- user: this.options.user,
308
- action: 'post'
309
- },
310
- 'Response: %s',
311
- JSON.stringify(logData)
312
- );
313
-
314
- if (data.error) {
315
- // Error Response : https://tools.ietf.org/html/rfc6749#section-5.2
316
- let errorMessage = data.error;
317
- if (data.error_description) {
318
- errorMessage += ': ' + data.error_description;
319
- }
320
- if (data.error_uri) {
321
- errorMessage += ' (' + data.error_uri + ')';
322
- }
323
- return callback(new Error(errorMessage));
324
- }
325
-
326
- if (data.access_token) {
327
- this.updateToken(data.access_token, data.expires_in);
328
- return callback(null, this.accessToken);
329
- }
330
-
331
- return callback(new Error('No access token'));
332
- });
333
- }
334
-
335
- /**
336
- * Converts an access_token and user id into a base64 encoded XOAuth2 token
337
- *
338
- * @param {String} [accessToken] Access token string
339
- * @return {String} Base64 encoded token for IMAP or SMTP login
340
- */
341
- buildXOAuth2Token(accessToken) {
342
- let authData = ['user=' + (this.options.user || ''), 'auth=Bearer ' + (accessToken || this.accessToken), '', ''];
343
- return Buffer.from(authData.join('\x01'), 'utf-8').toString('base64');
344
- }
345
-
346
- /**
347
- * Custom POST request handler.
348
- * This is only needed to keep paths short in Windows – usually this module
349
- * is a dependency of a dependency and if it tries to require something
350
- * like the request module the paths get way too long to handle for Windows.
351
- * As we do only a simple POST request we do not actually require complicated
352
- * logic support (no redirects, no nothing) anyway.
353
- *
354
- * @param {String} url Url to POST to
355
- * @param {String|Buffer} payload Payload to POST
356
- * @param {Function} callback Callback function with (err, buff)
357
- */
358
- postRequest(url, payload, params, callback) {
359
- let returned = false;
360
-
361
- let chunks = [];
362
- let chunklen = 0;
363
-
364
- let req = nmfetch(url, {
365
- method: 'post',
366
- headers: params.customHeaders,
367
- body: payload,
368
- allowErrorResponse: true
369
- });
370
-
371
- req.on('readable', () => {
372
- let chunk;
373
- while ((chunk = req.read()) !== null) {
374
- chunks.push(chunk);
375
- chunklen += chunk.length;
376
- }
377
- });
378
-
379
- req.once('error', err => {
380
- if (returned) {
381
- return;
382
- }
383
- returned = true;
384
- return callback(err);
385
- });
386
-
387
- req.once('end', () => {
388
- if (returned) {
389
- return;
390
- }
391
- returned = true;
392
- return callback(null, Buffer.concat(chunks, chunklen));
393
- });
394
- }
395
-
396
- /**
397
- * Encodes a buffer or a string into Base64url format
398
- *
399
- * @param {Buffer|String} data The data to convert
400
- * @return {String} The encoded string
401
- */
402
- toBase64URL(data) {
403
- if (typeof data === 'string') {
404
- data = Buffer.from(data);
405
- }
406
-
407
- return data
408
- .toString('base64')
409
- .replace(/[=]+/g, '') // remove '='s
410
- .replace(/\+/g, '-') // '+' → '-'
411
- .replace(/\//g, '_'); // '/' → '_'
412
- }
413
-
414
- /**
415
- * Creates a JSON Web Token signed with RS256 (SHA256 + RSA)
416
- *
417
- * @param {Object} payload The payload to include in the generated token
418
- * @return {String} The generated and signed token
419
- */
420
- jwtSignRS256(payload) {
421
- payload = ['{"alg":"RS256","typ":"JWT"}', JSON.stringify(payload)].map(val => this.toBase64URL(val)).join('.');
422
- let signature = crypto.createSign('RSA-SHA256').update(payload).sign(this.options.privateKey);
423
- return payload + '.' + this.toBase64URL(signature);
424
- }
425
- }
426
-
427
- module.exports = XOAuth2;
@@ -1,47 +0,0 @@
1
- {
2
- "name": "nodemailer",
3
- "version": "7.0.13",
4
- "description": "Easy as cake e-mail sending from your Node.js applications",
5
- "main": "lib/nodemailer.js",
6
- "scripts": {
7
- "test": "node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js",
8
- "test:coverage": "c8 node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js",
9
- "format": "prettier --write \"**/*.{js,json,md}\"",
10
- "format:check": "prettier --check \"**/*.{js,json,md}\"",
11
- "lint": "eslint .",
12
- "lint:fix": "eslint . --fix",
13
- "update": "rm -rf node_modules/ package-lock.json && ncu -u && npm install"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "https://github.com/nodemailer/nodemailer.git"
18
- },
19
- "keywords": [
20
- "Nodemailer"
21
- ],
22
- "author": "Andris Reinman",
23
- "license": "MIT-0",
24
- "bugs": {
25
- "url": "https://github.com/nodemailer/nodemailer/issues"
26
- },
27
- "homepage": "https://nodemailer.com/",
28
- "devDependencies": {
29
- "@aws-sdk/client-sesv2": "3.975.0",
30
- "bunyan": "1.8.15",
31
- "c8": "10.1.3",
32
- "eslint": "9.39.2",
33
- "eslint-config-prettier": "10.1.8",
34
- "globals": "17.1.0",
35
- "libbase64": "1.3.0",
36
- "libmime": "5.3.7",
37
- "libqp": "2.1.1",
38
- "nodemailer-ntlm-auth": "1.0.4",
39
- "prettier": "3.8.1",
40
- "proxy": "1.0.2",
41
- "proxy-test-server": "1.0.0",
42
- "smtp-server": "3.18.0"
43
- },
44
- "engines": {
45
- "node": ">=6.0.0"
46
- }
47
- }
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- upgrade: true,
5
- reject: [
6
- // API changes break existing tests
7
- 'proxy'
8
- ]
9
- };
@@ -1,8 +0,0 @@
1
- node_modules
2
- coverage
3
- *.min.js
4
- dist
5
- build
6
- .nyc_output
7
- package-lock.json
8
- CHANGELOG.md
@@ -1,12 +0,0 @@
1
- {
2
- "printWidth": 140,
3
- "tabWidth": 4,
4
- "useTabs": false,
5
- "semi": true,
6
- "singleQuote": true,
7
- "quoteProps": "as-needed",
8
- "trailingComma": "none",
9
- "bracketSpacing": true,
10
- "arrowParens": "avoid",
11
- "endOfLine": "lf"
12
- }
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- printWidth: 160,
5
- tabWidth: 4,
6
- singleQuote: true,
7
- endOfLine: 'lf',
8
- trailingComma: 'none',
9
- arrowParens: 'avoid'
10
- };
@@ -1,9 +0,0 @@
1
- {
2
- "packages": {
3
- ".": {
4
- "release-type": "node",
5
- "package-name": "nodemailer",
6
- "pull-request-title-pattern": "chore${scope}: release ${version} [skip-ci]"
7
- }
8
- }
9
- }
@@ -1,16 +0,0 @@
1
- Copyright (c) 2011-2023 Andris Reinman
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
- SOFTWARE.
@@ -1,86 +0,0 @@
1
- # Nodemailer
2
-
3
- [![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png)](https://nodemailer.com/about/)
4
-
5
- Send emails from Node.js – easy as cake! 🍰✉️
6
-
7
- [![NPM](https://nodei.co/npm/nodemailer.png?downloads=true&downloadRank=true&stars=true)](https://nodemailer.com/about/)
8
-
9
- See [nodemailer.com](https://nodemailer.com/) for documentation and terms.
10
-
11
- > [!TIP]
12
- > Check out **[EmailEngine](https://emailengine.app/?utm_source=github-nodemailer&utm_campaign=nodemailer&utm_medium=readme-link)** – a self-hosted email gateway that allows making **REST requests against IMAP and SMTP servers**. EmailEngine also sends webhooks whenever something changes on the registered accounts.\
13
- > \
14
- > Using the email accounts registered with EmailEngine, you can receive and [send emails](https://emailengine.app/sending-emails?utm_source=github-nodemailer&utm_campaign=nodemailer&utm_medium=readme-link). EmailEngine supports OAuth2, delayed sends, opens and clicks tracking, bounce detection, etc. All on top of regular email accounts without an external MTA service.
15
-
16
- ## Having an issue?
17
-
18
- #### First review the docs
19
-
20
- Documentation for Nodemailer can be found at [nodemailer.com](https://nodemailer.com/about/).
21
-
22
- #### Nodemailer throws a SyntaxError for "..."
23
-
24
- You are using an older Node.js version than v6.0. Upgrade Node.js to get support for the spread operator. Nodemailer supports all Node.js versions starting from Node.js@v6.0.0.
25
-
26
- #### I'm having issues with Gmail
27
-
28
- Gmail either works well, or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you, then don't use it. Read more about it [here](https://nodemailer.com/usage/using-gmail/).
29
-
30
- #### I get ETIMEDOUT errors
31
-
32
- Check your firewall settings. Timeout usually occurs when you try to open a connection to a firewalled port either on the server or on your machine. Some ISPs also block email ports to prevent spamming.
33
-
34
- #### Nodemailer works on one machine but not in another
35
-
36
- It's either a firewall issue, or your SMTP server blocks authentication attempts from some servers.
37
-
38
- #### I get TLS errors
39
-
40
- - If you are running the code on your machine, check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using.
41
- - Latest Node versions allow only TLS versions 1.2 and higher. Some servers might still use TLS 1.1 or lower. Check Node.js docs on how to get correct TLS support for your app. You can change this with [tls.minVersion](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tls_tls_createsecurecontext_options) option
42
- - You might have the wrong value for the `secure` option. This should be set to `true` only for port 465. For every other port, it should be `false`. Setting it to `false` does not mean that Nodemailer would not use TLS. Nodemailer would still try to upgrade the connection to use TLS if the server supports it.
43
- - Older Node versions do not fully support the certificate chain of the newest Let's Encrypt certificates. Either set [tls.rejectUnauthorized](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tlsconnectoptions-callback) to `false` to skip chain verification or upgrade your Node version
44
-
45
- ```js
46
- let configOptions = {
47
- host: 'smtp.example.com',
48
- port: 587,
49
- tls: {
50
- rejectUnauthorized: true,
51
- minVersion: 'TLSv1.2'
52
- }
53
- };
54
- ```
55
-
56
- #### I have issues with DNS / hosts file
57
-
58
- Node.js uses [c-ares](https://nodejs.org/en/docs/meta/topics/dependencies/#c-ares) to resolve domain names, not the DNS library provided by the system, so if you have some custom DNS routing set up, it might be ignored. Nodemailer runs [dns.resolve4()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve4hostname-options-callback) and [dns.resolve6()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve6hostname-options-callback) to resolve hostname into an IP address. If both calls fail, then Nodemailer will fall back to [dns.lookup()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnslookuphostname-options-callback). If this does not work for you, you can hard code the IP address into the configuration like shown below. In that case, Nodemailer would not perform any DNS lookups.
59
-
60
- ```js
61
- let configOptions = {
62
- host: '1.2.3.4',
63
- port: 465,
64
- secure: true,
65
- tls: {
66
- // must provide server name, otherwise TLS certificate check will fail
67
- servername: 'example.com'
68
- }
69
- };
70
- ```
71
-
72
- #### I have an issue with TypeScript types
73
-
74
- Nodemailer has official support for Node.js only. For anything related to TypeScript, you need to directly contact the authors of the [type definitions](https://www.npmjs.com/package/@types/nodemailer).
75
-
76
- #### I have a different problem
77
-
78
- If you are having issues with Nodemailer, then the best way to find help would be [Stack Overflow](https://stackoverflow.com/search?q=nodemailer) or revisit the [docs](https://nodemailer.com/about/).
79
-
80
- ### License
81
-
82
- Nodemailer is licensed under the **MIT No Attribution license**
83
-
84
- ---
85
-
86
- The Nodemailer logo was designed by [Sven Kristjansen](https://www.behance.net/kristjansen).
@@ -1,22 +0,0 @@
1
- -----BEGIN PGP SIGNED MESSAGE-----
2
- Hash: SHA256
3
-
4
- Contact: mailto:andris@reinman.eu
5
- Encryption: https://keys.openpgp.org/vks/v1/by-fingerprint/5D952A46E1D8C931F6364E01DC6C83F4D584D364
6
- Preferred-Languages: en, et
7
- -----BEGIN PGP SIGNATURE-----
8
-
9
- iQIzBAEBCAAdFiEEXZUqRuHYyTH2Nk4B3GyD9NWE02QFAmFDnUgACgkQ3GyD9NWE
10
- 02RqUA/+MM3afmRYq874C7wp+uN6dTMCvUX5g5zqBZ2yKpFr46L+PYvM7o8TMm5h
11
- hmLT2I1zZmi+xezOL3zHFizaw0tKkZIz9cWl3Jrgs0FLp0zOsSz1xucp9Q2tYM/Q
12
- vbiP6ys0gbim4tkDGRmZOEiO23s0BuRnmHt7vZg210O+D105Yd8/Ohzbj6PSLBO5
13
- W1tA7Xw5t0FQ14NNH5+MKyDIKoCX12n0FmrC6qLTXeojf291UgKhCUPda3LIGTmx
14
- mTXz0y68149Mw+JikRCYP8HfGRY9eA4XZrYXF7Bl2T9OJpKD3JAH+69P3xBw19Gn
15
- Csaw3twu8P1bxoVGjY4KRrBOp68W8TwZYjWVWbqY6oV8hb/JfrMxa+kaSxRuloFs
16
- oL6+phrDSPTWdOj2LlEDBJbPOMeDFzIlsBBcJ/JHCEHTvlHl7LoWr3YuWce9PUwl
17
- 4r3JUovvaeuJxLgC0vu3WCB3Jeocsl3SreqNkrVc1IjvkSomn3YGm5nCNAd/2F0V
18
- exCGRk/8wbkSjAY38GwQ8K/VuFsefWN3L9sVwIMAMu88KFCAN+GzVFiwvyIXehF5
19
- eogP9mIXzdQ5YReQjUjApOzGz54XnDyv9RJ3sdvMHosLP+IOg+0q5t9agWv6aqSR
20
- 2HzCpiQnH/gmM5NS0AU4Koq/L7IBeLu1B8+61/+BiHgZJJmPdgU=
21
- =BUZr
22
- -----END PGP SIGNATURE-----