From 398152be52b63be2633ce23c626097e6d6656bd8 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 8 Feb 2022 13:48:11 +0100 Subject: [PATCH] Disable Mailvelope "sign" message as it can't choose which key --- dev/Common/Globals.js | 1 + dev/Settings/User/OpenPgp.js | 4 ++-- dev/Stores/User/GnuPG.js | 6 +++--- dev/Stores/User/Pgp.js | 19 ++++++++++--------- dev/View/Popup/Compose.js | 5 ++++- .../templates/Views/User/PopupsCompose.html | 4 ++-- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/dev/Common/Globals.js b/dev/Common/Globals.js index 1a0b50df8..c6aa1d5c0 100644 --- a/dev/Common/Globals.js +++ b/dev/Common/Globals.js @@ -16,6 +16,7 @@ export const Settings = rl.settings, SettingsGet = Settings.get, + SettingsCapa = Settings.capa, dropdownVisibility = ko.observable(false).extend({ rateLimit: 0 }), diff --git a/dev/Settings/User/OpenPgp.js b/dev/Settings/User/OpenPgp.js index 7ac5174a8..544ccb3c0 100644 --- a/dev/Settings/User/OpenPgp.js +++ b/dev/Settings/User/OpenPgp.js @@ -10,7 +10,7 @@ import { OpenPgpImportPopupView } from 'View/Popup/OpenPgpImport'; import { OpenPgpGeneratePopupView } from 'View/Popup/OpenPgpGenerate'; import { Capa } from 'Common/Enums'; -import { Settings } from 'Common/Globals'; +import { SettingsCapa } from 'Common/Globals'; export class OpenPgpUserSettings /*extends AbstractViewSettings*/ { constructor() { @@ -20,7 +20,7 @@ export class OpenPgpUserSettings /*extends AbstractViewSettings*/ { this.openpgpkeysPublic = OpenPGPUserStore.publicKeys; this.openpgpkeysPrivate = OpenPGPUserStore.privateKeys; - this.canOpenPGP = Settings.capa(Capa.OpenPGP); + this.canOpenPGP = SettingsCapa(Capa.OpenPGP); this.canGnuPG = GnuPGUserStore.isSupported(); this.canMailvelope = !!window.mailvelope; diff --git a/dev/Stores/User/GnuPG.js b/dev/Stores/User/GnuPG.js index a034227d9..f8954a91a 100644 --- a/dev/Stores/User/GnuPG.js +++ b/dev/Stores/User/GnuPG.js @@ -1,7 +1,7 @@ import ko from 'ko'; import { Capa } from 'Common/Enums'; -import { Settings } from 'Common/Globals'; +import { SettingsCapa } from 'Common/Globals'; import { delegateRunOnDestroy } from 'Common/UtilsUser'; //import { EmailModel } from 'Model/Email'; @@ -34,7 +34,7 @@ export const GnuPGUserStore = new class { this.privateKeys = ko.observableArray(); } - loadKeyrings(/*identifier*/) { + loadKeyrings() { this.keyring = null; this.publicKeys([]); this.privateKeys([]); @@ -104,7 +104,7 @@ export const GnuPGUserStore = new class { * @returns {boolean} */ isSupported() { - return Settings.capa(Capa.GnuPG); + return SettingsCapa(Capa.GnuPG); } importKey(key, callback) { diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index 8873ede20..28b8c1be8 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -1,5 +1,5 @@ import { Capa } from 'Common/Enums'; -import { doc, createElement, Settings } from 'Common/Globals'; +import { doc, createElement, SettingsCapa, SettingsGet } from 'Common/Globals'; import { staticLink } from 'Common/Links'; //import { showScreenPopup } from 'Knoin/Knoin'; @@ -17,7 +17,7 @@ export const PgpUserStore = new class { } init() { - if (Settings.capa(Capa.OpenPGP) && window.crypto && crypto.getRandomValues) { + if (SettingsCapa(Capa.OpenPGP) && window.crypto && crypto.getRandomValues) { const script = createElement('script', {src:staticLink('js/min/openpgp.min.js')}); script.onload = () => this.loadKeyrings(); script.onerror = () => { @@ -31,11 +31,12 @@ export const PgpUserStore = new class { } loadKeyrings(identifier) { + identifier = identifier || SettingsGet('Email'); if (window.mailvelope) { - var fn = keyring => { - this.mailvelopeKeyring = keyring; - console.log('mailvelope ready'); - }; + const fn = keyring => { + this.mailvelopeKeyring = keyring; + console.log('mailvelope ready'); + }; mailvelope.getKeyring().then(fn, err => { if (identifier) { // attempt to create a new keyring for this app/user @@ -52,11 +53,11 @@ export const PgpUserStore = new class { } if (OpenPGPUserStore.isSupported()) { - OpenPGPUserStore.loadKeyrings(identifier); + OpenPGPUserStore.loadKeyrings(); } - if (Settings.capa(Capa.GnuPG)) { - GnuPGUserStore.loadKeyrings(identifier); + if (SettingsCapa(Capa.GnuPG)) { + GnuPGUserStore.loadKeyrings(); } } diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 06ebc42dd..580281c11 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -1540,6 +1540,8 @@ class ComposePopupView extends AbstractViewPopup { case 'M': quota *= 1024; // fallthrough case 'K': quota *= 1024; } + // Issue: can't select signing key +// this.pgpSign(this.pgpSign() || confirm('Sign this message?')); mailvelope.createEditorContainer('#mailvelope-editor', PgpUserStore.mailvelopeKeyring, { // https://mailvelope.github.io/mailvelope/global.html#EditorContainerOptions quota: Math.max(2048, (quota / 1024)) - 48, // (text + attachments) limit in kilobytes @@ -1550,8 +1552,9 @@ class ComposePopupView extends AbstractViewPopup { quotedMailIndent: true, // if true the quoted mail will be indented (default: true) quotedMailHeader: '', // header to be added before the quoted mail keepAttachments: false, // add attachments of quotedMail to editor (default: false) + // Issue: can't select signing key + signMsg: this.pgpSign() */ - signMsg: this.pgpSign() || confirm('Sign this message?') }).then(editor => this.mailvelope = editor); } this.viewArea('mailvelope'); diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html index fb3e75cec..7c1f7e83b 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html @@ -142,8 +142,8 @@ - - + +