diff --git a/src/matrix/login/LoginMethod.ts b/src/matrix/login/LoginMethod.ts index 342632a6..c4456180 100644 --- a/src/matrix/login/LoginMethod.ts +++ b/src/matrix/login/LoginMethod.ts @@ -19,5 +19,5 @@ import type {HomeServerApi} from "../net/HomeServerApi.js"; export interface ILoginMethod { homeserver: string; - login(hsApi: HomeServerApi, deviceName: string, log: ILogItem): Response["body"]; + login(hsApi: HomeServerApi, deviceName: string, log: ILogItem): Promise; } diff --git a/src/matrix/login/PasswordLoginMethod.js b/src/matrix/login/PasswordLoginMethod.ts similarity index 54% rename from src/matrix/login/PasswordLoginMethod.js rename to src/matrix/login/PasswordLoginMethod.ts index f147f229..d9edd3e7 100644 --- a/src/matrix/login/PasswordLoginMethod.js +++ b/src/matrix/login/PasswordLoginMethod.ts @@ -14,16 +14,22 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {LoginMethod} from "./LoginMethod"; +import {ILogItem} from "../../logging/types"; +import {ILoginMethod} from "./LoginMethod"; +import {HomeServerApi} from "../net/HomeServerApi.js"; -export class PasswordLoginMethod extends LoginMethod { - constructor(options) { - super(options); - this.username = options.username; - this.password = options.password; +export class PasswordLoginMethod implements ILoginMethod { + public username: string; + public password: string; + public homeserver: string; + + constructor({username, password, homeserver}: {username: string, password: string, homeserver: string}) { + this.username = username; + this.password = password; + this.homeserver = homeserver; } - async login(hsApi, deviceName, log) { + async login(hsApi: HomeServerApi, deviceName: string, log: ILogItem) { return await hsApi.passwordLogin(this.username, this.password, deviceName, {log}).response(); } }