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

@netology-group/conference

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netology-group/conference - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

2

dist/index.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Conference=t():e.Conference=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){var r=n(3),i=n(4);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}((e.exports=a).EventEmitter=a).prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,o,s;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),0<(i=c(e))&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,o(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):d(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var s;if(0<t.length&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=d(u,c);for(n=0;n<c;++n)o(f[n],this,t)}return!0},a.prototype.on=a.prototype.addListener=function(e,t){return f(this,e,t,!1)},a.prototype.prependListener=function(e,t){return f(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},a.prototype.off=a.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;0<=o;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;0<=r;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},a.prototype.listenerCount=h,a.prototype.eventNames=function(){return 0<this._eventsCount?r(this._events):[]}},function(e,t,n){e.exports=n(5)},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";n.r(t);var r=n(0),i=n.n(r),o=n(1),s=n.n(o);function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var u=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._ee=new s.a,this._messageHandler=r,this._mqtt=t,this._topic=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners(),this._addSubscription()}return t=e,(n=[{key:"_bindListeners",value:function(){this._mqtt.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._mqtt.off("message",this._handleMessageEvent)}},{key:"_addSubscription",value:function(){this._mqtt.subscribe(this._topic)}},{key:"_removeSubscription",value:function(){this._mqtt.unsubscribe(this._topic)}},{key:"_handleMessageEvent",value:function(e,t){if(e===this._topic){var n=this._messageHandler(e,t);null!==n&&this._ee.emit(n.type,n)}}},{key:"on",value:function(e,t){this._ee.addListener(e,t)}},{key:"off",value:function(e,t){this._ee.removeListener(e,t)}},{key:"destroy",value:function(){this._ee.removeAllListeners(),this._unbindListeners(),this._removeSubscription()}}])&&a(t.prototype,n),e;var t,n}();function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=function(){function e(t,n,r,i,o){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._codec=i,this._handlerMap={},this._incomingRequestMap={},this._mqtt=t,this._methods=o,this._requestStorage={},this._topicIn=n,this._topicOut=r,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._subMessageHandler=this._subMessageHandler.bind(this),this._sub=new u(this._mqtt,this._topicIn,this._subMessageHandler),this._bindListeners()}return t=e,(n=[{key:"_bindListeners",value:function(){this._sub.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._sub.off("message",this._handleMessageEvent)}},{key:"_subMessageHandler",value:function(e,t){return{type:"message",data:this._codec.decode(t)}}},{key:"_handleMessageEvent",value:function(e){var t=e.data,n=t.properties,r=t.payload,i=n.correlation_data,o=n.label,s=n.method,a=n.status,u=n.type;"response"===u&&i?"200"===a?this._processResponse("resolve",i,r):this._processResponse("reject",i,r):"request"===u&&s&&i?this._processIncomingRequest(n,r):"event"===u&&"string"==typeof o?this._processNotification(o,r):console.debug("Unknown message",t)}},{key:"_processIncomingRequest",value:function(e,t){var n=e.correlation_data,r=e.method,i=e.response_topic,o=this._handlerMap[r],s=null;if(o&&!this._incomingRequestMap[n]){this._incomingRequestMap[n]=!0,s=o(t);var a={payload:JSON.stringify(s),properties:{type:"response",status:"200",correlation_data:n}};this._mqtt.publish(i,this._codec.encode(a),null)}}},{key:"_processRequest",value:function(e,t){var n=this,r=i()(),o={properties:{type:"request",method:e,response_topic:this._topicIn,correlation_data:r},payload:JSON.stringify(t)},s=this._codec.encode(o);return this._mqtt.publish(this._topicOut,s,null,function(e){e&&n._processResponse("reject",r,e)}),new Promise(function(e,t){n._requestStorage[r]={payload:s,resolve:e,reject:t}})}},{key:"_processResponse",value:function(e,t,n){var r=this._requestStorage[t];r?("resolve"===e?r.resolve(n):r.reject(n),delete this._requestStorage[t]):console.debug("Unknown response",t,n)}},{key:"_processNotification",value:function(e,t){var n=this._methods[e];n&&"function"==typeof n&&n(t)}},{key:"send",value:function(e,t){return this._processRequest(e,t)}},{key:"register",value:function(e,t){if(this._handlerMap[e])throw new Error("Method ".concat(e," already registered"));this._handlerMap[e]=t}},{key:"unregister",value:function(e){if(!this._handlerMap[e])throw new Error("Method ".concat(e," not registered"));delete this._handlerMap[e]}},{key:"destroy",value:function(){this._unbindListeners(),this._sub.destroy(),this._handlerMap={},this._incomingRequestMap={},this._requestStorage={}}}])&&c(t.prototype,n),e;var t,n}();function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var h=new(function(){function e(t,n){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._encoder=t,this._decoder=n}return t=e,(n=[{key:"encode",value:function(e){return this._encoder(e)}},{key:"decode",value:function(e){return this._decoder(e)}}])&&l(t.prototype,n),e;var t,n}())(function(e){return JSON.stringify(e)},function(e){var t,n;try{n={properties:(t=JSON.parse(e.toString())).properties,payload:JSON.parse(t.payload)}}catch(e){n={}}return n}),d=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._agentId=n,this._appName=r,this._topicIn="agents/".concat(this._agentId,"/api/v1/in/").concat(this._appName),this._topicOut="agents/".concat(this._agentId,"/api/v1/out/").concat(this._appName),this._codec=h,this._mqtt=t,this._rpc=new f(this._mqtt,this._topicIn,this._topicOut,this._codec,{}),this._subMessageHandler=this._subMessageHandler.bind(this)}return t=e,(n=[{key:"createRoom",value:function(e,t){var n={time:e,audience:t};return this._rpc.send("room.create",n)}},{key:"readRoom",value:function(e){var t={id:e};return this._rpc.send("room.read",t)}},{key:"updateRoom",value:function(e,t,n){var r={id:e,time:t,audience:n};return this._rpc.send("room.update",r)}},{key:"deleteRoom",value:function(e){var t={id:e};return this._rpc.send("room.delete",t)}},{key:"createRtc",value:function(e){var t={room_id:e};return this._rpc.send("rtc.create",t)}},{key:"readRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.read",t)}},{key:"listRtc",value:function(e,t){var n={room_id:e,offset:t.offset||0,limit:t.limit||25};return this._rpc.send("rtc.list",n)}},{key:"connectRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.connect",t)}},{key:"createRtcSignal",value:function(e,t,n){var r={handle_id:e,jsep:t,label:n};return this._rpc.send("rtc_signal.create",r)}},{key:"listRtcStream",value:function(e,t){var n={room_id:e,rtc_id:t.rtcId,offset:t.offset||0,limit:t.limit||25,time:t.time};return this._rpc.send("rtc_stream.list",n)}},{key:"createMessage",value:function(e,t,n){var r={room_id:e,agent_id:t,data:n};return this._rpc.send("message.create",r)}},{key:"subscribeRoomEvents",value:function(e){return new u(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/").concat(e,"/events"),this._subMessageHandler)}},{key:"register",value:function(){var e;(e=this._rpc).register.apply(e,arguments)}},{key:"unregister",value:function(){var e;(e=this._rpc).unregister.apply(e,arguments)}},{key:"_subMessageHandler",value:function(e,t){var n=this._codec.decode(t),r=n.properties,i=n.payload,o=r.label,s=null;return"event"===r.type&&void 0!==i?s={type:o,data:i}:console.debug("Unknown message",n),s}},{key:"destroy",value:function(){this._rpc.destroy()}}])&&p(t.prototype,n),e;var t,n}();t.default=d}]).default});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Conference=t():e.Conference=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){var r=n(3),i=n(4);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}((e.exports=a).EventEmitter=a).prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,o,s;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),0<(i=c(e))&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,o(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):d(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var s;if(0<t.length&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,f=d(u,c);for(n=0;n<c;++n)o(f[n],this,t)}return!0},a.prototype.on=a.prototype.addListener=function(e,t){return f(this,e,t,!1)},a.prototype.prependListener=function(e,t){return f(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},a.prototype.off=a.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;0<=o;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;0<=r;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},a.prototype.listenerCount=h,a.prototype.eventNames=function(){return 0<this._eventsCount?r(this._events):[]}},function(e,t,n){e.exports=n(5)},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";n.r(t);var r=n(0),i=n.n(r),o=n(1),s=n.n(o);function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var u=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._ee=new s.a,this._messageHandler=r,this._mqtt=t,this._topic=n,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._bindListeners(),this._addSubscription()}return t=e,(n=[{key:"_bindListeners",value:function(){this._mqtt.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._mqtt.off("message",this._handleMessageEvent)}},{key:"_addSubscription",value:function(){this._mqtt.subscribe(this._topic)}},{key:"_removeSubscription",value:function(){this._mqtt.unsubscribe(this._topic)}},{key:"_handleMessageEvent",value:function(e,t,n){if(e===this._topic){var r=this._messageHandler(e,t,n);null!==r&&this._ee.emit(r.type,r)}}},{key:"on",value:function(e,t){this._ee.addListener(e,t)}},{key:"off",value:function(e,t){this._ee.removeListener(e,t)}},{key:"destroy",value:function(){this._ee.removeAllListeners(),this._unbindListeners(),this._removeSubscription()}}])&&a(t.prototype,n),e;var t,n}();function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=function(){function e(t,n,r,i,o){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._codec=i,this._handlerMap={},this._incomingRequestMap={},this._mqtt=t,this._methods=o,this._requestStorage={},this._topicIn=n,this._topicOut=r,this._handleMessageEvent=this._handleMessageEvent.bind(this),this._subMessageHandler=this._subMessageHandler.bind(this),this._sub=new u(this._mqtt,this._topicIn,this._subMessageHandler),this._bindListeners()}return t=e,(n=[{key:"_bindListeners",value:function(){this._sub.on("message",this._handleMessageEvent)}},{key:"_unbindListeners",value:function(){this._sub.off("message",this._handleMessageEvent)}},{key:"_subMessageHandler",value:function(e,t,n){return{type:"message",data:{payload:this._codec.decode(t),properties:n.properties}}}},{key:"_handleMessageEvent",value:function(e){var t=e.data,n=t.properties,r=t.payload,i=n.correlationData,o=n.userProperties,s=o.label,a=o.method,u=o.status,c=o.type;"response"===c&&i?"200"===u?this._processResponse("resolve",i,r):this._processResponse("reject",i,r):"request"===c&&a&&i?this._processIncomingRequest(n,r):"event"===c&&"string"==typeof s?this._processNotification(s,r):console.debug("Unknown message",t)}},{key:"_processIncomingRequest",value:function(e,t){var n=e.correlationData,r=e.responseTopic,i=e.userProperties.method,o=this._handlerMap[i],s=null;if(o&&!this._incomingRequestMap[n]){this._incomingRequestMap[n]=!0,s=o(t);var a={correlationData:n,userProperties:{status:"200",type:"response"}};this._mqtt.publish(r,this._codec.encode(s),{properties:a})}}},{key:"_processRequest",value:function(e,t){var n=this,r=i()(),o={correlationData:r,responseTopic:this._topicIn,userProperties:{method:e,type:"request"}},s=this._codec.encode(t);return this._mqtt.publish(this._topicOut,s,{properties:o},function(e){e&&n._processResponse("reject",r,e)}),new Promise(function(e,t){n._requestStorage[r]={payload:s,resolve:e,reject:t}})}},{key:"_processResponse",value:function(e,t,n){var r=this._requestStorage[t];r?("resolve"===e?r.resolve(n):r.reject(n),delete this._requestStorage[t]):console.debug("Unknown response",t,n)}},{key:"_processNotification",value:function(e,t){var n=this._methods[e];n&&"function"==typeof n&&n(t)}},{key:"send",value:function(e,t){return this._processRequest(e,t)}},{key:"register",value:function(e,t){if(this._handlerMap[e])throw new Error("Method ".concat(e," already registered"));this._handlerMap[e]=t}},{key:"unregister",value:function(e){if(!this._handlerMap[e])throw new Error("Method ".concat(e," not registered"));delete this._handlerMap[e]}},{key:"destroy",value:function(){this._unbindListeners(),this._sub.destroy(),this._handlerMap={},this._incomingRequestMap={},this._requestStorage={}}}])&&c(t.prototype,n),e;var t,n}();function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var h=new(function(){function e(t,n){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._encoder=t,this._decoder=n}return t=e,(n=[{key:"encode",value:function(e){return this._encoder(e)}},{key:"decode",value:function(e){return this._decoder(e)}}])&&l(t.prototype,n),e;var t,n}())(function(e){return JSON.stringify(e)},function(e){var t;try{t=JSON.parse(e.toString())}catch(e){t={}}return t}),d=function(){function e(t,n,r){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._agentId=n,this._appName=r,this._topicIn="agents/".concat(this._agentId,"/api/v1/in/").concat(this._appName),this._topicOut="agents/".concat(this._agentId,"/api/v1/out/").concat(this._appName),this._codec=h,this._mqtt=t,this._rpc=new f(this._mqtt,this._topicIn,this._topicOut,this._codec,{}),this._subMessageHandler=this._subMessageHandler.bind(this)}return t=e,(n=[{key:"createRoom",value:function(e,t){var n={time:e,audience:t};return this._rpc.send("room.create",n)}},{key:"readRoom",value:function(e){var t={id:e};return this._rpc.send("room.read",t)}},{key:"updateRoom",value:function(e,t,n){var r={id:e,time:t,audience:n};return this._rpc.send("room.update",r)}},{key:"deleteRoom",value:function(e){var t={id:e};return this._rpc.send("room.delete",t)}},{key:"enterRoom",value:function(e){var t={id:e};return this._rpc.send("room.enter",t)}},{key:"leaveRoom",value:function(e){var t={id:e};return this._rpc.send("room.leave",t)}},{key:"createRtc",value:function(e){var t={room_id:e};return this._rpc.send("rtc.create",t)}},{key:"readRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.read",t)}},{key:"listRtc",value:function(e,t){var n={room_id:e,offset:t.offset||0,limit:t.limit||25};return this._rpc.send("rtc.list",n)}},{key:"connectRtc",value:function(e){var t={id:e};return this._rpc.send("rtc.connect",t)}},{key:"createRtcSignal",value:function(e,t,n){var r={handle_id:e,jsep:t,label:n};return this._rpc.send("rtc_signal.create",r)}},{key:"listRtcStream",value:function(e,t){var n={room_id:e,rtc_id:t.rtcId,offset:t.offset||0,limit:t.limit||25,time:t.time};return this._rpc.send("rtc_stream.list",n)}},{key:"createMessage",value:function(e,t,n){var r={room_id:e,agent_id:t,data:n};return this._rpc.send("message.create",r)}},{key:"subscribeRoomEvents",value:function(e){return new u(this._mqtt,"apps/".concat(this._appName,"/api/v1/rooms/").concat(e,"/events"),this._subMessageHandler)}},{key:"register",value:function(){var e;(e=this._rpc).register.apply(e,arguments)}},{key:"unregister",value:function(){var e;(e=this._rpc).unregister.apply(e,arguments)}},{key:"_subMessageHandler",value:function(e,t,n){var r=this._codec.decode(t),i=n.properties.userProperties,o=i.label,s=null;return"event"===i.type&&void 0!==r?s={type:o,data:r}:console.debug("Unknown message",e,t),s}},{key:"destroy",value:function(){this._rpc.destroy()}}])&&p(t.prototype,n),e;var t,n}();t.default=d}]).default});

@@ -25,20 +25,11 @@ "use strict";

}, function (data) {
var envelope;
var properties;
var payload;
var result;
try {
envelope = JSON.parse(data.toString());
properties = envelope.properties;
payload = JSON.parse(envelope.payload);
result = {
properties: properties,
payload: payload
};
payload = JSON.parse(data.toString());
} catch (error) {
result = {};
payload = {};
}
return result;
return payload;
});

@@ -98,2 +89,18 @@

}, {
key: "enterRoom",
value: function enterRoom(id) {
var params = {
id: id
};
return this._rpc.send('room.enter', params);
}
}, {
key: "leaveRoom",
value: function leaveRoom(id) {
var params = {
id: id
};
return this._rpc.send('room.leave', params);
}
}, {
key: "createRtc",

@@ -170,2 +177,8 @@ value: function createRtc(roomId) {

}
/**
* @deprecated
* @param roomId
* @returns {Subscription}
*/
}, {

@@ -192,9 +205,9 @@ key: "subscribeRoomEvents",

key: "_subMessageHandler",
value: function _subMessageHandler(topic, message) {
var msg = this._codec.decode(message);
value: function _subMessageHandler(topic, message, packet) {
var payload = this._codec.decode(message);
var properties = msg.properties,
payload = msg.payload;
var label = properties.label,
type = properties.type;
var properties = packet.properties;
var _properties$userPrope = properties.userProperties,
label = _properties$userPrope.label,
type = _properties$userPrope.type;
var event = null;

@@ -208,3 +221,3 @@

} else {
console.debug('Unknown message', msg);
console.debug('Unknown message', topic, message);
}

@@ -211,0 +224,0 @@

@@ -53,8 +53,12 @@ "use strict";

key: "_subMessageHandler",
value: function _subMessageHandler(topic, message) {
var msg = this._codec.decode(message);
value: function _subMessageHandler(topic, message, packet) {
var payload = this._codec.decode(message);
var properties = packet.properties;
return {
type: 'message',
data: msg
data: {
payload: payload,
properties: properties
}
};

@@ -68,17 +72,16 @@ }

payload = message.payload;
var correlation_data = properties.correlation_data,
label = properties.label,
method = properties.method,
status = properties.status,
type = properties.type; // eslint-disable-line camelcase
var correlationData = properties.correlationData,
_properties$userPrope = properties.userProperties,
label = _properties$userPrope.label,
method = _properties$userPrope.method,
status = _properties$userPrope.status,
type = _properties$userPrope.type;
if (type === 'response' && correlation_data) {
// eslint-disable-line camelcase
if (type === 'response' && correlationData) {
if (status === '200') {
this._processResponse('resolve', correlation_data, payload);
this._processResponse('resolve', correlationData, payload);
} else {
this._processResponse('reject', correlation_data, payload);
this._processResponse('reject', correlationData, payload);
}
} else if (type === 'request' && method && correlation_data) {
// eslint-disable-line camelcase
} else if (type === 'request' && method && correlationData) {
this._processIncomingRequest(properties, payload);

@@ -94,22 +97,22 @@ } else if (type === 'event' && typeof label === 'string') {

value: function _processIncomingRequest(properties, payload) {
var correlation_data = properties.correlation_data,
method = properties.method,
response_topic = properties.response_topic; // eslint-disable-line camelcase
var correlationData = properties.correlationData,
responseTopic = properties.responseTopic,
method = properties.userProperties.method;
var handler = this._handlerMap[method];
var result = null;
if (handler && !this._incomingRequestMap[correlation_data]) {
this._incomingRequestMap[correlation_data] = true;
if (handler && !this._incomingRequestMap[correlationData]) {
this._incomingRequestMap[correlationData] = true;
result = handler(payload);
var data = {
payload: JSON.stringify(result),
properties: {
type: 'response',
var _properties = {
correlationData: correlationData,
userProperties: {
status: '200',
correlation_data: correlation_data
type: 'response'
}
};
this._mqtt.publish(response_topic, this._codec.encode(data), null);
this._mqtt.publish(responseTopic, this._codec.encode(result), {
properties: _properties
});
}

@@ -124,15 +127,15 @@ }

var properties = {
type: 'request',
method: method,
response_topic: this._topicIn,
correlation_data: id
correlationData: id,
responseTopic: this._topicIn,
userProperties: {
method: method,
type: 'request'
}
};
var data = {
properties: properties,
payload: JSON.stringify(params)
};
var payload = this._codec.encode(data);
var payload = this._codec.encode(params);
this._mqtt.publish(this._topicOut, payload, null, function (error) {
this._mqtt.publish(this._topicOut, payload, {
properties: properties
}, function (error) {
if (error) {

@@ -139,0 +142,0 @@ _this._processResponse('reject', id, error);

@@ -57,3 +57,3 @@ "use strict";

key: "_handleMessageEvent",
value: function _handleMessageEvent(topic, message) {
value: function _handleMessageEvent(topic, message, packet) {
if (topic !== this._topic) {

@@ -63,3 +63,3 @@ return;

var messageData = this._messageHandler(topic, message);
var messageData = this._messageHandler(topic, message, packet);

@@ -66,0 +66,0 @@ if (messageData !== null) {

{
"name": "@netology-group/conference",
"version": "0.3.2",
"version": "0.4.0",
"description": "JavaScript API-client for Conference service",

@@ -5,0 +5,0 @@ "files": [

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