@hive-p2p/server 1.0.29 → 1.0.31

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.
@@ -121,11 +121,14 @@ export class NodeServices {
121
121
  static deriveSTUNServers(bootstraps) {
122
122
  /** @type {Array<{urls: string}>} */
123
123
  const stunUrls = [];
124
- for (const b of bootstraps) {
125
- const domain = b.includes(':') ? b.split(':')[1].replace('//', '') : b;
126
- domain.replace('/ws', '/signal'); // in case someone put domain/ws
127
- const port = parseInt(b.split(':')[2]) + 1;
128
- stunUrls.push({ urls: `stun:${domain}:${port}` });
124
+ for (const b of bootstraps) { // {urls: 'stun:42312:NaN'}
125
+ if (!b.includes(':')) continue;
126
+ const url = b.replace('/ws', '/signal'); // in case someone put domain/ws
127
+ url.replace('/wss', '/signal'); // in case someone put domain/wss
128
+ url.replace('ws://', 'stun:');
129
+ url.replace('wss://', 'stun:');
130
+ if (!url.includes('stun:')) continue;
131
+ stunUrls.push({ urls: url });
129
132
  }
130
133
  if (!TRANSPORTS.CENTRALIZED_STUN_SERVERS) return stunUrls;
131
134
 
@@ -149,8 +149,9 @@ export class Topologist {
149
149
  const isBrowser = typeof window !== 'undefined';
150
150
  const isSecure = isBrowser && window.location.protocol === 'https:';
151
151
  const protocol = isSecure ? 'wss://' : 'ws://';
152
- const host = isBrowser ? window.location.host : url; // Récupère le host du browser
153
-
152
+ const hasWsSuffix = url.endsWith('/ws');
153
+ const host = isBrowser && !hasWsSuffix ? window.location.host : url;
154
+
154
155
  // Build full URL if not already prefixed
155
156
  return url.startsWith('ws') ? url : `${protocol}${host}`;
156
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hive-p2p/server",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },