@xtr-dev/rondevu-client 0.7.9 → 0.7.11

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/README.md CHANGED
@@ -411,7 +411,8 @@ const offers = await client.offers.create([{
411
411
  sdp: 'v=0...', // Your WebRTC offer SDP
412
412
  topics: ['movie-xyz', 'hd-content'],
413
413
  ttl: 300000, // 5 minutes
414
- secret: 'my-secret-password' // Optional: protect offer (max 128 chars)
414
+ secret: 'my-secret-password', // Optional: protect offer (max 128 chars)
415
+ info: 'Looking for peers in EU region' // Optional: public info (max 128 chars)
415
416
  }]);
416
417
 
417
418
  // Discover peers by topic
@@ -436,14 +437,26 @@ const newPeers = await client.offers.findByTopic('movie-xyz', {
436
437
 
437
438
  ### Authentication
438
439
 
439
- #### `client.register()`
440
+ #### `client.register(customPeerId?)`
440
441
  Register a new peer and receive credentials.
441
442
 
442
443
  ```typescript
444
+ // Auto-generate peer ID
443
445
  const creds = await client.register();
444
- // { peerId: '...', secret: '...' }
446
+ // { peerId: 'f17c195f067255e357232e34cf0735d9', secret: '...' }
447
+
448
+ // Or use a custom peer ID (1-128 characters)
449
+ const customCreds = await client.register('my-custom-peer-id');
450
+ // { peerId: 'my-custom-peer-id', secret: '...' }
445
451
  ```
446
452
 
453
+ **Parameters:**
454
+ - `customPeerId` (optional): Custom peer ID (1-128 characters). If not provided, a random ID will be generated.
455
+
456
+ **Notes:**
457
+ - Returns 409 Conflict if the custom peer ID is already in use
458
+ - Custom peer IDs must be non-empty and between 1-128 characters
459
+
447
460
  ### Topics
448
461
 
449
462
  #### `client.offers.getTopics(options?)`
@@ -477,7 +490,8 @@ const offers = await client.offers.create([
477
490
  sdp: 'v=0...',
478
491
  topics: ['topic-1', 'topic-2'],
479
492
  ttl: 300000, // optional, default 5 minutes
480
- secret: 'my-secret-password' // optional, max 128 chars
493
+ secret: 'my-secret-password', // optional, max 128 chars
494
+ info: 'Looking for peers in EU region' // optional, public info, max 128 chars
481
495
  }
482
496
  ]);
483
497
  ```
package/dist/auth.d.ts CHANGED
@@ -9,8 +9,10 @@ export declare class RondevuAuth {
9
9
  constructor(baseUrl: string, fetchFn?: FetchFunction);
10
10
  /**
11
11
  * Register a new peer and receive credentials
12
+ * @param customPeerId - Optional custom peer ID (1-128 characters). If not provided, a random ID will be generated.
13
+ * @throws Error if registration fails (e.g., peer ID already in use)
12
14
  */
13
- register(): Promise<Credentials>;
15
+ register(customPeerId?: string): Promise<Credentials>;
14
16
  /**
15
17
  * Create Authorization header value
16
18
  */
package/dist/auth.js CHANGED
@@ -11,14 +11,20 @@ export class RondevuAuth {
11
11
  }
12
12
  /**
13
13
  * Register a new peer and receive credentials
14
+ * @param customPeerId - Optional custom peer ID (1-128 characters). If not provided, a random ID will be generated.
15
+ * @throws Error if registration fails (e.g., peer ID already in use)
14
16
  */
15
- async register() {
17
+ async register(customPeerId) {
18
+ const body = {};
19
+ if (customPeerId !== undefined) {
20
+ body.peerId = customPeerId;
21
+ }
16
22
  const response = await this.fetchFn(`${this.baseUrl}/register`, {
17
23
  method: 'POST',
18
24
  headers: {
19
25
  'Content-Type': 'application/json',
20
26
  },
21
- body: JSON.stringify({}),
27
+ body: JSON.stringify(body),
22
28
  });
23
29
  if (!response.ok) {
24
30
  const error = await response.json().catch(() => ({ error: 'Unknown error' }));
package/dist/offers.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface CreateOfferRequest {
4
4
  topics: string[];
5
5
  ttl?: number;
6
6
  secret?: string;
7
+ info?: string;
7
8
  }
8
9
  export interface Offer {
9
10
  id: string;
@@ -15,6 +16,7 @@ export interface Offer {
15
16
  lastSeen: number;
16
17
  secret?: string;
17
18
  hasSecret?: boolean;
19
+ info?: string;
18
20
  answererPeerId?: string;
19
21
  answerSdp?: string;
20
22
  answeredAt?: number;
package/dist/rondevu.d.ts CHANGED
@@ -72,8 +72,9 @@ export declare class Rondevu {
72
72
  get offers(): RondevuOffers;
73
73
  /**
74
74
  * Register and initialize authenticated client
75
+ * @param customPeerId - Optional custom peer ID (1-128 characters). If not provided, a random ID will be generated.
75
76
  */
76
- register(): Promise<Credentials>;
77
+ register(customPeerId?: string): Promise<Credentials>;
77
78
  /**
78
79
  * Check if client is authenticated
79
80
  */
package/dist/rondevu.js CHANGED
@@ -25,9 +25,10 @@ export class Rondevu {
25
25
  }
26
26
  /**
27
27
  * Register and initialize authenticated client
28
+ * @param customPeerId - Optional custom peer ID (1-128 characters). If not provided, a random ID will be generated.
28
29
  */
29
- async register() {
30
- this.credentials = await this.auth.register();
30
+ async register(customPeerId) {
31
+ this.credentials = await this.auth.register(customPeerId);
31
32
  // Create offers API instance
32
33
  this._offers = new RondevuOffers(this.baseUrl, this.credentials, this.fetchFn);
33
34
  return this.credentials;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtr-dev/rondevu-client",
3
- "version": "0.7.9",
3
+ "version": "0.7.11",
4
4
  "description": "TypeScript client for Rondevu topic-based peer discovery and signaling server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",