mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-13 20:33:25 +00:00
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.
This commit is contained in:
20
src/rpc.ts
20
src/rpc.ts
@@ -9,6 +9,7 @@ import {
|
||||
isVersionCompatible,
|
||||
verifyEd25519Signature,
|
||||
validateAuthMessage,
|
||||
validateUsername,
|
||||
} from './crypto.ts';
|
||||
|
||||
/**
|
||||
@@ -67,18 +68,15 @@ async function verifyAuth(
|
||||
}
|
||||
|
||||
// Validate username format before claiming
|
||||
const validation = await validateUsernameClaim(
|
||||
username,
|
||||
publicKey,
|
||||
signature,
|
||||
message
|
||||
);
|
||||
const usernameValidation = validateUsername(username);
|
||||
if (!usernameValidation.valid) {
|
||||
return usernameValidation;
|
||||
}
|
||||
|
||||
if (!validation.valid) {
|
||||
return {
|
||||
valid: false,
|
||||
error: validation.error || 'Invalid username claim',
|
||||
};
|
||||
// Verify signature against the current message (not a claim message)
|
||||
const signatureValid = await verifyEd25519Signature(publicKey, signature, message);
|
||||
if (!signatureValid) {
|
||||
return { valid: false, error: 'Invalid signature for auto-claim' };
|
||||
}
|
||||
|
||||
// Auto-claim the username
|
||||
|
||||
Reference in New Issue
Block a user