mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
separate DB connection for each transaction (just for the record, will be reverted probably)
This commit is contained in:
@@ -11,18 +11,18 @@ async function verifyPassword(password) {
|
||||
return givenPasswordHash === dbPasswordHash;
|
||||
}
|
||||
|
||||
async function setDataKey(password, plainTextDataKey) {
|
||||
async function setDataKey(db, password, plainTextDataKey) {
|
||||
const passwordDerivedKey = await my_scrypt.getPasswordDerivedKey(password);
|
||||
|
||||
const encryptedDataKeyIv = utils.randomSecureToken(16).slice(0, 16);
|
||||
|
||||
await options.setOption('encrypted_data_key_iv', encryptedDataKeyIv);
|
||||
await options.setOption(db, 'encrypted_data_key_iv', encryptedDataKeyIv);
|
||||
|
||||
const buffer = Buffer.from(plainTextDataKey);
|
||||
|
||||
const newEncryptedDataKey = data_encryption.encrypt(passwordDerivedKey, encryptedDataKeyIv, buffer);
|
||||
|
||||
await options.setOption('encrypted_data_key', newEncryptedDataKey);
|
||||
await options.setOption(db, 'encrypted_data_key', newEncryptedDataKey);
|
||||
}
|
||||
|
||||
async function getDataKey(password) {
|
||||
|
||||
Reference in New Issue
Block a user