@xtr-dev/rondevu-client 0.0.4 → 0.0.6
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/dist/rondevu.d.ts +6 -3
- package/dist/rondevu.js +19 -8
- package/dist/types.d.ts +2 -2
- package/package.json +3 -2
package/dist/rondevu.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { RondevuOptions, JoinOptions } from './types';
|
|
|
6
6
|
export declare class Rondevu {
|
|
7
7
|
readonly peerId: string;
|
|
8
8
|
private client;
|
|
9
|
+
private baseUrl;
|
|
10
|
+
private fetchImpl?;
|
|
9
11
|
private rtcConfig?;
|
|
10
12
|
private pollingInterval;
|
|
11
13
|
private connectionTimeout;
|
|
@@ -13,7 +15,7 @@ export declare class Rondevu {
|
|
|
13
15
|
* Creates a new Rondevu client instance
|
|
14
16
|
* @param options - Client configuration options
|
|
15
17
|
*/
|
|
16
|
-
constructor(options
|
|
18
|
+
constructor(options?: RondevuOptions);
|
|
17
19
|
/**
|
|
18
20
|
* Generate a unique peer ID
|
|
19
21
|
*/
|
|
@@ -32,9 +34,10 @@ export declare class Rondevu {
|
|
|
32
34
|
/**
|
|
33
35
|
* Connect to an existing connection by ID (answerer role)
|
|
34
36
|
* @param id - Connection identifier
|
|
37
|
+
* @param origin - Optional origin header override for this connection
|
|
35
38
|
* @returns Promise that resolves to RondevuConnection
|
|
36
39
|
*/
|
|
37
|
-
connect(id: string): Promise<RondevuConnection>;
|
|
40
|
+
connect(id: string, origin?: string): Promise<RondevuConnection>;
|
|
38
41
|
/**
|
|
39
42
|
* Join a topic and discover available peers (answerer role)
|
|
40
43
|
* @param topic - Topic name
|
|
@@ -54,5 +57,5 @@ export declare class Rondevu {
|
|
|
54
57
|
* Find a session by connection ID
|
|
55
58
|
* This requires polling since we don't know which topic it's in
|
|
56
59
|
*/
|
|
57
|
-
private
|
|
60
|
+
private findSessionByIdWithClient;
|
|
58
61
|
}
|
package/dist/rondevu.js
CHANGED
|
@@ -8,9 +8,11 @@ export class Rondevu {
|
|
|
8
8
|
* Creates a new Rondevu client instance
|
|
9
9
|
* @param options - Client configuration options
|
|
10
10
|
*/
|
|
11
|
-
constructor(options) {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.baseUrl = options.baseUrl || 'https://rondevu.xtrdev.workers.dev';
|
|
13
|
+
this.fetchImpl = options.fetch;
|
|
12
14
|
this.client = new RondevuClient({
|
|
13
|
-
baseUrl:
|
|
15
|
+
baseUrl: this.baseUrl,
|
|
14
16
|
origin: options.origin,
|
|
15
17
|
fetch: options.fetch,
|
|
16
18
|
});
|
|
@@ -73,11 +75,20 @@ export class Rondevu {
|
|
|
73
75
|
/**
|
|
74
76
|
* Connect to an existing connection by ID (answerer role)
|
|
75
77
|
* @param id - Connection identifier
|
|
78
|
+
* @param origin - Optional origin header override for this connection
|
|
76
79
|
* @returns Promise that resolves to RondevuConnection
|
|
77
80
|
*/
|
|
78
|
-
async connect(id) {
|
|
81
|
+
async connect(id, origin) {
|
|
82
|
+
// Create a client with overridden origin if specified
|
|
83
|
+
const client = origin
|
|
84
|
+
? new RondevuClient({
|
|
85
|
+
baseUrl: this.baseUrl,
|
|
86
|
+
origin,
|
|
87
|
+
fetch: this.fetchImpl,
|
|
88
|
+
})
|
|
89
|
+
: this.client;
|
|
79
90
|
// Poll server to get session by ID
|
|
80
|
-
const sessionData = await this.
|
|
91
|
+
const sessionData = await this.findSessionByIdWithClient(id, client);
|
|
81
92
|
if (!sessionData) {
|
|
82
93
|
throw new Error(`Connection ${id} not found or expired`);
|
|
83
94
|
}
|
|
@@ -94,7 +105,7 @@ export class Rondevu {
|
|
|
94
105
|
// Wait for ICE gathering
|
|
95
106
|
await this.waitForIceGathering(pc);
|
|
96
107
|
// Send answer to server
|
|
97
|
-
await
|
|
108
|
+
await client.sendAnswer({
|
|
98
109
|
code: id,
|
|
99
110
|
answer: pc.localDescription.sdp,
|
|
100
111
|
side: 'answerer',
|
|
@@ -110,7 +121,7 @@ export class Rondevu {
|
|
|
110
121
|
pollingInterval: this.pollingInterval,
|
|
111
122
|
connectionTimeout: this.connectionTimeout,
|
|
112
123
|
};
|
|
113
|
-
const connection = new RondevuConnection(connectionParams,
|
|
124
|
+
const connection = new RondevuConnection(connectionParams, client);
|
|
114
125
|
// Start polling for ICE candidates
|
|
115
126
|
connection.startPolling();
|
|
116
127
|
return connection;
|
|
@@ -181,11 +192,11 @@ export class Rondevu {
|
|
|
181
192
|
* Find a session by connection ID
|
|
182
193
|
* This requires polling since we don't know which topic it's in
|
|
183
194
|
*/
|
|
184
|
-
async
|
|
195
|
+
async findSessionByIdWithClient(id, client) {
|
|
185
196
|
try {
|
|
186
197
|
// Try to poll for the session directly
|
|
187
198
|
// The poll endpoint should return the session data
|
|
188
|
-
const response = await
|
|
199
|
+
const response = await client.poll(id, 'answerer');
|
|
189
200
|
const answererResponse = response;
|
|
190
201
|
if (answererResponse.offer) {
|
|
191
202
|
return {
|
package/dist/types.d.ts
CHANGED
|
@@ -150,8 +150,8 @@ export interface RondevuClientOptions {
|
|
|
150
150
|
* Configuration options for Rondevu WebRTC client
|
|
151
151
|
*/
|
|
152
152
|
export interface RondevuOptions {
|
|
153
|
-
/** Base URL of the Rondevu server (
|
|
154
|
-
baseUrl
|
|
153
|
+
/** Base URL of the Rondevu server (defaults to 'https://rondevu.xtrdev.workers.dev') */
|
|
154
|
+
baseUrl?: string;
|
|
155
155
|
/** Peer identifier (optional, auto-generated if not provided) */
|
|
156
156
|
peerId?: string;
|
|
157
157
|
/** Origin header value for session isolation (defaults to baseUrl origin) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtr-dev/rondevu-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "TypeScript client for Rondevu peer signaling and discovery server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
|
-
"prepublishOnly": "npm run build"
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"publish": "npm publish"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"webrtc",
|