Skip to content

Commit bca2582

Browse files
authored
Remove deprecated methods of CryptoBackend (#4671)
* feat(CryptoBackend)!: remove deprecated methods * feat(rust-crypto)!: remove deprecated methods of `CryptoBackend` * test(rust-crypto): remove tests of deprecated methods of `CryptoBackend`
1 parent 344ffa3 commit bca2582

File tree

3 files changed

+0
-127
lines changed

3 files changed

+0
-127
lines changed

spec/unit/rust-crypto/rust-crypto.spec.ts

-28
Original file line numberDiff line numberDiff line change
@@ -1013,34 +1013,6 @@ describe("RustCrypto", () => {
10131013
});
10141014
});
10151015

1016-
describe(".getEventEncryptionInfo", () => {
1017-
let rustCrypto: RustCrypto;
1018-
1019-
beforeEach(async () => {
1020-
rustCrypto = await makeTestRustCrypto();
1021-
});
1022-
1023-
it("should handle unencrypted events", () => {
1024-
const event = mkEvent({ event: true, type: "m.room.message", content: { body: "xyz" } });
1025-
const res = rustCrypto.getEventEncryptionInfo(event);
1026-
expect(res.encrypted).toBeFalsy();
1027-
});
1028-
1029-
it("should handle encrypted events", async () => {
1030-
const event = mkEvent({ event: true, type: "m.room.encrypted", content: { algorithm: "fake_alg" } });
1031-
const mockCryptoBackend = {
1032-
decryptEvent: () =>
1033-
({
1034-
senderCurve25519Key: "1234",
1035-
}) as IEventDecryptionResult,
1036-
} as unknown as CryptoBackend;
1037-
await event.attemptDecryption(mockCryptoBackend);
1038-
1039-
const res = rustCrypto.getEventEncryptionInfo(event);
1040-
expect(res.encrypted).toBeTruthy();
1041-
});
1042-
});
1043-
10441016
describe(".getEncryptionInfoForEvent", () => {
10451017
let rustCrypto: RustCrypto;
10461018
let olmMachine: Mocked<RustSdkCryptoJs.OlmMachine>;

src/common-crypto/CryptoBackend.ts

-40
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import type { IDeviceLists, IToDeviceEvent } from "../sync-accumulator.ts";
1818
import { IClearEvent, MatrixEvent } from "../models/event.ts";
1919
import { Room } from "../models/room.ts";
2020
import { CryptoApi, DecryptionFailureCode, ImportRoomKeysOpts } from "../crypto-api/index.ts";
21-
import { CrossSigningInfo, UserTrustLevel } from "../crypto/CrossSigning.ts";
22-
import { IEncryptedEventInfo } from "../crypto/api.ts";
2321
import { KeyBackupInfo, KeyBackupSession } from "../crypto-api/keybackup.ts";
2422
import { IMegolmSessionData } from "../@types/crypto.ts";
2523

@@ -45,15 +43,6 @@ export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
4543
*/
4644
stop(): void;
4745

48-
/**
49-
* Get the verification level for a given user
50-
*
51-
* @param userId - user to be checked
52-
*
53-
* @deprecated Superceded by {@link CryptoApi#getUserVerificationStatus}.
54-
*/
55-
checkUserTrust(userId: string): UserTrustLevel;
56-
5746
/**
5847
* Encrypt an event according to the configuration of the room.
5948
*
@@ -74,35 +63,6 @@ export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
7463
*/
7564
decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;
7665

77-
/**
78-
* Get information about the encryption of an event
79-
*
80-
* @param event - event to be checked
81-
* @deprecated Use {@link CryptoApi#getEncryptionInfoForEvent} instead
82-
*/
83-
getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo;
84-
85-
/**
86-
* Get the cross signing information for a given user.
87-
*
88-
* The cross-signing API is currently UNSTABLE and may change without notice.
89-
*
90-
* @param userId - the user ID to get the cross-signing info for.
91-
*
92-
* @returns the cross signing information for the user.
93-
* @deprecated Prefer {@link CryptoApi#userHasCrossSigningKeys}
94-
*/
95-
getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null;
96-
97-
/**
98-
* Check the cross signing trust of the current user
99-
*
100-
* @param opts - Options object.
101-
*
102-
* @deprecated Unneeded for the new crypto
103-
*/
104-
checkOwnCrossSigningTrust(opts?: CheckOwnCrossSigningTrustOpts): Promise<void>;
105-
10666
/**
10767
* Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.
10868
* @param backupInfo - The backup information

src/rust-crypto/rust-crypto.ts

-59
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
2020
import type { IEventDecryptionResult, IMegolmSessionData } from "../@types/crypto.ts";
2121
import { KnownMembership } from "../@types/membership.ts";
2222
import type { IDeviceLists, IToDeviceEvent } from "../sync-accumulator.ts";
23-
import type { IEncryptedEventInfo } from "../crypto/api.ts";
2423
import type { ToDevicePayload, ToDeviceBatch } from "../models/ToDeviceMessage.ts";
2524
import { MatrixEvent, MatrixEventEvent } from "../models/event.ts";
2625
import { Room } from "../models/room.ts";
@@ -269,64 +268,6 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
269268
return await this.eventDecryptor.attemptEventDecryption(event, this.deviceIsolationMode);
270269
}
271270

272-
/**
273-
* Implementation of (deprecated) {@link MatrixClient#getEventEncryptionInfo}.
274-
*
275-
* @param event - event to inspect
276-
*/
277-
public getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo {
278-
const ret: Partial<IEncryptedEventInfo> = {};
279-
280-
ret.senderKey = event.getSenderKey() ?? undefined;
281-
ret.algorithm = event.getWireContent().algorithm;
282-
283-
if (!ret.senderKey || !ret.algorithm) {
284-
ret.encrypted = false;
285-
return ret as IEncryptedEventInfo;
286-
}
287-
ret.encrypted = true;
288-
ret.authenticated = true;
289-
ret.mismatchedSender = true;
290-
return ret as IEncryptedEventInfo;
291-
}
292-
293-
/**
294-
* Implementation of {@link CryptoBackend#checkUserTrust}.
295-
*
296-
* Stub for backwards compatibility.
297-
*
298-
*/
299-
public checkUserTrust(userId: string): UserVerificationStatus {
300-
return new UserVerificationStatus(false, false, false);
301-
}
302-
303-
/**
304-
* Get the cross signing information for a given user.
305-
*
306-
* The cross-signing API is currently UNSTABLE and may change without notice.
307-
*
308-
* @param userId - the user ID to get the cross-signing info for.
309-
*
310-
* @returns the cross signing information for the user.
311-
*/
312-
public getStoredCrossSigningForUser(userId: string): null {
313-
// TODO
314-
return null;
315-
}
316-
317-
/**
318-
* This function is unneeded for the rust-crypto.
319-
* The cross signing key import and the device verification are done in {@link CryptoApi#bootstrapCrossSigning}
320-
*
321-
* The function is stub to keep the compatibility with the old crypto.
322-
* More information: https://github.com/vector-im/element-web/issues/25648
323-
*
324-
* Implementation of {@link CryptoBackend#checkOwnCrossSigningTrust}
325-
*/
326-
public async checkOwnCrossSigningTrust(): Promise<void> {
327-
return;
328-
}
329-
330271
/**
331272
* Implementation of {@link CryptoBackend#getBackupDecryptor}.
332273
*/

0 commit comments

Comments
 (0)