Repository navigation
feat(auth): add GET auth/nonce route with deterministic failure-boundary coverage for validateAddressQuery - #1731
Merged
Baskarayelu merged 2 commits intoOct 1, 2026
Conversation
…ary coverage for validateAddressQuery (verification fix)
alfrednohesi-hash
force-pushed
the
fix/1713-auth-nonce-failure-boundary
branch
from
September 28, 2026 07:38
2ddbcba to
be8553c
Compare
Contributor
|
This pull request currently has a merge conflict with Could you please resolve the conflict (merge or rebase on the latest |
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.
Overview
Adds
GET /api/auth/nonce— a cache-hostile, single-live-nonce-per-address endpoint that issues Stellar authentication nonces. The address validator, the live-nonce store and the concurrency/supersede/expiry invariants are all directly exercised by a focused test file.Related Issue
Issue #1713 — Add deterministic failure-boundary coverage for
GETin./app/api/auth/nonce/route.ts.Changes
Auth nonce route
meridian-web/app/api/auth/nonce/route.tsvalidateAddressQuery(value)is pure, performs no I/O and never throws. It rejects a missing/empty address (MISSING_ADDRESS), a length other than exactly 56 (INVALID_ADDRESS_LENGTH), a missingGprefix (INVALID_ADDRESS_PREFIX) and any character outsideA-Z2-7in the remaining 55 positions (INVALID_ADDRESS_CHARSET), so lowercase,I,O,0,1and 55/57-char values are all rejected.{ error, issues }andCache-Control: no-store, private.{ address, nonce, expiresAt }with a fresh 32-bytecrypto.randomBytes(...).toString('hex')nonce, an ISO-8601expiresAt,Cache-Control: no-store, privateandX-Content-Type-Options: nosniff.NONCE_TTL_MS(default 300000) is read per call so tests can shrink it.peekLiveNonce(address)is the documented test-only seam that returns the live nonce (purging the entry once expired), and__resetNonceStore()clears the process-local store.Tests
meridian-web/lib/api/__tests__/auth-nonce.test.tsGprefixes (S.../T...), characters outside the alphabet at the pinned final position (0,1,I,O,8), and every accepted boundary character (A,7,2,Z).no-store/nosnifffor missing and invalid addresses; 200 with a 64-hex nonce and anexpiresAtinside a loose window aroundnow + NONCE_TTL_MS(withNONCE_TTL_MSshrunk via env, no fake timers); supersede behaviour (the first nonce is no longer live after a second request); 8 concurrent requests yielding 8 distinct nonces.NONCE_TTL_MS=1plus a real ~25ms delay, after whichpeekLiveNoncereturnsnull; a separate case keeps a live nonce while a 60000ms TTL has not elapsed.Verification Results
validateAddressQuerypinned at 56 chars and theG/base32 boundariesmeridian-web/lib/api/__tests__/auth-nonce.test.tsCloses #1713