mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
value fixes
This commit is contained in:
parent
27667a3086
commit
1520f5e0df
@ -1,5 +1,6 @@
|
||||
var CipherString = function (encryptedString) {
|
||||
this.encryptedString = encryptedString;
|
||||
this.decryptedValue = null;
|
||||
|
||||
if (encryptedString) {
|
||||
this.initializationVector = this.encryptedString.split('|')[0];
|
||||
@ -8,18 +9,16 @@ var CipherString = function (encryptedString) {
|
||||
};
|
||||
|
||||
!function () {
|
||||
var _decryptedValue = null;
|
||||
|
||||
CipherString.prototype.decrypt = function (callback) {
|
||||
if (!_decryptedValue) {
|
||||
if (!this.decryptedValue) {
|
||||
var cryptoService = chrome.extension.getBackgroundPage().cryptoService;
|
||||
cryptoService.decrypt(this, function (decValue) {
|
||||
_decryptedValue = decValue;
|
||||
callback(_decryptedValue);
|
||||
this.decryptedValue = decValue;
|
||||
callback(this.decryptedValue);
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback(_decryptedValue);
|
||||
callback(this.decryptedValue);
|
||||
}
|
||||
};
|
||||
}();
|
||||
@ -27,6 +26,7 @@ var CipherString = function (encryptedString) {
|
||||
var Site = function (obj, alreadyEncrypted) {
|
||||
this.id = obj.id ? obj.id : null;
|
||||
this.folderId = obj.folderId ? obj.folderId : null;
|
||||
this.favorite = obj.favorite ? true : false;
|
||||
|
||||
if (alreadyEncrypted === true) {
|
||||
this.name = obj.name ? obj.name : null;
|
||||
@ -42,8 +42,6 @@ var Site = function (obj, alreadyEncrypted) {
|
||||
this.password = obj.password ? new CipherString(obj.password) : null;
|
||||
this.notes = obj.notes ? new CipherString(obj.notes) : null;
|
||||
}
|
||||
|
||||
this.favorite = obj.favorite ? true : false;
|
||||
};
|
||||
|
||||
var Folder = function (obj, alreadyEncrypted) {
|
||||
|
@ -21,9 +21,11 @@
|
||||
id: folders[i].id
|
||||
});
|
||||
|
||||
promises.push(decrypt(folders[j].name, i).then(function (obj) {
|
||||
var folderNamePromise = decrypt(sites[i].name, i);
|
||||
promises.push(folderNamePromise);
|
||||
folderNamePromise.then(function (obj) {
|
||||
decFolders[obj.index].name = obj.val;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
for (var j = 0; j < sites.length; j++) {
|
||||
@ -33,13 +35,17 @@
|
||||
favorite: sites[j].favorite
|
||||
});
|
||||
|
||||
promises.push(decrypt(sites[j].name, j).then(function (obj) {
|
||||
var namePromise = decrypt(sites[j].name, j);
|
||||
promises.push(namePromise);
|
||||
namePromise.then(function (obj) {
|
||||
decSites[obj.index].name = obj.val;
|
||||
}));
|
||||
});
|
||||
|
||||
promises.push(decrypt(sites[j].username, j).then(function (obj) {
|
||||
var usernamePromise = decrypt(sites[j].username, j);
|
||||
promises.push(usernamePromise);
|
||||
usernamePromise.then(function (obj) {
|
||||
decSites[obj.index].username = obj.val;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
$q.all(promises).then(function () {
|
||||
@ -50,13 +56,19 @@
|
||||
});
|
||||
|
||||
function decrypt(cipherString, index) {
|
||||
return $q(function(resolve, reject) {
|
||||
return $q(function (resolve, reject) {
|
||||
if (!cipherString) {
|
||||
resolve({val: null, index: index});
|
||||
resolve({
|
||||
val: null,
|
||||
index: index
|
||||
});
|
||||
}
|
||||
else {
|
||||
cipherString.decrypt(function (decString) {
|
||||
resolve({ val: decString, index: index });
|
||||
resolve({
|
||||
val: decString,
|
||||
index: index
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user