fix: replace mock JWT tokens with real wallet-signature auth (Closes #35) - #67
Merged
Merged
Conversation
Wire the SEP-10-style challenge-transaction login into the app. After wallet connect, register now runs the real flow via authService.authenticate: fetch a nonce + challenge XDR, sign the challenge with the connected wallet (Freighter directly, Lobstr over WalletConnect using the stored sessionId), and exchange the signed challenge for JWT tokens — replacing the mock-access-token / mock-refresh-token placeholders. - services/auth.service.ts: add WalletType, sep0010 verify body, and the authenticate() orchestration; wallet signing failures surface as a WALLET_SIGNING_FAILED ApiClientError. - types/errors.ts: add WALLET_SIGNING_FAILED code + user message. - app/(auth)/register.tsx: call authenticate() with a wallet guard, keeping the existing error banner and finally reset. - Delete the dead legacy simulated sign-in path (components/pages/ SignIn.tsx, hooks/auth/use-sign-in.ts) — nothing referenced them. - Add services/__tests__/auth.service.test.ts covering both wallet types and the signing/network error paths. Closes #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #35
Replaces the
mock-access-token/mock-refresh-tokenplaceholders with real wallet-signature JWT auth. After wallet connect, the register flow now runsauthService.authenticate: it fetches a nonce + SEP-10-style challenge transaction, signs the challenge XDR with the connected wallet (Freighter directly, mobile Lobstr over WalletConnect using the storedsessionId), and exchanges the signed challenge withPOST /auth/verify(signatureType: sep0010) for JWT tokens. This pairs with the API side (StepFi-app/StepFi-API#138) that issues and verifies the challenge.This repo is for the React Native mobile app only
Type of change
Testing
Verified locally:
npm run typecheck,npm run lint, andnpm test(64/64) all clean, andnpx expo export --platform webexits 0. Addedservices/__tests__/auth.service.test.tscovering both wallet types plus the signing-failure and network-failure paths (challenge is signed once,/auth/verifypostssep0010, wallet/session failures surface asWALLET_SIGNING_FAILED). Also removed the dead legacy simulated sign-in path (components/pages/SignIn.tsx,hooks/auth/use-sign-in.ts) — nothing referenced them.Context files reviewed