mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
refactoring / unification of note encryption / decryption
This commit is contained in:
@@ -4,7 +4,6 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
const sql = require('../../services/sql');
|
||||
const auth = require('../../services/auth');
|
||||
const data_encryption = require('../../services/data_encryption');
|
||||
const protected_session = require('../../services/protected_session');
|
||||
const sync_table = require('../../services/sync_table');
|
||||
const wrap = require('express-promise-wrap').wrap;
|
||||
@@ -12,15 +11,7 @@ const wrap = require('express-promise-wrap').wrap;
|
||||
router.get('/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const noteId = req.params.noteId;
|
||||
const history = await sql.getAll("SELECT * FROM notes_history WHERE note_id = ? order by date_modified_to desc", [noteId]);
|
||||
|
||||
const dataKey = protected_session.getDataKey(req);
|
||||
|
||||
for (const hist of history) {
|
||||
if (hist.is_protected) {
|
||||
hist.note_title = data_encryption.decryptString(dataKey, data_encryption.noteTitleIv(hist.note_history_id), hist.note_title);
|
||||
hist.note_text = data_encryption.decryptString(dataKey, data_encryption.noteTextIv(hist.note_history_id), hist.note_text);
|
||||
}
|
||||
}
|
||||
protected_session.decryptNoteHistoryRows(req, history);
|
||||
|
||||
res.send(history);
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user