Remove references to some deprecated js-sdk identifiers (#12729)

* IKeyBackupInfo -> KeyBackupInfo

* ICryptoCallbacks -> CryptoCallbacks

* IRoomEncryption -> RoomEncryptionEventContent

* MEGOLM_ALGORITHM -> a single local constant

* UserTrustLevel -> UserVerificationStatus
This commit is contained in:
Richard van der Hoff 2024-07-04 16:50:07 +01:00 committed by GitHub
parent de12d69e6b
commit 489bc32674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 61 additions and 43 deletions

View file

@ -115,13 +115,10 @@ module.exports = {
"!matrix-js-sdk/src/extensible_events_v1/InvalidEventError", "!matrix-js-sdk/src/extensible_events_v1/InvalidEventError",
"!matrix-js-sdk/src/crypto", "!matrix-js-sdk/src/crypto",
"!matrix-js-sdk/src/crypto/aes", "!matrix-js-sdk/src/crypto/aes",
"!matrix-js-sdk/src/crypto/olmlib",
"!matrix-js-sdk/src/crypto/crypto", "!matrix-js-sdk/src/crypto/crypto",
"!matrix-js-sdk/src/crypto/keybackup", "!matrix-js-sdk/src/crypto/keybackup",
"!matrix-js-sdk/src/crypto/RoomList",
"!matrix-js-sdk/src/crypto/deviceinfo", "!matrix-js-sdk/src/crypto/deviceinfo",
"!matrix-js-sdk/src/crypto/key_passphrase", "!matrix-js-sdk/src/crypto/key_passphrase",
"!matrix-js-sdk/src/crypto/CrossSigning",
"!matrix-js-sdk/src/crypto/recoverykey", "!matrix-js-sdk/src/crypto/recoverykey",
"!matrix-js-sdk/src/crypto/dehydration", "!matrix-js-sdk/src/crypto/dehydration",
"!matrix-js-sdk/src/oidc", "!matrix-js-sdk/src/oidc",

View file

@ -20,6 +20,7 @@ import { Error as ErrorEvent } from "@matrix-org/analytics-events/types/typescri
import { DecryptionFailureCode } from "matrix-js-sdk/src/crypto-api"; import { DecryptionFailureCode } from "matrix-js-sdk/src/crypto-api";
import { PosthogAnalytics } from "./PosthogAnalytics"; import { PosthogAnalytics } from "./PosthogAnalytics";
import { MEGOLM_ENCRYPTION_ALGORITHM } from "./utils/crypto";
/** The key that we use to store the `reportedEvents` bloom filter in localstorage */ /** The key that we use to store the `reportedEvents` bloom filter in localstorage */
const DECRYPTION_FAILURE_STORAGE_KEY = "mx_decryption_failure_event_ids"; const DECRYPTION_FAILURE_STORAGE_KEY = "mx_decryption_failure_event_ids";
@ -207,7 +208,7 @@ export class DecryptionFailureTracker {
*/ */
private eventDecrypted(e: MatrixEvent, nowTs: number): void { private eventDecrypted(e: MatrixEvent, nowTs: number): void {
// for now we only track megolm decryption failures // for now we only track megolm decryption failures
if (e.getWireContent().algorithm != "m.megolm.v1.aes-sha2") { if (e.getWireContent().algorithm != MEGOLM_ENCRYPTION_ALGORITHM) {
return; return;
} }
const errCode = e.decryptionFailureReason; const errCode = e.decryptionFailureReason;

View file

@ -16,7 +16,7 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup"; import { KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
import { MatrixClientPeg } from "../../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../../MatrixClientPeg";
import dis from "../../../../dispatcher/dispatcher"; import dis from "../../../../dispatcher/dispatcher";
@ -28,7 +28,7 @@ import DialogButtons from "../../../../components/views/elements/DialogButtons";
import BaseDialog from "../../../../components/views/dialogs/BaseDialog"; import BaseDialog from "../../../../components/views/dialogs/BaseDialog";
interface IProps { interface IProps {
newVersionInfo: IKeyBackupInfo; newVersionInfo: KeyBackupInfo;
onFinished(): void; onFinished(): void;
} }

View file

@ -31,7 +31,7 @@ import { defer, IDeferred, QueryDict } from "matrix-js-sdk/src/utils";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { throttle } from "lodash"; import { throttle } from "lodash";
import { CryptoEvent } from "matrix-js-sdk/src/crypto"; import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup"; import { KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
// what-input helps improve keyboard accessibility // what-input helps improve keyboard accessibility
import "what-input"; import "what-input";
@ -1614,7 +1614,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
}); });
cli.on(CryptoEvent.KeyBackupFailed, async (errcode): Promise<void> => { cli.on(CryptoEvent.KeyBackupFailed, async (errcode): Promise<void> => {
let haveNewVersion: boolean | undefined; let haveNewVersion: boolean | undefined;
let newVersionInfo: IKeyBackupInfo | null = null; let newVersionInfo: KeyBackupInfo | null = null;
// if key backup is still enabled, there must be a new backup in place // if key backup is still enabled, there must be a new backup in place
if (cli.getKeyBackupEnabled()) { if (cli.getKeyBackupEnabled()) {
haveNewVersion = true; haveNewVersion = true;

View file

@ -15,8 +15,7 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup"; import { KeyBackupInfo, VerificationRequest } from "matrix-js-sdk/src/crypto-api";
import { VerificationRequest } from "matrix-js-sdk/src/crypto-api";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { SecretStorageKeyDescription } from "matrix-js-sdk/src/secret-storage"; import { SecretStorageKeyDescription } from "matrix-js-sdk/src/secret-storage";
@ -40,7 +39,7 @@ interface IProps {
interface IState { interface IState {
phase?: Phase; phase?: Phase;
verificationRequest: VerificationRequest | null; verificationRequest: VerificationRequest | null;
backupInfo: IKeyBackupInfo | null; backupInfo: KeyBackupInfo | null;
lostKeys: boolean; lostKeys: boolean;
} }

View file

@ -17,8 +17,9 @@ limitations under the License.
import React, { ChangeEvent } from "react"; import React, { ChangeEvent } from "react";
import { MatrixClient, MatrixError, SecretStorage } from "matrix-js-sdk/src/matrix"; import { MatrixClient, MatrixError, SecretStorage } from "matrix-js-sdk/src/matrix";
import { IKeyBackupInfo, IKeyBackupRestoreResult } from "matrix-js-sdk/src/crypto/keybackup"; import { IKeyBackupRestoreResult } from "matrix-js-sdk/src/crypto/keybackup";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
import { MatrixClientPeg } from "../../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../../MatrixClientPeg";
import { _t } from "../../../../languageHandler"; import { _t } from "../../../../languageHandler";
@ -51,7 +52,7 @@ interface IProps {
} }
interface IState { interface IState {
backupInfo: IKeyBackupInfo | null; backupInfo: KeyBackupInfo | null;
backupKeyStored: Record<string, SecretStorage.SecretStorageKeyDescription> | null; backupKeyStored: Record<string, SecretStorage.SecretStorageKeyDescription> | null;
loading: boolean; loading: boolean;
loadError: boolean | null; loadError: boolean | null;
@ -246,7 +247,7 @@ export default class RestoreKeyBackupDialog extends React.PureComponent<IProps,
} }
} }
private async restoreWithCachedKey(backupInfo: IKeyBackupInfo | null): Promise<boolean> { private async restoreWithCachedKey(backupInfo: KeyBackupInfo | null): Promise<boolean> {
if (!backupInfo) return false; if (!backupInfo) return false;
try { try {
const recoverInfo = await MatrixClientPeg.safeGet().restoreKeyBackupWithCache( const recoverInfo = await MatrixClientPeg.safeGet().restoreKeyBackupWithCache(

View file

@ -16,8 +16,8 @@ limitations under the License.
import React, { forwardRef, useContext } from "react"; import React, { forwardRef, useContext } from "react";
import { MatrixEvent } from "matrix-js-sdk/src/matrix"; import { MatrixEvent } from "matrix-js-sdk/src/matrix";
import { IRoomEncryption } from "matrix-js-sdk/src/crypto/RoomList";
import type { RoomEncryptionEventContent } from "matrix-js-sdk/src/types";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../MatrixClientPeg";
import EventTileBubble from "./EventTileBubble"; import EventTileBubble from "./EventTileBubble";
@ -25,30 +25,29 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
import DMRoomMap from "../../../utils/DMRoomMap"; import DMRoomMap from "../../../utils/DMRoomMap";
import { objectHasDiff } from "../../../utils/objects"; import { objectHasDiff } from "../../../utils/objects";
import { isLocalRoom } from "../../../utils/localRoom/isLocalRoom"; import { isLocalRoom } from "../../../utils/localRoom/isLocalRoom";
import { MEGOLM_ENCRYPTION_ALGORITHM } from "../../../utils/crypto";
interface IProps { interface IProps {
mxEvent: MatrixEvent; mxEvent: MatrixEvent;
timestamp?: JSX.Element; timestamp?: JSX.Element;
} }
const ALGORITHM = "m.megolm.v1.aes-sha2";
const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({ mxEvent, timestamp }, ref) => { const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({ mxEvent, timestamp }, ref) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
const roomId = mxEvent.getRoomId()!; const roomId = mxEvent.getRoomId()!;
const isRoomEncrypted = MatrixClientPeg.safeGet().isRoomEncrypted(roomId); const isRoomEncrypted = MatrixClientPeg.safeGet().isRoomEncrypted(roomId);
const prevContent = mxEvent.getPrevContent() as IRoomEncryption; const prevContent = mxEvent.getPrevContent() as RoomEncryptionEventContent;
const content = mxEvent.getContent<IRoomEncryption>(); const content = mxEvent.getContent<RoomEncryptionEventContent>();
// if no change happened then skip rendering this, a shallow check is enough as all known fields are top-level. // if no change happened then skip rendering this, a shallow check is enough as all known fields are top-level.
if (!objectHasDiff(prevContent, content)) return null; // nop if (!objectHasDiff(prevContent, content)) return null; // nop
if (content.algorithm === ALGORITHM && isRoomEncrypted) { if (content.algorithm === MEGOLM_ENCRYPTION_ALGORITHM && isRoomEncrypted) {
let subtitle: string; let subtitle: string;
const dmPartner = DMRoomMap.shared().getUserIdForRoomId(roomId); const dmPartner = DMRoomMap.shared().getUserIdForRoomId(roomId);
const room = cli?.getRoom(roomId); const room = cli?.getRoom(roomId);
if (prevContent.algorithm === ALGORITHM) { if (prevContent.algorithm === MEGOLM_ENCRYPTION_ALGORITHM) {
subtitle = _t("timeline|m.room.encryption|parameters_changed"); subtitle = _t("timeline|m.room.encryption|parameters_changed");
} else if (dmPartner) { } else if (dmPartner) {
const displayName = room?.getMember(dmPartner)?.rawDisplayName || dmPartner; const displayName = room?.getMember(dmPartner)?.rawDisplayName || dmPartner;

View file

@ -34,7 +34,6 @@ import { KnownMembership } from "matrix-js-sdk/src/types";
import { UserVerificationStatus, VerificationRequest } from "matrix-js-sdk/src/crypto-api"; import { UserVerificationStatus, VerificationRequest } from "matrix-js-sdk/src/crypto-api";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { CryptoEvent } from "matrix-js-sdk/src/crypto"; import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { UserTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning";
import dis from "../../../dispatcher/dispatcher"; import dis from "../../../dispatcher/dispatcher";
import Modal from "../../../Modal"; import Modal from "../../../Modal";
@ -1323,7 +1322,7 @@ export const useDevices = (userId: string): IDevice[] | undefined | null => {
if (_userId !== userId) return; if (_userId !== userId) return;
updateDevices(); updateDevices();
}; };
const onUserTrustStatusChanged = (_userId: string, trustLevel: UserTrustLevel): void => { const onUserTrustStatusChanged = (_userId: string, trustLevel: UserVerificationStatus): void => {
if (_userId !== userId) return; if (_userId !== userId) return;
updateDevices(); updateDevices();
}; };

View file

@ -35,8 +35,7 @@ import {
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { CallErrorCode } from "matrix-js-sdk/src/webrtc/call"; import { CallErrorCode } from "matrix-js-sdk/src/webrtc/call";
import { CryptoEvent } from "matrix-js-sdk/src/crypto"; import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { UserTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning"; import { EventShieldColour, EventShieldReason, UserVerificationStatus } from "matrix-js-sdk/src/crypto-api";
import { EventShieldColour, EventShieldReason } from "matrix-js-sdk/src/crypto-api";
import { Tooltip } from "@vector-im/compound-web"; import { Tooltip } from "@vector-im/compound-web";
import ReplyChain from "../elements/ReplyChain"; import ReplyChain from "../elements/ReplyChain";
@ -577,7 +576,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
} }
}; };
private onUserVerificationChanged = (userId: string, _trustStatus: UserTrustLevel): void => { private onUserVerificationChanged = (userId: string, _trustStatus: UserVerificationStatus): void => {
if (userId === this.props.mxEvent.getSender()) { if (userId === this.props.mxEvent.getSender()) {
this.verifyEvent(); this.verifyEvent();
} }

View file

@ -19,7 +19,7 @@ import React from "react";
import { RoomMember, RoomStateEvent, MatrixEvent, EventType } from "matrix-js-sdk/src/matrix"; import { RoomMember, RoomStateEvent, MatrixEvent, EventType } from "matrix-js-sdk/src/matrix";
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo"; import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
import { CryptoEvent } from "matrix-js-sdk/src/crypto"; import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { UserTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning"; import { UserVerificationStatus } from "matrix-js-sdk/src/crypto-api";
import dis from "../../../dispatcher/dispatcher"; import dis from "../../../dispatcher/dispatcher";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@ -103,7 +103,7 @@ export default class MemberTile extends React.Component<IProps, IState> {
this.updateE2EStatus(); this.updateE2EStatus();
}; };
private onUserTrustStatusChanged = (userId: string, trustStatus: UserTrustLevel): void => { private onUserTrustStatusChanged = (userId: string, trustStatus: UserVerificationStatus): void => {
if (userId !== this.props.member.userId) return; if (userId !== this.props.member.userId) return;
this.updateE2EStatus(); this.updateE2EStatus();
}; };

View file

@ -50,6 +50,7 @@ import SettingsTab from "../SettingsTab";
import SdkConfig from "../../../../../SdkConfig"; import SdkConfig from "../../../../../SdkConfig";
import { shouldForceDisableEncryption } from "../../../../../utils/crypto/shouldForceDisableEncryption"; import { shouldForceDisableEncryption } from "../../../../../utils/crypto/shouldForceDisableEncryption";
import { Caption } from "../../../typography/Caption"; import { Caption } from "../../../typography/Caption";
import { MEGOLM_ENCRYPTION_ALGORITHM } from "../../../../../utils/crypto";
interface IProps { interface IProps {
room: Room; room: Room;
@ -176,7 +177,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
this.setState({ encrypted: true }); this.setState({ encrypted: true });
this.context this.context
.sendStateEvent(this.props.room.roomId, EventType.RoomEncryption, { .sendStateEvent(this.props.room.roomId, EventType.RoomEncryption, {
algorithm: "m.megolm.v1.aes-sha2", algorithm: MEGOLM_ENCRYPTION_ALGORITHM,
}) })
.catch((e) => { .catch((e) => {
logger.error(e); logger.error(e);

View file

@ -50,6 +50,7 @@ import { shouldForceDisableEncryption } from "./utils/crypto/shouldForceDisableE
import { waitForMember } from "./utils/membership"; import { waitForMember } from "./utils/membership";
import { PreferredRoomVersions } from "./utils/PreferredRoomVersions"; import { PreferredRoomVersions } from "./utils/PreferredRoomVersions";
import SettingsStore from "./settings/SettingsStore"; import SettingsStore from "./settings/SettingsStore";
import { MEGOLM_ENCRYPTION_ALGORITHM } from "./utils/crypto";
// we define a number of interfaces which take their names from the js-sdk // we define a number of interfaces which take their names from the js-sdk
/* eslint-disable camelcase */ /* eslint-disable camelcase */
@ -220,7 +221,7 @@ export default async function createRoom(client: MatrixClient, opts: IOpts): Pro
type: "m.room.encryption", type: "m.room.encryption",
state_key: "", state_key: "",
content: { content: {
algorithm: "m.megolm.v1.aes-sha2", algorithm: MEGOLM_ENCRYPTION_ALGORITHM,
}, },
}); });
} }

View file

@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { CryptoCallbacks } from "matrix-js-sdk/src/crypto-api";
import { ICryptoCallbacks } from "matrix-js-sdk/src/crypto";
import { IMatrixClientCreds } from "../MatrixClientPeg"; import { IMatrixClientCreds } from "../MatrixClientPeg";
import { Kind as SetupEncryptionKind } from "../toasts/SetupEncryptionToast"; import { Kind as SetupEncryptionKind } from "../toasts/SetupEncryptionToast";
@ -62,7 +61,7 @@ export interface ISecurityCustomisations {
getSecretStorageKey?: typeof getSecretStorageKey; getSecretStorageKey?: typeof getSecretStorageKey;
catchAccessSecretStorageError?: typeof catchAccessSecretStorageError; catchAccessSecretStorageError?: typeof catchAccessSecretStorageError;
setupEncryptionNeeded?: typeof setupEncryptionNeeded; setupEncryptionNeeded?: typeof setupEncryptionNeeded;
getDehydrationKey?: ICryptoCallbacks["getDehydrationKey"]; getDehydrationKey?: CryptoCallbacks["getDehydrationKey"];
/** /**
* When false, disables the post-login UI from showing. If there's * When false, disables the post-login UI from showing. If there's

View file

@ -15,8 +15,12 @@ limitations under the License.
*/ */
import EventEmitter from "events"; import EventEmitter from "events";
import { VerificationPhase, VerificationRequest, VerificationRequestEvent } from "matrix-js-sdk/src/crypto-api"; import {
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup"; KeyBackupInfo,
VerificationPhase,
VerificationRequest,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto-api";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { CryptoEvent } from "matrix-js-sdk/src/crypto"; import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { Device, SecretStorage } from "matrix-js-sdk/src/matrix"; import { Device, SecretStorage } from "matrix-js-sdk/src/matrix";
@ -44,7 +48,7 @@ export class SetupEncryptionStore extends EventEmitter {
private started?: boolean; private started?: boolean;
public phase?: Phase; public phase?: Phase;
public verificationRequest: VerificationRequest | null = null; public verificationRequest: VerificationRequest | null = null;
public backupInfo: IKeyBackupInfo | null = null; public backupInfo: KeyBackupInfo | null = null;
// ID of the key that the secrets we want are encrypted with // ID of the key that the secrets we want are encrypted with
public keyId: string | null = null; public keyId: string | null = null;
// Descriptor of the key that the secrets we want are encrypted with // Descriptor of the key that the secrets we want are encrypted with

19
src/utils/crypto/index.ts Normal file
View file

@ -0,0 +1,19 @@
/*
Copyright 2024 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/** The `algorithm` property used in `m.room.encrypted` state events for encrypted rooms.
*/
export const MEGOLM_ENCRYPTION_ALGORITHM = "m.megolm.v1.aes-sha2";

View file

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { MEGOLM_ALGORITHM } from "matrix-js-sdk/src/crypto/olmlib";
import { EventType, KNOWN_SAFE_ROOM_VERSION, MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix"; import { EventType, KNOWN_SAFE_ROOM_VERSION, MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types"; import { KnownMembership } from "matrix-js-sdk/src/types";
import { LocalRoom, LOCAL_ROOM_ID_PREFIX } from "../../../src/models/LocalRoom"; import { LOCAL_ROOM_ID_PREFIX, LocalRoom } from "../../../src/models/LocalRoom";
import { determineCreateRoomEncryptionOption, Member } from "../../../src/utils/direct-messages"; import { determineCreateRoomEncryptionOption, Member } from "../../../src/utils/direct-messages";
import { MEGOLM_ENCRYPTION_ALGORITHM } from "../crypto";
/** /**
* Create a DM local room. This room will not be send to the server and only exists inside the client. * Create a DM local room. This room will not be send to the server and only exists inside the client.
@ -59,7 +59,7 @@ export async function createDmLocalRoom(client: MatrixClient, targets: Member[])
event_id: `~${localRoom.roomId}:${client.makeTxnId()}`, event_id: `~${localRoom.roomId}:${client.makeTxnId()}`,
type: EventType.RoomEncryption, type: EventType.RoomEncryption,
content: { content: {
algorithm: MEGOLM_ALGORITHM, algorithm: MEGOLM_ENCRYPTION_ALGORITHM,
}, },
sender: userId, sender: userId,
state_key: "", state_key: "",

View file

@ -18,7 +18,6 @@ import { Mocked, mocked } from "jest-mock";
import { MatrixEvent, Room, MatrixClient, Device, ClientStoppedError } from "matrix-js-sdk/src/matrix"; import { MatrixEvent, Room, MatrixClient, Device, ClientStoppedError } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { CryptoEvent } from "matrix-js-sdk/src/crypto"; import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup";
import { CryptoSessionStateChange } from "@matrix-org/analytics-events/types/typescript/CryptoSessionStateChange"; import { CryptoSessionStateChange } from "@matrix-org/analytics-events/types/typescript/CryptoSessionStateChange";
import { CrossSigningStatus, CryptoApi, DeviceVerificationStatus, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api"; import { CrossSigningStatus, CryptoApi, DeviceVerificationStatus, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
@ -357,7 +356,7 @@ describe("DeviceListener", () => {
it("shows upgrade encryption toast when user has a key backup available", async () => { it("shows upgrade encryption toast when user has a key backup available", async () => {
// non falsy response // non falsy response
mockClient!.getKeyBackupVersion.mockResolvedValue({} as unknown as IKeyBackupInfo); mockClient!.getKeyBackupVersion.mockResolvedValue({} as unknown as KeyBackupInfo);
await createAndStart(); await createAndStart();
expect(SetupEncryptionToast.showToast).toHaveBeenCalledWith( expect(SetupEncryptionToast.showToast).toHaveBeenCalledWith(

View file

@ -30,7 +30,6 @@ import {
IEvent, IEvent,
} from "matrix-js-sdk/src/matrix"; } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types"; import { KnownMembership } from "matrix-js-sdk/src/types";
import { MEGOLM_ALGORITHM } from "matrix-js-sdk/src/crypto/olmlib";
import { fireEvent, render, screen, RenderResult, waitForElementToBeRemoved, waitFor } from "@testing-library/react"; import { fireEvent, render, screen, RenderResult, waitForElementToBeRemoved, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
@ -71,6 +70,7 @@ import { WidgetType } from "../../../src/widgets/WidgetType";
import WidgetStore from "../../../src/stores/WidgetStore"; import WidgetStore from "../../../src/stores/WidgetStore";
import { ViewRoomErrorPayload } from "../../../src/dispatcher/payloads/ViewRoomErrorPayload"; import { ViewRoomErrorPayload } from "../../../src/dispatcher/payloads/ViewRoomErrorPayload";
import { SearchScope } from "../../../src/Searching"; import { SearchScope } from "../../../src/Searching";
import { MEGOLM_ENCRYPTION_ALGORITHM } from "../../../src/utils/crypto";
const RoomView = wrapInMatrixClientContext(_RoomView); const RoomView = wrapInMatrixClientContext(_RoomView);
@ -351,7 +351,7 @@ describe("RoomView", () => {
event_id: `~${localRoom.roomId}:${cli.makeTxnId()}`, event_id: `~${localRoom.roomId}:${cli.makeTxnId()}`,
type: EventType.RoomEncryption, type: EventType.RoomEncryption,
content: { content: {
algorithm: MEGOLM_ALGORITHM, algorithm: MEGOLM_ENCRYPTION_ALGORITHM,
}, },
sender: cli.getUserId()!, sender: cli.getUserId()!,
state_key: "", state_key: "",