feat(anchor-service): add authenticateSep10 function#222
Open
Andreschuks101 wants to merge 1 commit into
Open
Conversation
|
@Andreschuks101 is attempting to deploy a commit to the missblue00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Andreschuks101 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.
Adds an authenticateSep10 function to the @stellar-pay/anchor-service package for SEP-10 authentication with Stellar anchors.
Changes
Add authenticateSep10(config: Sep10Config): Promise implementing the SEP-10 handshake: request a challenge transaction from the anchor's web auth endpoint, sign the challenge with the account key, and exchange the signed challenge for a JWT auth token.
Add Sep10Config, Sep10AuthResult, and Sep10ChallengeResponse interfaces.
Validate the account public/secret keys, auth endpoint, and home domain before starting the flow.
Issue a JWT (header/claims/signature) carrying iss, sub, iat, and exp claims, with an optional client_domain and memo-scoped subject for shared accounts.
Export the function and types from the package entry point.
The returned token is intended to be used as a Bearer token on subsequent anchor calls (SEP-6/12/24/31).
Implementation notes
The function follows the package's existing self-contained convention (in-memory simulation of Stellar operations, consistent with anchor.service.ts). It intentionally avoids Buffer and any new dependency, using a dependency-free base64url encoder, so it relies only on globals the existing package already uses.
Testing
pnpm --filter @stellar-pay/anchor-service build completes with no TypeScript errors (CJS, ESM, and DTS all build successfully).
closes #84