mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 23:10:20 +00:00
Matrix: drop unused MatrixClient constructor params
This commit is contained in:
@@ -671,7 +671,7 @@ export async function resolveMatrixAuth(params?: {
|
||||
if (!userId || !knownDeviceId) {
|
||||
// Fetch whoami when we need to resolve userId and/or deviceId from token auth.
|
||||
ensureMatrixSdkLoggingConfigured();
|
||||
const tempClient = new MatrixClient(homeserver, accessToken, undefined, undefined, {
|
||||
const tempClient = new MatrixClient(homeserver, accessToken, {
|
||||
ssrfPolicy: resolved.ssrfPolicy,
|
||||
dispatcherPolicy: resolved.dispatcherPolicy,
|
||||
});
|
||||
@@ -768,7 +768,7 @@ export async function resolveMatrixAuth(params?: {
|
||||
|
||||
// Login with password using the same hardened request path as other Matrix HTTP calls.
|
||||
ensureMatrixSdkLoggingConfigured();
|
||||
const loginClient = new MatrixClient(homeserver, "", undefined, undefined, {
|
||||
const loginClient = new MatrixClient(homeserver, "", {
|
||||
ssrfPolicy: resolved.ssrfPolicy,
|
||||
dispatcherPolicy: resolved.dispatcherPolicy,
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ export async function createMatrixClient(params: {
|
||||
|
||||
const cryptoDatabasePrefix = `openclaw-matrix-${storagePaths.accountKey}-${storagePaths.tokenHash}`;
|
||||
|
||||
return new MatrixClient(homeserver, params.accessToken, undefined, undefined, {
|
||||
return new MatrixClient(homeserver, params.accessToken, {
|
||||
userId: matrixClientUserId,
|
||||
password: params.password,
|
||||
deviceId: params.deviceId,
|
||||
|
||||
@@ -223,7 +223,7 @@ describe("MatrixClient request hardening", () => {
|
||||
});
|
||||
|
||||
it("injects a guarded fetchFn into matrix-js-sdk", () => {
|
||||
new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
new MatrixClient("https://matrix.example.org", "token", {
|
||||
ssrfPolicy: { allowPrivateNetwork: true },
|
||||
});
|
||||
|
||||
@@ -241,7 +241,7 @@ describe("MatrixClient request hardening", () => {
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
||||
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", {
|
||||
ssrfPolicy: { allowPrivateNetwork: true },
|
||||
});
|
||||
await expect(client.downloadContent("mxc://example.org/media")).resolves.toEqual(payload);
|
||||
@@ -271,7 +271,7 @@ describe("MatrixClient request hardening", () => {
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
||||
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", {
|
||||
ssrfPolicy: { allowPrivateNetwork: true },
|
||||
});
|
||||
await expect(client.downloadContent("mxc://example.org/media")).resolves.toEqual(payload);
|
||||
@@ -447,7 +447,7 @@ describe("MatrixClient request hardening", () => {
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
||||
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", {
|
||||
ssrfPolicy: { allowPrivateNetwork: true },
|
||||
});
|
||||
|
||||
@@ -478,7 +478,7 @@ describe("MatrixClient request hardening", () => {
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
||||
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", {
|
||||
ssrfPolicy: { allowPrivateNetwork: true },
|
||||
});
|
||||
await client.doRequest("GET", "http://127.0.0.1:8008/start", undefined, undefined, {
|
||||
@@ -503,7 +503,7 @@ describe("MatrixClient request hardening", () => {
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
||||
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("http://127.0.0.1:8008", "token", {
|
||||
localTimeoutMs: 25,
|
||||
ssrfPolicy: { allowPrivateNetwork: true },
|
||||
});
|
||||
@@ -520,7 +520,7 @@ describe("MatrixClient request hardening", () => {
|
||||
const storagePath = path.join(tempDir, "bot-storage.json");
|
||||
|
||||
try {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
storagePath,
|
||||
});
|
||||
|
||||
@@ -734,7 +734,7 @@ describe("MatrixClient event bridge", () => {
|
||||
|
||||
it("retries failed decryptions immediately on crypto key update signals", async () => {
|
||||
vi.useFakeTimers();
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
const failed: string[] = [];
|
||||
@@ -835,7 +835,7 @@ describe("MatrixClient event bridge", () => {
|
||||
|
||||
it("does not start duplicate retries when crypto signals fire while retry is in-flight", async () => {
|
||||
vi.useFakeTimers();
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
const delivered: string[] = [];
|
||||
@@ -984,7 +984,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
it("passes cryptoDatabasePrefix into initRustCrypto", async () => {
|
||||
matrixJsClient.getCrypto = vi.fn(() => undefined);
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
cryptoDatabasePrefix: "openclaw-matrix-test",
|
||||
});
|
||||
@@ -1005,7 +1005,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
requestOwnUserVerification: vi.fn(async () => null),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
|
||||
@@ -1020,7 +1020,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
|
||||
it("retries bootstrap with forced reset when initial publish/verification is incomplete", async () => {
|
||||
matrixJsClient.getCrypto = vi.fn(() => ({ on: vi.fn() }));
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
password: "secret-password", // pragma: allowlist secret
|
||||
});
|
||||
@@ -1053,7 +1053,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
|
||||
it("does not force-reset bootstrap when the device is already signed by its owner", async () => {
|
||||
matrixJsClient.getCrypto = vi.fn(() => ({ on: vi.fn() }));
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
password: "secret-password", // pragma: allowlist secret
|
||||
});
|
||||
@@ -1100,7 +1100,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
|
||||
it("does not force-reset bootstrap when password is unavailable", async () => {
|
||||
matrixJsClient.getCrypto = vi.fn(() => ({ on: vi.fn() }));
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
const bootstrapSpy = vi.fn().mockResolvedValue({
|
||||
@@ -1134,7 +1134,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
"utf8",
|
||||
);
|
||||
|
||||
new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
recoveryKeyPath,
|
||||
});
|
||||
@@ -1170,7 +1170,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
vi.useFakeTimers();
|
||||
const databasesSpy = vi.spyOn(indexedDB, "databases").mockResolvedValue([]);
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
idbSnapshotPath: path.join(os.tmpdir(), "matrix-idb-interval.json"),
|
||||
cryptoDatabasePrefix: "openclaw-matrix-interval",
|
||||
@@ -1204,7 +1204,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
await client.start();
|
||||
@@ -1232,7 +1232,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
await client.start();
|
||||
@@ -1275,7 +1275,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
}));
|
||||
|
||||
const recoveryDir = fs.mkdtempSync(path.join(os.tmpdir(), "matrix-sdk-verify-key-"));
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
recoveryKeyPath: path.join(recoveryDir, "recovery-key.json"),
|
||||
});
|
||||
@@ -1315,7 +1315,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
}));
|
||||
|
||||
const recoveryDir = fs.mkdtempSync(path.join(os.tmpdir(), "matrix-sdk-verify-local-only-"));
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
recoveryKeyPath: path.join(recoveryDir, "recovery-key.json"),
|
||||
});
|
||||
@@ -1364,7 +1364,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
|
||||
const recoveryDir = fs.mkdtempSync(path.join(os.tmpdir(), "matrix-sdk-verify-untrusted-"));
|
||||
const recoveryKeyPath = path.join(recoveryDir, "recovery-key.json");
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
recoveryKeyPath,
|
||||
});
|
||||
@@ -1422,7 +1422,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
recoveryKeyPath,
|
||||
});
|
||||
@@ -1461,7 +1461,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockResolvedValue({ version: "11" });
|
||||
@@ -1505,7 +1505,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
|
||||
@@ -1549,7 +1549,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
isKeyBackupTrusted,
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
|
||||
@@ -1587,7 +1587,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
|
||||
@@ -1628,7 +1628,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
};
|
||||
matrixJsClient.getCrypto = vi.fn(() => crypto);
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockResolvedValue({ version: "9" });
|
||||
@@ -1676,7 +1676,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
};
|
||||
matrixJsClient.getCrypto = vi.fn(() => crypto);
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockResolvedValue({ version: "5256" });
|
||||
@@ -1705,7 +1705,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockResolvedValue({ version: "3" });
|
||||
@@ -1749,7 +1749,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
isKeyBackupTrusted,
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
|
||||
@@ -1784,7 +1784,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockImplementation(async (method, endpoint) => {
|
||||
@@ -1838,7 +1838,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
isKeyBackupTrusted,
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockImplementation(async (method, endpoint) => {
|
||||
@@ -1878,7 +1878,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "doRequest").mockImplementation(async (method, endpoint) => {
|
||||
@@ -1917,7 +1917,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "getOwnCrossSigningPublicationStatus").mockResolvedValue({
|
||||
@@ -1965,7 +1965,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "getOwnCrossSigningPublicationStatus").mockResolvedValue({
|
||||
@@ -2002,7 +2002,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "getOwnCrossSigningPublicationStatus").mockResolvedValue({
|
||||
@@ -2050,7 +2050,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "getOwnCrossSigningPublicationStatus").mockResolvedValue({
|
||||
@@ -2108,7 +2108,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "getOwnCrossSigningPublicationStatus").mockResolvedValue({
|
||||
@@ -2172,7 +2172,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
})),
|
||||
}));
|
||||
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", undefined, undefined, {
|
||||
const client = new MatrixClient("https://matrix.example.org", "token", {
|
||||
encryption: true,
|
||||
});
|
||||
vi.spyOn(client, "getOwnCrossSigningPublicationStatus").mockResolvedValue({
|
||||
|
||||
@@ -207,8 +207,6 @@ export class MatrixClient {
|
||||
constructor(
|
||||
homeserver: string,
|
||||
accessToken: string,
|
||||
_storage?: unknown,
|
||||
_cryptoStorage?: unknown,
|
||||
opts: {
|
||||
userId?: string;
|
||||
password?: string;
|
||||
|
||||
Reference in New Issue
Block a user