You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement Update/Delete APIs with enhanced security (#107) (#119)
This PR completes Issue #107 by implementing PUT and DELETE endpoints for the /api/gists/[id] route with comprehensive security features and API test refactoring.
## Key Features
### DELETE Endpoint
- Dual authentication methods:
- One-time view gists: metadata proof validation (SHA-256 hash)
- PIN-protected gists: PIN validation via X-Edit-Password header
- CSRF protection on all state-changing endpoints
- Fixed race condition by moving auto-deletion to explicit DELETE endpoint
### PUT Endpoint
- Multipart form data support for gist updates
- PIN validation for protected gists
- Optimistic locking to prevent concurrent update conflicts
- Support for updating encrypted user metadata and editor preferences
### Security Enhancements
- Created reusable CSRF validation in lib/security.ts
- Converted all crypto operations to WebCrypto API for edge runtime
- Added comprehensive schema validation using Zod
- Proper error handling with typed AppError system
### API Test Refactoring
- Established consistent test pattern: route.{method}.test.ts
- Split all combined test files by HTTP method
- Created API_TEST_PATTERN.md documentation
- All 69 tests passing with 100% coverage
### Additional Improvements
- Implemented user metadata encryption support
- Created shared schemas in lib/api-schemas.ts
- Added editor preferences to create/update operations
- Updated tracking documents and TODO.md
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments