Repository navigation
feat(auth): deterministic failure-boundary for handleNonceRequest (#1… - #1732
Merged
Baskarayelu merged 2 commits intoOct 1, 2026
Conversation
…mitwise-Org#1712) - Add lib/auth/nonce.ts: pure handleNonceRequest + consumeNonce with validation-first, fail-closed auth, allow-list, idempotent requestKey replay, conflicting-reuse 409, stale-version 410, rate-limit 429, store-fault 503, single-use consume, redacted logging - Add app/api/auth/nonce/route.ts: POST/GET adapter, re-exports handleNonceRequest, no-store headers, Retry-After on retryable faults - Add lib/auth/nonce.test.ts: 22 focused tests (success, rejection, boundary, retry/duplicate/concurrency/stale/permission/faults) Closes Remitwise-Org#1712
Contributor
|
This pull request currently has a merge conflict with Could you please resolve the conflict (merge or rebase on the latest |
Contributor
Author
@Baskarayelu The conflict has been resolved. |
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 #1712
…712)
Closes #1712
PR: feat(auth): deterministic failure-boundary for handleNonceRequest (#1712)
Branch: feat/1712-nonce-failure-boundary
Commit: 6892f66
Closes #1712
Summary
Implements deterministic failure-boundary coverage for
handleNonceRequestin
meridian-web/app/api/auth/nonce/route.ts(Remitwise-Frontend).The entry point did not exist (verified: 0 hits for
handleNonceRequest,no
app/api/auth/directory), so this is a greenfield, smallest-completeimplementation following the existing
app/api/transfer-capability/route.tspattern (fail-closed session resolution,
no-storeheaders, generic errorbodies, redacted logs).
New files (3 files, +757):
re-exports
handleNonceRequestCore lives in
lib/becausevitest.config.tsonly includeshooks/components/lib/models (app/** is excluded from vitest).
Design
auth_tokencookie preferred;addressbody/query field allowed for anonymous sign-in bootstrap.Neither => 401 NO_ACTIVE_SESSION.
8..128
[A-Za-z0-9:._-], clientVersion int >= 0,.strict()+ requireprincipal-or-address). Malformed input never touches the store.
{ nonce, principal, issuedAt, expiresAt, version, consumed }.
TTL from NONCE_TTL_MS (default 5min, clamped 30s..10min).
deduped:true, no mutation); 5. conflicting reuse => 409, store untouched;
Acceptance criteria -> code -> tests
consumeNonce single-use
unknown/expired rejection
concurrent identical requests => single nonce, expired binding
re-issues fresh, broken-store => 503 without leaking internals
route signatures; no migration needed.
429/503 + console.error with redactedKey() prefix only
nonceFailureToUiState mapping test (stale/permission/retry/error)
UI states: INVALID_INPUT/DUPLICATE_REUSED=>error, NO_ACTIVE_SESSION/
PRINCIPAL_NOT_AUTHORIZED=>permission, STORE_UNAVAILABLE/RATE_LIMITED=>retry,
STALE_VERSION=>stale.
Security and failure-mode handling
(no data loss / no session fixation).
Validation evidence
lib/auth/nonce.test.ts => 2 files, 59/59 passed (37 existing + 22 new)
unrelated hooks/useEmergencyTransfer.ts)
npm run linthas noconfig to run against)
Non-goals respected
No refactors, dependency upgrades (npm install was local-only for test run;
package-lock/tsbuildinfo churn restored, not committed), or weakened
validation.
Env knobs (all optional, safe defaults)