diff --git a/src/matrix/registration/Registration.ts b/src/matrix/registration/Registration.ts index cd44dc38..7fb263f3 100644 --- a/src/matrix/registration/Registration.ts +++ b/src/matrix/registration/Registration.ts @@ -17,30 +17,7 @@ limitations under the License. import type {HomeServerApi} from "../net/HomeServerApi"; import {registrationStageFromType} from "./registrationStageFromType"; import type {BaseRegistrationStage} from "./stages/BaseRegistrationStage"; - -export type RegistrationDetails = { - username: string | null; - password: string; - initialDeviceDisplayName: string; - inhibitLogin: boolean; -} - -export type RegistrationResponse = { - completed: string[]; - flows: Record[]; - params: Record; - session: string; -} & error & success; - -type error = { - errcode: string; - error: string; -} -type success = { - user_id: string; - device_id: string; - access_token?: string; -} +import type {RegistrationDetails, RegistrationResponse} from "./types/type"; export class Registration { private _hsApi: HomeServerApi; diff --git a/src/matrix/registration/registrationStageFromType.ts b/src/matrix/registration/registrationStageFromType.ts index 45375516..28d5c2b0 100644 --- a/src/matrix/registration/registrationStageFromType.ts +++ b/src/matrix/registration/registrationStageFromType.ts @@ -16,7 +16,7 @@ limitations under the License. import type {BaseRegistrationStage} from "./stages/BaseRegistrationStage"; import type {HomeServerApi} from "../net/HomeServerApi"; -import type {RegistrationDetails} from "./Registration"; +import type {RegistrationDetails} from "./types/type"; import {DummyAuth} from "./stages/DummyAuth"; import {TermsAuth} from "./stages/TermsAuth"; diff --git a/src/matrix/registration/stages/BaseRegistrationStage.ts b/src/matrix/registration/stages/BaseRegistrationStage.ts index 57c0fa0e..2dfc0628 100644 --- a/src/matrix/registration/stages/BaseRegistrationStage.ts +++ b/src/matrix/registration/stages/BaseRegistrationStage.ts @@ -14,19 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -type AuthenticationData = { - type: string; - session: string; - [key: string]: any; -} - -// contains data needed to complete this stage, eg: link to privacy policy -type RegistrationParams = { - [key: string]: any; -} - import type {HomeServerApi} from "../../net/HomeServerApi"; -import type {RegistrationDetails, RegistrationResponse} from "../Registration"; +import type {RegistrationDetails, RegistrationResponse, AuthenticationData, RegistrationParams} from "../types/type"; export abstract class BaseRegistrationStage { protected _hsApi: HomeServerApi; diff --git a/src/matrix/registration/types/type.ts b/src/matrix/registration/types/type.ts new file mode 100644 index 00000000..2863ec28 --- /dev/null +++ b/src/matrix/registration/types/type.ts @@ -0,0 +1,55 @@ +/* +Copyright 2021 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +export type RegistrationDetails = { + username: string | null; + password: string; + initialDeviceDisplayName: string; + inhibitLogin: boolean; +} + +export type RegistrationResponse = RegistrationResponse401 & RegistrationResponseError & RegistrationResponseSuccess; + +type RegistrationResponse401 = { + completed: string[]; + flows: Record[]; + params: Record; + session: string; +} + +type RegistrationResponseError = { + errcode: string; + error: string; +} + +type RegistrationResponseSuccess = { + user_id: string; + device_id: string; + access_token?: string; +} + +/* Types for Registration Stage */ + +export type AuthenticationData = { + type: string; + session: string; + [key: string]: any; +} + +// contains additional data needed to complete a stage, eg: link to privacy policy +export type RegistrationParams = { + [key: string]: any; +}