Move types to types.ts
This commit is contained in:
parent
3a67da8830
commit
6798a5e429
4 changed files with 58 additions and 37 deletions
|
@ -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<string, any>[];
|
||||
params: Record<string, any>;
|
||||
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;
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
55
src/matrix/registration/types/type.ts
Normal file
55
src/matrix/registration/types/type.ts
Normal file
|
@ -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<string, any>[];
|
||||
params: Record<string, any>;
|
||||
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;
|
||||
}
|
Reference in a new issue