mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 03:20:20 +00:00
fix(matrix): resolve crypto bootstrap failure and multi-extension idHint warning (#53298)
Merged via squash.
Prepared head SHA: 6f5813ffff
Co-authored-by: keithce <2086282+keithce@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
},
|
||||
"openclaw": {
|
||||
"extensions": [
|
||||
"./index.ts"
|
||||
"./index.ts",
|
||||
"./src/plugin-entry.runtime.ts"
|
||||
],
|
||||
"setupEntry": "./setup-entry.ts",
|
||||
"channel": {
|
||||
|
||||
@@ -55,6 +55,17 @@ beforeEach(async () => {
|
||||
sdkModule = await import("./sdk.js");
|
||||
});
|
||||
|
||||
vi.mock("matrix-js-sdk", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("matrix-js-sdk")>();
|
||||
return {
|
||||
...actual,
|
||||
createClient: vi.fn(() => ({
|
||||
// Minimal stub — auth tests spy on MatrixClient.prototype.doRequest
|
||||
// rather than exercising the underlying js-sdk client.
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
describe("resolveMatrixConfig", () => {
|
||||
it("prefers config over env", () => {
|
||||
const cfg = {
|
||||
|
||||
12
extensions/matrix/src/plugin-entry.runtime.js
Normal file
12
extensions/matrix/src/plugin-entry.runtime.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Thin ESM wrapper so native dynamic import() resolves in source-checkout mode
|
||||
// where jiti loads index.ts but import("./src/plugin-entry.runtime.js") uses
|
||||
// Node's native ESM loader which cannot resolve .ts files directly.
|
||||
import { createRequire } from "node:module";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { createJiti } = require("jiti");
|
||||
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
||||
const mod = jiti("./plugin-entry.runtime.ts");
|
||||
export const ensureMatrixCryptoRuntime = mod.ensureMatrixCryptoRuntime;
|
||||
export const handleVerifyRecoveryKey = mod.handleVerifyRecoveryKey;
|
||||
export const handleVerificationBootstrap = mod.handleVerificationBootstrap;
|
||||
export const handleVerificationStatus = mod.handleVerificationStatus;
|
||||
22
extensions/matrix/src/plugin-entry.runtime.test.ts
Normal file
22
extensions/matrix/src/plugin-entry.runtime.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
it("loads the plugin-entry runtime wrapper through native ESM import", async () => {
|
||||
const wrapperPath = path.join(
|
||||
process.cwd(),
|
||||
"extensions",
|
||||
"matrix",
|
||||
"src",
|
||||
"plugin-entry.runtime.js",
|
||||
);
|
||||
const wrapperUrl = pathToFileURL(wrapperPath);
|
||||
const mod = await import(wrapperUrl.href);
|
||||
|
||||
expect(mod).toMatchObject({
|
||||
ensureMatrixCryptoRuntime: expect.any(Function),
|
||||
handleVerifyRecoveryKey: expect.any(Function),
|
||||
handleVerificationBootstrap: expect.any(Function),
|
||||
handleVerificationStatus: expect.any(Function),
|
||||
});
|
||||
}, 240_000);
|
||||
Reference in New Issue
Block a user