@xtr-dev/rondevu-client 0.0.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Rondevu
2
2
 
3
- 🎯 Meet WebRTC peers by topic, by peer ID, or by connection ID.
3
+ 🎯 **Simple WebRTC peer signaling and discovery**
4
+
5
+ Meet peers by topic, by peer ID, or by connection ID.
6
+
7
+ **Related repositories:**
8
+ - [rondevu-server](https://github.com/xtr-dev/rondevu-server) - HTTP signaling server
9
+ - [rondevu-demo](https://github.com/xtr-dev/rondevu-demo) - Interactive demo
10
+
11
+ ---
4
12
 
5
13
  ## @xtr-dev/rondevu-client
6
14
 
7
15
  [![npm version](https://img.shields.io/npm/v/@xtr-dev/rondevu-client)](https://www.npmjs.com/package/@xtr-dev/rondevu-client)
8
16
 
9
- TypeScript Rondevu HTTP and WebRTC client, for simple peer discovery and connection.
17
+ TypeScript client library for Rondevu peer signaling and WebRTC connection management. Handles automatic signaling, ICE candidate exchange, and connection establishment.
10
18
 
11
19
  ### Install
12
20
 
@@ -19,7 +27,21 @@ npm install @xtr-dev/rondevu-client
19
27
  ```typescript
20
28
  import { Rondevu } from '@xtr-dev/rondevu-client';
21
29
 
22
- const rdv = new Rondevu({ baseUrl: 'https://server.com' });
30
+ const rdv = new Rondevu({
31
+ baseUrl: 'https://server.com',
32
+ rtcConfig: {
33
+ iceServers: [
34
+ // your ICE servers here
35
+ { urls: 'stun:stun.l.google.com:19302' },
36
+ { urls: 'stun:stun1.l.google.com:19302' },
37
+ {
38
+ urls: 'turn:relay1.example.com:3480',
39
+ username: 'example',
40
+ credential: 'example'
41
+ }
42
+ ]
43
+ }
44
+ });
23
45
 
24
46
  // Connect by topic
25
47
  const conn = await rdv.join('room');
package/dist/client.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { RondevuClientOptions, ListTopicsResponse, ListSessionsResponse, CreateOfferRequest, CreateOfferResponse, AnswerRequest, AnswerResponse, PollOffererResponse, PollAnswererResponse, HealthResponse, Side } from './types';
1
+ import { RondevuClientOptions, ListTopicsResponse, ListSessionsResponse, CreateOfferRequest, CreateOfferResponse, AnswerRequest, AnswerResponse, PollOffererResponse, PollAnswererResponse, VersionResponse, HealthResponse, Side } from './types';
2
2
  /**
3
3
  * HTTP client for Rondevu peer signaling and discovery server
4
4
  */
5
5
  export declare class RondevuClient {
6
6
  private readonly baseUrl;
7
- private readonly origin;
8
7
  private readonly fetchImpl;
9
8
  /**
10
9
  * Creates a new Rondevu client instance
@@ -15,6 +14,19 @@ export declare class RondevuClient {
15
14
  * Makes an HTTP request to the Rondevu server
16
15
  */
17
16
  private request;
17
+ /**
18
+ * Gets server version information
19
+ *
20
+ * @returns Server version (git commit hash)
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const client = new RondevuClient({ baseUrl: 'https://example.com' });
25
+ * const { version } = await client.getVersion();
26
+ * console.log('Server version:', version);
27
+ * ```
28
+ */
29
+ getVersion(): Promise<VersionResponse>;
18
30
  /**
19
31
  * Lists all topics with peer counts
20
32
  *
@@ -66,7 +78,6 @@ export declare class RondevuClient {
66
78
  * Sends an answer or candidate to an existing session
67
79
  *
68
80
  * @param request - Answer details including session code and signaling data
69
- * @param customHeaders - Optional custom headers to send with the request
70
81
  * @returns Success confirmation
71
82
  *
72
83
  * @example
@@ -88,13 +99,12 @@ export declare class RondevuClient {
88
99
  * });
89
100
  * ```
90
101
  */
91
- sendAnswer(request: AnswerRequest, customHeaders?: Record<string, string>): Promise<AnswerResponse>;
102
+ sendAnswer(request: AnswerRequest): Promise<AnswerResponse>;
92
103
  /**
93
104
  * Polls for session data from the other peer
94
105
  *
95
106
  * @param code - Session UUID
96
107
  * @param side - Which side is polling ('offerer' or 'answerer')
97
- * @param customHeaders - Optional custom headers to send with the request
98
108
  * @returns Session data including offers, answers, and candidates
99
109
  *
100
110
  * @example
@@ -112,7 +122,7 @@ export declare class RondevuClient {
112
122
  * console.log('Received offer:', answererData.offer);
113
123
  * ```
114
124
  */
115
- poll(code: string, side: Side, customHeaders?: Record<string, string>): Promise<PollOffererResponse | PollAnswererResponse>;
125
+ poll(code: string, side: Side): Promise<PollOffererResponse | PollAnswererResponse>;
116
126
  /**
117
127
  * Checks server health
118
128
  *
package/dist/client.js CHANGED
@@ -8,18 +8,15 @@ export class RondevuClient {
8
8
  */
9
9
  constructor(options) {
10
10
  this.baseUrl = options.baseUrl.replace(/\/$/, ''); // Remove trailing slash
11
- this.origin = options.origin || new URL(this.baseUrl).origin;
12
11
  this.fetchImpl = options.fetch || globalThis.fetch.bind(globalThis);
13
12
  }
14
13
  /**
15
14
  * Makes an HTTP request to the Rondevu server
16
15
  */
17
- async request(endpoint, options = {}, customHeaders) {
16
+ async request(endpoint, options = {}) {
18
17
  const url = `${this.baseUrl}${endpoint}`;
19
18
  const headers = {
20
- 'Origin': this.origin,
21
19
  ...options.headers,
22
- ...(customHeaders || {}),
23
20
  };
24
21
  if (options.body) {
25
22
  headers['Content-Type'] = 'application/json';
@@ -35,6 +32,23 @@ export class RondevuClient {
35
32
  }
36
33
  return data;
37
34
  }
35
+ /**
36
+ * Gets server version information
37
+ *
38
+ * @returns Server version (git commit hash)
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const client = new RondevuClient({ baseUrl: 'https://example.com' });
43
+ * const { version } = await client.getVersion();
44
+ * console.log('Server version:', version);
45
+ * ```
46
+ */
47
+ async getVersion() {
48
+ return this.request('/', {
49
+ method: 'GET',
50
+ });
51
+ }
38
52
  /**
39
53
  * Lists all topics with peer counts
40
54
  *
@@ -54,7 +68,7 @@ export class RondevuClient {
54
68
  page: page.toString(),
55
69
  limit: limit.toString(),
56
70
  });
57
- return this.request(`/?${params}`, {
71
+ return this.request(`/topics?${params}`, {
58
72
  method: 'GET',
59
73
  });
60
74
  }
@@ -103,7 +117,6 @@ export class RondevuClient {
103
117
  * Sends an answer or candidate to an existing session
104
118
  *
105
119
  * @param request - Answer details including session code and signaling data
106
- * @param customHeaders - Optional custom headers to send with the request
107
120
  * @returns Success confirmation
108
121
  *
109
122
  * @example
@@ -125,18 +138,17 @@ export class RondevuClient {
125
138
  * });
126
139
  * ```
127
140
  */
128
- async sendAnswer(request, customHeaders) {
141
+ async sendAnswer(request) {
129
142
  return this.request('/answer', {
130
143
  method: 'POST',
131
144
  body: JSON.stringify(request),
132
- }, customHeaders);
145
+ });
133
146
  }
134
147
  /**
135
148
  * Polls for session data from the other peer
136
149
  *
137
150
  * @param code - Session UUID
138
151
  * @param side - Which side is polling ('offerer' or 'answerer')
139
- * @param customHeaders - Optional custom headers to send with the request
140
152
  * @returns Session data including offers, answers, and candidates
141
153
  *
142
154
  * @example
@@ -154,12 +166,12 @@ export class RondevuClient {
154
166
  * console.log('Received offer:', answererData.offer);
155
167
  * ```
156
168
  */
157
- async poll(code, side, customHeaders) {
169
+ async poll(code, side) {
158
170
  const request = { code, side };
159
171
  return this.request('/poll', {
160
172
  method: 'POST',
161
173
  body: JSON.stringify(request),
162
- }, customHeaders);
174
+ });
163
175
  }
164
176
  /**
165
177
  * Checks server health
@@ -19,8 +19,7 @@ export declare class RondevuConnection extends EventEmitter {
19
19
  private connectionTimer?;
20
20
  private isPolling;
21
21
  private isClosed;
22
- private customHeaders?;
23
- constructor(params: RondevuConnectionParams, client: RondevuClient, customHeaders?: Record<string, string>);
22
+ constructor(params: RondevuConnectionParams, client: RondevuClient);
24
23
  /**
25
24
  * Setup RTCPeerConnection event handlers
26
25
  */
@@ -3,7 +3,7 @@ import { EventEmitter } from './event-emitter';
3
3
  * Represents a WebRTC connection with automatic signaling and ICE exchange
4
4
  */
5
5
  export class RondevuConnection extends EventEmitter {
6
- constructor(params, client, customHeaders) {
6
+ constructor(params, client) {
7
7
  super();
8
8
  this.isPolling = false;
9
9
  this.isClosed = false;
@@ -17,7 +17,6 @@ export class RondevuConnection extends EventEmitter {
17
17
  this.dataChannels = new Map();
18
18
  this.pollingIntervalMs = params.pollingInterval;
19
19
  this.connectionTimeoutMs = params.connectionTimeout;
20
- this.customHeaders = customHeaders;
21
20
  this.setupEventHandlers();
22
21
  this.startConnectionTimeout();
23
22
  }
@@ -90,7 +89,7 @@ export class RondevuConnection extends EventEmitter {
90
89
  code: this.id,
91
90
  candidate: JSON.stringify(candidate.toJSON()),
92
91
  side: this.role,
93
- }, this.customHeaders);
92
+ });
94
93
  }
95
94
  catch (err) {
96
95
  throw new Error(`Failed to send ICE candidate: ${err.message}`);
@@ -134,7 +133,7 @@ export class RondevuConnection extends EventEmitter {
134
133
  return;
135
134
  }
136
135
  try {
137
- const response = await this.client.poll(this.id, this.role, this.customHeaders);
136
+ const response = await this.client.poll(this.id, this.role);
138
137
  if (this.role === 'offerer') {
139
138
  const offererResponse = response;
140
139
  // Apply answer if received and not yet applied
package/dist/index.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  export { Rondevu } from './rondevu';
6
6
  export { RondevuConnection } from './connection';
7
7
  export { RondevuClient } from './client';
8
- export type { RondevuOptions, JoinOptions, ConnectionRole, RondevuConnectionParams, RondevuConnectionEvents, Side, Session, TopicInfo, Pagination, ListTopicsResponse, ListSessionsResponse, CreateOfferRequest, CreateOfferResponse, AnswerRequest, AnswerResponse, PollRequest, PollOffererResponse, PollAnswererResponse, PollResponse, HealthResponse, ErrorResponse, RondevuClientOptions, } from './types';
8
+ export type { RondevuOptions, JoinOptions, ConnectionRole, RondevuConnectionParams, RondevuConnectionEvents, Side, Session, TopicInfo, Pagination, ListTopicsResponse, ListSessionsResponse, CreateOfferRequest, CreateOfferResponse, AnswerRequest, AnswerResponse, PollRequest, PollOffererResponse, PollAnswererResponse, PollResponse, VersionResponse, HealthResponse, ErrorResponse, RondevuClientOptions, } from './types';
package/dist/rondevu.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RondevuConnection } from './connection';
2
- import { RondevuOptions, JoinOptions, ConnectOptions } from './types';
2
+ import { RondevuOptions, JoinOptions } from './types';
3
3
  /**
4
4
  * Main Rondevu WebRTC client with automatic connection management
5
5
  */
@@ -34,10 +34,9 @@ export declare class Rondevu {
34
34
  /**
35
35
  * Connect to an existing connection by ID (answerer role)
36
36
  * @param id - Connection identifier
37
- * @param options - Optional connection options (e.g., { global: true } for global origin)
38
37
  * @returns Promise that resolves to RondevuConnection
39
38
  */
40
- connect(id: string, options?: ConnectOptions): Promise<RondevuConnection>;
39
+ connect(id: string): Promise<RondevuConnection>;
41
40
  /**
42
41
  * Join a topic and discover available peers (answerer role)
43
42
  * @param topic - Topic name
package/dist/rondevu.js CHANGED
@@ -13,7 +13,6 @@ export class Rondevu {
13
13
  this.fetchImpl = options.fetch;
14
14
  this.client = new RondevuClient({
15
15
  baseUrl: this.baseUrl,
16
- origin: options.origin,
17
16
  fetch: options.fetch,
18
17
  });
19
18
  // Auto-generate peer ID if not provided
@@ -75,16 +74,11 @@ export class Rondevu {
75
74
  /**
76
75
  * Connect to an existing connection by ID (answerer role)
77
76
  * @param id - Connection identifier
78
- * @param options - Optional connection options (e.g., { global: true } for global origin)
79
77
  * @returns Promise that resolves to RondevuConnection
80
78
  */
81
- async connect(id, options) {
82
- // Build custom headers if global option is set
83
- const customHeaders = options?.global
84
- ? { 'X-Rondevu-Global': 'true' }
85
- : undefined;
79
+ async connect(id) {
86
80
  // Poll server to get session by ID
87
- const sessionData = await this.findSessionByIdWithClient(id, this.client, customHeaders);
81
+ const sessionData = await this.findSessionByIdWithClient(id, this.client);
88
82
  if (!sessionData) {
89
83
  throw new Error(`Connection ${id} not found or expired`);
90
84
  }
@@ -105,7 +99,7 @@ export class Rondevu {
105
99
  code: id,
106
100
  answer: pc.localDescription.sdp,
107
101
  side: 'answerer',
108
- }, customHeaders);
102
+ });
109
103
  // Create connection object
110
104
  const connectionParams = {
111
105
  id,
@@ -117,7 +111,7 @@ export class Rondevu {
117
111
  pollingInterval: this.pollingInterval,
118
112
  connectionTimeout: this.connectionTimeout,
119
113
  };
120
- const connection = new RondevuConnection(connectionParams, this.client, customHeaders);
114
+ const connection = new RondevuConnection(connectionParams, this.client);
121
115
  // Start polling for ICE candidates
122
116
  connection.startPolling();
123
117
  return connection;
@@ -188,11 +182,11 @@ export class Rondevu {
188
182
  * Find a session by connection ID
189
183
  * This requires polling since we don't know which topic it's in
190
184
  */
191
- async findSessionByIdWithClient(id, client, customHeaders) {
185
+ async findSessionByIdWithClient(id, client) {
192
186
  try {
193
187
  // Try to poll for the session directly
194
188
  // The poll endpoint should return the session data
195
- const response = await client.poll(id, 'answerer', customHeaders);
189
+ const response = await client.poll(id, 'answerer');
196
190
  const answererResponse = response;
197
191
  if (answererResponse.offer) {
198
192
  return {
package/dist/types.d.ts CHANGED
@@ -122,6 +122,13 @@ export interface PollAnswererResponse {
122
122
  * Response from POST /poll (union type)
123
123
  */
124
124
  export type PollResponse = PollOffererResponse | PollAnswererResponse;
125
+ /**
126
+ * Response from GET / - server version information
127
+ */
128
+ export interface VersionResponse {
129
+ /** Git commit hash or version identifier */
130
+ version: string;
131
+ }
125
132
  /**
126
133
  * Response from GET /health
127
134
  */
@@ -141,8 +148,6 @@ export interface ErrorResponse {
141
148
  export interface RondevuClientOptions {
142
149
  /** Base URL of the Rondevu server (e.g., 'https://example.com') */
143
150
  baseUrl: string;
144
- /** Origin header value for session isolation (defaults to baseUrl origin) */
145
- origin?: string;
146
151
  /** Optional fetch implementation (for Node.js environments) */
147
152
  fetch?: typeof fetch;
148
153
  }
@@ -154,8 +159,6 @@ export interface RondevuOptions {
154
159
  baseUrl?: string;
155
160
  /** Peer identifier (optional, auto-generated if not provided) */
156
161
  peerId?: string;
157
- /** Origin header value for session isolation (defaults to baseUrl origin) */
158
- origin?: string;
159
162
  /** Optional fetch implementation (for Node.js environments) */
160
163
  fetch?: typeof fetch;
161
164
  /** WebRTC configuration (ICE servers, etc.) */
@@ -165,13 +168,6 @@ export interface RondevuOptions {
165
168
  /** Connection timeout in milliseconds (default: 30000) */
166
169
  connectionTimeout?: number;
167
170
  }
168
- /**
169
- * Options for connecting to a session
170
- */
171
- export interface ConnectOptions {
172
- /** Use global origin (https://ronde.vu) instead of request origin for session isolation */
173
- global?: boolean;
174
- }
175
171
  /**
176
172
  * Options for joining a topic
177
173
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtr-dev/rondevu-client",
3
- "version": "0.0.9",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript client for Rondevu peer signaling and discovery server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",