From 61d99628f9c9874dd29658b3cdccf03e8b1ba2dc Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Sat, 28 Mar 2026 17:34:01 -0400 Subject: [PATCH] Matrix: cover crypto runtime require boundary --- CHANGELOG.md | 1 + .../matrix/sdk/crypto-node.runtime.test.ts | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 extensions/matrix/src/matrix/sdk/crypto-node.runtime.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index aa437f102b4..d391876bceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ Docs: https://docs.openclaw.ai - Daemon/status: surface immediate gateway close reasons from lightweight probes and prefer those concrete auth or pairing failures over generic timeouts in `openclaw daemon status`. (#56282) Thanks @mbelinky. - Agents/failover: classify HTTP 410 errors as retryable timeouts by default while still preserving explicit session-expired, billing, and auth signals from the payload. (#55201) thanks @nikus-pan. - Agents/subagents: restore completion announce delivery for extension channels like BlueBubbles. (#56348) +- Plugins/Matrix: load bundled `@matrix-org/matrix-sdk-crypto-nodejs` through `createRequire(...)` so E2EE media send and receive keep the package-local native binding lookup working in packaged ESM builds. (#54566) thanks @joelnishanth. ## 2026.3.24 diff --git a/extensions/matrix/src/matrix/sdk/crypto-node.runtime.test.ts b/extensions/matrix/src/matrix/sdk/crypto-node.runtime.test.ts new file mode 100644 index 00000000000..92d175467c8 --- /dev/null +++ b/extensions/matrix/src/matrix/sdk/crypto-node.runtime.test.ts @@ -0,0 +1,27 @@ +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { build } from "esbuild"; +import { describe, expect, it } from "vitest"; + +const sdkDir = path.dirname(fileURLToPath(import.meta.url)); +const cryptoNodeRuntimePath = path.join(sdkDir, "crypto-node.runtime.ts"); + +describe("crypto-node runtime bundling", () => { + it("keeps the native Matrix crypto package behind a runtime require boundary", async () => { + const result = await build({ + entryPoints: [cryptoNodeRuntimePath], + bundle: true, + external: ["@matrix-org/matrix-sdk-crypto-nodejs"], + format: "esm", + platform: "node", + write: false, + }); + + const bundled = result.outputFiles.at(0)?.text ?? ""; + + expect(bundled).toContain('from "node:module"'); + expect(bundled).toContain("createRequire(import.meta.url)"); + expect(bundled).toMatch(/require\d*\("@matrix-org\/matrix-sdk-crypto-nodejs"\)/); + expect(bundled).not.toContain('from "@matrix-org/matrix-sdk-crypto-nodejs"'); + }); +});