removed dataKey where it's not necessary anymore (use of CLS instead)

This commit is contained in:
azivner
2018-03-31 08:53:52 -04:00
parent 5d203b2278
commit 05676f3459
12 changed files with 78 additions and 105 deletions

View File

@@ -37,21 +37,18 @@ async function uploadFile(req) {
async function downloadFile(req, res) {
const noteId = req.params.noteId;
const note = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]);
const protectedSessionId = req.query.protectedSessionId;
if (!note) {
return res.status(404).send(`Note ${noteId} doesn't exist.`);
}
if (note.isProtected) {
const dataKey = protected_session.getDataKeyForProtectedSessionId(protectedSessionId);
if (!dataKey) {
if (!protected_session.isProtectedSessionAvailable()) {
res.status(401).send("Protected session not available");
return;
}
protected_session.decryptNote(dataKey, note);
protected_session.decryptNote(note);
}
const labelMap = await labels.getNoteLabelMap(noteId);

View File

@@ -6,7 +6,7 @@ const protected_session = require('../../services/protected_session');
async function getNoteRevisions(req) {
const noteId = req.params.noteId;
const revisions = await sql.getRows("SELECT * FROM note_revisions WHERE noteId = ? order by dateModifiedTo desc", [noteId]);
protected_session.decryptNoteRevisions(req, revisions);
protected_session.decryptNoteRevisions(revisions);
return revisions;
}

View File

@@ -20,7 +20,7 @@ async function getNote(req) {
return [404, "Note " + noteId + " has not been found."];
}
protected_session.decryptNote(req, note);
protected_session.decryptNote(note);
if (note.type === 'file') {
// no need to transfer (potentially large) file payload for this request
@@ -46,24 +46,21 @@ async function createNote(req) {
async function updateNote(req) {
const note = req.body;
const noteId = req.params.noteId;
const dataKey = protected_session.getDataKey(req);
await notes.updateNote(noteId, note, dataKey);
await notes.updateNote(noteId, note);
}
async function sortNotes(req) {
const noteId = req.params.noteId;
const dataKey = protected_session.getDataKey(req);
await tree.sortNotesAlphabetically(noteId, dataKey);
await tree.sortNotesAlphabetically(noteId);
}
async function protectBranch(req) {
const noteId = req.params.noteId;
const isProtected = !!parseInt(req.params.isProtected);
const dataKey = protected_session.getDataKey(req);
await notes.protectNoteRecursively(noteId, dataKey, isProtected);
await notes.protectNoteRecursively(noteId, isProtected);
}
async function setNoteTypeMime(req) {

View File

@@ -45,7 +45,7 @@ async function getTree(req) {
WHERE
notes.isDeleted = 0`));
protected_session.decryptNotes(req, notes);
protected_session.decryptNotes(notes);
notes.forEach(note => {
note.hideInAutocomplete = !!note.hideInAutocomplete;