From 89a97537b0d081ef56a8e06b5418b6ff9cd58943 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 3 Feb 2022 19:37:14 +0530 Subject: [PATCH] Make methods private + some props readonly --- src/matrix/registration/Registration.ts | 10 +++++----- .../registration/stages/BaseRegistrationStage.ts | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/matrix/registration/Registration.ts b/src/matrix/registration/Registration.ts index 9b2c0684..d50cbca5 100644 --- a/src/matrix/registration/Registration.ts +++ b/src/matrix/registration/Registration.ts @@ -28,9 +28,9 @@ import type { type FlowSelector = (flows: RegistrationFlow[]) => RegistrationFlow | void; export class Registration { - private _hsApi: HomeServerApi; - private _accountDetails: AccountDetails; - private _flowSelector: FlowSelector; + private readonly _hsApi: HomeServerApi; + private readonly _accountDetails: AccountDetails; + private readonly _flowSelector: FlowSelector; private _sessionInfo?: RegistrationResponseSuccess constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, flowSelector?: FlowSelector) { @@ -64,7 +64,7 @@ export class Registration { return this.parseRegistrationResponse(registrationResponse, stage); } - parseStagesFromResponse(response: RegistrationResponseMoreDataNeeded): BaseRegistrationStage { + private parseStagesFromResponse(response: RegistrationResponseMoreDataNeeded): BaseRegistrationStage { const { session, params } = response; const flow = this._flowSelector(response.flows); if (!flow) { @@ -89,7 +89,7 @@ export class Registration { return firstStage!; } - async parseRegistrationResponse(response: RegistrationResponse, currentStage: BaseRegistrationStage) { + private async parseRegistrationResponse(response: RegistrationResponse, currentStage: BaseRegistrationStage) { switch (response.status) { case 200: this._sessionInfo = response; diff --git a/src/matrix/registration/stages/BaseRegistrationStage.ts b/src/matrix/registration/stages/BaseRegistrationStage.ts index dfe71fa5..964cc75d 100644 --- a/src/matrix/registration/stages/BaseRegistrationStage.ts +++ b/src/matrix/registration/stages/BaseRegistrationStage.ts @@ -18,11 +18,11 @@ import type {HomeServerApi} from "../../net/HomeServerApi"; import type {AccountDetails, AuthenticationData, RegistrationParams} from "../types"; export abstract class BaseRegistrationStage { - protected _hsApi: HomeServerApi; - protected _accountDetails: AccountDetails; + protected readonly _hsApi: HomeServerApi; + protected readonly _accountDetails: AccountDetails; protected _session: string; protected _nextStage: BaseRegistrationStage; - protected _params?: Record + protected readonly _params?: Record constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, session: string, params?: RegistrationParams) { this._hsApi = hsApi;