1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Remove deprecated methods and fields (#4201)

* Remove legacy `threepidCreds` field

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove deprecated shouldUpgradeToVersion

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove `added` legacy login request field

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove deprecated re-exports

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove `home_server` field

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update imports in tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2024-05-15 16:23:04 +01:00
committed by GitHub
parent 51fa1866a9
commit f03dd7b7bc
18 changed files with 69 additions and 135 deletions

View File

@@ -23,12 +23,12 @@ import HttpBackend from "matrix-mock-request";
import * as olmlib from "../../../src/crypto/olmlib"; import * as olmlib from "../../../src/crypto/olmlib";
import { MatrixError } from "../../../src/http-api"; import { MatrixError } from "../../../src/http-api";
import { logger } from "../../../src/logger"; import { logger } from "../../../src/logger";
import { ICrossSigningKey, ICreateClientOpts, ISignedKey, MatrixClient } from "../../../src/client"; import { ICreateClientOpts, ISignedKey, MatrixClient } from "../../../src/client";
import { CryptoEvent } from "../../../src/crypto"; import { CryptoEvent } from "../../../src/crypto";
import { IDevice } from "../../../src/crypto/deviceinfo"; import { IDevice } from "../../../src/crypto/deviceinfo";
import { TestClient } from "../../TestClient"; import { TestClient } from "../../TestClient";
import { resetCrossSigningKeys } from "./crypto-utils"; import { resetCrossSigningKeys } from "./crypto-utils";
import { BootstrapCrossSigningOpts } from "../../../src/crypto-api"; import { BootstrapCrossSigningOpts, CrossSigningKeyInfo } from "../../../src/crypto-api";
const PUSH_RULES_RESPONSE: Response = { const PUSH_RULES_RESPONSE: Response = {
method: "GET", method: "GET",
@@ -377,7 +377,7 @@ describe("Cross Signing", function () {
const bobSigning = new global.Olm.PkSigning(); const bobSigning = new global.Olm.PkSigning();
const bobPrivkey = bobSigning.generate_seed(); const bobPrivkey = bobSigning.generate_seed();
const bobPubkey = bobSigning.init_with_seed(bobPrivkey); const bobPubkey = bobSigning.init_with_seed(bobPrivkey);
const bobSSK: ICrossSigningKey = { const bobSSK: CrossSigningKeyInfo = {
user_id: "@bob:example.com", user_id: "@bob:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {
@@ -515,7 +515,7 @@ describe("Cross Signing", function () {
}; };
olmlib.pkSign(bobDevice, selfSigningKey as unknown as PkSigning, "@bob:example.com", ""); olmlib.pkSign(bobDevice, selfSigningKey as unknown as PkSigning, "@bob:example.com", "");
const bobMaster: ICrossSigningKey = { const bobMaster: CrossSigningKeyInfo = {
user_id: "@bob:example.com", user_id: "@bob:example.com",
usage: ["master"], usage: ["master"],
keys: { keys: {
@@ -630,7 +630,7 @@ describe("Cross Signing", function () {
const bobSigning = new global.Olm.PkSigning(); const bobSigning = new global.Olm.PkSigning();
const bobPrivkey = bobSigning.generate_seed(); const bobPrivkey = bobSigning.generate_seed();
const bobPubkey = bobSigning.init_with_seed(bobPrivkey); const bobPubkey = bobSigning.init_with_seed(bobPrivkey);
const bobSSK: ICrossSigningKey = { const bobSSK: CrossSigningKeyInfo = {
user_id: "@bob:example.com", user_id: "@bob:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {
@@ -696,7 +696,7 @@ describe("Cross Signing", function () {
const bobSigning = new global.Olm.PkSigning(); const bobSigning = new global.Olm.PkSigning();
const bobPrivkey = bobSigning.generate_seed(); const bobPrivkey = bobSigning.generate_seed();
const bobPubkey = bobSigning.init_with_seed(bobPrivkey); const bobPubkey = bobSigning.init_with_seed(bobPrivkey);
const bobSSK: ICrossSigningKey = { const bobSSK: CrossSigningKeyInfo = {
user_id: "@bob:example.com", user_id: "@bob:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {
@@ -763,7 +763,7 @@ describe("Cross Signing", function () {
const bobSigning2 = new global.Olm.PkSigning(); const bobSigning2 = new global.Olm.PkSigning();
const bobPrivkey2 = bobSigning2.generate_seed(); const bobPrivkey2 = bobSigning2.generate_seed();
const bobPubkey2 = bobSigning2.init_with_seed(bobPrivkey2); const bobPubkey2 = bobSigning2.init_with_seed(bobPrivkey2);
const bobSSK2: ICrossSigningKey = { const bobSSK2: CrossSigningKeyInfo = {
user_id: "@bob:example.com", user_id: "@bob:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {
@@ -913,7 +913,7 @@ describe("Cross Signing", function () {
const aliceSigning = new global.Olm.PkSigning(); const aliceSigning = new global.Olm.PkSigning();
const alicePrivkey = aliceSigning.generate_seed(); const alicePrivkey = aliceSigning.generate_seed();
const alicePubkey = aliceSigning.init_with_seed(alicePrivkey); const alicePubkey = aliceSigning.init_with_seed(alicePrivkey);
const aliceSSK: ICrossSigningKey = { const aliceSSK: CrossSigningKeyInfo = {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {
@@ -988,7 +988,7 @@ describe("Cross Signing", function () {
const aliceSigning = new global.Olm.PkSigning(); const aliceSigning = new global.Olm.PkSigning();
const alicePrivkey = aliceSigning.generate_seed(); const alicePrivkey = aliceSigning.generate_seed();
const alicePubkey = aliceSigning.init_with_seed(alicePrivkey); const alicePubkey = aliceSigning.init_with_seed(alicePrivkey);
const aliceSSK: ICrossSigningKey = { const aliceSSK: CrossSigningKeyInfo = {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {
@@ -1048,7 +1048,7 @@ describe("Cross Signing", function () {
const aliceSigning = new global.Olm.PkSigning(); const aliceSigning = new global.Olm.PkSigning();
const alicePrivkey = aliceSigning.generate_seed(); const alicePrivkey = aliceSigning.generate_seed();
const alicePubkey = aliceSigning.init_with_seed(alicePrivkey); const alicePubkey = aliceSigning.init_with_seed(alicePrivkey);
const aliceSSK: ICrossSigningKey = { const aliceSSK: CrossSigningKeyInfo = {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["self_signing"], usage: ["self_signing"],
keys: { keys: {

View File

@@ -23,12 +23,13 @@ import { makeTestClients } from "./verification/util";
import { encryptAES } from "../../../src/crypto/aes"; import { encryptAES } from "../../../src/crypto/aes";
import { createSecretStorageKey, resetCrossSigningKeys } from "./crypto-utils"; import { createSecretStorageKey, resetCrossSigningKeys } from "./crypto-utils";
import { logger } from "../../../src/logger"; import { logger } from "../../../src/logger";
import { ClientEvent, ICreateClientOpts, ICrossSigningKey, MatrixClient } from "../../../src/client"; import { ClientEvent, ICreateClientOpts, MatrixClient } from "../../../src/client";
import { DeviceInfo } from "../../../src/crypto/deviceinfo"; import { DeviceInfo } from "../../../src/crypto/deviceinfo";
import { ISignatures } from "../../../src/@types/signed"; import { ISignatures } from "../../../src/@types/signed";
import { ICurve25519AuthData } from "../../../src/crypto/keybackup"; import { ICurve25519AuthData } from "../../../src/crypto/keybackup";
import { SecretStorageKeyDescription, SECRET_STORAGE_ALGORITHM_V1_AES } from "../../../src/secret-storage"; import { SecretStorageKeyDescription, SECRET_STORAGE_ALGORITHM_V1_AES } from "../../../src/secret-storage";
import { decodeBase64 } from "../../../src/base64"; import { decodeBase64 } from "../../../src/base64";
import { CrossSigningKeyInfo } from "../../../src/crypto-api";
async function makeTestClient( async function makeTestClient(
userInfo: { userId: string; deviceId: string }, userInfo: { userId: string; deviceId: string },
@@ -475,7 +476,7 @@ describe("Secrets", function () {
[`ed25519:${XSPubKey}`]: XSPubKey, [`ed25519:${XSPubKey}`]: XSPubKey,
}, },
}, },
self_signing: sign<ICrossSigningKey>( self_signing: sign<CrossSigningKeyInfo>(
{ {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["self_signing"], usage: ["self_signing"],
@@ -486,7 +487,7 @@ describe("Secrets", function () {
XSK, XSK,
"@alice:example.com", "@alice:example.com",
), ),
user_signing: sign<ICrossSigningKey>( user_signing: sign<CrossSigningKeyInfo>(
{ {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["user_signing"], usage: ["user_signing"],
@@ -631,7 +632,7 @@ describe("Secrets", function () {
[`ed25519:${XSPubKey}`]: XSPubKey, [`ed25519:${XSPubKey}`]: XSPubKey,
}, },
}, },
self_signing: sign<ICrossSigningKey>( self_signing: sign<CrossSigningKeyInfo>(
{ {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["self_signing"], usage: ["self_signing"],
@@ -642,7 +643,7 @@ describe("Secrets", function () {
XSK, XSK,
"@alice:example.com", "@alice:example.com",
), ),
user_signing: sign<ICrossSigningKey>( user_signing: sign<CrossSigningKeyInfo>(
{ {
user_id: "@alice:example.com", user_id: "@alice:example.com",
usage: ["user_signing"], usage: ["user_signing"],

View File

@@ -16,11 +16,12 @@ limitations under the License.
import { IContent, MatrixClient, MatrixEvent } from "../../../src"; import { IContent, MatrixClient, MatrixEvent } from "../../../src";
import { Room } from "../../../src/models/room"; import { Room } from "../../../src/models/room";
import { IEncryptedFile, RelationType, UNSTABLE_MSC3089_BRANCH } from "../../../src/@types/event"; import { RelationType, UNSTABLE_MSC3089_BRANCH } from "../../../src/@types/event";
import { EventTimelineSet } from "../../../src/models/event-timeline-set"; import { EventTimelineSet } from "../../../src/models/event-timeline-set";
import { EventTimeline } from "../../../src/models/event-timeline"; import { EventTimeline } from "../../../src/models/event-timeline";
import { MSC3089Branch } from "../../../src/models/MSC3089Branch"; import { MSC3089Branch } from "../../../src/models/MSC3089Branch";
import { MSC3089TreeSpace } from "../../../src/models/MSC3089TreeSpace"; import { MSC3089TreeSpace } from "../../../src/models/MSC3089TreeSpace";
import { EncryptedFile } from "../../../src/@types/media";
describe("MSC3089Branch", () => { describe("MSC3089Branch", () => {
let client: MatrixClient; let client: MatrixClient;
@@ -254,7 +255,7 @@ describe("MSC3089Branch", () => {
it("should create new versions of itself", async () => { it("should create new versions of itself", async () => {
const canaryName = "canary"; const canaryName = "canary";
const canaryContents = "contents go here"; const canaryContents = "contents go here";
const canaryFile = {} as IEncryptedFile; const canaryFile = {} as EncryptedFile;
const canaryAddl = { canary: true }; const canaryAddl = { canary: true };
indexEvent.getContent = () => ({ active: true, retained: true }); indexEvent.getContent = () => ({ active: true, retained: true });
const stateKeyOrder = [fileEventId2, fileEventId]; const stateKeyOrder = [fileEventId2, fileEventId];
@@ -287,23 +288,21 @@ describe("MSC3089Branch", () => {
const createFn = jest const createFn = jest
.fn() .fn()
.mockImplementation( .mockImplementation((name: string, contents: ArrayBuffer, info: Partial<EncryptedFile>, addl: IContent) => {
(name: string, contents: ArrayBuffer, info: Partial<IEncryptedFile>, addl: IContent) => { expect(name).toEqual(canaryName);
expect(name).toEqual(canaryName); expect(contents).toBe(canaryContents);
expect(contents).toBe(canaryContents); expect(info).toBe(canaryFile);
expect(info).toBe(canaryFile); expect(addl).toMatchObject({
expect(addl).toMatchObject({ ...canaryAddl,
...canaryAddl, "m.new_content": true,
"m.new_content": true, "m.relates_to": {
"m.relates_to": { rel_type: RelationType.Replace,
rel_type: RelationType.Replace, event_id: fileEventId,
event_id: fileEventId, },
}, });
});
return Promise.resolve({ event_id: fileEventId2 }); return Promise.resolve({ event_id: fileEventId2 });
}, });
);
directory.createFile = createFn; directory.createFile = createFn;
await branch.createNewVersion(canaryName, canaryContents, canaryFile, canaryAddl); await branch.createNewVersion(canaryName, canaryContents, canaryFile, canaryAddl);

View File

@@ -147,11 +147,6 @@ export interface LoginRequest {
* The login type being used. * The login type being used.
*/ */
type: "m.login.password" | "m.login.token" | string; type: "m.login.password" | "m.login.token" | string;
/**
* Third-party identifier for the user.
* @deprecated in favour of `identifier`.
*/
address?: string;
/** /**
* ID of the client device. * ID of the client device.
* If this does not correspond to a known client device, a new device will be created. * If this does not correspond to a known client device, a new device will be created.

View File

@@ -56,7 +56,6 @@ import {
SDPStreamMetadataKey, SDPStreamMetadataKey,
} from "../webrtc/callEventTypes"; } from "../webrtc/callEventTypes";
import { EncryptionKeysEventContent, ICallNotifyContent } from "../matrixrtc/types"; import { EncryptionKeysEventContent, ICallNotifyContent } from "../matrixrtc/types";
import { EncryptedFile } from "./media";
import { M_POLL_END, M_POLL_START, PollEndEventContent, PollStartEventContent } from "./polls"; import { M_POLL_END, M_POLL_START, PollEndEventContent, PollStartEventContent } from "./polls";
export enum EventType { export enum EventType {
@@ -305,11 +304,6 @@ export const UNSIGNED_THREAD_ID_FIELD = new UnstableValue("thread_id", "org.matr
*/ */
export const UNSIGNED_MEMBERSHIP_FIELD = new UnstableValue("membership", "io.element.msc4115.membership"); export const UNSIGNED_MEMBERSHIP_FIELD = new UnstableValue("membership", "io.element.msc4115.membership");
/**
* @deprecated in favour of {@link EncryptedFile}
*/
export type IEncryptedFile = EncryptedFile;
/** /**
* Mapped type from event type to content type for all specified non-state room events. * Mapped type from event type to content type for all specified non-state room events.
*/ */

View File

@@ -107,10 +107,4 @@ export interface RegisterResponse {
* Omitted if the inhibit_login option is true. * Omitted if the inhibit_login option is true.
*/ */
refresh_token?: string; refresh_token?: string;
/**
* The server_name of the homeserver on which the account has been registered.
*
* @deprecated Clients should extract the server_name from user_id (by splitting at the first colon) if they require it.
*/
home_server?: string;
} }

View File

@@ -560,16 +560,13 @@ export interface Capabilities {
"org.matrix.msc3882.get_login_token"?: IGetLoginTokenCapability; "org.matrix.msc3882.get_login_token"?: IGetLoginTokenCapability;
} }
/** @deprecated prefer {@link CrossSigningKeyInfo}. */
export type ICrossSigningKey = CrossSigningKeyInfo;
enum CrossSigningKeyType { enum CrossSigningKeyType {
MasterKey = "master_key", MasterKey = "master_key",
SelfSigningKey = "self_signing_key", SelfSigningKey = "self_signing_key",
UserSigningKey = "user_signing_key", UserSigningKey = "user_signing_key",
} }
export type CrossSigningKeys = Record<CrossSigningKeyType, ICrossSigningKey>; export type CrossSigningKeys = Record<CrossSigningKeyType, CrossSigningKeyInfo>;
export type SendToDeviceContentMap = Map<string, Map<string, Record<string, any>>>; export type SendToDeviceContentMap = Map<string, Map<string, Record<string, any>>>;
@@ -581,7 +578,7 @@ export interface ISignedKey {
device_id: string; device_id: string;
} }
export type KeySignatures = Record<string, Record<string, ICrossSigningKey | ISignedKey>>; export type KeySignatures = Record<string, Record<string, CrossSigningKeyInfo | ISignedKey>>;
export interface IUploadKeySignaturesResponse { export interface IUploadKeySignaturesResponse {
failures: Record< failures: Record<
string, string,

View File

@@ -24,13 +24,13 @@ import { logger } from "../logger";
import { IndexedDBCryptoStore } from "../crypto/store/indexeddb-crypto-store"; import { IndexedDBCryptoStore } from "../crypto/store/indexeddb-crypto-store";
import { decryptAES, encryptAES } from "./aes"; import { decryptAES, encryptAES } from "./aes";
import { DeviceInfo } from "./deviceinfo"; import { DeviceInfo } from "./deviceinfo";
import { ICrossSigningKey, ISignedKey, MatrixClient } from "../client"; import { ISignedKey, MatrixClient } from "../client";
import { OlmDevice } from "./OlmDevice"; import { OlmDevice } from "./OlmDevice";
import { ICryptoCallbacks } from "."; import { ICryptoCallbacks } from ".";
import { ISignatures } from "../@types/signed"; import { ISignatures } from "../@types/signed";
import { CryptoStore, SecretStorePrivateKeys } from "./store/base"; import { CryptoStore, SecretStorePrivateKeys } from "./store/base";
import { ServerSideSecretStorage, SecretStorageKeyDescription } from "../secret-storage"; import { ServerSideSecretStorage, SecretStorageKeyDescription } from "../secret-storage";
import { DeviceVerificationStatus, UserVerificationStatus as UserTrustLevel } from "../crypto-api"; import { CrossSigningKeyInfo, DeviceVerificationStatus, UserVerificationStatus as UserTrustLevel } from "../crypto-api";
import { decodeBase64, encodeBase64 } from "../base64"; import { decodeBase64, encodeBase64 } from "../base64";
// backwards-compatibility re-exports // backwards-compatibility re-exports
@@ -38,7 +38,7 @@ export { UserTrustLevel };
const KEY_REQUEST_TIMEOUT_MS = 1000 * 60; const KEY_REQUEST_TIMEOUT_MS = 1000 * 60;
function publicKeyFromKeyInfo(keyInfo: ICrossSigningKey): string { function publicKeyFromKeyInfo(keyInfo: CrossSigningKeyInfo): string {
// `keys` is an object with { [`ed25519:${pubKey}`]: pubKey } // `keys` is an object with { [`ed25519:${pubKey}`]: pubKey }
// We assume only a single key, and we want the bare form without type // We assume only a single key, and we want the bare form without type
// prefix, so we select the values. // prefix, so we select the values.
@@ -51,13 +51,13 @@ export interface ICacheCallbacks {
} }
export interface ICrossSigningInfo { export interface ICrossSigningInfo {
keys: Record<string, ICrossSigningKey>; keys: Record<string, CrossSigningKeyInfo>;
firstUse: boolean; firstUse: boolean;
crossSigningVerifiedBefore: boolean; crossSigningVerifiedBefore: boolean;
} }
export class CrossSigningInfo { export class CrossSigningInfo {
public keys: Record<string, ICrossSigningKey> = {}; public keys: Record<string, CrossSigningKeyInfo> = {};
public firstUse = true; public firstUse = true;
// This tracks whether we've ever verified this user with any identity. // This tracks whether we've ever verified this user with any identity.
// When you verify a user, any devices online at the time that receive // When you verify a user, any devices online at the time that receive
@@ -296,7 +296,7 @@ export class CrossSigningInfo {
} }
const privateKeys: Record<string, Uint8Array> = {}; const privateKeys: Record<string, Uint8Array> = {};
const keys: Record<string, ICrossSigningKey> = {}; const keys: Record<string, CrossSigningKeyInfo> = {};
let masterSigning: PkSigning | undefined; let masterSigning: PkSigning | undefined;
let masterPub: string | undefined; let masterPub: string | undefined;
@@ -368,8 +368,8 @@ export class CrossSigningInfo {
this.keys = {}; this.keys = {};
} }
public setKeys(keys: Record<string, ICrossSigningKey>): void { public setKeys(keys: Record<string, CrossSigningKeyInfo>): void {
const signingKeys: Record<string, ICrossSigningKey> = {}; const signingKeys: Record<string, CrossSigningKeyInfo> = {};
if (keys.master) { if (keys.master) {
if (keys.master.user_id !== this.userId) { if (keys.master.user_id !== this.userId) {
const error = "Mismatched user ID " + keys.master.user_id + " in master key from " + this.userId; const error = "Mismatched user ID " + keys.master.user_id + " in master key from " + this.userId;
@@ -457,7 +457,7 @@ export class CrossSigningInfo {
} }
} }
public async signUser(key: CrossSigningInfo): Promise<ICrossSigningKey | undefined> { public async signUser(key: CrossSigningInfo): Promise<CrossSigningKeyInfo | undefined> {
if (!this.keys.user_signing) { if (!this.keys.user_signing) {
logger.info("No user signing key: not signing user"); logger.info("No user signing key: not signing user");
return; return;

View File

@@ -20,22 +20,15 @@ import { createCryptoStoreCacheCallbacks, ICacheCallbacks } from "./CrossSigning
import { IndexedDBCryptoStore } from "./store/indexeddb-crypto-store"; import { IndexedDBCryptoStore } from "./store/indexeddb-crypto-store";
import { Method, ClientPrefix } from "../http-api"; import { Method, ClientPrefix } from "../http-api";
import { Crypto, ICryptoCallbacks } from "./index"; import { Crypto, ICryptoCallbacks } from "./index";
import { import { ClientEvent, ClientEventHandlerMap, CrossSigningKeys, ISignedKey, KeySignatures } from "../client";
ClientEvent,
ClientEventHandlerMap,
CrossSigningKeys,
ICrossSigningKey,
ISignedKey,
KeySignatures,
} from "../client";
import { IKeyBackupInfo } from "./keybackup"; import { IKeyBackupInfo } from "./keybackup";
import { TypedEventEmitter } from "../models/typed-event-emitter"; import { TypedEventEmitter } from "../models/typed-event-emitter";
import { AccountDataClient, SecretStorageKeyDescription } from "../secret-storage"; import { AccountDataClient, SecretStorageKeyDescription } from "../secret-storage";
import { BootstrapCrossSigningOpts } from "../crypto-api"; import { BootstrapCrossSigningOpts, CrossSigningKeyInfo } from "../crypto-api";
interface ICrossSigningKeys { interface ICrossSigningKeys {
authUpload: BootstrapCrossSigningOpts["authUploadDeviceSigningKeys"]; authUpload: BootstrapCrossSigningOpts["authUploadDeviceSigningKeys"];
keys: Record<"master" | "self_signing" | "user_signing", ICrossSigningKey>; keys: Record<"master" | "self_signing" | "user_signing", CrossSigningKeyInfo>;
} }
/** /**

View File

@@ -56,14 +56,7 @@ import { Room, RoomEvent } from "../models/room";
import { RoomMember, RoomMemberEvent } from "../models/room-member"; import { RoomMember, RoomMemberEvent } from "../models/room-member";
import { EventStatus, IContent, IEvent, MatrixEvent, MatrixEventEvent } from "../models/event"; import { EventStatus, IContent, IEvent, MatrixEvent, MatrixEventEvent } from "../models/event";
import { ToDeviceBatch } from "../models/ToDeviceMessage"; import { ToDeviceBatch } from "../models/ToDeviceMessage";
import { import { ClientEvent, IKeysUploadResponse, ISignedKey, IUploadKeySignaturesResponse, MatrixClient } from "../client";
ClientEvent,
ICrossSigningKey,
IKeysUploadResponse,
ISignedKey,
IUploadKeySignaturesResponse,
MatrixClient,
} from "../client";
import { IRoomEncryption, RoomList } from "./RoomList"; import { IRoomEncryption, RoomList } from "./RoomList";
import { IKeyBackupInfo } from "./keybackup"; import { IKeyBackupInfo } from "./keybackup";
import { ISyncStateData } from "../sync"; import { ISyncStateData } from "../sync";
@@ -89,6 +82,7 @@ import { ISecretRequest } from "./SecretSharing";
import { import {
BackupTrustInfo, BackupTrustInfo,
BootstrapCrossSigningOpts, BootstrapCrossSigningOpts,
CrossSigningKeyInfo,
CrossSigningStatus, CrossSigningStatus,
DecryptionFailureCode, DecryptionFailureCode,
DeviceVerificationStatus, DeviceVerificationStatus,
@@ -1527,7 +1521,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
*/ */
private async checkForValidDeviceSignature( private async checkForValidDeviceSignature(
userId: string, userId: string,
key: ICrossSigningKey, key: CrossSigningKeyInfo,
devices: Record<string, IDevice>, devices: Record<string, IDevice>,
): Promise<string[]> { ): Promise<string[]> {
const deviceIds: string[] = []; const deviceIds: string[] = [];
@@ -1904,7 +1898,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
* *
* @param keys - The new trusted set of keys * @param keys - The new trusted set of keys
*/ */
private async storeTrustedSelfKeys(keys: Record<string, ICrossSigningKey> | null): Promise<void> { private async storeTrustedSelfKeys(keys: Record<string, CrossSigningKeyInfo> | null): Promise<void> {
if (keys) { if (keys) {
this.crossSigningInfo.setKeys(keys); this.crossSigningInfo.setKeys(keys);
} else { } else {
@@ -2390,7 +2384,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
blocked: boolean | null = null, blocked: boolean | null = null,
known: boolean | null = null, known: boolean | null = null,
keys?: Record<string, string>, keys?: Record<string, string>,
): Promise<DeviceInfo | CrossSigningInfo | ICrossSigningKey | undefined> { ): Promise<DeviceInfo | CrossSigningInfo | CrossSigningKeyInfo | undefined> {
// Check if the 'device' is actually a cross signing key // Check if the 'device' is actually a cross signing key
// The js-sdk's verification treats cross-signing keys as devices // The js-sdk's verification treats cross-signing keys as devices
// and so uses this method to mark them verified. // and so uses this method to mark them verified.

View File

@@ -16,7 +16,6 @@ limitations under the License.
import { IRoomKeyRequestBody, IRoomKeyRequestRecipient } from "../index"; import { IRoomKeyRequestBody, IRoomKeyRequestRecipient } from "../index";
import { RoomKeyRequestState } from "../OutgoingRoomKeyRequestManager"; import { RoomKeyRequestState } from "../OutgoingRoomKeyRequestManager";
import { ICrossSigningKey } from "../../client";
import { IOlmDevice } from "../algorithms/megolm"; import { IOlmDevice } from "../algorithms/megolm";
import { TrackingStatus } from "../DeviceList"; import { TrackingStatus } from "../DeviceList";
import { IRoomEncryption } from "../RoomList"; import { IRoomEncryption } from "../RoomList";
@@ -27,6 +26,7 @@ import { InboundGroupSessionData } from "../OlmDevice";
import { MatrixEvent } from "../../models/event"; import { MatrixEvent } from "../../models/event";
import { DehydrationManager } from "../dehydration"; import { DehydrationManager } from "../dehydration";
import { IEncryptedPayload } from "../aes"; import { IEncryptedPayload } from "../aes";
import { CrossSigningKeyInfo } from "../../crypto-api";
/** /**
* Internal module. Definitions for storage for the crypto module * Internal module. Definitions for storage for the crypto module
@@ -100,13 +100,13 @@ export interface CryptoStore {
// Olm Account // Olm Account
getAccount(txn: unknown, func: (accountPickle: string | null) => void): void; getAccount(txn: unknown, func: (accountPickle: string | null) => void): void;
storeAccount(txn: unknown, accountPickle: string): void; storeAccount(txn: unknown, accountPickle: string): void;
getCrossSigningKeys(txn: unknown, func: (keys: Record<string, ICrossSigningKey> | null) => void): void; getCrossSigningKeys(txn: unknown, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void): void;
getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>( getSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(
txn: unknown, txn: unknown,
func: (key: SecretStorePrivateKeys[K] | null) => void, func: (key: SecretStorePrivateKeys[K] | null) => void,
type: K, type: K,
): void; ): void;
storeCrossSigningKeys(txn: unknown, keys: Record<string, ICrossSigningKey>): void; storeCrossSigningKeys(txn: unknown, keys: Record<string, CrossSigningKeyInfo>): void;
storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>( storeSecretStorePrivateKey<K extends keyof SecretStorePrivateKeys>(
txn: unknown, txn: unknown,
type: K, type: K,

View File

@@ -33,11 +33,11 @@ import {
ACCOUNT_OBJECT_KEY_MIGRATION_STATE, ACCOUNT_OBJECT_KEY_MIGRATION_STATE,
} from "./base"; } from "./base";
import { IRoomKeyRequestBody, IRoomKeyRequestRecipient } from "../index"; import { IRoomKeyRequestBody, IRoomKeyRequestRecipient } from "../index";
import { ICrossSigningKey } from "../../client";
import { IOlmDevice } from "../algorithms/megolm"; import { IOlmDevice } from "../algorithms/megolm";
import { IRoomEncryption } from "../RoomList"; import { IRoomEncryption } from "../RoomList";
import { InboundGroupSessionData } from "../OlmDevice"; import { InboundGroupSessionData } from "../OlmDevice";
import { IndexedDBCryptoStore } from "./indexeddb-crypto-store"; import { IndexedDBCryptoStore } from "./indexeddb-crypto-store";
import { CrossSigningKeyInfo } from "../../crypto-api";
const PROFILE_TRANSACTIONS = false; const PROFILE_TRANSACTIONS = false;
@@ -418,7 +418,7 @@ export class Backend implements CryptoStore {
public getCrossSigningKeys( public getCrossSigningKeys(
txn: IDBTransaction, txn: IDBTransaction,
func: (keys: Record<string, ICrossSigningKey> | null) => void, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void,
): void { ): void {
const objectStore = txn.objectStore("account"); const objectStore = txn.objectStore("account");
const getReq = objectStore.get("crossSigningKeys"); const getReq = objectStore.get("crossSigningKeys");
@@ -447,7 +447,7 @@ export class Backend implements CryptoStore {
}; };
} }
public storeCrossSigningKeys(txn: IDBTransaction, keys: Record<string, ICrossSigningKey>): void { public storeCrossSigningKeys(txn: IDBTransaction, keys: Record<string, CrossSigningKeyInfo>): void {
const objectStore = txn.objectStore("account"); const objectStore = txn.objectStore("account");
objectStore.put(keys, "crossSigningKeys"); objectStore.put(keys, "crossSigningKeys");
} }

View File

@@ -36,10 +36,10 @@ import {
ACCOUNT_OBJECT_KEY_MIGRATION_STATE, ACCOUNT_OBJECT_KEY_MIGRATION_STATE,
} from "./base"; } from "./base";
import { IRoomKeyRequestBody } from "../index"; import { IRoomKeyRequestBody } from "../index";
import { ICrossSigningKey } from "../../client";
import { IOlmDevice } from "../algorithms/megolm"; import { IOlmDevice } from "../algorithms/megolm";
import { IRoomEncryption } from "../RoomList"; import { IRoomEncryption } from "../RoomList";
import { InboundGroupSessionData } from "../OlmDevice"; import { InboundGroupSessionData } from "../OlmDevice";
import { CrossSigningKeyInfo } from "../../crypto-api";
/* /*
* Internal module. indexeddb storage for e2e. * Internal module. indexeddb storage for e2e.
@@ -420,7 +420,7 @@ export class IndexedDBCryptoStore implements CryptoStore {
*/ */
public getCrossSigningKeys( public getCrossSigningKeys(
txn: IDBTransaction, txn: IDBTransaction,
func: (keys: Record<string, ICrossSigningKey> | null) => void, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void,
): void { ): void {
this.backend!.getCrossSigningKeys(txn, func); this.backend!.getCrossSigningKeys(txn, func);
} }
@@ -444,7 +444,7 @@ export class IndexedDBCryptoStore implements CryptoStore {
* @param txn - An active transaction. See doTxn(). * @param txn - An active transaction. See doTxn().
* @param keys - keys object as getCrossSigningKeys() * @param keys - keys object as getCrossSigningKeys()
*/ */
public storeCrossSigningKeys(txn: IDBTransaction, keys: Record<string, ICrossSigningKey>): void { public storeCrossSigningKeys(txn: IDBTransaction, keys: Record<string, CrossSigningKeyInfo>): void {
this.backend!.storeCrossSigningKeys(txn, keys); this.backend!.storeCrossSigningKeys(txn, keys);
} }

View File

@@ -31,9 +31,9 @@ import {
} from "./base"; } from "./base";
import { IOlmDevice } from "../algorithms/megolm"; import { IOlmDevice } from "../algorithms/megolm";
import { IRoomEncryption } from "../RoomList"; import { IRoomEncryption } from "../RoomList";
import { ICrossSigningKey } from "../../client";
import { InboundGroupSessionData } from "../OlmDevice"; import { InboundGroupSessionData } from "../OlmDevice";
import { safeSet } from "../../utils"; import { safeSet } from "../../utils";
import { CrossSigningKeyInfo } from "../../crypto-api";
/** /**
* Internal module. Partial localStorage backed storage for e2e. * Internal module. Partial localStorage backed storage for e2e.
@@ -531,8 +531,8 @@ export class LocalStorageCryptoStore extends MemoryCryptoStore implements Crypto
setJsonItem(this.store, KEY_END_TO_END_ACCOUNT, accountPickle); setJsonItem(this.store, KEY_END_TO_END_ACCOUNT, accountPickle);
} }
public getCrossSigningKeys(txn: unknown, func: (keys: Record<string, ICrossSigningKey> | null) => void): void { public getCrossSigningKeys(txn: unknown, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void): void {
const keys = getJsonItem<Record<string, ICrossSigningKey>>(this.store, KEY_CROSS_SIGNING_KEYS); const keys = getJsonItem<Record<string, CrossSigningKeyInfo>>(this.store, KEY_CROSS_SIGNING_KEYS);
func(keys); func(keys);
} }
@@ -545,7 +545,7 @@ export class LocalStorageCryptoStore extends MemoryCryptoStore implements Crypto
func(key); func(key);
} }
public storeCrossSigningKeys(txn: unknown, keys: Record<string, ICrossSigningKey>): void { public storeCrossSigningKeys(txn: unknown, keys: Record<string, CrossSigningKeyInfo>): void {
setJsonItem(this.store, KEY_CROSS_SIGNING_KEYS, keys); setJsonItem(this.store, KEY_CROSS_SIGNING_KEYS, keys);
} }

View File

@@ -32,10 +32,10 @@ import {
SESSION_BATCH_SIZE, SESSION_BATCH_SIZE,
} from "./base"; } from "./base";
import { IRoomKeyRequestBody } from "../index"; import { IRoomKeyRequestBody } from "../index";
import { ICrossSigningKey } from "../../client";
import { IOlmDevice } from "../algorithms/megolm"; import { IOlmDevice } from "../algorithms/megolm";
import { IRoomEncryption } from "../RoomList"; import { IRoomEncryption } from "../RoomList";
import { InboundGroupSessionData } from "../OlmDevice"; import { InboundGroupSessionData } from "../OlmDevice";
import { CrossSigningKeyInfo } from "../../crypto-api";
function encodeSessionKey(senderCurve25519Key: string, sessionId: string): string { function encodeSessionKey(senderCurve25519Key: string, sessionId: string): string {
return encodeURIComponent(senderCurve25519Key) + "/" + encodeURIComponent(sessionId); return encodeURIComponent(senderCurve25519Key) + "/" + encodeURIComponent(sessionId);
@@ -56,7 +56,7 @@ export class MemoryCryptoStore implements CryptoStore {
private migrationState: MigrationState = MigrationState.NOT_STARTED; private migrationState: MigrationState = MigrationState.NOT_STARTED;
private outgoingRoomKeyRequests: OutgoingRoomKeyRequest[] = []; private outgoingRoomKeyRequests: OutgoingRoomKeyRequest[] = [];
private account: string | null = null; private account: string | null = null;
private crossSigningKeys: Record<string, ICrossSigningKey> | null = null; private crossSigningKeys: Record<string, CrossSigningKeyInfo> | null = null;
private privateKeys: Partial<SecretStorePrivateKeys> = {}; private privateKeys: Partial<SecretStorePrivateKeys> = {};
private sessions: { [deviceKey: string]: { [sessionId: string]: ISessionInfo } } = {}; private sessions: { [deviceKey: string]: { [sessionId: string]: ISessionInfo } } = {};
@@ -319,7 +319,7 @@ export class MemoryCryptoStore implements CryptoStore {
this.account = accountPickle; this.account = accountPickle;
} }
public getCrossSigningKeys(txn: unknown, func: (keys: Record<string, ICrossSigningKey> | null) => void): void { public getCrossSigningKeys(txn: unknown, func: (keys: Record<string, CrossSigningKeyInfo> | null) => void): void {
func(this.crossSigningKeys); func(this.crossSigningKeys);
} }
@@ -332,7 +332,7 @@ export class MemoryCryptoStore implements CryptoStore {
func(result || null); func(result || null);
} }
public storeCrossSigningKeys(txn: unknown, keys: Record<string, ICrossSigningKey>): void { public storeCrossSigningKeys(txn: unknown, keys: Record<string, CrossSigningKeyInfo>): void {
this.crossSigningKeys = keys; this.crossSigningKeys = keys;
} }

View File

@@ -121,10 +121,6 @@ interface ThreepidCreds {
type EmailIdentityDict = { type EmailIdentityDict = {
type: AuthType.Email; type: AuthType.Email;
threepid_creds: ThreepidCreds; threepid_creds: ThreepidCreds;
/**
* @deprecated in favour of `threepid_creds` - kept for backwards compatibility
*/
threepidCreds?: ThreepidCreds;
session: string; session: string;
}; };
@@ -349,11 +345,7 @@ export class InteractiveAuth<T> {
} }
authDict = { authDict = {
type: EMAIL_STAGE_TYPE, type: EMAIL_STAGE_TYPE,
// TODO: Remove `threepid_creds` once servers support proper UIA
// See https://github.com/matrix-org/synapse/issues/5665
// See https://github.com/matrix-org/matrix-doc/issues/2220
threepid_creds: creds, threepid_creds: creds,
threepidCreds: creds,
}; };
} }
} }

View File

@@ -105,10 +105,6 @@ export { IdentityProviderBrand, SSOAction } from "./@types/auth";
export type { ISSOFlow as SSOFlow, LoginFlow } from "./@types/auth"; export type { ISSOFlow as SSOFlow, LoginFlow } from "./@types/auth";
export type { IHierarchyRelation as HierarchyRelation, IHierarchyRoom as HierarchyRoom } from "./@types/spaces"; export type { IHierarchyRelation as HierarchyRelation, IHierarchyRoom as HierarchyRoom } from "./@types/spaces";
export { LocationAssetType } from "./@types/location"; export { LocationAssetType } from "./@types/location";
/**
* @deprecated in favour of RoomJoinRulesEventContent on the types export
*/
export type { RoomJoinRulesEventContent as IJoinRuleEventContent } from "./@types/state_events";
/** /**
* Types supporting cryptography. * Types supporting cryptography.

View File

@@ -605,27 +605,6 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
return createEvent.getContent()["room_version"] ?? "1"; return createEvent.getContent()["room_version"] ?? "1";
} }
/**
* Determines whether this room needs to be upgraded to a new version
* @returns What version the room should be upgraded to, or null if
* the room does not require upgrading at this time.
* @deprecated Use #getRecommendedVersion() instead
*/
public shouldUpgradeToVersion(): string | null {
// TODO: Remove this function.
// This makes assumptions about which versions are safe, and can easily
// be wrong. Instead, people are encouraged to use getRecommendedVersion
// which determines a safer value. This function doesn't use that function
// because this is not async-capable, and to avoid breaking the contract
// we're deprecating this.
if (!SAFE_ROOM_VERSIONS.includes(this.getVersion())) {
return KNOWN_SAFE_ROOM_VERSION;
}
return null;
}
/** /**
* Determines the recommended room version for the room. This returns an * Determines the recommended room version for the room. This returns an
* object with 3 properties: `version` as the new version the * object with 3 properties: `version` as the new version the