fix(storage-manager): save salt and timestamp
This commit is contained in:
parent
01a5a476c5
commit
8bee033efa
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user