Skip to content

Build your personal knowledge base with Trilium Notes

chore(standalone): move the crypto provider to noble

Elian Doran15f4d923d37a
diff --git a/.claude/skills/developing-standalone/SKILL.md b/.claude/skills/developing-standalone/SKILL.md
index 6d30745262..cdfe847d6c 100644
--- a/.claude/skills/developing-standalone/SKILL.md
+++ b/.claude/skills/developing-standalone/SKILL.md
@@ -46,7 +46,7 @@ apps/standalone/
|---|---|---|
| SQL | `sql_provider.ts` | wraps sqlite-wasm statements to core's `Statement` interface; SAHPool VFS install; nested transactions become SAVEPOINTs |
| Execution context (CLS) | `cls_provider.ts` | per-request context stack with a grace period for unawaited promises |
-| Crypto | `crypto_provider.ts` | WebCrypto + `scrypt-js` (pure JS, slow under coverage) |
+| Crypto | `crypto_provider.ts` | `@noble/hashes` + `@noble/ciphers` (pure JS and synchronous; scrypt is slow under coverage) |
| Zip / export | `zip_provider.ts`, `zip_export_provider_factory.ts` | bytes only — no filesystem `path` source |
| Request (outbound HTTP, sync) | `request_provider.ts` (`fetch`), `bridged_request_provider.ts` (Capacitor native, via `HTTP_REQUEST` to the page) | |
| Messaging | `messaging_provider.ts` | `postMessage` in place of WS |
diff --git a/.claude/skills/writing-unit-tests/SKILL.md b/.claude/skills/writing-unit-tests/SKILL.md
index 67191653c5..1377821784 100644
--- a/.claude/skills/writing-unit-tests/SKILL.md
+++ b/.claude/skills/writing-unit-tests/SKILL.md
@@ -83,7 +83,7 @@ coverage: {
- **Don't assert on translated (i18n) strings** — assert structure/keys/behavior (classes, counts, ids), not human-readable English.
- **happy-dom is not a browser:** `getBoundingClientRect()` returns zeros, `ResizeObserver`/layout/visibility are stubs. Anything pixel/size/scroll-based needs `@vitest/browser`, not happy-dom.
- **`@vitest/browser` real-browser mode IS configured** — the `packages/ckeditor5`, `-mermaid` and `-math` bundles run their co-located `src/**/*.spec.ts` in headless Chromium (`@vitest/browser-playwright`; see `packages/ckeditor5/vitest.config.ts`). These are the browser-mode `test:sequential` suites. Reserve real-browser mode for genuine layout/integration needs (CKEditor, Excalidraw, Modal transitions, size measurement); normal unit tests stay on happy-dom.
-- **WASM scrypt is ~10× slower** under the standalone suite (pure-JS `scrypt-js` under V8 coverage instrumentation, vs Node's native `scryptSync`) — enough to blow the 5s default. A core spec that hashes a password bumps the timeout for the standalone runtime only; copy the guard from `packages/trilium-core/src/routes/api/login.spec.ts:13`:
+- **WASM scrypt is ~10× slower** under the standalone suite (pure-JS `@noble/hashes` scrypt under V8 coverage instrumentation, vs Node's native `scryptSync`) — enough to blow the 5s default. A core spec that hashes a password bumps the timeout for the standalone runtime only; copy the guard from `packages/trilium-core/src/routes/api/login.spec.ts:13`:
```ts
const isBrowserRuntime = typeof window !== "undefined";
if (isBrowserRuntime) {
diff --git a/apps/standalone/package.json b/apps/standalone/package.json
index 2a1282e1e4..9350331073 100644
--- a/apps/standalone/package.json
+++ b/apps/standalone/package.json
@@ -16,6 +16,8 @@
"dependencies": {
"@excalidraw/excalidraw": "0.18.1",
"@floating-ui/dom": "1.8.0",
+ "@noble/ciphers": "2.4.0",
+ "@noble/hashes": "2.4.0",
"@popperjs/core": "2.11.8",
"@preact/signals": "2.11.3",
"@sqlite.org/sqlite-wasm": "3.51.1-build2",
@@ -38,14 +40,8 @@
"fullcalendar": "7.1.3",
"i18next": "26.5.11",
"i18next-http-backend": "4.0.6",
- "aes-js": "3.1.2",
"jquery": "4.0.0",
"jquery.fancytree": "2.38.5",
- "js-md5": "0.9.2",
- "js-sha1": "0.7.0",
- "js-sha256": "1.0.0",
- "js-sha512": "0.9.0",
- "scrypt-js": "3.0.1",
"katex": "0.19.1",
"maplibre-gl": "6.16.0",
"marked": "18.1.1",
@@ -60,7 +56,6 @@
"temporal-polyfill": "1.0.6"
},
"devDependencies": {
- "@types/aes-js": "3.1.4",
"@ckeditor/ckeditor5-inspector": "5.0.4",
"@codecov/vite-plugin": "2.0.1",
"@prefresh/vite": "4.0.1",
diff --git a/apps/standalone/src/lightweight/crypto_provider.spec.ts b/apps/standalone/src/lightweight/crypto_provider.spec.ts
index c35b1cfa29..9e24c9e739 100644
--- a/apps/standalone/src/lightweight/crypto_provider.spec.ts
+++ b/apps/standalone/src/lightweight/crypto_provider.spec.ts
@@ -1,6 +1,10 @@
-import { createHash as nodeCreateHash, createHmac as nodeCreateHmac } from "node:crypto";
+import {
+ createCipheriv as nodeCreateCipheriv,
+ createHash as nodeCreateHash,
+ createHmac as nodeCreateHmac,
+ scryptSync as nodeScrypt
+} from "node:crypto";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
-import aesjs from "aes-js";
import BrowserCryptoProvider from "./crypto_provider.js";
@@ -39,7 +43,7 @@ describe("BrowserCryptoProvider parity with the Node.js provider", () => {
it("createHash matches node:crypto for strings and for (invalid-UTF-8) binary content", () => {
for (const algorithm of ["md5", "sha1", "sha512"] as const) {
- for (const content of [utf8String, allBytes, largeBinary]) {
+ for (const content of ["", new Uint8Array(0), utf8String, allBytes, largeBinary]) {
const expected = new Uint8Array(nodeCreateHash(algorithm).update(content).digest());
expect(provider.createHash(algorithm, content), `${algorithm} of ${typeof content === "string" ? "string" : `${content.length} bytes`}`).toEqual(expected);
}
@@ -49,6 +53,8 @@ describe("BrowserCryptoProvider parity with the Node.js provider", () => {
it("hmac matches node:crypto for string and binary secrets/values", () => {
const cases: [string | Uint8Array, string | Uint8Array][] = [
["secret", "value"],
+ ["", ""],
+ [new Uint8Array(100).fill(1), "a secret longer than the block size is hashed first"],
[allBytes, largeBinary],
["secret", allBytes]
];
@@ -57,6 +63,87 @@ describe("BrowserCryptoProvider parity with the Node.js provider", () => {
expect(provider.hmac(secret, value)).toBe(expected);
}
});
+
+ it("scrypt matches node:crypto with the production parameters and with custom ones", async () => {
+ // N=16384, r=8, p=1 and a 32-byte key are what `scrypt.ts` in core passes.
+ expect(await provider.scrypt("pässword", "salt-string", 32, { N: 16384, r: 8, p: 1 }))
+ .toEqual(new Uint8Array(nodeScrypt("pässword", "salt-string", 32, { N: 16384, r: 8, p: 1 })));
+
+ const salt = largeBinary.subarray(0, 64);
+ expect(await provider.scrypt(allBytes, salt, 64, { N: 1024, r: 4, p: 2 }))
+ .toEqual(new Uint8Array(nodeScrypt(allBytes, salt, 64, { N: 1024, r: 4, p: 2 })));
+ });
+
+ it("scrypt defaults to N=16384, r=8, p=1", async () => {
+ const expected = new Uint8Array(nodeScrypt("password", "salt", 32, { N: 16384, r: 8, p: 1 }));
+ expect(await provider.scrypt("password", "salt", 32)).toEqual(expected);
+ expect(await provider.scrypt("password", "salt", 32, { N: 16384 })).toEqual(expected);
+ });
+
+ describe("aes-128-cbc", () => {
+ const key = Uint8Array.from({ length: 16 }, (_, i) => i * 13);
+ const iv = Uint8Array.from({ length: 16 }, (_, i) => 255 - i);
+ const lengths = [ 0, 1, 15, 16, 17, 31, 32, 33, 1000 ];
+
+ it("encrypts byte for byte like node:crypto, for every length around the block size", () => {
+ for (const length of lengths) {
+ const plain = largeBinary.subarray(0, length);
+
+ const cipher = provider.createCipheriv("aes-128-cbc", key, iv);
+ const encrypted = concat(cipher.update(plain), cipher.final());
+
+ expect(encrypted, `${length} bytes`).toEqual(nodeEncrypt(key, iv, plain));
+ }
+ });
+
+ it("decrypts what node:crypto encrypted, for every length around the block size", () => {
+ for (const length of lengths) {
+ const plain = largeBinary.subarray(0, length);
+
+ const decipher = provider.createDecipheriv("aes-128-cbc", key, iv);
+ const decrypted = concat(decipher.update(nodeEncrypt(key, iv, plain)), decipher.final());
+
+ expect(decrypted, `${length} bytes`).toEqual(new Uint8Array(plain));
+ }
+ });
+
+ it("joins the chunks passed to update() in order", () => {
+ const plain = largeBinary.subarray(0, 100);
+ const encrypted = nodeEncrypt(key, iv, plain);
+
+ const cipher = provider.createCipheriv("aes-128-cbc", key, iv);
+ expect(concat(
+ cipher.update(plain.subarray(0, 7)),
+ cipher.update(plain.subarray(7, 40)),
+ cipher.update(plain.subarray(40)),
+ cipher.final()
+ )).toEqual(encrypted);
+
+ const decipher = provider.createDecipheriv("aes-128-cbc", key, iv);
+ expect(concat(
+ decipher.update(encrypted.subarray(0, 5)),
+ decipher.update(encrypted.subarray(5)),
+ decipher.final()
+ )).toEqual(new Uint8Array(plain));
+ });
+
+ it("returns bytes rather than throwing when decrypting with a wrong key", () => {
+ // `data_encryption.decrypt()` detects a wrong key through its digest and returns false.
+ // Most wrong keys leave invalid padding, which must not throw before that check.
+ const encrypted = nodeEncrypt(key, iv, largeBinary.subarray(0, 50));
+ for (let i = 1; i <= 64; i++) {
+ const decipher = provider.createDecipheriv("aes-128-cbc", key.map((byte) => byte ^ i), iv);
+ decipher.update(encrypted);
+ expect(() => decipher.final(), `key xor ${i}`).not.toThrow();
+ }
+ });
+
+ it("throws for ciphertext that is not a whole number of blocks", () => {
+ const decipher = provider.createDecipheriv("aes-128-cbc", key, iv);
+ decipher.update(new Uint8Array(20));
+ expect(() => decipher.final()).toThrow();
+ });
+ });
});
describe("BrowserCryptoProvider random helpers", () => {
@@ -128,21 +215,26 @@ describe("AesJsCipher (via createCipheriv/createDecipheriv)", () => {
expect(() => cipher.final()).toThrow("Cipher has already been finalized");
});
- it("returns decrypted bytes unchanged when the trailing padding byte is invalid", () => {
- // Craft a single raw block whose decrypted last byte is 0 (an invalid
- // PKCS7 padding length), exercising the non-stripping branch in final().
- const plain = new Uint8Array(16).fill(65);
- plain[15] = 0;
- const rawCipher = new Uint8Array(
- new aesjs.ModeOfOperation.cbc(Array.from(key), Array.from(iv)).encrypt(plain)
- );
+ it("returns decrypted bytes unchanged when the trailing padding byte is out of range", () => {
+ for (const last of [ 0, 17, 255 ]) {
+ const plain = new Uint8Array(32).fill(65);
+ plain[31] = last;
+
+ const decipher = provider.createDecipheriv("aes-128-cbc", key, iv);
+ decipher.update(nodeEncrypt(key, iv, plain, false));
+
+ expect(decipher.final(), `last byte ${last}`).toEqual(plain);
+ }
+ });
+
+ it("strips as many bytes as the trailing padding byte says, without checking the others", () => {
+ const plain = new Uint8Array(32).fill(65);
+ plain[31] = 3;
const decipher = provider.createDecipheriv("aes-128-cbc", key, iv);
- decipher.update(rawCipher);
- const out = decipher.final();
+ decipher.update(nodeEncrypt(key, iv, plain, false));
- expect(out).toHaveLength(16);
- expect(out[15]).toBe(0);
+ expect(decipher.final()).toEqual(plain.subarray(0, 29));
});
});
@@ -341,3 +433,19 @@ describe("BrowserCryptoProvider base64", () => {
});
});
});
+
+/** Encrypts `plain` with node:crypto, with PKCS#7 padding unless `autoPadding` is false. */
+function nodeEncrypt(key: Uint8Array, iv: Uint8Array, plain: Uint8Array, autoPadding = true) {
+ const cipher = nodeCreateCipheriv("aes-128-cbc", key, iv).setAutoPadding(autoPadding);
+ return concat(cipher.update(plain), cipher.final());
+}
+
+function concat(...parts: Uint8Array[]) {
+ const result = new Uint8Array(parts.reduce((sum, part) => sum + part.length, 0));
+ let offset = 0;
+ for (const part of parts) {
+ result.set(part, offset);
+ offset += part.length;
+ }
+ return result;
+}
diff --git a/apps/standalone/src/lightweight/crypto_provider.ts b/apps/standalone/src/lightweight/crypto_provider.ts
index 96270e9bca..f6eb81b9d9 100644
--- a/apps/standalone/src/lightweight/crypto_provider.ts
+++ b/apps/standalone/src/lightweight/crypto_provider.ts
@@ -1,11 +1,10 @@
+import { cbc } from "@noble/ciphers/aes.js";
+import { hmac } from "@noble/hashes/hmac.js";
+import { md5, sha1 } from "@noble/hashes/legacy.js";
+import { scryptAsync } from "@noble/hashes/scrypt.js";
+import { sha256, sha512 } from "@noble/hashes/sha2.js";
import type { Cipher, CryptoProvider, ScryptOptions } from "@triliumnext/core";
import { binary_utils } from "@triliumnext/core";
-import { sha1 } from "js-sha1";
-import { sha256 } from "js-sha256";
-import { sha512 } from "js-sha512";
-import { md5 } from "js-md5";
-import { scrypt } from "scrypt-js";
-import aesjs from "aes-js";
const CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -15,44 +14,28 @@ const CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
declare const __TRILIUM_FORCE_B64_FALLBACK__: boolean;
const FORCE_B64_FALLBACK = typeof __TRILIUM_FORCE_B64_FALLBACK__ !== "undefined" && __TRILIUM_FORCE_B64_FALLBACK__;
+const HASHES = { md5, sha1, sha512 };
+
/**
- * Crypto provider for browser environments using pure JavaScript crypto libraries.
- * Uses aes-js for synchronous AES encryption (matching Node.js behavior).
+ * Crypto provider for browser environments, on the synchronous pure-JS hashes and ciphers of
+ * `@noble/hashes` and `@noble/ciphers`. WebCrypto cannot back it: core calls `createHash()` and
+ * `Cipher` synchronously.
*/
export default class BrowserCryptoProvider implements CryptoProvider {
createHash(algorithm: "md5" | "sha1" | "sha512", content: string | Uint8Array): Uint8Array {
- // Hash the raw bytes. Binary content must NOT be routed through unwrapStringOrBuffer
- // (UTF-8 decoding): it is lossy for non-UTF-8 bytes (invalid sequences become U+FFFD),
- // which produced digests diverging from the Node.js provider — e.g. protected binary
- // notes encrypted on server/desktop failed their integrity digest here and decrypted
- // to empty. For strings this is equivalent to before (the js-* libs UTF-8 encode
- // string inputs internally).
- const data = binary_utils.wrapStringOrBuffer(content);
-
- let hexHash: string;
- if (algorithm === "md5") {
- hexHash = md5(data);
- } else if (algorithm === "sha1") {
- hexHash = sha1(data);
- } else {
- hexHash = sha512(data);
- }
-
- // Convert hex string to Uint8Array
- const bytes = new Uint8Array(hexHash.length / 2);
- for (let i = 0; i < hexHash.length; i += 2) {
- bytes[i / 2] = parseInt(hexHash.substr(i, 2), 16);
- }
- return bytes;
+ // Binary content is hashed as is: a UTF-8 decode (`unwrapStringOrBuffer`) replaces invalid
+ // sequences with U+FFFD, and the digests of protected binary notes then differ from the
+ // Node.js provider's.
+ return HASHES[algorithm](binary_utils.wrapStringOrBuffer(content));
}
- createCipheriv(algorithm: "aes-128-cbc", key: Uint8Array, iv: Uint8Array): Cipher {
- return new AesJsCipher(algorithm, key, iv, "encrypt");
+ createCipheriv(_algorithm: "aes-128-cbc", key: Uint8Array, iv: Uint8Array): Cipher {
+ return new AesCbcCipher(key, iv, "encrypt");
}
- createDecipheriv(algorithm: "aes-128-cbc", key: Uint8Array, iv: Uint8Array): Cipher {
- return new AesJsCipher(algorithm, key, iv, "decrypt");
+ createDecipheriv(_algorithm: "aes-128-cbc", key: Uint8Array, iv: Uint8Array): Cipher {
+ return new AesCbcCipher(key, iv, "decrypt");
}
randomBytes(size: number): Uint8Array {
@@ -74,13 +57,7 @@ export default class BrowserCryptoProvider implements CryptoProvider {
// Same byte-vs-string rationale as createHash above: never UTF-8-decode binary inputs.
const secretBytes = binary_utils.wrapStringOrBuffer(secret);
const valueBytes = binary_utils.wrapStringOrBuffer(value);
- // sha256.hmac returns hex, convert to base64 to match Node's behavior
- const hexHash = sha256.hmac(secretBytes, valueBytes);
- const bytes = new Uint8Array(hexHash.length / 2);
- for (let i = 0; i < hexHash.length; i += 2) {
- bytes[i / 2] = parseInt(hexHash.substr(i, 2), 16);
- }
- return btoa(String.fromCharCode(...bytes));
+ return this.base64Encode(hmac(sha256, secretBytes, valueBytes));
}
async scrypt(
@@ -93,7 +70,7 @@ export default class BrowserCryptoProvider implements CryptoProvider {
const passwordBytes = binary_utils.wrapStringOrBuffer(password);
const saltBytes = binary_utils.wrapStringOrBuffer(salt);
- return scrypt(passwordBytes, saltBytes, N, r, p, keyLength);
+ return scryptAsync(passwordBytes, saltBytes, { N, r, p, dkLen: keyLength });
}
constantTimeCompare(a: Uint8Array, b: Uint8Array): boolean {
@@ -219,34 +196,24 @@ interface NativeBase64Constructor {
}
/**
- * A synchronous cipher implementation using aes-js.
- * Matches Node.js crypto behavior with update() and final() methods.
+ * AES-128-CBC with PKCS#7 padding behind Node's `update()`/`final()` interface. It buffers what
+ * `update()` receives and does the whole operation in `final()`.
*/
-class AesJsCipher implements Cipher {
+class AesCbcCipher implements Cipher {
private chunks: Uint8Array[] = [];
- private key: Uint8Array;
- private iv: Uint8Array;
- private mode: "encrypt" | "decrypt";
private finalized = false;
constructor(
- _algorithm: "aes-128-cbc",
- key: Uint8Array,
- iv: Uint8Array,
- mode: "encrypt" | "decrypt"
- ) {
- this.key = key;
- this.iv = iv;
- this.mode = mode;
- }
+ private readonly key: Uint8Array,
+ private readonly iv: Uint8Array,
+ private readonly mode: "encrypt" | "decrypt"
+ ) {}
update(data: Uint8Array): Uint8Array {
if (this.finalized) {
throw new Error("Cipher has already been finalized");
}
- // Buffer the data - we process everything in final() to match streaming behavior
this.chunks.push(data);
- // Return empty array since aes-js CBC doesn't support true streaming
return new Uint8Array(0);
}
@@ -266,32 +233,16 @@ class AesJsCipher implements Cipher {
}
if (this.mode === "encrypt") {
- // PKCS7 padding for encryption
- const blockSize = 16;
- const paddingLength = blockSize - (data.length % blockSize);
- const paddedData = new Uint8Array(data.length + paddingLength);
- paddedData.set(data);
- paddedData.fill(paddingLength, data.length);
-
- const aesCbc = new aesjs.ModeOfOperation.cbc(
- Array.from(this.key),
- Array.from(this.iv)
- );
- return new Uint8Array(aesCbc.encrypt(paddedData));
- } else {
- // Decryption
- const aesCbc = new aesjs.ModeOfOperation.cbc(
- Array.from(this.key),
- Array.from(this.iv)
- );
- const decrypted = new Uint8Array(aesCbc.decrypt(data));
-
- // Remove PKCS7 padding
- const paddingLength = decrypted[decrypted.length - 1];
- if (paddingLength > 0 && paddingLength <= 16) {
- return decrypted.slice(0, decrypted.length - paddingLength);
- }
- return decrypted;
+ return cbc(this.key, this.iv).encrypt(data);
+ }
+
+ // The padding is stripped by hand because `cbc()` throws on invalid padding, which most
+ // wrong keys leave. `data_encryption.decrypt()` detects those through its digest instead.
+ const decrypted = cbc(this.key, this.iv, { disablePadding: true }).decrypt(data);
+ const paddingLength = decrypted[decrypted.length - 1];
+ if (paddingLength > 0 && paddingLength <= 16) {
+ return decrypted.slice(0, decrypted.length - paddingLength);
}
+ return decrypted;
}
}
diff --git a/packages/trilium-core/src/routes/api/login.spec.ts b/packages/trilium-core/src/routes/api/login.spec.ts
index 76c6b7ed23..e14a66161d 100644
--- a/packages/trilium-core/src/routes/api/login.spec.ts
+++ b/packages/trilium-core/src/routes/api/login.spec.ts
@@ -7,7 +7,7 @@ import { CoreApiTester } from "../../test/api_tester";
// The protected-session login does real scrypt (N=16384) password verification
// and data-key derivation. Under the browser provider that runs in pure JS
-// (scrypt-js), ~10x slower with V8 coverage instrumentation than Node's native
+// (@noble/hashes), ~10x slower with V8 coverage instrumentation than Node's native
// scryptSync — enough to blow the 5s default. Give the standalone
// suite a larger timeout; the server suite keeps the strict default.
const isBrowserRuntime = typeof self !== "undefined";
diff --git a/packages/trilium-core/src/routes/api/password.spec.ts b/packages/trilium-core/src/routes/api/password.spec.ts
index cd66d8e4f4..e628ad1411 100644
--- a/packages/trilium-core/src/routes/api/password.spec.ts
+++ b/packages/trilium-core/src/routes/api/password.spec.ts
@@ -5,7 +5,7 @@ import { getSql } from "../../services/sql/index";
import { CoreApiTester } from "../../test/api_tester";
// Changing/setting a password does real scrypt (N=16384) hashing + data-key
-// re-derivation. Under the browser provider that runs in pure JS (scrypt-js),
+// re-derivation. Under the browser provider that runs in pure JS (@noble/hashes),
// ~10x slower with V8 coverage instrumentation than Node's native scryptSync —
// enough to blow the 5s default. Give the standalone suite a larger
// timeout; the server suite keeps the strict default.
diff --git a/packages/trilium-core/src/services/encryption/crypto.spec.ts b/packages/trilium-core/src/services/encryption/crypto.spec.ts
index 05dfddb010..542f93c638 100644
--- a/packages/trilium-core/src/services/encryption/crypto.spec.ts
+++ b/packages/trilium-core/src/services/encryption/crypto.spec.ts
@@ -13,7 +13,7 @@ import { type CryptoProvider, getCrypto, initCrypto } from "./crypto.js";
// initCrypto() restore the original in afterEach so the rest of the file keeps
// seeing the real provider.
-// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is
+// scrypt (N=16384) runs in pure JS (@noble/hashes) under the browser provider, which is
// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the
// standalone suite a larger timeout; the server suite keeps the strict
// default. The derived bytes are identical across runtimes — only the speed differs.
diff --git a/packages/trilium-core/src/services/encryption/password.spec.ts b/packages/trilium-core/src/services/encryption/password.spec.ts
index 067cbb009b..e0bbc5586d 100644
--- a/packages/trilium-core/src/services/encryption/password.spec.ts
+++ b/packages/trilium-core/src/services/encryption/password.spec.ts
@@ -14,7 +14,7 @@ import passwordService from "./password.js";
// the destructive reset/re-set at the end.
const FIXTURE_PASSWORD = "demo1234";
-// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is
+// scrypt (N=16384) runs in pure JS (@noble/hashes) under the browser provider, which is
// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the
// standalone suite a larger timeout; the server suite keeps the strict
// default. The derived bytes are identical across runtimes — only the speed differs.
diff --git a/packages/trilium-core/src/services/encryption/password_encryption.spec.ts b/packages/trilium-core/src/services/encryption/password_encryption.spec.ts
index f349d33efc..287831da21 100644
--- a/packages/trilium-core/src/services/encryption/password_encryption.spec.ts
+++ b/packages/trilium-core/src/services/encryption/password_encryption.spec.ts
@@ -13,7 +13,7 @@ import passwordEncryption from "./password_encryption.js";
// so the destructive verification-hash test is kept last.
const FIXTURE_PASSWORD = "demo1234";
-// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is
+// scrypt (N=16384) runs in pure JS (@noble/hashes) under the browser provider, which is
// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the
// standalone suite a larger timeout; the server suite keeps the strict
// default. The derived bytes are identical across runtimes — only the speed differs.
diff --git a/packages/trilium-core/src/services/encryption/scrypt.spec.ts b/packages/trilium-core/src/services/encryption/scrypt.spec.ts
index 6c1177defd..4a800b9bf5 100644
--- a/packages/trilium-core/src/services/encryption/scrypt.spec.ts
+++ b/packages/trilium-core/src/services/encryption/scrypt.spec.ts
@@ -16,7 +16,7 @@ import scryptService, {
// is required. Each spec file runs in its own vitest fork (pool: "forks").
const FIXTURE_PASSWORD = "demo1234";
-// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is
+// scrypt (N=16384) runs in pure JS (@noble/hashes) under the browser provider, which is
// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the
// standalone suite a larger timeout; the server suite keeps the strict
// default. The derived bytes are identical across runtimes — only the speed differs.
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 896212f819..30d1646ba1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -845,6 +845,12 @@ importers:
'@floating-ui/dom':
specifier: 1.8.0
version: 1.8.0
+ '@noble/ciphers':
+ specifier: 2.4.0
+ version: 2.4.0
+ '@noble/hashes':
+ specifier: 2.4.0
+ version: 2.4.0
'@popperjs/core':
specifier: 2.11.8
version: 2.11.8
@@ -878,9 +884,6 @@ importers:
'@triliumnext/split.js':
specifier: workspace:*
version: link:../../packages/splitjs
- aes-js:
- specifier: 3.1.2
- version: 3.1.2
bootstrap:
specifier: 5.3.8
version: 5.3.8(@popperjs/[email protected])
@@ -920,18 +923,6 @@ importers:
jquery.fancytree:
specifier: 2.38.5
version: 2.38.5([email protected])
- js-md5:
- specifier: 0.9.2
- version: 0.9.2
- js-sha1:
- specifier: 0.7.0
- version: 0.7.0
- js-sha256:
- specifier: 1.0.0
- version: 1.0.0
- js-sha512:
- specifier: 0.9.0
- version: 0.9.0
katex:
specifier: 0.19.1
version: 0.19.1
@@ -962,9 +953,6 @@ importers:
reveal.js:
specifier: 6.0.2
version: 6.0.2
- scrypt-js:
- specifier: 3.0.1
- version: 3.0.1
tabulator-tables:
specifier: 6.7.1
version: 6.7.1
@@ -981,9 +969,6 @@ importers:
'@prefresh/vite':
specifier: 4.0.1
- '@types/aes-js':
- specifier: 3.1.4
- version: 3.1.4
'@types/bootstrap':
specifier: 5.2.11
version: 5.2.11
@@ -3561,6 +3546,10 @@ packages:
'@nicolo-ribaudo/[email protected]':
resolution: {integrity: sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==}
+ '@noble/[email protected]':
+ resolution: {integrity: sha512-AnjFn0Jv92laAkvMrghlFZq4qQCIN/4DxFV/eooqtC2YTjB7kBeLMS2T9KJX4Dn+ZVXLOwK0lSgqDtx9gvxtiw==}
+ engines: {node: '>= 20.19.0'}
+
resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==}
engines: {node: ^14.21.3 || >=16}
@@ -4678,9 +4667,6 @@ packages:
'@tweenjs/[email protected]':
resolution: {integrity: sha512-XKLA6syeBUaPzx4j3qwMqzzq+V4uo72BnlbOjmuljLrRqdsd3qnzvZZoxvMHZ23ndsRS4aufU6JOZYpCbU6T1A==}
- '@types/[email protected]':
- resolution: {integrity: sha512-v3D66IptpUqh+pHKVNRxY8yvp2ESSZXe0rTzsGdzUhEwag7ljVfgCllkWv2YgiYXDhWFBrEywll4A5JToyTNFA==}
-
resolution: {integrity: sha512-G+n6DgZTZFOteITE30LnWj+HRVIGr7wMlAiLWOO02uJFWVEitaPU9JVXm9wJokkgshBawb2O1OykdcsmkkZfgg==}
@@ -5655,9 +5641,6 @@ packages:
resolution: {integrity: sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==}
engines: {node: '>=14.0'}
- resolution: {integrity: sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==}
-
resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
engines: {node: '>= 14'}
@@ -8467,18 +8450,6 @@ packages:
resolution: {integrity: sha512-TXCHVR3Lb6TZdtw1l3RTLf8RBWVGexdxL6AC8/e0xZKEpBflBsjh9/8LXw+dkNFuOyW9B7iB3O1sP7hS0Kiacg==}
- resolution: {integrity: sha512-QK62elp/ozZj7kzyCG5yaeK+uWeqxPlg3w3znYDBvwyqzJs7nh5bgTAAH9KltLni2LT7qx/E1EgSVwfiOSRe0Q==}
-
- resolution: {integrity: sha512-oQZ1Mo7440BfLSv9TX87VNEyU52pXPVG19F9PL3gTgNt0tVxlZ8F4O6yze3CLuLx28TxotxvlyepCNaaV0ZjMw==}
-
- resolution: {integrity: sha512-Bqxf6ENUzYIMzuELCmRNrJOVbjKH1oMgbfYJBKVr/W1Xf9fazpahqCbb24v1pR7XV1isuqhM+w9KWpK7zCyUQw==}
-
- resolution: {integrity: sha512-mirki9WS/SUahm+1TbAPkqvbCiCfOAAsyXeHxK1UkullnJVVqoJG2pL9ObvT05CN+tM7fxhfYm0NbXn+1hWoZg==}
-
resolution: {integrity: sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==}
@@ -10427,9 +10398,6 @@ packages:
resolution: {integrity: sha512-ZzWFVzFgyRHi/T2Ecxm37lL6J9+hZO0P9L7LCuLxAbC6XWxkvxcaQBCXhQxMGn/Tdt9nD7zIBk0ELwhMQ3UEDg==}
engines: {node: '>= 10.13.0'}
- resolution: {integrity: sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==}
-
resolution: {integrity: sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==}
@@ -14746,6 +14714,8 @@ snapshots:
dependencies:
eslint-scope: 5.1.1
+ '@noble/[email protected]': {}
+
'@noble/[email protected]': {}
'@noble/[email protected]': {}
@@ -15647,8 +15617,6 @@ snapshots:
'@tweenjs/[email protected]': {}
- '@types/[email protected]': {}
-
dependencies:
'@types/node': 24.19.0
@@ -17080,8 +17048,6 @@ snapshots:
-
@@ -20472,14 +20438,6 @@ snapshots:
-
-
-
-
@@ -22710,8 +22668,6 @@ snapshots:
ajv-keywords: 5.1.0([email protected])
optional: true
-