mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
exceptions on decryption
This commit is contained in:
parent
c79fb2cc12
commit
4721ddc6b3
@ -37,9 +37,15 @@ function isProtectedSessionAvailable() {
|
|||||||
function decryptNoteTitle(noteId, encryptedTitle) {
|
function decryptNoteTitle(noteId, encryptedTitle) {
|
||||||
const dataKey = getDataKey();
|
const dataKey = getDataKey();
|
||||||
|
|
||||||
const iv = dataEncryptionService.noteTitleIv(noteId);
|
try {
|
||||||
|
const iv = dataEncryptionService.noteTitleIv(noteId);
|
||||||
|
|
||||||
return dataEncryptionService.decryptString(dataKey, iv, encryptedTitle);
|
return dataEncryptionService.decryptString(dataKey, iv, encryptedTitle);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
e.message = `Cannot decrypt note title for noteId=${noteId}: ` + e.message;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function decryptNote(note) {
|
function decryptNote(note) {
|
||||||
@ -49,25 +55,29 @@ function decryptNote(note) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.title) {
|
try {
|
||||||
note.title = dataEncryptionService.decryptString(dataKey, dataEncryptionService.noteTitleIv(note.noteId), note.title);
|
if (note.title) {
|
||||||
|
note.title = dataEncryptionService.decryptString(dataKey, dataEncryptionService.noteTitleIv(note.noteId), note.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (note.content) {
|
||||||
|
const contentIv = dataEncryptionService.noteContentIv(note.noteId);
|
||||||
|
|
||||||
|
if (note.type === 'file') {
|
||||||
|
note.content = dataEncryptionService.decrypt(dataKey, contentIv, note.content);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
note.content = dataEncryptionService.decryptString(dataKey, contentIv, note.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
if (note.content) {
|
e.message = `Cannot decrypt note for noteId=${note.noteId}: ` + e.message;
|
||||||
const contentIv = dataEncryptionService.noteContentIv(note.noteId);
|
throw e;
|
||||||
|
|
||||||
if (note.type === 'file') {
|
|
||||||
note.content = dataEncryptionService.decrypt(dataKey, contentIv, note.content);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
note.content = dataEncryptionService.decryptString(dataKey, contentIv, note.content);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function decryptNotes(notes) {
|
function decryptNotes(notes) {
|
||||||
const dataKey = getDataKey();
|
|
||||||
|
|
||||||
for (const note of notes) {
|
for (const note of notes) {
|
||||||
decryptNote(note);
|
decryptNote(note);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user