refactoring / unification of note encryption / decryption

This commit is contained in:
azivner
2018-01-24 22:13:41 -05:00
parent 18709eb340
commit 74fff39c3f
7 changed files with 105 additions and 69 deletions

View File

@@ -7,7 +7,6 @@ const options = require('../../services/options');
const utils = require('../../services/utils');
const auth = require('../../services/auth');
const protected_session = require('../../services/protected_session');
const data_encryption = require('../../services/data_encryption');
const sync_table = require('../../services/sync_table');
const wrap = require('express-promise-wrap').wrap;
@@ -27,13 +26,7 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
ORDER BY
note_position`);
const dataKey = protected_session.getDataKey(req);
for (const note of notes) {
if (note.is_protected) {
note.note_title = data_encryption.decryptString(dataKey, data_encryption.noteTitleIv(note.note_id), note.note_title);
}
}
protected_session.decryptNotes(req, notes);
res.send({
notes: notes,