4 Commits

Author SHA1 Message Date
895e7765f9 Update README: Remove custom peer ID documentation
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:22:58 +01:00
49d3984640 Remove custom peer ID feature for security
Always generate cryptographically random 128-bit peer IDs to prevent peer ID hijacking vulnerability. This ensures peer IDs are secure through collision resistance rather than relying on expiration-based protection.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:19:07 +01:00
6057c3c582 0.7.11 2025-11-22 17:34:11 +01:00
255fe42a43 Add optional info field to offers
- Add info field to CreateOfferRequest and Offer types
- Update README with info field examples and documentation
- Public metadata field visible in all API responses

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 17:34:11 +01:00
6 changed files with 19 additions and 30 deletions

View File

@@ -411,7 +411,8 @@ const offers = await client.offers.create([{
sdp: 'v=0...', // Your WebRTC offer SDP sdp: 'v=0...', // Your WebRTC offer SDP
topics: ['movie-xyz', 'hd-content'], topics: ['movie-xyz', 'hd-content'],
ttl: 300000, // 5 minutes ttl: 300000, // 5 minutes
secret: 'my-secret-password' // Optional: protect offer (max 128 chars) secret: 'my-secret-password', // Optional: protect offer (max 128 chars)
info: 'Looking for peers in EU region' // Optional: public info (max 128 chars)
}]); }]);
// Discover peers by topic // Discover peers by topic
@@ -436,26 +437,16 @@ const newPeers = await client.offers.findByTopic('movie-xyz', {
### Authentication ### Authentication
#### `client.register(customPeerId?)` #### `client.register()`
Register a new peer and receive credentials. Register a new peer and receive credentials.
Generates a cryptographically random 128-bit peer ID.
```typescript ```typescript
// Auto-generate peer ID
const creds = await client.register(); const creds = await client.register();
// { peerId: 'f17c195f067255e357232e34cf0735d9', secret: '...' } // { peerId: 'f17c195f067255e357232e34cf0735d9', secret: '...' }
// Or use a custom peer ID (1-128 characters)
const customCreds = await client.register('my-custom-peer-id');
// { peerId: 'my-custom-peer-id', secret: '...' }
``` ```
**Parameters:**
- `customPeerId` (optional): Custom peer ID (1-128 characters). If not provided, a random ID will be generated.
**Notes:**
- Returns 409 Conflict if the custom peer ID is already in use
- Custom peer IDs must be non-empty and between 1-128 characters
### Topics ### Topics
#### `client.offers.getTopics(options?)` #### `client.offers.getTopics(options?)`
@@ -489,7 +480,8 @@ const offers = await client.offers.create([
sdp: 'v=0...', sdp: 'v=0...',
topics: ['topic-1', 'topic-2'], topics: ['topic-1', 'topic-2'],
ttl: 300000, // optional, default 5 minutes ttl: 300000, // optional, default 5 minutes
secret: 'my-secret-password' // optional, max 128 chars secret: 'my-secret-password', // optional, max 128 chars
info: 'Looking for peers in EU region' // optional, public info, max 128 chars
} }
]); ]);
``` ```

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@xtr-dev/rondevu-client", "name": "@xtr-dev/rondevu-client",
"version": "0.7.10", "version": "0.7.11",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@xtr-dev/rondevu-client", "name": "@xtr-dev/rondevu-client",
"version": "0.7.10", "version": "0.7.11",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@xtr-dev/rondevu-client": "^0.5.1" "@xtr-dev/rondevu-client": "^0.5.1"

View File

@@ -1,6 +1,6 @@
{ {
"name": "@xtr-dev/rondevu-client", "name": "@xtr-dev/rondevu-client",
"version": "0.7.10", "version": "0.7.12",
"description": "TypeScript client for Rondevu topic-based peer discovery and signaling server", "description": "TypeScript client for Rondevu topic-based peer discovery and signaling server",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@@ -29,21 +29,16 @@ export class RondevuAuth {
/** /**
* Register a new peer and receive credentials * Register a new peer and receive credentials
* @param customPeerId - Optional custom peer ID (1-128 characters). If not provided, a random ID will be generated. * Generates a cryptographically random peer ID (128-bit)
* @throws Error if registration fails (e.g., peer ID already in use) * @throws Error if registration fails
*/ */
async register(customPeerId?: string): Promise<Credentials> { async register(): Promise<Credentials> {
const body: { peerId?: string } = {};
if (customPeerId !== undefined) {
body.peerId = customPeerId;
}
const response = await this.fetchFn(`${this.baseUrl}/register`, { const response = await this.fetchFn(`${this.baseUrl}/register`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify(body), body: JSON.stringify({}),
}); });
if (!response.ok) { if (!response.ok) {

View File

@@ -9,6 +9,7 @@ export interface CreateOfferRequest {
topics: string[]; topics: string[];
ttl?: number; ttl?: number;
secret?: string; secret?: string;
info?: string;
} }
export interface Offer { export interface Offer {
@@ -21,6 +22,7 @@ export interface Offer {
lastSeen: number; lastSeen: number;
secret?: string; secret?: string;
hasSecret?: boolean; hasSecret?: boolean;
info?: string;
answererPeerId?: string; answererPeerId?: string;
answerSdp?: string; answerSdp?: string;
answeredAt?: number; answeredAt?: number;

View File

@@ -100,10 +100,10 @@ export class Rondevu {
/** /**
* Register and initialize authenticated client * Register and initialize authenticated client
* @param customPeerId - Optional custom peer ID (1-128 characters). If not provided, a random ID will be generated. * Generates a cryptographically random peer ID (128-bit)
*/ */
async register(customPeerId?: string): Promise<Credentials> { async register(): Promise<Credentials> {
this.credentials = await this.auth.register(customPeerId); this.credentials = await this.auth.register();
// Create offers API instance // Create offers API instance
this._offers = new RondevuOffers( this._offers = new RondevuOffers(