@xtr-dev/rondevu-client 0.7.8 → 0.7.10

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
@@ -436,14 +436,26 @@ const newPeers = await client.offers.findByTopic('movie-xyz', {
436
436
 
437
437
  ### Authentication
438
438
 
439
- #### `client.register()`
439
+ #### `client.register(customPeerId?)`
440
440
  Register a new peer and receive credentials.
441
441
 
442
442
  ```typescript
443
+ // Auto-generate peer ID
443
444
  const creds = await client.register();
444
- // { peerId: '...', secret: '...' }
445
+ // { peerId: 'f17c195f067255e357232e34cf0735d9', secret: '...' }
446
+
447
+ // Or use a custom peer ID (1-128 characters)
448
+ const customCreds = await client.register('my-custom-peer-id');
449
+ // { peerId: 'my-custom-peer-id', secret: '...' }
445
450
  ```
446
451
 
452
+ **Parameters:**
453
+ - `customPeerId` (optional): Custom peer ID (1-128 characters). If not provided, a random ID will be generated.
454
+
455
+ **Notes:**
456
+ - Returns 409 Conflict if the custom peer ID is already in use
457
+ - Custom peer IDs must be non-empty and between 1-128 characters
458
+
447
459
  ### Topics
448
460
 
449
461
  #### `client.offers.getTopics(options?)`
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' }));
@@ -58,6 +58,12 @@ export default class RondevuPeer extends EventEmitter<PeerEvents> {
58
58
  * Add a media track to the connection
59
59
  */
60
60
  addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender;
61
+ /**
62
+ * Create a data channel for sending and receiving arbitrary data
63
+ * This should typically be called by the offerer before creating the offer
64
+ * The answerer will receive the channel via the 'datachannel' event
65
+ */
66
+ createDataChannel(label: string, options?: RTCDataChannelInit): RTCDataChannel;
61
67
  /**
62
68
  * Close the connection and clean up
63
69
  */
@@ -123,6 +123,14 @@ export default class RondevuPeer extends EventEmitter {
123
123
  addTrack(track, ...streams) {
124
124
  return this.pc.addTrack(track, ...streams);
125
125
  }
126
+ /**
127
+ * Create a data channel for sending and receiving arbitrary data
128
+ * This should typically be called by the offerer before creating the offer
129
+ * The answerer will receive the channel via the 'datachannel' event
130
+ */
131
+ createDataChannel(label, options) {
132
+ return this.pc.createDataChannel(label, options);
133
+ }
126
134
  /**
127
135
  * Close the connection and clean up
128
136
  */
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.8",
3
+ "version": "0.7.10",
4
4
  "description": "TypeScript client for Rondevu topic-based peer discovery and signaling server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",