mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 19:03:24 +00:00
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>
This commit is contained in:
@@ -21,8 +21,9 @@ export class RondevuConnection extends EventEmitter {
|
||||
private connectionTimer?: ReturnType<typeof setTimeout>;
|
||||
private isPolling: boolean = false;
|
||||
private isClosed: boolean = false;
|
||||
private customHeaders?: Record<string, string>;
|
||||
|
||||
constructor(params: RondevuConnectionParams, client: RondevuClient) {
|
||||
constructor(params: RondevuConnectionParams, client: RondevuClient, customHeaders?: Record<string, string>) {
|
||||
super();
|
||||
this.id = params.id;
|
||||
this.topic = params.topic;
|
||||
@@ -34,6 +35,7 @@ export class RondevuConnection extends EventEmitter {
|
||||
this.dataChannels = new Map();
|
||||
this.pollingIntervalMs = params.pollingInterval;
|
||||
this.connectionTimeoutMs = params.connectionTimeout;
|
||||
this.customHeaders = customHeaders;
|
||||
|
||||
this.setupEventHandlers();
|
||||
this.startConnectionTimeout();
|
||||
@@ -119,7 +121,7 @@ export class RondevuConnection extends EventEmitter {
|
||||
code: this.id,
|
||||
candidate: JSON.stringify(candidate.toJSON()),
|
||||
side: this.role,
|
||||
});
|
||||
}, this.customHeaders);
|
||||
} catch (err: any) {
|
||||
throw new Error(`Failed to send ICE candidate: ${err.message}`);
|
||||
}
|
||||
@@ -169,7 +171,7 @@ export class RondevuConnection extends EventEmitter {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.client.poll(this.id, this.role);
|
||||
const response = await this.client.poll(this.id, this.role, this.customHeaders);
|
||||
|
||||
if (this.role === 'offerer') {
|
||||
const offererResponse = response as { answer: string | null; answerCandidates: string[] };
|
||||
|
||||
Reference in New Issue
Block a user