mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Split OpenPGP.js and GnuPG from PgpUserStore
This commit is contained in:
parent
76226f45ca
commit
76361a13da
6 changed files with 453 additions and 369 deletions
|
|
@ -29,6 +29,7 @@ import { IdentityUserStore } from 'Stores/User/Identity';
|
|||
import { AccountUserStore } from 'Stores/User/Account';
|
||||
import { FolderUserStore } from 'Stores/User/Folder';
|
||||
import { PgpUserStore } from 'Stores/User/Pgp';
|
||||
import { OpenPGPUserStore } from 'Stores/User/OpenPGP';
|
||||
import { MessageUserStore } from 'Stores/User/Message';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
|
@ -458,10 +459,10 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
if ('openpgp' == sign) {
|
||||
let privateKey;
|
||||
try {
|
||||
const keys = PgpUserStore.getOpenPGPPrivateKeyFor(this.currentIdentity().email());
|
||||
if (keys[0]) {
|
||||
keys[0].decrypt(window.prompt('Passphrase'));
|
||||
cfg.privateKey = privateKey = keys[0];
|
||||
const key = OpenPGPUserStore.getPrivateKeyFor(this.currentIdentity().email());
|
||||
if (key) {
|
||||
key.decrypt(window.prompt('Passphrase'));
|
||||
cfg.privateKey = privateKey = key;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
@ -477,7 +478,7 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
// error 'sign and encrypt must be same engine';
|
||||
} else if ('openpgp' == encrypt) {
|
||||
this.allRecipients().forEach(recEmail => {
|
||||
cfg.publicKeys = cfg.publicKeys.concat(PgpUserStore.getOpenPGPPublicKeyFor(recEmail));
|
||||
cfg.publicKeys = cfg.publicKeys.concat(OpenPGPUserStore.getPublicKeyFor(recEmail));
|
||||
});
|
||||
pgpPromise = openpgp.encrypt(cfg);
|
||||
} else if ('openpgp' == sign) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import { PgpUserStore } from 'Stores/User/Pgp';
|
||||
import { GnuPGUserStore } from 'Stores/User/GnuPG';
|
||||
import { OpenPGPUserStore } from 'Stores/User/OpenPGP';
|
||||
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
import { Capa } from 'Common/Enums';
|
||||
import { Settings } from 'Common/Globals';
|
||||
|
||||
export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||
constructor() {
|
||||
super('OpenPgpImport');
|
||||
|
|
@ -18,7 +16,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
|||
saveServer: true
|
||||
});
|
||||
|
||||
this.canGnuPG = Settings.capa(Capa.GnuPG);
|
||||
this.canGnuPG = GnuPGUserStore.isSupported();
|
||||
|
||||
this.key.subscribe(() => {
|
||||
this.keyError(false);
|
||||
|
|
@ -50,16 +48,8 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
|||
match = reg.exec(keyTrimmed);
|
||||
if (match && 0 < count) {
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2]) {
|
||||
let err = null;
|
||||
if (this.saveGnuPG()) {
|
||||
PgpUserStore.gnupgImportKey(this.key());
|
||||
}
|
||||
PgpUserStore.openpgpImportKey(this.key());
|
||||
if (err) {
|
||||
this.keyError(true);
|
||||
this.keyErrorMessage(err && err[0] ? '' + err[0] : '');
|
||||
console.log(err);
|
||||
}
|
||||
this.saveGnuPG() && GnuPGUserStore.isSupported() && GnuPGUserStore.importKey(this.key());
|
||||
OpenPGPUserStore.isSupported() && OpenPGPUserStore.importKey(this.key());
|
||||
}
|
||||
|
||||
--count;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue