Commit Graph

10 Commits

Author SHA1 Message Date
7e2e8c703e Add SDP validation to publishService()
Validation: Add comprehensive offer validation
- Validate each offer is an object
- Validate each offer has sdp property
- Validate sdp is a string
- Validate sdp is not empty/whitespace

Impact: Prevents runtime errors from malformed offers
Improves error messages with specific index information
2025-12-12 22:52:46 +01:00
05fe34be01 Remove explicit claimUsername RPC handler - claiming now fully implicit
Username claiming is now handled automatically in verifyAuth() when a username
doesn't exist. The separate claimUsername RPC method is no longer needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 21:56:56 +01:00
68bb28bbc2 Fix: Replace all remaining getOffersByService with getOffersForService 2025-12-12 21:13:02 +01:00
677bbbb37e Fix: Correct method name from getOffersByService to getOffersForService
The storage interface defines getOffersForService() but RPC
handler was calling getOffersByService(), causing runtime error.
2025-12-12 21:11:56 +01:00
caae10bcac Fix: Pass offers to createService method
The createService storage method expects offers in the request,
but publishService wasn't passing them. This caused undefined
error when d1.ts tried to call request.offers.map().

Now correctly passes offers to createService which handles
creating both the service and all offers atomically.
2025-12-12 21:09:15 +01:00
34babd036e Fix: Auto-claim should not validate claim message format
Auto-claim was incorrectly using validateUsernameClaim() which
expects 'claim:{username}:{timestamp}' message format. This failed
when users tried to auto-claim via publishService or getService.

Now auto-claim only:
- Validates username format
- Verifies signature against the actual message
- Claims the username

This allows implicit username claiming on first authenticated request.
2025-12-12 21:03:44 +01:00
876ac2602c Fix: Correct validateUsernameClaim function calls
The function expects 4 separate parameters, not an object.
This was causing 'Username must be a string' errors because
the entire object was being passed as the username parameter.
2025-12-12 21:00:11 +01:00
df9f3311e9 Fix: Add missing continue statement in message validation
The message validation was missing a continue statement, causing
the handler to continue executing even after pushing an error response.
This led to undefined errors when trying to map over undefined values.
2025-12-12 20:52:24 +01:00
9f30f8b46d Implement implicit username claiming in RPC handler
Modified verifyAuth() to automatically claim usernames on first use.
When a username is not claimed and a publicKey is provided in the
RPC request, the server will validate and auto-claim it.

Changes:
- Added publicKey parameter to verifyAuth() function
- Added publicKey field to RpcRequest interface
- Updated RpcHandler type to include publicKey parameter
- Modified all method handlers to pass publicKey to verifyAuth()
- Updated handleRpc() to extract publicKey from requests

🤖 Generated with Claude Code
https://claude.com/claude-code

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 20:22:23 +01:00
17765a9f4f refactor: Convert to RPC interface with single /rpc endpoint
BREAKING CHANGES:
- Replaced REST API with RPC interface
- Single POST /rpc endpoint for all operations
- Removed auth middleware (per-method auth instead)
- Support for batch operations
- Message format changed for all methods

Changes:
- Created src/rpc.ts with all method handlers
- Simplified src/app.ts to only handle /rpc endpoint
- Removed src/middleware/auth.ts
- Updated README.md with complete RPC documentation
2025-12-12 19:51:58 +01:00