Skip to content

SEP-10 / Soroban-compatible authentication patterns & examples (#260) - #285

Open
A6dulmalik wants to merge 1 commit into
StelTade:mainfrom
A6dulmalik:feat/260-sep10-auth-examples
Open

SEP-10 / Soroban-compatible authentication patterns & examples (#260)#285
A6dulmalik wants to merge 1 commit into
StelTade:mainfrom
A6dulmalik:feat/260-sep10-auth-examples

Conversation

@A6dulmalik

Copy link
Copy Markdown
Contributor

Closes #260

Summary

Adds examples/sep10-auth — a dependency-light (tweetnacl only), fully offline TypeScript reference implementation of SEP-10 tailored to SwapTrade:

  • Challenge/response (src/sep10.ts): canonical payload construction mirroring SEP-10's manage_data semantics, verification of both server and client ed25519 signatures, 15-minute validity window, and a Stellar G... strkey codec with CRC16-xmodem checksums.
  • Session tokens: HMAC-SHA256 tokens with explicit expiry — the JWT analogue anchors hand out after web auth.
  • Contract-call gating (src/gating.ts): two patterns — session gate (backend relays Soroban invocations only for valid tokens, passing the verified account into the authorization entry) and fee-sponsored relayer (clients sign canonical intent payloads; relayer verifies against the claimed account).
  • Replay protection at both stages via single-use guards on challenge nonces and intent tuples.
  • Note: root .gitignore excludes *.json, so the example's package.json/tsconfig.json are force-added intentionally.

Acceptance criteria mapping

Criterion Where
Working backend example w/ step-by-step instructions README.md quick start + flow sections
Integration gating contract-invoking operations Sep10Gate.authorizeWithToken / authorizeSignedIntent
Tests: accepted/rejected flows + replay protection 14 vitest tests in __tests__/
Developer docs for DApp adoption README 'Adopting SEP-10' section

Validation

  • npm test: 14/14 passing
  • npx tsc --noEmit (strict): clean

…s (issue StelTade#260)

- Offline SEP-10 challenge/response primitives: canonical payload
  construction, dual server+client ed25519 verification, validity-window
  checks, strkey codec with CRC16 validation
- HMAC session tokens (JWT analogue) with explicit expiry
- Sep10Gate integration layer: session-gated contract intents and a
  fee-sponsored relayer flow with client-signed intents
- Replay protections at every stage (challenge nonce, intent tuples)
- 14 vitest tests covering accepted/rejected auth flows and replay;
  tsc --noEmit strict-clean
- Developer README documenting the step-by-step flow and GrantFox/
  Stellar adoption guidance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SEP-10 / Soroban-Compatible Authentication Patterns & Examples

1 participant