delete notes & sync to firebase
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { doc, getDoc } from 'firebase/firestore'
|
||||
import { user, db } from '@/composables/useFirebase'
|
||||
import { decrypt, calculateClientKey } from '@/utils/crypto'
|
||||
import { decrypt, encrypt, calculateClientKey } from '@/utils/crypto'
|
||||
|
||||
function getClientKeysFromLocalStorage(): { [uid: string]: string } {
|
||||
try {
|
||||
@@ -76,3 +76,18 @@ export const decryptNotes = (notes: BaseNotes, encryptionKey: EncryptionKey) =>
|
||||
)
|
||||
return decryptedNotes
|
||||
}
|
||||
|
||||
const encryptNote = (note: BaseNote, key: EncryptionKey) => {
|
||||
return {
|
||||
...note,
|
||||
title: encrypt(note.title, key),
|
||||
content: encrypt(note.content, key)
|
||||
}
|
||||
}
|
||||
|
||||
export const encryptNotes = (notes: BaseNotes, encryptionKey: EncryptionKey) => {
|
||||
const encryptedNotes = Object.fromEntries(
|
||||
Object.entries(notes).map(([noteId, note]) => [noteId, { ...encryptNote(note, encryptionKey) }])
|
||||
)
|
||||
return encryptedNotes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user