From 8a1eee8484a9b0c6fe77e6e5d03d5f143407b166 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 1 Nov 2022 12:03:57 +0000 Subject: [PATCH 1/4] Make the js-sdk conform to tsc --strict --- spec/integ/matrix-client-syncing.spec.ts | 8 +- spec/unit/event-timeline.spec.ts | 24 +++--- spec/unit/webrtc/call.spec.ts | 2 +- src/@types/PushRules.ts | 5 +- src/autodiscovery.ts | 80 +++++++++++-------- src/client.ts | 43 +++++----- src/content-helpers.ts | 24 +++--- src/crypto/backup.ts | 2 +- .../store/indexeddb-crypto-store-backend.ts | 6 +- src/http-api/errors.ts | 2 +- src/interactive-auth.ts | 32 ++++---- src/models/MSC3089Branch.ts | 2 +- src/models/beacon.ts | 13 +-- src/models/event-timeline-set.ts | 2 +- src/models/event-timeline.ts | 53 ++++++------ src/models/event.ts | 29 +++---- src/models/invites-ignorer.ts | 2 +- src/models/room.ts | 24 +++--- src/models/thread.ts | 2 +- src/pushprocessor.ts | 15 ++-- src/webrtc/call.ts | 20 ++--- tsconfig.json | 3 +- 22 files changed, 202 insertions(+), 191 deletions(-) diff --git a/spec/integ/matrix-client-syncing.spec.ts b/spec/integ/matrix-client-syncing.spec.ts index 418e2d16add..216fbdbb1f6 100644 --- a/spec/integ/matrix-client-syncing.spec.ts +++ b/spec/integ/matrix-client-syncing.spec.ts @@ -707,15 +707,11 @@ describe("MatrixClient syncing", () => { awaitSyncEvent(2), ]).then(() => { const room = client!.getRoom(roomOne)!; - const stateAtStart = room.getLiveTimeline().getState( - EventTimeline.BACKWARDS, - ); + const stateAtStart = room.getLiveTimeline().getState(EventTimeline.BACKWARDS)!; const startRoomNameEvent = stateAtStart.getStateEvents('m.room.name', ''); expect(startRoomNameEvent.getContent().name).toEqual('Old room name'); - const stateAtEnd = room.getLiveTimeline().getState( - EventTimeline.FORWARDS, - ); + const stateAtEnd = room.getLiveTimeline().getState(EventTimeline.FORWARDS)!; const endRoomNameEvent = stateAtEnd.getStateEvents('m.room.name', ''); expect(endRoomNameEvent.getContent().name).toEqual('A new room name'); }); diff --git a/spec/unit/event-timeline.spec.ts b/spec/unit/event-timeline.spec.ts index 59f35dcce02..21434ec7111 100644 --- a/spec/unit/event-timeline.spec.ts +++ b/spec/unit/event-timeline.spec.ts @@ -55,13 +55,13 @@ describe("EventTimeline", function() { ]; timeline.initialiseState(events); // @ts-ignore private prop - const timelineStartState = timeline.startState; + const timelineStartState = timeline.startState!; expect(mocked(timelineStartState).setStateEvents).toHaveBeenCalledWith( events, { timelineWasEmpty: undefined }, ); // @ts-ignore private prop - const timelineEndState = timeline.endState; + const timelineEndState = timeline.endState!; expect(mocked(timelineEndState).setStateEvents).toHaveBeenCalledWith( events, { timelineWasEmpty: undefined }, @@ -185,14 +185,14 @@ describe("EventTimeline", function() { sentinel.name = "Old Alice"; sentinel.membership = "join"; - mocked(timeline.getState(EventTimeline.FORWARDS)).getSentinelMember + mocked(timeline.getState(EventTimeline.FORWARDS)!).getSentinelMember .mockImplementation(function(uid) { if (uid === userA) { return sentinel; } return null; }); - mocked(timeline.getState(EventTimeline.BACKWARDS)).getSentinelMember + mocked(timeline.getState(EventTimeline.BACKWARDS)!).getSentinelMember .mockImplementation(function(uid) { if (uid === userA) { return oldSentinel; @@ -225,14 +225,14 @@ describe("EventTimeline", function() { sentinel.name = "Old Alice"; sentinel.membership = "join"; - mocked(timeline.getState(EventTimeline.FORWARDS)).getSentinelMember + mocked(timeline.getState(EventTimeline.FORWARDS)!).getSentinelMember .mockImplementation(function(uid) { if (uid === userA) { return sentinel; } return null; }); - mocked(timeline.getState(EventTimeline.BACKWARDS)).getSentinelMember + mocked(timeline.getState(EventTimeline.BACKWARDS)!).getSentinelMember .mockImplementation(function(uid) { if (uid === userA) { return oldSentinel; @@ -269,15 +269,15 @@ describe("EventTimeline", function() { timeline.addEvent(events[0], { toStartOfTimeline: false }); timeline.addEvent(events[1], { toStartOfTimeline: false }); - expect(timeline.getState(EventTimeline.FORWARDS).setStateEvents). + expect(timeline.getState(EventTimeline.FORWARDS)!.setStateEvents). toHaveBeenCalledWith([events[0]], { timelineWasEmpty: undefined }); - expect(timeline.getState(EventTimeline.FORWARDS).setStateEvents). + expect(timeline.getState(EventTimeline.FORWARDS)!.setStateEvents). toHaveBeenCalledWith([events[1]], { timelineWasEmpty: undefined }); expect(events[0].forwardLooking).toBe(true); expect(events[1].forwardLooking).toBe(true); - expect(timeline.getState(EventTimeline.BACKWARDS).setStateEvents). + expect(timeline.getState(EventTimeline.BACKWARDS)!.setStateEvents). not.toHaveBeenCalled(); }); @@ -298,15 +298,15 @@ describe("EventTimeline", function() { timeline.addEvent(events[0], { toStartOfTimeline: true }); timeline.addEvent(events[1], { toStartOfTimeline: true }); - expect(timeline.getState(EventTimeline.BACKWARDS).setStateEvents). + expect(timeline.getState(EventTimeline.BACKWARDS)!.setStateEvents). toHaveBeenCalledWith([events[0]], { timelineWasEmpty: undefined }); - expect(timeline.getState(EventTimeline.BACKWARDS).setStateEvents). + expect(timeline.getState(EventTimeline.BACKWARDS)!.setStateEvents). toHaveBeenCalledWith([events[1]], { timelineWasEmpty: undefined }); expect(events[0].forwardLooking).toBe(false); expect(events[1].forwardLooking).toBe(false); - expect(timeline.getState(EventTimeline.FORWARDS).setStateEvents). + expect(timeline.getState(EventTimeline.FORWARDS)!.setStateEvents). not.toHaveBeenCalled(); }); diff --git a/spec/unit/webrtc/call.spec.ts b/spec/unit/webrtc/call.spec.ts index 01b110b4fad..8b42d9fe61a 100644 --- a/spec/unit/webrtc/call.spec.ts +++ b/spec/unit/webrtc/call.spec.ts @@ -757,7 +757,7 @@ describe('Call', function() { describe("transferToCall", () => { it("should send the required events", async () => { - const targetCall = new MatrixCall({ client: client.client }); + const targetCall = new MatrixCall({ client: client.client, roomId: "!roomId:server" }); const sendEvent = jest.spyOn(client.client, "sendEvent"); await call.transferToCall(targetCall); diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts index f3aeca156ba..59af4906074 100644 --- a/src/@types/PushRules.ts +++ b/src/@types/PushRules.ts @@ -30,7 +30,7 @@ export enum TweakName { export type Tweak = { set_tweak: N; - value: V; + value?: V; }; export type TweakHighlight = Tweak; @@ -76,7 +76,8 @@ export interface IPushRuleCondition { export interface IEventMatchCondition extends IPushRuleCondition { key: string; - pattern: string; + pattern?: string; + value?: string; } export interface IContainsDisplayNameCondition extends IPushRuleCondition { diff --git a/src/autodiscovery.ts b/src/autodiscovery.ts index f2128c0d549..f8e9afd1882 100644 --- a/src/autodiscovery.ts +++ b/src/autodiscovery.ts @@ -32,6 +32,27 @@ export enum AutoDiscoveryAction { FAIL_ERROR = "FAIL_ERROR", } +enum AutoDiscoveryError { + Invalid = "Invalid homeserver discovery response", + GenericFailure = "Failed to get autodiscovery configuration from server", + InvalidHsBaseUrl = "Invalid base_url for m.homeserver", + InvalidHomeserver = "Homeserver URL does not appear to be a valid Matrix homeserver", + InvalidIsBaseUrl = "Invalid base_url for m.identity_server", + InvalidIdentityServer = "Identity server URL does not appear to be a valid identity server", + InvalidIs = "Invalid identity server discovery response", + MissingWellknown = "No .well-known JSON file found", + InvalidJson = "Invalid JSON", +} + +interface ExtraFields { + state: AutoDiscoveryAction; +} + +interface ClientConfig { + "m.homeserver": IWellKnownConfig & ExtraFields; + "m.identity_server": IWellKnownConfig & ExtraFields; +} + /** * Utilities for automatically discovery resources, such as homeservers * for users to log in to. @@ -42,36 +63,25 @@ export class AutoDiscovery { // translate the meaning of the states in the spec, but also // support our own if needed. - public static readonly ERROR_INVALID = "Invalid homeserver discovery response"; + public static readonly ERROR_INVALID = AutoDiscoveryError.Invalid; - public static readonly ERROR_GENERIC_FAILURE = "Failed to get autodiscovery configuration from server"; + public static readonly ERROR_GENERIC_FAILURE = AutoDiscoveryError.GenericFailure; - public static readonly ERROR_INVALID_HS_BASE_URL = "Invalid base_url for m.homeserver"; + public static readonly ERROR_INVALID_HS_BASE_URL = AutoDiscoveryError.InvalidHsBaseUrl; - public static readonly ERROR_INVALID_HOMESERVER = "Homeserver URL does not appear to be a valid Matrix homeserver"; + public static readonly ERROR_INVALID_HOMESERVER = AutoDiscoveryError.InvalidHomeserver; - public static readonly ERROR_INVALID_IS_BASE_URL = "Invalid base_url for m.identity_server"; + public static readonly ERROR_INVALID_IS_BASE_URL = AutoDiscoveryError.InvalidIsBaseUrl; - // eslint-disable-next-line - public static readonly ERROR_INVALID_IDENTITY_SERVER = "Identity server URL does not appear to be a valid identity server"; + public static readonly ERROR_INVALID_IDENTITY_SERVER = AutoDiscoveryError.InvalidIdentityServer; - public static readonly ERROR_INVALID_IS = "Invalid identity server discovery response"; + public static readonly ERROR_INVALID_IS = AutoDiscoveryError.InvalidIs; - public static readonly ERROR_MISSING_WELLKNOWN = "No .well-known JSON file found"; + public static readonly ERROR_MISSING_WELLKNOWN = AutoDiscoveryError.MissingWellknown; - public static readonly ERROR_INVALID_JSON = "Invalid JSON"; + public static readonly ERROR_INVALID_JSON = AutoDiscoveryError.InvalidJson; - public static readonly ALL_ERRORS = [ - AutoDiscovery.ERROR_INVALID, - AutoDiscovery.ERROR_GENERIC_FAILURE, - AutoDiscovery.ERROR_INVALID_HS_BASE_URL, - AutoDiscovery.ERROR_INVALID_HOMESERVER, - AutoDiscovery.ERROR_INVALID_IS_BASE_URL, - AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER, - AutoDiscovery.ERROR_INVALID_IS, - AutoDiscovery.ERROR_MISSING_WELLKNOWN, - AutoDiscovery.ERROR_INVALID_JSON, - ]; + public static readonly ALL_ERRORS = Object.keys(AutoDiscoveryError); /** * The auto discovery failed. The client is expected to communicate @@ -126,7 +136,7 @@ export class AutoDiscovery { // We default to an error state to make the first few checks easier to // write. We'll update the properties of this object over the duration // of this function. - const clientConfig = { + const clientConfig: ClientConfig = { "m.homeserver": { state: AutoDiscovery.FAIL_ERROR, error: AutoDiscovery.ERROR_INVALID, @@ -136,7 +146,6 @@ export class AutoDiscovery { // Technically, we don't have a problem with the identity server // config at this point. state: AutoDiscovery.PROMPT, - error: null, base_url: null, }, }; @@ -188,7 +197,6 @@ export class AutoDiscovery { // Step 4: Now that the homeserver looks valid, update our client config. clientConfig["m.homeserver"] = { state: AutoDiscovery.SUCCESS, - error: null, base_url: hsUrl, }; @@ -197,7 +205,7 @@ export class AutoDiscovery { if (wellknown["m.identity_server"]) { // We prepare a failing identity server response to save lines later // in this branch. - const failingClientConfig = { + const failingClientConfig: ClientConfig = { "m.homeserver": clientConfig["m.homeserver"], "m.identity_server": { state: AutoDiscovery.FAIL_PROMPT, @@ -241,7 +249,6 @@ export class AutoDiscovery { if (isUrl && isUrl.toString().length > 0) { clientConfig["m.identity_server"] = { state: AutoDiscovery.SUCCESS, - error: null, base_url: isUrl, }; } @@ -298,7 +305,7 @@ export class AutoDiscovery { // We default to an error state to make the first few checks easier to // write. We'll update the properties of this object over the duration // of this function. - const clientConfig = { + const clientConfig: ClientConfig = { "m.homeserver": { state: AutoDiscovery.FAIL_ERROR, error: AutoDiscovery.ERROR_INVALID, @@ -308,7 +315,6 @@ export class AutoDiscovery { // Technically, we don't have a problem with the identity server // config at this point. state: AutoDiscovery.PROMPT, - error: null, base_url: null, }, }; @@ -324,7 +330,6 @@ export class AutoDiscovery { if (wellknown.action === AutoDiscoveryAction.IGNORE) { clientConfig["m.homeserver"] = { state: AutoDiscovery.PROMPT, - error: null, base_url: null, }; } else { @@ -367,18 +372,18 @@ export class AutoDiscovery { * @return {string|boolean} The sanitized URL or a falsey value if the URL is invalid. * @private */ - private static sanitizeWellKnownUrl(url: string): string | boolean { + private static sanitizeWellKnownUrl(url: string): string | false { if (!url) return false; try { - let parsed = null; + let parsed: URL | undefined; try { parsed = new URL(url); } catch (e) { logger.error("Could not parse url", e); } - if (!parsed || !parsed.hostname) return false; + if (!parsed?.hostname) return false; if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false; const port = parsed.port ? `:${parsed.port}` : ""; @@ -448,12 +453,17 @@ export class AutoDiscovery { }; } } catch (err) { - const error = err as Error | string | undefined; + const error = err as AutoDiscoveryError | string | undefined; + let reason = ""; + if (typeof error === "object") { + reason = (error)?.message; + } + return { error, raw: {}, action: AutoDiscoveryAction.FAIL_PROMPT, - reason: (error)?.message || "General failure", + reason: reason || "General failure", }; } @@ -463,7 +473,7 @@ export class AutoDiscovery { action: AutoDiscoveryAction.SUCCESS, }; } catch (err) { - const error = err as Error | string | undefined; + const error = err as Error; return { error, raw: {}, diff --git a/src/client.ts b/src/client.ts index 7e37c22afaf..341b2cbecd7 100644 --- a/src/client.ts +++ b/src/client.ts @@ -507,7 +507,7 @@ export interface IUploadKeySignaturesResponse { } export interface IPreviewUrlResponse { - [key: string]: string | number; + [key: string]: undefined | string | number; "og:title": string; "og:type": string; "og:url": string; @@ -705,8 +705,9 @@ export interface IMyDevice { display_name?: string; last_seen_ip?: string; last_seen_ts?: number; - [UNSTABLE_MSC3852_LAST_SEEN_UA.stable]?: string; - [UNSTABLE_MSC3852_LAST_SEEN_UA.unstable]?: string; + // UNSTABLE_MSC3852_LAST_SEEN_UA + last_seen_user_agent?: string; + "org.matrix.msc3852.last_seen_user_agent"?: string; } export interface Keys { @@ -3121,7 +3122,7 @@ export class MatrixClient extends TypedEventEmitter { const privKey = decodeRecoveryKey(recoveryKey); - return this.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts); + return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts); } public async restoreKeyBackupWithCache( @@ -3283,7 +3284,7 @@ export class MatrixClient extends TypedEventEmitter { if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) { @@ -3787,10 +3788,10 @@ export class MatrixClient extends TypedEventEmitter { return ev.isRelation(THREAD_RELATION_TYPE.name) && !ev.status; })?.getId() ?? threadId, @@ -4097,7 +4098,7 @@ export class MatrixClient extends TypedEventEmitter { if (typeof threadId !== "string" && threadId !== null) { @@ -4314,7 +4315,7 @@ export class MatrixClient extends TypedEventEmitter { @@ -4358,7 +4359,7 @@ export class MatrixClient extends TypedEventEmitter { @@ -5226,11 +5227,11 @@ export class MatrixClient extends TypedEventEmitter { if (res.state) { - const roomState = eventTimeline.getState(dir); + const roomState = eventTimeline.getState(dir)!; const stateEvents = res.state.map(this.getEventMapper()); roomState.setUnknownStateEvents(stateEvents); } @@ -5758,7 +5759,7 @@ export class MatrixClient extends TypedEventEmitter { if (res.state) { - const roomState = eventTimeline.getState(dir); + const roomState = eventTimeline.getState(dir)!; const stateEvents = res.state.map(this.getEventMapper()); roomState.setUnknownStateEvents(stateEvents); } diff --git a/src/content-helpers.ts b/src/content-helpers.ts index f6763fb8c55..531b939fa2e 100644 --- a/src/content-helpers.ts +++ b/src/content-helpers.ts @@ -118,12 +118,12 @@ export function makeEmoteMessage(body: string) { /** Location content helpers */ export const getTextForLocationEvent = ( - uri: string, + uri: string | undefined, assetType: LocationAssetType, - timestamp: number, + timestamp?: number, description?: string, ): string => { - const date = `at ${new Date(timestamp).toISOString()}`; + const date = `at ${new Date(timestamp!).toISOString()}`; const assetName = assetType === LocationAssetType.Self ? 'User' : undefined; const quotedDescription = description ? `"${description}"` : undefined; @@ -147,9 +147,9 @@ export const getTextForLocationEvent = ( export const makeLocationContent = ( // this is first but optional // to avoid a breaking change - text: string | undefined, - uri: string, - timestamp: number, + text?: string, + uri?: string, + timestamp?: number, description?: string, assetType?: LocationAssetType, ): LegacyLocationEventContent & MLocationEventContent => { @@ -187,7 +187,7 @@ export const parseLocationEvent = (wireEventContent: LocationEventWireContent): const assetType = asset?.type ?? LocationAssetType.Self; const fallbackText = text ?? wireEventContent.body; - return makeLocationContent(fallbackText, geoUri, timestamp, description, assetType); + return makeLocationContent(fallbackText, geoUri, timestamp ?? undefined, description ?? "", assetType); }; /** @@ -201,7 +201,7 @@ export type MakeTopicContent = ( export const makeTopicContent: MakeTopicContent = (topic, htmlTopic) => { const renderings = [{ body: topic, mimetype: "text/plain" }]; if (isProvided(htmlTopic)) { - renderings.push({ body: htmlTopic, mimetype: "text/html" }); + renderings.push({ body: htmlTopic!, mimetype: "text/html" }); } return { topic, [M_TOPIC.name]: renderings }; }; @@ -247,14 +247,14 @@ export const makeBeaconInfoContent: MakeBeaconInfoContent = ( export type BeaconInfoState = MBeaconInfoContent & { assetType?: LocationAssetType; - timestamp: number; + timestamp?: number; }; /** * Flatten beacon info event content */ export const parseBeaconInfoContent = (content: MBeaconInfoEventContent): BeaconInfoState => { const { description, timeout, live } = content; - const timestamp = M_TIMESTAMP.findIn(content); + const timestamp = M_TIMESTAMP.findIn(content) ?? undefined; const asset = M_ASSET.findIn(content); return { @@ -290,14 +290,14 @@ export const makeBeaconContent: MakeBeaconContent = ( }, }); -export type BeaconLocationState = MLocationContent & { +export type BeaconLocationState = Omit & { uri?: string; // override from MLocationContent to allow optionals timestamp?: number; }; export const parseBeaconContent = (content: MBeaconEventContent): BeaconLocationState => { const location = M_LOCATION.findIn(content); - const timestamp = M_TIMESTAMP.findIn(content); + const timestamp = M_TIMESTAMP.findIn(content) ?? undefined; return { description: location?.description, diff --git a/src/crypto/backup.ts b/src/crypto/backup.ts index f57cfe29359..fd4377e148c 100644 --- a/src/crypto/backup.ts +++ b/src/crypto/backup.ts @@ -302,7 +302,7 @@ export class BackupManager { || now - this.sessionLastCheckAttemptedTime[targetSessionId!] > KEY_BACKUP_CHECK_RATE_LIMIT ) { this.sessionLastCheckAttemptedTime[targetSessionId!] = now; - await this.baseApis.restoreKeyBackupWithCache(targetRoomId, targetSessionId, this.backupInfo, {}); + await this.baseApis.restoreKeyBackupWithCache(targetRoomId!, targetSessionId!, this.backupInfo, {}); } } diff --git a/src/crypto/store/indexeddb-crypto-store-backend.ts b/src/crypto/store/indexeddb-crypto-store-backend.ts index faeb5c829a6..f525c0c959a 100644 --- a/src/crypto/store/indexeddb-crypto-store-backend.ts +++ b/src/crypto/store/indexeddb-crypto-store-backend.ts @@ -201,7 +201,7 @@ export class Backend implements CryptoStore { let stateIndex = 0; let result: OutgoingRoomKeyRequest; - function onsuccess(this: IDBRequest) { + function onsuccess(this: IDBRequest) { const cursor = this.result; if (cursor) { // got a match @@ -256,7 +256,7 @@ export class Backend implements CryptoStore { let stateIndex = 0; const results: OutgoingRoomKeyRequest[] = []; - function onsuccess(this: IDBRequest) { + function onsuccess(this: IDBRequest) { const cursor = this.result; if (cursor) { const keyReq = cursor.value; @@ -309,7 +309,7 @@ export class Backend implements CryptoStore { ): Promise { let result: OutgoingRoomKeyRequest | null = null; - function onsuccess(this: IDBRequest) { + function onsuccess(this: IDBRequest) { const cursor = this.result; if (!cursor) { return; diff --git a/src/http-api/errors.ts b/src/http-api/errors.ts index faa379784f4..be63c94fdf0 100644 --- a/src/http-api/errors.ts +++ b/src/http-api/errors.ts @@ -49,7 +49,7 @@ export class HTTPError extends Error { */ export class MatrixError extends HTTPError { public readonly errcode?: string; - public readonly data: IErrorJson; + public data: IErrorJson; constructor( errorJson: IErrorJson = {}, diff --git a/src/interactive-auth.ts b/src/interactive-auth.ts index ef3bc8bd891..5ba5956695e 100644 --- a/src/interactive-auth.ts +++ b/src/interactive-auth.ts @@ -21,6 +21,7 @@ limitations under the License. import { logger } from './logger'; import { MatrixClient } from "./client"; import { defer, IDeferred } from "./utils"; +import { MatrixError } from "./http-api"; const EMAIL_STAGE_TYPE = "m.login.email.identity"; const MSISDN_STAGE_TYPE = "m.login.msisdn"; @@ -111,7 +112,7 @@ interface IOpts { sessionId?: string; clientSecret?: string; emailSid?: string; - doRequest(auth: IAuthData, background: boolean): Promise; + doRequest(auth: IAuthData | null, background: boolean): Promise; stateUpdated(nextStage: AuthType, status: IStageStatus): void; requestEmailToken(email: string, secret: string, attempt: number, session: string): Promise<{ sid: string }>; busyChanged?(busy: boolean): void; @@ -328,7 +329,7 @@ export class InteractiveAuth { * @param {string} loginType login type for the stage * @return {object?} any parameters from the server for this stage */ - public getStageParams(loginType: string): Record { + public getStageParams(loginType: string): Record | undefined { return this.data.params?.[loginType]; } @@ -428,10 +429,10 @@ export class InteractiveAuth { this.requestingEmailToken = true; try { const requestTokenResult = await this.requestEmailTokenCallback( - this.inputs.emailAddress, + this.inputs.emailAddress!, this.clientSecret, this.emailAttempt++, - this.data.session, + this.data.session!, ); this.emailSid = requestTokenResult.sid; logger.trace("Email token request succeeded"); @@ -454,16 +455,16 @@ 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: IAuthData, background = false): Promise { + private async doRequest(auth: IAuthData | null, background = false): Promise { try { const result = await this.requestCallback(auth, background); this.attemptAuthDeferred!.resolve(result); this.attemptAuthDeferred = null; } catch (error) { // sometimes UI auth errors don't come with flows - const errorFlows = error.data?.flows ?? null; + const errorFlows = (error).data?.flows ?? null; const haveFlows = this.data.flows || Boolean(errorFlows); - if (error.httpStatus !== 401 || !error.data || !haveFlows) { + if ((error).httpStatus !== 401 || !(error).data || !haveFlows) { // doesn't look like an interactive-auth failure. if (!background) { this.attemptAuthDeferred?.reject(error); @@ -474,20 +475,23 @@ export class InteractiveAuth { logger.log("Background poll request failed doing UI auth: ignoring", error); } } - if (!error.data) { - error.data = {}; + if (!(error).data) { + (error).data = {}; } // if the error didn't come with flows, completed flows or session ID, // copy over the ones we have. Synapse sometimes sends responses without // any UI auth data (eg. when polling for email validation, if the email // has not yet been validated). This appears to be a Synapse bug, which // we workaround here. - if (!error.data.flows && !error.data.completed && !error.data.session) { - error.data.flows = this.data.flows; - error.data.completed = this.data.completed; - error.data.session = this.data.session; + if (!(error).data.flows && + !(error).data.completed && + !(error).data.session + ) { + (error).data.flows = this.data.flows; + (error).data.completed = this.data.completed; + (error).data.session = this.data.session; } - this.data = error.data; + this.data = (error).data; try { this.startNextAuthStage(); } catch (e) { diff --git a/src/models/MSC3089Branch.ts b/src/models/MSC3089Branch.ts index e8c5af14acb..25ce51a20a1 100644 --- a/src/models/MSC3089Branch.ts +++ b/src/models/MSC3089Branch.ts @@ -145,7 +145,7 @@ export class MSC3089Branch { let event: MatrixEvent | undefined = room.getUnfilteredTimelineSet().findEventById(this.id); // keep scrolling back if needed until we find the event or reach the start of the room: - while (!event && room.getLiveTimeline().getState(EventTimeline.BACKWARDS).paginationToken) { + while (!event && room.getLiveTimeline().getState(EventTimeline.BACKWARDS)!.paginationToken) { await this.client.scrollback(room, 100); event = room.getUnfilteredTimelineSet().findEventById(this.id); } diff --git a/src/models/beacon.ts b/src/models/beacon.ts index 0ec955ffaa2..79876c469f9 100644 --- a/src/models/beacon.ts +++ b/src/models/beacon.ts @@ -132,19 +132,19 @@ export class Beacon extends TypedEventEmitter 1) { this.livenessWatchTimeout = setTimeout( () => { this.monitorLiveness(); }, expiryInMs, ); } - } else if (this.beaconInfo.timestamp > Date.now()) { + } else if (this.beaconInfo.timestamp! > Date.now()) { // beacon start timestamp is in the future // check liveness again then this.livenessWatchTimeout = setTimeout( () => { this.monitorLiveness(); }, - this.beaconInfo.timestamp - Date.now(), + this.beaconInfo.timestamp! - Date.now(), ); } } @@ -165,6 +165,7 @@ export class Beacon extends TypedEventEmitter Date.now() ? - this.beaconInfo.timestamp - 360000 /* 6min */ : + const startTimestamp = this.beaconInfo.timestamp! > Date.now() ? + this.beaconInfo.timestamp! - 360000 /* 6min */ : this.beaconInfo.timestamp; - this._isLive = !!this._beaconInfo?.live && + this._isLive = !!this._beaconInfo?.live && !!startTimestamp && isTimestampInDuration(startTimestamp, this._beaconInfo?.timeout, Date.now()); if (prevLiveness !== this.isLive) { diff --git a/src/models/event-timeline-set.ts b/src/models/event-timeline-set.ts index abf20ebf8bf..e41eec15881 100644 --- a/src/models/event-timeline-set.ts +++ b/src/models/event-timeline-set.ts @@ -625,7 +625,7 @@ export class EventTimelineSet extends TypedEventEmitter | null> = { @@ -126,10 +126,12 @@ export class EventTimeline { */ constructor(private readonly eventTimelineSet: EventTimelineSet) { this.roomId = eventTimelineSet.room?.roomId ?? null; - this.startState = new RoomState(this.roomId); - this.startState.paginationToken = null; - this.endState = new RoomState(this.roomId); - this.endState.paginationToken = null; + if (this.roomId) { + this.startState = new RoomState(this.roomId); + this.startState.paginationToken = null; + this.endState = new RoomState(this.roomId); + this.endState.paginationToken = null; + } // this is used by client.js this.paginationRequests = { 'b': null, 'f': null }; @@ -167,12 +169,8 @@ export class EventTimeline { Object.freeze(e); } - this.startState.setStateEvents(stateEvents, { - timelineWasEmpty, - }); - this.endState.setStateEvents(stateEvents, { - timelineWasEmpty, - }); + this.startState?.setStateEvents(stateEvents, { timelineWasEmpty }); + this.endState?.setStateEvents(stateEvents, { timelineWasEmpty }); } /** @@ -190,7 +188,7 @@ export class EventTimeline { public forkLive(direction: Direction): EventTimeline { const forkState = this.getState(direction); const timeline = new EventTimeline(this.eventTimelineSet); - timeline.startState = forkState.clone(); + timeline.startState = forkState?.clone(); // Now clobber the end state of the new live timeline with that from the // previous live timeline. It will be identical except that we'll keep // using the same RoomMember objects for the 'live' set of members with any @@ -198,7 +196,7 @@ export class EventTimeline { timeline.endState = forkState; // Firstly, we just stole the current timeline's end state, so it needs a new one. // Make an immutable copy of the state so back pagination will get the correct sentinels. - this.endState = forkState.clone(); + this.endState = forkState?.clone(); return timeline; } @@ -214,8 +212,8 @@ export class EventTimeline { public fork(direction: Direction): EventTimeline { const forkState = this.getState(direction); const timeline = new EventTimeline(this.eventTimelineSet); - timeline.startState = forkState.clone(); - timeline.endState = forkState.clone(); + timeline.startState = forkState?.clone(); + timeline.endState = forkState?.clone(); return timeline; } @@ -276,7 +274,7 @@ export class EventTimeline { * * @return {RoomState} state at the start/end of the timeline */ - public getState(direction: Direction): RoomState { + public getState(direction: Direction): RoomState | undefined { if (direction == EventTimeline.BACKWARDS) { return this.startState; } else if (direction == EventTimeline.FORWARDS) { @@ -296,7 +294,7 @@ export class EventTimeline { * @return {?string} pagination token */ public getPaginationToken(direction: Direction): string | null { - return this.getState(direction).paginationToken; + return this.getState(direction)?.paginationToken ?? null; } /** @@ -304,12 +302,15 @@ export class EventTimeline { * * @param {?string} token pagination token * - * @param {string} direction EventTimeline.BACKWARDS to set the paginatio + * @param {string} direction EventTimeline.BACKWARDS to set the pagination * token for going backwards in time; EventTimeline.FORWARDS to set the * pagination token for going forwards in time. */ public setPaginationToken(token: string | null, direction: Direction): void { - this.getState(direction).paginationToken = token; + const state = this.getState(direction); + if (state) { + state.paginationToken = token; + } } /** @@ -408,16 +409,14 @@ export class EventTimeline { const timelineSet = this.getTimelineSet(); if (timelineSet.room) { - EventTimeline.setEventMetadata(event, roomState, toStartOfTimeline); + EventTimeline.setEventMetadata(event, roomState!, toStartOfTimeline); // modify state but only on unfiltered timelineSets if ( event.isState() && timelineSet.room.getUnfilteredTimelineSet() === timelineSet ) { - roomState.setStateEvents([event], { - timelineWasEmpty, - }); + roomState?.setStateEvents([event], { timelineWasEmpty }); // it is possible that the act of setting the state event means we // can set more metadata (specifically sender/target props), so try // it again if the prop wasn't previously set. It may also mean that @@ -428,8 +427,8 @@ export class EventTimeline { // back in time, else we'll set the .sender value for BEFORE the given // member event, whereas we want to set the .sender value for the ACTUAL // member event itself. - if (!event.sender || (event.getType() === "m.room.member" && !toStartOfTimeline)) { - EventTimeline.setEventMetadata(event, roomState, toStartOfTimeline); + if (!event.sender || (event.getType() === EventType.RoomMember && !toStartOfTimeline)) { + EventTimeline.setEventMetadata(event, roomState!, toStartOfTimeline); } } } diff --git a/src/models/event.ts b/src/models/event.ts index 6fbe6a391ba..6ba8a65110e 100644 --- a/src/models/event.ts +++ b/src/models/event.ts @@ -413,7 +413,7 @@ export class MatrixEvent extends TypedEventEmitter1433502692297 */ public getTs(): number { - return this.event.origin_server_ts; + return this.event.origin_server_ts!; } /** @@ -625,8 +625,8 @@ export class MatrixEvent extends TypedEventEmitter { // state at the start and end of that timeline. These are more // for backwards-compatibility than anything else. this.timeline = this.getLiveTimeline().getEvents(); - this.oldState = this.getLiveTimeline() - .getState(EventTimeline.BACKWARDS); - this.currentState = this.getLiveTimeline() - .getState(EventTimeline.FORWARDS); + this.oldState = this.getLiveTimeline().getState(EventTimeline.BACKWARDS)!; + this.currentState = this.getLiveTimeline().getState(EventTimeline.FORWARDS)!; // Let people know to register new listeners for the new state // references. The reference won't necessarily change every time so only @@ -1564,8 +1562,8 @@ export class Room extends ReadReceipt { pendingEvents = true, }: ICreateFilterOpts = {}, ): EventTimelineSet { - if (this.filteredTimelineSets[filter.filterId]) { - return this.filteredTimelineSets[filter.filterId]; + if (this.filteredTimelineSets[filter.filterId!]) { + return this.filteredTimelineSets[filter.filterId!]; } const opts = Object.assign({ filter, pendingEvents }, this.opts); const timelineSet = new EventTimelineSet(this, opts); @@ -1574,7 +1572,7 @@ export class Room extends ReadReceipt { RoomEvent.TimelineReset, ]); if (useSyncEvents) { - this.filteredTimelineSets[filter.filterId] = timelineSet; + this.filteredTimelineSets[filter.filterId!] = timelineSet; this.timelineSets.push(timelineSet); } @@ -1623,7 +1621,7 @@ export class Room extends ReadReceipt { } private async getThreadListFilter(filterType = ThreadFilterType.All): Promise { - const myUserId = this.client.getUserId(); + const myUserId = this.client.getUserId()!; const filter = new Filter(myUserId); const definition: IFilterDefinition = { @@ -1635,7 +1633,7 @@ export class Room extends ReadReceipt { }; if (filterType === ThreadFilterType.My) { - definition.room.timeline[FILTER_RELATED_BY_SENDERS.name] = [myUserId]; + definition!.room!.timeline![FILTER_RELATED_BY_SENDERS.name] = [myUserId]; } filter.setDefinition(definition); @@ -1681,7 +1679,7 @@ export class Room extends ReadReceipt { return event.getSender() === this.client.getUserId(); }); if (filterType !== ThreadFilterType.My || currentUserParticipated) { - timelineSet.getLiveTimeline().addEvent(thread.rootEvent, { + timelineSet.getLiveTimeline().addEvent(thread.rootEvent!, { toStartOfTimeline: false, }); } @@ -1851,8 +1849,8 @@ export class Room extends ReadReceipt { * @param {Filter} filter the filter whose timelineSet is to be forgotten */ public removeFilteredTimelineSet(filter: Filter): void { - const timelineSet = this.filteredTimelineSets[filter.filterId]; - delete this.filteredTimelineSets[filter.filterId]; + const timelineSet = this.filteredTimelineSets[filter.filterId!]; + delete this.filteredTimelineSets[filter.filterId!]; const i = this.timelineSets.indexOf(timelineSet); if (i > -1) { this.timelineSets.splice(i, 1); @@ -2187,7 +2185,7 @@ export class Room extends ReadReceipt { // call setEventMetadata to set up event.sender etc // as event is shared over all timelineSets, we set up its metadata based // on the unfiltered timelineSet. - EventTimeline.setEventMetadata(event, this.getLiveTimeline().getState(EventTimeline.FORWARDS), false); + EventTimeline.setEventMetadata(event, this.getLiveTimeline().getState(EventTimeline.FORWARDS)!, false); this.txnToEvent[txnId] = event; if (this.pendingEventList) { diff --git a/src/models/thread.ts b/src/models/thread.ts index 117100d6923..0e3b6c3b51c 100644 --- a/src/models/thread.ts +++ b/src/models/thread.ts @@ -200,7 +200,7 @@ export class Thread extends ReadReceipt { }; public get roomState(): RoomState { - return this.room.getLiveTimeline().getState(EventTimeline.FORWARDS); + return this.room.getLiveTimeline().getState(EventTimeline.FORWARDS)!; } private addEventToTimeline(event: MatrixEvent, toStartOfTimeline: boolean): void { diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index 2976417fdc1..e979032d89b 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -219,8 +219,11 @@ export class PushProcessor { return null; } - private templateRuleToRaw(kind: PushRuleKind, tprule: any): any { - const rawrule = { + private templateRuleToRaw( + kind: PushRuleKind, + tprule: IPushRule, + ): Pick | null { + const rawrule: Pick = { 'rule_id': tprule.rule_id, 'actions': tprule.actions, 'conditions': [], @@ -234,7 +237,7 @@ export class PushProcessor { if (!tprule.rule_id) { return null; } - rawrule.conditions.push({ + rawrule.conditions!.push({ 'kind': ConditionKind.EventMatch, 'key': 'room_id', 'value': tprule.rule_id, @@ -244,7 +247,7 @@ export class PushProcessor { if (!tprule.rule_id) { return null; } - rawrule.conditions.push({ + rawrule.conditions!.push({ 'kind': ConditionKind.EventMatch, 'key': 'user_id', 'value': tprule.rule_id, @@ -254,7 +257,7 @@ export class PushProcessor { if (!tprule.pattern) { return null; } - rawrule.conditions.push({ + rawrule.conditions!.push({ 'kind': ConditionKind.EventMatch, 'key': 'content.body', 'pattern': tprule.pattern, @@ -474,7 +477,7 @@ export class PushProcessor { return actionObj; } - public ruleMatchesEvent(rule: IPushRule, ev: MatrixEvent): boolean { + public ruleMatchesEvent(rule: Partial & Pick, ev: MatrixEvent): boolean { if (!rule.conditions?.length) return true; let ret = true; diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index b495dfec659..93f5e18a89f 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -68,7 +68,7 @@ import { MatrixError } from "../http-api"; */ interface CallOpts { - roomId?: string; + roomId: string; client: MatrixClient; forceTURN?: boolean; turnServers?: Array; @@ -278,7 +278,7 @@ export class MatrixCall extends TypedEventEmitter; // A queue for candidates waiting to go out. // We try to amalgamate candidates into a single candidate message where @@ -291,7 +291,7 @@ export class MatrixCall extends TypedEventEmitter = []; private screensharingSenders: Array = []; private inviteOrAnswerSent = false; - private waitForLocalAVStream: boolean; + private waitForLocalAVStream?: boolean; private successor?: MatrixCall; private opponentMember?: RoomMember; private opponentVersion?: number | string; @@ -312,7 +312,7 @@ export class MatrixCall extends TypedEventEmitter { stats.push(item); }); @@ -797,9 +797,9 @@ export class MatrixCall extends TypedEventEmitter Date: Wed, 2 Nov 2022 08:49:50 +0000 Subject: [PATCH 2/4] Update tsconfig.json Co-authored-by: Faye Duxovni --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 53a536a3946..12dbee04f95 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "noUnusedLocals": true, "noEmit": true, "declaration": true, - "strict": true + "strict": true }, "include": [ "./src/**/*.ts", From f729f0958e5686c4d1bce5928e266996128d0b7a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 3 Nov 2022 10:38:54 +0000 Subject: [PATCH 3/4] Patch matrix-events-sdk until https://github.com/matrix-org/matrix-events-sdk/pull/16 lands --- package.json | 5 +- patches/matrix-events-sdk+0.0.1-beta.7.patch | 12 ++ yarn.lock | 162 ++++++++++++++++++- 3 files changed, 171 insertions(+), 8 deletions(-) create mode 100644 patches/matrix-events-sdk+0.0.1-beta.7.patch diff --git a/package.json b/package.json index 5e7fbe21f84..5ddafcba791 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ }, "scripts": { "prepublishOnly": "yarn build", + "postinstall": "patch-package", "start": "echo THIS IS FOR LEGACY PURPOSES ONLY. && babel src -w -s -d lib --verbose --extensions \".ts,.js\"", "dist": "echo 'This is for the release script so it can make assets (browser bundle).' && yarn build", "clean": "rimraf lib dist", @@ -58,7 +59,7 @@ "bs58": "^5.0.0", "content-type": "^1.0.4", "loglevel": "^1.7.1", - "matrix-events-sdk": "^0.0.1-beta.7", + "matrix-events-sdk": "0.0.1-beta.7", "p-retry": "4", "qs": "^6.9.6", "unhomoglyph": "^1.0.6" @@ -104,6 +105,8 @@ "jest-sonar-reporter": "^2.0.0", "jsdoc": "^3.6.6", "matrix-mock-request": "^2.5.0", + "patch-package": "^6.5.0", + "postinstall-postinstall": "^2.1.0", "rimraf": "^3.0.2", "terser": "^5.5.1", "tsify": "^5.0.2", diff --git a/patches/matrix-events-sdk+0.0.1-beta.7.patch b/patches/matrix-events-sdk+0.0.1-beta.7.patch new file mode 100644 index 00000000000..1d61653639f --- /dev/null +++ b/patches/matrix-events-sdk+0.0.1-beta.7.patch @@ -0,0 +1,12 @@ +diff --git a/node_modules/matrix-events-sdk/lib/NamespacedMap.d.ts b/node_modules/matrix-events-sdk/lib/NamespacedMap.d.ts +index c141b11..461f528 100644 +--- a/node_modules/matrix-events-sdk/lib/NamespacedMap.d.ts ++++ b/node_modules/matrix-events-sdk/lib/NamespacedMap.d.ts +@@ -1,6 +1,6 @@ + import { NamespacedValue } from "./NamespacedValue"; + import { Optional } from "./types"; +-declare type NS = NamespacedValue, Optional>; ++declare type NS = NamespacedValue; + /** + * A `Map` implementation which accepts a NamespacedValue as a key, and arbitrary value. The + * namespaced value must be a string type. diff --git a/yarn.lock b/yarn.lock index d62ad0734d6..8ac841a21c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1349,7 +1349,6 @@ "@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.13.tgz": version "3.2.13" - uid "0109fde93bcc61def851f79826c9384c073b5175" resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.13.tgz#0109fde93bcc61def851f79826c9384c073b5175" "@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3": @@ -1772,6 +1771,11 @@ "@typescript-eslint/types" "5.40.1" eslint-visitor-keys "^3.3.0" +"@yarnpkg/lockfile@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + JSONStream@^1.0.3: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -2455,7 +2459,7 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -2490,6 +2494,11 @@ chokidar@^3.4.0: optionalDependencies: fsevents "~2.3.2" +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + ci-info@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.5.0.tgz#bfac2a29263de4c829d806b1ab478e35091e171f" @@ -2719,6 +2728,17 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-spawn@^6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -3459,6 +3479,13 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" +find-yarn-workspace-root@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd" + integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== + dependencies: + micromatch "^4.0.2" + flat-cache@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" @@ -3487,6 +3514,15 @@ foreground-child@^2.0.0: cross-spawn "^7.0.0" signal-exit "^3.0.2" +fs-extra@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-readdir-recursive@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" @@ -3640,7 +3676,7 @@ globrex@^0.1.2: resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098" integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg== -graceful-fs@^4.1.9, graceful-fs@^4.2.4, graceful-fs@^4.2.9: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.4, graceful-fs@^4.2.9: version "4.2.10" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== @@ -3873,6 +3909,13 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + is-core-module@^2.10.0, is-core-module@^2.8.1, is-core-module@^2.9.0: version "2.11.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" @@ -4020,7 +4063,7 @@ is-weakref@^1.0.2: dependencies: call-bind "^1.0.2" -is-wsl@^2.2.0: +is-wsl@^2.1.1, is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== @@ -4604,6 +4647,13 @@ json5@^2.2.1: resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" + jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -4629,6 +4679,13 @@ kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +klaw-sync@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs "^4.1.11" + klaw@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146" @@ -4813,7 +4870,7 @@ marked@^4.0.10: resolved "https://registry.yarnpkg.com/marked/-/marked-4.1.1.tgz#2f709a4462abf65a283f2453dc1c42ab177d302e" integrity sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw== -matrix-events-sdk@^0.0.1-beta.7: +matrix-events-sdk@0.0.1-beta.7: version "0.0.1-beta.7" resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz#5ffe45eba1f67cc8d7c2377736c728b322524934" integrity sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA== @@ -4863,7 +4920,7 @@ merge2@^1.3.0, merge2@^1.4.1: resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -micromatch@^4.0.4: +micromatch@^4.0.2, micromatch@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== @@ -4980,6 +5037,11 @@ next-tick@1, next-tick@^1.1.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + node-dir@^0.1.10: version "0.1.17" resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.17.tgz#5f5665d93351335caabef8f1c554516cf5f1e4e5" @@ -5064,6 +5126,14 @@ onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" +open@^7.4.2: + version "7.4.2" + resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" + integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q== + dependencies: + is-docker "^2.0.0" + is-wsl "^2.1.1" + open@^8.4.0: version "8.4.0" resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" @@ -5090,6 +5160,11 @@ os-browserify@~0.3.0: resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" integrity sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A== +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + p-limit@^2.0.0, p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" @@ -5185,6 +5260,26 @@ parse-json@^5.2.0: json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" +patch-package@^6.5.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.0.tgz#feb058db56f0005da59cfa316488321de585e88a" + integrity sha512-tC3EqJmo74yKqfsMzELaFwxOAu6FH6t+FzFOsnWAuARm7/n2xB5AOeOueE221eM9gtMuIKMKpF9tBy/X2mNP0Q== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^4.1.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^2.0.0" + fs-extra "^7.0.1" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.6" + open "^7.4.2" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + yaml "^1.10.2" + path-browserify@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" @@ -5205,6 +5300,11 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== +path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== + path-key@^3.0.0, path-key@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" @@ -5270,6 +5370,11 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +postinstall-postinstall@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3" + integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ== + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -5736,6 +5841,13 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" +rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" @@ -5782,7 +5894,7 @@ safer-buffer@^2.1.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -semver@^5.6.0: +semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -5821,6 +5933,13 @@ shasum-object@^1.0.0: dependencies: fast-safe-stringify "^2.0.7" +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== + dependencies: + shebang-regex "^1.0.0" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -5828,6 +5947,11 @@ shebang-command@^2.0.0: dependencies: shebang-regex "^3.0.0" +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== + shebang-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" @@ -6167,6 +6291,13 @@ tiny-glob@^0.2.9: globalyzer "0.1.0" globrex "^0.1.2" +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" @@ -6415,6 +6546,11 @@ universal-user-agent@^6.0.0: resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + update-browserslist-db@^1.0.9: version "1.0.10" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" @@ -6583,6 +6719,13 @@ which-typed-array@^1.1.2: has-tostringtag "^1.0.0" is-typed-array "^1.1.9" +which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -6665,6 +6808,11 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== +yaml@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" + integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== + yargs-parser@^20.2.2, yargs-parser@^20.2.9: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" From f1405e731e4f155a36ca443275a99f3db9112235 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 3 Nov 2022 11:00:47 +0000 Subject: [PATCH 4/4] Fix tests --- src/autodiscovery.ts | 16 +++++++++++----- src/content-helpers.ts | 6 +++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/autodiscovery.ts b/src/autodiscovery.ts index f8e9afd1882..d26e4d5c683 100644 --- a/src/autodiscovery.ts +++ b/src/autodiscovery.ts @@ -44,13 +44,14 @@ enum AutoDiscoveryError { InvalidJson = "Invalid JSON", } -interface ExtraFields { +interface WellKnownConfig extends Omit { state: AutoDiscoveryAction; + error?: IWellKnownConfig["error"] | null; } interface ClientConfig { - "m.homeserver": IWellKnownConfig & ExtraFields; - "m.identity_server": IWellKnownConfig & ExtraFields; + "m.homeserver": WellKnownConfig; + "m.identity_server": WellKnownConfig; } /** @@ -130,7 +131,7 @@ export class AutoDiscovery { * configuration, which may include error states. Rejects on unexpected * failure, not when verification fails. */ - public static async fromDiscoveryConfig(wellknown: any): Promise { + public static async fromDiscoveryConfig(wellknown: any): Promise { // Step 1 is to get the config, which is provided to us here. // We default to an error state to make the first few checks easier to @@ -146,6 +147,7 @@ export class AutoDiscovery { // Technically, we don't have a problem with the identity server // config at this point. state: AutoDiscovery.PROMPT, + error: null, base_url: null, }, }; @@ -197,6 +199,7 @@ export class AutoDiscovery { // Step 4: Now that the homeserver looks valid, update our client config. clientConfig["m.homeserver"] = { state: AutoDiscovery.SUCCESS, + error: null, base_url: hsUrl, }; @@ -249,6 +252,7 @@ export class AutoDiscovery { if (isUrl && isUrl.toString().length > 0) { clientConfig["m.identity_server"] = { state: AutoDiscovery.SUCCESS, + error: null, base_url: isUrl, }; } @@ -286,7 +290,7 @@ export class AutoDiscovery { * configuration, which may include error states. Rejects on unexpected * failure, not when discovery fails. */ - public static async findClientConfig(domain: string): Promise { + public static async findClientConfig(domain: string): Promise { if (!domain || typeof(domain) !== "string" || domain.length === 0) { throw new Error("'domain' must be a string of non-zero length"); } @@ -315,6 +319,7 @@ export class AutoDiscovery { // Technically, we don't have a problem with the identity server // config at this point. state: AutoDiscovery.PROMPT, + error: null, base_url: null, }, }; @@ -330,6 +335,7 @@ export class AutoDiscovery { if (wellknown.action === AutoDiscoveryAction.IGNORE) { clientConfig["m.homeserver"] = { state: AutoDiscovery.PROMPT, + error: null, base_url: null, }; } else { diff --git a/src/content-helpers.ts b/src/content-helpers.ts index 531b939fa2e..4dbb37b212a 100644 --- a/src/content-helpers.ts +++ b/src/content-helpers.ts @@ -121,7 +121,7 @@ export const getTextForLocationEvent = ( uri: string | undefined, assetType: LocationAssetType, timestamp?: number, - description?: string, + description?: string | null, ): string => { const date = `at ${new Date(timestamp!).toISOString()}`; const assetName = assetType === LocationAssetType.Self ? 'User' : undefined; @@ -150,7 +150,7 @@ export const makeLocationContent = ( text?: string, uri?: string, timestamp?: number, - description?: string, + description?: string | null, assetType?: LocationAssetType, ): LegacyLocationEventContent & MLocationEventContent => { const defaultedText = text ?? @@ -187,7 +187,7 @@ export const parseLocationEvent = (wireEventContent: LocationEventWireContent): const assetType = asset?.type ?? LocationAssetType.Self; const fallbackText = text ?? wireEventContent.body; - return makeLocationContent(fallbackText, geoUri, timestamp ?? undefined, description ?? "", assetType); + return makeLocationContent(fallbackText, geoUri, timestamp ?? undefined, description, assetType); }; /**