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:
2025-11-07 23:45:52 +01:00
parent de6244cf24
commit 9df9966381
5 changed files with 38 additions and 26 deletions

View File

@@ -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[] };