Add ServiceHost, ServiceClient, and RondevuService for high-level service management

- Add RondevuService: High-level API for username claiming and service publishing with Ed25519 signatures
- Add ServiceHost: Manages offer pool for hosting services with auto-replacement
- Add ServiceClient: Connects to hosted services with automatic reconnection
- Add NoOpSignaler: Placeholder signaler for connection setup
- Integrate Ed25519 signature functionality from @noble/ed25519
- Add ESLint and Prettier configuration with 4-space indentation
- Add demo with local signaling test
- Version bump to 0.10.0

🤖 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-07 19:37:43 +01:00
parent 945d5a8792
commit 54355323d9
21 changed files with 5066 additions and 307 deletions

View File

@@ -1,34 +1,42 @@
/**
* Core connection types
*/
import {EventBus} from "./event-bus";
import {Binnable} from "./bin";
import { EventBus } from './event-bus.js'
import { Binnable } from './bin.js'
export type Message = string | ArrayBuffer;
export type Message = string | ArrayBuffer
export interface QueueMessageOptions {
expiresAt?: number;
expiresAt?: number
}
export interface ConnectionEvents {
'state-change': ConnectionInterface['state']
'message': Message;
message: Message
}
export interface ConnectionInterface {
id: string;
host: string;
service: string;
state: 'connected' | 'disconnected' | 'connecting';
lastActive: number;
expiresAt?: number;
events: EventBus<ConnectionEvents>;
export const ConnectionStates = ['connected', 'disconnected', 'connecting'] as const
queueMessage(message: Message, options?: QueueMessageOptions): Promise<void>;
sendMessage(message: Message): Promise<boolean>;
export const isConnectionState = (state: string): state is (typeof ConnectionStates)[number] =>
ConnectionStates.includes(state as any)
export interface ConnectionInterface {
id: string
service: string
state: (typeof ConnectionStates)[number]
lastActive: number
expiresAt?: number
events: EventBus<ConnectionEvents>
queueMessage(message: Message, options?: QueueMessageOptions): Promise<void>
sendMessage(message: Message): Promise<boolean>
}
export interface Signaler {
addIceCandidate(candidate: RTCIceCandidate): Promise<void> | void;
addListener(callback: (candidate: RTCIceCandidate) => void): Binnable;
}
addIceCandidate(candidate: RTCIceCandidate): Promise<void> | void
addListener(callback: (candidate: RTCIceCandidate) => void): Binnable
addOfferListener(callback: (offer: RTCSessionDescriptionInit) => void): Binnable
addAnswerListener(callback: (answer: RTCSessionDescriptionInit) => void): Binnable
setOffer(offer: RTCSessionDescriptionInit): Promise<void>
setAnswer(answer: RTCSessionDescriptionInit): Promise<void>
}