TypeAlias.AuthContext
type AuthContext = BaseAuth & {
isLoading: boolean;
login: (connection?: AuthConnection) => Promise<void>;
logout: () => Promise<void>;
passwordlessLogin: Promise<void>;
passwordlessStart: Promise<void>;
passwordLogin: Promise<void>;
};
Represents the authentication context, extending the base authentication state with loading status and methods for various login/logout flows.
Type declaration
Name | Type | Description |
---|---|---|
isLoading | boolean | Indicates whether an authentication operation is currently in progress. True while any login, logout or passwordless flow is pending. |
login() | (connection? : AuthConnection ) => Promise <void > | Initiates the login process. Throws If login fails (network error or invalid credentials). |
logout() | () => Promise <void > | Logs out the current user. Throws If logout fails. |
passwordlessLogin() | ( connection : "email" | "sms" , username : string , otp : string ) => Promise <void > | Completes the passwordless login flow using the received OTP. Throws If the phone number or OTP is invalid or expired. - On invalid input: "Wrong phone number or verification code." - Backend may return other codes (e.g. expired OTP) |
passwordlessStart() | (connection : "email" | "sms" , username : string ) => Promise <void > | Initiates the passwordless login flow by sending an OTP. Throws If sending OTP fails (invalid username or rate limit). |
passwordLogin() | (username : string , password : string ) => Promise <void > | Initiates login using username and password. Throws If credentials are invalid or login fails. |