Review security and fix some security bugs add some features to TODO.md
This commit is contained in:
+20
-1
@@ -1383,7 +1383,26 @@ ipcMain.handle('pgp:add-contact', async (event, input) => {
|
||||
}
|
||||
return pgpKeys.addContact({ armoredKey, source: input?.source === 'message' ? 'message' : 'import' });
|
||||
});
|
||||
ipcMain.handle('pgp:set-trust', (_event, fingerprint, trust) => pgpKeys.setTrust(pgpFingerprint(fingerprint), String(trust)));
|
||||
ipcMain.handle('pgp:set-trust', async (event, fingerprint, trust) => {
|
||||
const id = pgpFingerprint(fingerprint);
|
||||
const level = String(trust);
|
||||
// Raising trust changes which key outgoing mail is encrypted to, so confirm it here, outside the renderer.
|
||||
if (level !== 'unknown') {
|
||||
const contact = (await pgpKeys.listContacts()).find(item => item.fingerprint === id);
|
||||
if (!contact) throw new Error('That contact key was not found.');
|
||||
const { response } = await dialog.showMessageBox(BrowserWindow.fromWebContents(event.sender), {
|
||||
type: 'question',
|
||||
buttons: ['Cancel', `Mark as ${level}`],
|
||||
defaultId: 0,
|
||||
cancelId: 0,
|
||||
title: 'Confirm key trust',
|
||||
message: `Mark this key as ${level}?`,
|
||||
detail: `${contact.name || ''} ${(contact.emails || []).join(', ')}\nFingerprint:\n${id.replace(/(.{4})/g, '$1 ').trim()}\n\nOnly continue if you checked this fingerprint with the owner.`
|
||||
});
|
||||
if (response !== 1) throw new Error('Trust change cancelled.');
|
||||
}
|
||||
return pgpKeys.setTrust(id, level);
|
||||
});
|
||||
ipcMain.handle('pgp:remove-contact', (_event, fingerprint) => pgpKeys.removeContact(pgpFingerprint(fingerprint)));
|
||||
ipcMain.handle('pgp:export-contact', async (event, fingerprint) => {
|
||||
const id = pgpFingerprint(fingerprint);
|
||||
|
||||
Reference in New Issue
Block a user