mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 17:02:17 -05:00
integrated crypto lib changes into device storage dao
This commit is contained in:
parent
1e27297013
commit
bdab0e19c1
@ -43,13 +43,13 @@ app.dao.DeviceStorage = function(util, crypto, jsonDao, sqlcipherDao) {
|
|||||||
* @param offset [Number] The offset of items to fetch (0 is the last stored item)
|
* @param offset [Number] The offset of items to fetch (0 is the last stored item)
|
||||||
* @param num [Number] The number of items to fetch (null means fetch all)
|
* @param num [Number] The number of items to fetch (null means fetch all)
|
||||||
*/
|
*/
|
||||||
this.listItems = function(type, offset, num, callback) {
|
this.listItems = function(type, offset, num, senderPubkeys, callback) {
|
||||||
|
|
||||||
// fetch all items of a certain type from the data-store
|
// fetch all items of a certain type from the data-store
|
||||||
jsonDao.list(crypto.emailAddress + '_' + type, offset, num, function(encryptedList) {
|
jsonDao.list(crypto.emailAddress + '_' + type, offset, num, function(encryptedList) {
|
||||||
|
|
||||||
// decrypt list
|
// decrypt list
|
||||||
crypto.decryptListForUser(encryptedList, null, function(err, decryptedList) {
|
crypto.decryptListForUser(encryptedList, senderPubkeys, function(err, decryptedList) {
|
||||||
callback(err, decryptedList);
|
callback(err, decryptedList);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,9 @@ asyncTest("Init", 3, function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("Encrypt list for user", 2, function() {
|
asyncTest("Encrypt list for user", 2, function() {
|
||||||
devicestorage_test.crypto.encryptListForUser(devicestorage_test.list, null, function(err, encryptedList) {
|
var receiverPubkeys = [devicestorage_test.crypto.getPublicKey()];
|
||||||
|
|
||||||
|
devicestorage_test.crypto.encryptListForUser(devicestorage_test.list, receiverPubkeys, function(err, encryptedList) {
|
||||||
ok(!err);
|
ok(!err);
|
||||||
equal(encryptedList.length, devicestorage_test.list.length, 'Encrypt list');
|
equal(encryptedList.length, devicestorage_test.list.length, 'Encrypt list');
|
||||||
|
|
||||||
@ -58,11 +60,13 @@ asyncTest("Store encrypted list", 1, function() {
|
|||||||
|
|
||||||
asyncTest("List items", 3, function() {
|
asyncTest("List items", 3, function() {
|
||||||
|
|
||||||
|
var senderPubkeys = [devicestorage_test.crypto.getPublicKey()];
|
||||||
|
|
||||||
var offset = 2,
|
var offset = 2,
|
||||||
num = 6;
|
num = 6;
|
||||||
|
|
||||||
// list items from storage (decrypted)
|
// list items from storage (decrypted)
|
||||||
devicestorage_test.storage.listItems('email_inbox_5', offset, num, function(err, decryptedList) {
|
devicestorage_test.storage.listItems('email_inbox_5', offset, num, senderPubkeys, function(err, decryptedList) {
|
||||||
ok(!err);
|
ok(!err);
|
||||||
equal(decryptedList.length, num, 'Found ' + decryptedList.length + ' items in store (and decrypted)');
|
equal(decryptedList.length, num, 'Found ' + decryptedList.length + ' items in store (and decrypted)');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user