forked from mystiq/hydrogen-web
Make methods private + some props readonly
This commit is contained in:
parent
8a3c0afba6
commit
89a97537b0
2 changed files with 8 additions and 8 deletions
|
@ -28,9 +28,9 @@ import type {
|
||||||
type FlowSelector = (flows: RegistrationFlow[]) => RegistrationFlow | void;
|
type FlowSelector = (flows: RegistrationFlow[]) => RegistrationFlow | void;
|
||||||
|
|
||||||
export class Registration {
|
export class Registration {
|
||||||
private _hsApi: HomeServerApi;
|
private readonly _hsApi: HomeServerApi;
|
||||||
private _accountDetails: AccountDetails;
|
private readonly _accountDetails: AccountDetails;
|
||||||
private _flowSelector: FlowSelector;
|
private readonly _flowSelector: FlowSelector;
|
||||||
private _sessionInfo?: RegistrationResponseSuccess
|
private _sessionInfo?: RegistrationResponseSuccess
|
||||||
|
|
||||||
constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, flowSelector?: FlowSelector) {
|
constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, flowSelector?: FlowSelector) {
|
||||||
|
@ -64,7 +64,7 @@ export class Registration {
|
||||||
return this.parseRegistrationResponse(registrationResponse, stage);
|
return this.parseRegistrationResponse(registrationResponse, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseStagesFromResponse(response: RegistrationResponseMoreDataNeeded): BaseRegistrationStage {
|
private parseStagesFromResponse(response: RegistrationResponseMoreDataNeeded): BaseRegistrationStage {
|
||||||
const { session, params } = response;
|
const { session, params } = response;
|
||||||
const flow = this._flowSelector(response.flows);
|
const flow = this._flowSelector(response.flows);
|
||||||
if (!flow) {
|
if (!flow) {
|
||||||
|
@ -89,7 +89,7 @@ export class Registration {
|
||||||
return firstStage!;
|
return firstStage!;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseRegistrationResponse(response: RegistrationResponse, currentStage: BaseRegistrationStage) {
|
private async parseRegistrationResponse(response: RegistrationResponse, currentStage: BaseRegistrationStage) {
|
||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 200:
|
case 200:
|
||||||
this._sessionInfo = response;
|
this._sessionInfo = response;
|
||||||
|
|
|
@ -18,11 +18,11 @@ import type {HomeServerApi} from "../../net/HomeServerApi";
|
||||||
import type {AccountDetails, AuthenticationData, RegistrationParams} from "../types";
|
import type {AccountDetails, AuthenticationData, RegistrationParams} from "../types";
|
||||||
|
|
||||||
export abstract class BaseRegistrationStage {
|
export abstract class BaseRegistrationStage {
|
||||||
protected _hsApi: HomeServerApi;
|
protected readonly _hsApi: HomeServerApi;
|
||||||
protected _accountDetails: AccountDetails;
|
protected readonly _accountDetails: AccountDetails;
|
||||||
protected _session: string;
|
protected _session: string;
|
||||||
protected _nextStage: BaseRegistrationStage;
|
protected _nextStage: BaseRegistrationStage;
|
||||||
protected _params?: Record<string, any>
|
protected readonly _params?: Record<string, any>
|
||||||
|
|
||||||
constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, session: string, params?: RegistrationParams) {
|
constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, session: string, params?: RegistrationParams) {
|
||||||
this._hsApi = hsApi;
|
this._hsApi = hsApi;
|
||||||
|
|
Loading…
Reference in a new issue