@nocobase/plugin-workflow-mailer 2.2.20 → 2.2.21

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
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Nodemailer Error Codes
3
+ *
4
+ * Centralized error code definitions for consistent error handling.
5
+ *
6
+ * Usage:
7
+ * import * as errors from './errors.js';
8
+ * const err: NodemailerError = new Error('Connection closed');
9
+ * err.code = errors.ECONNECTION;
10
+ */
11
+ /**
12
+ * Error code descriptions for documentation and debugging
13
+ */
14
+ export declare const ERROR_CODES: {
15
+ readonly ECONNECTION: "Connection closed unexpectedly";
16
+ readonly ETIMEDOUT: "Connection or operation timed out";
17
+ readonly ESOCKET: "Socket-level error";
18
+ readonly EDNS: "DNS resolution failed";
19
+ readonly ETLS: "TLS handshake or STARTTLS failed";
20
+ readonly EREQUIRETLS: "REQUIRETLS not supported by server (RFC 8689)";
21
+ readonly EPROTOCOL: "Invalid SMTP server response";
22
+ readonly EENVELOPE: "Invalid mail envelope (sender or recipients)";
23
+ readonly EMESSAGE: "Message delivery error";
24
+ readonly ESTREAM: "Stream processing error";
25
+ readonly EAUTH: "Authentication failed";
26
+ readonly ENOAUTH: "Authentication credentials not provided";
27
+ readonly EOAUTH2: "OAuth2 token generation or refresh error";
28
+ readonly EMAXLIMIT: "Pool resource limit reached (max messages per connection)";
29
+ readonly EMAXRECIPIENTS: "Recipient count exceeds maxRecipients";
30
+ readonly ESENDMAIL: "Sendmail command error";
31
+ readonly ESES: "AWS SES transport error";
32
+ readonly ECONFIG: "Invalid configuration";
33
+ readonly EPROXY: "Proxy connection error";
34
+ readonly EFILEACCESS: "File access rejected (disableFileAccess is set)";
35
+ readonly EURLACCESS: "URL access rejected (disableUrlAccess is set)";
36
+ readonly EFETCH: "HTTP fetch error";
37
+ };
38
+ /**
39
+ * Union of all known Nodemailer error codes
40
+ */
41
+ export type ErrorCode = keyof typeof ERROR_CODES;
42
+ export declare const ECONNECTION = "ECONNECTION";
43
+ export declare const ETIMEDOUT = "ETIMEDOUT";
44
+ export declare const ESOCKET = "ESOCKET";
45
+ export declare const EDNS = "EDNS";
46
+ export declare const ETLS = "ETLS";
47
+ export declare const EREQUIRETLS = "EREQUIRETLS";
48
+ export declare const EPROTOCOL = "EPROTOCOL";
49
+ export declare const EENVELOPE = "EENVELOPE";
50
+ export declare const EMESSAGE = "EMESSAGE";
51
+ export declare const ESTREAM = "ESTREAM";
52
+ export declare const EAUTH = "EAUTH";
53
+ export declare const ENOAUTH = "ENOAUTH";
54
+ export declare const EOAUTH2 = "EOAUTH2";
55
+ export declare const EMAXLIMIT = "EMAXLIMIT";
56
+ export declare const EMAXRECIPIENTS = "EMAXRECIPIENTS";
57
+ export declare const ESENDMAIL = "ESENDMAIL";
58
+ export declare const ESES = "ESES";
59
+ export declare const ECONFIG = "ECONFIG";
60
+ export declare const EPROXY = "EPROXY";
61
+ export declare const EFILEACCESS = "EFILEACCESS";
62
+ export declare const EURLACCESS = "EURLACCESS";
63
+ export declare const EFETCH = "EFETCH";
64
+ /**
65
+ * An Error together with the properties Nodemailer attaches to the errors it
66
+ * hands to callers. Every property is optional, the set that is present
67
+ * depends on where the error originated. Socket level errors keep the errno
68
+ * and syscall fields Node.js sets on them.
69
+ */
70
+ export interface NodemailerError extends NodeJS.ErrnoException {
71
+ /** Nodemailer error code, see ERROR_CODES */
72
+ code?: string | undefined;
73
+ /** SMTP command that was in flight when the server replied with an error */
74
+ command?: string | undefined;
75
+ /** Raw SMTP server response */
76
+ response?: string | undefined;
77
+ /** Numeric SMTP response code */
78
+ responseCode?: number | undefined;
79
+ /** URL of the resource that could not be fetched */
80
+ sourceUrl?: string | undefined;
81
+ /** Recipient address the error applies to */
82
+ recipient?: string | undefined;
83
+ /** Recipient addresses rejected by the server */
84
+ rejected?: string[] | undefined;
85
+ /** Per-recipient errors for the rejected addresses */
86
+ rejectedErrors?: NodemailerError[] | undefined;
87
+ }
88
+ /**
89
+ * Node style callback: called with an error, or with null and the result
90
+ */
91
+ export type Callback<T> = (err: NodemailerError | null, result: T) => void;
92
+ /**
93
+ * Callback as the library calls it on its error paths: with an error alone, or with null and
94
+ * the result. The public signatures use Callback, internally the error paths cast to this
95
+ */
96
+ export type ResultCallback<T> = (err: NodemailerError | null, result?: T) => void;
@@ -1,49 +1,40 @@
1
- 'use strict';
2
-
3
1
  /**
4
2
  * Nodemailer Error Codes
5
3
  *
6
4
  * Centralized error code definitions for consistent error handling.
7
5
  *
8
6
  * Usage:
9
- * const errors = require('./errors');
10
- * let err = new Error('Connection closed');
7
+ * import * as errors from './errors.js';
8
+ * const err: NodemailerError = new Error('Connection closed');
11
9
  * err.code = errors.ECONNECTION;
12
10
  */
13
-
14
11
  /**
15
12
  * Error code descriptions for documentation and debugging
16
13
  */
17
- const ERROR_CODES = {
14
+ export const ERROR_CODES = {
18
15
  // Connection errors
19
16
  ECONNECTION: 'Connection closed unexpectedly',
20
17
  ETIMEDOUT: 'Connection or operation timed out',
21
18
  ESOCKET: 'Socket-level error',
22
19
  EDNS: 'DNS resolution failed',
23
-
24
20
  // TLS/Security errors
25
21
  ETLS: 'TLS handshake or STARTTLS failed',
26
22
  EREQUIRETLS: 'REQUIRETLS not supported by server (RFC 8689)',
27
-
28
23
  // Protocol errors
29
24
  EPROTOCOL: 'Invalid SMTP server response',
30
25
  EENVELOPE: 'Invalid mail envelope (sender or recipients)',
31
26
  EMESSAGE: 'Message delivery error',
32
27
  ESTREAM: 'Stream processing error',
33
-
34
28
  // Authentication errors
35
29
  EAUTH: 'Authentication failed',
36
30
  ENOAUTH: 'Authentication credentials not provided',
37
31
  EOAUTH2: 'OAuth2 token generation or refresh error',
38
-
39
32
  // Resource errors
40
33
  EMAXLIMIT: 'Pool resource limit reached (max messages per connection)',
41
34
  EMAXRECIPIENTS: 'Recipient count exceeds maxRecipients',
42
-
43
35
  // Transport-specific errors
44
36
  ESENDMAIL: 'Sendmail command error',
45
37
  ESES: 'AWS SES transport error',
46
-
47
38
  // Configuration and access errors
48
39
  ECONFIG: 'Invalid configuration',
49
40
  EPROXY: 'Proxy connection error',
@@ -51,9 +42,26 @@ const ERROR_CODES = {
51
42
  EURLACCESS: 'URL access rejected (disableUrlAccess is set)',
52
43
  EFETCH: 'HTTP fetch error'
53
44
  };
54
-
55
- // Export error codes as string constants and the full definitions object
56
- module.exports = { ERROR_CODES };
57
- for (const code of Object.keys(ERROR_CODES)) {
58
- module.exports[code] = code;
59
- }
45
+ // Error codes as string constants
46
+ export const ECONNECTION = 'ECONNECTION';
47
+ export const ETIMEDOUT = 'ETIMEDOUT';
48
+ export const ESOCKET = 'ESOCKET';
49
+ export const EDNS = 'EDNS';
50
+ export const ETLS = 'ETLS';
51
+ export const EREQUIRETLS = 'EREQUIRETLS';
52
+ export const EPROTOCOL = 'EPROTOCOL';
53
+ export const EENVELOPE = 'EENVELOPE';
54
+ export const EMESSAGE = 'EMESSAGE';
55
+ export const ESTREAM = 'ESTREAM';
56
+ export const EAUTH = 'EAUTH';
57
+ export const ENOAUTH = 'ENOAUTH';
58
+ export const EOAUTH2 = 'EOAUTH2';
59
+ export const EMAXLIMIT = 'EMAXLIMIT';
60
+ export const EMAXRECIPIENTS = 'EMAXRECIPIENTS';
61
+ export const ESENDMAIL = 'ESENDMAIL';
62
+ export const ESES = 'ESES';
63
+ export const ECONFIG = 'ECONFIG';
64
+ export const EPROXY = 'EPROXY';
65
+ export const EFILEACCESS = 'EFILEACCESS';
66
+ export const EURLACCESS = 'EURLACCESS';
67
+ export const EFETCH = 'EFETCH';
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Options for the Cookies jar
3
+ */
4
+ export interface CookiesOptions {
5
+ /** Lifetime in seconds for cookies that do not set their own expiration (default 1800) */
6
+ sessionTimeout?: number | string | undefined;
7
+ }
8
+ /**
9
+ * A cookie as parsed from a 'Set-Cookie:' header and kept in the jar
10
+ */
11
+ export interface Cookie {
12
+ name?: string | undefined;
13
+ value?: string | undefined;
14
+ domain?: string | undefined;
15
+ path?: string | undefined;
16
+ expires?: Date | undefined;
17
+ secure?: boolean | undefined;
18
+ httponly?: boolean | undefined;
19
+ }
20
+ type CookieEntry = Cookie;
21
+ /**
22
+ * Creates a biskviit cookie jar for managing cookie values in memory
23
+ *
24
+ * @constructor
25
+ * @param [options] Optional options object
26
+ */
27
+ declare class Cookies {
28
+ options: CookiesOptions;
29
+ cookies: Cookie[];
30
+ constructor(options?: CookiesOptions);
31
+ /**
32
+ * Stores a cookie string to the cookie storage
33
+ *
34
+ * @param cookieStr Value from the 'Set-Cookie:' header
35
+ * @param url Current URL
36
+ */
37
+ set(cookieStr: string, url?: string): boolean;
38
+ /**
39
+ * Returns cookie string for the 'Cookie:' header.
40
+ *
41
+ * @param url URL to check for
42
+ * @returns Cookie header or empty string if no matches were found
43
+ */
44
+ get(url?: string): string;
45
+ /**
46
+ * Lists all valied cookie objects for the specified URL
47
+ *
48
+ * @param url URL to check for
49
+ * @returns An array of cookie objects
50
+ */
51
+ list(url?: string): Cookie[];
52
+ /**
53
+ * Parses cookie string from the 'Set-Cookie:' header
54
+ *
55
+ * @param cookieStr String from the 'Set-Cookie:' header
56
+ * @returns Cookie object
57
+ */
58
+ parse(cookieStr?: string): Cookie;
59
+ /**
60
+ * Checks if a cookie object is valid for a specified URL
61
+ *
62
+ * @param cookie Cookie object
63
+ * @param url URL to check for
64
+ * @returns true if cookie is valid for specifiec URL
65
+ */
66
+ match(cookie: Cookie, url?: string): boolean;
67
+ /**
68
+ * Adds (or updates/removes if needed) a cookie object to the cookie storage
69
+ *
70
+ * @param cookie Cookie value to be stored
71
+ */
72
+ add(cookie: Cookie): boolean;
73
+ /**
74
+ * Checks if two cookie objects are the same
75
+ *
76
+ * @param a Cookie to check against
77
+ * @param b Cookie to check against
78
+ * @returns True, if the cookies are the same
79
+ */
80
+ compare(a: Cookie, b: Cookie): boolean;
81
+ /**
82
+ * Checks if a cookie is expired
83
+ *
84
+ * @param cookie Cookie object to check against
85
+ * @returns True, if the cookie is expired
86
+ */
87
+ isExpired(cookie: Cookie): boolean;
88
+ /**
89
+ * Returns the default path for an URL path argument, the default-path of
90
+ * RFC 6265 section 5.1.4. A cookie that carries no Path attribute is scoped
91
+ * to the directory of the URL it was set from
92
+ *
93
+ * @param pathname
94
+ * @returns Default path
95
+ */
96
+ getPath(pathname?: string | null): string;
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;
@@ -0,0 +1,242 @@
1
+ // module to handle cookies
2
+ import net from 'node:net';
3
+ import * as urllib from '../shared/url.js';
4
+ const SESSION_TIMEOUT = 1800; // 30 min
5
+ /**
6
+ * Creates a biskviit cookie jar for managing cookie values in memory
7
+ *
8
+ * @constructor
9
+ * @param [options] Optional options object
10
+ */
11
+ class Cookies {
12
+ constructor(options) {
13
+ this.options = options || {};
14
+ this.cookies = [];
15
+ }
16
+ /**
17
+ * Stores a cookie string to the cookie storage
18
+ *
19
+ * @param cookieStr Value from the 'Set-Cookie:' header
20
+ * @param url Current URL
21
+ */
22
+ set(cookieStr, url) {
23
+ const urlparts = urllib.parse(url || '');
24
+ const cookie = this.parse(cookieStr);
25
+ let domain;
26
+ if (cookie.domain) {
27
+ domain = cookie.domain.replace(/^\./, '');
28
+ // do not allow cross origin cookies. There is no public suffix list here, so a
29
+ // multi-label suffix like 'co.uk' can not be told apart from a registrable domain
30
+ if (
31
+ // can't be valid if the requested domain is shorter than current hostname
32
+ urlparts.hostname.length < domain.length ||
33
+ // a top level domain is not a valid scope, 'Domain=com' would otherwise be
34
+ // sent to every .com host. A trailing dot does not make 'com.' any better
35
+ domain.indexOf('.') < 0 ||
36
+ domain.endsWith('.') ||
37
+ // an IP address has no subdomains, so cookies set on it stay host-only
38
+ net.isIP(urlparts.hostname) ||
39
+ // prefix domains with dot to be sure that partial matches are not used
40
+ !('.' + urlparts.hostname).endsWith('.' + domain)) {
41
+ cookie.domain = urlparts.hostname;
42
+ }
43
+ }
44
+ else {
45
+ cookie.domain = urlparts.hostname;
46
+ }
47
+ if (!cookie.path) {
48
+ cookie.path = this.getPath(urlparts.pathname);
49
+ }
50
+ // if no expire date, then use sessionTimeout value
51
+ if (!cookie.expires) {
52
+ cookie.expires = new Date(Date.now() + (Number(this.options.sessionTimeout || SESSION_TIMEOUT) || SESSION_TIMEOUT) * 1000);
53
+ }
54
+ return this.add(cookie);
55
+ }
56
+ /**
57
+ * Returns cookie string for the 'Cookie:' header.
58
+ *
59
+ * @param url URL to check for
60
+ * @returns Cookie header or empty string if no matches were found
61
+ */
62
+ get(url) {
63
+ return this.list(url)
64
+ .map(cookie => cookie.name + '=' + cookie.value)
65
+ .join('; ');
66
+ }
67
+ /**
68
+ * Lists all valied cookie objects for the specified URL
69
+ *
70
+ * @param url URL to check for
71
+ * @returns An array of cookie objects
72
+ */
73
+ list(url) {
74
+ const result = [];
75
+ for (let i = this.cookies.length - 1; i >= 0; i--) {
76
+ const cookie = this.cookies[i];
77
+ if (this.isExpired(cookie)) {
78
+ this.cookies.splice(i, 1);
79
+ continue;
80
+ }
81
+ if (this.match(cookie, url)) {
82
+ result.unshift(cookie);
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+ /**
88
+ * Parses cookie string from the 'Set-Cookie:' header
89
+ *
90
+ * @param cookieStr String from the 'Set-Cookie:' header
91
+ * @returns Cookie object
92
+ */
93
+ parse(cookieStr) {
94
+ const cookie = {};
95
+ (cookieStr || '')
96
+ .toString()
97
+ .split(';')
98
+ .forEach(cookiePart => {
99
+ const valueParts = cookiePart.split('=');
100
+ const key = valueParts.shift().trim().toLowerCase();
101
+ let value = valueParts.join('=').trim();
102
+ let domain;
103
+ if (!key) {
104
+ // skip empty parts
105
+ return;
106
+ }
107
+ switch (key) {
108
+ case 'expires': {
109
+ const expires = new Date(value);
110
+ // ignore date if can not parse it
111
+ if (expires.toString() !== 'Invalid Date') {
112
+ cookie.expires = expires;
113
+ }
114
+ break;
115
+ }
116
+ case 'path':
117
+ cookie.path = value;
118
+ break;
119
+ case 'domain':
120
+ domain = value.toLowerCase();
121
+ if (domain.length && domain.charAt(0) !== '.') {
122
+ domain = '.' + domain; // ensure preceeding dot for user set domains
123
+ }
124
+ cookie.domain = domain;
125
+ break;
126
+ case 'max-age':
127
+ cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000);
128
+ break;
129
+ case 'secure':
130
+ cookie.secure = true;
131
+ break;
132
+ case 'httponly':
133
+ cookie.httponly = true;
134
+ break;
135
+ default:
136
+ if (!cookie.name) {
137
+ cookie.name = key;
138
+ cookie.value = value;
139
+ }
140
+ }
141
+ });
142
+ return cookie;
143
+ }
144
+ /**
145
+ * Checks if a cookie object is valid for a specified URL
146
+ *
147
+ * @param cookie Cookie object
148
+ * @param url URL to check for
149
+ * @returns true if cookie is valid for specifiec URL
150
+ */
151
+ match(cookie, url) {
152
+ const urlparts = urllib.parse(url || '');
153
+ // check if hostname matches
154
+ // .foo.com also matches subdomains, foo.com does not
155
+ if (urlparts.hostname !== cookie.domain &&
156
+ (cookie.domain.charAt(0) !== '.' ||
157
+ ('.' + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)) {
158
+ return false;
159
+ }
160
+ // check if the request path path-matches the cookie path (RFC 6265 section 5.1.4):
161
+ // identical paths match, otherwise the cookie path must be a directory prefix
162
+ const pathname = urlparts.pathname || '/';
163
+ const cookiePath = cookie.path;
164
+ const pathMatches = pathname === cookiePath ||
165
+ (pathname.startsWith(cookiePath) && (cookiePath.endsWith('/') || pathname.charAt(cookiePath.length) === '/'));
166
+ if (!pathMatches) {
167
+ return false;
168
+ }
169
+ // check secure argument
170
+ if (cookie.secure && urlparts.protocol !== 'https:') {
171
+ return false;
172
+ }
173
+ return true;
174
+ }
175
+ /**
176
+ * Adds (or updates/removes if needed) a cookie object to the cookie storage
177
+ *
178
+ * @param cookie Cookie value to be stored
179
+ */
180
+ add(cookie) {
181
+ // nothing to do here
182
+ if (!cookie || !cookie.name) {
183
+ return false;
184
+ }
185
+ // overwrite if has same params
186
+ for (let i = 0, len = this.cookies.length; i < len; i++) {
187
+ if (this.compare(this.cookies[i], cookie)) {
188
+ // check if the cookie needs to be removed instead
189
+ if (this.isExpired(cookie)) {
190
+ this.cookies.splice(i, 1); // remove expired/unset cookie
191
+ return false;
192
+ }
193
+ this.cookies[i] = cookie;
194
+ return true;
195
+ }
196
+ }
197
+ // add as new if not already expired
198
+ if (!this.isExpired(cookie)) {
199
+ this.cookies.push(cookie);
200
+ }
201
+ return true;
202
+ }
203
+ /**
204
+ * Checks if two cookie objects are the same
205
+ *
206
+ * @param a Cookie to check against
207
+ * @param b Cookie to check against
208
+ * @returns True, if the cookies are the same
209
+ */
210
+ compare(a, b) {
211
+ return a.name === b.name && a.path === b.path && a.domain === b.domain && a.secure === b.secure && a.httponly === b.httponly;
212
+ }
213
+ /**
214
+ * Checks if a cookie is expired
215
+ *
216
+ * @param cookie Cookie object to check against
217
+ * @returns True, if the cookie is expired
218
+ */
219
+ isExpired(cookie) {
220
+ return (cookie.expires && cookie.expires < new Date()) || !cookie.value;
221
+ }
222
+ /**
223
+ * Returns the default path for an URL path argument, the default-path of
224
+ * RFC 6265 section 5.1.4. A cookie that carries no Path attribute is scoped
225
+ * to the directory of the URL it was set from
226
+ *
227
+ * @param pathname
228
+ * @returns Default path
229
+ */
230
+ getPath(pathname) {
231
+ const pathParts = (pathname || '/').split('/');
232
+ pathParts.pop(); // remove filename part
233
+ const path = pathParts.join('/').trim();
234
+ // a path that holds no more than one '/' is scoped to the root path, and so
235
+ // is one that does not start with '/' at all
236
+ if (path.charAt(0) !== '/') {
237
+ return '/';
238
+ }
239
+ return path;
240
+ }
241
+ }
242
+ export default Cookies;
@@ -0,0 +1,65 @@
1
+ import http from 'node:http';
2
+ import { PassThrough, type Readable } from 'node:stream';
3
+ import Cookies from './cookies.js';
4
+ /**
5
+ * Options for nmfetch
6
+ */
7
+ export interface FetchOptions {
8
+ /** HTTP method, defaults to GET, or to POST when a body is given */
9
+ method?: string | undefined;
10
+ /** Request headers, keys are lowercased before use */
11
+ headers?: http.OutgoingHttpHeaders | undefined;
12
+ /** Overrides the default User-Agent header */
13
+ userAgent?: string | undefined;
14
+ /** Cookie string(s) to seed the cookie jar with for this URL */
15
+ cookie?: string | string[] | false | undefined;
16
+ /** Cookie jar shared across redirects, created when missing */
17
+ cookies?: Cookies | undefined;
18
+ /** Request body: a readable stream, a Buffer, a form object or a string */
19
+ body?: Readable | Buffer | {
20
+ [key: string]: any;
21
+ } | string | false | undefined;
22
+ /** Content-Type header for the body, false leaves it out for a stream body */
23
+ contentType?: string | false | undefined;
24
+ /** TLS settings, only the keys listed in TLS_OPTION_KEYS are used */
25
+ tls?: {
26
+ [key: string]: any;
27
+ } | undefined;
28
+ /** Socket inactivity timeout in milliseconds, defaults to 60000, 0 disables it */
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;
32
+ /** Maximum number of redirects to follow (default 5) */
33
+ maxRedirects?: number | undefined;
34
+ /** Resolve responses with a status code of 300 or above instead of emitting an error */
35
+ allowErrorResponse?: boolean | undefined;
36
+ /** Redirects followed so far, set by nmfetch itself */
37
+ redirects?: number | undefined;
38
+ /** Response stream shared across redirects, set by nmfetch itself */
39
+ fetchRes?: FetchResponse | undefined;
40
+ }
41
+ /**
42
+ * The stream nmfetch returns. The response body is piped into it, the status code and
43
+ * headers of the final response are attached once they arrive
44
+ */
45
+ export interface FetchResponse extends PassThrough {
46
+ statusCode?: number | undefined;
47
+ headers?: http.IncomingHttpHeaders | undefined;
48
+ }
49
+ declare function nmfetch(url: string, options?: FetchOptions): FetchResponse;
50
+ declare namespace nmfetch {
51
+ var Cookies: typeof import("./cookies.js").default;
52
+ var DEFAULT_TIMEOUT: number;
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 };
65
+ export default nmfetch;