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.2 to 1.1.3

3

dist/bundle.d.ts

@@ -28,3 +28,3 @@ // Generated by dts-bundle v0.7.2

id: string;
event: MessageEvent | Event;
event: MessageEvent | Event | DOMException;
}

@@ -38,2 +38,3 @@

static ANSWER: string;
static ERROR: string;
}

@@ -40,0 +41,0 @@

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

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

@@ -15,3 +15,3 @@ import { Connection } from './connection/connection';

private dispatchEvent(event);
private dispatchError(event);
private dispatchError(caller, event);
}

@@ -43,4 +43,4 @@ import { EventDispatcher } from './dispatcher/dispatcher';

};
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, _this.dispatchError);
}, this.dispatchError);
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
}, function (evnt) { return _this.dispatchError(event.caller, evnt); });
};

@@ -63,3 +63,3 @@ Bridge.prototype.onDisconnect = function (event) {

};
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, this.dispatchError);
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
peer.createAnswer(function (desc) {

@@ -73,8 +73,9 @@ var message = {

};
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, _this.dispatchError);
}, this.dispatchError);
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
}, function (evnt) { return _this.dispatchError(event.caller, evnt); });
};
Bridge.prototype.onAnswer = function (event) {
var _this = this;
var peer = this._peers[event.caller.id];
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, this.dispatchError);
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
};

@@ -90,4 +91,8 @@ Bridge.prototype.onCandidate = function (event) {

};
Bridge.prototype.dispatchError = function (event) {
EventDispatcher.dispatch(DataEventType.ERROR, event);
Bridge.prototype.dispatchError = function (caller, event) {
var message = {
id: caller.id,
event: event,
};
EventDispatcher.dispatch(DataEventType.ERROR, message);
};

@@ -94,0 +99,0 @@ return Bridge;

export interface DataEvent {
id: string;
event: MessageEvent | Event;
event: MessageEvent | Event | DOMException;
}

@@ -7,2 +7,3 @@ export declare class ConnectionEventType {

static ANSWER: string;
static ERROR: string;
}

@@ -12,2 +12,3 @@ var ConnectionEventType = (function () {

ConnectionEventType.ANSWER = 'ANSWER';
ConnectionEventType.ERROR = 'ERROR';
//# sourceMappingURL=event-type.js.map

@@ -15,3 +15,3 @@ import { Connection } from './connection/connection';

private dispatchEvent(event);
private dispatchError(event);
private dispatchError(caller, event);
}

@@ -45,4 +45,4 @@ "use strict";

};
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, _this.dispatchError);
}, this.dispatchError);
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
}, function (evnt) { return _this.dispatchError(event.caller, evnt); });
};

@@ -65,3 +65,3 @@ Bridge.prototype.onDisconnect = function (event) {

};
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, this.dispatchError);
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
peer.createAnswer(function (desc) {

@@ -75,8 +75,9 @@ var message = {

};
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, _this.dispatchError);
}, this.dispatchError);
peer.setLocalDescription(desc, function () { return _this.dispatchEvent(message); }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
}, function (evnt) { return _this.dispatchError(event.caller, evnt); });
};
Bridge.prototype.onAnswer = function (event) {
var _this = this;
var peer = this._peers[event.caller.id];
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, this.dispatchError);
peer.setRemoteDescription(new RTCSessionDescription(event.data), function () { }, function (evnt) { return _this.dispatchError(event.caller, evnt); });
};

@@ -92,4 +93,8 @@ Bridge.prototype.onCandidate = function (event) {

};
Bridge.prototype.dispatchError = function (event) {
dispatcher_1.EventDispatcher.dispatch(event_type_2.DataEventType.ERROR, event);
Bridge.prototype.dispatchError = function (caller, event) {
var message = {
id: caller.id,
event: event,
};
dispatcher_1.EventDispatcher.dispatch(event_type_2.DataEventType.ERROR, message);
};

@@ -96,0 +101,0 @@ return Bridge;

export interface DataEvent {
id: string;
event: MessageEvent | Event;
event: MessageEvent | Event | DOMException;
}

@@ -7,2 +7,3 @@ export declare class ConnectionEventType {

static ANSWER: string;
static ERROR: string;
}

@@ -13,3 +13,4 @@ "use strict";

ConnectionEventType.ANSWER = 'ANSWER';
ConnectionEventType.ERROR = 'ERROR';
exports.ConnectionEventType = ConnectionEventType;
//# sourceMappingURL=event-type.js.map
{
"name": "peer-data",
"version": "1.1.2",
"version": "1.1.3",
"description": "PeerData - library for files, media streaming/sharing using WebRTC",

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

@@ -33,2 +33,2 @@ {

}
}
}

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

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

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