Android security implementation Phase 3.1
This commit is contained in:
+9
-6
@@ -168,23 +168,26 @@ pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false) {
|
||||
|
||||
// Called by the send handler. Returns null (plain mail), false (cancelled) or send options.
|
||||
async function prepareSend(to, cc) {
|
||||
if (!pgpApi()) return null;
|
||||
if (!pgpApi()) return null;
|
||||
const plaintextFallback = () => pgpApi().platform === 'android'
|
||||
? { encrypt: false, sign: false, plaintextFallback: true }
|
||||
: null;
|
||||
let encrypt = Boolean(selectPgpMailUi('#pgp-encrypt')?.checked);
|
||||
const sign = Boolean(selectPgpMailUi('#pgp-sign')?.checked);
|
||||
if (!encrypt && !sign && selectPgpMailUi('#pgp-encrypt')?.dataset.touched === '1') return null;
|
||||
const status = await pgpApi().checkSend({ to, cc, sign });
|
||||
// The default-on update is debounced, so a quick send could skip encryption even though keys exist.
|
||||
if (!encrypt && !status.missing.length && status.recipients.length && selectPgpMailUi('#pgp-encrypt')?.dataset.touched !== '1') {
|
||||
if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) {
|
||||
if (!sign) return null;
|
||||
if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) {
|
||||
if (!sign) return plaintextFallback();
|
||||
} else return false;
|
||||
}
|
||||
if (!encrypt && !sign) return null;
|
||||
if (encrypt && status.missing.length) {
|
||||
const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`);
|
||||
if (!sendPlain) return false;
|
||||
encrypt = false;
|
||||
if (!sign) return null;
|
||||
if (!sendPlain) return false;
|
||||
encrypt = false;
|
||||
if (!sign) return plaintextFallback();
|
||||
}
|
||||
let passphrase = null;
|
||||
if (sign) {
|
||||
|
||||
@@ -9974,11 +9974,11 @@ ${parts.join("")}`;
|
||||
storePromise = null;
|
||||
throw error;
|
||||
});
|
||||
return storePromise;
|
||||
return storePromise.then((value) => JSON.parse(JSON.stringify(value)));
|
||||
}
|
||||
async function persist(value) {
|
||||
await EpMail2.pgpSaveStore({ store: value });
|
||||
storePromise = value;
|
||||
storePromise = Promise.resolve(JSON.parse(JSON.stringify(value)));
|
||||
}
|
||||
function cache(fingerprint, passphrase) {
|
||||
if (!cacheMinutes) {
|
||||
@@ -10488,7 +10488,13 @@ Only continue if you checked this fingerprint with the owner.`)) throw new Error
|
||||
saveAttachment: (details) => EpMail.saveAttachment(details),
|
||||
openExternal: (url) => EpMail.openExternal({ url }),
|
||||
send: async (message) => {
|
||||
if (!message?.pgp || !message.pgp.encrypt && !message.pgp.sign) return EpMail.send(message);
|
||||
if (!message?.pgp || !message.pgp.encrypt && !message.pgp.sign) {
|
||||
if (message?.pgp?.plaintextFallback) {
|
||||
const { pgp: _options, ...plainMessage } = message;
|
||||
return EpMail.send({ ...plainMessage, pgpRequested: true });
|
||||
}
|
||||
return EpMail.send(message);
|
||||
}
|
||||
try {
|
||||
const { rawBase64, to: to2, from } = await daybreakMail.pgp.buildOutgoing(message);
|
||||
const { pgp: _options, text: _text, attachments: _attachments, ...headers } = message;
|
||||
|
||||
Reference in New Issue
Block a user