Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy crypto #4653

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a45de2f
Remove deprecated calls in `webrtc/call.ts`
florianduros Nov 28, 2024
9c4f21b
Throw error when legacy call was used
florianduros Dec 6, 2024
020770b
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/call
florianduros Jan 16, 2025
d12fcc4
Merge pull request #4562 from matrix-org/florianduros/rip-out-legacy-…
florianduros Jan 23, 2025
1129c45
Remove `MatrixClient.initLegacyCrypto` (#4620)
florianduros Jan 27, 2025
8537aee
Remove legacy crypto support in `sync` api (#4622)
florianduros Jan 27, 2025
f763192
Remove deprecated `DeviceInfo` in `webrtc/call.ts` (#4654)
florianduros Jan 27, 2025
ce6f971
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/remove…
florianduros Jan 27, 2025
89cec0a
Remove deprecated methods and attributes of `MatrixClient` (#4659)
florianduros Jan 28, 2025
b156707
Remove usage of legacy crypto in `event.ts` (#4666)
florianduros Jan 29, 2025
2558903
Remove legacy crypto export in `matrix.ts` (#4667)
florianduros Jan 29, 2025
69db213
Remove usage of legacy crypto in integ tests (#4669)
florianduros Jan 29, 2025
344ffa3
Clean up legacy stores (#4663)
florianduros Jan 30, 2025
bca2582
Remove deprecated methods of `CryptoBackend` (#4671)
florianduros Jan 31, 2025
0185f30
Remove usage of legacy crypto in `embedded.ts` (#4668)
florianduros Jan 31, 2025
6bd319b
Remove legacy crypto files (#4672)
florianduros Feb 3, 2025
07016bb
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/remove…
florianduros Feb 3, 2025
b76ccc6
Clean up integ test after legacy crypto removal (#4682)
florianduros Feb 4, 2025
e287ff6
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/remove…
florianduros Feb 4, 2025
b3ec086
Restore broken link to `CryptoApi` (#4692)
florianduros Feb 5, 2025
19fbd6b
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/remove…
florianduros Feb 5, 2025
664e3fd
chore: fix linting and formatting due to merge
florianduros Feb 5, 2025
e6b7a1f
Remove unused crypto type and missing doc (#4696)
florianduros Feb 6, 2025
5fa0b04
Merge branch 'develop' into florianduros/rip-out-legacy-crypto/remove…
florianduros Feb 6, 2025
2e83fea
test(call): add test when crypto is enabled
florianduros Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ module.exports = {
// Disabled tests are a reality for now but as soon as all of the xits are
// eliminated, we should enforce this.
"jest/no-disabled-tests": "off",
// Also treat "oldBackendOnly" as a test function.
// Used in some crypto tests.
"jest/no-standalone-expect": [
"error",
{
additionalTestBlockFunctions: ["beforeAll", "beforeEach", "oldBackendOnly", "newBackendOnly"],
additionalTestBlockFunctions: ["beforeAll", "beforeEach"],
},
],
},
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ Then visit `http://localhost:8005` to see the API docs.

## Initialization

**Do not use `matrixClient.initLegacyCrypto()`. This method is deprecated and no longer maintained.**

To initialize the end-to-end encryption support in the matrix client:

```javascript
Expand Down
10 changes: 0 additions & 10 deletions spec/TestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import MockHttpBackend from "matrix-mock-request";

import type { IDeviceKeys, IOneTimeKey } from "../src/@types/crypto";
import type { IE2EKeyReceiver } from "./test-utils/E2EKeyReceiver";
import { LocalStorageCryptoStore } from "../src/crypto/store/localStorage-crypto-store";
import { logger } from "../src/logger";
import { syncPromise } from "./test-utils/test-utils";
import { createClient, type IStartClientOpts } from "../src/matrix";
Expand All @@ -36,7 +35,6 @@ import {
type MatrixClient,
PendingEventOrdering,
} from "../src/client";
import { MockStorageApi } from "./MockStorageApi";
import { type IKeysUploadResponse, type IUploadKeysRequest } from "../src/client";
import { type ISyncResponder } from "./test-utils/SyncResponder";

Expand All @@ -60,10 +58,6 @@ export class TestClient implements IE2EKeyReceiver, ISyncResponder {
sessionStoreBackend?: Storage,
options?: Partial<ICreateClientOpts>,
) {
if (sessionStoreBackend === undefined) {
sessionStoreBackend = new MockStorageApi() as unknown as Storage;
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
}

this.httpBackend = new MockHttpBackend();

const fullOptions: ICreateClientOpts = {
Expand All @@ -74,10 +68,6 @@ export class TestClient implements IE2EKeyReceiver, ISyncResponder {
fetchFn: this.httpBackend.fetchFn as typeof globalThis.fetch,
...options,
};
if (!fullOptions.cryptoStore) {
// expose this so the tests can get to it
fullOptions.cryptoStore = new LocalStorageCryptoStore(sessionStoreBackend);
}
this.client = createClient(fullOptions);

this.deviceKeys = null;
Expand Down
23 changes: 8 additions & 15 deletions spec/integ/crypto/cross-signing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import fetchMock from "fetch-mock-jest";
import "fake-indexeddb/auto";
import { IDBFactory } from "fake-indexeddb";

import { CRYPTO_BACKENDS, type InitCrypto, syncPromise } from "../../test-utils/test-utils";
import { type AuthDict, createClient, CryptoEvent, type MatrixClient } from "../../../src";
import { syncPromise } from "../../test-utils/test-utils";
import { type AuthDict, createClient, type MatrixClient } from "../../../src";
import { mockInitialApiRequests, mockSetupCrossSigningRequests } from "../../test-utils/mockEndpoints";
import encryptAESSecretStorageItem from "../../../src/utils/encryptAESSecretStorageItem.ts";
import { type CryptoCallbacks, CrossSigningKey } from "../../../src/crypto-api";
Expand All @@ -37,6 +37,7 @@ import {
import * as testData from "../../test-utils/test-data";
import { E2EKeyResponder } from "../../test-utils/E2EKeyResponder";
import { AccountDataAccumulator } from "../../test-utils/AccountDataAccumulator";
import { CryptoEvent } from "../../../src/crypto-api";

afterEach(() => {
// reset fake-indexeddb after each test, to make sure we don't leak connections
Expand All @@ -54,11 +55,7 @@ const TEST_DEVICE_ID = "xzcvb";
* These tests work by intercepting HTTP requests via fetch-mock rather than mocking out bits of the client, so as
* to provide the most effective integration tests possible.
*/
describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: string, initCrypto: InitCrypto) => {
// newBackendOnly is the opposite to `oldBackendOnly`: it will skip the test if we are running against the legacy
// backend. Once we drop support for legacy crypto, it will go away.
const newBackendOnly = backend === "rust-sdk" ? test : test.skip;

describe("cross-signing", () => {
let aliceClient: MatrixClient;

/** an object which intercepts `/sync` requests from {@link #aliceClient} */
Expand Down Expand Up @@ -107,7 +104,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
body: { errcode: "M_NOT_FOUND" },
});

await initCrypto(aliceClient);
await aliceClient.initRustCrypto();
},
/* it can take a while to initialise the crypto library on the first pass, so bump up the timeout. */
10000,
Expand Down Expand Up @@ -162,7 +159,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
);
});

newBackendOnly("get cross signing keys from secret storage and import them", async () => {
it("get cross signing keys from secret storage and import them", async () => {
// Return public cross signing keys
e2eKeyResponder.addCrossSigningData(SIGNED_CROSS_SIGNING_KEYS_DATA);

Expand Down Expand Up @@ -263,7 +260,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
expect(calls.length).toEqual(0);
});

newBackendOnly("will upload existing cross-signing keys to an established secret storage", async () => {
it("will upload existing cross-signing keys to an established secret storage", async () => {
// This rather obscure codepath covers the case that:
// - 4S is set up and working
// - our device has private cross-signing keys, but has not published them to 4S
Expand Down Expand Up @@ -420,9 +417,8 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
function awaitCrossSigningKeysUpload() {
return new Promise<any>((resolve) => {
fetchMock.post(
// legacy crypto uses /unstable/; /v3/ is correct
{
url: new RegExp("/_matrix/client/(unstable|v3)/keys/device_signing/upload"),
url: new RegExp("/_matrix/client/v3/keys/device_signing/upload"),
name: "upload-keys",
},
(url, options) => {
Expand Down Expand Up @@ -475,9 +471,6 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
await aliceClient.startClient();
await syncPromise(aliceClient);

// Wait for legacy crypto to find the device
await jest.advanceTimersByTimeAsync(10);

const devices = await aliceClient.getCrypto()!.getUserDeviceInfo([aliceClient.getSafeUserId()]);
expect(devices.get(aliceClient.getSafeUserId())!.has(testData.TEST_DEVICE_ID)).toBeTruthy();
});
Expand Down
Loading