Final Project - University of Greenwich Student: Vลฉ Trแบงn Quang Minh Email: [email protected] Academic Year: 2024-2025
Decode Protocol is a comprehensive Web3 authentication and identity management system built with Next.js 15.5.3, TypeScript 5, and modern Web3 technologies. The system implements dual authentication mechanisms combining traditional email/password authentication with Web3 wallet integration through cryptographic message signing.
- Dual Authentication System: Traditional credentials and Web3 wallet integration
- Device Fingerprinting: SHA-256 hashed device identification using browser, OS, timezone, language, and audio fingerprinting
- JWT Token Management: Secure session handling with automatic refresh and HttpOnly cookies
- Middleware-based Route Protection: Server-side authentication checks with token validation
- Multi-factor Authentication: Email verification and device trust management
- Cryptographic Security: Web3 message signing with ethers.js for wallet authentication
- CSRF Protection: SameSite cookie policies and request validation headers
- Secure Cookie Management: HttpOnly, Secure, and SameSite policies with automatic expiration
- Content Security Policy: Comprehensive CSP headers for XSS protection
- Request Validation: Internal request headers to prevent external API access
- AppKit Integration: WalletConnect v2 with multi-wallet support (MetaMask, Coinbase, Trust Wallet)
- Ethers.js 6.15.0: Ethereum library for Web3 interactions and message signing
- Multi-chain Support: Ethereum Mainnet and Arbitrum network compatibility
- IPFS Integration: Pinata service for decentralized avatar storage
- Wallet Management: Connect, link, and manage multiple Web3 wallets
- Next.js 15.5.3: React framework with App Router and server-side rendering
- TypeScript 5: Full type safety with strict configuration
- React 19.1.1: Latest React with concurrent features
- Tailwind CSS 4: Utility-first styling with custom CSS variables
- @reown/appkit 1.8.6: Wallet connection and management
- @reown/appkit-adapter-ethers 1.8.6: Ethers.js integration
- ethers 6.15.0: Ethereum library for blockchain interactions
- IPFS/Pinata: Decentralized file storage for avatars
- JWT Token Management: Access and refresh token rotation
- Device Fingerprinting: Browser-based device identification
- Cookie Security: HttpOnly, Secure, SameSite policies
- Middleware Protection: Route-level authentication guards
- ESLint 9: Code quality and consistency
- TypeScript Compiler: Type checking and compilation
- React Loading Skeleton: Loading state components
- React Toastify: User notification system
- TypeScript: Primary language for type-safe development
- JavaScript: Used for configuration and utility scripts
- Next.js: Full-stack React framework with App Router for routing and server-side rendering
- React: UI library for building interactive user interfaces
- Radix UI: Low-level UI primitives for accessible components (via shadcn/ui)
@reown/appkit: Wallet connection and management@reown/appkit-adapter-ethers: Ethers.js adapter for AppKitethers: Ethereum library for blockchain interactions and cryptographic operations
tailwindcss: Utility-first CSS frameworkclass-variance-authority: Class name utilities for component variantsclsx: Conditional class name utilitytailwind-merge: Tailwind class merging utility@radix-ui/*: Collection of accessible UI primitives (alert-dialog, avatar, checkbox, collapsible, dialog, dropdown-menu, hover-card, label, popover, progress, radio-group, scroll-area, select, separator, slot, switch, tabs, tooltip)lucide-react: Icon library@fortawesome/fontawesome-svg-core: FontAwesome icon core@fortawesome/free-solid-svg-icons: FontAwesome solid icons@fortawesome/react-fontawesome: React FontAwesome component
@reduxjs/toolkit: Redux toolkit for state managementreact-redux: React bindings for Reduxsocket.io-client: WebSocket client for real-time communication
react-hook-form: Performant forms with easy validation@hookform/resolvers: Resolvers for react-hook-formzod: TypeScript-first schema validation
recharts: Composable charting library built on React components
date-fns: Modern JavaScript date utility librarycmdk: Command palette componentreact-qr-code: QR code generation for Reactreact-toastify: Toast notificationsmongodb: MongoDB driver for database operations
- ESLint: Linting tool for code quality
- TypeScript Compiler (tsc): Type checking and compilation
- Next.js CLI: Development server and build tools
- npm: Package manager and script runner
- Next.js Build System: Optimized production builds
- ESLint Config Next: ESLint configuration for Next.js
- @typescript-eslint/eslint-plugin: TypeScript ESLint rules
- @typescript-eslint/parser: TypeScript parser for ESLint
- Cookies: Secure HTTP-only cookies for session management
- LocalStorage: Browser storage for theme preferences and user settings
- MongoDB: NoSQL database for user data, authentication, and application state
- IPFS (via Pinata): Decentralized storage for user avatars and media files
- JWT Tokens: JSON Web Tokens for authentication and authorization
- Device Fingerprinting: SHA-256 hashed device identification for security
- Session Management: Secure session handling with automatic token refresh
- Tailwind CSS: Utility-first CSS framework with custom design tokens
- shadcn/ui: Component library built on Radix UI primitives
- CSS Variables: Custom properties for theme management
- Reusable Components: Modular UI components for consistency
- Accessible Design: WCAG compliant components using Radix UI
- Responsive Design: Mobile-first approach with breakpoint utilities
- Loading States: Skeleton components for better perceived performance
- Toast Notifications: User feedback system for actions and errors
- Real-time Updates: Server-sent events for live notifications
- Form Validation: Client-side validation with error messaging
- Dark/Light Mode: Theme switching with localStorage persistence
- Custom Variables: CSS custom properties for color schemes
- Node.js 18+
- npm, yarn, pnpm, or bun
- Backend API endpoint (configured via environment variables)
- Web3 wallet (MetaMask, WalletConnect, etc.)
- Reown Project ID for AppKit integration
-
Clone and Install Dependencies
git clone <repository-url> cd decode-frontend-v2 npm install
-
Environment Configuration Create a
.envfile with required variables:BACKEND_BASE_URL=http://localhost:4000 NEXT_PUBLIC_REOWN_PROJECT_ID=your_reown_project_id PINATA_API_KEY=your_pinata_api_key PINATA_API_SECRET=your_pinata_secret PINATA_JWT=your_pinata_jwt_token NODE_ENV=development
-
Development Server
npm run dev
-
Production Build
npm run build npm run start
- Wallet Connection: AppKit modal opens for wallet selection
- Challenge Generation: Backend creates unique signing challenge
- Message Signing: User signs challenge with private key
- Signature Verification: Backend validates signature and wallet ownership
- Session Creation: JWT tokens created and stored securely
- Smart Detection: System determines if user exists via email/username
- Device Fingerprinting: SHA-256 hashed device identification
- Multi-factor Verification: Email OTP for new devices
- Token Management: Secure cookie-based session handling
- Fingerprint Generation: Browser, OS, timezone, language, audio fingerprinting
- Trust Verification: Email verification for untrusted devices
- Session Management: Device-specific session tracking
- Device Fingerprinting: Unique device identification using multiple browser APIs
- Email Verification: Multi-factor authentication for new devices
- JWT Token Management: Secure session handling with automatic refresh
- Route Protection: Middleware-based access control with token validation
- CSRF Protection: Request validation and secure cookie policies
- Message Signing: Cryptographic authentication using wallet private keys
- Wallet Verification: Address-based identity verification
- Network Validation: Supported network checks (Ethereum, Arbitrum)
- Signature Validation: Backend verification of wallet signatures
- HttpOnly Tokens: Secure server-side token storage
- Secure Cookies: Production environment security
- SameSite Protection: CSRF protection
- Automatic Expiration: Based on backend response timestamps
- Mobile-First: Optimized for mobile devices
- Desktop Enhancement: Enhanced features for larger screens
- Touch Support: Full touch interaction support
- Dark/Light Mode: Theme switching with localStorage persistence
- Server-Sent Events: Real-time notifications via WebSocket
- Live Updates: Instant UI updates for user actions
- Toast Notifications: User-friendly success/error messages
POST /api/auth/login- Traditional user login with device fingerprintingPOST /api/auth/register- User registration with email verificationPOST /api/auth/login-or-register- Smart login/register detectionPOST /api/auth/verify-*- Email verification for various flowsPOST /api/auth/forgot-password- Password reset initiationPOST /api/auth/change-password- Password update
POST /api/wallet/auth-challenge- Generate signing challengePOST /api/wallet/auth-validation- Validate wallet signaturePOST /api/wallet/link-challenge- Generate wallet linking challengePOST /api/wallet/link-validation- Validate wallet linking signatureGET /api/wallet/all-wallet- Fetch user's connected wallets
GET /api/users/overview- User profile dataPUT /api/users/profile-change- Update user profilePOST /api/users/avatar- Upload avatar to IPFSGET /api/users/notifications- Fetch user notificationsGET /api/users/websocket- Server-sent events for real-time updates
# Backend Configuration
BACKEND_BASE_URL=https://your-backend-api.com
# Web3 Configuration
NEXT_PUBLIC_REOWN_PROJECT_ID=your_reown_project_id
# IPFS Configuration (Pinata)
PINATA_API_KEY=your_pinata_api_key
PINATA_API_SECRET=your_pinata_secret
PINATA_JWT=your_pinata_jwt_token
# Environment
NODE_ENV=production
PUBLIC_FRONTEND_URL=https://decode.decodenetwork.app- Memory-based Workers: Optimized for memory-constrained environments
- Code Splitting: AppKit bundle separation for better performance
- Console Removal: Production console.log removal
- Image Optimization: Unoptimized images for IPFS compatibility
- Content Security Policy: Comprehensive CSP for XSS protection
- CORS Configuration: Proper cross-origin resource sharing
- Security Headers: X-Frame-Options, X-Content-Type-Options, HSTS
- Permissions Policy: Camera, microphone, geolocation restrictions
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run type-check # Run TypeScript checks- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- Mobile browsers with Web3 wallet support
This project demonstrates advanced full-stack development skills including:
- Modern React Development: Next.js 15 with App Router and server components
- TypeScript Proficiency: Advanced type safety and development practices
- Web3 Integration: Blockchain technology implementation with ethers.js
- Security Implementation: Comprehensive authentication and authorization
- User Experience Design: Modern, responsive interface with accessibility
- Multi-wallet Support: Expanded wallet provider integration
- Social Login: OAuth integration with major providers
- Advanced Analytics: Security event tracking and monitoring
- Mobile App: React Native implementation
- Cross-chain Compatibility: Additional blockchain network support
- NFT Integration: Non-fungible token management
- DeFi Protocol Integration: Decentralized finance features
This project is developed as part of academic coursework at the University of Greenwich.
For technical questions or support:
- Student Email: [email protected]
- University: University of Greenwich
- Project Type: Final Project - Web3 Authentication System
Built with โค๏ธ by Vลฉ Trแบงn Quang Minh for University of Greenwich Final Project
Integrating traditional authentication with Web3 technology for a secure, modern user experience.