You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Remove remaining legacy crypto imports in new crypto and tests (#4491)
* Use `CryptoCallbacks` from `CryptoApi` instead of legacy crypto. * Use `KeyBackup` from rust crypto instead of `IKeyBackup` from legacy crypto
This commit is contained in:
@ -91,7 +91,6 @@ import {
|
|||||||
OnlySignedDevicesIsolationMode,
|
OnlySignedDevicesIsolationMode,
|
||||||
} from "../../../src/crypto-api";
|
} from "../../../src/crypto-api";
|
||||||
import { E2EKeyResponder } from "../../test-utils/E2EKeyResponder";
|
import { E2EKeyResponder } from "../../test-utils/E2EKeyResponder";
|
||||||
import { IKeyBackup } from "../../../src/crypto/backup";
|
|
||||||
import {
|
import {
|
||||||
createOlmAccount,
|
createOlmAccount,
|
||||||
createOlmSession,
|
createOlmSession,
|
||||||
@ -106,6 +105,7 @@ import { ToDevicePayload } from "../../../src/models/ToDeviceMessage";
|
|||||||
import { AccountDataAccumulator } from "../../test-utils/AccountDataAccumulator";
|
import { AccountDataAccumulator } from "../../test-utils/AccountDataAccumulator";
|
||||||
import { UNSIGNED_MEMBERSHIP_FIELD } from "../../../src/@types/event";
|
import { UNSIGNED_MEMBERSHIP_FIELD } from "../../../src/@types/event";
|
||||||
import { KnownMembership } from "../../../src/@types/membership";
|
import { KnownMembership } from "../../../src/@types/membership";
|
||||||
|
import { KeyBackup } from "../../../src/rust-crypto/backup.ts";
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// reset fake-indexeddb after each test, to make sure we don't leak connections
|
// reset fake-indexeddb after each test, to make sure we don't leak connections
|
||||||
@ -3138,11 +3138,11 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
// Import a new key that should be uploaded
|
// Import a new key that should be uploaded
|
||||||
const newKey = testData.MEGOLM_SESSION_DATA;
|
const newKey = testData.MEGOLM_SESSION_DATA;
|
||||||
|
|
||||||
const awaitKeyUploaded = new Promise<IKeyBackup>((resolve) => {
|
const awaitKeyUploaded = new Promise<KeyBackup>((resolve) => {
|
||||||
fetchMock.put(
|
fetchMock.put(
|
||||||
"path:/_matrix/client/v3/room_keys/keys",
|
"path:/_matrix/client/v3/room_keys/keys",
|
||||||
(url, request) => {
|
(url, request) => {
|
||||||
const uploadPayload: IKeyBackup = JSON.parse(request.body?.toString() ?? "{}");
|
const uploadPayload: KeyBackup = JSON.parse(request.body?.toString() ?? "{}");
|
||||||
resolve(uploadPayload);
|
resolve(uploadPayload);
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
|
@ -42,10 +42,10 @@ import {
|
|||||||
} from "../../test-utils/test-utils";
|
} from "../../test-utils/test-utils";
|
||||||
import * as testData from "../../test-utils/test-data";
|
import * as testData from "../../test-utils/test-data";
|
||||||
import { KeyBackupInfo, KeyBackupSession } from "../../../src/crypto-api/keybackup";
|
import { KeyBackupInfo, KeyBackupSession } from "../../../src/crypto-api/keybackup";
|
||||||
import { IKeyBackup } from "../../../src/crypto/backup";
|
|
||||||
import { flushPromises } from "../../test-utils/flushPromises";
|
import { flushPromises } from "../../test-utils/flushPromises";
|
||||||
import { defer, IDeferred } from "../../../src/utils";
|
import { defer, IDeferred } from "../../../src/utils";
|
||||||
import { DecryptionFailureCode } from "../../../src/crypto-api";
|
import { DecryptionFailureCode } from "../../../src/crypto-api";
|
||||||
|
import { KeyBackup } from "../../../src/rust-crypto/backup.ts";
|
||||||
|
|
||||||
const ROOM_ID = testData.TEST_ROOM_ID;
|
const ROOM_ID = testData.TEST_ROOM_ID;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ function mockUploadEmitter(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const uploadPayload: IKeyBackup = JSON.parse(request.body?.toString() ?? "{}");
|
const uploadPayload: KeyBackup = JSON.parse(request.body?.toString() ?? "{}");
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const [roomId, value] of Object.entries(uploadPayload.rooms)) {
|
for (const [roomId, value] of Object.entries(uploadPayload.rooms)) {
|
||||||
for (const sessionId of Object.keys(value.sessions)) {
|
for (const sessionId of Object.keys(value.sessions)) {
|
||||||
|
@ -20,7 +20,6 @@ import { StoreHandle } from "@matrix-org/matrix-sdk-crypto-wasm";
|
|||||||
import { RustCrypto } from "./rust-crypto.ts";
|
import { RustCrypto } from "./rust-crypto.ts";
|
||||||
import { IHttpOpts, MatrixHttpApi } from "../http-api/index.ts";
|
import { IHttpOpts, MatrixHttpApi } from "../http-api/index.ts";
|
||||||
import { ServerSideSecretStorage } from "../secret-storage.ts";
|
import { ServerSideSecretStorage } from "../secret-storage.ts";
|
||||||
import { ICryptoCallbacks } from "../crypto/index.ts";
|
|
||||||
import { Logger } from "../logger.ts";
|
import { Logger } from "../logger.ts";
|
||||||
import { CryptoStore, MigrationState } from "../crypto/store/base.ts";
|
import { CryptoStore, MigrationState } from "../crypto/store/base.ts";
|
||||||
import {
|
import {
|
||||||
@ -28,6 +27,7 @@ import {
|
|||||||
migrateLegacyLocalTrustIfNeeded,
|
migrateLegacyLocalTrustIfNeeded,
|
||||||
migrateRoomSettingsFromLegacyCrypto,
|
migrateRoomSettingsFromLegacyCrypto,
|
||||||
} from "./libolm_migration.ts";
|
} from "./libolm_migration.ts";
|
||||||
|
import { CryptoCallbacks } from "../crypto-api/index.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new `RustCrypto` implementation
|
* Create a new `RustCrypto` implementation
|
||||||
@ -55,7 +55,7 @@ export async function initRustCrypto(args: {
|
|||||||
secretStorage: ServerSideSecretStorage;
|
secretStorage: ServerSideSecretStorage;
|
||||||
|
|
||||||
/** Crypto callbacks provided by the application. */
|
/** Crypto callbacks provided by the application. */
|
||||||
cryptoCallbacks: ICryptoCallbacks;
|
cryptoCallbacks: CryptoCallbacks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prefix to use on the indexeddbs created by rust-crypto.
|
* The prefix to use on the indexeddbs created by rust-crypto.
|
||||||
@ -145,7 +145,7 @@ async function initOlmMachine(
|
|||||||
userId: string,
|
userId: string,
|
||||||
deviceId: string,
|
deviceId: string,
|
||||||
secretStorage: ServerSideSecretStorage,
|
secretStorage: ServerSideSecretStorage,
|
||||||
cryptoCallbacks: ICryptoCallbacks,
|
cryptoCallbacks: CryptoCallbacks,
|
||||||
storeHandle: StoreHandle,
|
storeHandle: StoreHandle,
|
||||||
legacyCryptoStore?: CryptoStore,
|
legacyCryptoStore?: CryptoStore,
|
||||||
): Promise<RustCrypto> {
|
): Promise<RustCrypto> {
|
||||||
|
Reference in New Issue
Block a user