Skip to content

fix: CSP header, auth retry, idempotency keys, decimal-safe helpers - #333

Merged
chonilius merged 3 commits into
MergeFi:mainfrom
luciachizaram:main
Aug 25, 2026
Merged

chonilius merged 3 commits into
MergeFi:mainfrom
luciachizaram:main

Conversation

@luciachizaram

@luciachizaram luciachizaram commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

fixes 4 issues across security, auth resilience, and financial precision

  • add Content-Security-Policy header with unsafe-inline for scripts
    (needed for theme init, Turbopack dev, React hydration)
  • fix AuthContext.refresh() to retry 3x with exponential backoff on
    network errors instead of silently logging the user out; only clear
    JWT on genuine 401/403
  • generate UUID idempotency keys for fund, claim, refund, and deposit
    API calls to prevent double-submission on retries
  • add toCents/toMajorUnits helpers for integer-based financial
    arithmetic to eliminate floating-point drift

Closes #4
Closes #6
Closes #17
Closes #22

- Add Content-Security-Policy header in next.config.ts with 'unsafe-inline'
  for scripts (needed for theme init, Turbopack dev, React hydration)
- Fix AuthContext.refresh() to retry up to 3 times with exponential backoff
  on network/timeout errors instead of silently logging the user out
- Only clear the JWT token on genuine 401/403 auth failures

Closes MergeFi#4
…pers

- Generate UUID idempotency keys for fund, claim, refund, and deposit
  API calls to prevent double-submission on retries
- Add toCents/toMajorUnits helpers for integer-based financial arithmetic
  to eliminate floating-point drift in aggregated displays
- Preserves precision for USDC (2 decimals) and XLM (7 decimals)

Closes MergeFi#6 MergeFi#17
…lpers

- AuthContext: test that 401 clears token, network errors retry 3x
  with backoff, retries exhausted keeps session
- utils: test generateIdempotencyKey uniqueness and UUID format
- utils: test toCents/toMajorUnits conversion and float-drift-free sum

Refs MergeFi#4 MergeFi#6 MergeFi#17
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@luciachizaram 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

@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

@luciachizaram is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants