fix: split API client into public and admin modules (#1158) - #1253
Merged
hman38705 merged 6 commits intoJul 28, 2026
Conversation
PII (email address) was being sent as a URL query parameter on
GET /api/v1/newsletter/gdpr/export, exposing it to server access
logs, browser history, and proxy logs.
Changes:
- frontend: newsletterGdprExport now uses POST with body: { email }
instead of GET with params: { email } (client.ts)
- backend: added NewsletterExportBody struct, changed handler extractor
from Query to Json, updated utoipa path attribute to post,
updated route registration from get() to post() (handlers.rs, main.rs)
- tests: updated it.each entry to expect POST; added new test in
'GDPR export (#1156)' describe block asserting email is in the
request body and absent from the URL
Fixes #1156
Update openapi.yaml /api/v1/newsletter/gdpr/export from GET with query parameter to POST with requestBody (EmailRequest schema), matching the handler change in handlers.rs. Update SPEC_ROUTES in openapi_contract_test.rs from GET to POST to keep the contract test in sync with the spec and runtime router.
Wrap all path-segment interpolations with encodeURIComponent() to prevent path corruption and request-smuggling when values contain special characters (/, ?, #). Affected endpoints: getBlockchainMarket, getUserBets, getOracleResult, getTransactionStatus, resolveMarket, emailPreview. Add URI encoding test block (7 tests) covering all 6 endpoints and asserting that slash-containing values produce correctly encoded paths.
The full admin API surface (resolveMarket, emailPreview, emailSendTest, getEmailAnalytics, getEmailQueueStats) and the entire Soroban contract error-code map (CONTRACT_ERROR_MESSAGES, ~64 entries) were bundled into the public landing-page build because client.ts was imported wholesale by Statistics.tsx and LandingPage.tsx. Changes: - public-client.ts: new module containing only public-facing endpoints (health, getStatistics, getFeaturedMarkets, getContent, blockchain read-only, newsletter self-service). No admin methods, no contract error map. - admin-client.ts: new module that re-exports the public api and adds admin-only endpoints + CONTRACT_ERROR_MESSAGES/getContractErrorMessage. - client.ts: replaced with a thin re-export barrel from admin-client.ts so all existing imports continue to work without changes. - Statistics.tsx, LandingPage.tsx: updated to import from public-client.ts so the landing-page bundle no longer pulls in admin code. - public-client.test.ts: 17 new tests asserting admin symbols are absent from the public module and present on the admin module. All 78 tests pass. next build succeeds with zero warnings.
… port #1237's cache-invalidation success guard into both split request() implementations
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.
Conflict-resolved re-submission of #1241 (fork PR, no push access to update it directly). Resolves the design conflict with #1231 (both split client.ts into public/admin modules with incompatible layouts) in favor of this PR's design, per maintainer decision. Ported #1237's cache-invalidation success-guard fix into both new request() implementations (public-client.ts and admin-client.ts) since #1241 predates that fix and would otherwise have silently dropped it. Closes #1241 in favor of this.