diff --git a/config/element_io_preview.json b/config/element_io_preview.json index 7afb8f69..c65f252a 100644 --- a/config/element_io_preview.json +++ b/config/element_io_preview.json @@ -4,5 +4,9 @@ "base_url": "https://call.ems.host", "server_name": "call.ems.host" } + }, + "temp_sfu": { + "user_id": "@sfu:call.ems.host", + "device_id": "YNZDLSEQMP" } } diff --git a/package.json b/package.json index 90e02c37..c0da56fb 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "i18next": "^21.10.0", "i18next-browser-languagedetector": "^6.1.8", "i18next-http-backend": "^1.4.4", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#2c8eece5ca5333c6e6a14e8ed53f359ed0e9e9bf", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#e4cc17feb5350d2e01df62110f139508cd8ac6ad", "matrix-widget-api": "^1.0.0", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", diff --git a/src/ClientContext.tsx b/src/ClientContext.tsx index fa83f5d9..8e9a5d97 100644 --- a/src/ClientContext.tsx +++ b/src/ClientContext.tsx @@ -33,7 +33,6 @@ import { ErrorView } from "./FullScreenView"; import { initClient, CryptoStoreIntegrityError, - fallbackICEServerAllowed, } from "./matrix-utils"; import { widget } from "./widget"; import { PosthogAnalytics, RegistrationType } from "./PosthogAnalytics"; @@ -143,7 +142,6 @@ export const ClientProvider: FC = ({ children }) => { accessToken: access_token, userId: user_id, deviceId: device_id, - fallbackICEServerAllowed: fallbackICEServerAllowed, }, true ), @@ -159,7 +157,6 @@ export const ClientProvider: FC = ({ children }) => { accessToken: access_token, userId: user_id, deviceId: device_id, - fallbackICEServerAllowed: fallbackICEServerAllowed, }, false // Don't need the crypto store just to log out ); diff --git a/src/config/ConfigOptions.ts b/src/config/ConfigOptions.ts index e799d59d..ab4c7787 100644 --- a/src/config/ConfigOptions.ts +++ b/src/config/ConfigOptions.ts @@ -28,6 +28,15 @@ export interface ConfigOptions { server_name: string; }; }; + + /** + * Sets the client's preferred SFU + * TEMPORARY: Will be removed in favour of getting SFUs from the homeserver + */ + temp_sfu?: { + user_id: string; + device_id: string; + }; } // Overrides members from ConfigOptions that are always provided by the diff --git a/src/matrix-utils.ts b/src/matrix-utils.ts index 2d124a01..772e52f5 100644 --- a/src/matrix-utils.ts +++ b/src/matrix-utils.ts @@ -76,17 +76,22 @@ export async function initClient( indexedDB = window.indexedDB; } catch (e) {} - const storeOpts = {} as ICreateClientOpts; + // options we always pass to the client (stuff that we need in order to work) + const baseOpts = { + fallbackICEServerAllowed: fallbackICEServerAllowed, + localSfuUserId: Config.get().temp_sfu.user_id, + localSfuDeviceId: Config.get().temp_sfu.device_id, + } as ICreateClientOpts; if (indexedDB && localStorage && !import.meta.env.DEV) { - storeOpts.store = new IndexedDBStore({ + baseOpts.store = new IndexedDBStore({ indexedDB: window.indexedDB, localStorage, dbName: SYNC_STORE_NAME, workerFactory: () => new IndexedDBWorker(), }); } else if (localStorage) { - storeOpts.store = new MemoryStore({ localStorage }); + baseOpts.store = new MemoryStore({ localStorage }); } // Check whether we have crypto data store. If we are restoring a session @@ -118,14 +123,14 @@ export async function initClient( } if (indexedDB) { - storeOpts.cryptoStore = new IndexedDBCryptoStore( + baseOpts.cryptoStore = new IndexedDBCryptoStore( indexedDB, CRYPTO_STORE_NAME ); } else if (localStorage) { - storeOpts.cryptoStore = new LocalStorageCryptoStore(localStorage); + baseOpts.cryptoStore = new LocalStorageCryptoStore(localStorage); } else { - storeOpts.cryptoStore = new MemoryCryptoStore(); + baseOpts.cryptoStore = new MemoryCryptoStore(); } // XXX: we read from the URL params in RoomPage too: @@ -139,7 +144,7 @@ export async function initClient( } const client = createClient({ - ...storeOpts, + ...baseOpts, ...clientOptions, useAuthorizationHeader: true, // Use a relatively low timeout for API calls: this is a realtime app diff --git a/yarn.lock b/yarn.lock index 6095d369..d2323e74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1821,6 +1821,11 @@ resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0" integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw== +"@matrix-org/matrix-sdk-crypto-js@^0.1.0-alpha.2": + version "0.1.0-alpha.2" + resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.0-alpha.2.tgz#a09d0fea858e817da971a3c9f904632ef7b49eb6" + integrity sha512-oVkBCh9YP7H9i4gAoQbZzswniczfo/aIptNa4dxRi4Ff9lSvUCFv6Hvzi7C+90c0/PWZLXjIDTIAWZYmwyd2fA== + "@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz": version "3.2.8" resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz#8d53636d045e1776e2a2ec6613e57330dd9ce856" @@ -10266,11 +10271,12 @@ matrix-events-sdk@0.0.1: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd" integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#2c8eece5ca5333c6e6a14e8ed53f359ed0e9e9bf": - version "21.2.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/2c8eece5ca5333c6e6a14e8ed53f359ed0e9e9bf" +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#e4cc17feb5350d2e01df62110f139508cd8ac6ad": + version "22.0.0" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/e4cc17feb5350d2e01df62110f139508cd8ac6ad" dependencies: "@babel/runtime" "^7.12.5" + "@matrix-org/matrix-sdk-crypto-js" "^0.1.0-alpha.2" another-json "^0.2.0" bs58 "^5.0.0" content-type "^1.0.4" @@ -10281,6 +10287,7 @@ matrix-events-sdk@0.0.1: qs "^6.9.6" sdp-transform "^2.14.1" unhomoglyph "^1.0.6" + uuid "9" matrix-widget-api@^1.0.0: version "1.1.1" @@ -14183,6 +14190,11 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== +uuid@9: + version "9.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" + integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== + uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"