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

sip.js

Package Overview
Dependencies
Maintainers
3
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sip.js - npm Package Compare versions

Comparing version 0.7.7 to 0.7.8

dist/sip-0.7.8.js

2

bower.json
{
"name": "sip.js",
"version": "0.7.7",
"version": "0.7.8",
"authors": [

@@ -5,0 +5,0 @@ "James Criscuolo <james@onsip.com>",

@@ -5,3 +5,3 @@ {

"description": "A simple, intuitive, and powerful JavaScript signaling library",
"version": "0.7.7",
"version": "0.7.8",
"main": "src/index.js",

@@ -8,0 +8,0 @@ "browser": {

@@ -40,2 +40,3 @@ "use strict";

addEventListener: getPrefixedProperty(toplevel, 'addEventListener'),
removeEventListener: getPrefixedProperty(toplevel, 'removeEventListener'),
HTMLMediaElement: toplevel.HTMLMediaElement,

@@ -42,0 +43,0 @@

@@ -17,4 +17,2 @@ "use strict";

var sanityCheck,
logger,
message, ua, transport,
requests = [],

@@ -25,3 +23,3 @@ responses = [],

// Reply
function reply(status_code) {
function reply(status_code, message, transport) {
var to,

@@ -73,5 +71,5 @@ response = SIP.Utils.buildStatusLine(status_code),

// Sanity Check functions for requests
function rfc3261_8_2_2_1() {
function rfc3261_8_2_2_1(message, ua, transport) {
if(!message.ruri || message.ruri.scheme !== 'sip') {
reply(416);
reply(416, message, transport);
return false;

@@ -81,6 +79,6 @@ }

function rfc3261_16_3_4() {
function rfc3261_16_3_4(message, ua, transport) {
if(!message.to_tag) {
if(message.call_id.substr(0, 5) === ua.configuration.sipjsId) {
reply(482);
reply(482, message, transport);
return false;

@@ -91,3 +89,3 @@ }

function rfc3261_18_3_request() {
function rfc3261_18_3_request(message, ua, transport) {
var len = SIP.Utils.str_utf8_length(message.body),

@@ -97,3 +95,3 @@ contentLength = message.getHeader('content-length');

if(len < contentLength) {
reply(400);
reply(400, message, transport);
return false;

@@ -103,3 +101,3 @@ }

function rfc3261_8_2_2_2() {
function rfc3261_8_2_2_2(message, ua, transport) {
var tr, idx,

@@ -119,3 +117,3 @@ fromTag = message.from_tag,

if(tr.request.from_tag === fromTag && tr.request.call_id === call_id && tr.request.cseq === cseq) {
reply(482);
reply(482, message, transport);
return false;

@@ -133,3 +131,3 @@ }

if(tr.request.from_tag === fromTag && tr.request.call_id === call_id && tr.request.cseq === cseq) {
reply(482);
reply(482, message, transport);
return false;

@@ -144,5 +142,5 @@ }

// Sanity Check functions for responses
function rfc3261_8_1_3_3() {
function rfc3261_8_1_3_3(message, ua) {
if(message.getHeaders('via').length > 1) {
logger.warn('More than one Via header field present in the response. Dropping the response');
ua.getLogger('sip.sanitycheck').warn('More than one Via header field present in the response. Dropping the response');
return false;

@@ -152,6 +150,6 @@ }

function rfc3261_18_1_2() {
function rfc3261_18_1_2(message, ua) {
var viaHost = ua.configuration.viaHost;
if(message.via.host !== viaHost || message.via.port !== undefined) {
logger.warn('Via sent-by in the response does not match UA Via host value. Dropping the response');
ua.getLogger('sip.sanitycheck').warn('Via sent-by in the response does not match UA Via host value. Dropping the response');
return false;

@@ -161,3 +159,3 @@ }

function rfc3261_18_3_response() {
function rfc3261_18_3_response(message, ua) {
var

@@ -168,3 +166,3 @@ len = SIP.Utils.str_utf8_length(message.body),

if(len < contentLength) {
logger.warn('Message body length is lower than the value in Content-Length header field. Dropping the response');
ua.getLogger('sip.sanitycheck').warn('Message body length is lower than the value in Content-Length header field. Dropping the response');
return false;

@@ -175,3 +173,3 @@ }

// Sanity Check functions for requests and responses
function minimumHeaders() {
function minimumHeaders(message, ua) {
var

@@ -183,3 +181,3 @@ mandatoryHeaders = ['from', 'to', 'call_id', 'cseq', 'via'],

if(!message.hasHeader(mandatoryHeaders[idx])) {
logger.warn('Missing mandatory header field : '+ mandatoryHeaders[idx] +'. Dropping the response');
ua.getLogger('sip.sanitycheck').warn('Missing mandatory header field : '+ mandatoryHeaders[idx] +'. Dropping the response');
return false;

@@ -201,14 +199,8 @@ }

sanityCheck = function(m, u, t) {
sanityCheck = function(message, ua, transport) {
var len, pass;
message = m;
ua = u;
transport = t;
logger = ua.getLogger('sip.sanitycheck');
len = all.length;
while(len--) {
pass = all[len](message);
pass = all[len](message, ua, transport);
if(pass === false) {

@@ -222,3 +214,3 @@ return false;

while(len--) {
pass = requests[len](message);
pass = requests[len](message, ua, transport);
if(pass === false) {

@@ -233,3 +225,3 @@ return false;

while(len--) {
pass = responses[len](message);
pass = responses[len](message, ua, transport);
if(pass === false) {

@@ -236,0 +228,0 @@ return false;

@@ -9,10 +9,12 @@ /**

var pkg = require('../package.json');
var pkg = require('../package.json'),
version = pkg.version,
title = pkg.title;
var SIP = Object.defineProperties({}, {
version: {
get: function(){ return pkg.version; }
get: function(){ return version; }
},
name: {
get: function(){ return pkg.title; }
get: function(){ return title; }
}

@@ -19,0 +21,0 @@ });

@@ -127,2 +127,3 @@ "use strict";

this.ws.close();
this.ws = null;
}

@@ -154,2 +155,3 @@

this.ws.close();
this.ws = null;
}

@@ -175,2 +177,7 @@

transport.onClose(e);
// Always cleanup. Eases GC, prevents potential memory leaks.
this.onopen = null;
this.onclose = null;
this.onmessage = null;
this.onerror = null;
};

@@ -177,0 +184,0 @@

@@ -176,10 +176,2 @@ "use strict";

}
if (typeof environment.addEventListener === 'function') {
// Google Chrome Packaged Apps don't allow 'unload' listeners:
// unload is not available in packaged apps
if (!(global.chrome && global.chrome.app && global.chrome.app.runtime)) {
environment.addEventListener('unload', this.stop.bind(this));
}
}
};

@@ -248,2 +240,3 @@ UA.prototype = Object.create(SIP.EventEmitter.prototype);

this.afterConnected(context.invite.bind(context));
this.emit('inviteSent', context);
return context;

@@ -357,2 +350,10 @@ };

if (typeof environment.removeEventListener === 'function') {
// Google Chrome Packaged Apps don't allow 'unload' listeners:
// unload is not available in packaged apps
if (!(global.chrome && global.chrome.app && global.chrome.app.runtime)) {
environment.removeEventListener('unload', this.environListener);
}
}
return this;

@@ -386,2 +387,11 @@ };

if (this.configuration.autostop && typeof environment.addEventListener === 'function') {
// Google Chrome Packaged Apps don't allow 'unload' listeners:
// unload is not available in packaged apps
if (!(global.chrome && global.chrome.app && global.chrome.app.runtime)) {
this.environListener = this.stop.bind(this);
environment.addEventListener('unload', this.environListener);
}
}
return this;

@@ -893,2 +903,8 @@ };

//Custom Configuration Settings
custom: {},
//Display name
displayName: '',
// Password

@@ -940,2 +956,3 @@ password: null,

autostart: true,
autostop: true,

@@ -979,4 +996,6 @@ //Reliable Provisional Responses

var configCheck = this.getConfigurationCheck();
// Check Mandatory parameters
for(parameter in UA.configuration_check.mandatory) {
for(parameter in configCheck.mandatory) {
aliasUnderscored(parameter, this.logger);

@@ -987,3 +1006,3 @@ if(!configuration.hasOwnProperty(parameter)) {

value = configuration[parameter];
checked_value = UA.configuration_check.mandatory[parameter](value);
checked_value = configCheck.mandatory[parameter](value);
if (checked_value !== undefined) {

@@ -1002,3 +1021,3 @@ settings[parameter] = checked_value;

// Check Optional parameters
for(parameter in UA.configuration_check.optional) {
for(parameter in configCheck.optional) {
aliasUnderscored(parameter, this.logger);

@@ -1017,3 +1036,3 @@ if(configuration.hasOwnProperty(parameter)) {

checked_value = UA.configuration_check.optional[parameter](value);
checked_value = configCheck.optional[parameter](value);
if (checked_value !== undefined) {

@@ -1117,14 +1136,14 @@ settings[parameter] = checked_value;

var skeleton = {};
// Fill the value of the configuration_skeleton
for(parameter in settings) {
UA.configuration_skeleton[parameter].value = settings[parameter];
skeleton[parameter] = {
value: settings[parameter],
writable: (parameter === 'register' || parameter === 'custom'),
configurable: false
};
}
Object.defineProperties(this.configuration, UA.configuration_skeleton);
Object.defineProperties(this.configuration, skeleton);
// Clean UA.configuration_skeleton
for(parameter in settings) {
UA.configuration_skeleton[parameter].value = '';
}
this.logger.log('configuration parameters after validation:');

@@ -1150,518 +1169,456 @@ for(parameter in settings) {

/**
* Configuration Object skeleton.
* Configuration checker.
* @private
* @return {Boolean}
*/
UA.configuration_skeleton = (function() {
var idx, parameter,
skeleton = {},
parameters = [
// Internal parameters
"sipjsId",
"hostportParams",
UA.prototype.getConfigurationCheck = function () {
return {
mandatory: {
},
// Optional user configurable parameters
"uri",
"wsServers",
"authorizationUser",
"connectionRecoveryMaxInterval",
"connectionRecoveryMinInterval",
"keepAliveInterval",
"extraSupported",
"displayName",
"hackViaTcp", // false.
"hackIpInContact", //false
"hackWssInTransport", //false
"hackAllowUnregisteredOptionTags", //false
"hackCleanJitsiSdpImageattr", //false
"hackStripTcp", //false
"contactTransport", // 'ws'
"forceRport", // false
"iceCheckingTimeout",
"instanceId",
"noAnswerTimeout", // 30 seconds.
"password",
"registerExpires", // 600 seconds.
"registrarServer",
"reliable",
"rel100",
"replaces",
"userAgentString", //SIP.C.USER_AGENT
"autostart",
"rtcpMuxPolicy",
"stunServers",
"traceSip",
"turnServers",
"usePreloadedRoute",
"wsServerMaxReconnection",
"wsServerReconnectionTimeout",
"mediaHandlerFactory",
"media",
"mediaConstraints",
"authenticationFactory",
"allowLegacyNotifications",
optional: {
// Post-configuration generated parameters
"via_core_value",
"viaHost"
];
uri: function(uri) {
var parsed;
for(idx in parameters) {
parameter = parameters[idx];
skeleton[parameter] = {
value: '',
writable: false,
configurable: false
};
}
if (!(/^sip:/i).test(uri)) {
uri = SIP.C.SIP + ':' + uri;
}
parsed = SIP.URI.parse(uri);
skeleton['register'] = {
value: '',
writable: true,
configurable: false
};
if(!parsed) {
return;
} else if(!parsed.user) {
return;
} else {
return parsed;
}
},
return skeleton;
}());
//Note: this function used to call 'this.logger.error' but calling 'this' with anything here is invalid
wsServers: function(wsServers) {
var idx, length, url;
/**
* Configuration checker.
* @private
* @return {Boolean}
*/
UA.configuration_check = {
mandatory: {
},
/* Allow defining wsServers parameter as:
* String: "host"
* Array of Strings: ["host1", "host2"]
* Array of Objects: [{ws_uri:"host1", weight:1}, {ws_uri:"host2", weight:0}]
* Array of Objects and Strings: [{ws_uri:"host1"}, "host2"]
*/
if (typeof wsServers === 'string') {
wsServers = [{ws_uri: wsServers}];
} else if (wsServers instanceof Array) {
length = wsServers.length;
for (idx = 0; idx < length; idx++) {
if (typeof wsServers[idx] === 'string'){
wsServers[idx] = {ws_uri: wsServers[idx]};
}
}
} else {
return;
}
optional: {
if (wsServers.length === 0) {
return false;
}
uri: function(uri) {
var parsed;
length = wsServers.length;
for (idx = 0; idx < length; idx++) {
if (!wsServers[idx].ws_uri) {
return;
}
if (wsServers[idx].weight && !Number(wsServers[idx].weight)) {
return;
}
if (!(/^sip:/i).test(uri)) {
uri = SIP.C.SIP + ':' + uri;
}
parsed = SIP.URI.parse(uri);
url = SIP.Grammar.parse(wsServers[idx].ws_uri, 'absoluteURI');
if(!parsed) {
return;
} else if(!parsed.user) {
return;
} else {
return parsed;
}
},
if(url === -1) {
return;
} else if(['wss', 'ws', 'udp'].indexOf(url.scheme) < 0) {
return;
} else {
wsServers[idx].sip_uri = '<sip:' + url.host + (url.port ? ':' + url.port : '') + ';transport=' + url.scheme.replace(/^wss$/i, 'ws') + ';lr>';
//Note: this function used to call 'this.logger.error' but calling 'this' with anything here is invalid
wsServers: function(wsServers) {
var idx, length, url;
if (!wsServers[idx].weight) {
wsServers[idx].weight = 0;
}
/* Allow defining wsServers parameter as:
* String: "host"
* Array of Strings: ["host1", "host2"]
* Array of Objects: [{ws_uri:"host1", weight:1}, {ws_uri:"host2", weight:0}]
* Array of Objects and Strings: [{ws_uri:"host1"}, "host2"]
*/
if (typeof wsServers === 'string') {
wsServers = [{ws_uri: wsServers}];
} else if (wsServers instanceof Array) {
length = wsServers.length;
for (idx = 0; idx < length; idx++) {
if (typeof wsServers[idx] === 'string'){
wsServers[idx] = {ws_uri: wsServers[idx]};
wsServers[idx].status = 0;
wsServers[idx].scheme = url.scheme.toUpperCase();
}
}
} else {
return;
}
return wsServers;
},
if (wsServers.length === 0) {
return false;
}
length = wsServers.length;
for (idx = 0; idx < length; idx++) {
if (!wsServers[idx].ws_uri) {
authorizationUser: function(authorizationUser) {
if(SIP.Grammar.parse('"'+ authorizationUser +'"', 'quoted_string') === -1) {
return;
} else {
return authorizationUser;
}
if (wsServers[idx].weight && !Number(wsServers[idx].weight)) {
return;
},
connectionRecoveryMaxInterval: function(connectionRecoveryMaxInterval) {
var value;
if(SIP.Utils.isDecimal(connectionRecoveryMaxInterval)) {
value = Number(connectionRecoveryMaxInterval);
if(value > 0) {
return value;
}
}
},
url = SIP.Grammar.parse(wsServers[idx].ws_uri, 'absoluteURI');
connectionRecoveryMinInterval: function(connectionRecoveryMinInterval) {
var value;
if(SIP.Utils.isDecimal(connectionRecoveryMinInterval)) {
value = Number(connectionRecoveryMinInterval);
if(value > 0) {
return value;
}
}
},
if(url === -1) {
displayName: function(displayName) {
if(SIP.Grammar.parse('"' + displayName + '"', 'displayName') === -1) {
return;
} else if(['wss', 'ws', 'udp'].indexOf(url.scheme) < 0) {
return;
} else {
wsServers[idx].sip_uri = '<sip:' + url.host + (url.port ? ':' + url.port : '') + ';transport=' + url.scheme.replace(/^wss$/i, 'ws') + ';lr>';
return displayName;
}
},
if (!wsServers[idx].weight) {
wsServers[idx].weight = 0;
}
hackViaTcp: function(hackViaTcp) {
if (typeof hackViaTcp === 'boolean') {
return hackViaTcp;
}
},
wsServers[idx].status = 0;
wsServers[idx].scheme = url.scheme.toUpperCase();
hackIpInContact: function(hackIpInContact) {
if (typeof hackIpInContact === 'boolean') {
return hackIpInContact;
}
}
return wsServers;
},
else if (typeof hackIpInContact === 'string' && SIP.Grammar.parse(hackIpInContact, 'host') !== -1) {
return hackIpInContact;
}
},
authorizationUser: function(authorizationUser) {
if(SIP.Grammar.parse('"'+ authorizationUser +'"', 'quoted_string') === -1) {
return;
} else {
return authorizationUser;
}
},
iceCheckingTimeout: function(iceCheckingTimeout) {
if(SIP.Utils.isDecimal(iceCheckingTimeout)) {
return Math.max(500, iceCheckingTimeout);
}
},
connectionRecoveryMaxInterval: function(connectionRecoveryMaxInterval) {
var value;
if(SIP.Utils.isDecimal(connectionRecoveryMaxInterval)) {
value = Number(connectionRecoveryMaxInterval);
if(value > 0) {
return value;
hackWssInTransport: function(hackWssInTransport) {
if (typeof hackWssInTransport === 'boolean') {
return hackWssInTransport;
}
}
},
},
connectionRecoveryMinInterval: function(connectionRecoveryMinInterval) {
var value;
if(SIP.Utils.isDecimal(connectionRecoveryMinInterval)) {
value = Number(connectionRecoveryMinInterval);
if(value > 0) {
return value;
hackAllowUnregisteredOptionTags: function(hackAllowUnregisteredOptionTags) {
if (typeof hackAllowUnregisteredOptionTags === 'boolean') {
return hackAllowUnregisteredOptionTags;
}
}
},
},
displayName: function(displayName) {
if(SIP.Grammar.parse('"' + displayName + '"', 'displayName') === -1) {
return;
} else {
return displayName;
}
},
hackCleanJitsiSdpImageattr: function(hackCleanJitsiSdpImageattr) {
if (typeof hackCleanJitsiSdpImageattr === 'boolean') {
return hackCleanJitsiSdpImageattr;
}
},
hackViaTcp: function(hackViaTcp) {
if (typeof hackViaTcp === 'boolean') {
return hackViaTcp;
}
},
hackStripTcp: function(hackStripTcp) {
if (typeof hackStripTcp === 'boolean') {
return hackStripTcp;
}
},
hackIpInContact: function(hackIpInContact) {
if (typeof hackIpInContact === 'boolean') {
return hackIpInContact;
}
else if (typeof hackIpInContact === 'string' && SIP.Grammar.parse(hackIpInContact, 'host') !== -1) {
return hackIpInContact;
}
},
contactTransport: function(contactTransport) {
if (typeof contactTransport === 'string') {
return contactTransport;
}
},
iceCheckingTimeout: function(iceCheckingTimeout) {
if(SIP.Utils.isDecimal(iceCheckingTimeout)) {
return Math.max(500, iceCheckingTimeout);
}
},
forceRport: function(forceRport) {
if (typeof forceRport === 'boolean') {
return forceRport;
}
},
hackWssInTransport: function(hackWssInTransport) {
if (typeof hackWssInTransport === 'boolean') {
return hackWssInTransport;
}
},
instanceId: function(instanceId) {
if(typeof instanceId !== 'string') {
return;
}
hackAllowUnregisteredOptionTags: function(hackAllowUnregisteredOptionTags) {
if (typeof hackAllowUnregisteredOptionTags === 'boolean') {
return hackAllowUnregisteredOptionTags;
}
},
if ((/^uuid:/i.test(instanceId))) {
instanceId = instanceId.substr(5);
}
hackCleanJitsiSdpImageattr: function(hackCleanJitsiSdpImageattr) {
if (typeof hackCleanJitsiSdpImageattr === 'boolean') {
return hackCleanJitsiSdpImageattr;
}
},
if(SIP.Grammar.parse(instanceId, 'uuid') === -1) {
return;
} else {
return instanceId;
}
},
hackStripTcp: function(hackStripTcp) {
if (typeof hackStripTcp === 'boolean') {
return hackStripTcp;
}
},
contactTransport: function(contactTransport) {
if (typeof contactTransport === 'string') {
return contactTransport;
}
},
forceRport: function(forceRport) {
if (typeof forceRport === 'boolean') {
return forceRport;
}
},
instanceId: function(instanceId) {
if(typeof instanceId !== 'string') {
return;
}
if ((/^uuid:/i.test(instanceId))) {
instanceId = instanceId.substr(5);
}
if(SIP.Grammar.parse(instanceId, 'uuid') === -1) {
return;
} else {
return instanceId;
}
},
keepAliveInterval: function(keepAliveInterval) {
var value;
if (SIP.Utils.isDecimal(keepAliveInterval)) {
value = Number(keepAliveInterval);
if (value > 0) {
return value;
keepAliveInterval: function(keepAliveInterval) {
var value;
if (SIP.Utils.isDecimal(keepAliveInterval)) {
value = Number(keepAliveInterval);
if (value > 0) {
return value;
}
}
}
},
},
extraSupported: function(optionTags) {
var idx, length;
extraSupported: function(optionTags) {
var idx, length;
if (!(optionTags instanceof Array)) {
return;
}
length = optionTags.length;
for (idx = 0; idx < length; idx++) {
if (typeof optionTags[idx] !== 'string') {
if (!(optionTags instanceof Array)) {
return;
}
}
return optionTags;
},
noAnswerTimeout: function(noAnswerTimeout) {
var value;
if (SIP.Utils.isDecimal(noAnswerTimeout)) {
value = Number(noAnswerTimeout);
if (value > 0) {
return value;
length = optionTags.length;
for (idx = 0; idx < length; idx++) {
if (typeof optionTags[idx] !== 'string') {
return;
}
}
}
},
password: function(password) {
return String(password);
},
return optionTags;
},
rel100: function(rel100) {
if(rel100 === SIP.C.supported.REQUIRED) {
return SIP.C.supported.REQUIRED;
} else if (rel100 === SIP.C.supported.SUPPORTED) {
return SIP.C.supported.SUPPORTED;
} else {
return SIP.C.supported.UNSUPPORTED;
}
},
noAnswerTimeout: function(noAnswerTimeout) {
var value;
if (SIP.Utils.isDecimal(noAnswerTimeout)) {
value = Number(noAnswerTimeout);
if (value > 0) {
return value;
}
}
},
replaces: function(replaces) {
if(replaces === SIP.C.supported.REQUIRED) {
return SIP.C.supported.REQUIRED;
} else if (replaces === SIP.C.supported.SUPPORTED) {
return SIP.C.supported.SUPPORTED;
} else {
return SIP.C.supported.UNSUPPORTED;
}
},
password: function(password) {
return String(password);
},
register: function(register) {
if (typeof register === 'boolean') {
return register;
}
},
rel100: function(rel100) {
if(rel100 === SIP.C.supported.REQUIRED) {
return SIP.C.supported.REQUIRED;
} else if (rel100 === SIP.C.supported.SUPPORTED) {
return SIP.C.supported.SUPPORTED;
} else {
return SIP.C.supported.UNSUPPORTED;
}
},
registerExpires: function(registerExpires) {
var value;
if (SIP.Utils.isDecimal(registerExpires)) {
value = Number(registerExpires);
if (value > 0) {
return value;
replaces: function(replaces) {
if(replaces === SIP.C.supported.REQUIRED) {
return SIP.C.supported.REQUIRED;
} else if (replaces === SIP.C.supported.SUPPORTED) {
return SIP.C.supported.SUPPORTED;
} else {
return SIP.C.supported.UNSUPPORTED;
}
}
},
},
registrarServer: function(registrarServer) {
var parsed;
register: function(register) {
if (typeof register === 'boolean') {
return register;
}
},
if(typeof registrarServer !== 'string') {
return;
}
registerExpires: function(registerExpires) {
var value;
if (SIP.Utils.isDecimal(registerExpires)) {
value = Number(registerExpires);
if (value > 0) {
return value;
}
}
},
if (!/^sip:/i.test(registrarServer)) {
registrarServer = SIP.C.SIP + ':' + registrarServer;
}
parsed = SIP.URI.parse(registrarServer);
registrarServer: function(registrarServer) {
var parsed;
if(!parsed) {
return;
} else if(parsed.user) {
return;
} else {
return parsed;
}
},
if(typeof registrarServer !== 'string') {
return;
}
stunServers: function(stunServers) {
var idx, length, stun_server;
if (typeof stunServers === 'string') {
stunServers = [stunServers];
} else if (!(stunServers instanceof Array)) {
return;
}
length = stunServers.length;
for (idx = 0; idx < length; idx++) {
stun_server = stunServers[idx];
if (!(/^stuns?:/.test(stun_server))) {
stun_server = 'stun:' + stun_server;
if (!/^sip:/i.test(registrarServer)) {
registrarServer = SIP.C.SIP + ':' + registrarServer;
}
parsed = SIP.URI.parse(registrarServer);
if(SIP.Grammar.parse(stun_server, 'stun_URI') === -1) {
if(!parsed) {
return;
} else if(parsed.user) {
return;
} else {
stunServers[idx] = stun_server;
return parsed;
}
}
return stunServers;
},
},
traceSip: function(traceSip) {
if (typeof traceSip === 'boolean') {
return traceSip;
}
},
stunServers: function(stunServers) {
var idx, length, stun_server;
turnServers: function(turnServers) {
var idx, jdx, length, turn_server, num_turn_server_urls, url;
if (typeof stunServers === 'string') {
stunServers = [stunServers];
} else if (!(stunServers instanceof Array)) {
return;
}
if (turnServers instanceof Array) {
// Do nothing
} else {
turnServers = [turnServers];
}
length = stunServers.length;
for (idx = 0; idx < length; idx++) {
stun_server = stunServers[idx];
if (!(/^stuns?:/.test(stun_server))) {
stun_server = 'stun:' + stun_server;
}
length = turnServers.length;
for (idx = 0; idx < length; idx++) {
turn_server = turnServers[idx];
//Backwards compatibility: Allow defining the turn_server url with the 'server' property.
if (turn_server.server) {
turn_server.urls = [turn_server.server];
if(SIP.Grammar.parse(stun_server, 'stun_URI') === -1) {
return;
} else {
stunServers[idx] = stun_server;
}
}
return stunServers;
},
if (!turn_server.urls) {
return;
traceSip: function(traceSip) {
if (typeof traceSip === 'boolean') {
return traceSip;
}
},
if (turn_server.urls instanceof Array) {
num_turn_server_urls = turn_server.urls.length;
turnServers: function(turnServers) {
var idx, jdx, length, turn_server, num_turn_server_urls, url;
if (turnServers instanceof Array) {
// Do nothing
} else {
turn_server.urls = [turn_server.urls];
num_turn_server_urls = 1;
turnServers = [turnServers];
}
for (jdx = 0; jdx < num_turn_server_urls; jdx++) {
url = turn_server.urls[jdx];
if (!(/^turns?:/.test(url))) {
url = 'turn:' + url;
length = turnServers.length;
for (idx = 0; idx < length; idx++) {
turn_server = turnServers[idx];
//Backwards compatibility: Allow defining the turn_server url with the 'server' property.
if (turn_server.server) {
turn_server.urls = [turn_server.server];
}
if(SIP.Grammar.parse(url, 'turn_URI') === -1) {
if (!turn_server.urls) {
return;
}
if (turn_server.urls instanceof Array) {
num_turn_server_urls = turn_server.urls.length;
} else {
turn_server.urls = [turn_server.urls];
num_turn_server_urls = 1;
}
for (jdx = 0; jdx < num_turn_server_urls; jdx++) {
url = turn_server.urls[jdx];
if (!(/^turns?:/.test(url))) {
url = 'turn:' + url;
}
if(SIP.Grammar.parse(url, 'turn_URI') === -1) {
return;
}
}
}
}
return turnServers;
},
return turnServers;
},
rtcpMuxPolicy: function(rtcpMuxPolicy) {
if (typeof rtcpMuxPolicy === 'string') {
return rtcpMuxPolicy;
}
},
rtcpMuxPolicy: function(rtcpMuxPolicy) {
if (typeof rtcpMuxPolicy === 'string') {
return rtcpMuxPolicy;
}
},
userAgentString: function(userAgentString) {
if (typeof userAgentString === 'string') {
return userAgentString;
}
},
userAgentString: function(userAgentString) {
if (typeof userAgentString === 'string') {
return userAgentString;
}
},
usePreloadedRoute: function(usePreloadedRoute) {
if (typeof usePreloadedRoute === 'boolean') {
return usePreloadedRoute;
}
},
usePreloadedRoute: function(usePreloadedRoute) {
if (typeof usePreloadedRoute === 'boolean') {
return usePreloadedRoute;
}
},
wsServerMaxReconnection: function(wsServerMaxReconnection) {
var value;
if (SIP.Utils.isDecimal(wsServerMaxReconnection)) {
value = Number(wsServerMaxReconnection);
if (value > 0) {
return value;
wsServerMaxReconnection: function(wsServerMaxReconnection) {
var value;
if (SIP.Utils.isDecimal(wsServerMaxReconnection)) {
value = Number(wsServerMaxReconnection);
if (value > 0) {
return value;
}
}
}
},
},
wsServerReconnectionTimeout: function(wsServerReconnectionTimeout) {
var value;
if (SIP.Utils.isDecimal(wsServerReconnectionTimeout)) {
value = Number(wsServerReconnectionTimeout);
if (value > 0) {
return value;
wsServerReconnectionTimeout: function(wsServerReconnectionTimeout) {
var value;
if (SIP.Utils.isDecimal(wsServerReconnectionTimeout)) {
value = Number(wsServerReconnectionTimeout);
if (value > 0) {
return value;
}
}
}
},
},
autostart: function(autostart) {
if (typeof autostart === 'boolean') {
return autostart;
}
},
autostart: function(autostart) {
if (typeof autostart === 'boolean') {
return autostart;
}
},
mediaHandlerFactory: function(mediaHandlerFactory) {
if (mediaHandlerFactory instanceof Function) {
var promisifiedFactory = function promisifiedFactory () {
var mediaHandler = mediaHandlerFactory.apply(this, arguments);
autostop: function(autostop) {
if (typeof autostop === 'boolean') {
return autostop;
}
},
function patchMethod (methodName) {
var method = mediaHandler[methodName];
if (method.length > 1) {
var callbacksFirst = methodName === 'getDescription';
mediaHandler[methodName] = SIP.Utils.promisify(mediaHandler, methodName, callbacksFirst);
mediaHandlerFactory: function(mediaHandlerFactory) {
if (mediaHandlerFactory instanceof Function) {
var promisifiedFactory = function promisifiedFactory () {
var mediaHandler = mediaHandlerFactory.apply(this, arguments);
function patchMethod (methodName) {
var method = mediaHandler[methodName];
if (method.length > 1) {
var callbacksFirst = methodName === 'getDescription';
mediaHandler[methodName] = SIP.Utils.promisify(mediaHandler, methodName, callbacksFirst);
}
}
}
patchMethod('getDescription');
patchMethod('setDescription');
patchMethod('getDescription');
patchMethod('setDescription');
return mediaHandler;
};
return mediaHandler;
};
promisifiedFactory.isSupported = mediaHandlerFactory.isSupported;
return promisifiedFactory;
}
},
promisifiedFactory.isSupported = mediaHandlerFactory.isSupported;
return promisifiedFactory;
}
},
authenticationFactory: checkAuthenticationFactory,
authenticationFactory: checkAuthenticationFactory,
allowLegacyNotifications: function(allowLegacyNotifications) {
if (typeof allowLegacyNotifications === 'boolean') {
return allowLegacyNotifications;
allowLegacyNotifications: function(allowLegacyNotifications) {
if (typeof allowLegacyNotifications === 'boolean') {
return allowLegacyNotifications;
}
},
custom: function(custom) {
if (typeof custom === 'object') {
return custom;
}
}
}
}
};
};

@@ -1668,0 +1625,0 @@

@@ -176,2 +176,3 @@ "use strict";

setDescription: {writable: true, value: function setDescription (message) {
var self = this;
var sdp = message.body;

@@ -192,3 +193,7 @@

var description = new SIP.WebRTC.RTCSessionDescription(rawDescription);
return SIP.Utils.promisify(this.peerConnection, 'setRemoteDescription')(description);
return SIP.Utils.promisify(this.peerConnection, 'setRemoteDescription')(description)
.catch(function setRemoteDescriptionError(e) {
self.emit('peerConnection-setRemoteDescriptionFailed', e);
throw e;
});
}},

@@ -540,3 +545,11 @@

return SIP.Utils.promisify(pc, methodName, true)(constraints)
.catch(function methodError(e) {
self.emit('peerConnection-' + methodName + 'Failed', e);
throw e;
})
.then(SIP.Utils.promisify(pc, 'setLocalDescription'))
.catch(function localDescError(e) {
self.emit('peerConnection-selLocalDescriptionFailed', e);
throw e;
})
.then(function onSetLocalDescriptionSuccess() {

@@ -571,3 +584,3 @@ var deferred = SIP.Utils.defer();

})
.catch(function methodFailed (e) {
.catch(function createOfferAnswerError (e) {
self.logger.error(e);

@@ -574,0 +587,0 @@ self.ready = true;

Sorry, the diff of this file is not supported yet

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