Skip to content

implemented jwt auth for wallet signature#158

Merged
meshackyaro merged 4 commits into
trustflow-protocol:mainfrom
Josie123-Dev:me/GF
Jun 19, 2026
Merged

implemented jwt auth for wallet signature#158
meshackyaro merged 4 commits into
trustflow-protocol:mainfrom
Josie123-Dev:me/GF

Conversation

@Josie123-Dev

Copy link
Copy Markdown
Contributor

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

@meshackyaro

Copy link
Copy Markdown
Contributor

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

Please resolve conflicts

@Josie123-Dev

Copy link
Copy Markdown
Contributor Author

Kindly confirm fix @meshackyaro

@meshackyaro meshackyaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix pipeline

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 meshackyaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job getting this done

@Josie123-Dev

Copy link
Copy Markdown
Contributor Author

Kindly confirm fix @meshackyaro

@meshackyaro meshackyaro merged commit d00bf2b into trustflow-protocol:main Jun 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants