fix(storage-manager): save salt and timestamp
This commit is contained in:
parent
01a5a476c5
commit
8bee033efa
@ -16,8 +16,10 @@ export class StorageManager {
|
|||||||
|
|
||||||
namespace;
|
namespace;
|
||||||
version;
|
version;
|
||||||
|
|
||||||
_options;
|
_options;
|
||||||
_global;
|
_global;
|
||||||
|
_encryptionKey;
|
||||||
|
|
||||||
constructor(namespace, version, options) {
|
constructor(namespace, version, options) {
|
||||||
this.namespace = namespace;
|
this.namespace = namespace;
|
||||||
@ -41,6 +43,7 @@ export class StorageManager {
|
|||||||
else
|
else
|
||||||
throw new Error('Cannot setup StorageManager without window or global');
|
throw new Error('Cannot setup StorageManager without window or global');
|
||||||
|
|
||||||
|
// TODO handle salt and timestamp separately per location
|
||||||
if (this._options.encryption) {
|
if (this._options.encryption) {
|
||||||
const requestBody = {
|
const requestBody = {
|
||||||
type : this._options.encryption,
|
type : this._options.encryption,
|
||||||
@ -61,7 +64,8 @@ export class StorageManager {
|
|||||||
if (response.salt !== requestBody.salt || response.timestamp !== requestBody.timestamp) {
|
if (response.salt !== requestBody.salt || response.timestamp !== requestBody.timestamp) {
|
||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
this.save('encryption', response);
|
this.save('encryption', { salt: response.salt, timestamp: response.timestamp });
|
||||||
|
this._encryptionKey = response.key;
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user