From a05501a90937a4f73099bf3f8f761d31444ffecc Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 30 May 2022 10:09:13 +0100 Subject: [PATCH 01/12] Convert matrix-utils to typescript --- src/@types/global.d.ts | 7 ++++ src/{matrix-utils.js => matrix-utils.ts} | 46 +++++++++++++----------- tsconfig.json | 2 +- 3 files changed, 33 insertions(+), 22 deletions(-) rename src/{matrix-utils.js => matrix-utils.ts} (75%) diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 7b9c1d9d..35b93a73 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -15,3 +15,10 @@ limitations under the License. */ import "matrix-js-sdk/src/@types/global"; + +declare global { + interface Window { + // TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10 + OLM_OPTIONS: Record; + } +} diff --git a/src/matrix-utils.js b/src/matrix-utils.ts similarity index 75% rename from src/matrix-utils.js rename to src/matrix-utils.ts index dba6f165..4f01e700 100644 --- a/src/matrix-utils.js +++ b/src/matrix-utils.ts @@ -1,20 +1,24 @@ -import matrix from "matrix-js-sdk/src/browser-index"; -import { - GroupCallIntent, - GroupCallType, -} from "matrix-js-sdk/src/browser-index"; -import IndexedDBWorker from "./IndexedDBWorker?worker"; import Olm from "@matrix-org/olm"; import olmWasmPath from "@matrix-org/olm/olm.wasm?url"; +import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb"; +import { WebStorageSessionStore } from "matrix-js-sdk/src/store/session/webstorage"; +import { MemoryStore } from "matrix-js-sdk/src/store/memory"; +import { IndexedDBCryptoStore } from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store"; +import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix"; +import { ICreateClientOpts } from "matrix-js-sdk/src/matrix"; +import { Visibility, Preset, GroupCallIntent } from "matrix-js-sdk"; +import { GroupCallType } from "matrix-js-sdk"; + +import IndexedDBWorker from "./IndexedDBWorker?worker"; export const defaultHomeserver = - import.meta.env.VITE_DEFAULT_HOMESERVER || + (import.meta.env.VITE_DEFAULT_HOMESERVER as string) ?? `${window.location.protocol}//${window.location.host}`; export const defaultHomeserverHost = new URL(defaultHomeserver).host; function waitForSync(client) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const onSync = (state, _old, data) => { if (state === "PREPARED") { resolve(); @@ -28,7 +32,7 @@ function waitForSync(client) { }); } -export async function initClient(clientOptions) { +export async function initClient(clientOptions: ICreateClientOpts) { // TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10 window.OLM_OPTIONS = {}; await Olm.init({ locateFile: () => olmWasmPath }); @@ -39,10 +43,10 @@ export async function initClient(clientOptions) { indexedDB = window.indexedDB; } catch (e) {} - const storeOpts = {}; + const storeOpts = {} as ICreateClientOpts; if (indexedDB && localStorage && !import.meta.env.DEV) { - storeOpts.store = new matrix.IndexedDBStore({ + storeOpts.store = new IndexedDBStore({ indexedDB: window.indexedDB, localStorage: window.localStorage, dbName: "element-call-sync", @@ -51,17 +55,17 @@ export async function initClient(clientOptions) { } if (localStorage) { - storeOpts.sessionStore = new matrix.WebStorageSessionStore(localStorage); + storeOpts.sessionStore = new WebStorageSessionStore(localStorage); } if (indexedDB) { - storeOpts.cryptoStore = new matrix.IndexedDBCryptoStore( + storeOpts.cryptoStore = new IndexedDBCryptoStore( indexedDB, "matrix-js-sdk:crypto" ); } - const client = matrix.createClient({ + const client = createClient({ ...storeOpts, ...clientOptions, useAuthorizationHeader: true, @@ -74,7 +78,7 @@ export async function initClient(clientOptions) { "Error starting matrix client store. Falling back to memory store.", error ); - client.store = new matrix.MemoryStore({ localStorage }); + client.store = new MemoryStore({ localStorage }); await client.store.startup(); } @@ -127,10 +131,10 @@ export function isLocalRoomId(roomId) { return parts[1] === defaultHomeserverHost; } -export async function createRoom(client, name, isPtt = false) { - const { room_id, room_alias } = await client.createRoom({ - visibility: "private", - preset: "public_chat", +export async function createRoom(client: MatrixClient, name, isPtt = false) { + const createRoomResult = await client.createRoom({ + visibility: Visibility.Private, + preset: Preset.PublicChat, name, room_alias_name: roomAliasFromRoomName(name), power_level_content_override: { @@ -161,13 +165,13 @@ export async function createRoom(client, name, isPtt = false) { console.log({ isPtt }); await client.createGroupCall( - room_id, + createRoomResult.room_id, isPtt ? GroupCallType.Voice : GroupCallType.Video, isPtt, GroupCallIntent.Prompt ); - return room_alias || room_id; + return createRoomResult.room_id; } export function getRoomUrl(roomId) { diff --git a/tsconfig.json b/tsconfig.json index 0de9b902..437a94f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es2016", "esModuleInterop": true, - "module": "commonjs", + "module": "es2020", "moduleResolution": "node", "noEmit": true, "noImplicitAny": false, From 7bd95621f1e5f898198792ad59f739dfbd4a2f68 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 30 May 2022 11:28:16 +0100 Subject: [PATCH 02/12] More types --- src/matrix-utils.ts | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index 4f01e700..0faa1c65 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -6,8 +6,10 @@ import { MemoryStore } from "matrix-js-sdk/src/store/memory"; import { IndexedDBCryptoStore } from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store"; import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix"; import { ICreateClientOpts } from "matrix-js-sdk/src/matrix"; +import { ClientEvent } from "matrix-js-sdk/src/client"; import { Visibility, Preset, GroupCallIntent } from "matrix-js-sdk"; import { GroupCallType } from "matrix-js-sdk"; +import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync"; import IndexedDBWorker from "./IndexedDBWorker?worker"; @@ -17,22 +19,28 @@ export const defaultHomeserver = export const defaultHomeserverHost = new URL(defaultHomeserver).host; -function waitForSync(client) { +function waitForSync(client: MatrixClient) { return new Promise((resolve, reject) => { - const onSync = (state, _old, data) => { + const onSync = ( + state: SyncState, + _old: SyncState, + data: ISyncStateData + ) => { if (state === "PREPARED") { resolve(); - client.removeListener("sync", onSync); + client.removeListener(ClientEvent.Sync, onSync); } else if (state === "ERROR") { reject(data?.error); - client.removeListener("sync", onSync); + client.removeListener(ClientEvent.Sync, onSync); } }; - client.on("sync", onSync); + client.on(ClientEvent.Sync, onSync); }); } -export async function initClient(clientOptions: ICreateClientOpts) { +export async function initClient( + clientOptions: ICreateClientOpts +): Promise { // TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10 window.OLM_OPTIONS = {}; await Olm.init({ locateFile: () => olmWasmPath }); @@ -97,7 +105,7 @@ export async function initClient(clientOptions: ICreateClientOpts) { return client; } -export function roomAliasFromRoomName(roomName) { +export function roomAliasFromRoomName(roomName: string): string { return roomName .trim() .replace(/\s/g, "-") @@ -105,7 +113,7 @@ export function roomAliasFromRoomName(roomName) { .toLowerCase(); } -export function roomNameFromRoomId(roomId) { +export function roomNameFromRoomId(roomId: string): string { return roomId .match(/([^:]+):.*$/)[1] .substring(1) @@ -117,7 +125,7 @@ export function roomNameFromRoomId(roomId) { .toLowerCase(); } -export function isLocalRoomId(roomId) { +export function isLocalRoomId(roomId: string): boolean { if (!roomId) { return false; } @@ -131,7 +139,11 @@ export function isLocalRoomId(roomId) { return parts[1] === defaultHomeserverHost; } -export async function createRoom(client: MatrixClient, name, isPtt = false) { +export async function createRoom( + client: MatrixClient, + name: string, + isPtt = false +): Promise { const createRoomResult = await client.createRoom({ visibility: Visibility.Private, preset: Preset.PublicChat, @@ -174,7 +186,7 @@ export async function createRoom(client: MatrixClient, name, isPtt = false) { return createRoomResult.room_id; } -export function getRoomUrl(roomId) { +export function getRoomUrl(roomId: string): string { if (roomId.startsWith("#")) { const [localPart, host] = roomId.replace("#", "").split(":"); @@ -188,7 +200,11 @@ export function getRoomUrl(roomId) { } } -export function getAvatarUrl(client, mxcUrl, avatarSize = 96) { +export function getAvatarUrl( + client: MatrixClient, + mxcUrl: string, + avatarSize = 96 +): string { const width = Math.floor(avatarSize * window.devicePixelRatio); const height = Math.floor(avatarSize * window.devicePixelRatio); return mxcUrl && client.mxcUrlToHttp(mxcUrl, width, height, "crop"); From 2cdbeb6f120bbb9ddd5413052b6c722b667d74ec Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 30 May 2022 11:41:59 +0100 Subject: [PATCH 03/12] Fix imports --- src/matrix-utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index 0faa1c65..e3617c51 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -7,8 +7,11 @@ import { IndexedDBCryptoStore } from "matrix-js-sdk/src/crypto/store/indexeddb-c import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix"; import { ICreateClientOpts } from "matrix-js-sdk/src/matrix"; import { ClientEvent } from "matrix-js-sdk/src/client"; -import { Visibility, Preset, GroupCallIntent } from "matrix-js-sdk"; -import { GroupCallType } from "matrix-js-sdk"; +import { Visibility, Preset } from "matrix-js-sdk/src/@types/partials"; +import { + GroupCallIntent, + GroupCallType, +} from "matrix-js-sdk/src/webrtc/groupCall"; import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync"; import IndexedDBWorker from "./IndexedDBWorker?worker"; From 7ed2f9bd9a092760cbb80f848ec38c9b7f500af0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 30 May 2022 11:46:27 +0100 Subject: [PATCH 04/12] Lower timeout on js-sdk API call to 5s --- src/matrix-utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index e3617c51..e3b236fe 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -80,6 +80,9 @@ export async function initClient( ...storeOpts, ...clientOptions, useAuthorizationHeader: true, + // Use a relatively low timeout for API calls: this is a realtime + // so we don't want API calls taking ages, we'd rather they just fail. + localTimeoutMs: 5000, }); try { From 9edc1acc9000635739070abccc32205ae1cb99f7 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 1 Jun 2022 09:07:00 +0100 Subject: [PATCH 05/12] Add type to indexeddb variable --- src/matrix-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index e3617c51..7f98f9f1 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -48,7 +48,7 @@ export async function initClient( window.OLM_OPTIONS = {}; await Olm.init({ locateFile: () => olmWasmPath }); - let indexedDB; + let indexedDB: IDBFactory; try { indexedDB = window.indexedDB; From 2cf40ff0b813162e741414c70646f3bfacaec896 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 1 Jun 2022 09:29:47 +0100 Subject: [PATCH 06/12] Fix room creation The room alias is not part of the spec. Synapse returns it anyway, but it's not part of the js-sdk types. We don't really need the server to tell us what the alias is, so just generate it locally instead. --- src/home/RegisteredView.jsx | 4 ++-- src/home/UnauthenticatedView.jsx | 4 ++-- src/matrix-utils.ts | 15 +++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/home/RegisteredView.jsx b/src/home/RegisteredView.jsx index 0fc1b3e2..aaa8a339 100644 --- a/src/home/RegisteredView.jsx +++ b/src/home/RegisteredView.jsx @@ -15,7 +15,7 @@ limitations under the License. */ import React, { useState, useCallback } from "react"; -import { createRoom, roomAliasFromRoomName } from "../matrix-utils"; +import { createRoom, roomAliasLocalpartFromRoomName } from "../matrix-utils"; import { useGroupCallRooms } from "./useGroupCallRooms"; import { Header, HeaderLogo, LeftNav, RightNav } from "../Header"; import commonStyles from "./common.module.css"; @@ -56,7 +56,7 @@ export function RegisteredView({ client }) { submit().catch((error) => { if (error.errcode === "M_ROOM_IN_USE") { - setExistingRoomId(roomAliasFromRoomName(roomName)); + setExistingRoomId(roomAliasLocalpartFromRoomName(roomName)); setLoading(false); setError(undefined); modalState.open(); diff --git a/src/home/UnauthenticatedView.jsx b/src/home/UnauthenticatedView.jsx index 51e8eedd..aea8ae84 100644 --- a/src/home/UnauthenticatedView.jsx +++ b/src/home/UnauthenticatedView.jsx @@ -22,7 +22,7 @@ import { useHistory } from "react-router-dom"; import { FieldRow, InputField, ErrorMessage } from "../input/Input"; import { Button } from "../button"; import { randomString } from "matrix-js-sdk/src/randomstring"; -import { createRoom, roomAliasFromRoomName } from "../matrix-utils"; +import { createRoom, roomAliasLocalpartFromRoomName } from "../matrix-utils"; import { useInteractiveRegistration } from "../auth/useInteractiveRegistration"; import { useModalTriggerState } from "../Modal"; import { JoinExistingCallModal } from "./JoinExistingCallModal"; @@ -75,7 +75,7 @@ export function UnauthenticatedView() { if (error.errcode === "M_ROOM_IN_USE") { setOnFinished(() => () => { setClient(client, session); - const aliasLocalpart = roomAliasFromRoomName(roomName); + const aliasLocalpart = roomAliasLocalpartFromRoomName(roomName); const [, serverName] = client.getUserId().split(":"); history.push(`/room/#${aliasLocalpart}:${serverName}`); }); diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index 7f98f9f1..2f7897b8 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -108,7 +108,7 @@ export async function initClient( return client; } -export function roomAliasFromRoomName(roomName: string): string { +export function roomAliasLocalpartFromRoomName(roomName: string): string { return roomName .trim() .replace(/\s/g, "-") @@ -116,6 +116,13 @@ export function roomAliasFromRoomName(roomName: string): string { .toLowerCase(); } +export function fullAliasFromRoomName( + roomName: string, + client: MatrixClient +): string { + return `#${roomAliasLocalpartFromRoomName(roomName)}:${client.getDomain()}`; +} + export function roomNameFromRoomId(roomId: string): string { return roomId .match(/([^:]+):.*$/)[1] @@ -151,7 +158,7 @@ export async function createRoom( visibility: Visibility.Private, preset: Preset.PublicChat, name, - room_alias_name: roomAliasFromRoomName(name), + room_alias_name: roomAliasLocalpartFromRoomName(name), power_level_content_override: { invite: 100, kick: 100, @@ -177,7 +184,7 @@ export async function createRoom( }, }); - console.log({ isPtt }); + console.log(`Creating ${isPtt ? "PTT" : "video"} group call room`); await client.createGroupCall( createRoomResult.room_id, @@ -186,7 +193,7 @@ export async function createRoom( GroupCallIntent.Prompt ); - return createRoomResult.room_id; + return fullAliasFromRoomName(name, client); } export function getRoomUrl(roomId: string): string { From 7ee2f630db0e97f4f61c79a2366ae2f75c958fb8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 1 Jun 2022 09:59:59 +0100 Subject: [PATCH 07/12] Add more typers to useInteractiveLogin otherwise apparently Typescript can't trace the MatrixClient type through. --- src/auth/useInteractiveLogin.ts | 68 +++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/auth/useInteractiveLogin.ts b/src/auth/useInteractiveLogin.ts index b4e3ad29..2cfe78cd 100644 --- a/src/auth/useInteractiveLogin.ts +++ b/src/auth/useInteractiveLogin.ts @@ -16,40 +16,50 @@ limitations under the License. import { useCallback } from "react"; import matrix, { InteractiveAuth } from "matrix-js-sdk/src/browser-index"; +import { MatrixClient } from "matrix-js-sdk"; import { initClient, defaultHomeserver } from "../matrix-utils"; +import { Session } from "../ClientContext"; export const useInteractiveLogin = () => - useCallback( - async (homeserver: string, username: string, password: string) => { - const authClient = matrix.createClient(homeserver); + useCallback< + ( + homeserver: string, + username: string, + password: string + ) => Promise<[MatrixClient, Session]> + >(async (homeserver: string, username: string, password: string) => { + const authClient = matrix.createClient(homeserver); - const interactiveAuth = new InteractiveAuth({ - matrixClient: authClient, - doRequest: () => - authClient.login("m.login.password", { - identifier: { - type: "m.id.user", - user: username, - }, - password, - }), - }); + const interactiveAuth = new InteractiveAuth({ + matrixClient: authClient, + doRequest: () => + authClient.login("m.login.password", { + identifier: { + type: "m.id.user", + user: username, + }, + password, + }), + }); - /* eslint-disable camelcase */ - const { user_id, access_token, device_id } = - await interactiveAuth.attemptAuth(); - const session = { user_id, access_token, device_id }; + /* eslint-disable camelcase */ + const { user_id, access_token, device_id } = + await interactiveAuth.attemptAuth(); + const session = { + user_id, + access_token, + device_id, + passwordlessUser: false, + }; - const client = await initClient({ - baseUrl: defaultHomeserver, - accessToken: access_token, - userId: user_id, - deviceId: device_id, - }); - /* eslint-enable camelcase */ + const client = await initClient({ + baseUrl: defaultHomeserver, + accessToken: access_token, + userId: user_id, + deviceId: device_id, + }); + /* eslint-enable camelcase */ - return [client, session]; - }, - [] - ); + return [client, session]; + }, []); From f07ee54e05cc117bb206d2a6ff2251942f61877b Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 1 Jun 2022 10:04:49 +0100 Subject: [PATCH 08/12] Finish sentence Co-authored-by: Robin --- src/matrix-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index e3b236fe..3d295e56 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -80,7 +80,7 @@ export async function initClient( ...storeOpts, ...clientOptions, useAuthorizationHeader: true, - // Use a relatively low timeout for API calls: this is a realtime + // Use a relatively low timeout for API calls: this is a realtime application // so we don't want API calls taking ages, we'd rather they just fail. localTimeoutMs: 5000, }); From 0411e1cac8a4b30ec87059d524c2b6201c2d1529 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 1 Jun 2022 15:55:02 +0100 Subject: [PATCH 09/12] Fix app when built in production mode The recent typescripting appears to have caused the typescript compiler to get confused about dependency references and start refwrencing things like CRYPTO_ENABLED in the js-sdk before it's defined them. This avoids using things from the (javascript) browser-index import and instead pulls everything in from the typescript files, then fixes the resulting type failures, (in some cases with hacks). --- src/auth/useInteractiveLogin.ts | 12 ++++++++---- src/auth/useInteractiveRegistration.ts | 11 +++++++---- src/main.jsx | 6 ++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/auth/useInteractiveLogin.ts b/src/auth/useInteractiveLogin.ts index 2cfe78cd..cf230383 100644 --- a/src/auth/useInteractiveLogin.ts +++ b/src/auth/useInteractiveLogin.ts @@ -15,8 +15,8 @@ limitations under the License. */ import { useCallback } from "react"; -import matrix, { InteractiveAuth } from "matrix-js-sdk/src/browser-index"; -import { MatrixClient } from "matrix-js-sdk"; +import { InteractiveAuth } from "matrix-js-sdk/src/interactive-auth"; +import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix"; import { initClient, defaultHomeserver } from "../matrix-utils"; import { Session } from "../ClientContext"; @@ -29,7 +29,7 @@ export const useInteractiveLogin = () => password: string ) => Promise<[MatrixClient, Session]> >(async (homeserver: string, username: string, password: string) => { - const authClient = matrix.createClient(homeserver); + const authClient = createClient(homeserver); const interactiveAuth = new InteractiveAuth({ matrixClient: authClient, @@ -41,11 +41,15 @@ export const useInteractiveLogin = () => }, password, }), + stateUpdated: null, + requestEmailToken: null, }); + // XXX: This claims to return an IAuthData which contains none of these + // things - the js-sdk types may be wrong? /* eslint-disable camelcase */ const { user_id, access_token, device_id } = - await interactiveAuth.attemptAuth(); + (await interactiveAuth.attemptAuth()) as any; const session = { user_id, access_token, diff --git a/src/auth/useInteractiveRegistration.ts b/src/auth/useInteractiveRegistration.ts index 2386b531..320055bf 100644 --- a/src/auth/useInteractiveRegistration.ts +++ b/src/auth/useInteractiveRegistration.ts @@ -15,8 +15,8 @@ limitations under the License. */ import { useState, useEffect, useCallback, useRef } from "react"; -import matrix, { InteractiveAuth } from "matrix-js-sdk/src/browser-index"; -import { MatrixClient } from "matrix-js-sdk/src/client"; +import { InteractiveAuth } from "matrix-js-sdk/src/interactive-auth"; +import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix"; import { initClient, defaultHomeserver } from "../matrix-utils"; import { Session } from "../ClientContext"; @@ -37,7 +37,7 @@ export const useInteractiveRegistration = (): [ const authClient = useRef(); if (!authClient.current) { - authClient.current = matrix.createClient(defaultHomeserver); + authClient.current = createClient(defaultHomeserver); } useEffect(() => { @@ -81,11 +81,14 @@ export const useInteractiveRegistration = (): [ }); } }, + requestEmailToken: null, }); + // XXX: This claims to return an IAuthData which contains none of these + // things - the js-sdk types may be wrong? /* eslint-disable camelcase */ const { user_id, access_token, device_id } = - await interactiveAuth.attemptAuth(); + (await interactiveAuth.attemptAuth()) as any; const client = await initClient({ baseUrl: defaultHomeserver, diff --git a/src/main.jsx b/src/main.jsx index d9a87d26..08c48798 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -14,6 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +// We need to import this somewhere, once, so that the correct 'request' +// function gets set. It needs to be not in the same file as we use +// createClient, or the typescript transpiler gets confused about +// dependency references. +import "matrix-js-sdk/src/browser-index"; + import React from "react"; import ReactDOM from "react-dom"; import { createBrowserHistory } from "history"; From 017ec139811d2bb6581e648d70b7f452491e5ad2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 1 Jun 2022 16:05:58 +0100 Subject: [PATCH 10/12] Disable typescript warnings --- src/auth/useInteractiveLogin.ts | 2 +- src/auth/useInteractiveRegistration.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auth/useInteractiveLogin.ts b/src/auth/useInteractiveLogin.ts index cf230383..6379c67c 100644 --- a/src/auth/useInteractiveLogin.ts +++ b/src/auth/useInteractiveLogin.ts @@ -47,7 +47,7 @@ export const useInteractiveLogin = () => // XXX: This claims to return an IAuthData which contains none of these // things - the js-sdk types may be wrong? - /* eslint-disable camelcase */ + /* eslint-disable camelcase,@typescript-eslint/no-explicit-any */ const { user_id, access_token, device_id } = (await interactiveAuth.attemptAuth()) as any; const session = { diff --git a/src/auth/useInteractiveRegistration.ts b/src/auth/useInteractiveRegistration.ts index 320055bf..af611f9d 100644 --- a/src/auth/useInteractiveRegistration.ts +++ b/src/auth/useInteractiveRegistration.ts @@ -86,7 +86,7 @@ export const useInteractiveRegistration = (): [ // XXX: This claims to return an IAuthData which contains none of these // things - the js-sdk types may be wrong? - /* eslint-disable camelcase */ + /* eslint-disable camelcase,@typescript-eslint/no-explicit-any */ const { user_id, access_token, device_id } = (await interactiveAuth.attemptAuth()) as any; From 7d87b8d1e5a7ad6470647ff0431f121288ebc83b Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 2 Jun 2022 13:53:19 -0400 Subject: [PATCH 11/12] =?UTF-8?q?'Webcam'=20=E2=86=92=20'Camera'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/room/VideoPreview.jsx | 8 ++++---- src/room/VideoPreview.module.css | 2 +- src/settings/SettingsModal.jsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/room/VideoPreview.jsx b/src/room/VideoPreview.jsx index 996e4aed..c6f685bb 100644 --- a/src/room/VideoPreview.jsx +++ b/src/room/VideoPreview.jsx @@ -50,13 +50,13 @@ export function VideoPreview({