Skip to content

fix(backend): address issues #249, #250, #251, #252 - #439

Merged
dark-sarge merged 1 commit into
arflexx:mainfrom
GF-Hunter:fix/issues-249-250-251-252
Oct 17, 2026
Merged

dark-sarge merged 1 commit into
arflexx:mainfrom
GF-Hunter:fix/issues-249-250-251-252

Conversation

@GF-Hunter

Copy link
Copy Markdown
Contributor

Summary

This PR addresses backend issues #249, #250, #251, and #252.

Changes Included

  1. Issue [backend] - GET /api/v1/admin/users/:phone exposes full phone number without masking #249: Mask phone number on GET /api/v1/admin/users/:phone

    • Replaced plaintext phone in the response with maskedPhone using the existing maskPhone helper function.
    • Added phoneHash (first 8 characters of SHA-256 hex digest) to support non-PII lookups and indexing.
    • Normalised the :phone route parameter before DB query via normalizePhone to prevent enumeration and format discrepancies.
  2. Issue [backend] - No idempotency key support on POST /api/v1/trades — duplicate submissions create duplicate on-chain listings #250: Idempotency-Key support on POST /api/v1/trades

    • Supported optional Idempotency-Key header on trade creation.
    • Backed by cache with a 24-hour TTL for responses.
    • Duplicate submissions with the same idempotency key return the cached response without repeating the Soroban create_listing contract call or inserting duplicate records.
    • Added unit tests verifying duplicate requests return the cached response without repeating contract calls.
  3. Issue [backend] - fraudDetection.checkVelocity uses in-memory cache which resets on restart, defeating rate-limiting across replicas #251: Shared Redis persistence and startup check for fraudDetection.checkVelocity

    • Updated validateEnv to require REDIS_URL in production.
    • Added startup verification of Redis readiness (cache.checkReady() with PING test); if Redis is unavailable at startup, the server logs FATAL and terminates with exit code 1.
    • Added fatal log level to custom structured logger.
    • Added integration test verifying that transaction velocity counts persist across client disconnection and reconnection (simulated process restart).
  4. Issue [backend] - POST /api/v1/auth/recover/change-phone issues session JWT without verifying new phone ownership via OTP #252: Require OTP verification on POST /api/v1/auth/recover/change-phone

    • Updated phone recovery endpoint to invalidate the one-time recovery token immediately upon phone update.
    • Triggered OTP dispatch to the new phone number via Termii.
    • Returns a verification prompt without issuing a session JWT; the user must complete OTP verification via POST /api/v1/auth/verify-otp before receiving their session JWT.
    • Added unit test verifying OTP dispatch, lack of immediate session token, and recovery token invalidation against replay.

Closes #249
Closes #250
Closes #251
Closes #252

…rflexx#252

- arflexx#249: Mask phone numbers and include phoneHash on GET /api/v1/admin/users/:phone, and normalise phone lookup parameter
- arflexx#250: Add Idempotency-Key support on POST /api/v1/trades with 24-hour response caching
- arflexx#251: Require Redis in production, fail fast if Redis unavailable at startup, and persist velocity counters
- arflexx#252: Require OTP verification on POST /api/v1/auth/recover/change-phone and invalidate recovery token immediately
@GF-Hunter
GF-Hunter requested a review from dark-sarge as a code owner October 17, 2026 08:34
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@GF-Hunter 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! 🚀

Learn more about application limits

@dark-sarge
dark-sarge merged commit 218c198 into arflexx:main Oct 17, 2026
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment