@nocobase/plugin-workflow-mailer 2.3.0-beta.13 → 2.3.0-beta.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 (173) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/node_modules/joi/package.json +1 -1
  3. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +59 -0
  4. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.js +790 -0
  5. package/dist/node_modules/nodemailer/dist/cjs/base64/index.d.ts +36 -0
  6. package/dist/node_modules/nodemailer/dist/cjs/base64/index.js +119 -0
  7. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +52 -0
  8. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.js +228 -0
  9. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +48 -0
  10. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +180 -0
  11. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +36 -0
  12. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +148 -0
  13. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +52 -0
  14. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.js +165 -0
  15. package/dist/node_modules/nodemailer/dist/cjs/errors.d.ts +96 -0
  16. package/dist/node_modules/nodemailer/dist/cjs/errors.js +70 -0
  17. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +107 -0
  18. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.js +282 -0
  19. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +65 -0
  20. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.js +384 -0
  21. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +64 -0
  22. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.js +99 -0
  23. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +174 -0
  24. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.js +613 -0
  25. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +237 -0
  26. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.js +415 -0
  27. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +97 -0
  28. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +342 -0
  29. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +161 -0
  30. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +787 -0
  31. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
  32. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.js +2103 -0
  33. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +333 -0
  34. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.js +1493 -0
  35. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +5 -0
  36. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +32 -0
  37. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +9 -0
  38. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +40 -0
  39. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +10 -0
  40. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +47 -0
  41. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +124 -0
  42. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
  43. package/dist/node_modules/nodemailer/dist/cjs/package-info.d.ts +3 -0
  44. package/dist/node_modules/nodemailer/dist/cjs/package-info.js +7 -0
  45. package/dist/node_modules/nodemailer/dist/cjs/package.json +3 -0
  46. package/dist/node_modules/nodemailer/dist/cjs/punycode/index.d.ts +73 -0
  47. package/dist/node_modules/nodemailer/{lib → dist/cjs}/punycode/index.js +62 -111
  48. package/dist/node_modules/nodemailer/dist/cjs/qp/index.d.ts +32 -0
  49. package/dist/node_modules/nodemailer/dist/cjs/qp/index.js +207 -0
  50. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +69 -0
  51. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.js +210 -0
  52. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +112 -0
  53. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.js +252 -0
  54. package/dist/node_modules/nodemailer/dist/cjs/shared/index.d.ts +260 -0
  55. package/dist/node_modules/nodemailer/dist/cjs/shared/index.js +680 -0
  56. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.d.ts +23 -0
  57. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.js +43 -0
  58. package/dist/node_modules/nodemailer/dist/cjs/shared/url.d.ts +21 -0
  59. package/dist/node_modules/nodemailer/dist/cjs/shared/url.js +255 -0
  60. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +15 -0
  61. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +108 -0
  62. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +47 -0
  63. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +189 -0
  64. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +416 -0
  65. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +1837 -0
  66. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +133 -0
  67. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +569 -0
  68. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +62 -0
  69. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +257 -0
  70. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +156 -0
  71. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +371 -0
  72. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +65 -0
  73. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.js +146 -0
  74. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +35 -0
  75. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.js +41 -0
  76. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.d.ts +2 -0
  77. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.js +674 -0
  78. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +201 -0
  79. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.js +426 -0
  80. package/dist/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +59 -0
  81. package/dist/node_modules/nodemailer/{lib → dist/esm}/addressparser/index.js +361 -131
  82. package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
  83. package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +31 -56
  84. package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
  85. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +49 -78
  86. package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
  87. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/message-parser.js +64 -42
  88. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +36 -0
  89. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +141 -0
  90. package/dist/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +52 -0
  91. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/sign.js +50 -46
  92. package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
  93. package/dist/node_modules/nodemailer/{lib → dist/esm}/errors.js +26 -18
  94. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +107 -0
  95. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.js +242 -0
  96. package/dist/node_modules/nodemailer/dist/esm/fetch/index.d.ts +65 -0
  97. package/dist/node_modules/nodemailer/{lib → dist/esm}/fetch/index.js +80 -147
  98. package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
  99. package/dist/node_modules/nodemailer/{lib → dist/esm}/json-transport/index.js +19 -39
  100. package/dist/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +174 -0
  101. package/dist/node_modules/nodemailer/{lib → dist/esm}/mail-composer/index.js +199 -265
  102. package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
  103. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +128 -234
  104. package/dist/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +97 -0
  105. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/mail-message.js +62 -114
  106. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +161 -0
  107. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.js +738 -0
  108. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.d.ts +2 -0
  109. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-funcs/mime-types.js +29 -42
  110. package/dist/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +333 -0
  111. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/index.js +259 -372
  112. package/dist/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +5 -0
  113. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/last-newline.js +4 -10
  114. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +9 -0
  115. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-unix.js +6 -11
  116. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +10 -0
  117. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-windows.js +6 -13
  118. package/dist/node_modules/nodemailer/dist/esm/nodemailer.d.ts +124 -0
  119. package/dist/node_modules/nodemailer/dist/esm/nodemailer.js +166 -0
  120. package/dist/node_modules/nodemailer/dist/esm/package-info.d.ts +3 -0
  121. package/dist/node_modules/nodemailer/dist/esm/package-info.js +4 -0
  122. package/dist/node_modules/nodemailer/dist/esm/package.json +3 -0
  123. package/dist/node_modules/nodemailer/dist/esm/punycode/index.d.ts +73 -0
  124. package/dist/node_modules/nodemailer/dist/esm/punycode/index.js +405 -0
  125. package/dist/node_modules/nodemailer/dist/esm/qp/index.d.ts +32 -0
  126. package/dist/node_modules/nodemailer/{lib → dist/esm}/qp/index.js +38 -67
  127. package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
  128. package/dist/node_modules/nodemailer/{lib → dist/esm}/sendmail-transport/index.js +51 -101
  129. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +112 -0
  130. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.js +212 -0
  131. package/dist/node_modules/nodemailer/dist/esm/shared/index.d.ts +260 -0
  132. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/index.js +156 -272
  133. package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
  134. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/objects.js +13 -17
  135. package/dist/node_modules/nodemailer/dist/esm/shared/url.d.ts +21 -0
  136. package/dist/node_modules/nodemailer/dist/esm/shared/url.js +214 -0
  137. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +15 -0
  138. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +103 -0
  139. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +47 -0
  140. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/http-proxy-client.js +49 -74
  141. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
  142. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/index.js +574 -794
  143. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +133 -0
  144. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/index.js +172 -284
  145. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +62 -0
  146. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/pool-resource.js +57 -97
  147. package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
  148. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-transport/index.js +81 -179
  149. package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
  150. package/dist/node_modules/nodemailer/{lib → dist/esm}/stream-transport/index.js +36 -74
  151. package/dist/node_modules/nodemailer/dist/esm/well-known/index.d.ts +35 -0
  152. package/dist/node_modules/nodemailer/{lib → dist/esm}/well-known/index.js +5 -16
  153. package/dist/node_modules/nodemailer/dist/esm/well-known/services.d.ts +2 -0
  154. package/dist/node_modules/nodemailer/dist/esm/well-known/services.js +671 -0
  155. package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +201 -0
  156. package/dist/node_modules/nodemailer/{lib → dist/esm}/xoauth2/index.js +125 -187
  157. package/dist/node_modules/nodemailer/{lib → dist}/well-known/services.json +9 -2
  158. package/dist/node_modules/nodemailer/package.json +1 -1
  159. package/package.json +3 -3
  160. package/dist/node_modules/nodemailer/.gitattributes +0 -6
  161. package/dist/node_modules/nodemailer/.ncurc.js +0 -9
  162. package/dist/node_modules/nodemailer/.prettierignore +0 -8
  163. package/dist/node_modules/nodemailer/.prettierrc +0 -12
  164. package/dist/node_modules/nodemailer/.prettierrc.js +0 -10
  165. package/dist/node_modules/nodemailer/.release-please-config.json +0 -9
  166. package/dist/node_modules/nodemailer/eslint.config.js +0 -88
  167. package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  168. package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -276
  169. package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -671
  170. package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
  171. package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -266
  172. package/dist/node_modules/nodemailer/lib/shared/url.js +0 -151
  173. package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -105
@@ -1,11 +1,8 @@
1
- 'use strict';
2
-
3
- const { Stream } = require('stream');
4
- const nmfetch = require('../fetch');
5
- const crypto = require('crypto');
6
- const shared = require('../shared');
7
- const errors = require('../errors');
8
-
1
+ import { Stream } from 'node:stream';
2
+ import nmfetch from '../fetch/index.js';
3
+ import crypto from 'node:crypto';
4
+ import * as shared from '../shared/index.js';
5
+ import * as errors from '../errors.js';
9
6
  /**
10
7
  * XOAUTH2 access_token generator for Gmail.
11
8
  * Create client ID for web applications in Google API console to use it.
@@ -22,152 +19,123 @@ const errors = require('../errors');
22
19
  * If provisionCallback is used, then Nodemailer does not try to attempt generating the token by itself
23
20
  *
24
21
  * @constructor
25
- * @param {Object} options Client information for token generation
26
- * @param {String} options.user User e-mail address
27
- * @param {String} options.clientId Client ID value
28
- * @param {String} options.clientSecret Client secret value
29
- * @param {String} options.refreshToken Refresh token for an user
30
- * @param {String} options.accessUrl Endpoint for token generation, defaults to 'https://accounts.google.com/o/oauth2/token'
31
- * @param {String} options.accessToken An existing valid accessToken
32
- * @param {String} options.privateKey Private key for JSW
33
- * @param {Number} options.expires Optional Access Token expire time in ms
34
- * @param {Number} options.timeout Optional TTL for Access Token in seconds
35
- * @param {Function} options.provisionCallback Function to run when a new access token is required
36
- * @param {Object} options.tls Optional TLS options forwarded to the HTTPS token request. Defaults to strict cert validation; supply { rejectUnauthorized: false } only for self-hosted OAuth providers on private CAs.
22
+ * @param options Client information for token generation
23
+ * @param options.user User e-mail address
24
+ * @param options.clientId Client ID value
25
+ * @param options.clientSecret Client secret value
26
+ * @param options.refreshToken Refresh token for an user
27
+ * @param options.accessUrl Endpoint for token generation, defaults to 'https://accounts.google.com/o/oauth2/token'
28
+ * @param options.accessToken An existing valid accessToken
29
+ * @param options.privateKey Private key for JSW
30
+ * @param options.expires Optional Access Token expire time in ms
31
+ * @param options.timeout Optional TTL for Access Token in seconds
32
+ * @param options.provisionCallback Function to run when a new access token is required
33
+ * @param options.tls Optional TLS options forwarded to the HTTPS token request. Defaults to strict cert validation; supply { rejectUnauthorized: false } only for self-hosted OAuth providers on private CAs.
37
34
  */
38
35
  class XOAuth2 extends Stream {
39
36
  constructor(options, logger) {
40
37
  super();
41
-
42
38
  this.options = options || {};
43
-
39
+ this.configError = false;
44
40
  if (options && options.serviceClient) {
45
41
  if (!options.privateKey || !options.user) {
42
+ // reported through getToken() rather than an 'error' event: the transports forward
43
+ // that event up to the Mail object, where nothing may be listening
46
44
  const err = new Error('Options "privateKey" and "user" are required for service account!');
47
45
  err.code = errors.EOAUTH2;
48
- setImmediate(() => this.emit('error', err));
49
- return;
46
+ this.configError = err;
50
47
  }
51
-
52
48
  const serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600);
53
49
  this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60;
54
50
  }
55
-
56
- this.logger = shared.getLogger(
57
- {
58
- logger
59
- },
60
- {
61
- component: this.options.component || 'OAuth2'
62
- }
63
- );
64
-
51
+ this.logger = shared.getLogger({
52
+ logger
53
+ }, {
54
+ component: this.options.component || 'OAuth2'
55
+ });
65
56
  this.provisionCallback = typeof this.options.provisionCallback === 'function' ? this.options.provisionCallback : false;
66
-
67
57
  this.options.accessUrl = this.options.accessUrl || 'https://accounts.google.com/o/oauth2/token';
68
58
  this.options.customHeaders = this.options.customHeaders || {};
69
59
  this.options.customParams = this.options.customParams || {};
70
-
71
60
  this.accessToken = this.options.accessToken || false;
72
-
73
61
  if (this.options.expires && Number(this.options.expires)) {
74
62
  this.expires = this.options.expires;
75
- } else {
63
+ }
64
+ else {
76
65
  const timeout = Math.max(Number(this.options.timeout) || 0, 0);
77
66
  this.expires = (timeout && Date.now() + timeout * 1000) || 0;
78
67
  }
79
-
80
68
  this.renewing = false; // Track if renewal is in progress
81
69
  this.renewalQueue = []; // Queue for pending requests during renewal
82
70
  }
83
-
84
71
  /**
85
72
  * Returns or generates (if previous has expired) a XOAuth2 token
86
73
  *
87
- * @param {Boolean} renew If false then use cached access token (if available)
88
- * @param {Function} callback Callback function with error object and token string
74
+ * @param renew If false then use cached access token (if available)
75
+ * @param callback Callback function with error object and token string
89
76
  */
90
77
  getToken(renew, callback) {
78
+ // the error paths hand over the error alone
79
+ const done = callback;
80
+ if (this.configError) {
81
+ return done(this.configError);
82
+ }
91
83
  if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) {
92
- this.logger.debug(
93
- {
94
- tnx: 'OAUTH2',
95
- user: this.options.user,
96
- action: 'reuse'
97
- },
98
- 'Reusing existing access token for %s',
99
- this.options.user
100
- );
84
+ this.logger.debug({
85
+ tnx: 'OAUTH2',
86
+ user: this.options.user,
87
+ action: 'reuse'
88
+ }, 'Reusing existing access token for %s', this.options.user);
101
89
  return callback(null, this.accessToken);
102
90
  }
103
-
104
91
  // check if it is possible to renew, if not, return the current token or error
105
92
  if (!this.provisionCallback && !this.options.refreshToken && !this.options.serviceClient) {
106
93
  if (this.accessToken) {
107
- this.logger.debug(
108
- {
109
- tnx: 'OAUTH2',
110
- user: this.options.user,
111
- action: 'reuse'
112
- },
113
- 'Reusing existing access token (no refresh capability) for %s',
114
- this.options.user
115
- );
116
- return callback(null, this.accessToken);
117
- }
118
- this.logger.error(
119
- {
94
+ this.logger.debug({
120
95
  tnx: 'OAUTH2',
121
96
  user: this.options.user,
122
- action: 'renew'
123
- },
124
- 'Cannot renew access token for %s: No refresh mechanism available',
125
- this.options.user
126
- );
97
+ action: 'reuse'
98
+ }, 'Reusing existing access token (no refresh capability) for %s', this.options.user);
99
+ return callback(null, this.accessToken);
100
+ }
101
+ this.logger.error({
102
+ tnx: 'OAUTH2',
103
+ user: this.options.user,
104
+ action: 'renew'
105
+ }, 'Cannot renew access token for %s: No refresh mechanism available', this.options.user);
127
106
  const err = new Error("Can't create new access token for user");
128
107
  err.code = errors.EOAUTH2;
129
- return callback(err);
108
+ return done(err);
130
109
  }
131
-
132
110
  // If renewal already in progress, queue this request instead of starting another
133
111
  if (this.renewing) {
134
- return this.renewalQueue.push({ renew, callback });
112
+ this.renewalQueue.push({ renew, callback: done });
113
+ return;
135
114
  }
136
-
137
115
  this.renewing = true;
138
-
139
116
  // Handles token renewal completion - processes queued requests and cleans up
140
117
  const generateCallback = (err, accessToken) => {
141
118
  this.renewalQueue.forEach(item => item.callback(err, accessToken));
142
119
  this.renewalQueue = [];
143
120
  this.renewing = false;
144
-
145
121
  if (err) {
146
- this.logger.error(
147
- {
148
- err,
149
- tnx: 'OAUTH2',
150
- user: this.options.user,
151
- action: 'renew'
152
- },
153
- 'Failed generating new Access Token for %s',
154
- this.options.user
155
- );
156
- } else {
157
- this.logger.info(
158
- {
159
- tnx: 'OAUTH2',
160
- user: this.options.user,
161
- action: 'renew'
162
- },
163
- 'Generated new Access Token for %s',
164
- this.options.user
165
- );
122
+ this.logger.error({
123
+ err,
124
+ tnx: 'OAUTH2',
125
+ user: this.options.user,
126
+ action: 'renew'
127
+ }, 'Failed generating new Access Token for %s', this.options.user);
128
+ }
129
+ else {
130
+ this.logger.info({
131
+ tnx: 'OAUTH2',
132
+ user: this.options.user,
133
+ action: 'renew'
134
+ }, 'Generated new Access Token for %s', this.options.user);
166
135
  }
167
136
  // Complete original request
168
- callback(err, accessToken);
137
+ done(err, accessToken);
169
138
  };
170
-
171
139
  if (this.provisionCallback) {
172
140
  this.provisionCallback(this.options.user, !!renew, (err, accessToken, expires) => {
173
141
  if (!err && accessToken) {
@@ -176,16 +144,16 @@ class XOAuth2 extends Stream {
176
144
  }
177
145
  generateCallback(err, accessToken);
178
146
  });
179
- } else {
147
+ }
148
+ else {
180
149
  this.generateToken(generateCallback);
181
150
  }
182
151
  }
183
-
184
152
  /**
185
153
  * Updates token values
186
154
  *
187
- * @param {String} accessToken New access token
188
- * @param {Number} timeout Access token lifetime in seconds
155
+ * @param accessToken New access token
156
+ * @param timeout Access token lifetime in seconds
189
157
  *
190
158
  * Emits 'token': { user: User email-address, accessToken: the new accessToken, timeout: TTL in seconds}
191
159
  */
@@ -193,20 +161,20 @@ class XOAuth2 extends Stream {
193
161
  this.accessToken = accessToken;
194
162
  timeout = Math.max(Number(timeout) || 0, 0);
195
163
  this.expires = (timeout && Date.now() + timeout * 1000) || 0;
196
-
197
164
  this.emit('token', {
198
165
  user: this.options.user,
199
166
  accessToken: accessToken || '',
200
167
  expires: this.expires
201
168
  });
202
169
  }
203
-
204
170
  /**
205
171
  * Generates a new XOAuth2 token with the credentials provided at initialization
206
172
  *
207
- * @param {Function} callback Callback function with error object and token string
173
+ * @param callback Callback function with error object and token string
208
174
  */
209
175
  generateToken(callback) {
176
+ // the error paths hand over the error alone
177
+ const done = callback;
210
178
  let urlOptions;
211
179
  let loggedUrlOptions;
212
180
  if (this.options.serviceClient) {
@@ -223,28 +191,27 @@ class XOAuth2 extends Stream {
223
191
  let token;
224
192
  try {
225
193
  token = this.jwtSignRS256(tokenData);
226
- } catch (_err) {
194
+ }
195
+ catch (_err) {
227
196
  const err = new Error("Can't generate token. Check your auth options");
228
197
  err.code = errors.EOAUTH2;
229
- return callback(err);
198
+ return done(err);
230
199
  }
231
-
232
200
  urlOptions = {
233
201
  grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
234
202
  assertion: token
235
203
  };
236
-
237
204
  loggedUrlOptions = {
238
205
  grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
239
206
  assertion: tokenData
240
207
  };
241
- } else {
208
+ }
209
+ else {
242
210
  if (!this.options.refreshToken) {
243
211
  const err = new Error("Can't create new access token for user");
244
212
  err.code = errors.EOAUTH2;
245
- return callback(err);
213
+ return done(err);
246
214
  }
247
-
248
215
  // web app - https://developers.google.com/identity/protocols/OAuth2WebServer
249
216
  urlOptions = {
250
217
  client_id: this.options.clientId || '',
@@ -252,7 +219,6 @@ class XOAuth2 extends Stream {
252
219
  refresh_token: this.options.refreshToken,
253
220
  grant_type: 'refresh_token'
254
221
  };
255
-
256
222
  loggedUrlOptions = {
257
223
  client_id: this.options.clientId || '',
258
224
  client_secret: (this.options.clientSecret || '').substr(0, 6) + '...',
@@ -260,63 +226,43 @@ class XOAuth2 extends Stream {
260
226
  grant_type: 'refresh_token'
261
227
  };
262
228
  }
263
-
264
229
  Object.assign(urlOptions, this.options.customParams);
265
230
  Object.assign(loggedUrlOptions, this.options.customParams);
266
-
267
- this.logger.debug(
268
- {
269
- tnx: 'OAUTH2',
270
- user: this.options.user,
271
- action: 'generate'
272
- },
273
- 'Requesting token using: %s',
274
- JSON.stringify(loggedUrlOptions)
275
- );
276
-
231
+ this.logger.debug({
232
+ tnx: 'OAUTH2',
233
+ user: this.options.user,
234
+ action: 'generate'
235
+ }, 'Requesting token using: %s', JSON.stringify(loggedUrlOptions));
277
236
  this.postRequest(this.options.accessUrl, urlOptions, this.options, (error, body) => {
278
237
  let data;
279
-
280
238
  if (error) {
281
- return callback(error);
239
+ return done(error);
282
240
  }
283
-
284
241
  try {
285
242
  data = JSON.parse(body.toString());
286
- } catch (E) {
287
- return callback(E);
288
243
  }
289
-
244
+ catch (E) {
245
+ return done(E);
246
+ }
290
247
  if (!data || typeof data !== 'object') {
291
- this.logger.debug(
292
- {
293
- tnx: 'OAUTH2',
294
- user: this.options.user,
295
- action: 'post'
296
- },
297
- 'Response: %s',
298
- (body || '').toString()
299
- );
248
+ this.logger.debug({
249
+ tnx: 'OAUTH2',
250
+ user: this.options.user,
251
+ action: 'post'
252
+ }, 'Response: %s', (body || '').toString());
300
253
  const err = new Error('Invalid authentication response');
301
254
  err.code = errors.EOAUTH2;
302
- return callback(err);
255
+ return done(err);
303
256
  }
304
-
305
257
  const logData = Object.assign({}, data);
306
258
  if (logData.access_token) {
307
259
  logData.access_token = (logData.access_token || '').toString().substr(0, 6) + '...';
308
260
  }
309
-
310
- this.logger.debug(
311
- {
312
- tnx: 'OAUTH2',
313
- user: this.options.user,
314
- action: 'post'
315
- },
316
- 'Response: %s',
317
- JSON.stringify(logData)
318
- );
319
-
261
+ this.logger.debug({
262
+ tnx: 'OAUTH2',
263
+ user: this.options.user,
264
+ action: 'post'
265
+ }, 'Response: %s', JSON.stringify(logData));
320
266
  if (data.error) {
321
267
  // Error Response : https://tools.ietf.org/html/rfc6749#section-5.2
322
268
  let errorMessage = data.error;
@@ -328,57 +274,54 @@ class XOAuth2 extends Stream {
328
274
  }
329
275
  const err = new Error(errorMessage);
330
276
  err.code = errors.EOAUTH2;
331
- return callback(err);
277
+ return done(err);
332
278
  }
333
-
334
279
  if (data.access_token) {
335
280
  this.updateToken(data.access_token, data.expires_in);
336
281
  return callback(null, this.accessToken);
337
282
  }
338
-
339
283
  const err = new Error('No access token');
340
284
  err.code = errors.EOAUTH2;
341
- return callback(err);
285
+ return done(err);
342
286
  });
343
287
  }
344
-
345
288
  /**
346
289
  * Converts an access_token and user id into a base64 encoded XOAuth2 token
347
290
  *
348
- * @param {String} [accessToken] Access token string
349
- * @return {String} Base64 encoded token for IMAP or SMTP login
291
+ * @param [accessToken] Access token string
292
+ * @return Base64 encoded token for IMAP or SMTP login
350
293
  */
351
294
  buildXOAuth2Token(accessToken) {
352
295
  const authData = ['user=' + (this.options.user || ''), 'auth=Bearer ' + (accessToken || this.accessToken), '', ''];
353
296
  return Buffer.from(authData.join('\x01'), 'utf-8').toString('base64');
354
297
  }
355
-
356
298
  /**
357
299
  * Custom POST request handler.
358
- * This is only needed to keep paths short in Windows – usually this module
300
+ * This is only needed to keep paths short in Windows, usually this module
359
301
  * is a dependency of a dependency and if it tries to require something
360
302
  * like the request module the paths get way too long to handle for Windows.
361
303
  * As we do only a simple POST request we do not actually require complicated
362
304
  * logic support (no redirects, no nothing) anyway.
363
305
  *
364
- * @param {String} url Url to POST to
365
- * @param {String|Buffer} payload Payload to POST
366
- * @param {Function} callback Callback function with (err, buff)
306
+ * @param url Url to POST to
307
+ * @param payload Payload to POST
308
+ * @param params Client options, the customHeaders and tls values are used for the request
309
+ * @param callback Callback function with (err, buff)
367
310
  */
368
311
  postRequest(url, payload, params, callback) {
369
312
  let returned = false;
370
-
371
313
  const chunks = [];
372
314
  let chunklen = 0;
373
-
374
315
  const fetchOptions = {
375
316
  method: 'post',
376
317
  headers: params.customHeaders,
377
318
  body: payload,
378
- allowErrorResponse: true
319
+ allowErrorResponse: true,
320
+ // unset falls back to the fetch default, a stalled token endpoint would otherwise keep
321
+ // `renewing` set and queue every later request
322
+ timeout: params.requestTimeout
379
323
  };
380
-
381
- // OAuth2 token endpoints are credential-bearing. lib/fetch already
324
+ // OAuth2 token endpoints are credential-bearing. src/fetch already
382
325
  // validates certs by default; pin rejectUnauthorized:true here so the
383
326
  // token fetch stays strict, while still layering params.tls (the
384
327
  // user's options.tls) on top so callers with a self-hosted provider on
@@ -386,9 +329,7 @@ class XOAuth2 extends Stream {
386
329
  if (/^https:/i.test(url)) {
387
330
  fetchOptions.tls = Object.assign({ rejectUnauthorized: true }, params.tls || {});
388
331
  }
389
-
390
332
  const req = nmfetch(url, fetchOptions);
391
-
392
333
  req.on('readable', () => {
393
334
  let chunk;
394
335
  while ((chunk = req.read()) !== null) {
@@ -396,7 +337,6 @@ class XOAuth2 extends Stream {
396
337
  chunklen += chunk.length;
397
338
  }
398
339
  });
399
-
400
340
  req.once('error', err => {
401
341
  if (returned) {
402
342
  return;
@@ -404,7 +344,6 @@ class XOAuth2 extends Stream {
404
344
  returned = true;
405
345
  return callback(err);
406
346
  });
407
-
408
347
  req.once('end', () => {
409
348
  if (returned) {
410
349
  return;
@@ -413,36 +352,35 @@ class XOAuth2 extends Stream {
413
352
  return callback(null, Buffer.concat(chunks, chunklen));
414
353
  });
415
354
  }
416
-
417
355
  /**
418
356
  * Encodes a buffer or a string into Base64url format
419
357
  *
420
- * @param {Buffer|String} data The data to convert
421
- * @return {String} The encoded string
358
+ * @param data The data to convert
359
+ * @return The encoded string
422
360
  */
423
361
  toBase64URL(data) {
424
362
  if (typeof data === 'string') {
425
363
  data = Buffer.from(data);
426
364
  }
427
-
428
365
  return data
429
366
  .toString('base64')
430
367
  .replace(/[=]+/g, '') // remove '='s
431
368
  .replace(/\+/g, '-') // '+' → '-'
432
369
  .replace(/\//g, '_'); // '/' → '_'
433
370
  }
434
-
435
371
  /**
436
372
  * Creates a JSON Web Token signed with RS256 (SHA256 + RSA)
437
373
  *
438
- * @param {Object} payload The payload to include in the generated token
439
- * @return {String} The generated and signed token
374
+ * @param payload The payload to include in the generated token
375
+ * @return The generated and signed token
440
376
  */
441
377
  jwtSignRS256(payload) {
442
- payload = ['{"alg":"RS256","typ":"JWT"}', JSON.stringify(payload)].map(val => this.toBase64URL(val)).join('.');
443
- const signature = crypto.createSign('RSA-SHA256').update(payload).sign(this.options.privateKey);
444
- return payload + '.' + this.toBase64URL(signature);
378
+ const signedPayload = ['{"alg":"RS256","typ":"JWT"}', JSON.stringify(payload)].map(val => this.toBase64URL(val)).join('.');
379
+ const signature = crypto
380
+ .createSign('RSA-SHA256')
381
+ .update(signedPayload)
382
+ .sign(this.options.privateKey);
383
+ return signedPayload + '.' + this.toBase64URL(signature);
445
384
  }
446
385
  }
447
-
448
- module.exports = XOAuth2;
386
+ export default XOAuth2;
@@ -107,7 +107,7 @@
107
107
 
108
108
  "FastMail": {
109
109
  "description": "FastMail",
110
- "domains": ["fastmail.fm"],
110
+ "domains": ["fastmail.com", "fastmail.fm"],
111
111
  "host": "smtp.fastmail.com",
112
112
  "port": 465,
113
113
  "secure": true
@@ -196,7 +196,7 @@
196
196
  "iCloud": {
197
197
  "description": "iCloud Mail",
198
198
  "aliases": ["Me", "Mac"],
199
- "domains": ["me.com", "mac.com"],
199
+ "domains": ["icloud.com", "me.com", "mac.com"],
200
200
  "host": "smtp.mail.me.com",
201
201
  "port": 587
202
202
  },
@@ -279,6 +279,13 @@
279
279
  "port": 25
280
280
  },
281
281
 
282
+ "MailSenpai": {
283
+ "description": "MailSenpai (SMTP Senpai, EU)",
284
+ "host": "relay.mailsenpai.com",
285
+ "port": 2525,
286
+ "secure": false
287
+ },
288
+
282
289
  "Mailtrap": {
283
290
  "description": "Mailtrap",
284
291
  "host": "live.smtp.mailtrap.io",
@@ -1 +1 @@
1
- {"name":"nodemailer","version":"9.1.1","description":"Easy as cake e-mail sending from your Node.js applications","main":"lib/nodemailer.js","scripts":{"test":"node --test --test-concurrency=1 $(find test \\( -name '*-test.js' -o -name '*.test.js' \\))","test:coverage":"c8 node --test --test-concurrency=1 $(find test \\( -name '*-test.js' -o -name '*.test.js' \\))","format":"prettier --write \"**/*.{js,json,md}\"","format:check":"prettier --check \"**/*.{js,json,md}\"","lint":"eslint .","lint:fix":"eslint . --fix","update":"rm -rf node_modules/ package-lock.json && ncu -u && npm install","test:syntax":"docker run --rm -v \"$PWD:/app:ro\" -w /app node:6-alpine node test/syntax-compat.js"},"repository":{"type":"git","url":"https://github.com/nodemailer/nodemailer.git"},"keywords":["Nodemailer"],"author":"Andris Reinman","license":"MIT-0","bugs":{"url":"https://github.com/nodemailer/nodemailer/issues"},"homepage":"https://nodemailer.com/","devDependencies":{"@aws-sdk/client-sesv2":"3.1121.0","bunyan":"1.8.15","c8":"12.0.0","eslint":"10.9.1","eslint-config-prettier":"10.1.8","globals":"17.11.0","libbase64":"1.3.0","libmime":"5.4.2","libqp":"2.1.1","prettier":"3.9.6","proxy":"1.0.2","proxy-test-server":"1.0.0","smtp-server":"3.19.4"},"engines":{"node":">=6.0.0"},"_lastModified":"2026-09-30T00:53:43.361Z"}
1
+ {"name":"nodemailer","version":"10.0.14","description":"Easy as cake e-mail sending from your Node.js applications","type":"module","main":"./dist/cjs/nodemailer.js","typesVersions":{"*":{"lib/well-known/services.json":["dist/well-known/services.json"],"lib/well-known/services":["dist/well-known/services.json"],"lib/*":["dist/cjs/*/index.d.ts","dist/cjs/*.d.ts"]}},"exports":{".":{"import":"./dist/esm/nodemailer.js","require":"./dist/cjs/nodemailer.js"},"./lib/addressparser":{"import":"./dist/esm/addressparser/index.js","require":"./dist/cjs/addressparser/index.js"},"./lib/base64":{"import":"./dist/esm/base64/index.js","require":"./dist/cjs/base64/index.js"},"./lib/dkim":{"import":"./dist/esm/dkim/index.js","require":"./dist/cjs/dkim/index.js"},"./lib/fetch":{"import":"./dist/esm/fetch/index.js","require":"./dist/cjs/fetch/index.js"},"./lib/json-transport":{"import":"./dist/esm/json-transport/index.js","require":"./dist/cjs/json-transport/index.js"},"./lib/mail-composer":{"import":"./dist/esm/mail-composer/index.js","require":"./dist/cjs/mail-composer/index.js"},"./lib/mailer":{"import":"./dist/esm/mailer/index.js","require":"./dist/cjs/mailer/index.js"},"./lib/mime-funcs":{"import":"./dist/esm/mime-funcs/index.js","require":"./dist/cjs/mime-funcs/index.js"},"./lib/mime-node":{"import":"./dist/esm/mime-node/index.js","require":"./dist/cjs/mime-node/index.js"},"./lib/punycode":{"import":"./dist/esm/punycode/index.js","require":"./dist/cjs/punycode/index.js"},"./lib/qp":{"import":"./dist/esm/qp/index.js","require":"./dist/cjs/qp/index.js"},"./lib/sendmail-transport":{"import":"./dist/esm/sendmail-transport/index.js","require":"./dist/cjs/sendmail-transport/index.js"},"./lib/ses-transport":{"import":"./dist/esm/ses-transport/index.js","require":"./dist/cjs/ses-transport/index.js"},"./lib/shared":{"import":"./dist/esm/shared/index.js","require":"./dist/cjs/shared/index.js"},"./lib/smtp-connection":{"import":"./dist/esm/smtp-connection/index.js","require":"./dist/cjs/smtp-connection/index.js"},"./lib/smtp-pool":{"import":"./dist/esm/smtp-pool/index.js","require":"./dist/cjs/smtp-pool/index.js"},"./lib/smtp-transport":{"import":"./dist/esm/smtp-transport/index.js","require":"./dist/cjs/smtp-transport/index.js"},"./lib/stream-transport":{"import":"./dist/esm/stream-transport/index.js","require":"./dist/cjs/stream-transport/index.js"},"./lib/well-known":{"import":"./dist/esm/well-known/index.js","require":"./dist/cjs/well-known/index.js"},"./lib/well-known/services.json":"./dist/well-known/services.json","./lib/well-known/services":"./dist/well-known/services.json","./lib/xoauth2":{"import":"./dist/esm/xoauth2/index.js","require":"./dist/cjs/xoauth2/index.js"},"./lib/*.js":{"import":"./dist/esm/*.js","require":"./dist/cjs/*.js"},"./lib/*":{"import":"./dist/esm/*.js","require":"./dist/cjs/*.js"},"./package.json":"./package.json"},"files":["dist","CHANGELOG.md","SECURITY.md","SECURITY.txt"],"scripts":{"build":"node scripts/build.js","typecheck":"node scripts/build.js --generate-only && tsc -p tsconfig.json","pretest":"npm run build","test":"node --import tsx --test --test-concurrency=1 $(find test \\( -name '*-test.ts' -o -name '*.test.ts' \\))","pretest:coverage":"npm run build","test:coverage":"c8 node --import tsx --test --test-concurrency=1 $(find test \\( -name '*-test.ts' -o -name '*.test.ts' \\))","pretest:bun":"npm run build","test:bun":"bun test --timeout 60000 $(find ./test \\( -name '*-test.ts' -o -name '*.test.ts' \\))","format":"prettier --write \"**/*.{js,cjs,ts,json,md}\"","format:check":"prettier --check \"**/*.{js,cjs,ts,json,md}\"","lint":"eslint . && npm run typecheck","lint:fix":"eslint . --fix","prepare":"npm run build","update":"rm -rf node_modules/ package-lock.json && ncu -u && npm install"},"repository":{"type":"git","url":"https://github.com/nodemailer/nodemailer.git"},"keywords":["Nodemailer"],"author":"Andris Reinman","license":"MIT-0","bugs":{"url":"https://github.com/nodemailer/nodemailer/issues"},"homepage":"https://nodemailer.com/","devDependencies":{"@aws-sdk/client-sesv2":"3.1146.0","@types/node":"20.19.43","bunyan":"1.8.15","c8":"12.0.0","eslint":"10.12.0","eslint-config-prettier":"10.1.8","globals":"17.13.0","libbase64":"1.3.1","libmime":"5.4.6","libqp":"2.1.2","mailauth":"7.1.0","prettier":"3.9.9","proxy":"1.0.2","proxy-test-server":"1.0.0","smtp-server":"3.19.16","tsx":"4.23.15","typescript":"6.0.3","typescript-eslint":"8.71.0"},"engines":{"node":">=20.0.0"},"_lastModified":"2026-10-12T01:55:54.427Z"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Send email in workflow.",
7
7
  "description.ru-RU": "Отправляет электронное письмо в рамках рабочего процесса.",
8
8
  "description.zh-CN": "可用于在工作流中发送电子邮件。",
9
- "version": "2.3.0-beta.13",
9
+ "version": "2.3.0-beta.14",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
@@ -15,7 +15,7 @@
15
15
  "devDependencies": {
16
16
  "antd": "5.x",
17
17
  "joi": "^17.13.6",
18
- "nodemailer": "^9.1.1",
18
+ "nodemailer": "~10.0.9",
19
19
  "react": "18.x"
20
20
  },
21
21
  "peerDependencies": {
@@ -27,7 +27,7 @@
27
27
  "@nocobase/server": "2.x",
28
28
  "@nocobase/test": "2.x"
29
29
  },
30
- "gitHead": "b453f04b0bc3bad1df905ab65f483baa4aa22d43",
30
+ "gitHead": "2e19a2924cd2452eaacb99c5ca3419e656ed89bc",
31
31
  "keywords": [
32
32
  "NocoBase",
33
33
  "Workflow",
@@ -1,6 +0,0 @@
1
- *.js text eol=lf
2
- *.txt text eol=lf
3
- *.html text eol=lf
4
- *.htm text eol=lf
5
- *.ics -text
6
- *.bin -text
@@ -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