Add subcription feature 3
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
// frontend/src/api/services/auth.ts
|
||||
// ================================================================
|
||||
/**
|
||||
* Auth Service - Complete backend alignment
|
||||
* Auth Service - Atomic Registration Architecture
|
||||
*
|
||||
* Backend API structure (3-tier architecture):
|
||||
* - ATOMIC: users.py
|
||||
* - OPERATIONS: auth_operations.py, onboarding_progress.py
|
||||
*
|
||||
* Last Updated: 2025-10-05
|
||||
* Status: ✅ Complete - Zero drift with backend
|
||||
* Last Updated: 2025-01-14
|
||||
* Status: Complete - SetupIntent-first registration flow with 3DS support
|
||||
*/
|
||||
import { apiClient } from '../client';
|
||||
import {
|
||||
@@ -23,37 +22,42 @@ import {
|
||||
UserUpdate,
|
||||
TokenVerificationResponse,
|
||||
AuthHealthResponse,
|
||||
RegistrationStartResponse,
|
||||
RegistrationCompletionResponse,
|
||||
RegistrationVerification,
|
||||
} from '../types/auth';
|
||||
|
||||
export class AuthService {
|
||||
private readonly baseUrl = '/auth';
|
||||
|
||||
// ===================================================================
|
||||
// ATOMIC REGISTRATION: SetupIntent-First Approach
|
||||
// These methods implement the secure registration flow with 3DS support
|
||||
// ===================================================================
|
||||
|
||||
/**
|
||||
* Start secure registration flow with SetupIntent-first approach
|
||||
* This is the FIRST step in the atomic registration flow
|
||||
* Backend: services/auth/app/api/auth_operations.py:start_registration()
|
||||
*/
|
||||
async startRegistration(userData: UserRegistration): Promise<RegistrationStartResponse> {
|
||||
return apiClient.post<RegistrationStartResponse>(`${this.baseUrl}/start-registration`, userData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete registration after 3DS verification
|
||||
* This is the SECOND step in the atomic registration flow
|
||||
* Backend: services/auth/app/api/auth_operations.py:complete_registration()
|
||||
*/
|
||||
async completeRegistration(verificationData: RegistrationVerification): Promise<RegistrationCompletionResponse> {
|
||||
return apiClient.post<RegistrationCompletionResponse>(`${this.baseUrl}/complete-registration`, verificationData);
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// OPERATIONS: Authentication
|
||||
// Backend: services/auth/app/api/auth_operations.py
|
||||
// ===================================================================
|
||||
|
||||
async register(userData: UserRegistration): Promise<TokenResponse> {
|
||||
return apiClient.post<TokenResponse>(`${this.baseUrl}/register`, userData);
|
||||
}
|
||||
|
||||
async registerWithSubscription(userData: UserRegistration): Promise<UserRegistrationWithSubscriptionResponse> {
|
||||
return apiClient.post<UserRegistrationWithSubscriptionResponse>(`${this.baseUrl}/register-with-subscription`, userData);
|
||||
}
|
||||
|
||||
async completeRegistrationAfterSetupIntent(completionData: {
|
||||
email: string;
|
||||
password: string;
|
||||
full_name: string;
|
||||
setup_intent_id: string;
|
||||
plan_id: string;
|
||||
payment_method_id: string;
|
||||
billing_interval: 'monthly' | 'yearly';
|
||||
coupon_code?: string;
|
||||
}): Promise<TokenResponse> {
|
||||
return apiClient.post<TokenResponse>(`${this.baseUrl}/complete-registration-after-setup-intent`, completionData);
|
||||
}
|
||||
|
||||
async login(loginData: UserLogin): Promise<TokenResponse> {
|
||||
return apiClient.post<TokenResponse>(`${this.baseUrl}/login`, loginData);
|
||||
}
|
||||
@@ -136,7 +140,7 @@ export class AuthService {
|
||||
});
|
||||
}
|
||||
|
||||
async getAccountDeletionInfo(): Promise<any> {
|
||||
async getAccountDeletionInfo(): Promise<Record<string, unknown>> {
|
||||
return apiClient.get(`${this.baseUrl}/me/account/deletion-info`);
|
||||
}
|
||||
|
||||
@@ -152,15 +156,15 @@ export class AuthService {
|
||||
analytics_consent?: boolean;
|
||||
consent_method: string;
|
||||
consent_version?: string;
|
||||
}): Promise<any> {
|
||||
}): Promise<Record<string, unknown>> {
|
||||
return apiClient.post(`${this.baseUrl}/me/consent`, consentData);
|
||||
}
|
||||
|
||||
async getCurrentConsent(): Promise<any> {
|
||||
async getCurrentConsent(): Promise<Record<string, unknown>> {
|
||||
return apiClient.get(`${this.baseUrl}/me/consent/current`);
|
||||
}
|
||||
|
||||
async getConsentHistory(): Promise<any[]> {
|
||||
async getConsentHistory(): Promise<Record<string, unknown>[]> {
|
||||
return apiClient.get(`${this.baseUrl}/me/consent/history`);
|
||||
}
|
||||
|
||||
@@ -171,7 +175,7 @@ export class AuthService {
|
||||
analytics_consent?: boolean;
|
||||
consent_method: string;
|
||||
consent_version?: string;
|
||||
}): Promise<any> {
|
||||
}): Promise<Record<string, unknown>> {
|
||||
return apiClient.put(`${this.baseUrl}/me/consent`, consentData);
|
||||
}
|
||||
|
||||
@@ -184,11 +188,11 @@ export class AuthService {
|
||||
// Backend: services/auth/app/api/data_export.py
|
||||
// ===================================================================
|
||||
|
||||
async exportMyData(): Promise<any> {
|
||||
async exportMyData(): Promise<Record<string, unknown>> {
|
||||
return apiClient.get(`${this.baseUrl}/me/export`);
|
||||
}
|
||||
|
||||
async getExportSummary(): Promise<any> {
|
||||
async getExportSummary(): Promise<Record<string, unknown>> {
|
||||
return apiClient.get(`${this.baseUrl}/me/export/summary`);
|
||||
}
|
||||
|
||||
@@ -197,11 +201,11 @@ export class AuthService {
|
||||
// Backend: services/auth/app/api/onboarding_progress.py
|
||||
// ===================================================================
|
||||
|
||||
async getOnboardingProgress(): Promise<any> {
|
||||
async getOnboardingProgress(): Promise<Record<string, unknown>> {
|
||||
return apiClient.get(`${this.baseUrl}/me/onboarding/progress`);
|
||||
}
|
||||
|
||||
async updateOnboardingStep(stepName: string, completed: boolean, data?: any): Promise<any> {
|
||||
async updateOnboardingStep(stepName: string, completed: boolean, data?: Record<string, unknown>): Promise<Record<string, unknown>> {
|
||||
return apiClient.put(`${this.baseUrl}/me/onboarding/step`, {
|
||||
step_name: stepName,
|
||||
completed: completed,
|
||||
@@ -230,4 +234,4 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
export const authService = new AuthService();
|
||||
export const authService = new AuthService();
|
||||
|
||||
Reference in New Issue
Block a user