Remove references to matrix-js-sdk/src/crypto/verification (#12365)

All this stuff is deprecated and has better alternatives now.
This commit is contained in:
Richard van der Hoff 2024-03-25 17:44:45 +00:00 committed by GitHub
parent ef2bd7ae04
commit 157ca48dff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 35 deletions

View file

@ -119,11 +119,6 @@ module.exports = {
"!matrix-js-sdk/src/crypto/CrossSigning", "!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/crypto/verification",
"!matrix-js-sdk/src/crypto/verification/SAS",
"!matrix-js-sdk/src/crypto/verification/QRCode",
"!matrix-js-sdk/src/crypto/verification/request",
"!matrix-js-sdk/src/crypto/verification/request/VerificationRequest",
"!matrix-js-sdk/src/oidc", "!matrix-js-sdk/src/oidc",
"!matrix-js-sdk/src/oidc/discovery", "!matrix-js-sdk/src/oidc/discovery",
"!matrix-js-sdk/src/oidc/authorize", "!matrix-js-sdk/src/oidc/authorize",

View file

@ -17,8 +17,13 @@ limitations under the License.
import { type Page, expect, JSHandle } from "@playwright/test"; import { type Page, expect, JSHandle } from "@playwright/test";
import type { CryptoEvent, ICreateRoomOpts, MatrixClient } from "matrix-js-sdk/src/matrix"; import type { CryptoEvent, ICreateRoomOpts, MatrixClient } from "matrix-js-sdk/src/matrix";
import type { VerificationRequest, Verifier, EmojiMapping, VerifierEvent } from "matrix-js-sdk/src/crypto-api"; import type {
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS"; VerificationRequest,
Verifier,
EmojiMapping,
VerifierEvent,
ShowSasCallbacks,
} from "matrix-js-sdk/src/crypto-api";
import { Credentials, HomeserverInstance } from "../../plugins/homeserver"; import { Credentials, HomeserverInstance } from "../../plugins/homeserver";
import { Client } from "../../pages/client"; import { Client } from "../../pages/client";
import { ElementAppPage } from "../../pages/ElementAppPage"; import { ElementAppPage } from "../../pages/ElementAppPage";
@ -58,7 +63,7 @@ export function handleSasVerification(verifier: JSHandle<Verifier>): Promise<Emo
if (event) return event.sas.emoji; if (event) return event.sas.emoji;
return new Promise<EmojiMapping[]>((resolve) => { return new Promise<EmojiMapping[]>((resolve) => {
const onShowSas = (event: ISasEvent) => { const onShowSas = (event: ShowSasCallbacks) => {
verifier.off("show_sas" as VerifierEvent, onShowSas); verifier.off("show_sas" as VerifierEvent, onShowSas);
event.confirm(); event.confirm();
resolve(event.sas.emoji); resolve(event.sas.emoji);

View file

@ -29,9 +29,8 @@ import {
RoomNameType, RoomNameType,
TokenRefreshFunction, TokenRefreshFunction,
} from "matrix-js-sdk/src/matrix"; } from "matrix-js-sdk/src/matrix";
import { VerificationMethod } from "matrix-js-sdk/src/types";
import * as utils from "matrix-js-sdk/src/utils"; import * as utils from "matrix-js-sdk/src/utils";
import { verificationMethods } from "matrix-js-sdk/src/crypto";
import { SHOW_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import createMatrixClient from "./utils/createMatrixClient"; import createMatrixClient from "./utils/createMatrixClient";
@ -433,9 +432,9 @@ class MatrixClientPegClass implements IMatrixClientPeg {
// the call arrives. // the call arrives.
iceCandidatePoolSize: 20, iceCandidatePoolSize: 20,
verificationMethods: [ verificationMethods: [
verificationMethods.SAS, VerificationMethod.Sas,
SHOW_QR_CODE_METHOD, VerificationMethod.ShowQrCode,
verificationMethods.RECIPROCATE_QR_CODE, VerificationMethod.Reciprocate,
], ],
identityServer: new IdentityAuthClient(), identityServer: new IdentityAuthClient(),
// These are always installed regardless of the labs flag so that cross-signing features // These are always installed regardless of the labs flag so that cross-signing features

View file

@ -15,18 +15,17 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import { verificationMethods } from "matrix-js-sdk/src/crypto";
import { SCAN_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode";
import { import {
ShowQrCodeCallbacks,
ShowSasCallbacks,
VerificationPhase as Phase, VerificationPhase as Phase,
VerificationRequest, VerificationRequest,
VerificationRequestEvent, VerificationRequestEvent,
ShowQrCodeCallbacks,
ShowSasCallbacks,
VerifierEvent, VerifierEvent,
} from "matrix-js-sdk/src/crypto-api"; } from "matrix-js-sdk/src/crypto-api";
import { RoomMember, Device, User } from "matrix-js-sdk/src/matrix"; import { Device, RoomMember, User } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { VerificationMethod } from "matrix-js-sdk/src/types";
import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../MatrixClientPeg";
import VerificationQRCode from "../elements/crypto/VerificationQRCode"; import VerificationQRCode from "../elements/crypto/VerificationQRCode";
@ -87,8 +86,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
private renderQRPhase(): JSX.Element { private renderQRPhase(): JSX.Element {
const { member, request } = this.props; const { member, request } = this.props;
const showSAS: boolean = request.otherPartySupportsMethod(verificationMethods.SAS); const showSAS: boolean = request.otherPartySupportsMethod(VerificationMethod.Sas);
const showQR: boolean = request.otherPartySupportsMethod(SCAN_QR_CODE_METHOD); const showQR: boolean = request.otherPartySupportsMethod(VerificationMethod.ScanQrCode);
const brand = SdkConfig.get().brand; const brand = SdkConfig.get().brand;
const noCommonMethodError: JSX.Element | null = const noCommonMethodError: JSX.Element | null =
@ -368,9 +367,9 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
return this.renderQRPhase(); return this.renderQRPhase();
case Phase.Started: case Phase.Started:
switch (request.chosenMethod) { switch (request.chosenMethod) {
case verificationMethods.RECIPROCATE_QR_CODE: case VerificationMethod.Reciprocate:
return this.renderQRReciprocatePhase(); return this.renderQRReciprocatePhase();
case verificationMethods.SAS: { case VerificationMethod.Sas: {
const emojis = this.state.sasEvent ? ( const emojis = this.state.sasEvent ? (
<VerificationShowSas <VerificationShowSas
displayName={displayName} displayName={displayName}
@ -400,7 +399,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
private startSAS = async (): Promise<void> => { private startSAS = async (): Promise<void> => {
this.setState({ emojiButtonClicked: true }); this.setState({ emojiButtonClicked: true });
await this.props.request.startVerification(verificationMethods.SAS); await this.props.request.startVerification(VerificationMethod.Sas);
}; };
private onSasMatchesClick = (): void => { private onSasMatchesClick = (): void => {

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { User, MatrixClient, RoomMember } from "matrix-js-sdk/src/matrix"; import { User, MatrixClient, RoomMember } from "matrix-js-sdk/src/matrix";
import { verificationMethods as VerificationMethods } from "matrix-js-sdk/src/crypto"; import { VerificationMethod } from "matrix-js-sdk/src/types";
import { CrossSigningKey, VerificationRequest } from "matrix-js-sdk/src/crypto-api"; import { CrossSigningKey, VerificationRequest } from "matrix-js-sdk/src/crypto-api";
import dis from "./dispatcher/dispatcher"; import dis from "./dispatcher/dispatcher";
@ -61,7 +61,7 @@ export async function verifyDevice(matrixClient: MatrixClient, user: User, devic
const verificationRequestPromise = matrixClient.legacyDeviceVerification( const verificationRequestPromise = matrixClient.legacyDeviceVerification(
user.userId, user.userId,
device.deviceId, device.deviceId,
VerificationMethods.SAS, VerificationMethod.Sas,
); );
setRightPanel({ member: user, verificationRequestPromise }); setRightPanel({ member: user, verificationRequestPromise });
} else if (action === "legacy") { } else if (action === "legacy") {

View file

@ -30,14 +30,14 @@ import {
Device, Device,
} 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 {
Phase,
VerificationRequest,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
import { defer } from "matrix-js-sdk/src/utils"; import { defer } from "matrix-js-sdk/src/utils";
import { EventEmitter } from "events"; import { EventEmitter } from "events";
import { UserVerificationStatus } from "matrix-js-sdk/src/crypto-api"; import {
UserVerificationStatus,
VerificationRequest,
VerificationPhase as Phase,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto-api";
import { TooltipProvider } from "@vector-im/compound-web"; import { TooltipProvider } from "@vector-im/compound-web";
import UserInfo, { import UserInfo, {

View file

@ -17,11 +17,8 @@ limitations under the License.
import React, { ComponentProps } from "react"; import React, { ComponentProps } from "react";
import { mocked, Mocked } from "jest-mock"; import { mocked, Mocked } from "jest-mock";
import { act, render, RenderResult } from "@testing-library/react"; import { act, render, RenderResult } from "@testing-library/react";
import {
VerificationRequest,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
import { TypedEventEmitter, IMyDevice, MatrixClient, Device } from "matrix-js-sdk/src/matrix"; import { TypedEventEmitter, IMyDevice, MatrixClient, Device } from "matrix-js-sdk/src/matrix";
import { VerificationRequest, VerificationRequestEvent } from "matrix-js-sdk/src/crypto-api";
import VerificationRequestToast from "../../../../src/components/views/toasts/VerificationRequestToast"; import VerificationRequestToast from "../../../../src/components/views/toasts/VerificationRequestToast";
import { import {