mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-11 11:23:24 +00:00
feat: implement offer pooling for multi-connection services
- Add OfferPool class for managing multiple offers with auto-refill polling - Add ServicePool class for orchestrating pooled connections and connection registry - Modify exposeService() to support poolSize parameter (backward compatible) - Add discovery API with service resolution and online status checking - Add username claiming with Ed25519 signatures and TTL-based expiry - Fix TypeScript import errors (RondevuPeer default export) - Fix RondevuPeer instantiation to use RondevuOffers instance - Fix peer.answer() calls to include required PeerOptions parameter - Fix Ed25519 API call (randomSecretKey vs randomPrivateKey) - Remove bloom filter (V1 legacy code) - Update version to 0.8.0 - Document pooling feature and new APIs in README 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { RondevuAuth, Credentials, FetchFunction } from './auth.js';
|
||||
import { RondevuOffers } from './offers.js';
|
||||
import { RondevuUsername } from './usernames.js';
|
||||
import { RondevuServices } from './services.js';
|
||||
import { RondevuDiscovery } from './discovery.js';
|
||||
import RondevuPeer from './peer/index.js';
|
||||
|
||||
export interface RondevuOptions {
|
||||
@@ -65,7 +68,11 @@ export interface RondevuOptions {
|
||||
|
||||
export class Rondevu {
|
||||
readonly auth: RondevuAuth;
|
||||
readonly usernames: RondevuUsername;
|
||||
|
||||
private _offers?: RondevuOffers;
|
||||
private _services?: RondevuServices;
|
||||
private _discovery?: RondevuDiscovery;
|
||||
private credentials?: Credentials;
|
||||
private baseUrl: string;
|
||||
private fetchFn?: FetchFunction;
|
||||
@@ -81,15 +88,19 @@ export class Rondevu {
|
||||
this.rtcIceCandidate = options.RTCIceCandidate;
|
||||
|
||||
this.auth = new RondevuAuth(this.baseUrl, this.fetchFn);
|
||||
this.usernames = new RondevuUsername(this.baseUrl);
|
||||
|
||||
if (options.credentials) {
|
||||
this.credentials = options.credentials;
|
||||
this._offers = new RondevuOffers(this.baseUrl, this.credentials, this.fetchFn);
|
||||
this._services = new RondevuServices(this.baseUrl, this.credentials);
|
||||
this._discovery = new RondevuDiscovery(this.baseUrl, this.credentials);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offers API (requires authentication)
|
||||
* Get offers API (low-level access, requires authentication)
|
||||
* For most use cases, use services and discovery APIs instead
|
||||
*/
|
||||
get offers(): RondevuOffers {
|
||||
if (!this._offers) {
|
||||
@@ -98,6 +109,26 @@ export class Rondevu {
|
||||
return this._offers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get services API (requires authentication)
|
||||
*/
|
||||
get services(): RondevuServices {
|
||||
if (!this._services) {
|
||||
throw new Error('Not authenticated. Call register() first or provide credentials.');
|
||||
}
|
||||
return this._services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get discovery API (requires authentication)
|
||||
*/
|
||||
get discovery(): RondevuDiscovery {
|
||||
if (!this._discovery) {
|
||||
throw new Error('Not authenticated. Call register() first or provide credentials.');
|
||||
}
|
||||
return this._discovery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register and initialize authenticated client
|
||||
* Generates a cryptographically random peer ID (128-bit)
|
||||
@@ -105,12 +136,14 @@ export class Rondevu {
|
||||
async register(): Promise<Credentials> {
|
||||
this.credentials = await this.auth.register();
|
||||
|
||||
// Create offers API instance
|
||||
// Create API instances
|
||||
this._offers = new RondevuOffers(
|
||||
this.baseUrl,
|
||||
this.credentials,
|
||||
this.fetchFn
|
||||
);
|
||||
this._services = new RondevuServices(this.baseUrl, this.credentials);
|
||||
this._discovery = new RondevuDiscovery(this.baseUrl, this.credentials);
|
||||
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user