Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

peer-data

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peer-data - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

2

dist/peer-data.js

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("socket.io-client")):"function"==typeof define&&define.amd?define(["exports","socket.io-client"],n):n(e["peer-data"]=e["peer-data"]||{},e.io)}(this,function(e,n){"use strict";var t={},r=function(){function e(){}return e.register=function(e,n){t[e]||(t[e]=[]),t[e].push(n)},e.dispatch=function(e,n){t[e].forEach(function(e){return e(n)})},e}(),i=function(){function e(){}return e}();i.CONNECT="CONNECT",i.DISCONNECT="DISCONNECT",i.CANDIDATE="CANDIDATE",i.OFFER="OFFER",i.ANSWER="ANSWER",i.ERROR="ERROR";var o=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null),this._servers={},this._dataConstraints=null,this._peers={},this._channels={},this._servers=e,this._dataConstraints=n}return Object.defineProperty(e.prototype,"peers",{get:function(){return this._peers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channels",{get:function(){return this._channels},enumerable:!0,configurable:!0}),e.prototype.addPeer=function(e,n){return this._peers.hasOwnProperty(e)||(this._peers[e]=n),this},e.prototype.removePeer=function(e){return this._peers.hasOwnProperty(e)&&(this._peers[e].close(),delete this._peers[e],delete this._peers[e]),this},e.prototype.addChannel=function(e,n){return this._channels.hasOwnProperty(e)||(this._channels[e]=n),this},e.prototype.removeChannel=function(e){return this._channels.hasOwnProperty(e)&&(this._channels[e].close(),delete this._channels[e]),this},Object.defineProperty(e.prototype,"servers",{get:function(){return this._servers},set:function(e){this._servers=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataConstraints",{get:function(){return this._dataConstraints},set:function(e){this._dataConstraints=e},enumerable:!0,configurable:!0}),e}(),s=function(){function e(){}return e}();s.LOG="LOG",s.OPEN="OPEN",s.CLOSE="CLOSE",s.ERROR="ERROR",s.DATA="DATA";var c=function(){function e(){}return e.get=function(e,n){var t=new RTCPeerConnection(e);return t.onicecandidate=function(e){if(e.candidate){var t=e instanceof RTCIceCandidate?e:e.candidate,o={type:i.CANDIDATE,caller:null,callee:n.caller,room:n.room,data:t};r.dispatch("send",o)}},t},e}(),a=function(){function e(){}return e.get=function(e,n){var t=Math.floor(1e16*(1+Math.random())).toString(16).substring(1);return e.createDataChannel(t,n)},e.subscribeToEvents=function(e,n,t){return e.onmessage=function(e){var n={id:t.caller.id,event:e};r.dispatch(s.DATA,n)},e.onopen=function(e){var n={id:t.caller.id,event:e};r.dispatch(s.OPEN,n)},e.onclose=function(e){var i={id:t.caller.id,event:e};r.dispatch(s.CLOSE,i),delete n[t.caller.id]},e.onerror=function(e){var n={id:t.caller.id,event:e};r.dispatch(s.ERROR,n)},e},e}(),l=function(){function e(e){this._peers={},this._channels={},this._connection=e,this._peers=this._connection.peers,this._channels=this._connection.channels,r.register(i.CONNECT,this.onConnect.bind(this)),r.register(i.DISCONNECT,this.onDisconnect.bind(this)),r.register(i.OFFER,this.onOffer.bind(this)),r.register(i.ANSWER,this.onAnswer.bind(this)),r.register(i.CANDIDATE,this.onCandidate.bind(this))}return Object.defineProperty(e.prototype,"connection",{get:function(){return this._connection},set:function(e){this._connection=e},enumerable:!0,configurable:!0}),e.prototype.onConnect=function(e){var n=this,t=this._peers[e.caller.id]=c.get(this._connection.servers,e),r=a.get(t,this._connection.dataConstraints);this._channels[e.caller.id]=a.subscribeToEvents(r,this._channels,e),this._peers[e.caller.id]=t,t.createOffer(function(r){var o={type:i.OFFER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(o)},function(t){return n.dispatchError(e.caller,t)})},function(t){return n.dispatchError(e.caller,t)})},e.prototype.onDisconnect=function(e){var n=this._channels[e.caller.id],t=this._peers[e.caller.id];n.close(),t.close(),delete this._channels[e.caller.id],delete this._peers[e.caller.id]},e.prototype.onOffer=function(e){var n=this,t=c.get(this._connection.servers,e);this._peers[e.caller.id]=t,t.ondatachannel=function(t){var r=a.subscribeToEvents(t.channel,n._channels,e);n._connection.addChannel(e.caller.id,r)},t.setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e.caller,t)}),t.createAnswer(function(r){var o={type:i.ANSWER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(o)},function(t){return n.dispatchError(e.caller,t)})},function(t){return n.dispatchError(e.caller,t)})},e.prototype.onAnswer=function(e){var n=this;this._peers[e.caller.id].setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e.caller,t)})},e.prototype.onCandidate=function(e){var n=this,t=this._peers[e.caller.id],r=new RTCIceCandidate(e.data);t.addIceCandidate(r).then(function(){},function(t){return n.dispatchError(e.caller,t)})},e.prototype.dispatchEvent=function(e){r.dispatch("send",e)},e.prototype.dispatchError=function(e,n){var t={id:e.id,event:n};r.dispatch(s.ERROR,t)},e}(),h=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null);var t=new o(e,n);this.bridge=new l(t)}return e.prototype.on=function(e,n){r.register(e,n)},e.prototype.send=function(e,n){if(n){var t=this.bridge.connection.channels[n];t&&t.send(e)}else Object.entries(this.bridge.connection.channels).forEach(function(n){n[0];return n[1].send(e)})},e.prototype.connect=function(e){var n={type:i.CONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.disconnect=function(e){Object.entries(this.bridge.connection.channels).forEach(function(e){e[0];return e[1].close()}),Object.entries(this.bridge.connection.peers).forEach(function(e){e[0];return e[1].close()});var n={type:i.DISCONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e}(),u=function(){function e(e){this.socket=n.connect(e),this.subscribeEvents()}return e.prototype.onSend=function(e){this.socket.emit("message",e)},e.prototype.subscribeEvents=function(){this.socket.on("message",this.onMessage.bind(this)),this.socket.on("ipaddr",this.onIp.bind(this)),this.socket.on("log",this.onLog.bind(this)),r.register("send",this.onSend.bind(this))},e.prototype.onIp=function(e){r.dispatch(s.LOG,"Server IP address is: "+e)},e.prototype.onLog=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.dispatch(s.LOG,e)},e.prototype.onMessage=function(e){r.dispatch(e.type,e)},e}();e.default=h,e.EventDispatcher=r,e.ConnectionEventType=i,e.DataEventType=s,e.SocketChannel=u,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("socket.io-client")):"function"==typeof define&&define.amd?define(["exports","socket.io-client"],n):n(e["peer-data"]=e["peer-data"]||{},e.io)}(this,function(e,n){"use strict";var t={},r=function(){function e(){}return e.register=function(e,n){t[e]||(t[e]=[]),t[e].push(n)},e.dispatch=function(e,n){t[e].forEach(function(e){return e(n)})},e}(),i=function(){function e(){}return e}();i.CONNECT="CONNECT",i.DISCONNECT="DISCONNECT",i.CANDIDATE="CANDIDATE",i.OFFER="OFFER",i.ANSWER="ANSWER",i.ERROR="ERROR";var o=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null),this._servers={},this._dataConstraints=null,this._peers={},this._channels={},this._servers=e,this._dataConstraints=n}return Object.defineProperty(e.prototype,"peers",{get:function(){return this._peers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channels",{get:function(){return this._channels},enumerable:!0,configurable:!0}),e.prototype.addPeer=function(e,n){return this._peers.hasOwnProperty(e)||(this._peers[e]=n),this},e.prototype.removePeer=function(e){return this._peers.hasOwnProperty(e)&&(this._peers[e].close(),delete this._peers[e],delete this._peers[e]),this},e.prototype.addChannel=function(e,n){return this._channels.hasOwnProperty(e)||(this._channels[e]=n),this},e.prototype.removeChannel=function(e){return this._channels.hasOwnProperty(e)&&(this._channels[e].close(),delete this._channels[e]),this},Object.defineProperty(e.prototype,"servers",{get:function(){return this._servers},set:function(e){this._servers=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataConstraints",{get:function(){return this._dataConstraints},set:function(e){this._dataConstraints=e},enumerable:!0,configurable:!0}),e}(),s=function(){function e(){}return e}();s.LOG="LOG",s.OPEN="OPEN",s.CLOSE="CLOSE",s.ERROR="ERROR",s.DATA="DATA";var c=function(){function e(){}return e.get=function(e,n){var t=new RTCPeerConnection(e);return t.onicecandidate=function(e){if(e.candidate){var t={type:i.CANDIDATE,caller:null,callee:n.caller,room:n.room,data:e.candidate};r.dispatch("send",t)}},t},e}(),a=function(){function e(){}return e.get=function(e,n){var t=Math.floor(1e16*(1+Math.random())).toString(16).substring(1);return e.createDataChannel(t,n)},e.subscribeToEvents=function(e,n,t){return e.onmessage=function(e){var n={id:t.caller.id,event:e};r.dispatch(s.DATA,n)},e.onopen=function(e){var n={id:t.caller.id,event:e};r.dispatch(s.OPEN,n)},e.onclose=function(e){var i={id:t.caller.id,event:e};r.dispatch(s.CLOSE,i),delete n[t.caller.id]},e.onerror=function(e){var n={id:t.caller.id,event:e};r.dispatch(s.ERROR,n)},e},e}(),l=function(){function e(e){this._peers={},this._channels={},this._connection=e,this._peers=this._connection.peers,this._channels=this._connection.channels,r.register(i.CONNECT,this.onConnect.bind(this)),r.register(i.DISCONNECT,this.onDisconnect.bind(this)),r.register(i.OFFER,this.onOffer.bind(this)),r.register(i.ANSWER,this.onAnswer.bind(this)),r.register(i.CANDIDATE,this.onCandidate.bind(this))}return Object.defineProperty(e.prototype,"connection",{get:function(){return this._connection},set:function(e){this._connection=e},enumerable:!0,configurable:!0}),e.prototype.onConnect=function(e){var n=this,t=this._peers[e.caller.id]=c.get(this._connection.servers,e),r=a.get(t,this._connection.dataConstraints);this._channels[e.caller.id]=a.subscribeToEvents(r,this._channels,e),this._peers[e.caller.id]=t,t.createOffer(function(r){var o={type:i.OFFER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(o)},function(t){return n.dispatchError(e.caller,t)})},function(t){return n.dispatchError(e.caller,t)})},e.prototype.onDisconnect=function(e){var n=this._channels[e.caller.id],t=this._peers[e.caller.id];n.close(),t.close(),delete this._channels[e.caller.id],delete this._peers[e.caller.id]},e.prototype.onOffer=function(e){var n=this,t=c.get(this._connection.servers,e);this._peers[e.caller.id]=t,t.ondatachannel=function(t){var r=a.subscribeToEvents(t.channel,n._channels,e);n._connection.addChannel(e.caller.id,r)},t.setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e.caller,t)}),t.createAnswer(function(r){var o={type:i.ANSWER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(o)},function(t){return n.dispatchError(e.caller,t)})},function(t){return n.dispatchError(e.caller,t)})},e.prototype.onAnswer=function(e){var n=this;this._peers[e.caller.id].setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e.caller,t)})},e.prototype.onCandidate=function(e){var n=this,t=this._peers[e.caller.id],r=new RTCIceCandidate(e.data);t.addIceCandidate(r).then(function(){},function(t){return n.dispatchError(e.caller,t)})},e.prototype.dispatchEvent=function(e){r.dispatch("send",e)},e.prototype.dispatchError=function(e,n){var t={id:e.id,event:n};r.dispatch(s.ERROR,t)},e}(),h=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null);var t=new o(e,n);this.bridge=new l(t)}return e.prototype.on=function(e,n){r.register(e,n)},e.prototype.send=function(e,n){if(n){var t=this.bridge.connection.channels[n];t&&t.send(e)}else Object.entries(this.bridge.connection.channels).forEach(function(n){n[0];return n[1].send(e)})},e.prototype.connect=function(e){var n={type:i.CONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.disconnect=function(e){Object.entries(this.bridge.connection.channels).forEach(function(e){e[0];return e[1].close()}),Object.entries(this.bridge.connection.peers).forEach(function(e){e[0];return e[1].close()});var n={type:i.DISCONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e}(),u=function(){function e(e){this.socket=n.connect(e),this.subscribeEvents()}return e.prototype.onSend=function(e){this.socket.emit("message",e)},e.prototype.subscribeEvents=function(){this.socket.on("message",this.onMessage.bind(this)),this.socket.on("ipaddr",this.onIp.bind(this)),this.socket.on("log",this.onLog.bind(this)),r.register("send",this.onSend.bind(this))},e.prototype.onIp=function(e){r.dispatch(s.LOG,"Server IP address is: "+e)},e.prototype.onLog=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.dispatch(s.LOG,e)},e.prototype.onMessage=function(e){r.dispatch(e.type,e)},e}();e.default=h,e.EventDispatcher=r,e.ConnectionEventType=i,e.DataEventType=s,e.SocketChannel=u,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=peer-data.js.map

@@ -10,3 +10,2 @@ import { EventDispatcher } from './../dispatcher/dispatcher';

if (iceEvent.candidate) {
var sdp = iceEvent instanceof RTCIceCandidate ? iceEvent : iceEvent.candidate;
var message = {

@@ -17,3 +16,3 @@ type: ConnectionEventType.CANDIDATE,

room: event.room,
data: sdp,
data: iceEvent.candidate,
};

@@ -20,0 +19,0 @@ EventDispatcher.dispatch('send', message);

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

if (iceEvent.candidate) {
var sdp = iceEvent instanceof RTCIceCandidate ? iceEvent : iceEvent.candidate;
var message = {

@@ -19,3 +18,3 @@ type: event_type_1.ConnectionEventType.CANDIDATE,

room: event.room,
data: sdp,
data: iceEvent.candidate,
};

@@ -22,0 +21,0 @@ dispatcher_1.EventDispatcher.dispatch('send', message);

{
"name": "peer-data",
"version": "1.1.6",
"version": "1.1.7",
"description": "PeerData - library for files, media streaming/sharing using WebRTC",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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