mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
parent
1d3673f117
commit
ce971de919
5 changed files with 74 additions and 58 deletions
|
@ -21,6 +21,7 @@ export class OpenPgpUserSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.canOpenPGP = !!PgpUserStore.openpgpKeyring;
|
||||
// this.canOpenPGP = Settings.capa(Capa.OpenPGP);
|
||||
this.canMailvelope = !!window.mailvelope;
|
||||
|
||||
this.allowDraftAutosave = SettingsUserStore.allowDraftAutosave;
|
||||
|
||||
|
@ -41,6 +42,11 @@ export class OpenPgpUserSettings /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
window.mailvelope
|
||||
&& mailvelope.createSettingsContainer('#mailvelope-settings'/*[, keyring], options*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {OpenPgpKeyModel} openPgpKeyToRemove
|
||||
* @returns {void}
|
||||
|
|
|
@ -270,21 +270,24 @@ export const PgpUserStore = new class {
|
|||
* @returns {void}
|
||||
*/
|
||||
deleteKey(openPgpKeyToRemove) {
|
||||
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess() && this.openpgpKeyring) {
|
||||
let findedItem = this.openpgpPublicKeys.find(key => openPgpKeyToRemove === key);
|
||||
if (findedItem) {
|
||||
this.openpgpPublicKeys.remove(findedItem);
|
||||
this.openpgpKeyring.publicKeys.removeForId(findedItem.guid);
|
||||
} else {
|
||||
findedItem = this.openpgpPrivateKeys.find(key => openPgpKeyToRemove === key);
|
||||
if (findedItem) {
|
||||
this.openpgpPrivateKeys.remove(findedItem);
|
||||
this.openpgpKeyring.privateKeys.removeForId(findedItem.guid);
|
||||
}
|
||||
const openpgpKeyring = this.openpgpKeyring;
|
||||
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess() && openpgpKeyring) {
|
||||
let items = [
|
||||
this.openpgpPrivateKeys.find(key => openPgpKeyToRemove === key),
|
||||
this.openpgpPublicKeys.find(key => openPgpKeyToRemove === key)
|
||||
];
|
||||
if (items[0]) {
|
||||
this.openpgpPrivateKeys.remove(items[0]);
|
||||
openpgpKeyring.privateKeys.removeForId(items[0].guid);
|
||||
delegateRunOnDestroy(items[0]);
|
||||
}
|
||||
if (findedItem) {
|
||||
delegateRunOnDestroy(findedItem);
|
||||
this.openpgpKeyring.store();
|
||||
if (items[1]) {
|
||||
this.openpgpPublicKeys.remove(items[1]);
|
||||
openpgpKeyring.publicKeys.removeForId(items[1].guid);
|
||||
delegateRunOnDestroy(items[1]);
|
||||
}
|
||||
if (items[0] || items[1]) {
|
||||
openpgpKeyring.store();
|
||||
}
|
||||
// this.reloadOpenPgpKeys();
|
||||
}
|
||||
|
|
|
@ -635,52 +635,54 @@ export class MailMessageView extends AbstractViewRight {
|
|||
pgpVerify(self) {
|
||||
const message = self.message();
|
||||
if (message && PgpUserStore.isSupported()) {
|
||||
const mode = PgpUserStore.hasPublicKeyForEmails([message.from[0].email()]);
|
||||
if ('gnupg' === mode) {
|
||||
let params = message.pgpSigned(); // { BodyPartId: "1", SigPartId: "2", MicAlg: "pgp-sha256" }
|
||||
if (params) {
|
||||
params.Folder = message.folder;
|
||||
params.Uid = message.uid;
|
||||
rl.app.Remote.post('MessagePgpVerify', null, params)
|
||||
.then(data => {
|
||||
// TODO
|
||||
console.dir(data);
|
||||
})
|
||||
.catch(error => {
|
||||
// TODO
|
||||
console.dir(error);
|
||||
});
|
||||
}
|
||||
} else if ('openpgp' === mode) {
|
||||
let text = null;
|
||||
try {
|
||||
text = PgpUserStore.openpgp.cleartext.readArmored(message.plain);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (text && text.getText && text.verify) {
|
||||
PgpUserStore.verifyMessage(text, (validKey, signingKeyIds) => {
|
||||
console.dir([validKey, signingKeyIds]);
|
||||
/*
|
||||
if (validKey) {
|
||||
i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
USER: validKey.user + ' (' + validKey.id + ')'
|
||||
PgpUserStore.hasPublicKeyForEmails([message.from[0].email]).then(mode => {
|
||||
if ('gnupg' === mode) {
|
||||
let params = message.pgpSigned(); // { BodyPartId: "1", SigPartId: "2", MicAlg: "pgp-sha256" }
|
||||
if (params) {
|
||||
params.Folder = message.folder;
|
||||
params.Uid = message.uid;
|
||||
rl.app.Remote.post('MessagePgpVerify', null, params)
|
||||
.then(data => {
|
||||
// TODO
|
||||
console.dir(data);
|
||||
})
|
||||
.catch(error => {
|
||||
// TODO
|
||||
console.dir(error);
|
||||
});
|
||||
message.getText()
|
||||
} else {
|
||||
const keyIds = arrayLength(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds
|
||||
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(v => v).join(', ')
|
||||
: '';
|
||||
}
|
||||
} else if ('openpgp' === mode) {
|
||||
let text = null;
|
||||
try {
|
||||
// TODO: if message.pgpSigned().SigPartId then fetch raw from server
|
||||
text = PgpUserStore.openpgp.cleartext.readArmored(message.plain);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (text && text.getText && text.verify) {
|
||||
PgpUserStore.verifyMessage(text, (validKey, signingKeyIds) => {
|
||||
console.dir([validKey, signingKeyIds]);
|
||||
/*
|
||||
if (validKey) {
|
||||
i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
USER: validKey.user + ' (' + validKey.id + ')'
|
||||
});
|
||||
message.getText()
|
||||
} else {
|
||||
const keyIds = arrayLength(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds
|
||||
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(v => v).join(', ')
|
||||
: '';
|
||||
|
||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : '');
|
||||
}
|
||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : '');
|
||||
}
|
||||
*/
|
||||
});
|
||||
} else {
|
||||
// controlsHelper(dom, this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
});
|
||||
} else {
|
||||
// controlsHelper(dom, this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -602,7 +602,7 @@ class GnuPG
|
|||
return $this->GPG->verify($signed_text, $signature, $plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->verify($signed_text, $signature = '');
|
||||
return $this->Crypt_GPG->verify($signed_text, $signature);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ class GnuPG
|
|||
return $this->GPG->verifyFile($filename, $signature, $plaintext);
|
||||
}
|
||||
if ($this->Crypt_GPG) {
|
||||
return $this->Crypt_GPG->verifyFile($filename, $signature = '');
|
||||
return $this->Crypt_GPG->verifyFile($filename, $signature);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -83,3 +83,8 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- ko if: canMailvelope -->
|
||||
<h1>Mailvelope</h1>
|
||||
<div id="mailvelope-settings" style="height:40em"></div>
|
||||
<!-- /ko -->
|
||||
|
|
Loading…
Reference in a new issue