Integrate secret parameter into peer classes

- Add secret field to PeerOptions interface
- Pass secret when creating offers in CreatingOfferState
- Pass secret when answering offers in AnsweringState
- Bump version to 0.7.7

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-16 22:13:19 +01:00
parent 3530213870
commit 0ac1f94502
5 changed files with 8 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ export class AnsweringState extends PeerState {
// Send answer to server BEFORE setLocalDescription
// This registers us as the answerer so ICE candidates will be accepted
await this.peer.offersApi.answer(offerId, answer.sdp!);
await this.peer.offersApi.answer(offerId, answer.sdp!, options.secret);
// Enable trickle ICE - set up handler before ICE gathering starts
this.setupIceCandidateHandler();

View File

@@ -36,7 +36,8 @@ export class CreatingOfferState extends PeerState {
const offers = await this.peer.offersApi.create([{
sdp: offer.sdp!,
topics: options.topics,
ttl: options.ttl || 300000
ttl: options.ttl || 300000,
secret: options.secret
}]);
const offerId = offers[0].id;

View File

@@ -22,6 +22,8 @@ export interface PeerOptions {
topics: string[];
/** How long the offer should live (milliseconds) */
ttl?: number;
/** Optional secret to protect the offer (max 128 characters) */
secret?: string;
/** Whether to create a data channel automatically (for offerer) */
createDataChannel?: boolean;
/** Label for the automatically created data channel */