Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/@types/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,58 @@ export interface IRefreshTokenResponse {
}

/* eslint-enable camelcase */

/**
* Response to GET login flows as per https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3login
*/
export interface ILoginFlowsResponse {
flows: LoginFlow[];
}

export type LoginFlow = ISSOFlow | IPasswordFlow | ILoginFlow;

export interface ILoginFlow {
type: string;
}

export interface IPasswordFlow extends ILoginFlow {
type: "m.login.password";
}

/**
* Representation of SSO flow as per https://spec.matrix.org/latest/client-server-api/#client-login-via-sso
*/
export interface ISSOFlow extends ILoginFlow {
type: "m.login.sso" | "m.login.cas";
// eslint-disable-next-line camelcase
identity_providers?: IIdentityProvider[];
}

export enum IdentityProviderBrand {
Gitlab = "gitlab",
Github = "github",
Apple = "apple",
Google = "google",
Facebook = "facebook",
Twitter = "twitter",
}

export interface IIdentityProvider {
id: string;
name: string;
icon?: string;
brand?: IdentityProviderBrand | string;
}

/**
* Parameters to login request as per https://spec.matrix.org/latest/client-server-api/#login
*/
/* eslint-disable camelcase */
export interface ILoginParams {
identifier?: object;
password?: string;
token?: string;
device_id?: string;
initial_device_display_name?: string;
}
/* eslint-enable camelcase */
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ import { IPusher, IPusherRequest, IPushRules, PushRuleAction, PushRuleKind, Rule
import { IThreepid } from "./@types/threepids";
import { CryptoStore } from "./crypto/store/base";
import { MediaHandler } from "./webrtc/mediaHandler";
import { IRefreshTokenResponse } from "./@types/auth";
import { ILoginFlowsResponse, IRefreshTokenResponse } from "./@types/auth";
import { TypedEventEmitter } from "./models/typed-event-emitter";
import { ReceiptType } from "./@types/read_receipts";
import { MSC3575SlidingSyncRequest, MSC3575SlidingSyncResponse, SlidingSync } from "./sliding-sync";
Expand Down Expand Up @@ -7077,10 +7077,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa

/**
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {Promise<ILoginFlowsResponse>} Resolves to the available login flows
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public loginFlows(callback?: Callback): Promise<any> { // TODO: Types
public loginFlows(callback?: Callback): Promise<ILoginFlowsResponse> {
return this.http.request(callback, Method.Get, "/login");
}

Expand Down