28 lines
961 B
TypeScript
28 lines
961 B
TypeScript
import { api, apiGet, apiPost } from "./api";
|
|
import type { Admin, AuthResponse, AuthStatus, ChangePasswordInput, LoginCredentials } from "../types/auth";
|
|
|
|
export function getAuthStatus(): Promise<AuthStatus> {
|
|
return apiGet<AuthStatus>("/api/auth/status");
|
|
}
|
|
|
|
export function getSession(): Promise<AuthResponse> {
|
|
return apiGet<AuthResponse>("/api/auth/session");
|
|
}
|
|
|
|
export function login(credentials: LoginCredentials): Promise<AuthResponse> {
|
|
return apiPost<AuthResponse>("/api/auth/login", credentials);
|
|
}
|
|
|
|
export function logout(): Promise<void> {
|
|
return apiPost<void>("/api/auth/logout");
|
|
}
|
|
|
|
export function changePassword(input: ChangePasswordInput): Promise<AuthResponse> {
|
|
return apiPost<AuthResponse>("/api/auth/change-password", input);
|
|
}
|
|
|
|
export type { Admin, AuthResponse, AuthStatus, ChangePasswordInput, LoginCredentials };
|
|
|
|
// Keep a typed escape hatch for future authenticated services without exposing fetch details.
|
|
export { api };
|