Avoid using deprecated exports, fields, and duplicate code (#12555)
This commit is contained in:
parent
1973197eb6
commit
148a360598
33 changed files with 258 additions and 108 deletions
|
@ -78,15 +78,6 @@ export interface IMatrixClientPeg {
|
|||
*/
|
||||
opts: IStartClientOpts;
|
||||
|
||||
/**
|
||||
* Return the server name of the user's homeserver
|
||||
* Throws an error if unable to deduce the homeserver name
|
||||
* (e.g. if the user is not logged in)
|
||||
*
|
||||
* @returns {string} The homeserver name, if present.
|
||||
*/
|
||||
getHomeserverName(): string;
|
||||
|
||||
/**
|
||||
* Get the current MatrixClient, if any
|
||||
*/
|
||||
|
@ -384,14 +375,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
|||
logger.log(`MatrixClientPeg: MatrixClient started`);
|
||||
}
|
||||
|
||||
public getHomeserverName(): string {
|
||||
const matches = /^@[^:]+:(.+)$/.exec(this.safeGet().getSafeUserId());
|
||||
if (matches === null || matches.length < 1) {
|
||||
throw new Error("Failed to derive homeserver name from user ID!");
|
||||
}
|
||||
return matches[1];
|
||||
}
|
||||
|
||||
private namesToRoomName(names: string[], count: number): string | undefined {
|
||||
const countWithoutMe = count - 1;
|
||||
if (!names.length) {
|
||||
|
|
|
@ -14,13 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
DeviceVerificationStatus,
|
||||
ICryptoCallbacks,
|
||||
MatrixClient,
|
||||
encodeBase64,
|
||||
SecretStorage,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { Crypto, ICryptoCallbacks, MatrixClient, encodeBase64, SecretStorage } from "matrix-js-sdk/src/matrix";
|
||||
import { deriveKey } from "matrix-js-sdk/src/crypto/key_passphrase";
|
||||
import { decodeRecoveryKey } from "matrix-js-sdk/src/crypto/recoverykey";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
@ -249,7 +243,7 @@ async function onSecretRequested(
|
|||
deviceId: string,
|
||||
requestId: string,
|
||||
name: string,
|
||||
deviceTrust: DeviceVerificationStatus,
|
||||
deviceTrust: Crypto.DeviceVerificationStatus,
|
||||
): Promise<string | undefined> {
|
||||
logger.log("onSecretRequested", userId, deviceId, requestId, name, deviceTrust);
|
||||
const client = MatrixClientPeg.safeGet();
|
||||
|
|
|
@ -436,7 +436,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
|||
</summary>
|
||||
<LabelledToggleSwitch
|
||||
label={_t("create_room|unfederated", {
|
||||
serverName: MatrixClientPeg.getHomeserverName(),
|
||||
serverName: MatrixClientPeg.safeGet().getDomain(),
|
||||
})}
|
||||
onChange={this.onNoFederateChange}
|
||||
value={this.state.noFederate}
|
||||
|
|
|
@ -95,7 +95,7 @@ export default class ServerOfflineDialog extends React.PureComponent<IProps> {
|
|||
timeline = [<div key={1}>{_t("server_offline|empty_timeline")}</div>];
|
||||
}
|
||||
|
||||
const serverName = MatrixClientPeg.getHomeserverName();
|
||||
const serverName = MatrixClientPeg.safeGet().getDomain();
|
||||
return (
|
||||
<BaseDialog
|
||||
title={_t("server_offline|title")}
|
||||
|
|
|
@ -38,7 +38,7 @@ export async function getServerVersionFromFederationApi(client: MatrixClient): P
|
|||
let baseUrl = client.getHomeserverUrl();
|
||||
|
||||
try {
|
||||
const hsName = MatrixClientPeg.getHomeserverName();
|
||||
const hsName = MatrixClientPeg.safeGet().getDomain();
|
||||
// We don't use the js-sdk Autodiscovery module here as it only support client well-known, not server ones.
|
||||
const response = await fetch(`https://${hsName}/.well-known/matrix/server`);
|
||||
const json = await response.json();
|
||||
|
|
|
@ -118,7 +118,7 @@ function useServers(): ServerList {
|
|||
SettingLevel.ACCOUNT,
|
||||
);
|
||||
|
||||
const homeServer = MatrixClientPeg.getHomeserverName();
|
||||
const homeServer = MatrixClientPeg.safeGet().getDomain()!;
|
||||
const configServers = new Set<string>(SdkConfig.getObject("room_directory")?.get("servers") ?? []);
|
||||
removeAll(configServers, homeServer);
|
||||
// configured servers take preference over user-defined ones, if one occurs in both ignore the latter one.
|
||||
|
|
|
@ -43,7 +43,6 @@ import DMRoomMap from "../../../utils/DMRoomMap";
|
|||
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
|
||||
import SdkConfig from "../../../SdkConfig";
|
||||
import MultiInviter from "../../../utils/MultiInviter";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import E2EIcon from "../rooms/E2EIcon";
|
||||
import { useTypedEventEmitter } from "../../../hooks/useEventEmitter";
|
||||
import { textualPowerLevel } from "../../../Roles";
|
||||
|
@ -1413,8 +1412,7 @@ const BasicUserInfo: React.FC<{
|
|||
|
||||
// We don't need a perfect check here, just something to pass as "probably not our homeserver". If
|
||||
// someone does figure out how to bypass this check the worst that happens is an error.
|
||||
// FIXME this should be using cli instead of MatrixClientPeg.matrixClient
|
||||
if (isSynapseAdmin && member.userId.endsWith(`:${MatrixClientPeg.getHomeserverName()}`)) {
|
||||
if (isSynapseAdmin && member.userId.endsWith(`:${cli.getDomain()}`)) {
|
||||
synapseDeactivateButton = (
|
||||
<AccessibleButton
|
||||
kind="link"
|
||||
|
|
|
@ -90,7 +90,7 @@ export const usePublicRoomDirectory = (): {
|
|||
async ({ limit = 20, query, roomTypes }: IPublicRoomsOpts): Promise<boolean> => {
|
||||
const opts: IRoomDirectoryOptions = { limit };
|
||||
|
||||
if (config?.roomServer != MatrixClientPeg.getHomeserverName()) {
|
||||
if (config?.roomServer != MatrixClientPeg.safeGet().getDomain()) {
|
||||
opts.server = config?.roomServer;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ export const usePublicRoomDirectory = (): {
|
|||
return;
|
||||
}
|
||||
|
||||
const myHomeserver = MatrixClientPeg.getHomeserverName();
|
||||
const myHomeserver = MatrixClientPeg.safeGet().getDomain()!;
|
||||
const lsRoomServer = localStorage.getItem(LAST_SERVER_KEY);
|
||||
const lsInstanceId: string | undefined = localStorage.getItem(LAST_INSTANCE_KEY) ?? undefined;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { Method, MatrixClient, CryptoApi } from "matrix-js-sdk/src/matrix";
|
||||
import { Method, MatrixClient, Crypto } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import type * as Pako from "pako";
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
|
@ -177,7 +177,7 @@ async function collectSynapseSpecific(client: MatrixClient, body: FormData): Pro
|
|||
/**
|
||||
* Collects crypto related information.
|
||||
*/
|
||||
async function collectCryptoInfo(cryptoApi: CryptoApi, body: FormData): Promise<void> {
|
||||
async function collectCryptoInfo(cryptoApi: Crypto.CryptoApi, body: FormData): Promise<void> {
|
||||
body.append("crypto_version", cryptoApi.getVersion());
|
||||
|
||||
const ownDeviceKeys = await cryptoApi.getOwnDeviceKeys();
|
||||
|
@ -206,7 +206,7 @@ async function collectCryptoInfo(cryptoApi: CryptoApi, body: FormData): Promise<
|
|||
/**
|
||||
* Collects information about secret storage and backup.
|
||||
*/
|
||||
async function collectRecoveryInfo(client: MatrixClient, cryptoApi: CryptoApi, body: FormData): Promise<void> {
|
||||
async function collectRecoveryInfo(client: MatrixClient, cryptoApi: Crypto.CryptoApi, body: FormData): Promise<void> {
|
||||
const secretStorage = client.secretStorage;
|
||||
body.append("secret_storage_ready", String(await cryptoApi.isSecretStorageReady()));
|
||||
body.append("secret_storage_key_in_account", String(await secretStorage.hasKey()));
|
||||
|
|
|
@ -68,7 +68,7 @@ const mapAutoDiscoveryErrorTranslation = (err: AutoDiscoveryError): TranslationK
|
|||
return _td("auth|autodiscovery_no_well_known");
|
||||
case AutoDiscoveryError.InvalidJson:
|
||||
return _td("auth|autodiscovery_invalid_json");
|
||||
case AutoDiscoveryError.HomeserverTooOld:
|
||||
case AutoDiscoveryError.UnsupportedHomeserverSpecVersion:
|
||||
return _td("auth|autodiscovery_hs_incompatible");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,7 +20,6 @@ import * as zxcvbnEnPackage from "@zxcvbn-ts/language-en";
|
|||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { _t } from "../languageHandler";
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import SdkConfig from "../SdkConfig";
|
||||
|
||||
zxcvbnOptions.setOptions({
|
||||
|
@ -96,14 +95,14 @@ export function scorePassword(
|
|||
|
||||
if (matrixClient) {
|
||||
inputs.push(matrixClient.getUserIdLocalpart()!);
|
||||
}
|
||||
|
||||
try {
|
||||
const domain = MatrixClientPeg.getHomeserverName();
|
||||
const domain = matrixClient.getDomain()!;
|
||||
inputs.push(domain);
|
||||
} catch {
|
||||
// This is fine
|
||||
}
|
||||
}
|
||||
|
||||
zxcvbnOptions.setTranslations(getTranslations());
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { CryptoApi } from "matrix-js-sdk/src/matrix";
|
||||
import { Crypto } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
|
||||
|
@ -29,7 +29,7 @@ import { MatrixClientPeg } from "../../MatrixClientPeg";
|
|||
*
|
||||
* Dehydration can currently only be enabled by setting a flag in the .well-known file.
|
||||
*/
|
||||
async function deviceDehydrationEnabled(crypto: CryptoApi | undefined): Promise<boolean> {
|
||||
async function deviceDehydrationEnabled(crypto: Crypto.CryptoApi | undefined): Promise<boolean> {
|
||||
if (!crypto) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ export async function createDmLocalRoom(client: MatrixClient, targets: Member[])
|
|||
room_version: KNOWN_SAFE_ROOM_VERSION,
|
||||
},
|
||||
state_key: "",
|
||||
user_id: userId,
|
||||
sender: userId,
|
||||
room_id: localRoom.roomId,
|
||||
origin_server_ts: Date.now(),
|
||||
|
@ -62,7 +61,6 @@ export async function createDmLocalRoom(client: MatrixClient, targets: Member[])
|
|||
content: {
|
||||
algorithm: MEGOLM_ALGORITHM,
|
||||
},
|
||||
user_id: userId,
|
||||
sender: userId,
|
||||
state_key: "",
|
||||
room_id: localRoom.roomId,
|
||||
|
@ -80,7 +78,6 @@ export async function createDmLocalRoom(client: MatrixClient, targets: Member[])
|
|||
membership: KnownMembership.Join,
|
||||
},
|
||||
state_key: userId,
|
||||
user_id: userId,
|
||||
sender: userId,
|
||||
room_id: localRoom.roomId,
|
||||
}),
|
||||
|
|
|
@ -15,20 +15,12 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { Mocked, mocked } from "jest-mock";
|
||||
import {
|
||||
MatrixEvent,
|
||||
Room,
|
||||
MatrixClient,
|
||||
DeviceVerificationStatus,
|
||||
CryptoApi,
|
||||
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 { 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 { CrossSigningStatus, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
import { CrossSigningStatus, CryptoApi, DeviceVerificationStatus, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import DeviceListener from "../src/DeviceListener";
|
||||
import { MatrixClientPeg } from "../src/MatrixClientPeg";
|
||||
|
|
|
@ -16,7 +16,8 @@ limitations under the License.
|
|||
|
||||
import { mocked } from "jest-mock";
|
||||
import { PostHog } from "posthog-js";
|
||||
import { CryptoApi, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { CryptoApi } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import { Anonymity, getRedactedCurrentLocation, IPosthogEvent, PosthogAnalytics } from "../src/PosthogAnalytics";
|
||||
import SdkConfig from "../src/SdkConfig";
|
||||
|
|
|
@ -49,9 +49,11 @@ function mockPinnedEvent(pinnedMessageIds?: string[], prevPinnedMessageIds?: str
|
|||
content: {
|
||||
pinned: pinnedMessageIds,
|
||||
},
|
||||
unsigned: {
|
||||
prev_content: {
|
||||
pinned: prevPinnedMessageIds,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -183,10 +185,12 @@ describe("TextForEvent", () => {
|
|||
users_default: usersDefault,
|
||||
users,
|
||||
},
|
||||
unsigned: {
|
||||
prev_content: {
|
||||
users: prevUsers,
|
||||
users_default: prevDefault,
|
||||
},
|
||||
},
|
||||
});
|
||||
mxEvent.sender = { name: userA.name } as RoomMember;
|
||||
return mxEvent;
|
||||
|
@ -315,10 +319,12 @@ describe("TextForEvent", () => {
|
|||
alias,
|
||||
alt_aliases: altAliases,
|
||||
},
|
||||
unsigned: {
|
||||
prev_content: {
|
||||
alias: prevAlias,
|
||||
alt_aliases: prevAltAliases,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
type TestCase = [string, AliasEventProps & { result: string }];
|
||||
|
@ -512,11 +518,13 @@ describe("TextForEvent", () => {
|
|||
avatar_url: "b",
|
||||
displayname: "Bob",
|
||||
},
|
||||
unsigned: {
|
||||
prev_content: {
|
||||
membership: KnownMembership.Join,
|
||||
avatar_url: "a",
|
||||
displayname: "Andy",
|
||||
},
|
||||
},
|
||||
state_key: "@a:foo",
|
||||
}),
|
||||
mockClient,
|
||||
|
|
|
@ -353,7 +353,6 @@ describe("RoomView", () => {
|
|||
content: {
|
||||
algorithm: MEGOLM_ALGORITHM,
|
||||
},
|
||||
user_id: cli.getUserId()!,
|
||||
sender: cli.getUserId()!,
|
||||
state_key: "",
|
||||
room_id: localRoom.roomId,
|
||||
|
|
|
@ -82,8 +82,8 @@ function mockClient({
|
|||
}: MockClientOptions = {}): MatrixClient {
|
||||
stubClient();
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
MatrixClientPeg.getHomeserverName = jest.fn(() => homeserver);
|
||||
cli.getUserId = jest.fn(() => userId);
|
||||
cli.getDomain = jest.fn(() => homeserver);
|
||||
cli.getHomeserverUrl = jest.fn(() => homeserver);
|
||||
cli.getThirdpartyProtocols = jest.fn(() => Promise.resolve(thirdPartyProtocols));
|
||||
cli.publicRooms = jest.fn((options) => {
|
||||
|
|
|
@ -18,7 +18,7 @@ import { render, RenderResult, screen } from "@testing-library/react";
|
|||
import userEvent from "@testing-library/user-event";
|
||||
import React from "react";
|
||||
import { mocked, MockedObject } from "jest-mock";
|
||||
import { CryptoApi, MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import { Crypto, MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import { defer, IDeferred, sleep } from "matrix-js-sdk/src/utils";
|
||||
import { BackupTrustInfo, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
|
@ -35,7 +35,7 @@ import RestoreKeyBackupDialog from "../../../../../src/components/views/dialogs/
|
|||
|
||||
describe("CreateSecretStorageDialog", () => {
|
||||
let mockClient: MockedObject<MatrixClient>;
|
||||
let mockCrypto: MockedObject<CryptoApi>;
|
||||
let mockCrypto: MockedObject<Crypto.CryptoApi>;
|
||||
|
||||
beforeEach(() => {
|
||||
mockClient = getMockClientWithEventEmitter({
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import React from "react";
|
||||
import { screen, fireEvent, render, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { CryptoApi, IMegolmSessionData } from "matrix-js-sdk/src/matrix";
|
||||
import { Crypto, IMegolmSessionData } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import * as MegolmExportEncryption from "../../../../../src/utils/MegolmExportEncryption";
|
||||
import ExportE2eKeysDialog from "../../../../../src/async-components/views/dialogs/security/ExportE2eKeysDialog";
|
||||
|
@ -70,7 +70,7 @@ describe("ExportE2eKeysDialog", () => {
|
|||
cli.getCrypto = () => {
|
||||
return {
|
||||
exportRoomKeysAsJson,
|
||||
} as unknown as CryptoApi;
|
||||
} as unknown as Crypto.CryptoApi;
|
||||
};
|
||||
|
||||
// Mock the result of encrypting the sessions. If we don't do this, the
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import React from "react";
|
||||
import { fireEvent, render, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { CryptoApi } from "matrix-js-sdk/src/matrix";
|
||||
import { Crypto } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import ImportE2eKeysDialog from "../../../../../src/async-components/views/dialogs/security/ImportE2eKeysDialog";
|
||||
import * as MegolmExportEncryption from "../../../../../src/utils/MegolmExportEncryption";
|
||||
|
@ -75,7 +75,7 @@ describe("ImportE2eKeysDialog", () => {
|
|||
cli.getCrypto = () => {
|
||||
return {
|
||||
importRoomKeysAsJson,
|
||||
} as unknown as CryptoApi;
|
||||
} as unknown as Crypto.CryptoApi;
|
||||
};
|
||||
|
||||
// Mock the result of decrypting the sessions, to avoid needing to
|
||||
|
|
|
@ -18,17 +18,7 @@ import React from "react";
|
|||
import { fireEvent, render, screen, waitFor, cleanup, act, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { Mocked, mocked } from "jest-mock";
|
||||
import {
|
||||
Room,
|
||||
User,
|
||||
MatrixClient,
|
||||
RoomMember,
|
||||
MatrixEvent,
|
||||
EventType,
|
||||
CryptoApi,
|
||||
DeviceVerificationStatus,
|
||||
Device,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { Room, User, MatrixClient, RoomMember, MatrixEvent, EventType, Device } from "matrix-js-sdk/src/matrix";
|
||||
import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||
import { defer } from "matrix-js-sdk/src/utils";
|
||||
import { EventEmitter } from "events";
|
||||
|
@ -37,6 +27,8 @@ import {
|
|||
VerificationRequest,
|
||||
VerificationPhase as Phase,
|
||||
VerificationRequestEvent,
|
||||
CryptoApi,
|
||||
DeviceVerificationStatus,
|
||||
} from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import UserInfo, {
|
||||
|
@ -157,6 +149,7 @@ beforeEach(() => {
|
|||
isCryptoEnabled: jest.fn(),
|
||||
getUserId: jest.fn(),
|
||||
getSafeUserId: jest.fn(),
|
||||
getDomain: jest.fn(),
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
isSynapseAdministrator: jest.fn().mockResolvedValue(false),
|
||||
|
@ -584,6 +577,19 @@ describe("<UserInfo />", () => {
|
|||
expect(within(device2Button).getByText("dehydrated device 2")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("should render a deactivate button for users of the same server if we are a server admin", async () => {
|
||||
mockClient.isSynapseAdministrator.mockResolvedValue(true);
|
||||
mockClient.getDomain.mockReturnValue("example.com");
|
||||
|
||||
const { container } = renderComponent({
|
||||
phase: RightPanelPhases.RoomMemberInfo,
|
||||
room: mockRoom,
|
||||
});
|
||||
|
||||
await waitFor(() => expect(screen.getByRole("button", { name: "Deactivate user" })).toBeInTheDocument());
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe("with an encrypted room", () => {
|
||||
|
|
|
@ -223,3 +223,176 @@ exports[`<UserInfo /> with crypto enabled renders <BasicUserInfo /> 1`] = `
|
|||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`<UserInfo /> with crypto enabled should render a deactivate button for users of the same server if we are a server admin 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="mx_BaseCard mx_UserInfo"
|
||||
>
|
||||
<div
|
||||
class="mx_BaseCard_header"
|
||||
>
|
||||
<div
|
||||
aria-label="Close"
|
||||
class="mx_AccessibleButton mx_BaseCard_close"
|
||||
data-testid="base-card-close-button"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
/>
|
||||
<div
|
||||
class="mx_BaseCard_headerProp"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="mx_AutoHideScrollbar"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="mx_UserInfo_avatar"
|
||||
>
|
||||
<div
|
||||
class="mx_UserInfo_avatar_transition"
|
||||
>
|
||||
<div
|
||||
class="mx_UserInfo_avatar_transition_child"
|
||||
>
|
||||
<button
|
||||
aria-label="Profile picture"
|
||||
aria-live="off"
|
||||
class="_avatar_mcap2_17 mx_BaseAvatar _avatar-imageless_mcap2_61"
|
||||
data-color="3"
|
||||
data-testid="avatar-img"
|
||||
data-type="round"
|
||||
role="button"
|
||||
style="--cpd-avatar-size: 230.39999999999998px;"
|
||||
>
|
||||
u
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_container mx_UserInfo_separator"
|
||||
>
|
||||
<div
|
||||
class="mx_UserInfo_profile"
|
||||
>
|
||||
<div>
|
||||
<h2>
|
||||
<span
|
||||
aria-label="@user:example.com"
|
||||
dir="auto"
|
||||
title="@user:example.com"
|
||||
>
|
||||
@user:example.com
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_profile_mxid"
|
||||
>
|
||||
customUserIdentifier
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_profileStatus"
|
||||
>
|
||||
<div
|
||||
class="mx_PresenceLabel"
|
||||
>
|
||||
Unknown
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_container"
|
||||
>
|
||||
<h3>
|
||||
Security
|
||||
</h3>
|
||||
<p>
|
||||
Messages in this room are not end-to-end encrypted.
|
||||
</p>
|
||||
<div
|
||||
class="mx_UserInfo_container_verifyButton"
|
||||
>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_UserInfo_field mx_UserInfo_verifyButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Verify
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_devices"
|
||||
>
|
||||
<div />
|
||||
<div>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_UserInfo_expand mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="mx_E2EIcon mx_E2EIcon_normal"
|
||||
/>
|
||||
<div>
|
||||
1 session
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_container"
|
||||
>
|
||||
<h3>
|
||||
Options
|
||||
</h3>
|
||||
<div>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_UserInfo_field mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Message
|
||||
</div>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_UserInfo_field mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Share Link to User
|
||||
</div>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_UserInfo_field mx_UserInfo_destructive mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Ignore
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mx_UserInfo_container"
|
||||
>
|
||||
<h3>
|
||||
Admin Tools
|
||||
</h3>
|
||||
<div
|
||||
class="mx_UserInfo_buttons"
|
||||
>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_UserInfo_field mx_UserInfo_destructive mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Deactivate user
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
|
|
@ -18,7 +18,6 @@ import * as React from "react";
|
|||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { mocked } from "jest-mock";
|
||||
import {
|
||||
CryptoApi,
|
||||
EventType,
|
||||
IEventDecryptionResult,
|
||||
MatrixClient,
|
||||
|
@ -28,7 +27,7 @@ import {
|
|||
Room,
|
||||
TweakName,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { EventEncryptionInfo, EventShieldColour, EventShieldReason } from "matrix-js-sdk/src/crypto-api";
|
||||
import { CryptoApi, EventEncryptionInfo, EventShieldColour, EventShieldReason } from "matrix-js-sdk/src/crypto-api";
|
||||
import { mkEncryptedMatrixEvent } from "matrix-js-sdk/src/testing";
|
||||
|
||||
import EventTile, { EventTileProps } from "../../../../src/components/views/rooms/EventTile";
|
||||
|
|
|
@ -18,7 +18,7 @@ import React from "react";
|
|||
import { act, fireEvent, render, RenderResult, screen } from "@testing-library/react";
|
||||
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto-api";
|
||||
import { CryptoApi, DeviceVerificationStatus, VerificationRequest } from "matrix-js-sdk/src/crypto-api";
|
||||
import { defer, sleep } from "matrix-js-sdk/src/utils";
|
||||
import {
|
||||
ClientEvent,
|
||||
|
@ -30,8 +30,6 @@ import {
|
|||
PUSHER_ENABLED,
|
||||
IAuthData,
|
||||
GET_LOGIN_TOKEN_CAPABILITY,
|
||||
CryptoApi,
|
||||
DeviceVerificationStatus,
|
||||
MatrixError,
|
||||
MatrixClient,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
|
|
|
@ -15,7 +15,8 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { mocked, Mocked } from "jest-mock";
|
||||
import { CryptoApi, MatrixClient, Device, Preset, RoomType } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixClient, Device, Preset, RoomType } from "matrix-js-sdk/src/matrix";
|
||||
import { CryptoApi } from "matrix-js-sdk/src/crypto-api";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ describe("usePublicRoomDirectory", () => {
|
|||
stubClient();
|
||||
cli = MatrixClientPeg.safeGet();
|
||||
|
||||
MatrixClientPeg.getHomeserverName = () => "matrix.org";
|
||||
cli.getDomain = () => "matrix.org";
|
||||
cli.getThirdpartyProtocols = () => Promise.resolve({});
|
||||
cli.publicRooms = ({ filter }: IRoomDirectoryOptions) => {
|
||||
const chunk = filter?.generic_search_term
|
||||
|
|
|
@ -33,7 +33,7 @@ describe("useUserDirectory", () => {
|
|||
stubClient();
|
||||
cli = MatrixClientPeg.safeGet();
|
||||
|
||||
MatrixClientPeg.getHomeserverName = () => "matrix.org";
|
||||
cli.getDomain = () => "matrix.org";
|
||||
cli.getThirdpartyProtocols = () => Promise.resolve({});
|
||||
cli.searchUserDirectory = ({ term: query }) =>
|
||||
Promise.resolve({
|
||||
|
|
|
@ -16,9 +16,10 @@ limitations under the License.
|
|||
|
||||
import { mocked, Mocked } from "jest-mock";
|
||||
import { IBootstrapCrossSigningOpts } from "matrix-js-sdk/src/crypto";
|
||||
import { CryptoApi, DeviceVerificationStatus, MatrixClient, Device } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixClient, Device } from "matrix-js-sdk/src/matrix";
|
||||
import { SecretStorageKeyDescriptionAesV1, ServerSideSecretStorage } from "matrix-js-sdk/src/secret-storage";
|
||||
import { IDehydratedDevice } from "matrix-js-sdk/src/crypto/dehydration";
|
||||
import { CryptoApi, DeviceVerificationStatus } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import { SdkContextClass } from "../../src/contexts/SDKContext";
|
||||
import { accessSecretStorage } from "../../src/SecurityManager";
|
||||
|
|
|
@ -27,7 +27,6 @@ import fetchMock from "fetch-mock-jest";
|
|||
|
||||
import { getMockClientWithEventEmitter, mockClientMethodsCrypto, mockPlatformPeg } from "./test-utils";
|
||||
import { collectBugReport } from "../src/rageshake/submit-rageshake";
|
||||
import { MatrixClientPeg } from "../src/MatrixClientPeg";
|
||||
import SettingsStore from "../src/settings/SettingsStore";
|
||||
import { ConsoleLogger } from "../src/rageshake/rageshake";
|
||||
|
||||
|
@ -45,13 +44,12 @@ describe("Rageshakes", () => {
|
|||
);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.spyOn(MatrixClientPeg, "getHomeserverName").mockReturnValue("alice-server.com");
|
||||
|
||||
mockClient = getMockClientWithEventEmitter({
|
||||
credentials: { userId: "@test:example.com" },
|
||||
deviceId: "AAAAAAAAAA",
|
||||
baseUrl: "https://alice-server.com",
|
||||
getHomeserverUrl: jest.fn().mockReturnValue("https://alice-server.com"),
|
||||
getDomain: jest.fn().mockReturnValue("alice-server.com"),
|
||||
...mockClientMethodsCrypto(),
|
||||
http: mockHttpAPI,
|
||||
});
|
||||
|
|
|
@ -364,10 +364,12 @@ export function mkEvent(opts: MakeEventProps): MatrixEvent {
|
|||
room_id: opts.room,
|
||||
sender: opts.user,
|
||||
content: opts.content,
|
||||
prev_content: opts.prev_content,
|
||||
event_id: opts.id ?? "$" + Math.random() + "-" + Math.random(),
|
||||
origin_server_ts: opts.ts ?? 0,
|
||||
unsigned: opts.unsigned,
|
||||
unsigned: {
|
||||
...opts.unsigned,
|
||||
prev_content: opts.prev_content,
|
||||
},
|
||||
redacts: opts.redacts,
|
||||
};
|
||||
if (opts.skey !== undefined) {
|
||||
|
|
|
@ -18,8 +18,9 @@ import React from "react";
|
|||
import { render, RenderResult, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { mocked, Mocked } from "jest-mock";
|
||||
import { CryptoApi, DeviceVerificationStatus, IMyDevice, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { IMyDevice, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
|
||||
import { CryptoApi, DeviceVerificationStatus } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import dis from "../../src/dispatcher/dispatcher";
|
||||
import { showToast } from "../../src/toasts/UnverifiedSessionToast";
|
||||
|
|
|
@ -218,7 +218,7 @@ describe("AutoDiscoveryUtils", () => {
|
|||
...validIsConfig,
|
||||
"m.homeserver": {
|
||||
state: AutoDiscoveryAction.FAIL_ERROR,
|
||||
error: AutoDiscovery.ERROR_HOMESERVER_TOO_OLD,
|
||||
error: AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION,
|
||||
base_url: "https://matrix.org",
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue