mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
* feat: note version history * fix bugs * add tests for session history * update tests * add tests for restoring content * add more tests * update jsdoc * return empty array if no session history present for a note * init note history with await * add note history versions limit * cleanup note history after adding a new session * fix tests * add test for session cleanup * test: add collector tests * feat: dateEdited -> dateModified * feat: migrate to liqe for searching * chore: forceExit jest after test run * feat: note version history * fix bugs * add tests for session history * update tests * add tests for restoring content * add more tests * update jsdoc * return empty array if no session history present for a note * init note history with await * add note history versions limit * cleanup note history after adding a new session * fix tests * add test for session cleanup * init ContentHistory with await * fix reference to db in init * make sessionId in db * check if note is locked through note metadata * make cleanup method private * use remove methods in notehistory and contenthistory * restore note content via notes.add method if note is not locked * move getting all items to seperate functions * check if parsed json is valid * deserialize a session only if it's sessionContent exists * add locked property to sessionContent * remove makeSessionId function * update tests * remove yarn.lock file * update tests Co-authored-by: ammarahm-ed <ammarahmed6506@gmail.com>
26 lines
660 B
JavaScript
26 lines
660 B
JavaScript
import { hash, SALT_LENGTH } from "@stablelib/blake2s";
|
|
import SparkMD5 from "spark-md5";
|
|
import { USER_PERSONALIZATION_HASH } from "../common";
|
|
import { randomBytes } from "./random";
|
|
|
|
export default function () {
|
|
const bytes = randomBytes(64);
|
|
const salt = randomBytes(SALT_LENGTH);
|
|
return Buffer.from(
|
|
hash(bytes, 12, { salt, personalization: USER_PERSONALIZATION_HASH })
|
|
).toString("hex");
|
|
}
|
|
|
|
export function makeId(text) {
|
|
return SparkMD5.hash(text);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {string} noteId id of a note
|
|
* @returns {string} An id with postfix of "_index"
|
|
*/
|
|
export function makeSessionContentId(sessionId) {
|
|
return sessionId + "_content";
|
|
}
|