Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Remove dependency on org.matrix.e2e_cross_signing unstable feature (#…
Browse files Browse the repository at this point in the history
…10593)

* Remove dependency on `org.matrix.e2e_cross_signing` unstable feature

Currently, we have some code that relies on the server declaring support for an
`unstable_feature` called `org.matrix.e2e_cross_signing`. There is nothing in
the spec that requires this, so this would make us incompatible with some
server implementations.

The features in question were added in spec v1.1, so we can test for that
instead.

* fix unit test
  • Loading branch information
richvdh authored Apr 14, 2023
1 parent 70b87f8 commit 6b451af
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/DeviceListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ export default class DeviceListener {
if (!this.running) return; // we have been stopped
const cli = MatrixClientPeg.get();

if (!(await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"))) return;
// cross-signing support was added to Matrix in MSC1756, which landed in spec v1.1
if (!(await cli.isVersionSupported("v1.1"))) return;

if (!cli.isCryptoEnabled()) return;
// don't recheck until the initial sync is complete: lots of account data events will fire
Expand Down
4 changes: 0 additions & 4 deletions src/rageshake/submit-rageshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promise<Form
const secretStorage = client.crypto.secretStorage;

body.append("cross_signing_ready", String(await client.isCrossSigningReady()));
body.append(
"cross_signing_supported_by_hs",
String(await client.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")),
);
body.append("cross_signing_key", crossSigning.getId() ?? "n/a");
body.append(
"cross_signing_privkey_in_secret_storage",
Expand Down
3 changes: 0 additions & 3 deletions src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ async function getCryptoContext(client: MatrixClient): Promise<CryptoContext> {
return {
device_keys: keys.join(", "),
cross_signing_ready: String(await client.isCrossSigningReady()),
cross_signing_supported_by_hs: String(
await client.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"),
),
cross_signing_key: crossSigning.getId()!,
cross_signing_privkey_in_secret_storage: String(!!(await crossSigning.isStoredInSecretStorage(secretStorage))),
cross_signing_master_privkey_cached: String(!!(pkCache && (await pkCache.getCrossSigningKeyCache?.("master")))),
Expand Down
5 changes: 3 additions & 2 deletions test/DeviceListener-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("DeviceListener", () => {
getUserId: jest.fn().mockReturnValue(userId),
getKeyBackupVersion: jest.fn().mockResolvedValue(undefined),
getRooms: jest.fn().mockReturnValue([]),
doesServerSupportUnstableFeature: jest.fn().mockResolvedValue(true),
isVersionSupported: jest.fn().mockResolvedValue(true),
isCrossSigningReady: jest.fn().mockResolvedValue(true),
isSecretStorageReady: jest.fn().mockResolvedValue(true),
isCryptoEnabled: jest.fn().mockReturnValue(true),
Expand Down Expand Up @@ -234,9 +234,10 @@ describe("DeviceListener", () => {

describe("recheck", () => {
it("does nothing when cross signing feature is not supported", async () => {
mockClient!.doesServerSupportUnstableFeature.mockResolvedValue(false);
mockClient!.isVersionSupported.mockResolvedValue(false);
await createAndStart();

expect(mockClient!.isVersionSupported).toHaveBeenCalledWith("v1.1");
expect(mockClient!.isCrossSigningReady).not.toHaveBeenCalled();
});
it("does nothing when crypto is not enabled", async () => {
Expand Down

0 comments on commit 6b451af

Please sign in to comment.