mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 18:05:55 +01:00
server side encryption WIP
This commit is contained in:
@@ -7,6 +7,8 @@ const sql = require('../../services/sql');
|
||||
const options = require('../../services/options');
|
||||
const utils = require('../../services/utils');
|
||||
const notes = require('../../services/notes');
|
||||
const protected_session = require('../../services/protected_session');
|
||||
const data_encryption = require('../../services/data_encryption');
|
||||
|
||||
router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
|
||||
let noteId = req.params.noteId;
|
||||
@@ -20,6 +22,13 @@ router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
|
||||
detail = sql.getSingleResult("select * from notes where note_id = ?", [noteId]);
|
||||
}
|
||||
|
||||
if (detail.encryption > 0) {
|
||||
const dataKey = protected_session.getDataKey(req);
|
||||
|
||||
detail.note_title = data_encryption.decrypt(dataKey, detail.note_title);
|
||||
detail.note_text = data_encryption.decrypt(dataKey, detail.note_text);
|
||||
}
|
||||
|
||||
res.send({
|
||||
detail: detail,
|
||||
images: await sql.getResults("select * from images where note_id = ? order by note_offset", [noteId]),
|
||||
|
||||
Reference in New Issue
Block a user