New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-troubleshoot

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-troubleshoot - npm Package Compare versions

Comparing version 0.4.0 to 1.0.0

2

package.json
{
"name": "webrtc-troubleshoot",
"version": "0.4.0",
"version": "1.0.0",
"description": "A way to add webrtc troubleshooting to your app",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,2 +12,3 @@ import TestSuite from '../utils/TestSuite';

this.deferred = Promise.defer();
this.stopOnFailure = true;

@@ -22,3 +23,8 @@ this.addTest(new CameraResolutionTest([[320, 240]], options));

start () {
return super.start().then(this.deferred.resolve, this.deferred.reject);
super.start().then((results) => {
return this.deferred.resolve(results);
}, (err) => {
return this.deferred.reject(err);
});
return this.deferred.promise;
}

@@ -25,0 +31,0 @@

@@ -12,2 +12,3 @@ // adapted from https://github.com/webrtc/testrtc

super(options);
this.name = 'Camera resolution test';
this.resolutions = resolutions;

@@ -29,3 +30,14 @@ this.duration = options.duration;

this.logger.log(`Advanced Camera Test with resolutions: ${JSON.stringify(settings.resolutions)} and duration ${JSON.stringify(settings.duration)}`);
return this.startGetUserMedia(this.resolutions[this.currentResolution]).then(this.resolve.bind(this), this.reject.bind(this));
return this.startGetUserMedia(this.resolutions[this.currentResolution]).then(() => {
if (!this.hasError) {
return this.resolve(this.getResults());
} else {
const err = new Error('Camera resolution check failed');
err.details = this.getResults();
return this.reject(err);
}
}, (err) => {
err.details = this.getResults();
return this.reject(err);
});
}

@@ -44,2 +56,3 @@

reportSuccess (str) {
this.log.push(str);
this.logger.log(`SUCCESS: ${str}`);

@@ -49,2 +62,4 @@ }

reportError (str) {
this.hasError = true;
this.log.push(str);
this.logger.warn(`${str}`);

@@ -153,2 +168,4 @@ }

return call.gatherStats(call.pc1, 100);
}, (err) => {
return Promise.reject(err);
}).then(({stats, statsCollectTime}) => {

@@ -158,2 +175,4 @@ const result = this.analyzeStats({resolution, videoElement, stream, frameChecker, stats, statsCollectTime});

return result;
}, (err) => {
return Promise.reject(err);
});

@@ -163,2 +182,3 @@ }

analyzeStats ({resolution, videoElement, stream, frameChecker, stats, statsCollectTime}) {
this.stats = stats;
const googAvgEncodeTime = [];

@@ -165,0 +185,0 @@ const googAvgFrameRateInput = [];

@@ -14,9 +14,9 @@ import Test from '../utils/Test';

this.options.iceServers.forEach((iceServer) => {
this.logger.log(`webrtc-troubleshooter: Using ICE Server: ${iceServer.url}`);
this.logger.log(`Using ICE Server: ${iceServer.url}`);
});
if (this.options.iceServers.length === 0) {
this.logger.error('webrtc-troubleshooter: no ice servers provided');
this.logger.error('no ice servers provided');
}
} else {
this.logger.log('webrtc-troubleshooter: Using default ICE Servers');
this.logger.log('Using default ICE Servers');
}

@@ -31,15 +31,15 @@ }

const connectivityCheckFailure = window.setTimeout(() => {
this.logger.error('webrtc-troubleshooter: Connectivity timeout error');
this.logger.error('Connectivity timeout error');
this.reject(new Error('connectivity timeout'));
}, 10000);
this.pc2.on('ice', (candidate) => {
this.logger.log('webrtc-troubleshooter: pc2 ICE candidate');
this.logger.log('pc2 ICE candidate');
this.pc1.processIce(candidate);
});
this.pc1.on('ice', (candidate) => {
this.logger.log('webrtc-troubleshooter: pc1 ICE candidate');
this.logger.log('pc1 ICE candidate');
this.pc2.processIce(candidate);
});
this.pc2.on('answer', (answer) => {
this.logger.log('webrtc-troubleshooter: pc2 handle answer');
this.logger.log('pc2 handle answer');
this.pc1.handleAnswer(answer);

@@ -50,15 +50,15 @@ });

this.pc1.on('offer', (offer) => {
this.logger.log('webrtc-troubleshooter: pc1 offer');
this.logger.log('pc1 offer');
this.pc2.handleOffer(offer, (err) => {
if (err) {
this.logger.error('webrtc-troubleshooter: pc2 failed to handle offer');
this.logger.error('pc2 failed to handle offer');
this.reject(err);
}
this.logger.log('webrtc-troubleshooter: pc2 handle offer');
this.logger.log('pc2 handle offer');
this.pc2.answer((err, answer) => {
if (err) {
this.logger.error('webrtc-troubleshooter: pc2 failed answer');
this.logger.error('pc2 failed answer');
this.reject(err);
}
this.logger.log(`webrtc-troubleshooter: pc2 successful ${answer.type}`);
this.logger.log(`pc2 successful ${answer.type}`);
});

@@ -91,3 +91,3 @@ });

window.clearTimeout(connectivityCheckFailure);
this.logger.log(`webrtc-troubleshooter: Received ${messagesReceived} messages`);
this.logger.log(`Received ${messagesReceived} messages`);
this.resolve();

@@ -99,3 +99,3 @@ }

channel.onopen = () => {
this.logger.log(`webrtc-troubleshooter: Sending ${messageQueue.length} messages`);
this.logger.log(`Sending ${messageQueue.length} messages`);
messageQueue2.forEach(channel.send.bind(channel));

@@ -102,0 +102,0 @@ };

@@ -41,2 +41,3 @@ // adapted from https://github.com/webrtc/testrtc/blob/master/src/js/bandwidth_test.js

this.log = [];
this.stats = {};
}

@@ -46,3 +47,2 @@

super.start();
this.log = this.results = {log: []};

@@ -63,5 +63,22 @@ this.addLog('info', 'Video Bandwidth Test');

return this.doGetUserMedia(this.constraints);
return this.doGetUserMedia(this.constraints).then(() => {
if (!this.hasError) {
return this.resolve(this.getResults());
} else {
return this.reject(new Error('Video Bandwidth Error'), this.getResults());
}
}, (err) => {
return this.reject(err, this.getResults());
});
}
getResults () {
const results = {
log: this.log,
stats: this.stats,
constraints: this.constraints
};
return results;
}
addLog (level, msg) {

@@ -72,3 +89,6 @@ this.logger[level.toLowerCase()](msg);

}
this.results.log.push(`${level}: ${msg}`);
if (level === 'error') {
this.hasError = true;
}
this.log.push(`${level}: ${msg}`);
}

@@ -81,7 +101,6 @@

this.addLog('info', { status: 'success', camera });
return this.gotStream(stream).then(this.resolve.bind(this), this.reject.bind(this));
return this.gotStream(stream);
}, (error) => {
this.addLog('error', {'status': 'fail', 'error': error});
this.addLog('error', `Failed to get access to local media due to error: ${error.name}`);
console.warn('rejecting2', this);
return this.reject(error);

@@ -177,3 +196,3 @@ });

this.call = null;
const stats = this.results.stats = {};
const stats = this.stats;

@@ -180,0 +199,0 @@ if (isWebkit) {

@@ -5,5 +5,9 @@ export default class TestSuite {

this.allTestsComplete = false;
this.stopOnFailure = false;
this.running = false;
this.queue = [];
this.logger = options.logger || console;
this.hasError = false;
this.results = [];
}

@@ -17,3 +21,13 @@

return new Promise((resolve, reject) => {
return this.runNextTest().then(resolve, reject);
return this.runNextTest().then(() => {
if (this.hasError) {
const error = new Error('A test failure occurred');
error.details = this.results;
return reject(error);
}
return resolve(this.results);
}, (err) => {
err.details = this.results;
return reject(err);
});
});

@@ -34,13 +48,25 @@ }

const next = () => {
const next = (err) => {
test.running = false;
test.destroy();
if (err) {
this.hasError = true;
if (this.stopOnFailure) {
return Promise.reject(err);
}
}
return this.runNextTest();
};
return test.start().then(() => {
return test.start().then((results) => {
if (results) {
this.results.push(results);
}
return next();
}, (err) => {
this.logger.error('Test failure', err, test);
return next();
this.hasError = true;
const errInfo = { message: err.message, details: err.details };
this.results.push(errInfo);
this.logger.error('Test failure', errInfo, test);
return next(err);
});

@@ -47,0 +73,0 @@ }

@@ -16,3 +16,3 @@ /* global RTCPeerConnection, mozRTCPeerConnection */

establishConnection () {
return this.pc1.createOffer().then(this.gotOffer.bind(this), console.error.bind(console));
return this.pc1.createOffer().then(this.gotOffer.bind(this), () => this.logger.error(...arguments));
}

@@ -19,0 +19,0 @@

@@ -12,4 +12,4 @@ /* global WebRTCTroubleshooter */

const testCompleted = function (test, success) {
console.log('test completed', test.name, success ? 'success' : 'failure');
const testCompleted = function (test, success, res) {
console.log('test completed', test.name, success ? 'success' : 'failure', res, res ? res.details : 'no results');
};

@@ -63,4 +63,6 @@

testSuite.start().then(function () {
console.log('Finished the tests');
testSuite.start().then(function (results) {
console.log('Finished the tests', results);
}, function(err) {
console.warn('test failure', err, err.details);
});

@@ -67,0 +69,0 @@ };

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc