Add ANDROID_SECURITY_PLAN.md to project
This commit is contained in:
+49
-12
@@ -1,3 +1,5 @@
|
||||
require('v8-compile-cache');
|
||||
|
||||
const startupTraceEnabled = process.env.EP_MAIL_STARTUP_TRACE === '1';
|
||||
const startupTraceStartedAt = process.hrtime.bigint();
|
||||
function traceStartup(message) {
|
||||
@@ -11,13 +13,44 @@ const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, p
|
||||
const fsSync = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs/promises');
|
||||
const { ImapFlow } = require('imapflow');
|
||||
const nodemailer = require('nodemailer');
|
||||
const { simpleParser } = require('mailparser');
|
||||
const { randomUUID } = require('node:crypto');
|
||||
const { createDAVClient } = require('tsdav');
|
||||
const ICAL = require('ical.js');
|
||||
const openpgp = require('openpgp');
|
||||
|
||||
let tsdavPromise = null;
|
||||
function getTsdav() {
|
||||
if (!tsdavPromise) tsdavPromise = import('tsdav');
|
||||
return tsdavPromise;
|
||||
}
|
||||
|
||||
let icalPromise = null;
|
||||
function getICAL() {
|
||||
if (!icalPromise) icalPromise = import('ical.js');
|
||||
return icalPromise;
|
||||
}
|
||||
|
||||
let openpgpPromise = null;
|
||||
function getOpenPGP() {
|
||||
if (!openpgpPromise) openpgpPromise = import('openpgp');
|
||||
return openpgpPromise;
|
||||
}
|
||||
|
||||
let imapFlowPromise = null;
|
||||
function getImapFlow() {
|
||||
if (!imapFlowPromise) imapFlowPromise = import('imapflow');
|
||||
return imapFlowPromise;
|
||||
}
|
||||
|
||||
let nodemailerPromise = null;
|
||||
function getNodemailer() {
|
||||
if (!nodemailerPromise) nodemailerPromise = import('nodemailer');
|
||||
return nodemailerPromise;
|
||||
}
|
||||
|
||||
let mailparserPromise = null;
|
||||
function getMailparser() {
|
||||
if (!mailparserPromise) mailparserPromise = import('mailparser');
|
||||
return mailparserPromise;
|
||||
}
|
||||
|
||||
const { createKeyServerService, listServers, MAX_CUSTOM_SERVERS, normalizeCustomServer } = require('./pgp-keyservers.cjs');
|
||||
const { normalizeOutgoingAttachments, serializeOutgoingAttachments } = require('./mail-attachments.cjs');
|
||||
const {
|
||||
@@ -52,6 +85,8 @@ const { pgpFailure, registerPgpIpcHandlers } = require('./ipc/pgp.cjs');
|
||||
const { registerDavIpcHandlers } = require('./ipc/dav.cjs');
|
||||
const { registerMailIpcHandlers } = require('./ipc/mail.cjs');
|
||||
|
||||
traceStartup('all requires complete');
|
||||
|
||||
const credentialsPath = () => path.join(app.getPath('userData'), 'mail-account.enc');
|
||||
const davCredentialsPath = () => path.join(app.getPath('userData'), 'dav-accounts.enc');
|
||||
const pgpKeysPath = () => path.join(app.getPath('userData'), 'pgp-keys.enc');
|
||||
@@ -204,6 +239,7 @@ function davPublicConfig(config) {
|
||||
}
|
||||
|
||||
async function openDavClient(config, type) {
|
||||
const { createDAVClient } = await getTsdav();
|
||||
return createDAVClient({ serverUrl: config.serverUrl, credentials: { username: config.username, password: config.password }, authMethod: 'Basic', defaultAccountType: type });
|
||||
}
|
||||
|
||||
@@ -214,8 +250,8 @@ function activeDavConfig(store, type, id = null) {
|
||||
}
|
||||
|
||||
const { imapClient, smtpTransport } = createMailConnections({
|
||||
ImapFlow,
|
||||
createTransport: nodemailer.createTransport,
|
||||
getImapFlow,
|
||||
getNodemailer,
|
||||
oauthTokenManager
|
||||
});
|
||||
|
||||
@@ -290,6 +326,7 @@ function cachedMailbox(account, folder, offset = 0, limit = 20, filters = {}) {
|
||||
}
|
||||
|
||||
async function toUiMessage(item, folder) {
|
||||
const { simpleParser } = await getMailparser();
|
||||
const parsed = await simpleParser(item.source);
|
||||
const sender = parsed.from?.value?.[0];
|
||||
const pgpKind = pgpMail.detect(parsed);
|
||||
@@ -410,7 +447,7 @@ registerPgpIpcHandlers({
|
||||
BrowserWindow,
|
||||
dialog,
|
||||
fs,
|
||||
openpgp,
|
||||
getOpenPGP,
|
||||
pgpKeys,
|
||||
pgpCache,
|
||||
pgpMail,
|
||||
@@ -423,7 +460,7 @@ registerPgpIpcHandlers({
|
||||
readAccount,
|
||||
imapClient,
|
||||
folderPath,
|
||||
simpleParser,
|
||||
getMailparser,
|
||||
extractMailContent
|
||||
});
|
||||
const { sendMailNow } = createMailSender({ smtpTransport, imapClient, findSentMailbox });
|
||||
@@ -500,7 +537,7 @@ registerMailIpcHandlers({
|
||||
mailOutbox,
|
||||
pgpMail,
|
||||
PgpError,
|
||||
simpleParser,
|
||||
getMailparser,
|
||||
folderPath,
|
||||
sendMailNow,
|
||||
pgpFailure
|
||||
@@ -513,7 +550,7 @@ registerDavIpcHandlers({
|
||||
davPublicConfig,
|
||||
openDavClient,
|
||||
activeDavConfig,
|
||||
ICAL,
|
||||
getICAL,
|
||||
makeCalendarData,
|
||||
makeVcard,
|
||||
randomUUID,
|
||||
|
||||
Reference in New Issue
Block a user