@bobfrankston/mailx 1.0.12 → 1.0.13

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 (237) hide show
  1. package/bin/mailx.js +47 -29
  2. package/client/app.js +93 -13
  3. package/client/components/folder-tree.js +84 -3
  4. package/client/components/message-list.js +134 -8
  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 +33 -9
  9. package/client/lib/api-client.js +102 -30
  10. package/client/lib/mailxapi.js +123 -0
  11. package/client/package.json +1 -1
  12. package/client/styles/components.css +188 -15
  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.exe +0 -0
  17. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Breadcrumbs +0 -0
  18. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Crashpad/metadata +0 -0
  19. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Crashpad/settings.dat +0 -0
  20. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Crashpad/throttle_store.dat +1 -0
  21. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/CrashpadMetrics-active.pma +0 -0
  22. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/BrowsingTopicsSiteData +0 -0
  23. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Cache/No_Vary_Search/journal.baj +1 -0
  24. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/DIPS +0 -0
  25. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/DashTrackerDatabase +0 -0
  26. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/EdgeJourneys/EdgeJourneys.db +0 -0
  27. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Rules/LOCK +0 -0
  28. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Rules/LOG +3 -0
  29. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Rules/MANIFEST-000001 +0 -0
  30. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Scripts/LOCK +0 -0
  31. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Scripts/LOG +3 -0
  32. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Scripts/MANIFEST-000001 +0 -0
  33. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension State/LOCK +0 -0
  34. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension State/LOG +3 -0
  35. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension State/MANIFEST-000001 +0 -0
  36. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/ExtensionActivityComp +0 -0
  37. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/ExtensionActivityEdge +0 -0
  38. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Favicons +0 -0
  39. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/History +0 -0
  40. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/History-journal +0 -0
  41. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/IndexedDB/devtools_devtools_0.indexeddb.leveldb/LOCK +0 -0
  42. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/IndexedDB/devtools_devtools_0.indexeddb.leveldb/LOG +3 -0
  43. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/IndexedDB/devtools_devtools_0.indexeddb.leveldb/MANIFEST-000001 +0 -0
  44. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Local Storage/leveldb/LOCK +0 -0
  45. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Local Storage/leveldb/LOG +3 -0
  46. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Local Storage/leveldb/MANIFEST-000001 +0 -0
  47. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Login Data +0 -0
  48. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Login Data For Account +0 -0
  49. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Network/Cookies +0 -0
  50. NEL +0 -0
  51. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Network/Trust Tokens +0 -0
  52. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Network Action Predictor +0 -0
  53. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Preferences +1 -0
  54. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Safe Browsing Network/Safe Browsing Cookies +0 -0
  55. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/ServerCertificate +0 -0
  56. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Session Storage/LOCK +0 -0
  57. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Session Storage/LOG +3 -0
  58. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Session Storage/MANIFEST-000001 +0 -0
  59. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Shared Dictionary/db +0 -0
  60. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/SharedStorage +0 -0
  61. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Shortcuts +0 -0
  62. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Site Characteristics Database/LOCK +0 -0
  63. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Site Characteristics Database/LOG +3 -0
  64. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Site Characteristics Database/MANIFEST-000001 +0 -0
  65. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/LOCK +0 -0
  66. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/LOG +3 -0
  67. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/MANIFEST-000001 +0 -0
  68. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Top Sites +0 -0
  69. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Vpn Tokens +0 -0
  70. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Web Data +0 -0
  71. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Web Data-journal +0 -0
  72. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/WebStorage/QuotaManager +0 -0
  73. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/WebStorage/QuotaManager-journal +0 -0
  74. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/heavy_ad_intervention_opt_out.db +0 -0
  75. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/LOCK +0 -0
  76. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/LOG +3 -0
  77. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/MANIFEST-000001 +0 -0
  78. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/LOCK +0 -0
  79. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/LOG +3 -0
  80. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/MANIFEST-000001 +0 -0
  81. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/DeferredBrowserMetrics/BrowserMetrics-69CAD063-BE24.pma +0 -0
  82. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Local State +1 -0
  83. package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Variations +1 -0
  84. package/launcher/bin/mailx-app.old.exe +0 -0
  85. package/package.json +1 -1
  86. package/packages/mailx-api/index.js +79 -26
  87. package/packages/mailx-core/index.d.ts +129 -0
  88. package/packages/mailx-core/index.js +323 -0
  89. package/packages/mailx-core/ipc.d.ts +13 -0
  90. package/packages/mailx-core/ipc.js +56 -0
  91. package/packages/mailx-core/package.json +18 -0
  92. package/packages/mailx-imap/index.d.ts +5 -1
  93. package/packages/mailx-imap/index.js +76 -14
  94. package/packages/mailx-server/index.js +42 -31
  95. package/packages/mailx-server/package.json +1 -2
  96. package/packages/mailx-settings/index.d.ts +1 -1
  97. package/packages/mailx-settings/index.js +21 -12
  98. package/packages/mailx-store/db.d.ts +5 -1
  99. package/packages/mailx-store/db.js +64 -12
  100. package/packages/mailx-store/file-store.d.ts +2 -8
  101. package/packages/mailx-store/file-store.js +7 -31
  102. package/packages/mailx-types/index.d.ts +3 -1
  103. package/.tswalk.json +0 -7396
  104. package/launcher/release.cmd +0 -4
  105. package/mailx.json +0 -9
  106. package/packages/mailx-api/node_modules/nodemailer/.ncurc.js +0 -9
  107. package/packages/mailx-api/node_modules/nodemailer/.prettierignore +0 -8
  108. package/packages/mailx-api/node_modules/nodemailer/.prettierrc +0 -12
  109. package/packages/mailx-api/node_modules/nodemailer/.prettierrc.js +0 -10
  110. package/packages/mailx-api/node_modules/nodemailer/.release-please-config.json +0 -9
  111. package/packages/mailx-api/node_modules/nodemailer/LICENSE +0 -16
  112. package/packages/mailx-api/node_modules/nodemailer/README.md +0 -86
  113. package/packages/mailx-api/node_modules/nodemailer/SECURITY.txt +0 -22
  114. package/packages/mailx-api/node_modules/nodemailer/eslint.config.js +0 -88
  115. package/packages/mailx-api/node_modules/nodemailer/lib/addressparser/index.js +0 -383
  116. package/packages/mailx-api/node_modules/nodemailer/lib/base64/index.js +0 -139
  117. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/index.js +0 -253
  118. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  119. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  120. package/packages/mailx-api/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  121. package/packages/mailx-api/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  122. package/packages/mailx-api/node_modules/nodemailer/lib/fetch/index.js +0 -280
  123. package/packages/mailx-api/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  124. package/packages/mailx-api/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
  125. package/packages/mailx-api/node_modules/nodemailer/lib/mailer/index.js +0 -441
  126. package/packages/mailx-api/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
  127. package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  128. package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
  129. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
  130. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
  131. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
  132. package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
  133. package/packages/mailx-api/node_modules/nodemailer/lib/nodemailer.js +0 -157
  134. package/packages/mailx-api/node_modules/nodemailer/lib/punycode/index.js +0 -460
  135. package/packages/mailx-api/node_modules/nodemailer/lib/qp/index.js +0 -227
  136. package/packages/mailx-api/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  137. package/packages/mailx-api/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
  138. package/packages/mailx-api/node_modules/nodemailer/lib/shared/index.js +0 -754
  139. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  140. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  141. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
  142. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
  143. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
  144. package/packages/mailx-api/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
  145. package/packages/mailx-api/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  146. package/packages/mailx-api/node_modules/nodemailer/lib/well-known/index.js +0 -47
  147. package/packages/mailx-api/node_modules/nodemailer/lib/well-known/services.json +0 -611
  148. package/packages/mailx-api/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
  149. package/packages/mailx-api/node_modules/nodemailer/package.json +0 -47
  150. package/packages/mailx-imap/node_modules/nodemailer/.ncurc.js +0 -9
  151. package/packages/mailx-imap/node_modules/nodemailer/.prettierignore +0 -8
  152. package/packages/mailx-imap/node_modules/nodemailer/.prettierrc +0 -12
  153. package/packages/mailx-imap/node_modules/nodemailer/.prettierrc.js +0 -10
  154. package/packages/mailx-imap/node_modules/nodemailer/.release-please-config.json +0 -9
  155. package/packages/mailx-imap/node_modules/nodemailer/LICENSE +0 -16
  156. package/packages/mailx-imap/node_modules/nodemailer/README.md +0 -86
  157. package/packages/mailx-imap/node_modules/nodemailer/SECURITY.txt +0 -22
  158. package/packages/mailx-imap/node_modules/nodemailer/eslint.config.js +0 -88
  159. package/packages/mailx-imap/node_modules/nodemailer/lib/addressparser/index.js +0 -383
  160. package/packages/mailx-imap/node_modules/nodemailer/lib/base64/index.js +0 -139
  161. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/index.js +0 -253
  162. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  163. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  164. package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  165. package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  166. package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/index.js +0 -280
  167. package/packages/mailx-imap/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  168. package/packages/mailx-imap/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
  169. package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/index.js +0 -441
  170. package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
  171. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  172. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
  173. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
  174. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
  175. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
  176. package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
  177. package/packages/mailx-imap/node_modules/nodemailer/lib/nodemailer.js +0 -157
  178. package/packages/mailx-imap/node_modules/nodemailer/lib/punycode/index.js +0 -460
  179. package/packages/mailx-imap/node_modules/nodemailer/lib/qp/index.js +0 -227
  180. package/packages/mailx-imap/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  181. package/packages/mailx-imap/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
  182. package/packages/mailx-imap/node_modules/nodemailer/lib/shared/index.js +0 -754
  183. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  184. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  185. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
  186. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
  187. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
  188. package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
  189. package/packages/mailx-imap/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  190. package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/index.js +0 -47
  191. package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/services.json +0 -611
  192. package/packages/mailx-imap/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
  193. package/packages/mailx-imap/node_modules/nodemailer/package.json +0 -47
  194. package/packages/mailx-send/node_modules/nodemailer/.ncurc.js +0 -9
  195. package/packages/mailx-send/node_modules/nodemailer/.prettierignore +0 -8
  196. package/packages/mailx-send/node_modules/nodemailer/.prettierrc +0 -12
  197. package/packages/mailx-send/node_modules/nodemailer/.prettierrc.js +0 -10
  198. package/packages/mailx-send/node_modules/nodemailer/.release-please-config.json +0 -9
  199. package/packages/mailx-send/node_modules/nodemailer/LICENSE +0 -16
  200. package/packages/mailx-send/node_modules/nodemailer/README.md +0 -86
  201. package/packages/mailx-send/node_modules/nodemailer/SECURITY.txt +0 -22
  202. package/packages/mailx-send/node_modules/nodemailer/eslint.config.js +0 -88
  203. package/packages/mailx-send/node_modules/nodemailer/lib/addressparser/index.js +0 -383
  204. package/packages/mailx-send/node_modules/nodemailer/lib/base64/index.js +0 -139
  205. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/index.js +0 -253
  206. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  207. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  208. package/packages/mailx-send/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  209. package/packages/mailx-send/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  210. package/packages/mailx-send/node_modules/nodemailer/lib/fetch/index.js +0 -280
  211. package/packages/mailx-send/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  212. package/packages/mailx-send/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
  213. package/packages/mailx-send/node_modules/nodemailer/lib/mailer/index.js +0 -441
  214. package/packages/mailx-send/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
  215. package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  216. package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
  217. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
  218. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
  219. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
  220. package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
  221. package/packages/mailx-send/node_modules/nodemailer/lib/nodemailer.js +0 -157
  222. package/packages/mailx-send/node_modules/nodemailer/lib/punycode/index.js +0 -460
  223. package/packages/mailx-send/node_modules/nodemailer/lib/qp/index.js +0 -227
  224. package/packages/mailx-send/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  225. package/packages/mailx-send/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
  226. package/packages/mailx-send/node_modules/nodemailer/lib/shared/index.js +0 -754
  227. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  228. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  229. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
  230. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
  231. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
  232. package/packages/mailx-send/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
  233. package/packages/mailx-send/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  234. package/packages/mailx-send/node_modules/nodemailer/lib/well-known/index.js +0 -47
  235. package/packages/mailx-send/node_modules/nodemailer/lib/well-known/services.json +0 -611
  236. package/packages/mailx-send/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
  237. package/packages/mailx-send/node_modules/nodemailer/package.json +0 -47
@@ -1,117 +0,0 @@
1
- 'use strict';
2
-
3
- const punycode = require('../punycode');
4
- const mimeFuncs = require('../mime-funcs');
5
- const crypto = require('crypto');
6
-
7
- /**
8
- * Returns DKIM signature header line
9
- *
10
- * @param {Object} headers Parsed headers object from MessageParser
11
- * @param {String} bodyHash Base64 encoded hash of the message
12
- * @param {Object} options DKIM options
13
- * @param {String} options.domainName Domain name to be signed for
14
- * @param {String} options.keySelector DKIM key selector to use
15
- * @param {String} options.privateKey DKIM private key to use
16
- * @return {String} Complete header line
17
- */
18
-
19
- module.exports = (headers, hashAlgo, bodyHash, options) => {
20
- options = options || {};
21
-
22
- // all listed fields from RFC4871 #5.5
23
- let defaultFieldNames =
24
- 'From:Sender:Reply-To:Subject:Date:Message-ID:To:' +
25
- 'Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:' +
26
- 'Content-Description:Resent-Date:Resent-From:Resent-Sender:' +
27
- 'Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:' +
28
- 'List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:' +
29
- 'List-Owner:List-Archive';
30
-
31
- let fieldNames = options.headerFieldNames || defaultFieldNames;
32
-
33
- let canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields);
34
- let dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
35
-
36
- let signer, signature;
37
-
38
- canonicalizedHeaderData.headers += 'dkim-signature:' + relaxedHeaderLine(dkimHeader);
39
-
40
- signer = crypto.createSign(('rsa-' + hashAlgo).toUpperCase());
41
- signer.update(canonicalizedHeaderData.headers);
42
- try {
43
- signature = signer.sign(options.privateKey, 'base64');
44
- } catch (_E) {
45
- return false;
46
- }
47
-
48
- return dkimHeader + signature.replace(/(^.{73}|.{75}(?!\r?\n|\r))/g, '$&\r\n ').trim();
49
- };
50
-
51
- module.exports.relaxedHeaders = relaxedHeaders;
52
-
53
- function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyHash) {
54
- let dkim = [
55
- 'v=1',
56
- 'a=rsa-' + hashAlgo,
57
- 'c=relaxed/relaxed',
58
- 'd=' + punycode.toASCII(domainName),
59
- 'q=dns/txt',
60
- 's=' + keySelector,
61
- 'bh=' + bodyHash,
62
- 'h=' + fieldNames
63
- ].join('; ');
64
-
65
- return mimeFuncs.foldLines('DKIM-Signature: ' + dkim, 76) + ';\r\n b=';
66
- }
67
-
68
- function relaxedHeaders(headers, fieldNames, skipFields) {
69
- let includedFields = new Set();
70
- let skip = new Set();
71
- let headerFields = new Map();
72
-
73
- (skipFields || '')
74
- .toLowerCase()
75
- .split(':')
76
- .forEach(field => {
77
- skip.add(field.trim());
78
- });
79
-
80
- (fieldNames || '')
81
- .toLowerCase()
82
- .split(':')
83
- .filter(field => !skip.has(field.trim()))
84
- .forEach(field => {
85
- includedFields.add(field.trim());
86
- });
87
-
88
- for (let i = headers.length - 1; i >= 0; i--) {
89
- let line = headers[i];
90
- // only include the first value from bottom to top
91
- if (includedFields.has(line.key) && !headerFields.has(line.key)) {
92
- headerFields.set(line.key, relaxedHeaderLine(line.line));
93
- }
94
- }
95
-
96
- let headersList = [];
97
- let fields = [];
98
- includedFields.forEach(field => {
99
- if (headerFields.has(field)) {
100
- fields.push(field);
101
- headersList.push(field + ':' + headerFields.get(field));
102
- }
103
- });
104
-
105
- return {
106
- headers: headersList.join('\r\n') + '\r\n',
107
- fieldNames: fields.join(':')
108
- };
109
- }
110
-
111
- function relaxedHeaderLine(line) {
112
- return line
113
- .substr(line.indexOf(':') + 1)
114
- .replace(/\r?\n/g, '')
115
- .replace(/\s+/g, ' ')
116
- .trim();
117
- }
@@ -1,281 +0,0 @@
1
- 'use strict';
2
-
3
- // module to handle cookies
4
-
5
- const urllib = require('url');
6
-
7
- const SESSION_TIMEOUT = 1800; // 30 min
8
-
9
- /**
10
- * Creates a biskviit cookie jar for managing cookie values in memory
11
- *
12
- * @constructor
13
- * @param {Object} [options] Optional options object
14
- */
15
- class Cookies {
16
- constructor(options) {
17
- this.options = options || {};
18
- this.cookies = [];
19
- }
20
-
21
- /**
22
- * Stores a cookie string to the cookie storage
23
- *
24
- * @param {String} cookieStr Value from the 'Set-Cookie:' header
25
- * @param {String} url Current URL
26
- */
27
- set(cookieStr, url) {
28
- let urlparts = urllib.parse(url || '');
29
- let cookie = this.parse(cookieStr);
30
- let domain;
31
-
32
- if (cookie.domain) {
33
- domain = cookie.domain.replace(/^\./, '');
34
-
35
- // do not allow cross origin cookies
36
- if (
37
- // can't be valid if the requested domain is shorter than current hostname
38
- urlparts.hostname.length < domain.length ||
39
- // prefix domains with dot to be sure that partial matches are not used
40
- ('.' + urlparts.hostname).substr(-domain.length + 1) !== '.' + domain
41
- ) {
42
- cookie.domain = urlparts.hostname;
43
- }
44
- } else {
45
- cookie.domain = urlparts.hostname;
46
- }
47
-
48
- if (!cookie.path) {
49
- cookie.path = this.getPath(urlparts.pathname);
50
- }
51
-
52
- // if no expire date, then use sessionTimeout value
53
- if (!cookie.expires) {
54
- cookie.expires = new Date(Date.now() + (Number(this.options.sessionTimeout || SESSION_TIMEOUT) || SESSION_TIMEOUT) * 1000);
55
- }
56
-
57
- return this.add(cookie);
58
- }
59
-
60
- /**
61
- * Returns cookie string for the 'Cookie:' header.
62
- *
63
- * @param {String} url URL to check for
64
- * @returns {String} Cookie header or empty string if no matches were found
65
- */
66
- get(url) {
67
- return this.list(url)
68
- .map(cookie => cookie.name + '=' + cookie.value)
69
- .join('; ');
70
- }
71
-
72
- /**
73
- * Lists all valied cookie objects for the specified URL
74
- *
75
- * @param {String} url URL to check for
76
- * @returns {Array} An array of cookie objects
77
- */
78
- list(url) {
79
- let result = [];
80
- let i;
81
- let cookie;
82
-
83
- for (i = this.cookies.length - 1; i >= 0; i--) {
84
- cookie = this.cookies[i];
85
-
86
- if (this.isExpired(cookie)) {
87
- this.cookies.splice(i, i);
88
- continue;
89
- }
90
-
91
- if (this.match(cookie, url)) {
92
- result.unshift(cookie);
93
- }
94
- }
95
-
96
- return result;
97
- }
98
-
99
- /**
100
- * Parses cookie string from the 'Set-Cookie:' header
101
- *
102
- * @param {String} cookieStr String from the 'Set-Cookie:' header
103
- * @returns {Object} Cookie object
104
- */
105
- parse(cookieStr) {
106
- let cookie = {};
107
-
108
- (cookieStr || '')
109
- .toString()
110
- .split(';')
111
- .forEach(cookiePart => {
112
- let valueParts = cookiePart.split('=');
113
- let key = valueParts.shift().trim().toLowerCase();
114
- let value = valueParts.join('=').trim();
115
- let domain;
116
-
117
- if (!key) {
118
- // skip empty parts
119
- return;
120
- }
121
-
122
- switch (key) {
123
- case 'expires':
124
- value = new Date(value);
125
- // ignore date if can not parse it
126
- if (value.toString() !== 'Invalid Date') {
127
- cookie.expires = value;
128
- }
129
- break;
130
-
131
- case 'path':
132
- cookie.path = value;
133
- break;
134
-
135
- case 'domain':
136
- domain = value.toLowerCase();
137
- if (domain.length && domain.charAt(0) !== '.') {
138
- domain = '.' + domain; // ensure preceeding dot for user set domains
139
- }
140
- cookie.domain = domain;
141
- break;
142
-
143
- case 'max-age':
144
- cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000);
145
- break;
146
-
147
- case 'secure':
148
- cookie.secure = true;
149
- break;
150
-
151
- case 'httponly':
152
- cookie.httponly = true;
153
- break;
154
-
155
- default:
156
- if (!cookie.name) {
157
- cookie.name = key;
158
- cookie.value = value;
159
- }
160
- }
161
- });
162
-
163
- return cookie;
164
- }
165
-
166
- /**
167
- * Checks if a cookie object is valid for a specified URL
168
- *
169
- * @param {Object} cookie Cookie object
170
- * @param {String} url URL to check for
171
- * @returns {Boolean} true if cookie is valid for specifiec URL
172
- */
173
- match(cookie, url) {
174
- let urlparts = urllib.parse(url || '');
175
-
176
- // check if hostname matches
177
- // .foo.com also matches subdomains, foo.com does not
178
- if (
179
- urlparts.hostname !== cookie.domain &&
180
- (cookie.domain.charAt(0) !== '.' || ('.' + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)
181
- ) {
182
- return false;
183
- }
184
-
185
- // check if path matches
186
- let path = this.getPath(urlparts.pathname);
187
- if (path.substr(0, cookie.path.length) !== cookie.path) {
188
- return false;
189
- }
190
-
191
- // check secure argument
192
- if (cookie.secure && urlparts.protocol !== 'https:') {
193
- return false;
194
- }
195
-
196
- return true;
197
- }
198
-
199
- /**
200
- * Adds (or updates/removes if needed) a cookie object to the cookie storage
201
- *
202
- * @param {Object} cookie Cookie value to be stored
203
- */
204
- add(cookie) {
205
- let i;
206
- let len;
207
-
208
- // nothing to do here
209
- if (!cookie || !cookie.name) {
210
- return false;
211
- }
212
-
213
- // overwrite if has same params
214
- for (i = 0, len = this.cookies.length; i < len; i++) {
215
- if (this.compare(this.cookies[i], cookie)) {
216
- // check if the cookie needs to be removed instead
217
- if (this.isExpired(cookie)) {
218
- this.cookies.splice(i, 1); // remove expired/unset cookie
219
- return false;
220
- }
221
-
222
- this.cookies[i] = cookie;
223
- return true;
224
- }
225
- }
226
-
227
- // add as new if not already expired
228
- if (!this.isExpired(cookie)) {
229
- this.cookies.push(cookie);
230
- }
231
-
232
- return true;
233
- }
234
-
235
- /**
236
- * Checks if two cookie objects are the same
237
- *
238
- * @param {Object} a Cookie to check against
239
- * @param {Object} b Cookie to check against
240
- * @returns {Boolean} True, if the cookies are the same
241
- */
242
- compare(a, b) {
243
- return a.name === b.name && a.path === b.path && a.domain === b.domain && a.secure === b.secure && a.httponly === a.httponly;
244
- }
245
-
246
- /**
247
- * Checks if a cookie is expired
248
- *
249
- * @param {Object} cookie Cookie object to check against
250
- * @returns {Boolean} True, if the cookie is expired
251
- */
252
- isExpired(cookie) {
253
- return (cookie.expires && cookie.expires < new Date()) || !cookie.value;
254
- }
255
-
256
- /**
257
- * Returns normalized cookie path for an URL path argument
258
- *
259
- * @param {String} pathname
260
- * @returns {String} Normalized path
261
- */
262
- getPath(pathname) {
263
- let path = (pathname || '/').split('/');
264
- path.pop(); // remove filename part
265
- path = path.join('/').trim();
266
-
267
- // ensure path prefix /
268
- if (path.charAt(0) !== '/') {
269
- path = '/' + path;
270
- }
271
-
272
- // ensure path suffix /
273
- if (path.substr(-1) !== '/') {
274
- path += '/';
275
- }
276
-
277
- return path;
278
- }
279
- }
280
-
281
- module.exports = Cookies;
@@ -1,280 +0,0 @@
1
- 'use strict';
2
-
3
- const http = require('http');
4
- const https = require('https');
5
- const urllib = require('url');
6
- const zlib = require('zlib');
7
- const PassThrough = require('stream').PassThrough;
8
- const Cookies = require('./cookies');
9
- const packageData = require('../../package.json');
10
- const net = require('net');
11
-
12
- const MAX_REDIRECTS = 5;
13
-
14
- module.exports = function (url, options) {
15
- return nmfetch(url, options);
16
- };
17
-
18
- module.exports.Cookies = Cookies;
19
-
20
- function nmfetch(url, options) {
21
- options = options || {};
22
-
23
- options.fetchRes = options.fetchRes || new PassThrough();
24
- options.cookies = options.cookies || new Cookies();
25
- options.redirects = options.redirects || 0;
26
- options.maxRedirects = isNaN(options.maxRedirects) ? MAX_REDIRECTS : options.maxRedirects;
27
-
28
- if (options.cookie) {
29
- [].concat(options.cookie || []).forEach(cookie => {
30
- options.cookies.set(cookie, url);
31
- });
32
- options.cookie = false;
33
- }
34
-
35
- let fetchRes = options.fetchRes;
36
- let parsed = urllib.parse(url);
37
- let method = (options.method || '').toString().trim().toUpperCase() || 'GET';
38
- let finished = false;
39
- let cookies;
40
- let body;
41
-
42
- let handler = parsed.protocol === 'https:' ? https : http;
43
-
44
- let headers = {
45
- 'accept-encoding': 'gzip,deflate',
46
- 'user-agent': 'nodemailer/' + packageData.version
47
- };
48
-
49
- Object.keys(options.headers || {}).forEach(key => {
50
- headers[key.toLowerCase().trim()] = options.headers[key];
51
- });
52
-
53
- if (options.userAgent) {
54
- headers['user-agent'] = options.userAgent;
55
- }
56
-
57
- if (parsed.auth) {
58
- headers.Authorization = 'Basic ' + Buffer.from(parsed.auth).toString('base64');
59
- }
60
-
61
- if ((cookies = options.cookies.get(url))) {
62
- headers.cookie = cookies;
63
- }
64
-
65
- if (options.body) {
66
- if (options.contentType !== false) {
67
- headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded';
68
- }
69
-
70
- if (typeof options.body.pipe === 'function') {
71
- // it's a stream
72
- headers['Transfer-Encoding'] = 'chunked';
73
- body = options.body;
74
- body.on('error', err => {
75
- if (finished) {
76
- return;
77
- }
78
- finished = true;
79
- err.type = 'FETCH';
80
- err.sourceUrl = url;
81
- fetchRes.emit('error', err);
82
- });
83
- } else {
84
- if (options.body instanceof Buffer) {
85
- body = options.body;
86
- } else if (typeof options.body === 'object') {
87
- try {
88
- // encodeURIComponent can fail on invalid input (partial emoji etc.)
89
- body = Buffer.from(
90
- Object.keys(options.body)
91
- .map(key => {
92
- let value = options.body[key].toString().trim();
93
- return encodeURIComponent(key) + '=' + encodeURIComponent(value);
94
- })
95
- .join('&')
96
- );
97
- } catch (E) {
98
- if (finished) {
99
- return;
100
- }
101
- finished = true;
102
- E.type = 'FETCH';
103
- E.sourceUrl = url;
104
- fetchRes.emit('error', E);
105
- return;
106
- }
107
- } else {
108
- body = Buffer.from(options.body.toString().trim());
109
- }
110
-
111
- headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded';
112
- headers['Content-Length'] = body.length;
113
- }
114
- // if method is not provided, use POST instead of GET
115
- method = (options.method || '').toString().trim().toUpperCase() || 'POST';
116
- }
117
-
118
- let req;
119
- let reqOptions = {
120
- method,
121
- host: parsed.hostname,
122
- path: parsed.path,
123
- port: parsed.port ? parsed.port : parsed.protocol === 'https:' ? 443 : 80,
124
- headers,
125
- rejectUnauthorized: false,
126
- agent: false
127
- };
128
-
129
- if (options.tls) {
130
- Object.keys(options.tls).forEach(key => {
131
- reqOptions[key] = options.tls[key];
132
- });
133
- }
134
-
135
- if (
136
- parsed.protocol === 'https:' &&
137
- parsed.hostname &&
138
- parsed.hostname !== reqOptions.host &&
139
- !net.isIP(parsed.hostname) &&
140
- !reqOptions.servername
141
- ) {
142
- reqOptions.servername = parsed.hostname;
143
- }
144
-
145
- try {
146
- req = handler.request(reqOptions);
147
- } catch (E) {
148
- finished = true;
149
- setImmediate(() => {
150
- E.type = 'FETCH';
151
- E.sourceUrl = url;
152
- fetchRes.emit('error', E);
153
- });
154
- return fetchRes;
155
- }
156
-
157
- if (options.timeout) {
158
- req.setTimeout(options.timeout, () => {
159
- if (finished) {
160
- return;
161
- }
162
- finished = true;
163
- req.abort();
164
- let err = new Error('Request Timeout');
165
- err.type = 'FETCH';
166
- err.sourceUrl = url;
167
- fetchRes.emit('error', err);
168
- });
169
- }
170
-
171
- req.on('error', err => {
172
- if (finished) {
173
- return;
174
- }
175
- finished = true;
176
- err.type = 'FETCH';
177
- err.sourceUrl = url;
178
- fetchRes.emit('error', err);
179
- });
180
-
181
- req.on('response', res => {
182
- let inflate;
183
-
184
- if (finished) {
185
- return;
186
- }
187
-
188
- switch (res.headers['content-encoding']) {
189
- case 'gzip':
190
- case 'deflate':
191
- inflate = zlib.createUnzip();
192
- break;
193
- }
194
-
195
- if (res.headers['set-cookie']) {
196
- [].concat(res.headers['set-cookie'] || []).forEach(cookie => {
197
- options.cookies.set(cookie, url);
198
- });
199
- }
200
-
201
- if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
202
- // redirect
203
- options.redirects++;
204
- if (options.redirects > options.maxRedirects) {
205
- finished = true;
206
- let err = new Error('Maximum redirect count exceeded');
207
- err.type = 'FETCH';
208
- err.sourceUrl = url;
209
- fetchRes.emit('error', err);
210
- req.abort();
211
- return;
212
- }
213
- // redirect does not include POST body
214
- options.method = 'GET';
215
- options.body = false;
216
- return nmfetch(urllib.resolve(url, res.headers.location), options);
217
- }
218
-
219
- fetchRes.statusCode = res.statusCode;
220
- fetchRes.headers = res.headers;
221
-
222
- if (res.statusCode >= 300 && !options.allowErrorResponse) {
223
- finished = true;
224
- let err = new Error('Invalid status code ' + res.statusCode);
225
- err.type = 'FETCH';
226
- err.sourceUrl = url;
227
- fetchRes.emit('error', err);
228
- req.abort();
229
- return;
230
- }
231
-
232
- res.on('error', err => {
233
- if (finished) {
234
- return;
235
- }
236
- finished = true;
237
- err.type = 'FETCH';
238
- err.sourceUrl = url;
239
- fetchRes.emit('error', err);
240
- req.abort();
241
- });
242
-
243
- if (inflate) {
244
- res.pipe(inflate).pipe(fetchRes);
245
- inflate.on('error', err => {
246
- if (finished) {
247
- return;
248
- }
249
- finished = true;
250
- err.type = 'FETCH';
251
- err.sourceUrl = url;
252
- fetchRes.emit('error', err);
253
- req.abort();
254
- });
255
- } else {
256
- res.pipe(fetchRes);
257
- }
258
- });
259
-
260
- setImmediate(() => {
261
- if (body) {
262
- try {
263
- if (typeof body.pipe === 'function') {
264
- return body.pipe(req);
265
- } else {
266
- req.write(body);
267
- }
268
- } catch (err) {
269
- finished = true;
270
- err.type = 'FETCH';
271
- err.sourceUrl = url;
272
- fetchRes.emit('error', err);
273
- return;
274
- }
275
- }
276
- req.end();
277
- });
278
-
279
- return fetchRes;
280
- }