Update openpgpjs 0.3.0 -> 0.5.1 (#142)

This commit is contained in:
RainLoop Team 2014-04-26 20:09:38 +04:00
parent 1ed1efbe6c
commit 61a7a9c078
23 changed files with 160 additions and 228 deletions

View file

@ -385,7 +385,7 @@ RainLoopApp.prototype.reloadOpenPgpKeys = function ()
aKeys = [],
oEmail = new EmailModel(),
oOpenpgpKeyring = RL.data().openpgpKeyring,
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.keys : []
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : []
;
_.each(oOpenpgpKeys, function (oItem, iIndex) {
@ -1035,7 +1035,7 @@ RainLoopApp.prototype.bootstart = function ()
'success': function () {
if (window.openpgp)
{
RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver());
RL.data().openpgpKeyring = new window.openpgp.Keyring();
RL.data().allowOpenPGP(true);
RL.pub('openpgp.init');

View file

@ -271,7 +271,7 @@ LinkBuilder.prototype.notificationMailIcon = function ()
LinkBuilder.prototype.openPgpJs = function ()
{
return ('' === this.sCdnStaticDomain ? 'rainloop/v/' : this.sCdnStaticDomain) +
this.sVersion + '/static/js/openpgp.js';
this.sVersion + '/static/js/openpgp.min.js';
};
/**

View file

@ -53,33 +53,16 @@ SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
{
this.openPgpKeyForDeletion(null);
var
iFindIndex = -1,
oOpenpgpKeyring = RL.data().openpgpKeyring,
fRemoveAccount = function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
}
;
if (oOpenPgpKeyToRemove && oOpenpgpKeyring)
if (oOpenPgpKeyToRemove && RL.data().openpgpKeyring)
{
this.openpgpkeys.remove(fRemoveAccount);
_.each(oOpenpgpKeyring.keys, function (oKey, iIndex) {
if (-1 === iFindIndex && oKey && oKey.primaryKey &&
oOpenPgpKeyToRemove.guid === oKey.primaryKey.getFingerprint() &&
oOpenPgpKeyToRemove.isPrivate === oKey.isPrivate())
{
iFindIndex = iIndex;
}
this.openpgpkeys.remove(function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
if (0 <= iFindIndex)
{
oOpenpgpKeyring.removeKey(iFindIndex);
}
RL.data().openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oOpenPgpKeyToRemove.guid);
oOpenpgpKeyring.store();
RL.data().openpgpKeyring.store();
RL.reloadOpenPgpKeys();
}

View file

@ -1,60 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function OpenPgpLocalStorageDriver()
{
}
/*
* Declare the localstore itemname
*/
OpenPgpLocalStorageDriver.prototype.item = 'armoredRainLoopKeys';
/**
* Load the keyring from HTML5 local storage and initializes this instance.
* @return {Array<module:key~Key>} array of keys retrieved from localstore
*/
OpenPgpLocalStorageDriver.prototype.load = function ()
{
var
iIndex = 0,
iLen = 0,
aKeys = [],
aArmoredKeys = JSON.parse(window.localStorage.getItem(this.item))
;
if (aArmoredKeys && 0 < aArmoredKeys.length)
{
for (iLen = aArmoredKeys.length; iIndex < iLen; iIndex++)
{
aKeys.push(
window.openpgp.key.readArmored(aArmoredKeys[iIndex]).keys[0]
);
}
}
return aKeys;
};
/**
* Saves the current state of the keyring to HTML5 local storage.
* The privateKeys array and publicKeys array gets Stringified using JSON
* @param {Array<module:key~Key>} aKeys array of keys to save in localstore
*/
OpenPgpLocalStorageDriver.prototype.store = function (aKeys)
{
var
iIndex = 0,
iLen = aKeys.length,
aArmoredKeys = []
;
for (; iIndex < iLen; iIndex++)
{
aArmoredKeys.push(aKeys[iIndex].armor());
}
window.localStorage.setItem(this.item, JSON.stringify(aArmoredKeys));
};

View file

@ -106,7 +106,11 @@ html.rl-started-trigger.no-mobile #rl-content {
animation: animate-stripes 2s linear infinite;
}
&.csstransitions .b-settings-folders {
&.csstransitions .button-delete-transitions {
.transition(all 0.2s linear);
}
/* &.csstransitions .b-settings-folders {
.folder-item {
.button-delete {
.transition(all 0.2s linear);
@ -142,7 +146,7 @@ html.rl-started-trigger.no-mobile #rl-content {
.button-delete {
.transition(margin-left 0.2s linear);
}
}
}*/
&.cssanimations .b-folders .e-item .anim-action-class {
-webkit-animation: highlight-folder-row 0.5s linear;

View file

@ -19,7 +19,10 @@ function PopupsAddOpenPgpKeyViewModel()
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
var
iCount = 30,
aMatch = null,
sKey = Utils.trim(this.key()),
oReg = /[\-]{3,6}BEGIN PGP (PRIVATE|PUBLIC) KEY BLOCK[\-]{3,6}[\s\S]+[\-]{3,6}END PGP (PRIVATE|PUBLIC) KEY BLOCK[\-]{3,6}/gi,
oOpenpgpKeyring = RL.data().openpgpKeyring
;
@ -30,7 +33,30 @@ function PopupsAddOpenPgpKeyViewModel()
return false;
}
oOpenpgpKeyring.importKey(sKey);
do
{
aMatch = oReg.exec(sKey);
if (!aMatch || 0 > iCount)
{
break;
}
if (aMatch[0] && aMatch[1] && aMatch[2] && aMatch[1] === aMatch[2])
{
if ('PRIVATE' === aMatch[1])
{
oOpenpgpKeyring.privateKeys.importKey(aMatch[0]);
}
else if ('PUBLIC' === aMatch[1])
{
oOpenpgpKeyring.publicKeys.importKey(aMatch[0]);
}
}
iCount--;
}
while (true);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();

View file

@ -49,10 +49,10 @@ function PopupsGenerateNewOpenPgpKeyViewModel()
mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password()));
if (mKeyPair && mKeyPair.privateKeyArmored)
{
oOpenpgpKeyring.importKey(mKeyPair.privateKeyArmored);
oOpenpgpKeyring.importKey(mKeyPair.publicKeyArmored);
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
Utils.delegateRun(self, 'cancelCommand');
}