Skip to content

feat: implement wallet connection and JWT authentication flow #49

Description

@Josue19-08

🔖 Title

Implement wallet connection and complete JWT authentication flow


📄 Description

The `SignIn.tsx` and `CreateAccountScreen.tsx` screens exist with full UI and validation, but neither makes any API calls. The "Connect Wallet" button has no `onPress` handler. The authentication flow (nonce → sign → verify → store JWT) needs to be wired up end to end.


✅ Tasks to complete

  • Integrate Freighter or Albedo wallet SDK for Stellar wallet connection in React Native
  • Implement wallet connection in `use-sign-in.ts`:
    1. Request wallet public key from connected wallet
    2. Call `POST /auth/nonce` with `{ walletAddress }`
    3. Sign the returned nonce message with the wallet
    4. Call `POST /auth/verify` with `{ walletAddress, signature, nonce }`
    5. Store received `accessToken` and `refreshToken` via `token-storage.ts`
    6. Navigate to main app screen
  • Wire up `POST /auth/register` in `use-create-account.ts` with multipart form data (profile image + wallet + username + displayName)
  • Create `AuthContext` (React Context) to expose `user`, `isAuthenticated`, `signOut` globally
  • Implement sign-out: call `DELETE /auth/logout`, clear secure storage, redirect to sign-in
  • Protect authenticated screens: redirect unauthenticated users to sign-in
  • Add error handling for wallet not installed, rejected signature, network errors

📚 Documentation/context for AI

(This link never should removed)
https://github.com/TrustUp-app/TrustUp-API/tree/main/docs


🗒️ Additional notes

  • Depends on the API client layer issue being completed first
  • The API uses Ed25519 Stellar signatures — the wallet must sign a plain text nonce string
  • Store tokens in `expo-secure-store`, never in AsyncStorage (insecure for credentials)
  • Consider deep-link support for wallet redirect flows on mobile

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions