Skip to content

feat: wallet auth lifecycle and cross-tab sync (#27-30) - #167

Merged
Marvell69 merged 1 commit into
OracleDesk:developfrom
EmmanuelOchaje:feat/issues-27-28-29-30
Oct 18, 2026
Merged

Marvell69 merged 1 commit into
OracleDesk:developfrom
EmmanuelOchaje:feat/issues-27-28-29-30

Conversation

@EmmanuelOchaje

Copy link
Copy Markdown
Contributor

Summary

Implements comprehensive wallet authentication improvements:

Changes

#27 - Hardware Wallet Support

  • Document Ledger/Trezor integration via StellarWalletsKit
  • All wallet modules enabled via defaultModules()
  • Troubleshooting guide for common hardware wallet issues
  • Browser compatibility matrix and setup instructions

#28 - Cross-Tab Synchronization

  • New lib/api/cross-tab-sync.ts module
  • BroadcastChannel for real-time sync with storage event fallback
  • Broadcasts wallet connect, disconnect, and session changes
  • Integrated into WalletProvider lifecycle
  • Prevents session hijacking across tabs

#29 - JWT Lifecycle Management

  • New lib/api/jwt-manager.ts module
  • decodeJWT() and isTokenExpired() for client-side checks
  • getTokenTTL() returns milliseconds until expiry
  • Single-flight re-auth via ensureAuthWithSingleFlight()
  • Prevents thundering herd on 401 errors

#30 - SEP-10 Challenge Validation

  • New lib/stellar/sep10-validator.ts module
  • validateSEP10Challenge() checks before signing:
    • XDR format and structure
    • Network passphrase matches
    • Signature from backend
    • Challenge expiration
    • ManageData operation presence
  • Prevents accidental signing of malformed transactions

Enhanced API Client

  • New isAuthError() function detects 401/TOKEN_EXPIRED
  • Clearer error handling for authentication failures

Test Plan

  • Connect hardware wallet (Ledger or Trezor)
  • Validate SEP-10 challenge before signing
  • Open app in two tabs and verify state sync
  • Check JWT expiry prevents stale token usage
  • Verify single-flight prevents duplicate re-auth

Closes #27
Closes #28
Closes #29
Closes #30

Issue OracleDesk#27 - Hardware wallet support:
- Document Ledger/Trezor integration via StellarWalletsKit
- All wallet modules enabled by default (Freighter, WalletConnect, Ledger, Trezor)
- Add comprehensive troubleshooting guide for hardware wallet setup

Issue OracleDesk#28 - Cross-tab state sync:
- Add cross-tab-sync.ts for BroadcastChannel with storage event fallback
- Sync wallet connection, disconnection, and session changes across tabs
- Prevent session hijacking when same wallet used in multiple tabs
- Integrate sync listener in WalletProvider

Issue OracleDesk#29 - JWT lifecycle management:
- Add jwt-manager.ts for expiry checking and single-flight re-auth
- decodeJWT() safely parses JWT payload without verification
- isTokenExpired() checks if token is expired (with 30s buffer)
- getTokenTTL() returns milliseconds until expiry
- Single-flight re-auth prevents thundering herd on 401 errors
- ensureAuthWithSingleFlight() deduplicates concurrent re-auth attempts

Issue OracleDesk#30 - SEP-10 validation:
- Add sep10-validator.ts for pre-signing challenge validation
- validateSEP10Challenge() checks XDR format, network, expiry, signatures
- extractChallengeToken() retrieves token from ManageData operation
- signInWithWallet() now validates before signing (prevents accidents)

Enhanced API client with isAuthError() to detect 401/TOKEN_EXPIRED conditions.
Updated auth.ts to integrate all new modules.
Updated WalletProvider to use cross-tab sync.

Closes OracleDesk#27
Closes OracleDesk#28
Closes OracleDesk#29
Closes OracleDesk#30
@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@EmmanuelOchaje is attempting to deploy a commit to the Marvel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@EmmanuelOchaje Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Marvell69
Marvell69 merged commit c0f728b into OracleDesk:develop Oct 18, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants