Send publicKey in RPC requests for implicit username claiming

Updated client to send publicKey in all authenticated RPC requests,
enabling server-side implicit username claiming.

Changes:
- Added publicKey field to RpcRequest interface
- Added publicKey to all authenticated RPC method calls
- Removed username claiming requirement from publishService()
- Auto-mark username as claimed after successful publish

Users no longer need to call claimUsername() before publishing
services. The server will automatically claim the username on
the first authenticated request.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-12 20:22:28 +01:00
parent f4ae5dee30
commit 238cc08bf5
2 changed files with 18 additions and 8 deletions

View File

@@ -167,18 +167,13 @@ export class Rondevu {
/**
* Publish a service with automatic signature generation
* Username will be automatically claimed on first publish if not already claimed
*/
async publishService(options: PublishServiceOptions): Promise<Service> {
if (!this.keypair) {
throw new Error('Not initialized. Call initialize() first.')
}
if (!this.usernameClaimed) {
throw new Error(
'Username not claimed. Call claimUsername() first or the server will reject the service.'
)
}
const { serviceFqn, offers, ttl } = options
// Generate signature for service publication
@@ -194,8 +189,13 @@ export class Rondevu {
ttl,
}
// Publish to server
return await this.getAPI().publishService(serviceRequest)
// Publish to server (server will auto-claim username if needed)
const result = await this.getAPI().publishService(serviceRequest)
// Mark username as claimed after successful publish
this.usernameClaimed = true
return result
}
// ============================================