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