@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,139 +0,0 @@
1
- 'use strict';
2
-
3
- const Transform = require('stream').Transform;
4
-
5
- /**
6
- * Encodes a Buffer into a base64 encoded string
7
- *
8
- * @param {Buffer} buffer Buffer to convert
9
- * @returns {String} base64 encoded string
10
- */
11
- function encode(buffer) {
12
- if (typeof buffer === 'string') {
13
- buffer = Buffer.from(buffer, 'utf-8');
14
- }
15
-
16
- return buffer.toString('base64');
17
- }
18
-
19
- /**
20
- * Adds soft line breaks to a base64 string
21
- *
22
- * @param {String} str base64 encoded string that might need line wrapping
23
- * @param {Number} [lineLength=76] Maximum allowed length for a line
24
- * @returns {String} Soft-wrapped base64 encoded string
25
- */
26
- function wrap(str, lineLength) {
27
- str = (str || '').toString();
28
- lineLength = lineLength || 76;
29
-
30
- if (str.length <= lineLength) {
31
- return str;
32
- }
33
-
34
- let result = [];
35
- let pos = 0;
36
- let chunkLength = lineLength * 1024;
37
- while (pos < str.length) {
38
- let wrappedLines = str.substr(pos, chunkLength).replace(new RegExp('.{' + lineLength + '}', 'g'), '$&\r\n');
39
- result.push(wrappedLines);
40
- pos += chunkLength;
41
- }
42
-
43
- return result.join('');
44
- }
45
-
46
- /**
47
- * Creates a transform stream for encoding data to base64 encoding
48
- *
49
- * @constructor
50
- * @param {Object} options Stream options
51
- * @param {Number} [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
52
- */
53
- class Encoder extends Transform {
54
- constructor(options) {
55
- super();
56
- this.options = options || {};
57
-
58
- if (this.options.lineLength !== false) {
59
- this.options.lineLength = this.options.lineLength || 76;
60
- }
61
-
62
- this._curLine = '';
63
- this._remainingBytes = false;
64
-
65
- this.inputBytes = 0;
66
- this.outputBytes = 0;
67
- }
68
-
69
- _transform(chunk, encoding, done) {
70
- if (encoding !== 'buffer') {
71
- chunk = Buffer.from(chunk, encoding);
72
- }
73
-
74
- if (!chunk || !chunk.length) {
75
- return setImmediate(done);
76
- }
77
-
78
- this.inputBytes += chunk.length;
79
-
80
- if (this._remainingBytes && this._remainingBytes.length) {
81
- chunk = Buffer.concat([this._remainingBytes, chunk], this._remainingBytes.length + chunk.length);
82
- this._remainingBytes = false;
83
- }
84
-
85
- if (chunk.length % 3) {
86
- this._remainingBytes = chunk.slice(chunk.length - (chunk.length % 3));
87
- chunk = chunk.slice(0, chunk.length - (chunk.length % 3));
88
- } else {
89
- this._remainingBytes = false;
90
- }
91
-
92
- let b64 = this._curLine + encode(chunk);
93
-
94
- if (this.options.lineLength) {
95
- b64 = wrap(b64, this.options.lineLength);
96
-
97
- let lastLF = b64.lastIndexOf('\n');
98
- if (lastLF < 0) {
99
- this._curLine = b64;
100
- b64 = '';
101
- } else {
102
- this._curLine = b64.substring(lastLF + 1);
103
- b64 = b64.substring(0, lastLF + 1);
104
-
105
- if (b64 && !b64.endsWith('\r\n')) {
106
- b64 += '\r\n';
107
- }
108
- }
109
- } else {
110
- this._curLine = '';
111
- }
112
-
113
- if (b64) {
114
- this.outputBytes += b64.length;
115
- this.push(Buffer.from(b64, 'ascii'));
116
- }
117
-
118
- setImmediate(done);
119
- }
120
-
121
- _flush(done) {
122
- if (this._remainingBytes && this._remainingBytes.length) {
123
- this._curLine += encode(this._remainingBytes);
124
- }
125
-
126
- if (this._curLine) {
127
- this.outputBytes += this._curLine.length;
128
- this.push(Buffer.from(this._curLine, 'ascii'));
129
- this._curLine = '';
130
- }
131
- done();
132
- }
133
- }
134
-
135
- module.exports = {
136
- encode,
137
- wrap,
138
- Encoder
139
- };
@@ -1,253 +0,0 @@
1
- 'use strict';
2
-
3
- // FIXME:
4
- // replace this Transform mess with a method that pipes input argument to output argument
5
-
6
- const MessageParser = require('./message-parser');
7
- const RelaxedBody = require('./relaxed-body');
8
- const sign = require('./sign');
9
- const PassThrough = require('stream').PassThrough;
10
- const fs = require('fs');
11
- const path = require('path');
12
- const crypto = require('crypto');
13
-
14
- const DKIM_ALGO = 'sha256';
15
- const MAX_MESSAGE_SIZE = 2 * 1024 * 1024; // buffer messages larger than this to disk
16
-
17
- /*
18
- // Usage:
19
-
20
- let dkim = new DKIM({
21
- domainName: 'example.com',
22
- keySelector: 'key-selector',
23
- privateKey,
24
- cacheDir: '/tmp'
25
- });
26
- dkim.sign(input).pipe(process.stdout);
27
-
28
- // Where inputStream is a rfc822 message (either a stream, string or Buffer)
29
- // and outputStream is a DKIM signed rfc822 message
30
- */
31
-
32
- class DKIMSigner {
33
- constructor(options, keys, input, output) {
34
- this.options = options || {};
35
- this.keys = keys;
36
-
37
- this.cacheTreshold = Number(this.options.cacheTreshold) || MAX_MESSAGE_SIZE;
38
- this.hashAlgo = this.options.hashAlgo || DKIM_ALGO;
39
-
40
- this.cacheDir = this.options.cacheDir || false;
41
-
42
- this.chunks = [];
43
- this.chunklen = 0;
44
- this.readPos = 0;
45
- this.cachePath = this.cacheDir
46
- ? path.join(this.cacheDir, 'message.' + Date.now() + '-' + crypto.randomBytes(14).toString('hex'))
47
- : false;
48
- this.cache = false;
49
-
50
- this.headers = false;
51
- this.bodyHash = false;
52
- this.parser = false;
53
- this.relaxedBody = false;
54
-
55
- this.input = input;
56
- this.output = output;
57
- this.output.usingCache = false;
58
-
59
- this.hasErrored = false;
60
-
61
- this.input.on('error', err => {
62
- this.hasErrored = true;
63
- this.cleanup();
64
- output.emit('error', err);
65
- });
66
- }
67
-
68
- cleanup() {
69
- if (!this.cache || !this.cachePath) {
70
- return;
71
- }
72
- fs.unlink(this.cachePath, () => false);
73
- }
74
-
75
- createReadCache() {
76
- // pipe remainings to cache file
77
- this.cache = fs.createReadStream(this.cachePath);
78
- this.cache.once('error', err => {
79
- this.cleanup();
80
- this.output.emit('error', err);
81
- });
82
- this.cache.once('close', () => {
83
- this.cleanup();
84
- });
85
- this.cache.pipe(this.output);
86
- }
87
-
88
- sendNextChunk() {
89
- if (this.hasErrored) {
90
- return;
91
- }
92
-
93
- if (this.readPos >= this.chunks.length) {
94
- if (!this.cache) {
95
- return this.output.end();
96
- }
97
- return this.createReadCache();
98
- }
99
- let chunk = this.chunks[this.readPos++];
100
- if (this.output.write(chunk) === false) {
101
- return this.output.once('drain', () => {
102
- this.sendNextChunk();
103
- });
104
- }
105
- setImmediate(() => this.sendNextChunk());
106
- }
107
-
108
- sendSignedOutput() {
109
- let keyPos = 0;
110
- let signNextKey = () => {
111
- if (keyPos >= this.keys.length) {
112
- this.output.write(this.parser.rawHeaders);
113
- return setImmediate(() => this.sendNextChunk());
114
- }
115
- let key = this.keys[keyPos++];
116
- let dkimField = sign(this.headers, this.hashAlgo, this.bodyHash, {
117
- domainName: key.domainName,
118
- keySelector: key.keySelector,
119
- privateKey: key.privateKey,
120
- headerFieldNames: this.options.headerFieldNames,
121
- skipFields: this.options.skipFields
122
- });
123
- if (dkimField) {
124
- this.output.write(Buffer.from(dkimField + '\r\n'));
125
- }
126
- return setImmediate(signNextKey);
127
- };
128
-
129
- if (this.bodyHash && this.headers) {
130
- return signNextKey();
131
- }
132
-
133
- this.output.write(this.parser.rawHeaders);
134
- this.sendNextChunk();
135
- }
136
-
137
- createWriteCache() {
138
- this.output.usingCache = true;
139
- // pipe remainings to cache file
140
- this.cache = fs.createWriteStream(this.cachePath);
141
- this.cache.once('error', err => {
142
- this.cleanup();
143
- // drain input
144
- this.relaxedBody.unpipe(this.cache);
145
- this.relaxedBody.on('readable', () => {
146
- while (this.relaxedBody.read() !== null) {
147
- // do nothing
148
- }
149
- });
150
- this.hasErrored = true;
151
- // emit error
152
- this.output.emit('error', err);
153
- });
154
- this.cache.once('close', () => {
155
- this.sendSignedOutput();
156
- });
157
- this.relaxedBody.removeAllListeners('readable');
158
- this.relaxedBody.pipe(this.cache);
159
- }
160
-
161
- signStream() {
162
- this.parser = new MessageParser();
163
- this.relaxedBody = new RelaxedBody({
164
- hashAlgo: this.hashAlgo
165
- });
166
-
167
- this.parser.on('headers', value => {
168
- this.headers = value;
169
- });
170
-
171
- this.relaxedBody.on('hash', value => {
172
- this.bodyHash = value;
173
- });
174
-
175
- this.relaxedBody.on('readable', () => {
176
- let chunk;
177
- if (this.cache) {
178
- return;
179
- }
180
- while ((chunk = this.relaxedBody.read()) !== null) {
181
- this.chunks.push(chunk);
182
- this.chunklen += chunk.length;
183
- if (this.chunklen >= this.cacheTreshold && this.cachePath) {
184
- return this.createWriteCache();
185
- }
186
- }
187
- });
188
-
189
- this.relaxedBody.on('end', () => {
190
- if (this.cache) {
191
- return;
192
- }
193
- this.sendSignedOutput();
194
- });
195
-
196
- this.parser.pipe(this.relaxedBody);
197
- setImmediate(() => this.input.pipe(this.parser));
198
- }
199
- }
200
-
201
- class DKIM {
202
- constructor(options) {
203
- this.options = options || {};
204
- this.keys = [].concat(
205
- this.options.keys || {
206
- domainName: options.domainName,
207
- keySelector: options.keySelector,
208
- privateKey: options.privateKey
209
- }
210
- );
211
- }
212
-
213
- sign(input, extraOptions) {
214
- let output = new PassThrough();
215
- let inputStream = input;
216
- let writeValue = false;
217
-
218
- if (Buffer.isBuffer(input)) {
219
- writeValue = input;
220
- inputStream = new PassThrough();
221
- } else if (typeof input === 'string') {
222
- writeValue = Buffer.from(input);
223
- inputStream = new PassThrough();
224
- }
225
-
226
- let options = this.options;
227
- if (extraOptions && Object.keys(extraOptions).length) {
228
- options = {};
229
- Object.keys(this.options || {}).forEach(key => {
230
- options[key] = this.options[key];
231
- });
232
- Object.keys(extraOptions || {}).forEach(key => {
233
- if (!(key in options)) {
234
- options[key] = extraOptions[key];
235
- }
236
- });
237
- }
238
-
239
- let signer = new DKIMSigner(options, this.keys, inputStream, output);
240
- setImmediate(() => {
241
- signer.signStream();
242
- if (writeValue) {
243
- setImmediate(() => {
244
- inputStream.end(writeValue);
245
- });
246
- }
247
- });
248
-
249
- return output;
250
- }
251
- }
252
-
253
- module.exports = DKIM;
@@ -1,155 +0,0 @@
1
- 'use strict';
2
-
3
- const Transform = require('stream').Transform;
4
-
5
- /**
6
- * MessageParser instance is a transform stream that separates message headers
7
- * from the rest of the body. Headers are emitted with the 'headers' event. Message
8
- * body is passed on as the resulting stream.
9
- */
10
- class MessageParser extends Transform {
11
- constructor(options) {
12
- super(options);
13
- this.lastBytes = Buffer.alloc(4);
14
- this.headersParsed = false;
15
- this.headerBytes = 0;
16
- this.headerChunks = [];
17
- this.rawHeaders = false;
18
- this.bodySize = 0;
19
- }
20
-
21
- /**
22
- * Keeps count of the last 4 bytes in order to detect line breaks on chunk boundaries
23
- *
24
- * @param {Buffer} data Next data chunk from the stream
25
- */
26
- updateLastBytes(data) {
27
- let lblen = this.lastBytes.length;
28
- let nblen = Math.min(data.length, lblen);
29
-
30
- // shift existing bytes
31
- for (let i = 0, len = lblen - nblen; i < len; i++) {
32
- this.lastBytes[i] = this.lastBytes[i + nblen];
33
- }
34
-
35
- // add new bytes
36
- for (let i = 1; i <= nblen; i++) {
37
- this.lastBytes[lblen - i] = data[data.length - i];
38
- }
39
- }
40
-
41
- /**
42
- * Finds and removes message headers from the remaining body. We want to keep
43
- * headers separated until final delivery to be able to modify these
44
- *
45
- * @param {Buffer} data Next chunk of data
46
- * @return {Boolean} Returns true if headers are already found or false otherwise
47
- */
48
- checkHeaders(data) {
49
- if (this.headersParsed) {
50
- return true;
51
- }
52
-
53
- let lblen = this.lastBytes.length;
54
- let headerPos = 0;
55
- this.curLinePos = 0;
56
- for (let i = 0, len = this.lastBytes.length + data.length; i < len; i++) {
57
- let chr;
58
- if (i < lblen) {
59
- chr = this.lastBytes[i];
60
- } else {
61
- chr = data[i - lblen];
62
- }
63
- if (chr === 0x0a && i) {
64
- let pr1 = i - 1 < lblen ? this.lastBytes[i - 1] : data[i - 1 - lblen];
65
- let pr2 = i > 1 ? (i - 2 < lblen ? this.lastBytes[i - 2] : data[i - 2 - lblen]) : false;
66
- if (pr1 === 0x0a) {
67
- this.headersParsed = true;
68
- headerPos = i - lblen + 1;
69
- this.headerBytes += headerPos;
70
- break;
71
- } else if (pr1 === 0x0d && pr2 === 0x0a) {
72
- this.headersParsed = true;
73
- headerPos = i - lblen + 1;
74
- this.headerBytes += headerPos;
75
- break;
76
- }
77
- }
78
- }
79
-
80
- if (this.headersParsed) {
81
- this.headerChunks.push(data.slice(0, headerPos));
82
- this.rawHeaders = Buffer.concat(this.headerChunks, this.headerBytes);
83
- this.headerChunks = null;
84
- this.emit('headers', this.parseHeaders());
85
- if (data.length - 1 > headerPos) {
86
- let chunk = data.slice(headerPos);
87
- this.bodySize += chunk.length;
88
- // this would be the first chunk of data sent downstream
89
- setImmediate(() => this.push(chunk));
90
- }
91
- return false;
92
- } else {
93
- this.headerBytes += data.length;
94
- this.headerChunks.push(data);
95
- }
96
-
97
- // store last 4 bytes to catch header break
98
- this.updateLastBytes(data);
99
-
100
- return false;
101
- }
102
-
103
- _transform(chunk, encoding, callback) {
104
- if (!chunk || !chunk.length) {
105
- return callback();
106
- }
107
-
108
- if (typeof chunk === 'string') {
109
- chunk = Buffer.from(chunk, encoding);
110
- }
111
-
112
- let headersFound;
113
-
114
- try {
115
- headersFound = this.checkHeaders(chunk);
116
- } catch (E) {
117
- return callback(E);
118
- }
119
-
120
- if (headersFound) {
121
- this.bodySize += chunk.length;
122
- this.push(chunk);
123
- }
124
-
125
- setImmediate(callback);
126
- }
127
-
128
- _flush(callback) {
129
- if (this.headerChunks) {
130
- let chunk = Buffer.concat(this.headerChunks, this.headerBytes);
131
- this.bodySize += chunk.length;
132
- this.push(chunk);
133
- this.headerChunks = null;
134
- }
135
- callback();
136
- }
137
-
138
- parseHeaders() {
139
- let lines = (this.rawHeaders || '').toString().split(/\r?\n/);
140
- for (let i = lines.length - 1; i > 0; i--) {
141
- if (/^\s/.test(lines[i])) {
142
- lines[i - 1] += '\n' + lines[i];
143
- lines.splice(i, 1);
144
- }
145
- }
146
- return lines
147
- .filter(line => line.trim())
148
- .map(line => ({
149
- key: line.substr(0, line.indexOf(':')).trim().toLowerCase(),
150
- line
151
- }));
152
- }
153
- }
154
-
155
- module.exports = MessageParser;
@@ -1,154 +0,0 @@
1
- 'use strict';
2
-
3
- // streams through a message body and calculates relaxed body hash
4
-
5
- const Transform = require('stream').Transform;
6
- const crypto = require('crypto');
7
-
8
- class RelaxedBody extends Transform {
9
- constructor(options) {
10
- super();
11
- options = options || {};
12
- this.chunkBuffer = [];
13
- this.chunkBufferLen = 0;
14
- this.bodyHash = crypto.createHash(options.hashAlgo || 'sha1');
15
- this.remainder = '';
16
- this.byteLength = 0;
17
-
18
- this.debug = options.debug;
19
- this._debugBody = options.debug ? [] : false;
20
- }
21
-
22
- updateHash(chunk) {
23
- let bodyStr;
24
-
25
- // find next remainder
26
- let nextRemainder = '';
27
-
28
- // This crux finds and removes the spaces from the last line and the newline characters after the last non-empty line
29
- // If we get another chunk that does not match this description then we can restore the previously processed data
30
- let state = 'file';
31
- for (let i = chunk.length - 1; i >= 0; i--) {
32
- let c = chunk[i];
33
-
34
- if (state === 'file' && (c === 0x0a || c === 0x0d)) {
35
- // do nothing, found \n or \r at the end of chunk, stil end of file
36
- } else if (state === 'file' && (c === 0x09 || c === 0x20)) {
37
- // switch to line ending mode, this is the last non-empty line
38
- state = 'line';
39
- } else if (state === 'line' && (c === 0x09 || c === 0x20)) {
40
- // do nothing, found ' ' or \t at the end of line, keep processing the last non-empty line
41
- } else if (state === 'file' || state === 'line') {
42
- // non line/file ending character found, switch to body mode
43
- state = 'body';
44
- if (i === chunk.length - 1) {
45
- // final char is not part of line end or file end, so do nothing
46
- break;
47
- }
48
- }
49
-
50
- if (i === 0) {
51
- // reached to the beginning of the chunk, check if it is still about the ending
52
- // and if the remainder also matches
53
- if (
54
- (state === 'file' && (!this.remainder || /[\r\n]$/.test(this.remainder))) ||
55
- (state === 'line' && (!this.remainder || /[ \t]$/.test(this.remainder)))
56
- ) {
57
- // keep everything
58
- this.remainder += chunk.toString('binary');
59
- return;
60
- } else if (state === 'line' || state === 'file') {
61
- // process existing remainder as normal line but store the current chunk
62
- nextRemainder = chunk.toString('binary');
63
- chunk = false;
64
- break;
65
- }
66
- }
67
-
68
- if (state !== 'body') {
69
- continue;
70
- }
71
-
72
- // reached first non ending byte
73
- nextRemainder = chunk.slice(i + 1).toString('binary');
74
- chunk = chunk.slice(0, i + 1);
75
- break;
76
- }
77
-
78
- let needsFixing = !!this.remainder;
79
- if (chunk && !needsFixing) {
80
- // check if we even need to change anything
81
- for (let i = 0, len = chunk.length; i < len; i++) {
82
- if (i && chunk[i] === 0x0a && chunk[i - 1] !== 0x0d) {
83
- // missing \r before \n
84
- needsFixing = true;
85
- break;
86
- } else if (i && chunk[i] === 0x0d && chunk[i - 1] === 0x20) {
87
- // trailing WSP found
88
- needsFixing = true;
89
- break;
90
- } else if (i && chunk[i] === 0x20 && chunk[i - 1] === 0x20) {
91
- // multiple spaces found, needs to be replaced with just one
92
- needsFixing = true;
93
- break;
94
- } else if (chunk[i] === 0x09) {
95
- // TAB found, needs to be replaced with a space
96
- needsFixing = true;
97
- break;
98
- }
99
- }
100
- }
101
-
102
- if (needsFixing) {
103
- bodyStr = this.remainder + (chunk ? chunk.toString('binary') : '');
104
- this.remainder = nextRemainder;
105
- bodyStr = bodyStr
106
- .replace(/\r?\n/g, '\n') // use js line endings
107
- .replace(/[ \t]*$/gm, '') // remove line endings, rtrim
108
- .replace(/[ \t]+/gm, ' ') // single spaces
109
- .replace(/\n/g, '\r\n'); // restore rfc822 line endings
110
- chunk = Buffer.from(bodyStr, 'binary');
111
- } else if (nextRemainder) {
112
- this.remainder = nextRemainder;
113
- }
114
-
115
- if (this.debug) {
116
- this._debugBody.push(chunk);
117
- }
118
- this.bodyHash.update(chunk);
119
- }
120
-
121
- _transform(chunk, encoding, callback) {
122
- if (!chunk || !chunk.length) {
123
- return callback();
124
- }
125
-
126
- if (typeof chunk === 'string') {
127
- chunk = Buffer.from(chunk, encoding);
128
- }
129
-
130
- this.updateHash(chunk);
131
-
132
- this.byteLength += chunk.length;
133
- this.push(chunk);
134
- callback();
135
- }
136
-
137
- _flush(callback) {
138
- // generate final hash and emit it
139
- if (/[\r\n]$/.test(this.remainder) && this.byteLength > 2) {
140
- // add terminating line end
141
- this.bodyHash.update(Buffer.from('\r\n'));
142
- }
143
- if (!this.byteLength) {
144
- // emit empty line buffer to keep the stream flowing
145
- this.push(Buffer.from('\r\n'));
146
- // this.bodyHash.update(Buffer.from('\r\n'));
147
- }
148
-
149
- this.emit('hash', this.bodyHash.digest('base64'), this.debug ? Buffer.concat(this._debugBody) : false);
150
- callback();
151
- }
152
- }
153
-
154
- module.exports = RelaxedBody;