mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
OpenPGP - part 2 - unstable (#53)
This commit is contained in:
parent
d181974127
commit
0bb69d4494
23 changed files with 600 additions and 339 deletions
|
|
@ -6,6 +6,7 @@
|
|||
function AdminSecurity()
|
||||
{
|
||||
this.csrfProtection = ko.observable(!!RL.settingsGet('UseTokenProtection'));
|
||||
this.openPGP = ko.observable(!!RL.settingsGet('OpenPGP'));
|
||||
|
||||
this.adminLogin = ko.observable(RL.settingsGet('AdminLogin'));
|
||||
this.adminPassword = ko.observable('');
|
||||
|
|
@ -65,6 +66,12 @@ AdminSecurity.prototype.onBuild = function ()
|
|||
'TokenProtection': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.openPGP.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
||||
'OpenPGP': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
AdminSecurity.prototype.onHide = function ()
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
|||
*/
|
||||
AbstractApp.prototype.pub = function (sName, aArgs)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||
if (!Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
_.each(this.oSubs[sName], function (aItem) {
|
||||
|
|
|
|||
|
|
@ -703,6 +703,7 @@ RainLoopApp.prototype.mailToHelper = function (sMailToUrl)
|
|||
|
||||
RainLoopApp.prototype.bootstart = function ()
|
||||
{
|
||||
RL.pub('rl.bootstart');
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
RL.data().populateDataOnStart();
|
||||
|
|
@ -785,17 +786,26 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
if (bValue)
|
||||
{
|
||||
// if (window.crypto && window.crypto.getRandomValues)
|
||||
// {
|
||||
// $.ajax({
|
||||
// 'url': RL.link().openPgpJs(),
|
||||
// 'dataType': 'script',
|
||||
// 'cache': true,
|
||||
// 'success': function () {
|
||||
// window.console.log('openPgpJs');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
if (window.crypto && window.crypto.getRandomValues && RL.settingsGet('OpenPGP'))
|
||||
{
|
||||
$.ajax({
|
||||
'url': RL.link().openPgpJs(),
|
||||
'dataType': 'script',
|
||||
'cache': true,
|
||||
'success': function () {
|
||||
if (window.openpgp)
|
||||
{
|
||||
// window.console.log(window.openpgp);
|
||||
Globals.bAllowOpenPGP = true;
|
||||
RL.pub('openpgp.init');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.bAllowOpenPGP = false;
|
||||
}
|
||||
|
||||
kn.startScreens([MailBoxScreen, SettingsScreen]);
|
||||
|
||||
|
|
@ -846,13 +856,15 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
}, 2000);
|
||||
|
||||
|
||||
Plugins.runHook('rl-start-user-screens');
|
||||
RL.pub('rl.bootstart-user-screens');
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([LoginScreen]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
RL.pub('rl.bootstart-login-screens');
|
||||
}
|
||||
|
||||
if (window.SimplePace)
|
||||
|
|
@ -878,6 +890,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
kn.startScreens([LoginScreen]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
RL.pub('rl.bootstart-login-screens');
|
||||
|
||||
if (window.SimplePace)
|
||||
{
|
||||
|
|
@ -925,6 +938,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
});
|
||||
|
||||
Plugins.runHook('rl-start-screens');
|
||||
RL.pub('rl.bootstart-end');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
|||
*/
|
||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAllowOpenPGP = false;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -82,11 +82,16 @@ function MessageModel()
|
|||
}, this);
|
||||
|
||||
this.body = null;
|
||||
this.plainRaw = '';
|
||||
this.isRtl = ko.observable(false);
|
||||
this.isHtml = ko.observable(false);
|
||||
this.hasImages = ko.observable(false);
|
||||
this.attachments = ko.observableArray([]);
|
||||
|
||||
this.isPgpSigned = ko.observable(false);
|
||||
this.isPgpEncrypted = ko.observable(false);
|
||||
this.pgpSignature = ko.observable('');
|
||||
|
||||
this.priority = ko.observable(Enums.MessagePriority.Normal);
|
||||
this.readReceipt = ko.observable('');
|
||||
|
||||
|
|
@ -253,6 +258,10 @@ MessageModel.prototype.clear = function ()
|
|||
this.isHtml(false);
|
||||
this.hasImages(false);
|
||||
this.attachments([]);
|
||||
|
||||
this.isPgpSigned(false);
|
||||
this.isPgpEncrypted(false);
|
||||
this.pgpSignature('');
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.readReceipt('');
|
||||
|
|
@ -347,6 +356,13 @@ MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
|
|||
this.sInReplyTo = oJsonMessage.InReplyTo;
|
||||
this.sReferences = oJsonMessage.References;
|
||||
|
||||
if (Globals.bAllowOpenPGP)
|
||||
{
|
||||
this.isPgpSigned(!!oJsonMessage.PgpSigned);
|
||||
this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted);
|
||||
this.pgpSignature(oJsonMessage.PgpSignature);
|
||||
}
|
||||
|
||||
this.hasAttachments(!!oJsonMessage.HasAttachments);
|
||||
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
|
||||
|
||||
|
|
@ -808,6 +824,10 @@ MessageModel.prototype.populateByMessageListItem = function (oMessage)
|
|||
// this.hasImages(false);
|
||||
// this.attachments([]);
|
||||
|
||||
// this.isPgpSigned(false);
|
||||
// this.isPgpEncrypted(false);
|
||||
// this.pgpSignature('');
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.aDraftInfo = [];
|
||||
this.sMessageId = '';
|
||||
|
|
|
|||
|
|
@ -709,6 +709,10 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody = null,
|
||||
oTextBody = null,
|
||||
sId = '',
|
||||
sPlain = '',
|
||||
bPgpSigned = false,
|
||||
bPgpEncrypted = false,
|
||||
mPgpMessage = null,
|
||||
oMessagesBodiesDom = this.messagesBodiesDom(),
|
||||
oMessage = this.message()
|
||||
;
|
||||
|
|
@ -747,7 +751,57 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
|
||||
{
|
||||
bIsHtml = false;
|
||||
oBody.html(oData.Result.Plain.toString()).addClass('b-text-part plain');
|
||||
sPlain = oData.Result.Plain.toString();
|
||||
|
||||
if (Globals.bAllowOpenPGP && (oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) &&
|
||||
Utils.isNormal(oData.Result.PlainRaw))
|
||||
{
|
||||
bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw);
|
||||
if (!bPgpEncrypted)
|
||||
{
|
||||
bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oData.Result.PlainRaw) &&
|
||||
/-----BEGIN PGP SIGNATURE-----/.test(oData.Result.PlainRaw);
|
||||
}
|
||||
|
||||
if (bPgpSigned && oMessage.isPgpSigned() && oMessage.pgpSignature())
|
||||
{
|
||||
sPlain = '<pre class="b-plain-openpgp signed">' + oData.Result.PlainRaw + '</pre>';
|
||||
|
||||
try
|
||||
{
|
||||
mPgpMessage = window.openpgp.cleartext.readArmored(oData.Result.PlainRaw);
|
||||
}
|
||||
catch (oExc) {}
|
||||
|
||||
if (mPgpMessage && mPgpMessage.getText)
|
||||
{
|
||||
sPlain = mPgpMessage.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
bPgpSigned = false;
|
||||
}
|
||||
}
|
||||
else if (bPgpEncrypted && oMessage.isPgpEncrypted())
|
||||
{
|
||||
try
|
||||
{
|
||||
mPgpMessage = window.openpgp.message.readArmored(oData.Result.PlainRaw);
|
||||
}
|
||||
catch (oExc) {}
|
||||
|
||||
sPlain = '<pre class="b-plain-openpgp encrypted">' + oData.Result.PlainRaw + '</pre>';
|
||||
}
|
||||
|
||||
if (bPgpSigned || bPgpEncrypted)
|
||||
{
|
||||
oBody.data('rl-plain-raw', oData.Result.PlainRaw);
|
||||
oBody.data('rl-plain-pgp-encrypted', bPgpEncrypted);
|
||||
oBody.data('rl-plain-pgp-signed', bPgpSigned);
|
||||
}
|
||||
}
|
||||
|
||||
oBody.html(sPlain).addClass('b-text-part plain');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -760,15 +814,19 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody.addClass('rtl-text-part');
|
||||
}
|
||||
|
||||
oMessagesBodiesDom.append(oBody);
|
||||
|
||||
oBody.data('rl-is-html', bIsHtml);
|
||||
oBody.data('rl-has-images', bHasExternals);
|
||||
|
||||
oMessage.isRtl(!!oBody.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oBody.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oBody.data('rl-has-images'));
|
||||
oMessage.body = oBody;
|
||||
if (oMessage.body)
|
||||
{
|
||||
oMessagesBodiesDom.append(oMessage.body);
|
||||
|
||||
oMessage.body.data('rl-is-html', bIsHtml);
|
||||
oMessage.body.data('rl-has-images', bHasExternals);
|
||||
|
||||
oMessage.isRtl(!!oMessage.body.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oMessage.body.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oMessage.body.data('rl-has-images'));
|
||||
oMessage.plainRaw = Utils.pString(oMessage.body.data('rl-plain-raw'));
|
||||
}
|
||||
|
||||
if (bHasInternals)
|
||||
{
|
||||
|
|
@ -784,12 +842,26 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
}
|
||||
else
|
||||
{
|
||||
oTextBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
|
||||
|
||||
oMessage.isRtl(!!oTextBody.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oTextBody.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oTextBody.data('rl-has-images'));
|
||||
oMessage.body = oTextBody;
|
||||
if (oMessage.body)
|
||||
{
|
||||
oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
|
||||
oMessage.isRtl(!!oMessage.body.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oMessage.body.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oMessage.body.data('rl-has-images'));
|
||||
oMessage.plainRaw = Utils.pString(oMessage.body.data('rl-plain-raw'));
|
||||
}
|
||||
}
|
||||
|
||||
if (Globals.bAllowOpenPGP && oMessage.body)
|
||||
{
|
||||
oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed'));
|
||||
oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
oMessage.isPgpSigned(false);
|
||||
oMessage.isPgpEncrypted(false);
|
||||
}
|
||||
|
||||
this.messageActiveDom(oMessage.body);
|
||||
|
|
|
|||
|
|
@ -145,24 +145,4 @@
|
|||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.editorTextArea, .editorHtmlArea {
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
font-size: 14px;
|
||||
|
||||
table {
|
||||
border-collapse: separate;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border: 0;
|
||||
border-left: solid 2px #444;
|
||||
margin-left: 5px;
|
||||
margin: 5px 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,12 +76,15 @@
|
|||
|
||||
.box-sizing(border-box);
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
|
||||
border: 0px !important;
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
|
||||
|
|
@ -102,9 +105,11 @@
|
|||
}
|
||||
|
||||
blockquote {
|
||||
border: 0;
|
||||
border-left: solid 2px #444;
|
||||
margin-left: 5px;
|
||||
padding-left: 5px
|
||||
margin: 5px 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
img {
|
||||
|
|
@ -119,14 +124,17 @@
|
|||
.editorTextArea {
|
||||
.box-sizing(border-box);
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
|
||||
display: block;
|
||||
border: 0px !important;
|
||||
width: 100%;
|
||||
line-height: 16px;
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 14px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ html.rl-no-preview-pane {
|
|||
height: 0px;
|
||||
}
|
||||
|
||||
.showImages, .readReceipt {
|
||||
.showImages, .readReceipt, .pgpSigned, .pgpEncrypted {
|
||||
cursor: pointer;
|
||||
padding: 10px 15px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
|
|
@ -192,6 +192,10 @@ html.rl-no-preview-pane {
|
|||
background-color: #ffffd9;
|
||||
}
|
||||
|
||||
.pgpSigned, .pgpEncrypted {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.attachmentsPlace {
|
||||
|
||||
padding: 10px;
|
||||
|
|
@ -306,16 +310,15 @@ html.rl-no-preview-pane {
|
|||
&.plain {
|
||||
|
||||
padding: 15px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
|
||||
pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: arial, sans-serif;
|
||||
background: #fff;
|
||||
border: none;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
|
||||
blockquote {
|
||||
border-left: 2px solid blue;
|
||||
color: blue;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ function MailBoxMessageViewViewModel()
|
|||
this.viewDownloadLink = ko.observable('');
|
||||
this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic);
|
||||
this.viewUserPicVisible = ko.observable(false);
|
||||
|
||||
|
||||
this.message.subscribe(function (oMessage) {
|
||||
|
||||
this.messageActiveDom(null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue