1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

ElementR: Cross user verification (#11364)

The hard work has been done in previous PRs in the js-sdk, so this is now just a case of updating a few call sites to use the new APIs.
This commit is contained in:
Florian Duros
2023-09-18 18:34:00 +02:00
committed by GitHub
parent e887c6d71f
commit 579b0dd10a
8 changed files with 33 additions and 31 deletions

View File

@ -15,6 +15,7 @@ limitations under the License.
*/
import { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
import { UserVerificationStatus } from "matrix-js-sdk/src/crypto-api";
import { shieldStatusForRoom } from "../../src/utils/ShieldUtils";
import DMRoomMap from "../../src/utils/DMRoomMap";
@ -30,10 +31,8 @@ function mkClient(selfTrust = false) {
getUserDeviceInfo: async (userIds: string[]) => {
return new Map(userIds.map((u) => [u, new Map([["DEVICE", {}]])]));
},
}),
checkUserTrust: (userId: string) => ({
isCrossSigningVerified: () => userId[1] == "T",
wasCrossSigningVerified: () => userId[1] == "T" || userId[1] == "W",
getUserVerificationStatus: async (userId: string): Promise<UserVerificationStatus> =>
new UserVerificationStatus(userId[1] == "T", userId[1] == "T" || userId[1] == "W", false),
}),
} as unknown as MatrixClient;
}
@ -50,8 +49,9 @@ describe("mkClient self-test", function () {
["@TF:h", true],
["@FT:h", false],
["@FF:h", false],
])("behaves well for user trust %s", (userId, trust) => {
expect(mkClient().checkUserTrust(userId).isCrossSigningVerified()).toBe(trust);
])("behaves well for user trust %s", async (userId, trust) => {
const status = await mkClient().getCrypto()?.getUserVerificationStatus(userId);
expect(status!.isCrossSigningVerified()).toBe(trust);
});
test.each([