mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Fill in ts types + change names
This commit is contained in:
parent
b482d478b4
commit
49ade61ef6
@ -18,7 +18,7 @@ import type {HomeServerApi} from "../net/HomeServerApi";
|
|||||||
import {registrationStageFromType} from "./registrationStageFromType";
|
import {registrationStageFromType} from "./registrationStageFromType";
|
||||||
import type {BaseRegistrationStage} from "./stages/BaseRegistrationStage";
|
import type {BaseRegistrationStage} from "./stages/BaseRegistrationStage";
|
||||||
|
|
||||||
export type RegistrationParameters = {
|
export type RegistrationDetails = {
|
||||||
username: string | null;
|
username: string | null;
|
||||||
password: string;
|
password: string;
|
||||||
initialDeviceDisplayName: string;
|
initialDeviceDisplayName: string;
|
||||||
@ -32,9 +32,9 @@ export type RegistrationResponse = {
|
|||||||
|
|
||||||
export class Registration {
|
export class Registration {
|
||||||
private _hsApi: HomeServerApi;
|
private _hsApi: HomeServerApi;
|
||||||
private _data: RegistrationParameters;
|
private _data: RegistrationDetails;
|
||||||
|
|
||||||
constructor(hsApi: HomeServerApi, data: RegistrationParameters) {
|
constructor(hsApi: HomeServerApi, data: RegistrationDetails) {
|
||||||
this._hsApi = hsApi;
|
this._hsApi = hsApi;
|
||||||
this._data = data;
|
this._data = data;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
import type {BaseRegistrationStage} from "./stages/BaseRegistrationStage";
|
import type {BaseRegistrationStage} from "./stages/BaseRegistrationStage";
|
||||||
import type {HomeServerApi} from "../net/HomeServerApi";
|
import type {HomeServerApi} from "../net/HomeServerApi";
|
||||||
import type {RegistrationParameters} from "./Registration";
|
import type {RegistrationDetails} from "./Registration";
|
||||||
import {DummyAuth} from "./stages/DummyAuth";
|
import {DummyAuth} from "./stages/DummyAuth";
|
||||||
import {TermsAuth} from "./stages/TermsAuth";
|
import {TermsAuth} from "./stages/TermsAuth";
|
||||||
|
|
||||||
type DerivedFromBaseRegistration = { new(hsApi: HomeServerApi, registrationData: RegistrationParameters, session: string, params?: Record<string, any>): BaseRegistrationStage } & typeof BaseRegistrationStage | undefined;
|
type DerivedFromBaseRegistration = { new(hsApi: HomeServerApi, registrationData: RegistrationDetails, session: string, params?: Record<string, any>): BaseRegistrationStage } & typeof BaseRegistrationStage | undefined;
|
||||||
|
|
||||||
export function registrationStageFromType(type: string): DerivedFromBaseRegistration {
|
export function registrationStageFromType(type: string): DerivedFromBaseRegistration {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -14,25 +14,28 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type Auth = {
|
type AuthenticationData = {
|
||||||
|
type: string;
|
||||||
|
session: string;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Params = {
|
// contains data needed to complete this stage, eg: link to privacy policy
|
||||||
|
type RegistrationParams = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
import type {HomeServerApi} from "../../net/HomeServerApi";
|
import type {HomeServerApi} from "../../net/HomeServerApi";
|
||||||
import type {RegistrationParameters, RegistrationResponse} from "../Registration";
|
import type {RegistrationDetails, RegistrationResponse} from "../Registration";
|
||||||
|
|
||||||
export abstract class BaseRegistrationStage {
|
export abstract class BaseRegistrationStage {
|
||||||
protected _hsApi: HomeServerApi;
|
protected _hsApi: HomeServerApi;
|
||||||
protected _registrationData: RegistrationParameters;
|
protected _registrationData: RegistrationDetails;
|
||||||
protected _session: string;
|
protected _session: string;
|
||||||
protected _nextStage: BaseRegistrationStage;
|
protected _nextStage: BaseRegistrationStage;
|
||||||
protected _params?: Record<string, any>
|
protected _params?: Record<string, any>
|
||||||
|
|
||||||
constructor(hsApi: HomeServerApi, registrationData: RegistrationParameters, session: string, params?: Params) {
|
constructor(hsApi: HomeServerApi, registrationData: RegistrationDetails, session: string, params?: RegistrationParams) {
|
||||||
this._hsApi = hsApi;
|
this._hsApi = hsApi;
|
||||||
this._registrationData = registrationData;
|
this._registrationData = registrationData;
|
||||||
this._session = session;
|
this._session = session;
|
||||||
@ -49,7 +52,7 @@ export abstract class BaseRegistrationStage {
|
|||||||
* - the next stage if this stage was completed successfully
|
* - the next stage if this stage was completed successfully
|
||||||
* - user-id (string) if registration is completed
|
* - user-id (string) if registration is completed
|
||||||
*/
|
*/
|
||||||
abstract complete(auth?: Auth): Promise<BaseRegistrationStage | string>;
|
abstract complete(auth?: AuthenticationData): Promise<BaseRegistrationStage | string>;
|
||||||
|
|
||||||
setNextStage(stage: BaseRegistrationStage) {
|
setNextStage(stage: BaseRegistrationStage) {
|
||||||
this._nextStage = stage;
|
this._nextStage = stage;
|
||||||
|
Loading…
Reference in New Issue
Block a user