import { request } from './client' export interface AuthResponse { token: string } export function register( email: string, password: string, ): Promise { return request('/auth/register', { method: 'POST', body: JSON.stringify({ email, password }), }) } export function login(email: string, password: string): Promise { return request('/auth/login', { method: 'POST', body: JSON.stringify({ email, password }), }) } export interface MessageResponse { message: string } /** Optional testToken is returned only when backend expose-token is enabled (E2E). */ export interface ChangeEmailResponse extends MessageResponse { testToken?: string } /** Optional testToken is returned only when backend expose-token is enabled (E2E). */ export interface ForgotPasswordResponse extends MessageResponse { testToken?: string } export function forgotPassword(email: string): Promise { return request('/auth/forgot-password', { method: 'POST', body: JSON.stringify({ email }), }) } export function resetPassword( token: string, password: string, ): Promise { return request('/auth/reset-password', { method: 'POST', body: JSON.stringify({ token, password }), }) } export function changePassword( currentPassword: string, newPassword: string, ): Promise { return request('/auth/change-password', { method: 'POST', body: JSON.stringify({ currentPassword, newPassword }), }) } export function changeEmail( newEmail: string, password: string, ): Promise { return request('/auth/change-email', { method: 'POST', body: JSON.stringify({ newEmail, password }), }) } export function confirmEmailChange( token: string, password: string, ): Promise { return request('/auth/confirm-email-change', { method: 'POST', body: JSON.stringify({ token, password }), }) }