mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Type RegistrationResponse
This commit is contained in:
parent
49ade61ef6
commit
1d4b079d0c
@ -25,9 +25,21 @@ export type RegistrationDetails = {
|
|||||||
inhibitLogin: boolean;
|
inhibitLogin: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: type this later
|
|
||||||
export type RegistrationResponse = {
|
export type RegistrationResponse = {
|
||||||
[key: string]: any;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Registration {
|
export class Registration {
|
||||||
@ -52,6 +64,9 @@ export class Registration {
|
|||||||
parseStagesFromResponse(response: RegistrationResponse): BaseRegistrationStage {
|
parseStagesFromResponse(response: RegistrationResponse): BaseRegistrationStage {
|
||||||
const { session, params } = response;
|
const { session, params } = response;
|
||||||
const flow = response.flows.pop();
|
const flow = response.flows.pop();
|
||||||
|
if (!flow) {
|
||||||
|
throw new Error("No registration flows available!");
|
||||||
|
}
|
||||||
let firstStage: BaseRegistrationStage | undefined;
|
let firstStage: BaseRegistrationStage | undefined;
|
||||||
let lastStage: BaseRegistrationStage;
|
let lastStage: BaseRegistrationStage;
|
||||||
for (const stage of flow.stages) {
|
for (const stage of flow.stages) {
|
||||||
|
Loading…
Reference in New Issue
Block a user