This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ declare global {
100100 mxOnRecaptchaLoaded ?: ( ) => void ;
101101 electron ?: Electron ;
102102 mxSendSentryReport : ( userText : string , issueUrl : string , error : Error ) => Promise < void > ;
103+ mxLoginWithAccessToken : ( hsUrl : string , accessToken : string ) => Promise < void > ;
103104 }
104105
105106 interface DesktopCapturerSource {
Original file line number Diff line number Diff line change @@ -538,8 +538,8 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
538538 * fires on_logging_in, optionally clears localstorage, persists new credentials
539539 * to localstorage, starts the new client.
540540 *
541- * @param {MatrixClientCreds } credentials
542- * @param {Boolean } clearStorage
541+ * @param {IMatrixClientCreds } credentials
542+ * @param {Boolean } clearStorageEnabled
543543 *
544544 * @returns {Promise } promise which resolves to the new MatrixClient once it has been started
545545 */
@@ -918,3 +918,17 @@ export function stopMatrixClient(unsetClient = true): void {
918918 }
919919 }
920920}
921+
922+ // Utility method to perform a login with an existing access_token
923+ window . mxLoginWithAccessToken = async ( hsUrl : string , accessToken : string ) : Promise < void > => {
924+ const tempClient = createClient ( {
925+ baseUrl : hsUrl ,
926+ accessToken,
927+ } ) ;
928+ const { user_id : userId } = await tempClient . whoami ( ) ;
929+ await doSetLoggedIn ( {
930+ homeserverUrl : hsUrl ,
931+ accessToken,
932+ userId,
933+ } , true ) ;
934+ } ;
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ import { logger } from "matrix-js-sdk/src/logger";
4040
4141export interface IMatrixClientCreds {
4242 homeserverUrl : string ;
43- identityServerUrl : string ;
43+ identityServerUrl ? : string ;
4444 userId : string ;
4545 deviceId ?: string ;
4646 accessToken : string ;
You can’t perform that action at this time.
0 commit comments