feat(puzzles): implement puzzle solution submission and verification …#171
Open
Robinsonchiziterem wants to merge 1 commit intoMindFlowInteractive:mainfrom
Open
Conversation
Contributor
|
@Robinsonchiziterem Not starting. Please resolve |
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.

PR: Implement Puzzle Solution Submission and Verification API
This pull request implements the core infrastructure for submitting and verifying puzzle solutions, as outlined in GitHub issue #141.
Summary of Changes
🧩 Core Infrastructure
New Entity: Added
PuzzleSolutionAttempt
to track every submission attempt with:
SHA-256 hashed answer storage for security.
Nonce-based anti-replay protection.
Detailed timing, reward, and fraud metadata.
Service Layer: Implemented
SolutionSubmissionService
to orchestrate:
Rate limiting (max 5 submissions / 60s).
Answer verification with normalisation (case-insensitivity, object key ordering).
Server-side timing validation against puzzle time limits.
Fraud detection for "impossibly fast" completions.
Atomic reward and aggregate statistic updates.
🛡️ Anti-Cheat & Security
Integrated with
AntiCheatService
to report suspicious completion times.
Implemented SHA-256 hashing for all answer comparisons.
Added strict nonce uniqueness enforcement to prevent replay attacks.
🚀 API Endpoints
POST /puzzles/:id/submit: Submit a solution for verification.
GET /puzzles/:id/submissions: Retrieve current user's history for a specific puzzle.
GET /puzzles/submissions/history: Retrieve full submission history for the authenticated user.
✅ Verification
Added a comprehensive test suite in
src/puzzles/tests/solution-submission.service.spec.ts
(35+ test cases).
Covered edge cases including:
Correct/incorrect answers.
Answer normalization.
Time limit expiration.
Replay attacks.
Fraudulent timing.
Rate limit exhaustion.
Closes #141