fix(storage-manager): correctly use encryption key in decrypt call

This commit is contained in:
Sarah Vaupel 2020-02-01 14:57:24 +01:00
parent 001614522e
commit 9e9726e173

View File

@ -300,7 +300,7 @@ export class StorageManager {
_getFromStorage(storage, location, options=this._options) {
const encryption = options.encryption && (options.encryption.all || options.encryption[location]);
if (encryption && storage.encryption) {
return { ...storage, ...JSON.parse(decrypt(storage.encryption.ciphertext, encryption.key) || '{}') };
return { ...storage, ...JSON.parse(decrypt(storage.encryption.ciphertext, this._encryptionKey[location]) || '{}') };
} else {
return storage;
}
@ -365,7 +365,7 @@ function encrypt(plaintext, key) {
sodium.crypto_secretbox_easy(cipherB, plaintextB, nonceB, keyB);
return cipherB.toString('base64');
return cipherB;
}
// TODO debug unnecessary calls of decrypt