9 Commits

Author SHA1 Message Date
b6129294c4 0.1.1 2025-11-08 11:53:13 +01:00
649a8d5d3f Update client to use /topics endpoint and add getVersion method
- Update listTopics() to use /topics endpoint instead of /
- Add getVersion() method to fetch server version information
- Add VersionResponse type and export it

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 11:35:00 +01:00
2065aecc6a Add link to rondevu-demo repository
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:55:59 +01:00
5e98610e30 Add cross-links between related repositories
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:53:41 +01:00
2c3f8ef22b Remove global origin option and update README
- Remove origin option from RondevuClientOptions and RondevuOptions
- Remove ConnectOptions interface with global flag
- Remove all customHeaders logic for origin override
- Update README with consistent Rondevu branding

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:52:56 +01:00
7831e03af1 Add RTC configuration example to README
- Demonstrate how to configure `rtcConfig` with ICE servers in Rondevu constructor.
2025-11-08 10:40:53 +01:00
9df9966381 Replace origin override with global option
- Remove origin parameter from connect() method
- Add ConnectOptions interface with global flag
- When global: true, sends X-Rondevu-Global header instead of trying to override Origin
- Update client methods to accept customHeaders parameter
- Pass custom headers through connection polling and ICE candidate exchange
- Bump version to 0.1.0

This change works around browser restriction on Origin header modification.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 23:45:52 +01:00
de6244cf24 Bump version to 0.0.6 and add publish script to package.json 2025-11-07 23:30:14 +01:00
33ecb9f9bc Add default baseUrl and origin override support
- Set default baseUrl to 'https://rondevu.xtrdev.workers.dev' in RondevuOptions
- Make baseUrl optional in Rondevu constructor
- Add optional origin parameter to connect() method for per-connection origin override
- Bump version to 0.0.5

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 23:29:30 +01:00
6 changed files with 72 additions and 21 deletions

View File

@@ -1,12 +1,20 @@
# Rondevu
🎯 Meet WebRTC peers by topic, by peer ID, or by connection ID.
🎯 **Simple WebRTC peer signaling and discovery**
Meet peers by topic, by peer ID, or by connection ID.
**Related repositories:**
- [rondevu-server](https://github.com/xtr-dev/rondevu-server) - HTTP signaling server
- [rondevu-demo](https://github.com/xtr-dev/rondevu-demo) - Interactive demo
---
## @xtr-dev/rondevu-client
[![npm version](https://img.shields.io/npm/v/@xtr-dev/rondevu-client)](https://www.npmjs.com/package/@xtr-dev/rondevu-client)
TypeScript Rondevu HTTP and WebRTC client, for simple peer discovery and connection.
TypeScript client library for Rondevu peer signaling and WebRTC connection management. Handles automatic signaling, ICE candidate exchange, and connection establishment.
### Install
@@ -19,7 +27,21 @@ npm install @xtr-dev/rondevu-client
```typescript
import { Rondevu } from '@xtr-dev/rondevu-client';
const rdv = new Rondevu({ baseUrl: 'https://server.com' });
const rdv = new Rondevu({
baseUrl: 'https://server.com',
rtcConfig: {
iceServers: [
// your ICE servers here
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{
urls: 'turn:relay1.example.com:3480',
username: 'example',
credential: 'example'
}
]
}
});
// Connect by topic
const conn = await rdv.join('room');

View File

@@ -1,6 +1,6 @@
{
"name": "@xtr-dev/rondevu-client",
"version": "0.0.4",
"version": "0.1.1",
"description": "TypeScript client for Rondevu peer signaling and discovery server",
"type": "module",
"main": "dist/index.js",
@@ -8,7 +8,8 @@
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"publish": "npm publish"
},
"keywords": [
"webrtc",

View File

@@ -9,6 +9,7 @@ import {
PollRequest,
PollOffererResponse,
PollAnswererResponse,
VersionResponse,
HealthResponse,
ErrorResponse,
Side,
@@ -19,7 +20,6 @@ import {
*/
export class RondevuClient {
private readonly baseUrl: string;
private readonly origin: string;
private readonly fetchImpl: typeof fetch;
/**
@@ -28,7 +28,6 @@ export class RondevuClient {
*/
constructor(options: RondevuClientOptions) {
this.baseUrl = options.baseUrl.replace(/\/$/, ''); // Remove trailing slash
this.origin = options.origin || new URL(this.baseUrl).origin;
this.fetchImpl = options.fetch || globalThis.fetch.bind(globalThis);
}
@@ -42,7 +41,6 @@ export class RondevuClient {
const url = `${this.baseUrl}${endpoint}`;
const headers: Record<string, string> = {
'Origin': this.origin,
...(options.headers as Record<string, string>),
};
@@ -65,6 +63,24 @@ export class RondevuClient {
return data as T;
}
/**
* Gets server version information
*
* @returns Server version (git commit hash)
*
* @example
* ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
* const { version } = await client.getVersion();
* console.log('Server version:', version);
* ```
*/
async getVersion(): Promise<VersionResponse> {
return this.request<VersionResponse>('/', {
method: 'GET',
});
}
/**
* Lists all topics with peer counts
*
@@ -84,7 +100,7 @@ export class RondevuClient {
page: page.toString(),
limit: limit.toString(),
});
return this.request<ListTopicsResponse>(`/?${params}`, {
return this.request<ListTopicsResponse>(`/topics?${params}`, {
method: 'GET',
});
}

View File

@@ -35,6 +35,7 @@ export type {
PollOffererResponse,
PollAnswererResponse,
PollResponse,
VersionResponse,
HealthResponse,
ErrorResponse,
RondevuClientOptions,

View File

@@ -9,6 +9,8 @@ export class Rondevu {
readonly peerId: string;
private client: RondevuClient;
private baseUrl: string;
private fetchImpl?: typeof fetch;
private rtcConfig?: RTCConfiguration;
private pollingInterval: number;
private connectionTimeout: number;
@@ -17,10 +19,12 @@ export class Rondevu {
* Creates a new Rondevu client instance
* @param options - Client configuration options
*/
constructor(options: RondevuOptions) {
constructor(options: RondevuOptions = {}) {
this.baseUrl = options.baseUrl || 'https://rondevu.xtrdev.workers.dev';
this.fetchImpl = options.fetch;
this.client = new RondevuClient({
baseUrl: options.baseUrl,
origin: options.origin,
baseUrl: this.baseUrl,
fetch: options.fetch,
});
@@ -99,7 +103,7 @@ export class Rondevu {
*/
async connect(id: string): Promise<RondevuConnection> {
// Poll server to get session by ID
const sessionData = await this.findSessionById(id);
const sessionData = await this.findSessionByIdWithClient(id, this.client);
if (!sessionData) {
throw new Error(`Connection ${id} not found or expired`);
@@ -237,7 +241,10 @@ export class Rondevu {
* Find a session by connection ID
* This requires polling since we don't know which topic it's in
*/
private async findSessionById(id: string): Promise<{
private async findSessionByIdWithClient(
id: string,
client: RondevuClient
): Promise<{
code: string;
peerId: string;
offer: string;
@@ -246,7 +253,7 @@ export class Rondevu {
try {
// Try to poll for the session directly
// The poll endpoint should return the session data
const response = await this.client.poll(id, 'answerer');
const response = await client.poll(id, 'answerer');
const answererResponse = response as { offer: string; offerCandidates: string[] };
if (answererResponse.offer) {

View File

@@ -140,6 +140,14 @@ export interface PollAnswererResponse {
*/
export type PollResponse = PollOffererResponse | PollAnswererResponse;
/**
* Response from GET / - server version information
*/
export interface VersionResponse {
/** Git commit hash or version identifier */
version: string;
}
/**
* Response from GET /health
*/
@@ -161,8 +169,6 @@ export interface ErrorResponse {
export interface RondevuClientOptions {
/** Base URL of the Rondevu server (e.g., 'https://example.com') */
baseUrl: string;
/** Origin header value for session isolation (defaults to baseUrl origin) */
origin?: string;
/** Optional fetch implementation (for Node.js environments) */
fetch?: typeof fetch;
}
@@ -175,12 +181,10 @@ export interface RondevuClientOptions {
* Configuration options for Rondevu WebRTC client
*/
export interface RondevuOptions {
/** Base URL of the Rondevu server (e.g., 'https://example.com') */
baseUrl: string;
/** Base URL of the Rondevu server (defaults to 'https://rondevu.xtrdev.workers.dev') */
baseUrl?: string;
/** Peer identifier (optional, auto-generated if not provided) */
peerId?: string;
/** Origin header value for session isolation (defaults to baseUrl origin) */
origin?: string;
/** Optional fetch implementation (for Node.js environments) */
fetch?: typeof fetch;
/** WebRTC configuration (ICE servers, etc.) */