user: use fixed salt to derive key for encryption

This commit is contained in:
thecodrr
2020-04-13 15:36:51 +05:00
parent ffa1e3b15c
commit a462a02f56
2 changed files with 5 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ export default class Storage {
decrypt(password, cipher) {
return this.storage.decrypt(password, cipher);
}
deriveKey(password) {
return this.storage.deriveKey(password, null, true);
deriveKey(password, salt) {
return this.storage.deriveKey(password, salt, true);
}
}

View File

@@ -16,7 +16,7 @@ export default class User {
async key() {
const user = await this.get();
return user.key;
return { key: user.key, salt: user.salt };
}
async set(user) {
@@ -31,7 +31,7 @@ export default class User {
password,
grant_type: "password",
});
const key = await this.context.deriveKey(password);
const key = await this.context.deriveKey(password, response.payload.salt);
let user = userFromResponse(response, key);
await this.context.write("user", user);
}
@@ -69,7 +69,7 @@ export default class User {
password,
email,
});
const key = await this.context.deriveKey(password);
const key = await this.context.deriveKey(password, response.payload.salt);
let user = userFromResponse(response, key);
await this.context.write("user", user);
}