mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-25 16:59:17 +01:00
reject referred instead of throwing exceptions
This commit is contained in:
parent
98b12d1e40
commit
81101f2890
@ -322,7 +322,8 @@ function initCryptoService(constantsService) {
|
|||||||
self.getKey(function (localKey) {
|
self.getKey(function (localKey) {
|
||||||
key = key || localKey;
|
key = key || localKey;
|
||||||
if (!key) {
|
if (!key) {
|
||||||
throw 'Encryption key unavailable.';
|
deferred.reject('Encryption key unavailable.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plainValueEncoding = plainValueEncoding || 'utf8';
|
plainValueEncoding = plainValueEncoding || 'utf8';
|
||||||
@ -350,15 +351,16 @@ function initCryptoService(constantsService) {
|
|||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
try {
|
|
||||||
if (cipherString === null || cipherString === undefined || !cipherString.encryptedString) {
|
if (cipherString === null || cipherString === undefined || !cipherString.encryptedString) {
|
||||||
throw 'cannot decrypt nothing';
|
deferred.reject('cannot decrypt nothing');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.getKey(function (localKey) {
|
self.getKey(function (localKey) {
|
||||||
key = key || localKey;
|
key = key || localKey;
|
||||||
if (!key) {
|
if (!key) {
|
||||||
throw 'Encryption key unavailable.';
|
deferred.reject('Encryption key unavailable.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputEncoding = outputEncoding || 'utf8';
|
outputEncoding = outputEncoding || 'utf8';
|
||||||
@ -372,7 +374,8 @@ function initCryptoService(constantsService) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cipherString.encryptionType !== key.encType) {
|
if (cipherString.encryptionType !== key.encType) {
|
||||||
throw 'encType unavailable.';
|
deferred.reject('encType unavailable.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ivBytes = forge.util.decode64(cipherString.initializationVector);
|
var ivBytes = forge.util.decode64(cipherString.initializationVector);
|
||||||
@ -403,10 +406,6 @@ function initCryptoService(constantsService) {
|
|||||||
|
|
||||||
deferred.resolve(decValue);
|
deferred.resolve(decValue);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
deferred.reject('Decryption failed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user