From 85a55c79cdf94b557bbf21ae1eaee45be469730e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 25 Mar 2024 12:21:11 +0000 Subject: [PATCH] Remove various deprecated methods & re-exports (#4125) --- spec/unit/matrix-client.spec.ts | 2 - spec/unit/models/event.spec.ts | 48 +------------ src/@types/partials.ts | 7 -- src/@types/uia.ts | 4 +- src/client.ts | 75 ++++----------------- src/interactive-auth.ts | 16 ++--- src/models/event.ts | 30 +-------- src/models/room.ts | 2 +- src/models/thread.ts | 5 -- src/oidc/validate.ts | 6 -- src/rust-crypto/OutgoingRequestProcessor.ts | 4 +- 11 files changed, 26 insertions(+), 173 deletions(-) diff --git a/spec/unit/matrix-client.spec.ts b/spec/unit/matrix-client.spec.ts index c87ab3177..5f0cddda3 100644 --- a/spec/unit/matrix-client.spec.ts +++ b/spec/unit/matrix-client.spec.ts @@ -1528,8 +1528,6 @@ describe("MatrixClient", function () { { startOpts: {}, hasThreadSupport: false }, { startOpts: { threadSupport: true }, hasThreadSupport: true }, { startOpts: { threadSupport: false }, hasThreadSupport: false }, - { startOpts: { experimentalThreadSupport: true }, hasThreadSupport: true }, - { startOpts: { experimentalThreadSupport: true, threadSupport: false }, hasThreadSupport: false }, ])("enabled thread support for the SDK instance", async ({ startOpts, hasThreadSupport }) => { await client.startClient(startOpts); expect(client.supportsThreads()).toBe(hasThreadSupport); diff --git a/spec/unit/models/event.spec.ts b/spec/unit/models/event.spec.ts index 0b9416fd8..d308d0139 100644 --- a/spec/unit/models/event.spec.ts +++ b/spec/unit/models/event.spec.ts @@ -503,52 +503,6 @@ describe("MatrixEvent", () => { default: false, enabled: true, } as IAnnotatedPushRule; - describe("setPushActions()", () => { - it("sets actions on event", () => { - const actions = { notify: false, tweaks: {} }; - const event = new MatrixEvent({ - type: "com.example.test", - content: { - isTest: true, - }, - }); - event.setPushActions(actions); - - expect(event.getPushActions()).toBe(actions); - }); - - it("sets actions to undefined", () => { - const event = new MatrixEvent({ - type: "com.example.test", - content: { - isTest: true, - }, - }); - event.setPushActions(null); - - // undefined is set on state - expect(event.getPushDetails().actions).toBe(undefined); - // but pushActions getter returns null when falsy - expect(event.getPushActions()).toBe(null); - }); - - it("clears existing push rule", () => { - const prevActions = { notify: true, tweaks: { highlight: true } }; - const actions = { notify: false, tweaks: {} }; - const event = new MatrixEvent({ - type: "com.example.test", - content: { - isTest: true, - }, - }); - event.setPushDetails(prevActions, pushRule); - - event.setPushActions(actions); - - // rule is not in event push cache - expect(event.getPushDetails()).toEqual({ actions }); - }); - }); describe("setPushDetails()", () => { it("sets actions and rule on event", () => { @@ -577,7 +531,7 @@ describe("MatrixEvent", () => { }); event.setPushDetails(prevActions, pushRule); - event.setPushActions(actions); + event.setPushDetails(actions); // rule is not in event push cache expect(event.getPushDetails()).toEqual({ actions }); diff --git a/src/@types/partials.ts b/src/@types/partials.ts index 6aaea7996..abc3363ef 100644 --- a/src/@types/partials.ts +++ b/src/@types/partials.ts @@ -14,13 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { ImageInfo } from "./media"; - -/** - * @deprecated use {@link ImageInfo} instead. - */ -export type IImageInfo = ImageInfo; - export enum Visibility { Public = "public", Private = "private", diff --git a/src/@types/uia.ts b/src/@types/uia.ts index 67e7a68ed..bc10f2dd9 100644 --- a/src/@types/uia.ts +++ b/src/@types/uia.ts @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { IAuthDict, IAuthData } from "../interactive-auth"; +import { AuthDict, IAuthData } from "../interactive-auth"; /** * Helper type to represent HTTP request body for a UIA enabled endpoint */ export type UIARequest = T & { - auth?: IAuthDict; + auth?: AuthDict; }; /** diff --git a/src/client.ts b/src/client.ts index 3192e1449..8bf277071 100644 --- a/src/client.ts +++ b/src/client.ts @@ -149,15 +149,7 @@ import { UNSTABLE_MSC3088_PURPOSE, UNSTABLE_MSC3089_TREE_SUBTYPE, } from "./@types/event"; -import { - GuestAccess, - HistoryVisibility, - IdServerUnbindResult, - IImageInfo, - JoinRule, - Preset, - Visibility, -} from "./@types/partials"; +import { GuestAccess, HistoryVisibility, IdServerUnbindResult, JoinRule, Preset, Visibility } from "./@types/partials"; import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper"; import { randomString } from "./randomstring"; import { BackupManager, IKeyBackup, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup"; @@ -231,6 +223,7 @@ import { RegisterRequest, RegisterResponse } from "./@types/registration"; import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager"; import { getRelationsThreadFilter } from "./thread-utils"; import { KnownMembership, Membership } from "./@types/membership"; +import { ImageInfo } from "./@types/media"; export type Store = IStore; @@ -509,11 +502,6 @@ export interface IStartClientOpts { */ clientWellKnownPollPeriod?: number; - /** - * @deprecated use `threadSupport` instead - */ - experimentalThreadSupport?: boolean; - /** * Will organises events in threaded conversations when * a thread relation is encountered @@ -1536,19 +1524,6 @@ export class MatrixClient extends TypedEventEmitter this.logger.info("Sync startup aborted with an error:", e)); if (this.clientOpts.clientWellKnownPollPeriod !== undefined) { @@ -4506,7 +4481,6 @@ export class MatrixClient extends TypedEventEmitter { let content: IPowerLevelsContent | undefined; if (this.clientRunning && this.isInitialSyncComplete()) { @@ -5083,24 +5053,24 @@ export class MatrixClient extends TypedEventEmitter; + public sendImageMessage(roomId: string, url: string, info?: ImageInfo, text?: string): Promise; public sendImageMessage( roomId: string, threadId: string | null, url: string, - info?: IImageInfo, + info?: ImageInfo, text?: string, ): Promise; public sendImageMessage( roomId: string, threadId: string | null, - url?: string | IImageInfo, - info?: IImageInfo | string, + url?: string | ImageInfo, + info?: ImageInfo | string, text = "Image", ): Promise { if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) { text = (info as string) || "Image"; - info = url as IImageInfo; + info = url as ImageInfo; url = threadId as string; threadId = null; } @@ -5120,26 +5090,26 @@ export class MatrixClient extends TypedEventEmitter; public sendStickerMessage( roomId: string, threadId: string | null, url: string, - info?: IImageInfo, + info?: ImageInfo, text?: string, ): Promise; public sendStickerMessage( roomId: string, threadId: string | null, - url?: string | IImageInfo, - info?: IImageInfo | string, + url?: string | ImageInfo, + info?: ImageInfo | string, text = "Sticker", ): Promise { if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) { text = (info as string) || "Sticker"; - info = url as IImageInfo; + info = url as ImageInfo; url = threadId as string; threadId = null; } @@ -8526,17 +8496,6 @@ export class MatrixClient extends TypedEventEmitter { - const path = utils.encodeUri("/directory/room/$alias", { $alias: roomAlias }); - return this.http.request(Method.Get, path); - } - /** * Get the visibility of a room in the current HS's room directory * @returns Promise which resolves: TODO @@ -8550,7 +8509,7 @@ export class MatrixClient extends TypedEventEmitter; [key: string]: any } | {}; -/** - * Backwards compatible export - * @deprecated in favour of AuthDict - */ -export type IAuthDict = AuthDict; - export class NoAuthFlowFoundError extends Error { public name = "NoAuthFlowFoundError"; @@ -168,7 +162,7 @@ export class NoAuthFlowFoundError extends Error { * * The generic parameter `T` is the type of the response of the endpoint, once it is eventually successful. */ -export type UIAuthCallback = (makeRequest: (authData: IAuthDict | null) => Promise>) => Promise; +export type UIAuthCallback = (makeRequest: (authData: AuthDict | null) => Promise>) => Promise; interface IOpts { /** @@ -340,7 +334,7 @@ export class InteractiveAuth { // another just to check what the status is if (this.submitPromise) return; - let authDict: IAuthDict = {}; + let authDict: AuthDict = {}; if (this.currentStage == EMAIL_STAGE_TYPE) { // The email can be validated out-of-band, but we need to provide the // creds so the HS can go & check it. @@ -410,7 +404,7 @@ export class InteractiveAuth { * in the attemptAuth promise being rejected. This can be set to true * for requests that just poll to see if auth has been completed elsewhere. */ - public async submitAuthDict(authData: IAuthDict, background = false): Promise { + public async submitAuthDict(authData: AuthDict, background = false): Promise { if (!this.attemptAuthDeferred) { throw new Error("submitAuthDict() called before attemptAuth()"); } @@ -431,7 +425,7 @@ export class InteractiveAuth { } // use the sessionid from the last request, if one is present. - let auth: IAuthDict; + let auth: AuthDict; if ((this.data as IAuthData)?.session) { auth = { session: (this.data as IAuthData).session, @@ -515,7 +509,7 @@ export class InteractiveAuth { * This can be set to true for requests that just poll to see if auth has * been completed elsewhere. */ - private async doRequest(auth: IAuthDict | null, background = false): Promise { + private async doRequest(auth: AuthDict | null, background = false): Promise { try { const result = await this.requestCallback(auth, background); this.attemptAuthDeferred!.resolve(result); diff --git a/src/models/event.ts b/src/models/event.ts index 04a60d532..7c2725cda 100644 --- a/src/models/event.ts +++ b/src/models/event.ts @@ -1172,10 +1172,6 @@ export class MatrixEvent extends TypedEventEmitter { [[], [], []], ); } else { - // When `experimentalThreadSupport` is disabled treat all events as timelineEvents + // When `threadSupport` is disabled treat all events as timelineEvents return [events as MatrixEvent[], [] as MatrixEvent[], [] as MatrixEvent[]]; } } diff --git a/src/models/thread.ts b/src/models/thread.ts index 8baebba9a..6db967d4e 100644 --- a/src/models/thread.ts +++ b/src/models/thread.ts @@ -47,11 +47,6 @@ export type ThreadEventHandlerMap = { [ThreadEvent.Delete]: (thread: Thread) => void; } & EventTimelineSetHandlerMap; -/** - * @deprecated please use ThreadEventHandlerMap instead - */ -export type EventHandlerMap = ThreadEventHandlerMap; - interface IThreadOpts { room: Room; client: MatrixClient; diff --git a/src/oidc/validate.ts b/src/oidc/validate.ts index 38d730ba4..eabbc2071 100644 --- a/src/oidc/validate.ts +++ b/src/oidc/validate.ts @@ -20,12 +20,6 @@ import { OidcMetadata, SigninResponse } from "oidc-client-ts"; import { logger } from "../logger"; import { OidcError } from "./error"; -/** - * re-export for backwards compatibility - * @deprecated use OidcError - */ -export { OidcError as OidcDiscoveryError }; - export type ValidatedIssuerConfig = { authorizationEndpoint: string; tokenEndpoint: string; diff --git a/src/rust-crypto/OutgoingRequestProcessor.ts b/src/rust-crypto/OutgoingRequestProcessor.ts index 8e7e15584..268450154 100644 --- a/src/rust-crypto/OutgoingRequestProcessor.ts +++ b/src/rust-crypto/OutgoingRequestProcessor.ts @@ -29,7 +29,7 @@ import { import { logger } from "../logger"; import { calculateRetryBackoff, IHttpOpts, MatrixHttpApi, Method } from "../http-api"; import { logDuration, QueryDict, sleep } from "../utils"; -import { IAuthDict, UIAuthCallback } from "../interactive-auth"; +import { AuthDict, UIAuthCallback } from "../interactive-auth"; import { UIAResponse } from "../@types/uia"; import { ToDeviceMessageId } from "../@types/event"; @@ -169,7 +169,7 @@ export class OutgoingRequestProcessor { } const parsedBody = JSON.parse(body); - const makeRequest = async (auth: IAuthDict | null): Promise> => { + const makeRequest = async (auth: AuthDict | null): Promise> => { const newBody: Record = { ...parsedBody, };