From 91f2a96403e466be902d5a1e4015dd5d421cb8ae Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 24 Nov 2021 13:40:04 +0530 Subject: [PATCH] Make LoginMethod an interface --- .../login/{LoginMethod.js => LoginMethod.ts} | 17 +++++------------ src/matrix/login/PasswordLoginMethod.js | 2 +- src/matrix/login/TokenLoginMethod.js | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) rename src/matrix/login/{LoginMethod.js => LoginMethod.ts} (61%) diff --git a/src/matrix/login/LoginMethod.js b/src/matrix/login/LoginMethod.ts similarity index 61% rename from src/matrix/login/LoginMethod.js rename to src/matrix/login/LoginMethod.ts index ece18871..342632a6 100644 --- a/src/matrix/login/LoginMethod.js +++ b/src/matrix/login/LoginMethod.ts @@ -14,17 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -export class LoginMethod { - constructor({homeserver}) { - this.homeserver = homeserver; - } +import type {ILogItem} from "../../logging/types"; +import type {HomeServerApi} from "../net/HomeServerApi.js"; - // eslint-disable-next-line no-unused-vars - async login(hsApi, deviceName, log) { - /* - Regardless of the login method, SessionContainer.startWithLogin() - can do SomeLoginMethod.login() - */ - throw("Not Implemented"); - } +export interface ILoginMethod { + homeserver: string; + login(hsApi: HomeServerApi, deviceName: string, log: ILogItem): Response["body"]; } diff --git a/src/matrix/login/PasswordLoginMethod.js b/src/matrix/login/PasswordLoginMethod.js index 5c90ccf8..f147f229 100644 --- a/src/matrix/login/PasswordLoginMethod.js +++ b/src/matrix/login/PasswordLoginMethod.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {LoginMethod} from "./LoginMethod.js"; +import {LoginMethod} from "./LoginMethod"; export class PasswordLoginMethod extends LoginMethod { constructor(options) { diff --git a/src/matrix/login/TokenLoginMethod.js b/src/matrix/login/TokenLoginMethod.js index e55cedcf..1c623045 100644 --- a/src/matrix/login/TokenLoginMethod.js +++ b/src/matrix/login/TokenLoginMethod.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {LoginMethod} from "./LoginMethod.js"; +import {LoginMethod} from "./LoginMethod"; import {makeTxnId} from "../common.js"; export class TokenLoginMethod extends LoginMethod {