node-rtc-connection 1.0.14 → 1.0.16
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/dist/index.cjs +54 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +54 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/ice/RTCIceTransport.js +46 -4
- package/src/peerconnection/RTCPeerConnection.js +4 -3
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var require$$0$1 = require('events');
|
|
4
4
|
var require$$0 = require('dgram');
|
|
5
5
|
var require$$3 = require('crypto');
|
|
6
|
-
var require$$
|
|
6
|
+
var require$$5 = require('os');
|
|
7
7
|
var require$$1 = require('net');
|
|
8
8
|
|
|
9
9
|
function getDefaultExportFromCjs (x) {
|
|
@@ -1772,16 +1772,43 @@ function requireRTCIceTransport () {
|
|
|
1772
1772
|
throw new TypeError('Candidate must be an object');
|
|
1773
1773
|
}
|
|
1774
1774
|
|
|
1775
|
-
//
|
|
1775
|
+
// Ensure candidate is properly formatted
|
|
1776
|
+
// If it's a plain object with a candidate string, parse it
|
|
1777
|
+
let parsedCandidate = candidate;
|
|
1778
|
+
const RTCIceCandidate = requireRTCIceCandidate();
|
|
1779
|
+
|
|
1780
|
+
if (!(candidate instanceof RTCIceCandidate)) {
|
|
1781
|
+
// Try to create an RTCIceCandidate to parse and validate
|
|
1782
|
+
try {
|
|
1783
|
+
parsedCandidate = new RTCIceCandidate(candidate);
|
|
1784
|
+
} catch (err) {
|
|
1785
|
+
console.warn('Failed to parse remote candidate:', err.message);
|
|
1786
|
+
// Store the original anyway for compatibility
|
|
1787
|
+
this._remoteCandidates.push(candidate);
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
} else {
|
|
1791
|
+
parsedCandidate = candidate;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
// Validate that candidate has required properties for connectivity checks
|
|
1795
|
+
if (!parsedCandidate.address || parsedCandidate.port === null || parsedCandidate.port === undefined) {
|
|
1796
|
+
console.warn('Remote candidate missing address or port, skipping connectivity checks');
|
|
1797
|
+
// Store the original candidate for compatibility
|
|
1798
|
+
this._remoteCandidates.push(candidate);
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
// Store the original candidate (for getRemoteCandidates compatibility)
|
|
1776
1803
|
this._remoteCandidates.push(candidate);
|
|
1777
1804
|
|
|
1778
1805
|
// Start connectivity checks if we're in checking state
|
|
1779
1806
|
if (this._state === RTCIceTransportState.CHECKING && this._localCandidates.length > 0) {
|
|
1780
|
-
// Create pairs
|
|
1807
|
+
// Create pairs using the parsed candidate for connectivity checks
|
|
1781
1808
|
for (const localCandidate of this._localCandidates) {
|
|
1782
1809
|
const pair = {
|
|
1783
1810
|
local: localCandidate,
|
|
1784
|
-
remote:
|
|
1811
|
+
remote: parsedCandidate,
|
|
1785
1812
|
state: 'waiting'
|
|
1786
1813
|
};
|
|
1787
1814
|
this._candidatePairs.push(pair);
|
|
@@ -1897,7 +1924,7 @@ function requireRTCIceTransport () {
|
|
|
1897
1924
|
* @private
|
|
1898
1925
|
*/
|
|
1899
1926
|
async _gatherHostCandidates() {
|
|
1900
|
-
const os = require$$
|
|
1927
|
+
const os = require$$5;
|
|
1901
1928
|
const interfaces = os.networkInterfaces();
|
|
1902
1929
|
|
|
1903
1930
|
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
@@ -2162,12 +2189,27 @@ function requireRTCIceTransport () {
|
|
|
2162
2189
|
* @param {Object} pair - Candidate pair
|
|
2163
2190
|
* @private
|
|
2164
2191
|
*/
|
|
2192
|
+
/**
|
|
2193
|
+
* Send ICE connectivity check to remote candidate
|
|
2194
|
+
* @param {Object} pair - Candidate pair
|
|
2195
|
+
* @private
|
|
2196
|
+
*/
|
|
2165
2197
|
_sendConnectivityCheck(pair) {
|
|
2166
2198
|
const socket = this._sockets.get(pair.local.foundation);
|
|
2167
2199
|
if (!socket || socket.type === 'turn') {
|
|
2168
2200
|
return; // Skip TURN candidates for now
|
|
2169
2201
|
}
|
|
2170
2202
|
|
|
2203
|
+
// Validate remote candidate has required properties
|
|
2204
|
+
if (!pair.remote.address || !pair.remote.port) {
|
|
2205
|
+
console.warn('Cannot send connectivity check: remote candidate missing address or port', {
|
|
2206
|
+
address: pair.remote.address,
|
|
2207
|
+
port: pair.remote.port,
|
|
2208
|
+
candidate: pair.remote.candidate
|
|
2209
|
+
});
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2171
2213
|
const transactionId = crypto.randomBytes(12);
|
|
2172
2214
|
const request = this._createBindingRequest(transactionId);
|
|
2173
2215
|
|
|
@@ -2178,7 +2220,7 @@ function requireRTCIceTransport () {
|
|
|
2178
2220
|
}
|
|
2179
2221
|
});
|
|
2180
2222
|
} catch (err) {
|
|
2181
|
-
console.error(`Error sending connectivity check:`, err);
|
|
2223
|
+
console.error(`Error sending connectivity check to ${pair.remote.address || 'unknown'}:${pair.remote.port || 'unknown'}:`, err);
|
|
2182
2224
|
}
|
|
2183
2225
|
}
|
|
2184
2226
|
|
|
@@ -4787,7 +4829,7 @@ function requireRTCPeerConnection () {
|
|
|
4787
4829
|
const { address, port } = await this._networkTransport.listen(0, '0.0.0.0');
|
|
4788
4830
|
|
|
4789
4831
|
// Get local address (try to find non-localhost)
|
|
4790
|
-
const os = require$$
|
|
4832
|
+
const os = require$$5;
|
|
4791
4833
|
const interfaces = os.networkInterfaces();
|
|
4792
4834
|
let localAddress = '127.0.0.1';
|
|
4793
4835
|
|
|
@@ -5044,10 +5086,11 @@ function requireRTCPeerConnection () {
|
|
|
5044
5086
|
if (this._sctpTransport.state === 'connected') {
|
|
5045
5087
|
for (const channel of this._dataChannels.values()) {
|
|
5046
5088
|
if (channel.readyState === 'connecting') {
|
|
5047
|
-
channel
|
|
5048
|
-
|
|
5049
|
-
// Hook up channel to network transport
|
|
5089
|
+
// Hook up channel to network transport first
|
|
5050
5090
|
this._connectChannelToNetwork(channel);
|
|
5091
|
+
|
|
5092
|
+
// Then set state to open (emits 'open' event)
|
|
5093
|
+
channel._setStateToOpen();
|
|
5051
5094
|
}
|
|
5052
5095
|
}
|
|
5053
5096
|
}
|
|
@@ -5276,7 +5319,7 @@ function requireRTCPeerConnection () {
|
|
|
5276
5319
|
return RTCPeerConnection_1;
|
|
5277
5320
|
}
|
|
5278
5321
|
|
|
5279
|
-
var version = "1.0.
|
|
5322
|
+
var version = "1.0.16";
|
|
5280
5323
|
var require$$10 = {
|
|
5281
5324
|
version: version};
|
|
5282
5325
|
|