Add startRegistration method

This commit is contained in:
RMidhunSuresh 2022-01-05 12:45:41 +05:30
parent 8ab8726b8f
commit 170d7a5e55

View File

@ -30,6 +30,7 @@ import {PasswordLoginMethod} from "./login/PasswordLoginMethod";
import {TokenLoginMethod} from "./login/TokenLoginMethod"; import {TokenLoginMethod} from "./login/TokenLoginMethod";
import {SSOLoginHelper} from "./login/SSOLoginHelper"; import {SSOLoginHelper} from "./login/SSOLoginHelper";
import {getDehydratedDevice} from "./e2ee/Dehydration.js"; import {getDehydratedDevice} from "./e2ee/Dehydration.js";
import {Registration} from "./registration/Registration";
export const LoadStatus = createEnum( export const LoadStatus = createEnum(
"NotLoading", "NotLoading",
@ -131,6 +132,19 @@ export class Client {
}); });
} }
async startRegistration(homeserver, username, password, initialDeviceDisplayName) {
const request = this._platform.request;
const hsApi = new HomeServerApi({homeserver, request});
const registration = new Registration(hsApi, {
username,
password,
initialDeviceDisplayName,
inhibitLogin: true
});
let stage = await registration.start();
return stage;
}
async startWithLogin(loginMethod, {inspectAccountSetup} = {}) { async startWithLogin(loginMethod, {inspectAccountSetup} = {}) {
const currentStatus = this._status.get(); const currentStatus = this._status.get();
if (currentStatus !== LoadStatus.LoginFailed && if (currentStatus !== LoadStatus.LoginFailed &&