Files
gridpilot.gg/apps/website/lib/gateways/api/auth/AuthApiClient.ts
2026-01-24 12:47:49 +01:00

45 lines
1.6 KiB
TypeScript

import { AuthSessionDTO } from '../../../types/generated/AuthSessionDTO';
import { ForgotPasswordDTO } from '../../../types/generated/ForgotPasswordDTO';
import { LoginParamsDTO } from '../../../types/generated/LoginParamsDTO';
import { ResetPasswordDTO } from '../../../types/generated/ResetPasswordDTO';
import { SignupParamsDTO } from '../../../types/generated/SignupParamsDTO';
import { BaseApiClient } from '../base/BaseApiClient';
/**
* Auth API Client
*
* Handles all authentication-related API operations.
*/
export class AuthApiClient extends BaseApiClient {
/** Sign up with email */
signup(params: SignupParamsDTO): Promise<AuthSessionDTO> {
return this.post<AuthSessionDTO>('/auth/signup', params);
}
/** Login with email */
login(params: LoginParamsDTO): Promise<AuthSessionDTO> {
return this.post<AuthSessionDTO>('/auth/login', params);
}
/** Get current session */
getSession(): Promise<AuthSessionDTO | null> {
return this.request<AuthSessionDTO | null>('GET', '/auth/session', undefined, {
allowUnauthenticated: true,
});
}
/** Logout */
logout(): Promise<void> {
return this.post<void>('/auth/logout', {});
}
/** Forgot password - send reset link */
forgotPassword(params: ForgotPasswordDTO): Promise<{ message: string; magicLink?: string }> {
return this.post<{ message: string; magicLink?: string }>('/auth/forgot-password', params);
}
/** Reset password with token */
resetPassword(params: ResetPasswordDTO): Promise<{ message: string }> {
return this.post<{ message: string }>('/auth/reset-password', params);
}
}