Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
import type FNote from "../entities/fnote.js";
import server from "./server.js";
function enableProtectedSession() {
glob.isProtectedSessionAvailable = true;
touchProtectedSession();
}
async function resetProtectedSession() {
await server.post("logout/protected");
}
function isProtectedSessionAvailable() {
return glob.isProtectedSessionAvailable;
}
async function touchProtectedSession() {
if (isProtectedSessionAvailable()) {
await server.post("login/protected/touch");
}
}
function touchProtectedSessionIfNecessary(note: FNote | null) {
if (note && note.isProtected && isProtectedSessionAvailable()) {
touchProtectedSession();
}
}
export default {
enableProtectedSession,
resetProtectedSession,
isProtectedSessionAvailable,
touchProtectedSession,
touchProtectedSessionIfNecessary
};