snappymail/dev/Stores/User/Pgp.js

120 lines
2.2 KiB
JavaScript
Raw Normal View History

2015-02-01 23:44:44 +08:00
(function () {
'use strict';
2015-02-03 07:58:58 +08:00
var
ko = require('ko')
;
2015-02-01 23:44:44 +08:00
/**
* @constructor
*/
function PgpUserStore()
{
2015-02-03 07:58:58 +08:00
this.capaOpenPGP = ko.observable(false);
2015-02-01 23:44:44 +08:00
this.openpgp = null;
2015-02-03 07:58:58 +08:00
this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null;
2015-02-01 23:44:44 +08:00
2015-02-03 07:58:58 +08:00
this.openpgpkeysPublic = this.openpgpkeys.filter(function (oItem) {
return !!(oItem && !oItem.isPrivate);
});
2015-02-01 23:44:44 +08:00
2015-02-03 07:58:58 +08:00
this.openpgpkeysPrivate = this.openpgpkeys.filter(function (oItem) {
return !!(oItem && oItem.isPrivate);
});
}
2015-02-01 23:44:44 +08:00
2015-02-03 07:58:58 +08:00
// PgpUserStore.prototype.sign = function (sText, oPrivateKey)
// {
// try
// {
// return this.openpgp.signClearMessage([oPrivateKey], sText);
// }
// catch (oExc) {}
//
// return sText;
// };
//
// PgpUserStore.prototype.encrypt = function (sText, aPublicKeys)
// {
// try
// {
// return this.openpgp.encryptMessage(aPublicKeys, sText);
// }
// catch (oExc) {}
//
// return sText;
// };
//
// PgpUserStore.prototype.signAndEncrypt = function (sText, aPublicKeys, oPrivateKey)
// {
// try
// {
// return this.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, sText);
// }
// catch (oExc) {}
//
// return sText;
// };
//
// /**/
//
// PgpUserStore.prototype.verify = function (sText, aPublicKeys)
// {
// var
// mPgpMessage = null
// ;
//
// try
// {
// mPgpMessage = this.openpgp.cleartext.readArmored(sText);
// if (mPgpMessage && mPgpMessage.getText)
// {
// mPgpMessage.verify(aPublicKeys);
// }
// }
// catch (oExc) {}
//
// return false;
// };
//
// PgpUserStore.prototype.decryptAndVerify = function (sEnctyptedText, aPublicKeys, oPivateKey)
// {
// var
// mPgpMessageDecrypted = null,
// mPgpMessage = null
// ;
//
// try
// {
// mPgpMessage = this.openpgp.message.readArmored(sEnctyptedText);
// if (mPgpMessage && oPivateKey && mPgpMessage.decrypt)
// {
// mPgpMessageDecrypted = mPgpMessage.decrypt(oPivateKey);
// if (mPgpMessageDecrypted)
// {
// mPgpMessageDecrypted.verify(aPublicKeys);
// }
// }
// }
// catch (oExc) {}
//
// return false;
// };
2015-02-01 23:44:44 +08:00
/**
* @return {boolean}
*/
PgpUserStore.prototype.isSupported = function ()
{
return !!this.openpgp;
};
module.exports = new PgpUserStore();
}());