mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03: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 = !!PgpUserStore.openpgpKeyring;
|
||||||
// this.canOpenPGP = Settings.capa(Capa.OpenPGP);
|
// this.canOpenPGP = Settings.capa(Capa.OpenPGP);
|
||||||
|
this.canMailvelope = !!window.mailvelope;
|
||||||
|
|
||||||
this.allowDraftAutosave = SettingsUserStore.allowDraftAutosave;
|
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
|
* @param {OpenPgpKeyModel} openPgpKeyToRemove
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
|
|
|
||||||
|
|
@ -270,21 +270,24 @@ export const PgpUserStore = new class {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
deleteKey(openPgpKeyToRemove) {
|
deleteKey(openPgpKeyToRemove) {
|
||||||
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess() && this.openpgpKeyring) {
|
const openpgpKeyring = this.openpgpKeyring;
|
||||||
let findedItem = this.openpgpPublicKeys.find(key => openPgpKeyToRemove === key);
|
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess() && openpgpKeyring) {
|
||||||
if (findedItem) {
|
let items = [
|
||||||
this.openpgpPublicKeys.remove(findedItem);
|
this.openpgpPrivateKeys.find(key => openPgpKeyToRemove === key),
|
||||||
this.openpgpKeyring.publicKeys.removeForId(findedItem.guid);
|
this.openpgpPublicKeys.find(key => openPgpKeyToRemove === key)
|
||||||
} else {
|
];
|
||||||
findedItem = this.openpgpPrivateKeys.find(key => openPgpKeyToRemove === key);
|
if (items[0]) {
|
||||||
if (findedItem) {
|
this.openpgpPrivateKeys.remove(items[0]);
|
||||||
this.openpgpPrivateKeys.remove(findedItem);
|
openpgpKeyring.privateKeys.removeForId(items[0].guid);
|
||||||
this.openpgpKeyring.privateKeys.removeForId(findedItem.guid);
|
delegateRunOnDestroy(items[0]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (findedItem) {
|
if (items[1]) {
|
||||||
delegateRunOnDestroy(findedItem);
|
this.openpgpPublicKeys.remove(items[1]);
|
||||||
this.openpgpKeyring.store();
|
openpgpKeyring.publicKeys.removeForId(items[1].guid);
|
||||||
|
delegateRunOnDestroy(items[1]);
|
||||||
|
}
|
||||||
|
if (items[0] || items[1]) {
|
||||||
|
openpgpKeyring.store();
|
||||||
}
|
}
|
||||||
// this.reloadOpenPgpKeys();
|
// this.reloadOpenPgpKeys();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -635,52 +635,54 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
pgpVerify(self) {
|
pgpVerify(self) {
|
||||||
const message = self.message();
|
const message = self.message();
|
||||||
if (message && PgpUserStore.isSupported()) {
|
if (message && PgpUserStore.isSupported()) {
|
||||||
const mode = PgpUserStore.hasPublicKeyForEmails([message.from[0].email()]);
|
PgpUserStore.hasPublicKeyForEmails([message.from[0].email]).then(mode => {
|
||||||
if ('gnupg' === mode) {
|
if ('gnupg' === mode) {
|
||||||
let params = message.pgpSigned(); // { BodyPartId: "1", SigPartId: "2", MicAlg: "pgp-sha256" }
|
let params = message.pgpSigned(); // { BodyPartId: "1", SigPartId: "2", MicAlg: "pgp-sha256" }
|
||||||
if (params) {
|
if (params) {
|
||||||
params.Folder = message.folder;
|
params.Folder = message.folder;
|
||||||
params.Uid = message.uid;
|
params.Uid = message.uid;
|
||||||
rl.app.Remote.post('MessagePgpVerify', null, params)
|
rl.app.Remote.post('MessagePgpVerify', null, params)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
// TODO
|
// TODO
|
||||||
console.dir(data);
|
console.dir(data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// TODO
|
// TODO
|
||||||
console.dir(error);
|
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 + ')'
|
|
||||||
});
|
});
|
||||||
message.getText()
|
}
|
||||||
} else {
|
} else if ('openpgp' === mode) {
|
||||||
const keyIds = arrayLength(signingKeyIds) ? signingKeyIds : null,
|
let text = null;
|
||||||
additional = keyIds
|
try {
|
||||||
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(v => v).join(', ')
|
// 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 {
|
} else {
|
||||||
// controlsHelper(dom, this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
// controlsHelper(dom, this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -602,7 +602,7 @@ class GnuPG
|
||||||
return $this->GPG->verify($signed_text, $signature, $plaintext);
|
return $this->GPG->verify($signed_text, $signature, $plaintext);
|
||||||
}
|
}
|
||||||
if ($this->Crypt_GPG) {
|
if ($this->Crypt_GPG) {
|
||||||
return $this->Crypt_GPG->verify($signed_text, $signature = '');
|
return $this->Crypt_GPG->verify($signed_text, $signature);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -619,7 +619,7 @@ class GnuPG
|
||||||
return $this->GPG->verifyFile($filename, $signature, $plaintext);
|
return $this->GPG->verifyFile($filename, $signature, $plaintext);
|
||||||
}
|
}
|
||||||
if ($this->Crypt_GPG) {
|
if ($this->Crypt_GPG) {
|
||||||
return $this->Crypt_GPG->verifyFile($filename, $signature = '');
|
return $this->Crypt_GPG->verifyFile($filename, $signature);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,3 +83,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<!-- ko if: canMailvelope -->
|
||||||
|
<h1>Mailvelope</h1>
|
||||||
|
<div id="mailvelope-settings" style="height:40em"></div>
|
||||||
|
<!-- /ko -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue