freedom-pgp-e2e
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -18,2 +18,3 @@ /*globals freedom, console, e2e, exports, ArrayBuffer, Uint8Array, Uint16Array, DataView*/ | ||
this.pgpUser = null; | ||
this.storage = new store(); | ||
}; | ||
@@ -40,3 +41,14 @@ | ||
mye2e.prototype.clear = function() { | ||
// e2e can only store one private key in LocalStorage | ||
// Attempting to set another will result in an HMAC error | ||
// So, make sure to clear before doing so | ||
// See googstorage.js for details on how storage works | ||
if (this.storage.get('UserKeyRing')) { | ||
this.storage.remove('UserKeyRing'); | ||
} | ||
}; | ||
mye2e.prototype.importKeypair = function(passphrase, userid, privateKey) { | ||
this.clear(); | ||
this.pgpContext.setKeyRingPassphrase(passphrase); | ||
@@ -46,3 +58,3 @@ this.importKey(privateKey, passphrase); | ||
if (e2e.async.Result.getValue( | ||
this.pgpContext.searchPrivateKey(userid)).length === 0 || | ||
this.pgpContext.searchPrivateKey(userid)).length === 0 || | ||
e2e.async.Result.getValue( | ||
@@ -49,0 +61,0 @@ this.pgpContext.searchPublicKey(userid)).length === 0) { |
@@ -5,3 +5,7 @@ | ||
this.memStorage = {}; | ||
this.initialize(); | ||
this.freedomStorage.get('UserKeyRing').then(function(value) { | ||
if (value) { | ||
this.memStorage.UserKeyRing = value; | ||
} | ||
}); | ||
} | ||
@@ -31,3 +35,5 @@ | ||
this.memStorage = {}; | ||
this.freedomStorage.clear(); | ||
if (this.freedomStorage) { | ||
this.freedomStorage.clear(); | ||
} | ||
}; | ||
@@ -71,18 +77,2 @@ | ||
store.prototype.initialize = function() { | ||
this.memStorage = store.preparedMem; | ||
}; | ||
store.preparedMem = {}; | ||
store.prepareFreedom = function() { | ||
freedomStorage = freedom['core.storage'](); | ||
return freedomStorage.get('UserKeyRing').then(function(value) { | ||
if (value) { | ||
store.preparedMem.UserKeyRing = value; | ||
} | ||
}); | ||
}; | ||
goog.storage.mechanism.HTML5LocalStorage = store; |
@@ -7,3 +7,3 @@ { | ||
"end-to-end.compiled.js", | ||
"googstorage_mock.js", | ||
"googstorage.js", | ||
"e2e.js" | ||
@@ -40,4 +40,12 @@ ] | ||
"clear": { | ||
"_comment": "Clear local storage, resetting priavte key", | ||
"type": "method", | ||
"value": [], | ||
"ret": [], | ||
"err": { "errcode": "string", "message": "string" } | ||
}, | ||
"importKeypair": { | ||
"_comment": "Import a pre-existing public/private keypair", | ||
"_comment": "Import a public/private keypair, overwriting if needed", | ||
"type": "method", | ||
@@ -44,0 +52,0 @@ "value": ["string", "string", "string"], |
{ | ||
"name": "freedom-pgp-e2e", | ||
"description": "Library to provide freedom API wrapper of end-to-end library", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"contributors": [ | ||
@@ -14,3 +14,3 @@ "Aaron Gallant <ag@cs.washington.edu>" | ||
"e2e": "^0.0.5", | ||
"es6-promise": "^2.2.0", | ||
"es6-promise": "^2.3.0", | ||
"freedom": "^0.6.25", | ||
@@ -32,3 +32,3 @@ "freedom-for-chrome": "^0.4.19", | ||
"karma-chrome-launcher": "^0.1.12", | ||
"karma-coverage": "^0.3.1", | ||
"karma-coverage": "^0.4.2", | ||
"karma-firefox-launcher": "^0.1.6", | ||
@@ -35,0 +35,0 @@ "karma-jasmine": "^0.3.5", |
@@ -18,2 +18,3 @@ /*globals freedom,Uint8Array,ArrayBuffer*/ | ||
this.dispatch('print', 'Starting encryption test!'); | ||
Promise.resolve(e2e.clear()); // clear any existing private key | ||
e2e.setup('secret passphrase', 'Joe Test <joetest@example.com>').then( | ||
@@ -67,4 +68,6 @@ function () { | ||
function (e) { | ||
this.dispatch('print', 'Keypair import test encountered error %1', | ||
[e]); | ||
if (e.message) { | ||
e = e.message; | ||
} | ||
this.dispatch('print', 'Keypair import test encountered error ' + e); | ||
}.bind(this)); | ||
@@ -71,0 +74,0 @@ }; |
@@ -18,2 +18,3 @@ /*globals freedom, console, e2e, exports, ArrayBuffer, Uint8Array, Uint16Array, DataView*/ | ||
this.pgpUser = null; | ||
this.storage = new store(); | ||
}; | ||
@@ -40,3 +41,14 @@ | ||
mye2e.prototype.clear = function() { | ||
// e2e can only store one private key in LocalStorage | ||
// Attempting to set another will result in an HMAC error | ||
// So, make sure to clear before doing so | ||
// See googstorage.js for details on how storage works | ||
if (this.storage.get('UserKeyRing')) { | ||
this.storage.remove('UserKeyRing'); | ||
} | ||
}; | ||
mye2e.prototype.importKeypair = function(passphrase, userid, privateKey) { | ||
this.clear(); | ||
this.pgpContext.setKeyRingPassphrase(passphrase); | ||
@@ -46,3 +58,3 @@ this.importKey(privateKey, passphrase); | ||
if (e2e.async.Result.getValue( | ||
this.pgpContext.searchPrivateKey(userid)).length === 0 || | ||
this.pgpContext.searchPrivateKey(userid)).length === 0 || | ||
e2e.async.Result.getValue( | ||
@@ -49,0 +61,0 @@ this.pgpContext.searchPublicKey(userid)).length === 0) { |
@@ -5,3 +5,7 @@ | ||
this.memStorage = {}; | ||
this.initialize(); | ||
this.freedomStorage.get('UserKeyRing').then(function(value) { | ||
if (value) { | ||
this.memStorage.UserKeyRing = value; | ||
} | ||
}); | ||
} | ||
@@ -31,3 +35,5 @@ | ||
this.memStorage = {}; | ||
this.freedomStorage.clear(); | ||
if (this.freedomStorage) { | ||
this.freedomStorage.clear(); | ||
} | ||
}; | ||
@@ -71,18 +77,2 @@ | ||
store.prototype.initialize = function() { | ||
this.memStorage = store.preparedMem; | ||
}; | ||
store.preparedMem = {}; | ||
store.prepareFreedom = function() { | ||
freedomStorage = freedom['core.storage'](); | ||
return freedomStorage.get('UserKeyRing').then(function(value) { | ||
if (value) { | ||
store.preparedMem.UserKeyRing = value; | ||
} | ||
}); | ||
}; | ||
goog.storage.mechanism.HTML5LocalStorage = store; |
@@ -7,3 +7,3 @@ { | ||
"end-to-end.compiled.js", | ||
"googstorage_mock.js", | ||
"googstorage.js", | ||
"e2e.js" | ||
@@ -40,4 +40,12 @@ ] | ||
"clear": { | ||
"_comment": "Clear local storage, resetting priavte key", | ||
"type": "method", | ||
"value": [], | ||
"ret": [], | ||
"err": { "errcode": "string", "message": "string" } | ||
}, | ||
"importKeypair": { | ||
"_comment": "Import a pre-existing public/private keypair", | ||
"_comment": "Import a public/private keypair, overwriting if needed", | ||
"type": "method", | ||
@@ -44,0 +52,0 @@ "value": ["string", "string", "string"], |
Sorry, the diff of this file is not supported yet
1823069
14708