- Centralized and refactored configuration management (`config`) with runtime validation for environment variables. - Introduced utilities for secure token storage, including AES-GCM encryption and fallback handling. - Enhanced `authStore` state management with token validation, secure persistence, and initialization from storage. - Modularized authentication utilities and updated export structure for better maintainability. - Improved error handling, input validation, and added detailed comments for enhanced clarity.
28 lines
1.0 KiB
TypeScript
Executable File
28 lines
1.0 KiB
TypeScript
Executable File
// Application configuration
|
|
// Environment variables, constants, feature flags, etc.
|
|
|
|
export const config = {
|
|
api: {
|
|
baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api/v1',
|
|
timeout: parseInt(process.env.NEXT_PUBLIC_API_TIMEOUT || '30000', 10),
|
|
},
|
|
app: {
|
|
name: process.env.NEXT_PUBLIC_APP_NAME || 'Template Project',
|
|
url: process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000',
|
|
},
|
|
auth: {
|
|
tokenRefreshThreshold: parseInt(process.env.NEXT_PUBLIC_TOKEN_REFRESH_THRESHOLD || '300000', 10),
|
|
accessTokenExpiry: parseInt(process.env.NEXT_PUBLIC_ACCESS_TOKEN_EXPIRY || '900000', 10),
|
|
refreshTokenExpiry: parseInt(process.env.NEXT_PUBLIC_REFRESH_TOKEN_EXPIRY || '604800000', 10),
|
|
},
|
|
features: {
|
|
enableRegistration: process.env.NEXT_PUBLIC_ENABLE_REGISTRATION === 'true',
|
|
enableSessionManagement: process.env.NEXT_PUBLIC_ENABLE_SESSION_MANAGEMENT === 'true',
|
|
},
|
|
debug: {
|
|
api: process.env.NEXT_PUBLIC_DEBUG_API === 'true',
|
|
},
|
|
} as const;
|
|
|
|
export type AppConfig = typeof config;
|