All files / src/constants auth.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93  45x             45x             45x               45x                 45x                   45x 2x 2x                 45x                                     45x                 45x           45x          
// Local Storage Keys
export const AUTH_STORAGE_KEYS = {
  TOKEN: 'auth-token',
  USER: 'auth-user',
  REMEMBER_ME: 'auth-remember-me',
};
 
// Authentication States
export const AUTH_STATES = {
  AUTHENTICATED: 'authenticated',
  UNAUTHENTICATED: 'unauthenticated',
  LOADING: 'loading',
};
 
// Auth Form Types
export const AUTH_FORM_TYPES = {
  SIGNIN: 'signin',
  SIGNUP: 'signup',
  FORGOT_PASSWORD: 'forgot_password',
  RESET_PASSWORD: 'reset_password',
};
 
// Auth Loading States
export const AUTH_LOADING_STATES = {
  SIGNIN: 'signin',
  SIGNUP: 'signup',
  LOGOUT: 'logout',
  FORGOT_PASSWORD: 'forgot_password',
  RESET_PASSWORD: 'reset_password',
};
 
// Authentication API Endpoints
export const AUTH_API_ENDPOINTS = {
  SIGNIN: '/auth/signin',
  SIGNUP: '/auth/signup',
  LOGOUT: '/auth/logout',
  FORGOT_PASSWORD: '/auth/forgot-password',
  RESET_PASSWORD: '/auth/reset-password',
  CHANGE_PASSWORD: '/auth/change-password',
};
 
// Authentication Success Messages
export const AUTH_SUCCESS_MESSAGES = {
  SIGNIN: (username: string) => `Welcome back, ${username}!`,
  SIGNUP: (username: string) => `Welcome to Coinbase, ${username}!`,
  LOGOUT: 'Successfully logged out',
  FORGOT_PASSWORD: 'Password reset instructions sent to your email',
  RESET_PASSWORD:
    'Password reset successful. You can now login with your new password',
  CHANGE_PASSWORD: 'Password updated successfully!',
};
 
// Authentication Error Messages
export const AUTH_ERROR_MESSAGES = {
  INVALID_CREDENTIALS: 'Invalid email or password',
  EMAIL_EXISTS: 'User with this email already exists',
  WEAK_PASSWORD:
    'Password must contain at least one uppercase letter, one lowercase letter, and one number',
  PASSWORDS_DONT_MATCH: 'Passwords do not match',
  ACCOUNT_BLOCKED: 'Your account has been blocked',
  EMAIL_REQUIRED: 'Email is required',
  PASSWORD_REQUIRED: 'Password is required',
  GENERIC_ERROR: 'Authentication failed. Please try again',
  SIGNIN_FAILED: 'Sign in failed',
  SIGNUP_FAILED: 'Sign up failed',
  LOGOUT_FAILED: 'Logout failed',
  FORGOT_PASSWORD_FAILED: 'Failed to send reset email',
  RESET_PASSWORD_FAILED: 'Password reset failed',
  CHANGE_PASSWORD_FAILED: 'Failed to change password',
};
 
// Password validation criteria
export const PASSWORD_VALIDATION = {
  MIN_LENGTH: 6,
  REQUIRE_UPPERCASE: true,
  REQUIRE_LOWERCASE: true,
  REQUIRE_NUMBER: true,
  REQUIRE_SPECIAL_CHAR: false,
};
 
// Session related constants
export const SESSION = {
  TOKEN_EXPIRY: '7d', // JWT expiration time
  REFRESH_THRESHOLD: 60 * 60 * 1000, // 1 hour in milliseconds before expiry to refresh
};
 
// Toast notification duration
export const TOAST_DURATION = {
  DEFAULT: 3000, // 3 seconds
  LONG: 5000, // 5 seconds
  SHORT: 2000, // 2 seconds
};