implemented jwt auth for wallet signature#158
Conversation
Please resolve conflicts |
|
Kindly confirm fix @meshackyaro |
Regenerate package-lock.json (npm install) to fix npm ci EUSAGE error from the main merge, and restore the Passport-based JwtAuthGuard/JwtStrategy that the merge had reverted to an incompatible standalone implementation.
meshackyaro
left a comment
There was a problem hiding this comment.
Great job getting this done
|
Kindly confirm fix @meshackyaro |
Description
Implements JWT Authentication for Wallet Signatures with Freighter wallet integration. Users can now authenticate by signing a cryptographic challenge with their Stellar wallet, proving ownership without exposing private keys.
Type of Change
✨ New feature (non-breaking change which adds functionality)
🐛 Bug fix (non-breaking change which fixes an issue)
💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
📝 Documentation update
🔧 Configuration change
♻️ Code refactoring
⚡ Performance improvement
✅ Test update
Component
Backend (Node.js API)
Frontend (Next.js UI)
Smart Contract (Soroban/Rust)
SDK
Infrastructure/DevOps
Documentation
Changes Made
Added @stellar/stellar-sdk@^16.0.1 for Stellar signature verification
Added class-validator@^0.14.4 and class-transformer@^0.5.1 for request validation
Updated auth.module.ts to include JwtModule and PassportModule configuration
Implemented proper Stellar signature verification in auth.service.ts using @stellar/stellar-sdk
Updated JWT token generation to use @nestjs/jwt instead of custom implementation
Updated jwt.strategy.ts to use Passport JWT strategy with proper configuration
Updated auth.guard.ts to extend NestJS AuthGuard for JWT validation
Added DTOs for request validation: ChallengeDto, VerifyDto, ChallengeResponseDto, TokenResponseDto
Updated auth.controller.ts to use DTOs and proper response types
Fixed package.json entry point (main.ts instead of index.ts)
Fixed TypeScript errors in escrow.controller.ts and health.controller.ts
Created comprehensive documentation at backend/src/auth/AUTH_IMPLEMENTATION.md
Testing
Manual Testing
Tested locally
Tested in development environment
Tested edge cases
Automated Testing
Unit tests added/updated
Integration tests added/updated
All tests passing locally
Checklist
My code follows the project's style guidelines
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
My changes generate no new warnings or errors
I have added tests that prove my fix is effective or that my feature works
New and existing unit tests pass locally with my changes
Any dependent changes have been merged and published
Screenshots/Recordings (if applicable)
N/A
Additional Notes
Challenge expiration set to 5 minutes to prevent replay attacks
JWT tokens expire after 24 hours
Challenges are stored in-memory (consider Redis for production deployment)
Temporarily disabled soroban.helper.ts due to API changes in new @stellar/stellar-sdk package - this will need to be updated separately
The implementation uses standard Stellar public key validation (G-prefixed, 56 characters)
All authentication endpoints are documented in Swagger UI at /api/docs