mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
user: use fixed salt to derive key for encryption
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user