Fix/open source issuesfix(auth): verify challenge nonces, use configurable network passphrase, and bound /api/routes results - #234
Merged
Conversation
Adds database schema and helper functions for persisting auth challenge nonces. This is part of the SEP-10-style challenge/response flow (accensa#221) where nonces must be stored server-side to prevent replay of unrelated signed transactions.
- Persist nonces to the database so verify can confirm they were issued here and have not been consumed (accensa#221) - Replace hardcoded Networks.TESTNET with STELLAR_NETWORK_PASSPHRASE env var, read at runtime to support pubnet deployments (accensa#222) - Sweep expired nonces opportunistically on each challenge issuance
- Verify the transaction contains exactly one manageData operation with key 'Accensa Auth' (accensa#221) - Consume the nonce on first successful use, rejecting replays (accensa#221) - Replace hardcoded Networks.TESTNET with configurable passphrase (accensa#222) - Reject transactions with extra operations or wrong data key
Tests that the challenge endpoint: - Returns a valid XDR and the configured network passphrase - Defaults to testnet when STELLAR_NETWORK_PASSPHRASE is unset - Persists the nonce to the database - Returns 500 when MERCHANT_ADDRESS is not configured
Tests that the verify endpoint: - Accepts a valid challenge and issues a session - Rejects transactions with no manageData operation - Rejects transactions with multiple operations - Rejects challenges with unknown nonces - Rejects replayed challenges (replay protection) - Rejects expired challenges - Uses the configured network passphrase
Add the new optional environment variable to the deployment docs so operators know how to configure pubnet authentication (accensa#222).
- Default limit of 50 groups (max 200), following /api/payments pattern - Default 30-day time window to prevent full-table scans on every load - Aggregated (other) row for the tail when results are truncated - Returns truncated flag and default_window_days in response - Uses existing idx_payments_ts index for the windowed query
Tests that the endpoint: - Returns routes with default limit of 50 - Truncates results and adds (other) row when exceeding limit - Validates limit bounds (1-200) - Applies default 30-day window when no from/to given - Respects custom from/to parameters - Returns 500 when DATABASE_URL is missing
|
@Ojukwu-Chinedu 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! 🚀 |
|
@Ojukwu-Chinedu is attempting to deploy a commit to the ACCENSA Team on Vercel. A member of the Team first needs to authorize it. |
wagmiiii
self-requested a review
August 25, 2026 19:56
Replaces spread argument pattern with vi.hoisted() to satisfy strict tsc --noEmit in CI. The spread (...args: unknown[]) => mock(...args) pattern was rejected by TypeScript with TS2556.
Replaces spread argument pattern with vi.hoisted() to satisfy strict tsc --noEmit in CI.
Ensures Prettier produces consistent output matching the existing single-quote style across the codebase, fixing CI format:check failures.
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.
Closes #221
Closes #222
Closes #224
What changed
closes Both auth routes hardcode Networks.TESTNET, so the dashboard cannot authenticate on pubnet #222 — Both auth routes hardcode Networks.TESTNET
closes /api/routes aggregates the whole payments table with no limit or pagination #224 — /api/routes aggregates the whole payments table with no limit or pagination
closes apps/indexer and apps/demo contain nothing but node_modules #225 — Uses the existing idx_payments_ts index for the windowed query
Files changed
File Change
apps/web/src/lib/db.ts Add challenge_nonces table + nonce store/consume/sweep helpers
apps/web/src/app/api/auth/challenge/route.ts Persist nonce, use configurable passphrase
apps/web/src/app/api/auth/verify/route.ts Verify operation structure, consume nonce, use configurable passphrase
apps/web/src/app/api/auth/challenge/route.test.ts New — 4 tests for challenge endpoint
apps/web/src/app/api/auth/verify/route.test.ts New — 9 tests for verify endpoint
apps/web/src/app/api/routes/route.ts Add limit, default time window, (other) aggregation row
apps/web/src/app/api/routes/route.test.ts New — 10 tests for routes endpoint
DEPLOYMENT.md Document STELLAR_NETWORK_PASSPHRASE env var
Verification