feat: add useWebAuth hook for SEP-10 Web Authentication - #579
Merged
gloriaelishahabu merged 1 commit intoAug 3, 2026
Merged
Conversation
Implements the full SEP-10 challenge/response JWT flow: - GET challenge transaction from WEB_AUTH_ENDPOINT - Validate with WebAuth.readChallengeTx (server signing key, home domain) - Sign challenge via Freighter - POST signed XDR to exchange for a JWT Exposes: authenticate(), status, token, isLoading, isSuccess, isError, error, reset(). Supports onSuccess/onError callbacks, publicKey override, and networkPassphrase override falling back to StellarProvider config. Also adds unit tests covering the happy path, all error branches, status transitions, reset behaviour, and camelCase/snake_case signing key aliases.
|
@edrizxabdulganiyu-blip 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! 🚀 |
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.
feat: add useWebAuth hook for SEP-10 Web Authentication
Summary
Implements useWebAuth, a React hook that handles the full [SEP-10 Web
(https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md)
challenge/response flow and exposes a JWT token for use with SEP-6/SEP-12/SEP-24 anchor
endpoints.
What changed
src/hooks/useWebAuth.ts
domain, and transaction structure)
src/hooks/useWebAuth.test.ts
signing key, challenge fetch failure, missing transaction field, readChallengeTx throws, user
rejects signing, token POST failure, missing token field
src/hooks/index.ts / src/index.ts
Usage
import { useWebAuth, useStellarToml } from "stellar-hooks";
function AnchorLogin() {
const { webAuthEndpoint } = useStellarToml("testanchor.stellar.org");
const { authenticate, token, isLoading, error } = useWebAuth({
webAuthEndpoint: webAuthEndpoint ?? "",
homeDomain: "testanchor.stellar.org",
});
}
Notes
main (caused by packages/types being picked up as an implicit @types/stellar-hooks library) and
is unrelated to this PR
closes Implement useSep10Auth() hook #493