@bobfrankston/mailx 1.0.9 → 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.
- package/bin/mailx.js +47 -29
- package/bin/postinstall.js +41 -0
- package/client/app.js +93 -13
- package/client/components/folder-tree.js +84 -3
- package/client/components/message-list.js +134 -8
- package/client/components/message-viewer.js +130 -13
- package/client/compose/compose.html +4 -4
- package/client/compose/compose.js +53 -34
- package/client/index.html +33 -9
- package/client/lib/api-client.js +102 -30
- package/client/lib/mailxapi.js +123 -0
- package/client/package.json +5 -1
- package/client/styles/components.css +188 -15
- package/client/styles/layout.css +2 -1
- package/killmail.cmd +6 -0
- package/launch.ps1 +48 -3
- package/launcher/bin/mailx-app.exe +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Breadcrumbs +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Crashpad/metadata +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Crashpad/settings.dat +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Crashpad/throttle_store.dat +1 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/CrashpadMetrics-active.pma +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/BrowsingTopicsSiteData +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Cache/No_Vary_Search/journal.baj +1 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/DIPS +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/DashTrackerDatabase +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/EdgeJourneys/EdgeJourneys.db +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Rules/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Rules/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Rules/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Scripts/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Scripts/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension Scripts/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension State/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension State/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Extension State/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/ExtensionActivityComp +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/ExtensionActivityEdge +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Favicons +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/History +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/History-journal +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/IndexedDB/devtools_devtools_0.indexeddb.leveldb/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/IndexedDB/devtools_devtools_0.indexeddb.leveldb/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/IndexedDB/devtools_devtools_0.indexeddb.leveldb/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Local Storage/leveldb/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Local Storage/leveldb/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Local Storage/leveldb/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Login Data +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Login Data For Account +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Network/Cookies +0 -0
- NEL +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Network/Trust Tokens +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Network Action Predictor +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Preferences +1 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Safe Browsing Network/Safe Browsing Cookies +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/ServerCertificate +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Session Storage/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Session Storage/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Session Storage/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Shared Dictionary/db +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/SharedStorage +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Shortcuts +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Site Characteristics Database/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Site Characteristics Database/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Site Characteristics Database/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Top Sites +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Vpn Tokens +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Web Data +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/Web Data-journal +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/WebStorage/QuotaManager +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/WebStorage/QuotaManager-journal +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/heavy_ad_intervention_opt_out.db +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/LOCK +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/LOG +3 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/MANIFEST-000001 +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/DeferredBrowserMetrics/BrowserMetrics-69CAD063-BE24.pma +0 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Local State +1 -0
- package/launcher/bin/mailx-app.exe.WebView2/EBWebView/Variations +1 -0
- package/launcher/bin/mailx-app.old.exe +0 -0
- package/launcher/mailx.ico +0 -0
- package/npmg.bat +6 -0
- package/package.json +9 -3
- package/packages/mailx-api/index.js +79 -26
- package/packages/mailx-api/package.json +5 -1
- package/packages/mailx-compose/package.json +5 -1
- package/packages/mailx-core/index.d.ts +129 -0
- package/packages/mailx-core/index.js +323 -0
- package/packages/mailx-core/ipc.d.ts +13 -0
- package/packages/mailx-core/ipc.js +56 -0
- package/packages/mailx-core/package.json +18 -0
- package/packages/mailx-imap/index.d.ts +5 -1
- package/packages/mailx-imap/index.js +76 -14
- package/packages/mailx-imap/package.json +5 -1
- package/packages/mailx-send/package.json +12 -2
- package/packages/mailx-server/index.js +42 -31
- package/packages/mailx-server/package.json +5 -2
- package/packages/mailx-settings/index.d.ts +1 -1
- package/packages/mailx-settings/index.js +21 -12
- package/packages/mailx-settings/package.json +5 -1
- package/packages/mailx-store/db.d.ts +5 -1
- package/packages/mailx-store/db.js +64 -12
- package/packages/mailx-store/file-store.d.ts +2 -8
- package/packages/mailx-store/file-store.js +7 -31
- package/packages/mailx-store/package.json +5 -1
- package/packages/mailx-types/index.d.ts +3 -1
- package/packages/mailx-types/package.json +6 -2
- package/.tswalk.json +0 -3366
- package/mailx.json +0 -9
- package/packages/mailx-api/node_modules/nodemailer/.ncurc.js +0 -9
- package/packages/mailx-api/node_modules/nodemailer/.prettierignore +0 -8
- package/packages/mailx-api/node_modules/nodemailer/.prettierrc +0 -12
- package/packages/mailx-api/node_modules/nodemailer/.prettierrc.js +0 -10
- package/packages/mailx-api/node_modules/nodemailer/.release-please-config.json +0 -9
- package/packages/mailx-api/node_modules/nodemailer/LICENSE +0 -16
- package/packages/mailx-api/node_modules/nodemailer/README.md +0 -86
- package/packages/mailx-api/node_modules/nodemailer/SECURITY.txt +0 -22
- package/packages/mailx-api/node_modules/nodemailer/eslint.config.js +0 -88
- package/packages/mailx-api/node_modules/nodemailer/lib/addressparser/index.js +0 -383
- package/packages/mailx-api/node_modules/nodemailer/lib/base64/index.js +0 -139
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/index.js +0 -253
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/packages/mailx-api/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/packages/mailx-api/node_modules/nodemailer/lib/fetch/index.js +0 -280
- package/packages/mailx-api/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/packages/mailx-api/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
- package/packages/mailx-api/node_modules/nodemailer/lib/mailer/index.js +0 -441
- package/packages/mailx-api/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
- package/packages/mailx-api/node_modules/nodemailer/lib/nodemailer.js +0 -157
- package/packages/mailx-api/node_modules/nodemailer/lib/punycode/index.js +0 -460
- package/packages/mailx-api/node_modules/nodemailer/lib/qp/index.js +0 -227
- package/packages/mailx-api/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/packages/mailx-api/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
- package/packages/mailx-api/node_modules/nodemailer/lib/shared/index.js +0 -754
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
- package/packages/mailx-api/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/packages/mailx-api/node_modules/nodemailer/lib/well-known/index.js +0 -47
- package/packages/mailx-api/node_modules/nodemailer/lib/well-known/services.json +0 -611
- package/packages/mailx-api/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
- package/packages/mailx-api/node_modules/nodemailer/package.json +0 -47
- package/packages/mailx-imap/node_modules/nodemailer/.ncurc.js +0 -9
- package/packages/mailx-imap/node_modules/nodemailer/.prettierignore +0 -8
- package/packages/mailx-imap/node_modules/nodemailer/.prettierrc +0 -12
- package/packages/mailx-imap/node_modules/nodemailer/.prettierrc.js +0 -10
- package/packages/mailx-imap/node_modules/nodemailer/.release-please-config.json +0 -9
- package/packages/mailx-imap/node_modules/nodemailer/LICENSE +0 -16
- package/packages/mailx-imap/node_modules/nodemailer/README.md +0 -86
- package/packages/mailx-imap/node_modules/nodemailer/SECURITY.txt +0 -22
- package/packages/mailx-imap/node_modules/nodemailer/eslint.config.js +0 -88
- package/packages/mailx-imap/node_modules/nodemailer/lib/addressparser/index.js +0 -383
- package/packages/mailx-imap/node_modules/nodemailer/lib/base64/index.js +0 -139
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/index.js +0 -253
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/index.js +0 -280
- package/packages/mailx-imap/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/packages/mailx-imap/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
- package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/index.js +0 -441
- package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
- package/packages/mailx-imap/node_modules/nodemailer/lib/nodemailer.js +0 -157
- package/packages/mailx-imap/node_modules/nodemailer/lib/punycode/index.js +0 -460
- package/packages/mailx-imap/node_modules/nodemailer/lib/qp/index.js +0 -227
- package/packages/mailx-imap/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/packages/mailx-imap/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
- package/packages/mailx-imap/node_modules/nodemailer/lib/shared/index.js +0 -754
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
- package/packages/mailx-imap/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/index.js +0 -47
- package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/services.json +0 -611
- package/packages/mailx-imap/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
- package/packages/mailx-imap/node_modules/nodemailer/package.json +0 -47
- package/packages/mailx-send/node_modules/nodemailer/.ncurc.js +0 -9
- package/packages/mailx-send/node_modules/nodemailer/.prettierignore +0 -8
- package/packages/mailx-send/node_modules/nodemailer/.prettierrc +0 -12
- package/packages/mailx-send/node_modules/nodemailer/.prettierrc.js +0 -10
- package/packages/mailx-send/node_modules/nodemailer/.release-please-config.json +0 -9
- package/packages/mailx-send/node_modules/nodemailer/LICENSE +0 -16
- package/packages/mailx-send/node_modules/nodemailer/README.md +0 -86
- package/packages/mailx-send/node_modules/nodemailer/SECURITY.txt +0 -22
- package/packages/mailx-send/node_modules/nodemailer/eslint.config.js +0 -88
- package/packages/mailx-send/node_modules/nodemailer/lib/addressparser/index.js +0 -383
- package/packages/mailx-send/node_modules/nodemailer/lib/base64/index.js +0 -139
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/index.js +0 -253
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/packages/mailx-send/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/packages/mailx-send/node_modules/nodemailer/lib/fetch/index.js +0 -280
- package/packages/mailx-send/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/packages/mailx-send/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
- package/packages/mailx-send/node_modules/nodemailer/lib/mailer/index.js +0 -441
- package/packages/mailx-send/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
- package/packages/mailx-send/node_modules/nodemailer/lib/nodemailer.js +0 -157
- package/packages/mailx-send/node_modules/nodemailer/lib/punycode/index.js +0 -460
- package/packages/mailx-send/node_modules/nodemailer/lib/qp/index.js +0 -227
- package/packages/mailx-send/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/packages/mailx-send/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
- package/packages/mailx-send/node_modules/nodemailer/lib/shared/index.js +0 -754
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
- package/packages/mailx-send/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/packages/mailx-send/node_modules/nodemailer/lib/well-known/index.js +0 -47
- package/packages/mailx-send/node_modules/nodemailer/lib/well-known/services.json +0 -611
- package/packages/mailx-send/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
- package/packages/mailx-send/node_modules/nodemailer/package.json +0 -47
|
@@ -1,629 +0,0 @@
|
|
|
1
|
-
/* eslint no-undefined: 0 */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const MimeNode = require('../mime-node');
|
|
6
|
-
const mimeFuncs = require('../mime-funcs');
|
|
7
|
-
const parseDataURI = require('../shared').parseDataURI;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates the object for composing a MimeNode instance out from the mail options
|
|
11
|
-
*
|
|
12
|
-
* @constructor
|
|
13
|
-
* @param {Object} mail Mail options
|
|
14
|
-
*/
|
|
15
|
-
class MailComposer {
|
|
16
|
-
constructor(mail) {
|
|
17
|
-
this.mail = mail || {};
|
|
18
|
-
this.message = false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Builds MimeNode instance
|
|
23
|
-
*/
|
|
24
|
-
compile() {
|
|
25
|
-
this._alternatives = this.getAlternatives();
|
|
26
|
-
this._htmlNode = this._alternatives.filter(alternative => /^text\/html\b/i.test(alternative.contentType)).pop();
|
|
27
|
-
this._attachments = this.getAttachments(!!this._htmlNode);
|
|
28
|
-
|
|
29
|
-
this._useRelated = !!(this._htmlNode && this._attachments.related.length);
|
|
30
|
-
this._useAlternative = this._alternatives.length > 1;
|
|
31
|
-
this._useMixed = this._attachments.attached.length > 1 || (this._alternatives.length && this._attachments.attached.length === 1);
|
|
32
|
-
|
|
33
|
-
// Compose MIME tree
|
|
34
|
-
if (this.mail.raw) {
|
|
35
|
-
this.message = new MimeNode('message/rfc822', { newline: this.mail.newline }).setRaw(this.mail.raw);
|
|
36
|
-
} else if (this._useMixed) {
|
|
37
|
-
this.message = this._createMixed();
|
|
38
|
-
} else if (this._useAlternative) {
|
|
39
|
-
this.message = this._createAlternative();
|
|
40
|
-
} else if (this._useRelated) {
|
|
41
|
-
this.message = this._createRelated();
|
|
42
|
-
} else {
|
|
43
|
-
this.message = this._createContentNode(
|
|
44
|
-
false,
|
|
45
|
-
[]
|
|
46
|
-
.concat(this._alternatives || [])
|
|
47
|
-
.concat(this._attachments.attached || [])
|
|
48
|
-
.shift() || {
|
|
49
|
-
contentType: 'text/plain',
|
|
50
|
-
content: ''
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Add custom headers
|
|
56
|
-
if (this.mail.headers) {
|
|
57
|
-
this.message.addHeader(this.mail.headers);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Add headers to the root node, always overrides custom headers
|
|
61
|
-
['from', 'sender', 'to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'message-id', 'date'].forEach(header => {
|
|
62
|
-
let key = header.replace(/-(\w)/g, (o, c) => c.toUpperCase());
|
|
63
|
-
if (this.mail[key]) {
|
|
64
|
-
this.message.setHeader(header, this.mail[key]);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Sets custom envelope
|
|
69
|
-
if (this.mail.envelope) {
|
|
70
|
-
this.message.setEnvelope(this.mail.envelope);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ensure Message-Id value
|
|
74
|
-
this.message.messageId();
|
|
75
|
-
|
|
76
|
-
return this.message;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* List all attachments. Resulting attachment objects can be used as input for MimeNode nodes
|
|
81
|
-
*
|
|
82
|
-
* @param {Boolean} findRelated If true separate related attachments from attached ones
|
|
83
|
-
* @returns {Object} An object of arrays (`related` and `attached`)
|
|
84
|
-
*/
|
|
85
|
-
getAttachments(findRelated) {
|
|
86
|
-
let icalEvent, eventObject;
|
|
87
|
-
let attachments = [].concat(this.mail.attachments || []).map((attachment, i) => {
|
|
88
|
-
let data;
|
|
89
|
-
|
|
90
|
-
if (/^data:/i.test(attachment.path || attachment.href)) {
|
|
91
|
-
attachment = this._processDataUrl(attachment);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let contentType =
|
|
95
|
-
attachment.contentType || mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin');
|
|
96
|
-
|
|
97
|
-
let isImage = /^image\//i.test(contentType);
|
|
98
|
-
let isMessageNode = /^message\//i.test(contentType);
|
|
99
|
-
|
|
100
|
-
let contentDisposition =
|
|
101
|
-
attachment.contentDisposition || (isMessageNode || (isImage && attachment.cid) ? 'inline' : 'attachment');
|
|
102
|
-
|
|
103
|
-
let contentTransferEncoding;
|
|
104
|
-
if ('contentTransferEncoding' in attachment) {
|
|
105
|
-
// also contains `false`, to set
|
|
106
|
-
contentTransferEncoding = attachment.contentTransferEncoding;
|
|
107
|
-
} else if (isMessageNode) {
|
|
108
|
-
// the content might include non-ASCII bytes but at this point we do not know it yet
|
|
109
|
-
contentTransferEncoding = '8bit';
|
|
110
|
-
} else {
|
|
111
|
-
contentTransferEncoding = 'base64'; // the default
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
data = {
|
|
115
|
-
contentType,
|
|
116
|
-
contentDisposition,
|
|
117
|
-
contentTransferEncoding
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
if (attachment.filename) {
|
|
121
|
-
data.filename = attachment.filename;
|
|
122
|
-
} else if (!isMessageNode && attachment.filename !== false) {
|
|
123
|
-
data.filename = (attachment.path || attachment.href || '').split('/').pop().split('?').shift() || 'attachment-' + (i + 1);
|
|
124
|
-
if (data.filename.indexOf('.') < 0) {
|
|
125
|
-
data.filename += '.' + mimeFuncs.detectExtension(data.contentType);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (/^https?:\/\//i.test(attachment.path)) {
|
|
130
|
-
attachment.href = attachment.path;
|
|
131
|
-
attachment.path = undefined;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (attachment.cid) {
|
|
135
|
-
data.cid = attachment.cid;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (attachment.raw) {
|
|
139
|
-
data.raw = attachment.raw;
|
|
140
|
-
} else if (attachment.path) {
|
|
141
|
-
data.content = {
|
|
142
|
-
path: attachment.path
|
|
143
|
-
};
|
|
144
|
-
} else if (attachment.href) {
|
|
145
|
-
data.content = {
|
|
146
|
-
href: attachment.href,
|
|
147
|
-
httpHeaders: attachment.httpHeaders
|
|
148
|
-
};
|
|
149
|
-
} else {
|
|
150
|
-
data.content = attachment.content || '';
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (attachment.encoding) {
|
|
154
|
-
data.encoding = attachment.encoding;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (attachment.headers) {
|
|
158
|
-
data.headers = attachment.headers;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return data;
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
if (this.mail.icalEvent) {
|
|
165
|
-
if (
|
|
166
|
-
typeof this.mail.icalEvent === 'object' &&
|
|
167
|
-
(this.mail.icalEvent.content || this.mail.icalEvent.path || this.mail.icalEvent.href || this.mail.icalEvent.raw)
|
|
168
|
-
) {
|
|
169
|
-
icalEvent = this.mail.icalEvent;
|
|
170
|
-
} else {
|
|
171
|
-
icalEvent = {
|
|
172
|
-
content: this.mail.icalEvent
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
eventObject = {};
|
|
177
|
-
Object.keys(icalEvent).forEach(key => {
|
|
178
|
-
eventObject[key] = icalEvent[key];
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
eventObject.contentType = 'application/ics';
|
|
182
|
-
if (!eventObject.headers) {
|
|
183
|
-
eventObject.headers = {};
|
|
184
|
-
}
|
|
185
|
-
eventObject.filename = eventObject.filename || 'invite.ics';
|
|
186
|
-
eventObject.headers['Content-Disposition'] = 'attachment';
|
|
187
|
-
eventObject.headers['Content-Transfer-Encoding'] = 'base64';
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (!findRelated) {
|
|
191
|
-
return {
|
|
192
|
-
attached: attachments.concat(eventObject || []),
|
|
193
|
-
related: []
|
|
194
|
-
};
|
|
195
|
-
} else {
|
|
196
|
-
return {
|
|
197
|
-
attached: attachments.filter(attachment => !attachment.cid).concat(eventObject || []),
|
|
198
|
-
related: attachments.filter(attachment => !!attachment.cid)
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* List alternatives. Resulting objects can be used as input for MimeNode nodes
|
|
205
|
-
*
|
|
206
|
-
* @returns {Array} An array of alternative elements. Includes the `text` and `html` values as well
|
|
207
|
-
*/
|
|
208
|
-
getAlternatives() {
|
|
209
|
-
let alternatives = [],
|
|
210
|
-
text,
|
|
211
|
-
html,
|
|
212
|
-
watchHtml,
|
|
213
|
-
amp,
|
|
214
|
-
icalEvent,
|
|
215
|
-
eventObject;
|
|
216
|
-
|
|
217
|
-
if (this.mail.text) {
|
|
218
|
-
if (
|
|
219
|
-
typeof this.mail.text === 'object' &&
|
|
220
|
-
(this.mail.text.content || this.mail.text.path || this.mail.text.href || this.mail.text.raw)
|
|
221
|
-
) {
|
|
222
|
-
text = this.mail.text;
|
|
223
|
-
} else {
|
|
224
|
-
text = {
|
|
225
|
-
content: this.mail.text
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
text.contentType = 'text/plain; charset=utf-8';
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (this.mail.watchHtml) {
|
|
232
|
-
if (
|
|
233
|
-
typeof this.mail.watchHtml === 'object' &&
|
|
234
|
-
(this.mail.watchHtml.content || this.mail.watchHtml.path || this.mail.watchHtml.href || this.mail.watchHtml.raw)
|
|
235
|
-
) {
|
|
236
|
-
watchHtml = this.mail.watchHtml;
|
|
237
|
-
} else {
|
|
238
|
-
watchHtml = {
|
|
239
|
-
content: this.mail.watchHtml
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
watchHtml.contentType = 'text/watch-html; charset=utf-8';
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (this.mail.amp) {
|
|
246
|
-
if (
|
|
247
|
-
typeof this.mail.amp === 'object' &&
|
|
248
|
-
(this.mail.amp.content || this.mail.amp.path || this.mail.amp.href || this.mail.amp.raw)
|
|
249
|
-
) {
|
|
250
|
-
amp = this.mail.amp;
|
|
251
|
-
} else {
|
|
252
|
-
amp = {
|
|
253
|
-
content: this.mail.amp
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
amp.contentType = 'text/x-amp-html; charset=utf-8';
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// NB! when including attachments with a calendar alternative you might end up in a blank screen on some clients
|
|
260
|
-
if (this.mail.icalEvent) {
|
|
261
|
-
if (
|
|
262
|
-
typeof this.mail.icalEvent === 'object' &&
|
|
263
|
-
(this.mail.icalEvent.content || this.mail.icalEvent.path || this.mail.icalEvent.href || this.mail.icalEvent.raw)
|
|
264
|
-
) {
|
|
265
|
-
icalEvent = this.mail.icalEvent;
|
|
266
|
-
} else {
|
|
267
|
-
icalEvent = {
|
|
268
|
-
content: this.mail.icalEvent
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
eventObject = {};
|
|
273
|
-
Object.keys(icalEvent).forEach(key => {
|
|
274
|
-
eventObject[key] = icalEvent[key];
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
if (eventObject.content && typeof eventObject.content === 'object') {
|
|
278
|
-
// we are going to have the same attachment twice, so mark this to be
|
|
279
|
-
// resolved just once
|
|
280
|
-
eventObject.content._resolve = true;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
eventObject.filename = false;
|
|
284
|
-
eventObject.contentType =
|
|
285
|
-
'text/calendar; charset=utf-8; method=' + (eventObject.method || 'PUBLISH').toString().trim().toUpperCase();
|
|
286
|
-
if (!eventObject.headers) {
|
|
287
|
-
eventObject.headers = {};
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (this.mail.html) {
|
|
292
|
-
if (
|
|
293
|
-
typeof this.mail.html === 'object' &&
|
|
294
|
-
(this.mail.html.content || this.mail.html.path || this.mail.html.href || this.mail.html.raw)
|
|
295
|
-
) {
|
|
296
|
-
html = this.mail.html;
|
|
297
|
-
} else {
|
|
298
|
-
html = {
|
|
299
|
-
content: this.mail.html
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
html.contentType = 'text/html; charset=utf-8';
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
[]
|
|
306
|
-
.concat(text || [])
|
|
307
|
-
.concat(watchHtml || [])
|
|
308
|
-
.concat(amp || [])
|
|
309
|
-
.concat(html || [])
|
|
310
|
-
.concat(eventObject || [])
|
|
311
|
-
.concat(this.mail.alternatives || [])
|
|
312
|
-
.forEach(alternative => {
|
|
313
|
-
let data;
|
|
314
|
-
|
|
315
|
-
if (/^data:/i.test(alternative.path || alternative.href)) {
|
|
316
|
-
alternative = this._processDataUrl(alternative);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
data = {
|
|
320
|
-
contentType:
|
|
321
|
-
alternative.contentType ||
|
|
322
|
-
mimeFuncs.detectMimeType(alternative.filename || alternative.path || alternative.href || 'txt'),
|
|
323
|
-
contentTransferEncoding: alternative.contentTransferEncoding
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
if (alternative.filename) {
|
|
327
|
-
data.filename = alternative.filename;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (/^https?:\/\//i.test(alternative.path)) {
|
|
331
|
-
alternative.href = alternative.path;
|
|
332
|
-
alternative.path = undefined;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (alternative.raw) {
|
|
336
|
-
data.raw = alternative.raw;
|
|
337
|
-
} else if (alternative.path) {
|
|
338
|
-
data.content = {
|
|
339
|
-
path: alternative.path
|
|
340
|
-
};
|
|
341
|
-
} else if (alternative.href) {
|
|
342
|
-
data.content = {
|
|
343
|
-
href: alternative.href
|
|
344
|
-
};
|
|
345
|
-
} else {
|
|
346
|
-
data.content = alternative.content || '';
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (alternative.encoding) {
|
|
350
|
-
data.encoding = alternative.encoding;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (alternative.headers) {
|
|
354
|
-
data.headers = alternative.headers;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
alternatives.push(data);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
return alternatives;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Builds multipart/mixed node. It should always contain different type of elements on the same level
|
|
365
|
-
* eg. text + attachments
|
|
366
|
-
*
|
|
367
|
-
* @param {Object} parentNode Parent for this note. If it does not exist, a root node is created
|
|
368
|
-
* @returns {Object} MimeNode node element
|
|
369
|
-
*/
|
|
370
|
-
_createMixed(parentNode) {
|
|
371
|
-
let node;
|
|
372
|
-
|
|
373
|
-
if (!parentNode) {
|
|
374
|
-
node = new MimeNode('multipart/mixed', {
|
|
375
|
-
baseBoundary: this.mail.baseBoundary,
|
|
376
|
-
textEncoding: this.mail.textEncoding,
|
|
377
|
-
boundaryPrefix: this.mail.boundaryPrefix,
|
|
378
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
379
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
380
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
381
|
-
newline: this.mail.newline
|
|
382
|
-
});
|
|
383
|
-
} else {
|
|
384
|
-
node = parentNode.createChild('multipart/mixed', {
|
|
385
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
386
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
387
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
388
|
-
newline: this.mail.newline
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (this._useAlternative) {
|
|
393
|
-
this._createAlternative(node);
|
|
394
|
-
} else if (this._useRelated) {
|
|
395
|
-
this._createRelated(node);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
[]
|
|
399
|
-
.concat((!this._useAlternative && this._alternatives) || [])
|
|
400
|
-
.concat(this._attachments.attached || [])
|
|
401
|
-
.forEach(element => {
|
|
402
|
-
// if the element is a html node from related subpart then ignore it
|
|
403
|
-
if (!this._useRelated || element !== this._htmlNode) {
|
|
404
|
-
this._createContentNode(node, element);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
return node;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Builds multipart/alternative node. It should always contain same type of elements on the same level
|
|
413
|
-
* eg. text + html view of the same data
|
|
414
|
-
*
|
|
415
|
-
* @param {Object} parentNode Parent for this note. If it does not exist, a root node is created
|
|
416
|
-
* @returns {Object} MimeNode node element
|
|
417
|
-
*/
|
|
418
|
-
_createAlternative(parentNode) {
|
|
419
|
-
let node;
|
|
420
|
-
|
|
421
|
-
if (!parentNode) {
|
|
422
|
-
node = new MimeNode('multipart/alternative', {
|
|
423
|
-
baseBoundary: this.mail.baseBoundary,
|
|
424
|
-
textEncoding: this.mail.textEncoding,
|
|
425
|
-
boundaryPrefix: this.mail.boundaryPrefix,
|
|
426
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
427
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
428
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
429
|
-
newline: this.mail.newline
|
|
430
|
-
});
|
|
431
|
-
} else {
|
|
432
|
-
node = parentNode.createChild('multipart/alternative', {
|
|
433
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
434
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
435
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
436
|
-
newline: this.mail.newline
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
this._alternatives.forEach(alternative => {
|
|
441
|
-
if (this._useRelated && this._htmlNode === alternative) {
|
|
442
|
-
this._createRelated(node);
|
|
443
|
-
} else {
|
|
444
|
-
this._createContentNode(node, alternative);
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
return node;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Builds multipart/related node. It should always contain html node with related attachments
|
|
453
|
-
*
|
|
454
|
-
* @param {Object} parentNode Parent for this note. If it does not exist, a root node is created
|
|
455
|
-
* @returns {Object} MimeNode node element
|
|
456
|
-
*/
|
|
457
|
-
_createRelated(parentNode) {
|
|
458
|
-
let node;
|
|
459
|
-
|
|
460
|
-
if (!parentNode) {
|
|
461
|
-
node = new MimeNode('multipart/related; type="text/html"', {
|
|
462
|
-
baseBoundary: this.mail.baseBoundary,
|
|
463
|
-
textEncoding: this.mail.textEncoding,
|
|
464
|
-
boundaryPrefix: this.mail.boundaryPrefix,
|
|
465
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
466
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
467
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
468
|
-
newline: this.mail.newline
|
|
469
|
-
});
|
|
470
|
-
} else {
|
|
471
|
-
node = parentNode.createChild('multipart/related; type="text/html"', {
|
|
472
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
473
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
474
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
475
|
-
newline: this.mail.newline
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
this._createContentNode(node, this._htmlNode);
|
|
480
|
-
|
|
481
|
-
this._attachments.related.forEach(alternative => this._createContentNode(node, alternative));
|
|
482
|
-
|
|
483
|
-
return node;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
* Creates a regular node with contents
|
|
488
|
-
*
|
|
489
|
-
* @param {Object} parentNode Parent for this note. If it does not exist, a root node is created
|
|
490
|
-
* @param {Object} element Node data
|
|
491
|
-
* @returns {Object} MimeNode node element
|
|
492
|
-
*/
|
|
493
|
-
_createContentNode(parentNode, element) {
|
|
494
|
-
element = element || {};
|
|
495
|
-
element.content = element.content || '';
|
|
496
|
-
|
|
497
|
-
let node;
|
|
498
|
-
let encoding = (element.encoding || 'utf8')
|
|
499
|
-
.toString()
|
|
500
|
-
.toLowerCase()
|
|
501
|
-
.replace(/[-_\s]/g, '');
|
|
502
|
-
|
|
503
|
-
if (!parentNode) {
|
|
504
|
-
node = new MimeNode(element.contentType, {
|
|
505
|
-
filename: element.filename,
|
|
506
|
-
baseBoundary: this.mail.baseBoundary,
|
|
507
|
-
textEncoding: this.mail.textEncoding,
|
|
508
|
-
boundaryPrefix: this.mail.boundaryPrefix,
|
|
509
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
510
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
511
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
512
|
-
newline: this.mail.newline
|
|
513
|
-
});
|
|
514
|
-
} else {
|
|
515
|
-
node = parentNode.createChild(element.contentType, {
|
|
516
|
-
filename: element.filename,
|
|
517
|
-
textEncoding: this.mail.textEncoding,
|
|
518
|
-
disableUrlAccess: this.mail.disableUrlAccess,
|
|
519
|
-
disableFileAccess: this.mail.disableFileAccess,
|
|
520
|
-
normalizeHeaderKey: this.mail.normalizeHeaderKey,
|
|
521
|
-
newline: this.mail.newline
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// add custom headers
|
|
526
|
-
if (element.headers) {
|
|
527
|
-
node.addHeader(element.headers);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (element.cid) {
|
|
531
|
-
node.setHeader('Content-Id', '<' + element.cid.replace(/[<>]/g, '') + '>');
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (element.contentTransferEncoding) {
|
|
535
|
-
node.setHeader('Content-Transfer-Encoding', element.contentTransferEncoding);
|
|
536
|
-
} else if (this.mail.encoding && /^text\//i.test(element.contentType)) {
|
|
537
|
-
node.setHeader('Content-Transfer-Encoding', this.mail.encoding);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if (!/^text\//i.test(element.contentType) || element.contentDisposition) {
|
|
541
|
-
node.setHeader(
|
|
542
|
-
'Content-Disposition',
|
|
543
|
-
element.contentDisposition || (element.cid && /^image\//i.test(element.contentType) ? 'inline' : 'attachment')
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
if (typeof element.content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) {
|
|
548
|
-
element.content = Buffer.from(element.content, encoding);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// prefer pregenerated raw content
|
|
552
|
-
if (element.raw) {
|
|
553
|
-
node.setRaw(element.raw);
|
|
554
|
-
} else {
|
|
555
|
-
node.setContent(element.content);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return node;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Parses data uri and converts it to a Buffer
|
|
563
|
-
*
|
|
564
|
-
* @param {Object} element Content element
|
|
565
|
-
* @return {Object} Parsed element
|
|
566
|
-
*/
|
|
567
|
-
_processDataUrl(element) {
|
|
568
|
-
const dataUrl = element.path || element.href;
|
|
569
|
-
|
|
570
|
-
// Early validation to prevent ReDoS
|
|
571
|
-
if (!dataUrl || typeof dataUrl !== 'string') {
|
|
572
|
-
return element;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if (!dataUrl.startsWith('data:')) {
|
|
576
|
-
return element;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
if (dataUrl.length > 52428800) {
|
|
580
|
-
// 52428800 chars = 50MB limit for data URL string (~37.5MB decoded image)
|
|
581
|
-
// Extract content type before rejecting to preserve MIME type
|
|
582
|
-
let detectedType = 'application/octet-stream';
|
|
583
|
-
const commaPos = dataUrl.indexOf(',');
|
|
584
|
-
|
|
585
|
-
if (commaPos > 0 && commaPos < 200) {
|
|
586
|
-
// Parse header safely with size limit
|
|
587
|
-
const header = dataUrl.substring(5, commaPos); // skip 'data:'
|
|
588
|
-
const parts = header.split(';');
|
|
589
|
-
if (parts[0] && parts[0].includes('/')) {
|
|
590
|
-
detectedType = parts[0].trim();
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
// Return empty content for excessively long data URLs
|
|
595
|
-
return Object.assign({}, element, {
|
|
596
|
-
path: false,
|
|
597
|
-
href: false,
|
|
598
|
-
content: Buffer.alloc(0),
|
|
599
|
-
contentType: element.contentType || detectedType
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
let parsedDataUri;
|
|
604
|
-
try {
|
|
605
|
-
parsedDataUri = parseDataURI(dataUrl);
|
|
606
|
-
} catch (_err) {
|
|
607
|
-
return element;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
if (!parsedDataUri) {
|
|
611
|
-
return element;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
element.content = parsedDataUri.data;
|
|
615
|
-
element.contentType = element.contentType || parsedDataUri.contentType;
|
|
616
|
-
|
|
617
|
-
if ('path' in element) {
|
|
618
|
-
element.path = false;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
if ('href' in element) {
|
|
622
|
-
element.href = false;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
return element;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
module.exports = MailComposer;
|