matrix-react-sdk
Version:
SDK for matrix.org using React
73 lines (72 loc) • 2.98 kB
TypeScript
import { MatrixClient, LoginFlow, ILoginFlow, LoginRequest, OidcClientConfig } from "matrix-js-sdk/src/matrix";
import { IMatrixClientCreds } from "./MatrixClientPeg";
/**
* Login flows supported by this client
* LoginFlow type use the client API /login endpoint
* OidcNativeFlow is specific to this client
*/
export type ClientLoginFlow = LoginFlow | OidcNativeFlow;
interface ILoginOptions {
defaultDeviceDisplayName?: string;
/**
* Delegated auth config from server's .well-known.
*
* If this property is set, we will attempt an OIDC login using the delegated auth settings.
* The caller is responsible for checking that OIDC is enabled in the labs settings.
*/
delegatedAuthentication?: OidcClientConfig;
}
export default class Login {
private hsUrl;
private isUrl;
private fallbackHsUrl;
private flows;
private readonly defaultDeviceDisplayName?;
private delegatedAuthentication?;
private tempClient;
constructor(hsUrl: string, isUrl: string, fallbackHsUrl: string | null, opts: ILoginOptions);
getHomeserverUrl(): string;
getIdentityServerUrl(): string;
setHomeserverUrl(hsUrl: string): void;
setIdentityServerUrl(isUrl: string): void;
/**
* Set delegated authentication config, clears tempClient.
* @param delegatedAuthentication delegated auth config, from ValidatedServerConfig
*/
setDelegatedAuthentication(delegatedAuthentication?: OidcClientConfig): void;
/**
* Get a temporary MatrixClient, which can be used for login or register
* requests.
* @returns {MatrixClient}
*/
createTemporaryClient(): MatrixClient;
/**
* Get supported login flows
* @param isRegistration OPTIONAL used to verify registration is supported in delegated authentication config
* @returns Promise that resolves to supported login flows
*/
getFlows(isRegistration?: boolean): Promise<Array<ClientLoginFlow>>;
loginViaPassword(username: string | undefined, phoneCountry: string | undefined, phoneNumber: string | undefined, password: string): Promise<IMatrixClientCreds>;
}
/**
* Describes the OIDC native login flow
* Separate from js-sdk's `LoginFlow` as this does not use the same /login flow
* to which that type belongs.
*/
export interface OidcNativeFlow extends ILoginFlow {
type: "oidcNativeFlow";
clientId: string;
}
/**
* Send a login request to the given server, and format the response
* as a MatrixClientCreds
*
* @param {string} hsUrl the base url of the Homeserver used to log in.
* @param {string} isUrl the base url of the default identity server
* @param {string} loginType the type of login to do
* @param {ILoginParams} loginParams the parameters for the login
*
* @returns {IMatrixClientCreds}
*/
export declare function sendLoginRequest(hsUrl: string, isUrl: string | undefined, loginType: string, loginParams: Omit<LoginRequest, "type">): Promise<IMatrixClientCreds>;
export {};