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
chore(core): address some missing methods in utils
Elian Doran8399600e79ba
diff --git a/apps/server/src/services/utils.ts b/apps/server/src/services/utils.tsindex 861a8396fc..5ad481211d 100644--- a/apps/server/src/services/utils.ts+++ b/apps/server/src/services/utils.ts@@ -33,10 +33,6 @@ export function randomString(length: number): string {return coreUtils.randomString(length);}-export function randomSecureToken(bytes = 32) {- return crypto.randomBytes(bytes).toString("base64");-}-export function md5(content: crypto.BinaryLike) {return crypto.createHash("md5").update(content).digest("hex");}@@ -459,6 +455,7 @@ function slugify(text: string) {export const escapeHtml = coreUtils.escapeHtml;export const unescapeHtml = coreUtils.unescapeHtml;+export const randomSecureToken = coreUtils.randomSecureToken;export default {compareVersions,diff --git a/packages/trilium-core/src/services/keyboard_actions.ts b/packages/trilium-core/src/services/keyboard_actions.tsindex 0d20a886c8..704a639adb 100644--- a/packages/trilium-core/src/services/keyboard_actions.ts+++ b/packages/trilium-core/src/services/keyboard_actions.ts@@ -2,7 +2,7 @@import optionService from "./options.js";import { getLog } from "./log.js";-import { isElectron, isMac } from "./utils.js";+import { isElectron, isMac } from "./utils/index.js";import type { ActionKeyboardShortcut, KeyboardShortcut } from "@triliumnext/commons";import { t } from "i18next";diff --git a/packages/trilium-core/src/services/options_init.ts b/packages/trilium-core/src/services/options_init.tsindex a77727ec33..9b9ed9099c 100644--- a/packages/trilium-core/src/services/options_init.ts+++ b/packages/trilium-core/src/services/options_init.ts@@ -5,7 +5,7 @@ import dateUtils from "./utils/date.js";import keyboardActions from "./keyboard_actions.js";import { getLog } from "./log.js";import optionService from "./options.js";-import { isWindows, randomSecureToken } from "./utils.js";+import { isWindows, randomSecureToken } from "./utils/index.js";function initDocumentOptions() {optionService.createOption("documentId", randomSecureToken(16), false);diff --git a/packages/trilium-core/src/services/utils/index.ts b/packages/trilium-core/src/services/utils/index.tsindex f33ccb0391..e966f72374 100644--- a/packages/trilium-core/src/services/utils/index.ts+++ b/packages/trilium-core/src/services/utils/index.ts@@ -5,6 +5,11 @@ import mimeTypes from "mime-types";import escape from "escape-html";import unescape from "unescape";+// TODO: Implement platform detection.+export const isElectron = false;+export const isMac = false;+export const isWindows = false;+// render and book are string note in the sense that they are expected to contain empty stringconst STRING_NOTE_TYPES = new Set(["text", "code", "relationMap", "search", "render", "book", "mermaid", "canvas", "webView"]);const STRING_MIME_TYPES = new Set(["application/javascript", "application/x-javascript", "application/json", "application/x-sql", "image/svg+xml"]);@@ -117,3 +122,7 @@ export function toMap<T extends Record<string, any>>(list: T[], key: keyof T) {export const escapeHtml = escape;export const unescapeHtml = unescape;++export function randomSecureToken(bytes = 32) {+ return encodeBase64(getCrypto().randomBytes(32));+}