fix(storage-manager): save salt and timestamp

This commit is contained in:
Sarah Vaupel 2020-01-28 19:41:43 +01:00
parent 01a5a476c5
commit 8bee033efa

View File

@ -16,8 +16,10 @@ export class StorageManager {
namespace;
version;
_options;
_global;
_encryptionKey;
constructor(namespace, version, options) {
this.namespace = namespace;
@ -41,6 +43,7 @@ export class StorageManager {
else
throw new Error('Cannot setup StorageManager without window or global');
// TODO handle salt and timestamp separately per location
if (this._options.encryption) {
const requestBody = {
type : this._options.encryption,
@ -61,7 +64,8 @@ export class StorageManager {
if (response.salt !== requestBody.salt || response.timestamp !== requestBody.timestamp) {
this.clear();
}
this.save('encryption', response);
this.save('encryption', { salt: response.salt, timestamp: response.timestamp });
this._encryptionKey = response.key;
}).catch(console.error);
}
}