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

@testrtc/watchrtc-sdk

Package Overview
Dependencies
Maintainers
2
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testrtc/watchrtc-sdk - npm Package Compare versions

Comparing version 1.28.2 to 1.28.3

2

lib/index.js

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.watchRTC=n():e.watchRTC=n()}(self,(function(){return(()=>{"use strict";var e={607:(e,n,t)=>{n.IO=n.S1=void 0,t(699);var i=t(231);n.S1=function(e){i.initSDK(e,["","webkit","moz"])},n.IO=function(e,n){i.setUserRating(e,n)},n.default={init:n.S1,setUserRating:n.IO}},231:function(e,n,t){var i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},o=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var i=Array(e),o=0;for(n=0;n<t;n++)for(var r=arguments[n],a=0,c=r.length;a<c;a++,o++)i[o]=r[a];return i};Object.defineProperty(n,"__esModule",{value:!0}),n.setUserRating=n.initSDK=void 0;var r=t(85),a=t(412),c=t(593),s=function(e,n){e=e||{},n=n||{},n=JSON.parse(JSON.stringify(n)),Object.keys(n).forEach((function(t){var i=n[t];delete i.id,e[t]&&Object.keys(i).forEach((function(o){i[o]===e[t][o]&&delete n[t][o],(0===Object.keys(i).length||1===Object.keys(i).length&&i.timestamp)&&delete n[t]}))}));var t=-1/0;return Object.keys(n).forEach((function(e){var i=n[e];i.timestamp>t&&(t=i.timestamp)})),Object.keys(n).forEach((function(e){var i=n[e];i.timestamp===t&&(i.timestamp=0)})),n.timestamp=t,n},l=function(e){return{id:e.id,tracks:e.getTracks().map((function(e){return{id:e.id,kind:e.kind,label:e.label,enabled:e.enabled,muted:e.muted,readyState:e.readyState}}))}};n.initSDK=function(e,n){if(!window.watchRTCInitialized){window.watchRTCInitialized=!0;var t,d=0,f=null,u=0,p=!1,g=new r.default,v=g.trace,h={},y=!!window.mozRTCPeerConnection,m=!!window.RTCIceGatherer,_=(!y&&window.RTCPeerConnection&&window.navigator.webkitGetUserMedia,function(){return Object.keys(h).filter((function(e){return h[e].validConnection})).length}),w=function(){var e,n,r,s,l,d=_();if(d>0&&!p){p=!0;var y=(l=f)?l.rtcApiKey?l.rtcRoomId?!!l.rtcPeerId||(console.info.apply(console,o(c.logPrefix("error"),["config.rtcPeerId is required."])),!1):(console.info.apply(console,o(c.logPrefix("error"),["config.rtcRoomId is required."])),!1):(console.info.apply(console,o(c.logPrefix("error"),["config.rtcApiKey is required."])),!1):(console.info.apply(console,o(c.logPrefix("error"),["config is required."])),!1),w=Object.keys(h)[d-1];if(y){f.rtcTags&&!Array.isArray(f.rtcTags)&&(console.info.apply(console,o(c.logPrefix("info"),["config.rtcTags must be an array."])),f.rtcTags=void 0);var S=(e=f.rtcApiKey,n=f.proxyUrl||f.wsUrl,r="wss://watchrtc.testrtc.com",s=e.split(":"),-1!==e.indexOf("local")?{url:n||"ws://localhost:9101",apiKey:s[1]}:-1!==e.indexOf("staging")?{url:n||"wss://watchrtc-staging2.testrtc.com",apiKey:s[1]}:-1!==e.indexOf("production")?{url:n||r,apiKey:s[1]}:{url:n||r,apiKey:s[0]});u=Date.now(),g.connect(S.url+"?apiKey="+S.apiKey+"&timestamp="+Date.now(),(function(e){console.info.apply(console,o(c.logPrefix("info"),["Connection established. watchRTCConnectionId: "+e.connectionId+" sdkVersion:"+a.default])),v("watchrtc",w,i(i(i({},f),e),{sdkVersion:a.default})),m||(window.clearInterval(t),t=window.setInterval((function(){0===_()?u&&u+2e4<Date.now()&&(p=!1,window.clearInterval(t),g.close(),console.info.apply(console,o(c.logPrefix("info"),["Last connection closed. watchRTCConnectionId: "+e.connectionId+" sdkVersion: "+a.default]))):(u=Date.now(),Object.values(h).forEach((function(e){"closed"!==e.pc.signalingState&&b(e)})))}),e.interval))}),(function(){p=!1,u=0}))}}},b=function(e){var n=e.id,t=e.pc,i=e.prev;t.getStats(null).then((function(t){var o=function(e){if(!e.entries)return e;var n={};return e.forEach((function(e,t){n[t]=e})),n}(t),r=JSON.parse(JSON.stringify(o)),a=s(i,o);null!==(null==a?void 0:a.timestamp)&&(null==a?void 0:a.timestamp)!==-1/0&&v("getstats",n,s(e.prev,o)),e.prev=r}))};if(n.forEach((function(n){if(window[n+"RTCPeerConnection"]&&("webkit"!==n||!m)){var t=window[n+"RTCPeerConnection"],i=function(n,i){var o=new t(n,i),r="PC_"+d++;return o.__rtcStatsId=r,h[r]={id:r,pc:o,validConnection:!1},f=e||(null==n?void 0:n.watchrtc),n||(n={nullConfig:!0}),((n=JSON.parse(JSON.stringify(n)))&&n.iceServers||[]).forEach((function(e){delete e.credential})),(null==n?void 0:n.watchrtc)&&delete n.watchrtc,n.browserType=y?"moz":m?"edge":"webkit",v("create",r,n),i&&v("constraints",r,i),o.addEventListener("icecandidate",(function(e){v("onicecandidate",r,e.candidate)})),o.addEventListener("addstream",(function(e){v("onaddstream",r,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),o.addEventListener("track",(function(e){v("ontrack",r,e.track.kind+":"+e.track.id+" "+e.streams.map((function(e){return"stream:"+e.id})))})),o.addEventListener("removestream",(function(e){v("onremovestream",r,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),o.addEventListener("signalingstatechange",(function(){h[r]&&!h[r].validConnection&&(h[r].validConnection=!0,setTimeout(w,5e3)),v("onsignalingstatechange",r,o.signalingState)})),o.addEventListener("iceconnectionstatechange",(function(){v("oniceconnectionstatechange",r,o.iceConnectionState)})),o.addEventListener("icegatheringstatechange",(function(){v("onicegatheringstatechange",r,o.iceGatheringState)})),o.addEventListener("connectionstatechange",(function(){v("onconnectionstatechange",r,o.connectionState)})),o.addEventListener("negotiationneeded",(function(){v("onnegotiationneeded",r,void 0)})),o.addEventListener("datachannel",(function(e){v("ondatachannel",r,[e.channel.id,e.channel.label])})),m||o.addEventListener("iceconnectionstatechange",(function(){"connected"===o.iceConnectionState&&b(h[r])})),o};["createDataChannel","close"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){return v(e,this.__rtcStatsId,arguments),delete h[this.__rtcStatsId],n.apply(this,arguments)})})),["addStream","removeStream"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=arguments[0],i=t.getTracks().map((function(e){return e.kind+":"+e.id})).join(",");return v(e,this.__rtcStatsId,t.id+" "+i),n.apply(this,arguments)})})),["addTrack"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=arguments[0],i=[].slice.call(arguments,1);return v(e,this.__rtcStatsId,t.kind+":"+t.id+" "+(i.map((function(e){return"stream:"+e.id})).join(";")||"-")),n.apply(this,arguments)})})),["removeTrack"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=arguments[0].track;return v(e,this.__rtcStatsId,t?t.kind+":"+t.id:"null"),n.apply(this,arguments)})})),["createOffer","createAnswer"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t,i=this.__rtcStatsId,o=arguments;return 1===arguments.length&&"object"==typeof arguments[0]?t=arguments[0]:3===arguments.length&&"object"==typeof arguments[2]&&(t=arguments[2]),v(e,this.__rtcStatsId,t),n.apply(this,t?[t]:void 0).then((function(n){if(v(e+"OnSuccess",i,n),!(o.length>0&&"function"==typeof o[0]))return n;o[0].apply(null,[n])}),(function(n){if(v(e+"OnFailure",i,n.toString()),!(o.length>1&&"function"==typeof o[1]))throw n;o[1].apply(null,[n])}))})})),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=this.__rtcStatsId,i=arguments;return v(e,this.__rtcStatsId,i[0]),n.apply(this,[i[0]]).then((function(){v(e+"OnSuccess",t,void 0),i.length>=2&&"function"==typeof i[1]&&i[1].apply(null,[])}),(function(n){if(v(e+"OnFailure",t,n.toString()),!(i.length>=3&&"function"==typeof i[2]))throw n;i[2].apply(null,[n])}))})})),t.generateCertificate&&Object.defineProperty(i,"generateCertificate",{get:function(){return arguments.length?t.generateCertificate.apply(null,arguments):t.generateCertificate}}),window[n+"RTCPeerConnection"]=i,window[n+"RTCPeerConnection"].prototype=t.prototype}})),n.forEach((function(e){var n=e+(e.length?"GetUserMedia":"getUserMedia");if(navigator[n]){var t=navigator[n].bind(navigator);navigator[n]=function(){v("getUserMedia",null,arguments[0]);var e=arguments[1],n=arguments[2];t(arguments[0],(function(n){v("getUserMediaOnSuccess",null,l(n)),e&&e(n)}),(function(e){v("getUserMediaOnFailure",null,e.name),n&&n(e)}))}.bind(navigator)}})),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){var S=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(){return v("navigator.mediaDevices.getUserMedia",null,arguments[0]),S.apply(navigator.mediaDevices,arguments).then((function(e){return v("navigator.mediaDevices.getUserMediaOnSuccess",null,l(e)),e}),(function(e){return v("navigator.mediaDevices.getUserMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia){var k=navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getDisplayMedia=function(){return v("navigator.mediaDevices.getDisplayMedia",null,arguments[0]),k.apply(navigator.mediaDevices,arguments).then((function(e){return v("navigator.mediaDevices.getDisplayMediaOnSuccess",null,l(e)),e}),(function(e){return v("navigator.mediaDevices.getDisplayMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}}},n.setUserRating=function(e,n){var t;e&&(r.default._instance&&(null===(t=r.default._instance.connection)||void 0===t?void 0:t.readyState)===WebSocket.OPEN?r.default._instance.trace("userRating","",{rate:e,rateReason:n}):console.info.apply(console,o(c.logPrefix("error"),["Please set user rating before websocket connection is closed."])))}},699:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0})},593:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.logPrefix=void 0,n.logPrefix=function(e){return void 0===e&&(e="info"),"error"===e?["%cwatchRTC %cERROR","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;","background: red; color: white; padding: 2px 0.5em; border-radius: 0.5em;"]:["%cwatchRTC","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;"]}},412:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.default="1.28.2"},85:function(e,n,t){var i=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var i=Array(e),o=0;for(n=0;n<t;n++)for(var r=arguments[n],a=0,c=r.length;a<c;a++,o++)i[o]=r[a];return i};Object.defineProperty(n,"__esModule",{value:!0});var o=t(593),r=function(){function e(){this.connection=null,this.buffer=[],this.sendInterval=1,this.onClose=function(){},e._instance?console.info.apply(console,i(o.logPrefix("info"),["WatchRTCSocket instance already created"])):e._instance=this}return e.prototype.connect=function(n,t,r){e._instance.connection&&e._instance.connection.close(),e._instance.connection=new WebSocket(n,"2.0"),e._instance.connection.onopen=function(e){},e._instance.connection.onclose=function(e){};var a=e._instance;e._instance.connection.onmessage=function(n){var c;try{var s=JSON.parse(n.data);s.error?(null===(c=null==a?void 0:a.connection)||void 0===c||c.close(),a.connection=null,console.info.apply(console,i(o.logPrefix("error"),["\n"+s.error])),r(s.error)):(s.sendInterval&&(e._instance.sendInterval=s.sendInterval),t(s))}catch(e){console.info.apply(console,i(o.logPrefix("error"),[{err:e.stack}])),r(e.message)}},e._instance.connection.onerror=function(e){console.info.apply(console,i(o.logPrefix("error"),["\n",e])),r(e)}},e.prototype.trace=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var i=Array.prototype.slice.call(n);if(i.push(Date.now()),i[1]instanceof RTCPeerConnection&&(i[1]=i[1].__rtcStatsId),e._instance.connection){if(e._instance.connection.readyState===WebSocket.OPEN&&(e._instance.buffer.push(i),e._instance.buffer.length>=e._instance.sendInterval)){var o=JSON.stringify(e._instance.buffer);e._instance.buffer=[],e._instance.connection.send(o)}}else{if(e._instance.buffer.length>1e3)return;e._instance.buffer.push(i)}},e.prototype.close=function(){e._instance.buffer=[],e._instance.connection&&(e._instance.connection.close(),e._instance.onClose(),e._instance.connection=null)},e}();n.default=r}},n={},t=function t(i){if(n[i])return n[i].exports;var o=n[i]={exports:{}};return e[i].call(o.exports,o,o.exports,t),o.exports}(607);return t.default})()}));
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.watchRTC=n():e.watchRTC=n()}(self,(function(){return(()=>{"use strict";var e={607:(e,n,t)=>{n.IO=n.S1=void 0,t(699);var i=t(231);n.S1=function(e){i.initSDK(e,["","webkit","moz"])},n.IO=function(e,n){i.setUserRating(e,n)},n.default={init:n.S1,setUserRating:n.IO}},231:function(e,n,t){var i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},o=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var i=Array(e),o=0;for(n=0;n<t;n++)for(var r=arguments[n],a=0,c=r.length;a<c;a++,o++)i[o]=r[a];return i};Object.defineProperty(n,"__esModule",{value:!0}),n.setUserRating=n.initSDK=void 0;var r=t(85),a=t(412),c=t(593),s=function(e,n){e=e||{},n=n||{},n=JSON.parse(JSON.stringify(n)),Object.keys(n).forEach((function(t){var i=n[t];delete i.id,e[t]&&Object.keys(i).forEach((function(o){i[o]===e[t][o]&&delete n[t][o],(0===Object.keys(i).length||1===Object.keys(i).length&&i.timestamp)&&delete n[t]}))}));var t=-1/0;return Object.keys(n).forEach((function(e){var i=n[e];i.timestamp>t&&(t=i.timestamp)})),Object.keys(n).forEach((function(e){var i=n[e];i.timestamp===t&&(i.timestamp=0)})),n.timestamp=t,n},l=function(e){return{id:e.id,tracks:e.getTracks().map((function(e){return{id:e.id,kind:e.kind,label:e.label,enabled:e.enabled,muted:e.muted,readyState:e.readyState}}))}};n.initSDK=function(e,n){if(!window.watchRTCInitialized){window.watchRTCInitialized=!0;var t,d=0,f=null,u=0,p=!1,g=new r.default,v=g.trace,h={},y=!!window.mozRTCPeerConnection,m=!!window.RTCIceGatherer,_=(!y&&window.RTCPeerConnection&&window.navigator.webkitGetUserMedia,function(){return Object.keys(h).filter((function(e){return h[e].validConnection})).length}),w=function(){var e,n,r,s,l,d=_();if(d>0&&!p){p=!0;var y=(l=f)?l.rtcApiKey?l.rtcRoomId?!!l.rtcPeerId||(console.info.apply(console,o(c.logPrefix("error"),["config.rtcPeerId is required."])),!1):(console.info.apply(console,o(c.logPrefix("error"),["config.rtcRoomId is required."])),!1):(console.info.apply(console,o(c.logPrefix("error"),["config.rtcApiKey is required."])),!1):(console.info.apply(console,o(c.logPrefix("error"),["config is required."])),!1),w=Object.keys(h)[d-1];if(y){f.rtcTags&&!Array.isArray(f.rtcTags)&&(console.info.apply(console,o(c.logPrefix("info"),["config.rtcTags must be an array."])),f.rtcTags=void 0);var S=(e=f.rtcApiKey,n=f.proxyUrl||f.wsUrl,r="wss://watchrtc.testrtc.com",s=e.split(":"),-1!==e.indexOf("local")?{url:n||"ws://localhost:9101",apiKey:s[1]}:-1!==e.indexOf("staging")?{url:n||"wss://watchrtc-staging2.testrtc.com",apiKey:s[1]}:-1!==e.indexOf("production")?{url:n||r,apiKey:s[1]}:{url:n||r,apiKey:s[0]});u=Date.now(),g.connect(S.url+"?apiKey="+S.apiKey+"&timestamp="+Date.now(),(function(e){console.info.apply(console,o(c.logPrefix("info"),["Connection established. watchRTCConnectionId: "+e.connectionId+" sdkVersion:"+a.default])),v("watchrtc",w,i(i(i({},f),e),{sdkVersion:a.default})),m||(window.clearInterval(t),t=window.setInterval((function(){0===_()?u&&u+2e4<Date.now()&&(p=!1,window.clearInterval(t),g.close(),console.info.apply(console,o(c.logPrefix("info"),["Last connection closed. watchRTCConnectionId: "+e.connectionId+" sdkVersion: "+a.default]))):(u=Date.now(),Object.values(h).forEach((function(e){"closed"!==e.pc.signalingState&&b(e)})))}),e.interval))}),(function(){p=!1,u=0}))}}},b=function(e){if(e){var n=e.id,t=e.pc,i=e.prev;t.getStats(null).then((function(t){var o=function(e){if(!e.entries)return e;var n={};return e.forEach((function(e,t){n[t]=e})),n}(t),r=JSON.parse(JSON.stringify(o)),a=s(i,o);null!==(null==a?void 0:a.timestamp)&&(null==a?void 0:a.timestamp)!==-1/0&&v("getstats",n,s(e.prev,o)),e.prev=r}))}};if(n.forEach((function(n){if(window[n+"RTCPeerConnection"]&&("webkit"!==n||!m)){var t=window[n+"RTCPeerConnection"],i=function(n,i){var o=new t(n,i),r="PC_"+d++;return o.__rtcStatsId=r,h[r]={id:r,pc:o,validConnection:!1},f=e||(null==n?void 0:n.watchrtc),n||(n={nullConfig:!0}),((n=JSON.parse(JSON.stringify(n)))&&n.iceServers||[]).forEach((function(e){delete e.credential})),(null==n?void 0:n.watchrtc)&&delete n.watchrtc,n.browserType=y?"moz":m?"edge":"webkit",v("create",r,n),i&&v("constraints",r,i),o.addEventListener("icecandidate",(function(e){v("onicecandidate",r,e.candidate)})),o.addEventListener("addstream",(function(e){v("onaddstream",r,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),o.addEventListener("track",(function(e){v("ontrack",r,e.track.kind+":"+e.track.id+" "+e.streams.map((function(e){return"stream:"+e.id})))})),o.addEventListener("removestream",(function(e){v("onremovestream",r,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),o.addEventListener("signalingstatechange",(function(){h[r]&&!h[r].validConnection&&(h[r].validConnection=!0,setTimeout(w,5e3)),v("onsignalingstatechange",r,o.signalingState)})),o.addEventListener("iceconnectionstatechange",(function(){v("oniceconnectionstatechange",r,o.iceConnectionState)})),o.addEventListener("icegatheringstatechange",(function(){v("onicegatheringstatechange",r,o.iceGatheringState)})),o.addEventListener("connectionstatechange",(function(){v("onconnectionstatechange",r,o.connectionState)})),o.addEventListener("negotiationneeded",(function(){v("onnegotiationneeded",r,void 0)})),o.addEventListener("datachannel",(function(e){v("ondatachannel",r,[e.channel.id,e.channel.label])})),m||o.addEventListener("iceconnectionstatechange",(function(){"connected"===o.iceConnectionState&&b(h[r])})),o};["createDataChannel","close"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){return v(e,this.__rtcStatsId,arguments),delete h[this.__rtcStatsId],n.apply(this,arguments)})})),["addStream","removeStream"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=arguments[0],i=t.getTracks().map((function(e){return e.kind+":"+e.id})).join(",");return v(e,this.__rtcStatsId,t.id+" "+i),n.apply(this,arguments)})})),["addTrack"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=arguments[0],i=[].slice.call(arguments,1);return v(e,this.__rtcStatsId,t.kind+":"+t.id+" "+(i.map((function(e){return"stream:"+e.id})).join(";")||"-")),n.apply(this,arguments)})})),["removeTrack"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=arguments[0].track;return v(e,this.__rtcStatsId,t?t.kind+":"+t.id:"null"),n.apply(this,arguments)})})),["createOffer","createAnswer"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t,i=this.__rtcStatsId,o=arguments;return 1===arguments.length&&"object"==typeof arguments[0]?t=arguments[0]:3===arguments.length&&"object"==typeof arguments[2]&&(t=arguments[2]),v(e,this.__rtcStatsId,t),n.apply(this,t?[t]:void 0).then((function(n){if(v(e+"OnSuccess",i,n),!(o.length>0&&"function"==typeof o[0]))return n;o[0].apply(null,[n])}),(function(n){if(v(e+"OnFailure",i,n.toString()),!(o.length>1&&"function"==typeof o[1]))throw n;o[1].apply(null,[n])}))})})),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(e){var n=t.prototype[e];n&&(t.prototype[e]=function(){var t=this.__rtcStatsId,i=arguments;return v(e,this.__rtcStatsId,i[0]),n.apply(this,[i[0]]).then((function(){v(e+"OnSuccess",t,void 0),i.length>=2&&"function"==typeof i[1]&&i[1].apply(null,[])}),(function(n){if(v(e+"OnFailure",t,n.toString()),!(i.length>=3&&"function"==typeof i[2]))throw n;i[2].apply(null,[n])}))})})),t.generateCertificate&&Object.defineProperty(i,"generateCertificate",{get:function(){return arguments.length?t.generateCertificate.apply(null,arguments):t.generateCertificate}}),window[n+"RTCPeerConnection"]=i,window[n+"RTCPeerConnection"].prototype=t.prototype}})),n.forEach((function(e){var n=e+(e.length?"GetUserMedia":"getUserMedia");if(navigator[n]){var t=navigator[n].bind(navigator);navigator[n]=function(){v("getUserMedia",null,arguments[0]);var e=arguments[1],n=arguments[2];t(arguments[0],(function(n){v("getUserMediaOnSuccess",null,l(n)),e&&e(n)}),(function(e){v("getUserMediaOnFailure",null,e.name),n&&n(e)}))}.bind(navigator)}})),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){var S=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(){return v("navigator.mediaDevices.getUserMedia",null,arguments[0]),S.apply(navigator.mediaDevices,arguments).then((function(e){return v("navigator.mediaDevices.getUserMediaOnSuccess",null,l(e)),e}),(function(e){return v("navigator.mediaDevices.getUserMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia){var k=navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getDisplayMedia=function(){return v("navigator.mediaDevices.getDisplayMedia",null,arguments[0]),k.apply(navigator.mediaDevices,arguments).then((function(e){return v("navigator.mediaDevices.getDisplayMediaOnSuccess",null,l(e)),e}),(function(e){return v("navigator.mediaDevices.getDisplayMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}}},n.setUserRating=function(e,n){var t;e&&(r.default._instance&&(null===(t=r.default._instance.connection)||void 0===t?void 0:t.readyState)===WebSocket.OPEN?r.default._instance.trace("userRating","",{rate:e,rateReason:n}):console.info.apply(console,o(c.logPrefix("error"),["Please set user rating before websocket connection is closed."])))}},699:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0})},593:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.logPrefix=void 0,n.logPrefix=function(e){return void 0===e&&(e="info"),"error"===e?["%cwatchRTC %cERROR","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;","background: red; color: white; padding: 2px 0.5em; border-radius: 0.5em;"]:["%cwatchRTC","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;"]}},412:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.default="1.28.3"},85:function(e,n,t){var i=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var i=Array(e),o=0;for(n=0;n<t;n++)for(var r=arguments[n],a=0,c=r.length;a<c;a++,o++)i[o]=r[a];return i};Object.defineProperty(n,"__esModule",{value:!0});var o=t(593),r=function(){function e(){this.connection=null,this.buffer=[],this.sendInterval=1,this.onClose=function(){},e._instance?console.info.apply(console,i(o.logPrefix("info"),["WatchRTCSocket instance already created"])):e._instance=this}return e.prototype.connect=function(n,t,r){e._instance.connection&&e._instance.connection.close(),e._instance.connection=new WebSocket(n,"2.0"),e._instance.connection.onopen=function(e){},e._instance.connection.onclose=function(e){};var a=e._instance;e._instance.connection.onmessage=function(n){var c;try{var s=JSON.parse(n.data);s.error?(null===(c=null==a?void 0:a.connection)||void 0===c||c.close(),a.connection=null,console.info.apply(console,i(o.logPrefix("error"),["\n"+s.error])),r(s.error)):(s.sendInterval&&(e._instance.sendInterval=s.sendInterval),t(s))}catch(e){console.info.apply(console,i(o.logPrefix("error"),[{err:e.stack}])),r(e.message)}},e._instance.connection.onerror=function(e){console.info.apply(console,i(o.logPrefix("error"),["\n",e])),r(e)}},e.prototype.trace=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var i=Array.prototype.slice.call(n);if(i.push(Date.now()),i[1]instanceof RTCPeerConnection&&(i[1]=i[1].__rtcStatsId),e._instance.connection){if(e._instance.connection.readyState===WebSocket.OPEN&&(e._instance.buffer.push(i),e._instance.buffer.length>=e._instance.sendInterval)){var o=JSON.stringify(e._instance.buffer);e._instance.buffer=[],e._instance.connection.send(o)}}else{if(e._instance.buffer.length>1e3)return;e._instance.buffer.push(i)}},e.prototype.close=function(){e._instance.buffer=[],e._instance.connection&&(e._instance.connection.close(),e._instance.onClose(),e._instance.connection=null)},e}();n.default=r}},n={},t=function t(i){if(n[i])return n[i].exports;var o=n[i]={exports:{}};return e[i].call(o.exports,o,o.exports,t),o.exports}(607);return t.default})()}));
//# sourceMappingURL=index.js.map

@@ -233,25 +233,27 @@ "use strict";

var getStats = function (pcInfo) {
var id = pcInfo.id, pc = pcInfo.pc, prev = pcInfo.prev;
if (standardGetstats || isFirefox || isSafari) {
pc.getStats(null).then(function (res) {
var now = map2obj(res);
var base = JSON.parse(JSON.stringify(now)); // our new prev
var data = deltaCompression(prev, now);
if ((data === null || data === void 0 ? void 0 : data.timestamp) !== null && (data === null || data === void 0 ? void 0 : data.timestamp) !== -Infinity) {
trace("getstats", id, deltaCompression(pcInfo.prev, now));
}
pcInfo.prev = base;
});
if (pcInfo) {
var id_2 = pcInfo.id, pc_1 = pcInfo.pc, prev_1 = pcInfo.prev;
if (standardGetstats || isFirefox || isSafari) {
pc_1.getStats(null).then(function (res) {
var now = map2obj(res);
var base = JSON.parse(JSON.stringify(now)); // our new prev
var data = deltaCompression(prev_1, now);
if ((data === null || data === void 0 ? void 0 : data.timestamp) !== null && (data === null || data === void 0 ? void 0 : data.timestamp) !== -Infinity) {
trace("getstats", id_2, deltaCompression(pcInfo.prev, now));
}
pcInfo.prev = base;
});
}
else {
pc_1.getStats(function (res) {
var now = mangleChromeStats(pc_1, res);
var base = JSON.parse(JSON.stringify(now)); // our new prev
var data = deltaCompression(prev_1, now);
if ((data === null || data === void 0 ? void 0 : data.timestamp) !== null && (data === null || data === void 0 ? void 0 : data.timestamp) !== -Infinity) {
trace("getstats", id_2, deltaCompression(prev_1, now));
}
pcInfo.prev = base;
});
}
}
else {
pc.getStats(function (res) {
var now = mangleChromeStats(pc, res);
var base = JSON.parse(JSON.stringify(now)); // our new prev
var data = deltaCompression(prev, now);
if ((data === null || data === void 0 ? void 0 : data.timestamp) !== null && (data === null || data === void 0 ? void 0 : data.timestamp) !== -Infinity) {
trace("getstats", id, deltaCompression(prev, now));
}
pcInfo.prev = base;
});
}
};

@@ -258,0 +260,0 @@ prefixesToWrap.forEach(function (prefix) {

@@ -1,2 +0,2 @@

declare const _default: "1.28.2";
declare const _default: "1.28.3";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = "1.28.2";
exports.default = "1.28.3";
{
"name": "@testrtc/watchrtc-sdk",
"version": "1.28.2",
"version": "1.28.3",
"description": "gather WebRTC API traces and statistics",

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

Sorry, the diff of this file is not supported yet

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