Phase 02 OpenPGP implementation

This commit is contained in:
2026-11-03 15:28:43 +02:00
parent 0250743250
commit a42774dcf1
25 changed files with 21119 additions and 162 deletions
+23 -7
View File
@@ -1,12 +1,15 @@
import { Capacitor, registerPlugin } from '@capacitor/core';
import { Capacitor, registerPlugin } from '@capacitor/core';
import { createAndroidPgp } from './android-pgp.js';
const EpMail = registerPlugin('EpMail');
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
window.daybreakMail = {
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
const daybreakMail = {
getAppVersion: () => EpMail.getAppVersion().then(result => result.version),
getNotificationPrivacy: () => EpMail.getNotificationPrivacy(),
setNotificationDetails: enabled => EpMail.setNotificationDetails({ enabled }),
getAppLockSettings: () => EpMail.getAppLockSettings(),
setAppLockEnabled: enabled => EpMail.setAppLockEnabled({ enabled }),
getAccount: () => EpMail.getAccount(),
listAccounts: () => EpMail.listAccounts(),
selectAccount: id => EpMail.selectAccount({ id }),
@@ -27,7 +30,18 @@ if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
previewAttachment: details => EpMail.previewAttachment(details),
saveAttachment: details => EpMail.saveAttachment(details),
openExternal: url => EpMail.openExternal({ url }),
send: message => EpMail.send(message),
send: async message => {
if (!message?.pgp || (!message.pgp.encrypt && !message.pgp.sign)) return EpMail.send(message);
try {
const { rawBase64, to, from } = await daybreakMail.pgp.buildOutgoing(message);
const { pgp: _options, text: _text, attachments: _attachments, ...headers } = message;
return await EpMail.send({ ...headers, rawBase64, envelope: { from, to }, text: '', attachments: [] });
} catch (error) {
return { failed: true, code: error.code || 'PGP_ERROR', message: error.message || 'Could not encrypt this message.' };
}
},
pgpGetMessageSource: details => EpMail.pgpGetMessageSource(details),
savePgpAttachment: details => EpMail.savePgpAttachment(details),
disconnect: id => EpMail.removeAccount({ id }),
davList: () => EpMail.davList(),
davConnect: config => EpMail.davConnect(config),
@@ -37,6 +51,8 @@ if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
davSaveEvent: event => EpMail.davSaveEvent(event),
davDeleteEvent: remote => EpMail.davDeleteEvent(remote),
davSaveContact: contact => EpMail.davSaveContact(contact),
davDeleteContact: remote => EpMail.davDeleteContact(remote)
};
}
davDeleteContact: remote => EpMail.davDeleteContact(remote)
};
daybreakMail.pgp = createAndroidPgp({ EpMail, getAccount: () => EpMail.getAccount() });
window.daybreakMail = daybreakMail;
}