fix(sdk): align auth endpoints with real SEP-10 routes + implement initSdkAuth - #918
Merged
Topmatrixmor2014 merged 1 commit intoAug 26, 2026
Merged
Conversation
🤖 Greptile AI Code ReviewGreptile will automatically review this PR (2 file(s) changed). Review gates:
|
3 tasks
| const res = await apiFetch(`${this.baseUrl}/api/auth/challenge`, { | ||
| method: "POST", | ||
| async getChallenge(publicKey: string): Promise<{ transaction: string; networkPassphrase: string }> { | ||
| const res = await apiFetch(\`\${this.baseUrl}/api/auth?account=\${encodeURIComponent(publicKey)}\`, { |
6 tasks
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
Fixes #899 — the SDK's auth helpers were calling non-existent endpoints (
POST /api/auth/challenge,POST /api/auth/verify) which returned 404, andinitSdkAuth()was an empty stub, so the SDK could never authenticate against the real SEP-10 backend.Changes
frontend/lib/sdk-instance.tsgetChallenge(publicKey)→ now callsGET ${baseUrl}/api/auth?account=${publicKey}(matches the backend route inbackend/src/routes/auth.js), with the public key URL-encoded. No request body.verifyChallenge(signedXDR)→ now callsPOST ${baseUrl}/api/authwith body{ "transaction": signedXDR }(matches the backend verify route).initSdkAuth()→ now loads the access token fromgetJwtToken()(the existing auth storage) and attaches it to the SDK instance viasdk.setToken(token).apiFetch(it was referenced but not imported).frontend/__tests__/sdk-instance.test.ts(new)initSdkAuth, and no-token no-op behavior.Acceptance criteria
initSdkAuthactually attaches a tokenWallet address (GrantFox FWC26 — no specific token, not appended)