mirror of https://github.com/vector-im/riot-web
Clean up some references to internal js-sdk classes (#12363)
* Fix references to `crypto-api/verification` This is supposed to be an internal module; use the front door instead. * `IRecoveryKey` -> `GeneratedSecretStorageKey` `IRecoveryKey` is just a backwards-compatibility alias for `GeneratedSecretStorageKey` * `ISecretStorageKeyInfo` -> `SecretStorage.SecretStorageKeyDescription` Again, same thing * `IPassphraseInfo` -> `SecretStorage.PassphraseInfo` * Remove unused import restriction exceptionspull/28217/head
parent
79f9a130fa
commit
d36c1b39fd
|
@ -76,6 +76,7 @@ module.exports = {
|
|||
group: [
|
||||
"matrix-js-sdk/src/**",
|
||||
"!matrix-js-sdk/src/matrix",
|
||||
"!matrix-js-sdk/src/crypto-api",
|
||||
"!matrix-js-sdk/src/types",
|
||||
"matrix-js-sdk/lib",
|
||||
"matrix-js-sdk/lib/",
|
||||
|
@ -105,13 +106,9 @@ module.exports = {
|
|||
"!matrix-js-sdk/src/extensible_events_v1/PollResponseEvent",
|
||||
"!matrix-js-sdk/src/extensible_events_v1/PollEndEvent",
|
||||
"!matrix-js-sdk/src/extensible_events_v1/InvalidEventError",
|
||||
"!matrix-js-sdk/src/crypto-api",
|
||||
"!matrix-js-sdk/src/crypto-api/verification",
|
||||
"!matrix-js-sdk/src/crypto",
|
||||
"!matrix-js-sdk/src/crypto/algorithms",
|
||||
"!matrix-js-sdk/src/crypto/api",
|
||||
"!matrix-js-sdk/src/crypto/aes",
|
||||
"!matrix-js-sdk/src/crypto/backup",
|
||||
"!matrix-js-sdk/src/crypto/olmlib",
|
||||
"!matrix-js-sdk/src/crypto/crypto",
|
||||
"!matrix-js-sdk/src/crypto/keybackup",
|
||||
|
|
|
@ -17,12 +17,7 @@ limitations under the License.
|
|||
import { type Page, expect, JSHandle } from "@playwright/test";
|
||||
|
||||
import type { CryptoEvent, ICreateRoomOpts, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import type {
|
||||
VerificationRequest,
|
||||
Verifier,
|
||||
EmojiMapping,
|
||||
VerifierEvent,
|
||||
} from "matrix-js-sdk/src/crypto-api/verification";
|
||||
import type { VerificationRequest, Verifier, EmojiMapping, VerifierEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
|
||||
import { Credentials, HomeserverInstance } from "../../plugins/homeserver";
|
||||
import { Client } from "../../pages/client";
|
||||
|
|
|
@ -14,8 +14,13 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { DeviceVerificationStatus, ICryptoCallbacks, MatrixClient, encodeBase64 } from "matrix-js-sdk/src/matrix";
|
||||
import { ISecretStorageKeyInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import {
|
||||
DeviceVerificationStatus,
|
||||
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";
|
||||
|
@ -38,14 +43,14 @@ import InteractiveAuthDialog from "./components/views/dialogs/InteractiveAuthDia
|
|||
// single secret storage operation, as it will clear the cached keys once the
|
||||
// operation ends.
|
||||
let secretStorageKeys: Record<string, Uint8Array> = {};
|
||||
let secretStorageKeyInfo: Record<string, ISecretStorageKeyInfo> = {};
|
||||
let secretStorageKeyInfo: Record<string, SecretStorage.SecretStorageKeyDescription> = {};
|
||||
let secretStorageBeingAccessed = false;
|
||||
|
||||
let nonInteractive = false;
|
||||
|
||||
let dehydrationCache: {
|
||||
key?: Uint8Array;
|
||||
keyInfo?: ISecretStorageKeyInfo;
|
||||
keyInfo?: SecretStorage.SecretStorageKeyDescription;
|
||||
} = {};
|
||||
|
||||
function isCachingAllowed(): boolean {
|
||||
|
@ -80,7 +85,9 @@ async function confirmToDismiss(): Promise<boolean> {
|
|||
return !sure;
|
||||
}
|
||||
|
||||
function makeInputToKey(keyInfo: ISecretStorageKeyInfo): (keyParams: KeyParams) => Promise<Uint8Array> {
|
||||
function makeInputToKey(
|
||||
keyInfo: SecretStorage.SecretStorageKeyDescription,
|
||||
): (keyParams: KeyParams) => Promise<Uint8Array> {
|
||||
return async ({ passphrase, recoveryKey }): Promise<Uint8Array> => {
|
||||
if (passphrase) {
|
||||
return deriveKey(passphrase, keyInfo.passphrase.salt, keyInfo.passphrase.iterations);
|
||||
|
@ -94,11 +101,11 @@ function makeInputToKey(keyInfo: ISecretStorageKeyInfo): (keyParams: KeyParams)
|
|||
async function getSecretStorageKey({
|
||||
keys: keyInfos,
|
||||
}: {
|
||||
keys: Record<string, ISecretStorageKeyInfo>;
|
||||
keys: Record<string, SecretStorage.SecretStorageKeyDescription>;
|
||||
}): Promise<[string, Uint8Array]> {
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
let keyId = await cli.getDefaultSecretStorageKeyId();
|
||||
let keyInfo!: ISecretStorageKeyInfo;
|
||||
let keyInfo!: SecretStorage.SecretStorageKeyDescription;
|
||||
if (keyId) {
|
||||
// use the default SSSS key if set
|
||||
keyInfo = keyInfos[keyId];
|
||||
|
@ -177,7 +184,7 @@ async function getSecretStorageKey({
|
|||
}
|
||||
|
||||
export async function getDehydrationKey(
|
||||
keyInfo: ISecretStorageKeyInfo,
|
||||
keyInfo: SecretStorage.SecretStorageKeyDescription,
|
||||
checkFunc: (data: Uint8Array) => void,
|
||||
): Promise<Uint8Array> {
|
||||
const keyFromCustomisations = SecurityCustomisations.getSecretStorageKey?.();
|
||||
|
@ -226,7 +233,11 @@ export async function getDehydrationKey(
|
|||
return key;
|
||||
}
|
||||
|
||||
function cacheSecretStorageKey(keyId: string, keyInfo: ISecretStorageKeyInfo, key: Uint8Array): void {
|
||||
function cacheSecretStorageKey(
|
||||
keyId: string,
|
||||
keyInfo: SecretStorage.SecretStorageKeyDescription,
|
||||
key: Uint8Array,
|
||||
): void {
|
||||
if (isCachingAllowed()) {
|
||||
secretStorageKeys[keyId] = key;
|
||||
secretStorageKeyInfo[keyId] = keyInfo;
|
||||
|
|
|
@ -19,10 +19,9 @@ import React, { createRef } from "react";
|
|||
import FileSaver from "file-saver";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { AuthDict, CrossSigningKeys, MatrixError, UIAFlow, UIAResponse } from "matrix-js-sdk/src/matrix";
|
||||
import { IRecoveryKey } from "matrix-js-sdk/src/crypto/api";
|
||||
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
|
||||
import classNames from "classnames";
|
||||
import { BackupTrustInfo, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
import { BackupTrustInfo, GeneratedSecretStorageKey, KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||
import { _t, _td } from "../../../../languageHandler";
|
||||
|
@ -122,7 +121,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
|||
hasCancel: true,
|
||||
forceReset: false,
|
||||
};
|
||||
private recoveryKey?: IRecoveryKey;
|
||||
private recoveryKey?: GeneratedSecretStorageKey;
|
||||
private backupKey?: Uint8Array;
|
||||
private recoveryKeyNode = createRef<HTMLElement>();
|
||||
private passphraseField = createRef<Field>();
|
||||
|
|
|
@ -15,10 +15,10 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { ISecretStorageKeyInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup";
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto-api";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { SecretStorageKeyDescription } from "matrix-js-sdk/src/secret-storage";
|
||||
|
||||
import { _t } from "../../../languageHandler";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
@ -29,7 +29,7 @@ import EncryptionPanel from "../../views/right_panel/EncryptionPanel";
|
|||
import AccessibleButton, { ButtonEvent } from "../../views/elements/AccessibleButton";
|
||||
import Spinner from "../../views/elements/Spinner";
|
||||
|
||||
function keyHasPassphrase(keyInfo: ISecretStorageKeyInfo): boolean {
|
||||
function keyHasPassphrase(keyInfo: SecretStorageKeyDescription): boolean {
|
||||
return Boolean(keyInfo.passphrase && keyInfo.passphrase.salt && keyInfo.passphrase.iterations);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React, { ReactNode } from "react";
|
||||
import { GeneratedSas, ShowSasCallbacks, Verifier, VerifierEvent } from "matrix-js-sdk/src/crypto-api/verification";
|
||||
import { GeneratedSas, ShowSasCallbacks, Verifier, VerifierEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
|
|
@ -17,8 +17,8 @@ limitations under the License.
|
|||
import { debounce } from "lodash";
|
||||
import classNames from "classnames";
|
||||
import React, { ChangeEvent, FormEvent } from "react";
|
||||
import { ISecretStorageKeyInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { SecretStorage } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||
import Field from "../../elements/Field";
|
||||
|
@ -42,7 +42,7 @@ const VALIDATION_THROTTLE_MS = 200;
|
|||
export type KeyParams = { passphrase?: string; recoveryKey?: string };
|
||||
|
||||
interface IProps {
|
||||
keyInfo: ISecretStorageKeyInfo;
|
||||
keyInfo: SecretStorage.SecretStorageKeyDescription;
|
||||
checkPrivateKey: (k: KeyParams) => Promise<boolean>;
|
||||
onFinished(result?: false | KeyParams): void;
|
||||
}
|
||||
|
|
|
@ -16,9 +16,8 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React, { ChangeEvent } from "react";
|
||||
import { MatrixClient, MatrixError } 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 { ISecretStorageKeyInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||
|
@ -53,7 +52,7 @@ interface IProps {
|
|||
|
||||
interface IState {
|
||||
backupInfo: IKeyBackupInfo | null;
|
||||
backupKeyStored: Record<string, ISecretStorageKeyInfo> | null;
|
||||
backupKeyStored: Record<string, SecretStorage.SecretStorageKeyDescription> | null;
|
||||
loading: boolean;
|
||||
loadError: boolean | null;
|
||||
restoreError: unknown | null;
|
||||
|
|
|
@ -21,10 +21,12 @@ import {
|
|||
VerificationPhase as Phase,
|
||||
VerificationRequest,
|
||||
VerificationRequestEvent,
|
||||
ShowQrCodeCallbacks,
|
||||
ShowSasCallbacks,
|
||||
VerifierEvent,
|
||||
} from "matrix-js-sdk/src/crypto-api";
|
||||
import { RoomMember, Device, User } from "matrix-js-sdk/src/matrix";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { ShowQrCodeCallbacks, ShowSasCallbacks, VerifierEvent } from "matrix-js-sdk/src/crypto-api/verification";
|
||||
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import VerificationQRCode from "../elements/crypto/VerificationQRCode";
|
||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
import { Device } from "matrix-js-sdk/src/matrix";
|
||||
import { GeneratedSas, EmojiMapping } from "matrix-js-sdk/src/crypto-api/verification";
|
||||
import { GeneratedSas, EmojiMapping } from "matrix-js-sdk/src/crypto-api";
|
||||
import SasEmoji from "@matrix-org/spec/sas-emoji.json";
|
||||
|
||||
import { _t, getNormalizedLanguageKeys, getUserLanguage } from "../../../languageHandler";
|
||||
|
|
|
@ -17,10 +17,9 @@ limitations under the License.
|
|||
import EventEmitter from "events";
|
||||
import { VerificationPhase, VerificationRequest, VerificationRequestEvent } from "matrix-js-sdk/src/crypto-api";
|
||||
import { IKeyBackupInfo } from "matrix-js-sdk/src/crypto/keybackup";
|
||||
import { ISecretStorageKeyInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
|
||||
import { Device } from "matrix-js-sdk/src/matrix";
|
||||
import { Device, SecretStorage } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
import { AccessCancelledError, accessSecretStorage } from "../SecurityManager";
|
||||
|
@ -48,7 +47,7 @@ export class SetupEncryptionStore extends EventEmitter {
|
|||
// ID of the key that the secrets we want are encrypted with
|
||||
public keyId: string | null = null;
|
||||
// Descriptor of the key that the secrets we want are encrypted with
|
||||
public keyInfo: ISecretStorageKeyInfo | null = null;
|
||||
public keyInfo: SecretStorage.SecretStorageKeyDescription | null = null;
|
||||
public hasDevicesToVerifyAgainst?: boolean;
|
||||
|
||||
public static sharedInstance(): SetupEncryptionStore {
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { EmojiMapping } from "matrix-js-sdk/src/crypto-api/verification";
|
||||
import { EmojiMapping } from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import { tEmoji } from "../../../src/components/views/verification/VerificationShowSas";
|
||||
|
||||
|
|
|
@ -15,10 +15,9 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React, { ComponentProps } from "react";
|
||||
import { IPassphraseInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import { SecretStorage, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { Mocked } from "jest-mock";
|
||||
|
||||
import { getMockClientWithEventEmitter, mockPlatformPeg } from "../../../test-utils";
|
||||
|
@ -117,7 +116,7 @@ describe("AccessSecretStorageDialog", () => {
|
|||
passphrase: {
|
||||
// this type is weird in js-sdk
|
||||
// cast 'm.pbkdf2' to itself
|
||||
algorithm: "m.pbkdf2" as IPassphraseInfo["algorithm"],
|
||||
algorithm: "m.pbkdf2" as SecretStorage.PassphraseInfo["algorithm"],
|
||||
iterations: 2,
|
||||
salt: "nonempty",
|
||||
},
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
Verifier,
|
||||
VerifierEvent,
|
||||
VerifierEventHandlerMap,
|
||||
} from "matrix-js-sdk/src/crypto-api/verification";
|
||||
} from "matrix-js-sdk/src/crypto-api";
|
||||
import { TypedEventEmitter } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import IncomingSasDialog from "../../../../src/components/views/dialogs/IncomingSasDialog";
|
||||
|
|
|
@ -27,7 +27,7 @@ import {
|
|||
Verifier,
|
||||
VerifierEvent,
|
||||
VerifierEventHandlerMap,
|
||||
} from "matrix-js-sdk/src/crypto-api/verification";
|
||||
} from "matrix-js-sdk/src/crypto-api";
|
||||
|
||||
import VerificationPanel from "../../../../src/components/views/right_panel/VerificationPanel";
|
||||
import { flushPromises, stubClient } from "../../../test-utils";
|
||||
|
|
Loading…
Reference in New Issue