Convert TokenLoginMethod to ts

This commit is contained in:
RMidhunSuresh 2021-11-24 13:56:47 +05:30
parent e4c443c73a
commit 64037cb32a
2 changed files with 12 additions and 7 deletions

View File

@ -27,7 +27,7 @@ import {RequestScheduler} from "./net/RequestScheduler.js";
import {Sync, SyncStatus} from "./Sync.js"; import {Sync, SyncStatus} from "./Sync.js";
import {Session} from "./Session.js"; import {Session} from "./Session.js";
import {PasswordLoginMethod} from "./login/PasswordLoginMethod.js"; import {PasswordLoginMethod} from "./login/PasswordLoginMethod.js";
import {TokenLoginMethod} from "./login/TokenLoginMethod.js"; import {TokenLoginMethod} from "./login/TokenLoginMethod";
import {SSOLoginHelper} from "./login/SSOLoginHelper.js"; import {SSOLoginHelper} from "./login/SSOLoginHelper.js";
import {getDehydratedDevice} from "./e2ee/Dehydration.js"; import {getDehydratedDevice} from "./e2ee/Dehydration.js";

View File

@ -14,16 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {LoginMethod} from "./LoginMethod";
import {makeTxnId} from "../common.js"; import {makeTxnId} from "../common.js";
import {ILogItem} from "../../logging/types";
import {ILoginMethod} from "./LoginMethod";
import {HomeServerApi} from "../net/HomeServerApi.js";
export class TokenLoginMethod extends LoginMethod { export class TokenLoginMethod implements ILoginMethod {
constructor(options) { public readonly homeserver: string;
super(options); private readonly _loginToken: string;
this._loginToken = options.loginToken;
constructor({ homeserver, loginToken }: { homeserver: string, loginToken: string}) {
this.homeserver = homeserver;
this._loginToken = loginToken;
} }
async login(hsApi, deviceName, log) { async login(hsApi: HomeServerApi, deviceName: string, log: ILogItem): Promise<Response["body"]> {
return await hsApi.tokenLogin(this._loginToken, makeTxnId(), deviceName, {log}).response(); return await hsApi.tokenLogin(this._loginToken, makeTxnId(), deviceName, {log}).response();
} }
} }