diff --git a/src/@types/auth.ts b/src/@types/auth.ts index 592974221..db07ce661 100644 --- a/src/@types/auth.ts +++ b/src/@types/auth.ts @@ -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 */ diff --git a/src/client.ts b/src/client.ts index d734d256c..66e3ec2da 100644 --- a/src/client.ts +++ b/src/client.ts @@ -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"; @@ -7077,10 +7077,10 @@ export class MatrixClient extends TypedEventEmitter} Resolves to the available login flows * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public loginFlows(callback?: Callback): Promise { // TODO: Types + public loginFlows(callback?: Callback): Promise { return this.http.request(callback, Method.Get, "/login"); }