Fix critical security, stability, and performance quick wins#167
Open
Sparksx wants to merge 1 commit into
Open
Fix critical security, stability, and performance quick wins#167Sparksx wants to merge 1 commit into
Sparksx wants to merge 1 commit into
Conversation
Security: - Refund webhook now returns 500 on failure instead of silently claiming success - Stripe checkout URLs validated against allowed origins (prevent open redirect) Stability: - Use sendBeacon for save flush on tab close (guaranteed delivery) - Clan leave wrapped in a single transaction (prevent ownership race) - Mission progress uses interactive transaction (prevent double completion) - Expedition resolution errors caught per-expedition (no handler crash) - Chat history emits error response on failure (prevent client hang) - Clamp expedition rewards to non-negative values Performance: - Add HTTP compression middleware (gzip responses) - Mission contributions limited to top 3 at query level - Add database indexes: ChatMessage.senderId, User.createdAt Quality: - Add forge probability validation tests (sum=100, 7 slots, no negatives) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LecvFszB9cnNJfRBMpX2ia
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.
Summary
Comprehensive codebase audit across security, stability, performance, and functionality — this PR implements the highest-priority quick wins (high impact, low difficulty).
Security
charge.refundedwebhook now returns 500 on DB error instead of 200, so Stripe retries instead of assuming success (prevents gold leakage)Origin/RefererheadersStability
beforeunloadflush now usesnavigator.sendBeacon()for guaranteed delivery (+ new/api/game/state/beaconendpoint)xpGain/goldPottoMath.max(0, ...)Performance
compressionmiddleware for gzip responses on all API payloadscontributionsquery limited totake: 3+orderBy: descat DB level (was fetching all, sorting in JS, slicing to 3)ChatMessage.senderIdandUser.createdAtfor admin/moderation queriesQuality
Test plan
npm test— 311 tests pass (including 3 new forge validation tests)npm run lint— 0 errors (only pre-existing warnings)npm run build— production build succeeds🤖 Generated with Claude Code
https://claude.ai/code/session_01LecvFszB9cnNJfRBMpX2ia
Generated by Claude Code