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

conectar-middleware

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conectar-middleware - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

37

dist/conectar-middleware.cjs.development.js

@@ -259,17 +259,2 @@ 'use strict';

function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
// A type of promise-like that resolves synchronously and supports only one observer

@@ -841,19 +826,11 @@ const _Pact = /*#__PURE__*/(function() {

_proto.prepareTime = function prepareTime(_ref) {
var timestamp = _ref.timestamp,
rest = _objectWithoutPropertiesLoose(_ref, ["timestamp"]);
return _extends(_extends({}, rest), {}, {
timestamp: new Date(timestamp * 1000)
});
};
_proto.createObservableSocket = function createObservableSocket(conversationRequest) {
var _this = this;
var _ref2 = [this.config.getBaseUrl(), this.config.getApiToken()],
baseUrl = _ref2[0],
token = _ref2[1];
var protocol = 'wss'; //if (window.location.protocol !== 'http:') protocol += 's';
var _ref = [this.config.getBaseUrl(), this.config.getApiToken()],
baseUrl = _ref[0],
token = _ref[1];
var protocol = 'ws';
if (window.location.protocol !== 'http:') protocol += 's';
console.log(conversationRequest);
var formattedBaseUrl = baseUrl.split('//')[1];

@@ -873,3 +850,3 @@ console.log(conversationRequest.ConversationId);

_this.eventService.publish(message.action, _this.prepareTime(message)); // TODO: Look into the private event here
_this.eventService.publish(message.action, message); // TODO: Look into the private event here
// Found that the private event is kinda broken or maybe there's something missing

@@ -876,0 +853,0 @@ // sending a request for a call only sends the id of the call receiver, but somehow

2

dist/conectar-middleware.cjs.production.min.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("reflect-metadata");var e,t=require("inversify"),r=require("tslib"),n=(e=require("axios"))&&"object"==typeof e&&"default"in e?e.default:e,i=require("rxjs"),o={CallService:Symbol.for("ICallService"),AttachmentService:Symbol.for("IAttachmentService"),EventService:Symbol.for("IEventService"),ConversationService:Symbol.for("IConversationService"),WhiteboardService:Symbol.for("IWhiteboardService"),WebsocketService:Symbol.for("IWebsocketService"),ConfigService:Symbol.for("IConfigService"),PeerConnectionService:Symbol.for("IPeerConnectionService")},a=function(){function e(e,t,r){this.configService=e,this.websocketService=t,this.eventService=r}var t=e.prototype;return t.createConnection=function(e){return this.websocketService.createObservableSocket(e)},t.setConfig=function(e,t){this.configService.setBaseUrl(e),this.configService.setApiToken(t)},t.getConversationByUserId=function(e){try{var t=this.resolveParams(),r=t[1];return Promise.resolve(n.get(t[0]+"/users/"+e+"/conversations/",{headers:r&&{Authorization:"Bearer "+r}}))}catch(e){return Promise.reject(e)}},t.getUserConversations=function(){try{var e=this.resolveParams(),t=e[1];return Promise.resolve(n.get(e[0]+"/conversations/",{headers:t&&{Authorization:"Bearer "+t}}))}catch(e){return Promise.reject(e)}},t.getMessages=function(e,t){try{var r=this.configService,i=[r.getBaseUrl(),r.getApiToken()],o=i[1];return Promise.resolve(n.get(i[0]+"/"+e+"/messages",{headers:o&&{Authorization:"Bearer "+o},data:{conversationId:e,page:t}}))}catch(e){return Promise.reject(e)}},t.getRoomConversation=function(e){try{var t=this.resolveParams(),r=t[1];return Promise.resolve(n.get(t[0]+"/"+e+"/room",{headers:r&&{Authorization:"Bearer "+r}}))}catch(e){return Promise.reject(e)}},t.resolveParams=function(){var e=this.configService,t=[e.getBaseUrl(),e.getApiToken()];return[t[0],t[1]]},t.sendMessage=function(e){this.websocketService.send(e)},t.addEventListener=function(e,t){this.eventService.addEventListener(e,t)},e}();a=r.__decorate([t.injectable(),r.__param(0,t.inject(o.ConfigService)),r.__param(1,t.inject(o.WebsocketService)),r.__param(2,t.inject(o.EventService)),r.__metadata("design:paramtypes",[Object,Object,Object])],a);var c=function(){function e(e){this.websocketService=e}var t=e.prototype;return t.addWhiteboardMetadata=function(e,t){this.sendEvent("update_whiteboard",{id:e,name:"",meta:t,objects:[]})},t.addWhiteboardObject=function(e,t,r){this.sendEvent("add_whiteboard_object",{id:e,name:"",meta:"",objects:[{id:t,object:r}]})},t.createWhiteboard=function(e,t){this.sendEvent("new_whiteboard",{id:e,name:t,meta:"",objects:[]})},t.removeWhiteboard=function(e){this.sendEvent("remove_whiteboard",{id:e,name:"",meta:"",objects:[]})},t.removeWhiteBoardObject=function(e,t,r){this.sendEvent("remove_whiteboard_object",{id:e,name:"",meta:"",objects:[{id:t,object:r}]})},t.renameWhiteboard=function(e,t){this.sendEvent("rename_whiteboard",{id:e,name:t,meta:"",objects:[]})},t.sendEvent=function(e,t){this.websocketService.send({action:e,data:t})},e}();function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}c=r.__decorate([t.injectable(),r.__param(0,t.inject(o.WebsocketService)),r.__metadata("design:paramtypes",[Object])],c);const v=function(){function e(){}return e.prototype.then=function(t,r){const n=new e,i=this.s;if(i){const e=1&i?t:r;if(e){try{u(n,1,e(this.v))}catch(e){u(n,2,e)}return n}return this}return this.o=function(e){try{const i=e.v;1&e.s?u(n,1,t?t(i):i):r?u(n,1,r(i)):u(n,2,i)}catch(e){u(n,2,e)}},n},e}();function u(e,t,r){if(!e.s){if(r instanceof v){if(!r.s)return void(r.o=u.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(u.bind(null,e,t),u.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}function l(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d=function(){function e(e,t,r){var n=this;this.eventService=e,this.websocketService=t,this.peerConnectionService=r,this.eventService.getObservableForEvent("webrtc").subscribe({next:function(e){return n.handleWebRTCEvent(e)}}),this.peers={},this.localStreams={},this.remoteStreams={},this.peerConnections={},this.iceServers=[{urls:"turn:conectar.demo.forasoft.com?transport=tcp",username:"conectar",credential:"ZVp1NaagEN7r"},{urls:"stun:stun.l.google.com:19302"}]}var t=e.prototype;return t.startDevice=function(e){try{return Promise.resolve(this.startStream(e)).then((function(){}))}catch(e){return Promise.reject(e)}},t.endCamera=function(){var e=this.localStreams.camera;null==e||e.getTracks().forEach((function(e){return e.stop()})),delete this.localStreams.camera},t.hangUp=function(e){try{var t=this;for(var r in t.peerConnections)for(var n=0,i=["mic","camera"];n<i.length;n++)for(var o=i[n],a=0,c=["out","in"];a<c.length;a++){var s,v,u,l,d=c[a],h=null===(s=t.peerConnections)||void 0===s||null===(v=s[r])||void 0===v?void 0:v[o+"_"+d];if(!h)return Promise.resolve();h.close(),(null===(u=t.peerConnections)||void 0===u||null===(l=u[r])||void 0===l?void 0:l[o+"_"+d])&&delete t.peerConnections[r][o+"_"+d]}var f=t.stringify("private_event",{payload:"hang_up",recipient:e});return t.websocketService.send(f),t.send("private_event",{payload:"hang_up",recipient:e}),["mic","camera","screen"].forEach((function(e){var r=t.localStreams[e];null==r||r.getTracks().forEach((function(e){return e.stop()})),delete t.localStreams[e]})),Promise.resolve()}catch(e){return Promise.reject(e)}},t.makeCall=function(e,t){try{var r,n=function(r){if(!r)throw new Error("Cannot find audio stream");return i.addStream(r,"mic",e),function(){if("video"===t){var r,n=function(t){if(!t)throw new Error("Cannot find video stream");i.addStream(t,"mic",e)},o=null===(r=i.localStreams)||void 0===r?void 0:r.camera;return o?Promise.resolve(i.startStream("camera")).then(n):n(o)}}()},i=this,o=null===(r=i.localStreams)||void 0===r?void 0:r.mic;return Promise.resolve(o?Promise.resolve(i.startStream("mic")).then(n):n(o))}catch(e){return Promise.reject(e)}},t.stringify=function(e,t){return JSON.stringify(s({action:e},t))},t.send=function(e,t){try{try{this.websocketService.send(s({action:e},t))}catch(e){console.error(e)}return Promise.resolve()}catch(e){return Promise.reject(e)}},t.shareScreen=function(e){try{var t=this;return Promise.resolve(t.startStream("screen")).then((function(r){return function(){if(r){var n;try{t.addStream(r,"screen",e)}catch(e){console.log("create connection failed due to "+e)}return null===(n=t.eventService.getObservableForEvent("new_stream"))||void 0===n||n.next([e,"screen",r]),function(){if(!t.localStreams.mic)return Promise.resolve(t.startStream("mic")).then((function(r){if(!r)throw new Error("Cannot find mic stream");t.addStream(r,"mic",e)}))}()}throw new Error("Cannot find screen stream.")}()}))}catch(e){return Promise.reject(e)}},t.toggleMedia=function(e){var t,r;if(this.localStreams[e]){var n="mic"===e?"getAudioTracks":"camera"===e?"getVideoTracks":null;if(n){var i=null===(t=this.localStreams)||void 0===t||null===(r=t[e])||void 0===r?void 0:r[n]()[0];i&&(i.enabled=!i.enabled)}}},t.addStream=function(e,t,r){var n=this;if(this.localStreams[t]=e,r){var i=this.createPeerConnection(r,t,"out");e.getTracks().forEach((function(e){return i.addTrack(e)})),this.initiateOffer(i,r,t,"out")}else Object.values(this.peers).forEach((function(r){var i=n.createPeerConnection(r.userId,t,"out");e.getTracks().forEach((function(e){return i.addTrack(e)})),n.initiateOffer(i,r.userId,t,"out")}))},t.initiateOffer=function(e,t,r,n){try{var i=this,o=l((function(){return Promise.resolve(e.createOffer()).then((function(o){return Promise.resolve(e.setLocalDescription(o)).then((function(){var e=i.stringify("webrtc",{media:r,direction:n,type:"offer",recipient:t,payload:o.sdp});i.websocketService.send(e)}))}))}),(function(e){console.error(e)}));return Promise.resolve(o&&o.then?o.then((function(){})):void 0)}catch(e){return Promise.reject(e)}},t.createPeerConnection=function(e,t,r){var n;return n=new RTCPeerConnection({iceServers:this.iceServers}),console.log("create connection"),this.peerConnectionService.processEventFromPeerConnection(n,e,t,r),this.peerConnections[e]||(this.peerConnections[e]={}),this.peerConnections[e][t+"_"+r]=n,n},t.handleWebRTCEvent=function(e){try{var t,r,n;return t="offer"===e.type?this.createPeerConnection(e.sender,e.media,e.direction):null===(r=this.peerConnections)||void 0===r||null===(n=r[e.sender])||void 0===n?void 0:n[e.media+"_"+e.direction],Promise.resolve(this.peerConnectionService.processWebRTCEventFromWebsocket(e,t)).then((function(){}))}catch(e){return Promise.reject(e)}},t.startStream=function(e){try{var t=function(t){return r?t:Promise.resolve(n.localStreams[e])},r=!1,n=this,i=function(){if(!n.localStreams[e])return Promise.resolve(n.peerConnectionService.getUserMedia(e)).then((function(t){return n.localStreams[e]=t,r=!0,t}))}();return Promise.resolve(i&&i.then?i.then(t):t(i))}catch(e){return Promise.reject(e)}},e}();d=r.__decorate([t.injectable(),r.__param(0,t.inject(o.EventService)),r.__param(1,t.inject(o.WebsocketService)),r.__param(2,t.inject(o.PeerConnectionService)),r.__metadata("design:paramtypes",[Object,Object,Object])],d);var h=function(){function e(e){this.configService=e}var t=e.prototype;return t.uploadAttachment=function(e,t){try{return Promise.resolve(n.post(this.configService.getBaseUrl()+"/"+e.userId+"/attachment/"+e.roomId+"/upload",t,{headers:this.configService.getApiToken()&&{"Content-type":"multipart/form-data",Authorization:"Bearer "+this.configService.getApiToken()}}))}catch(e){return Promise.reject(e)}},t.getRoomFiles=function(e){try{return Promise.resolve(n.get(this.configService.getBaseUrl()+"/"+e+"/attachments",{headers:this.configService.getApiToken()&&{Authorization:"Bearer "+this.configService.getApiToken()}}))}catch(e){return Promise.reject(e)}},e}();h=r.__decorate([t.injectable(),r.__param(0,t.inject(o.ConfigService)),r.__metadata("design:paramtypes",[Object])],h);var f=function(){function e(e,t){this.eventService=e,this.config=t,this.connectionIsOpen=1}var t=e.prototype;return t.prepareTime=function(e){var t=e.timestamp;return s(s({},function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}(e,["timestamp"])),{},{timestamp:new Date(1e3*t)})},t.createObservableSocket=function(e){var t=this,r=[this.config.getBaseUrl(),this.config.getApiToken()],n=r[1],i=r[0].split("//")[1];console.log(e.ConversationId),this.connection=new WebSocket("wss://"+i+"/ws?UserId="+e.UserId+"&ConversationType="+e.ConversationType+"&ConversationId="+e.ConversationId+"&RequestType="+e.RequestType+"&token="+n),this.connection.onopen=function(){console.log("CONNECTED")},this.connection.onmessage=function(e){console.log({WSEvent:e});var r=JSON.parse(e.data);t.eventService.publish(r.action,t.prepareTime(r)),console.log(r.action+"_payload")},this.connection.onerror=function(){console.error("WEBSOCKET_CONNECTION_ERROR")},this.connection.onclose=function(){console.error("WEBSOCKET_CONNECTION_CLOSED")}},t.send=function(e){var t;if(console.log({connection:this.connection}),(null===(t=this.connection)||void 0===t?void 0:t.readyState)===this.connectionIsOpen)return this.connection.send(JSON.stringify(e)),"Sent to server";throw new Error("NO_CONNECTION")},e}();f=r.__decorate([t.injectable(),r.__param(0,t.inject(o.EventService)),r.__param(1,t.inject(o.ConfigService)),r.__metadata("design:paramtypes",[Object,Object])],f);var m=function(){function e(){this.allEvents=new Map}var t=e.prototype;return t.publish=function(e,t){var r;if(console.log({eventName:e}),!this.allEvents.has(e))throw new Error("EVENT_NOT_REGISTERED");null===(r=this.allEvents.get(e))||void 0===r||r.next(t)},t.getObservableForEvent=function(e){return console.log("got here"),this.allEvents.has(e)||this.allEvents.set(e,new i.Subject),this.allEvents.get(e)},t.addEventListener=function(e,t){var r;this.allEvents.has(e)||this.allEvents.set(e,new i.Subject),null===(r=this.allEvents.get(e))||void 0===r||r.subscribe(t)},e}();m=r.__decorate([t.injectable()],m);var p=function(){function e(){this.CLASSROOM_BASE_URL=this.resolveBaseURL(),this.API_TOKEN=localStorage.getItem("token")}var t=e.prototype;return t.setApiToken=function(e){this.API_TOKEN=e},t.setBaseUrl=function(e){this.CLASSROOM_BASE_URL=e},t.getApiToken=function(){return this.API_TOKEN},t.getBaseUrl=function(){return this.CLASSROOM_BASE_URL},t.resolveBaseURL=function(){return window.location.protocol+"//classroom-dev-api.herokuapp.com"},e}();p=r.__decorate([t.injectable(),r.__metadata("design:paramtypes",[])],p);var S=function(){function e(e,t){this.eventService=e,this.websocketService=t}var t=e.prototype;return t.processEventFromPeerConnection=function(e,t,r,n){var i=this;e.ontrack=function(e){i.runListeners("new_stream",t,r,e.streams[0])},e.onicecandidate=function(e){if(e.candidate){var o=i.stringify("webrtc",{media:r,direction:n,type:"candidate",recipient:t,payload:JSON.stringify(e.candidate.toJSON())});i.websocketService.send(o)}},e.oniceconnectionstatechange=function(){switch(null==e?void 0:e.iceConnectionState){case"connected":break;case"failed":console.error("Peer connection "+t+" "+r+"_"+n+" failed");break;case"closed":case"disconnected":i.runListeners("closed",{media:r,userId:t,direction:n})}}},t.processWebRTCEventFromWebsocket=function(e,t){try{var r=function(){},n=this,i=function(e,t){var r,n=-1;e:{for(var i=0;i<t.length;i++){var o=t[i][0];if(o){var a=o();if(a&&a.then)break e;if(a===e){n=i;break}}else n=i}if(-1!==n){do{for(var c=t[n][1];!c;)n++,c=t[n][1];var s=c();if(s&&s.then){r=!0;break e}var l=t[n][2];n++}while(l&&!l());return s}}const d=new v,h=u.bind(null,d,2);return(r?s.then(f):a.then((function r(a){for(;;){if(a===e){n=i;break}if(++i===t.length){if(-1!==n)break;return void u(d,1,s)}if(o=t[i][0]){if((a=o())&&a.then)return void a.then(r).then(void 0,h)}else n=i}do{for(var c=t[n][1];!c;)n++,c=t[n][1];var s=c();if(s&&s.then)return void s.then(f).then(void 0,h);var v=t[n][2];n++}while(v&&!v());u(d,1,s)}))).then(void 0,h),d;function f(e){for(;;){var r=t[n][2];if(!r||r())break;n++;for(var i=t[n][1];!i;)n++,i=t[n][1];if((e=i())&&e.then)return void e.then(f).then(void 0,h)}u(d,1,e)}}(e.type,[[function(){return"offer"},function(){var i=new RTCSessionDescription({type:"offer",sdp:e.payload}),o=l((function(){return Promise.resolve(t.setRemoteDescription(i)).then((function(){return Promise.resolve(t.createAnswer()).then((function(r){return Promise.resolve(t.setLocalDescription(r)).then((function(){var t=n.stringify("webrtc",{media:e.media,direction:e.direction,type:"answer",recipient:e.sender,payload:r.sdp});n.websocketService.send(t)}))}))}))}),(function(e){console.error(e)}));return o&&o.then?o.then(r):void 0}],[function(){return"answer"},function(){var r=new RTCSessionDescription({type:"answer",sdp:e.payload});null==t||t.setRemoteDescription(r)}],[function(){return"candidate"},function(){var r=new RTCIceCandidate(JSON.parse(e.payload));try{null==t||t.addIceCandidate(r)}catch(e){console.error(e,r)}}]]);return Promise.resolve(i&&i.then?i.then((function(){})):void 0)}catch(e){return Promise.reject(e)}},t.getUserMedia=function(e){try{var t;return Promise.resolve(navigator.mediaDevices.getUserMedia(((t={})["mic"===e?"audio":"video"]="screen"!==e||{frameRate:15},t)))}catch(e){return Promise.reject(e)}},t.runListeners=function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];null===(t=this.eventService.getObservableForEvent(e))||void 0===t||t.next.apply(t,n)},t.stringify=function(e,t){return JSON.stringify(s({action:e},t))},e}();S=r.__decorate([t.injectable(),r.__param(0,t.inject(o.EventService)),r.__param(1,t.inject(o.WebsocketService)),r.__metadata("design:paramtypes",[Object,Object])],S);var b=function(){function e(e){this.diContainer=new t.Container,"mocks"!==e&&this.configureServices()}return e.prototype.configureServices=function(){this.diContainer.bind(o.ConversationService).to(a),this.diContainer.bind(o.WhiteboardService).to(c),this.diContainer.bind(o.CallService).to(d),this.diContainer.bind(o.AttachmentService).to(h),this.diContainer.bind(o.EventService).to(m).inSingletonScope(),this.diContainer.bind(o.ConfigService).to(p).inSingletonScope(),this.diContainer.bind(o.WebsocketService).to(f).inSingletonScope(),this.diContainer.bind(o.PeerConnectionService).to(S).inSingletonScope()},e}(),g=function(){function e(e){this.messageService=e}var t=e.prototype;return t.setConfig=function(e,t){this.messageService.setConfig(e,t)},t.createConnection=function(e){return console.log(e),console.log(e.ConversationId),this.messageService.createConnection(e)},t.addEventListener=function(e,t){this.messageService.addEventListener(e,t)},t.getMessages=function(e,t){try{return Promise.resolve(this.messageService.getMessages(e,t))}catch(e){return Promise.reject(e)}},t.getConversations=function(){try{return Promise.resolve(this.messageService.getUserConversations())}catch(e){return Promise.reject(e)}},t.getConversationByUserId=function(e){try{return Promise.resolve(this.messageService.getConversationByUserId(e))}catch(e){return Promise.reject(e)}},t.sendMessage=function(e){try{return Promise.resolve(this.messageService.sendMessage(e))}catch(e){return Promise.reject(e)}},e}();g=r.__decorate([t.injectable(),r.__param(0,t.inject(o.ConversationService)),r.__metadata("design:paramtypes",[Object])],g);var C=function(){function e(e){this.whiteBoardService=e}var t=e.prototype;return t.createWhiteboard=function(e,t){return this.whiteBoardService.createWhiteboard(e,t)},t.renameWhiteboard=function(e,t){return this.whiteBoardService.renameWhiteboard(e,t)},t.addWhiteboardMetadata=function(e,t){return this.whiteBoardService.addWhiteboardMetadata(e,t)},t.removeWhiteboard=function(e){return this.whiteBoardService.removeWhiteboard(e)},t.addWhiteboardObject=function(e,t,r){return this.whiteBoardService.addWhiteboardObject(e,t,r)},t.removeWhiteBoardObject=function(e,t,r){return this.whiteBoardService.removeWhiteBoardObject(e,t,r)},e}();C=r.__decorate([t.injectable(),r.__param(0,t.inject(o.WhiteboardService)),r.__metadata("design:paramtypes",[Object])],C);var y=function(){function e(e){this.callService=e}var t=e.prototype;return t.endCamera=function(){return this.callService.endCamera()},t.hangUp=function(e){return this.callService.hangUp(e)},t.makeVideoCall=function(e){return this.callService.makeCall(e,"video")},t.makeVoiceCall=function(e){return this.callService.makeCall(e,"voice")},t.send=function(e,t){return this.callService.send(e,t)},t.sendCallDecline=function(e){return this.send("private_event",{payload:"call_decline",recipient:e})},t.sendCallEvent=function(e,t,r){this.send("private_event",{recipient:e,payload:t+"_call_"+r})},t.sendVideoCallAccept=function(e){return this.sendCallEvent(e,"video","accept")},t.sendVideoCallRequest=function(e){return this.sendCallEvent(e,"video","request")},t.sendVoiceCallAccept=function(e){return this.sendCallEvent(e,"audio","accept")},t.sendVoiceCallRequest=function(e){return this.sendCallEvent(e,"audio","request")},t.shareScreen=function(e){return this.callService.shareScreen(e)},t.startCamera=function(){return this.callService.startDevice("camera")},t.startMic=function(){return this.callService.startDevice("screen")},t.toggleMic=function(){return this.callService.toggleMedia("mic")},t.toggleVideo=function(){return this.callService.toggleMedia("camera")},e}();y=r.__decorate([t.injectable(),r.__param(0,t.inject(o.CallService)),r.__metadata("design:paramtypes",[Object])],y);var _=function(){function e(e){this.attachmentService=e}var t=e.prototype;return t.uploadAttachment=function(e,t){try{return Promise.resolve(this.attachmentService.uploadAttachment(e,t))}catch(e){return Promise.reject(e)}},t.getRoomFiles=function(e){try{return Promise.resolve(this.attachmentService.getRoomFiles(e))}catch(e){return Promise.reject(e)}},e}();_=r.__decorate([t.injectable(),r.__param(0,t.inject(o.AttachmentService)),r.__metadata("design:paramtypes",[Object])],_);var j=new function(){this.bootstrap=new b("main"),this.Attachment=this.bootstrap.diContainer.resolve(_),this.Call=this.bootstrap.diContainer.resolve(y),this.Messaging=this.bootstrap.diContainer.resolve(g),this.Whiteboard=this.bootstrap.diContainer.resolve(C)},E=j.Call,P=j.Messaging,w=j.Whiteboard;exports.Attachment=j.Attachment,exports.Call=E,exports.Messaging=P,exports.Whiteboard=w,exports.default=j;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("reflect-metadata");var e,t=require("inversify"),r=require("tslib"),n=(e=require("axios"))&&"object"==typeof e&&"default"in e?e.default:e,i=require("rxjs"),o={CallService:Symbol.for("ICallService"),AttachmentService:Symbol.for("IAttachmentService"),EventService:Symbol.for("IEventService"),ConversationService:Symbol.for("IConversationService"),WhiteboardService:Symbol.for("IWhiteboardService"),WebsocketService:Symbol.for("IWebsocketService"),ConfigService:Symbol.for("IConfigService"),PeerConnectionService:Symbol.for("IPeerConnectionService")},c=function(){function e(e,t,r){this.configService=e,this.websocketService=t,this.eventService=r}var t=e.prototype;return t.createConnection=function(e){return this.websocketService.createObservableSocket(e)},t.setConfig=function(e,t){this.configService.setBaseUrl(e),this.configService.setApiToken(t)},t.getConversationByUserId=function(e){try{var t=this.resolveParams(),r=t[1];return Promise.resolve(n.get(t[0]+"/users/"+e+"/conversations/",{headers:r&&{Authorization:"Bearer "+r}}))}catch(e){return Promise.reject(e)}},t.getUserConversations=function(){try{var e=this.resolveParams(),t=e[1];return Promise.resolve(n.get(e[0]+"/conversations/",{headers:t&&{Authorization:"Bearer "+t}}))}catch(e){return Promise.reject(e)}},t.getMessages=function(e,t){try{var r=this.configService,i=[r.getBaseUrl(),r.getApiToken()],o=i[1];return Promise.resolve(n.get(i[0]+"/"+e+"/messages",{headers:o&&{Authorization:"Bearer "+o},data:{conversationId:e,page:t}}))}catch(e){return Promise.reject(e)}},t.getRoomConversation=function(e){try{var t=this.resolveParams(),r=t[1];return Promise.resolve(n.get(t[0]+"/"+e+"/room",{headers:r&&{Authorization:"Bearer "+r}}))}catch(e){return Promise.reject(e)}},t.resolveParams=function(){var e=this.configService,t=[e.getBaseUrl(),e.getApiToken()];return[t[0],t[1]]},t.sendMessage=function(e){this.websocketService.send(e)},t.addEventListener=function(e,t){this.eventService.addEventListener(e,t)},e}();c=r.__decorate([t.injectable(),r.__param(0,t.inject(o.ConfigService)),r.__param(1,t.inject(o.WebsocketService)),r.__param(2,t.inject(o.EventService)),r.__metadata("design:paramtypes",[Object,Object,Object])],c);var a=function(){function e(e){this.websocketService=e}var t=e.prototype;return t.addWhiteboardMetadata=function(e,t){this.sendEvent("update_whiteboard",{id:e,name:"",meta:t,objects:[]})},t.addWhiteboardObject=function(e,t,r){this.sendEvent("add_whiteboard_object",{id:e,name:"",meta:"",objects:[{id:t,object:r}]})},t.createWhiteboard=function(e,t){this.sendEvent("new_whiteboard",{id:e,name:t,meta:"",objects:[]})},t.removeWhiteboard=function(e){this.sendEvent("remove_whiteboard",{id:e,name:"",meta:"",objects:[]})},t.removeWhiteBoardObject=function(e,t,r){this.sendEvent("remove_whiteboard_object",{id:e,name:"",meta:"",objects:[{id:t,object:r}]})},t.renameWhiteboard=function(e,t){this.sendEvent("rename_whiteboard",{id:e,name:t,meta:"",objects:[]})},t.sendEvent=function(e,t){this.websocketService.send({action:e,data:t})},e}();function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}a=r.__decorate([t.injectable(),r.__param(0,t.inject(o.WebsocketService)),r.__metadata("design:paramtypes",[Object])],a);const v=function(){function e(){}return e.prototype.then=function(t,r){const n=new e,i=this.s;if(i){const e=1&i?t:r;if(e){try{u(n,1,e(this.v))}catch(e){u(n,2,e)}return n}return this}return this.o=function(e){try{const i=e.v;1&e.s?u(n,1,t?t(i):i):r?u(n,1,r(i)):u(n,2,i)}catch(e){u(n,2,e)}},n},e}();function u(e,t,r){if(!e.s){if(r instanceof v){if(!r.s)return void(r.o=u.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(u.bind(null,e,t),u.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}function l(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d=function(){function e(e,t,r){var n=this;this.eventService=e,this.websocketService=t,this.peerConnectionService=r,this.eventService.getObservableForEvent("webrtc").subscribe({next:function(e){return n.handleWebRTCEvent(e)}}),this.peers={},this.localStreams={},this.remoteStreams={},this.peerConnections={},this.iceServers=[{urls:"turn:conectar.demo.forasoft.com?transport=tcp",username:"conectar",credential:"ZVp1NaagEN7r"},{urls:"stun:stun.l.google.com:19302"}]}var t=e.prototype;return t.startDevice=function(e){try{return Promise.resolve(this.startStream(e)).then((function(){}))}catch(e){return Promise.reject(e)}},t.endCamera=function(){var e=this.localStreams.camera;null==e||e.getTracks().forEach((function(e){return e.stop()})),delete this.localStreams.camera},t.hangUp=function(e){try{var t=this;for(var r in t.peerConnections)for(var n=0,i=["mic","camera"];n<i.length;n++)for(var o=i[n],c=0,a=["out","in"];c<a.length;c++){var s,v,u,l,d=a[c],h=null===(s=t.peerConnections)||void 0===s||null===(v=s[r])||void 0===v?void 0:v[o+"_"+d];if(!h)return Promise.resolve();h.close(),(null===(u=t.peerConnections)||void 0===u||null===(l=u[r])||void 0===l?void 0:l[o+"_"+d])&&delete t.peerConnections[r][o+"_"+d]}var f=t.stringify("private_event",{payload:"hang_up",recipient:e});return t.websocketService.send(f),t.send("private_event",{payload:"hang_up",recipient:e}),["mic","camera","screen"].forEach((function(e){var r=t.localStreams[e];null==r||r.getTracks().forEach((function(e){return e.stop()})),delete t.localStreams[e]})),Promise.resolve()}catch(e){return Promise.reject(e)}},t.makeCall=function(e,t){try{var r,n=function(r){if(!r)throw new Error("Cannot find audio stream");return i.addStream(r,"mic",e),function(){if("video"===t){var r,n=function(t){if(!t)throw new Error("Cannot find video stream");i.addStream(t,"mic",e)},o=null===(r=i.localStreams)||void 0===r?void 0:r.camera;return o?Promise.resolve(i.startStream("camera")).then(n):n(o)}}()},i=this,o=null===(r=i.localStreams)||void 0===r?void 0:r.mic;return Promise.resolve(o?Promise.resolve(i.startStream("mic")).then(n):n(o))}catch(e){return Promise.reject(e)}},t.stringify=function(e,t){return JSON.stringify(s({action:e},t))},t.send=function(e,t){try{try{this.websocketService.send(s({action:e},t))}catch(e){console.error(e)}return Promise.resolve()}catch(e){return Promise.reject(e)}},t.shareScreen=function(e){try{var t=this;return Promise.resolve(t.startStream("screen")).then((function(r){return function(){if(r){var n;try{t.addStream(r,"screen",e)}catch(e){console.log("create connection failed due to "+e)}return null===(n=t.eventService.getObservableForEvent("new_stream"))||void 0===n||n.next([e,"screen",r]),function(){if(!t.localStreams.mic)return Promise.resolve(t.startStream("mic")).then((function(r){if(!r)throw new Error("Cannot find mic stream");t.addStream(r,"mic",e)}))}()}throw new Error("Cannot find screen stream.")}()}))}catch(e){return Promise.reject(e)}},t.toggleMedia=function(e){var t,r;if(this.localStreams[e]){var n="mic"===e?"getAudioTracks":"camera"===e?"getVideoTracks":null;if(n){var i=null===(t=this.localStreams)||void 0===t||null===(r=t[e])||void 0===r?void 0:r[n]()[0];i&&(i.enabled=!i.enabled)}}},t.addStream=function(e,t,r){var n=this;if(this.localStreams[t]=e,r){var i=this.createPeerConnection(r,t,"out");e.getTracks().forEach((function(e){return i.addTrack(e)})),this.initiateOffer(i,r,t,"out")}else Object.values(this.peers).forEach((function(r){var i=n.createPeerConnection(r.userId,t,"out");e.getTracks().forEach((function(e){return i.addTrack(e)})),n.initiateOffer(i,r.userId,t,"out")}))},t.initiateOffer=function(e,t,r,n){try{var i=this,o=l((function(){return Promise.resolve(e.createOffer()).then((function(o){return Promise.resolve(e.setLocalDescription(o)).then((function(){var e=i.stringify("webrtc",{media:r,direction:n,type:"offer",recipient:t,payload:o.sdp});i.websocketService.send(e)}))}))}),(function(e){console.error(e)}));return Promise.resolve(o&&o.then?o.then((function(){})):void 0)}catch(e){return Promise.reject(e)}},t.createPeerConnection=function(e,t,r){var n;return n=new RTCPeerConnection({iceServers:this.iceServers}),console.log("create connection"),this.peerConnectionService.processEventFromPeerConnection(n,e,t,r),this.peerConnections[e]||(this.peerConnections[e]={}),this.peerConnections[e][t+"_"+r]=n,n},t.handleWebRTCEvent=function(e){try{var t,r,n;return t="offer"===e.type?this.createPeerConnection(e.sender,e.media,e.direction):null===(r=this.peerConnections)||void 0===r||null===(n=r[e.sender])||void 0===n?void 0:n[e.media+"_"+e.direction],Promise.resolve(this.peerConnectionService.processWebRTCEventFromWebsocket(e,t)).then((function(){}))}catch(e){return Promise.reject(e)}},t.startStream=function(e){try{var t=function(t){return r?t:Promise.resolve(n.localStreams[e])},r=!1,n=this,i=function(){if(!n.localStreams[e])return Promise.resolve(n.peerConnectionService.getUserMedia(e)).then((function(t){return n.localStreams[e]=t,r=!0,t}))}();return Promise.resolve(i&&i.then?i.then(t):t(i))}catch(e){return Promise.reject(e)}},e}();d=r.__decorate([t.injectable(),r.__param(0,t.inject(o.EventService)),r.__param(1,t.inject(o.WebsocketService)),r.__param(2,t.inject(o.PeerConnectionService)),r.__metadata("design:paramtypes",[Object,Object,Object])],d);var h=function(){function e(e){this.configService=e}var t=e.prototype;return t.uploadAttachment=function(e,t){try{return Promise.resolve(n.post(this.configService.getBaseUrl()+"/"+e.userId+"/attachment/"+e.roomId+"/upload",t,{headers:this.configService.getApiToken()&&{"Content-type":"multipart/form-data",Authorization:"Bearer "+this.configService.getApiToken()}}))}catch(e){return Promise.reject(e)}},t.getRoomFiles=function(e){try{return Promise.resolve(n.get(this.configService.getBaseUrl()+"/"+e+"/attachments",{headers:this.configService.getApiToken()&&{Authorization:"Bearer "+this.configService.getApiToken()}}))}catch(e){return Promise.reject(e)}},e}();h=r.__decorate([t.injectable(),r.__param(0,t.inject(o.ConfigService)),r.__metadata("design:paramtypes",[Object])],h);var f=function(){function e(e,t){this.eventService=e,this.config=t,this.connectionIsOpen=1}var t=e.prototype;return t.createObservableSocket=function(e){var t=this,r=[this.config.getBaseUrl(),this.config.getApiToken()],n=r[0],i=r[1],o="ws";"http:"!==window.location.protocol&&(o+="s"),console.log(e);var c=n.split("//")[1];console.log(e.ConversationId),this.connection=new WebSocket(o+"://"+c+"/ws?UserId="+e.UserId+"&ConversationType="+e.ConversationType+"&ConversationId="+e.ConversationId+"&RequestType="+e.RequestType+"&token="+i),this.connection.onopen=function(){console.log("CONNECTED")},this.connection.onmessage=function(e){console.log({WSEvent:e});var r=JSON.parse(e.data);t.eventService.publish(r.action,r),console.log(r.action+"_payload")},this.connection.onerror=function(){console.error("WEBSOCKET_CONNECTION_ERROR")},this.connection.onclose=function(){console.error("WEBSOCKET_CONNECTION_CLOSED")}},t.send=function(e){var t;if(console.log({connection:this.connection}),(null===(t=this.connection)||void 0===t?void 0:t.readyState)===this.connectionIsOpen)return this.connection.send(JSON.stringify(e)),"Sent to server";throw new Error("NO_CONNECTION")},e}();f=r.__decorate([t.injectable(),r.__param(0,t.inject(o.EventService)),r.__param(1,t.inject(o.ConfigService)),r.__metadata("design:paramtypes",[Object,Object])],f);var m=function(){function e(){this.allEvents=new Map}var t=e.prototype;return t.publish=function(e,t){var r;if(console.log({eventName:e}),!this.allEvents.has(e))throw new Error("EVENT_NOT_REGISTERED");null===(r=this.allEvents.get(e))||void 0===r||r.next(t)},t.getObservableForEvent=function(e){return console.log("got here"),this.allEvents.has(e)||this.allEvents.set(e,new i.Subject),this.allEvents.get(e)},t.addEventListener=function(e,t){var r;this.allEvents.has(e)||this.allEvents.set(e,new i.Subject),null===(r=this.allEvents.get(e))||void 0===r||r.subscribe(t)},e}();m=r.__decorate([t.injectable()],m);var p=function(){function e(){this.CLASSROOM_BASE_URL=this.resolveBaseURL(),this.API_TOKEN=localStorage.getItem("token")}var t=e.prototype;return t.setApiToken=function(e){this.API_TOKEN=e},t.setBaseUrl=function(e){this.CLASSROOM_BASE_URL=e},t.getApiToken=function(){return this.API_TOKEN},t.getBaseUrl=function(){return this.CLASSROOM_BASE_URL},t.resolveBaseURL=function(){return window.location.protocol+"//classroom-dev-api.herokuapp.com"},e}();p=r.__decorate([t.injectable(),r.__metadata("design:paramtypes",[])],p);var S=function(){function e(e,t){this.eventService=e,this.websocketService=t}var t=e.prototype;return t.processEventFromPeerConnection=function(e,t,r,n){var i=this;e.ontrack=function(e){i.runListeners("new_stream",t,r,e.streams[0])},e.onicecandidate=function(e){if(e.candidate){var o=i.stringify("webrtc",{media:r,direction:n,type:"candidate",recipient:t,payload:JSON.stringify(e.candidate.toJSON())});i.websocketService.send(o)}},e.oniceconnectionstatechange=function(){switch(null==e?void 0:e.iceConnectionState){case"connected":break;case"failed":console.error("Peer connection "+t+" "+r+"_"+n+" failed");break;case"closed":case"disconnected":i.runListeners("closed",{media:r,userId:t,direction:n})}}},t.processWebRTCEventFromWebsocket=function(e,t){try{var r=function(){},n=this,i=function(e,t){var r,n=-1;e:{for(var i=0;i<t.length;i++){var o=t[i][0];if(o){var c=o();if(c&&c.then)break e;if(c===e){n=i;break}}else n=i}if(-1!==n){do{for(var a=t[n][1];!a;)n++,a=t[n][1];var s=a();if(s&&s.then){r=!0;break e}var l=t[n][2];n++}while(l&&!l());return s}}const d=new v,h=u.bind(null,d,2);return(r?s.then(f):c.then((function r(c){for(;;){if(c===e){n=i;break}if(++i===t.length){if(-1!==n)break;return void u(d,1,s)}if(o=t[i][0]){if((c=o())&&c.then)return void c.then(r).then(void 0,h)}else n=i}do{for(var a=t[n][1];!a;)n++,a=t[n][1];var s=a();if(s&&s.then)return void s.then(f).then(void 0,h);var v=t[n][2];n++}while(v&&!v());u(d,1,s)}))).then(void 0,h),d;function f(e){for(;;){var r=t[n][2];if(!r||r())break;n++;for(var i=t[n][1];!i;)n++,i=t[n][1];if((e=i())&&e.then)return void e.then(f).then(void 0,h)}u(d,1,e)}}(e.type,[[function(){return"offer"},function(){var i=new RTCSessionDescription({type:"offer",sdp:e.payload}),o=l((function(){return Promise.resolve(t.setRemoteDescription(i)).then((function(){return Promise.resolve(t.createAnswer()).then((function(r){return Promise.resolve(t.setLocalDescription(r)).then((function(){var t=n.stringify("webrtc",{media:e.media,direction:e.direction,type:"answer",recipient:e.sender,payload:r.sdp});n.websocketService.send(t)}))}))}))}),(function(e){console.error(e)}));return o&&o.then?o.then(r):void 0}],[function(){return"answer"},function(){var r=new RTCSessionDescription({type:"answer",sdp:e.payload});null==t||t.setRemoteDescription(r)}],[function(){return"candidate"},function(){var r=new RTCIceCandidate(JSON.parse(e.payload));try{null==t||t.addIceCandidate(r)}catch(e){console.error(e,r)}}]]);return Promise.resolve(i&&i.then?i.then((function(){})):void 0)}catch(e){return Promise.reject(e)}},t.getUserMedia=function(e){try{var t;return Promise.resolve(navigator.mediaDevices.getUserMedia(((t={})["mic"===e?"audio":"video"]="screen"!==e||{frameRate:15},t)))}catch(e){return Promise.reject(e)}},t.runListeners=function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];null===(t=this.eventService.getObservableForEvent(e))||void 0===t||t.next.apply(t,n)},t.stringify=function(e,t){return JSON.stringify(s({action:e},t))},e}();S=r.__decorate([t.injectable(),r.__param(0,t.inject(o.EventService)),r.__param(1,t.inject(o.WebsocketService)),r.__metadata("design:paramtypes",[Object,Object])],S);var b=function(){function e(e){this.diContainer=new t.Container,"mocks"!==e&&this.configureServices()}return e.prototype.configureServices=function(){this.diContainer.bind(o.ConversationService).to(c),this.diContainer.bind(o.WhiteboardService).to(a),this.diContainer.bind(o.CallService).to(d),this.diContainer.bind(o.AttachmentService).to(h),this.diContainer.bind(o.EventService).to(m).inSingletonScope(),this.diContainer.bind(o.ConfigService).to(p).inSingletonScope(),this.diContainer.bind(o.WebsocketService).to(f).inSingletonScope(),this.diContainer.bind(o.PeerConnectionService).to(S).inSingletonScope()},e}(),g=function(){function e(e){this.messageService=e}var t=e.prototype;return t.setConfig=function(e,t){this.messageService.setConfig(e,t)},t.createConnection=function(e){return console.log(e),console.log(e.ConversationId),this.messageService.createConnection(e)},t.addEventListener=function(e,t){this.messageService.addEventListener(e,t)},t.getMessages=function(e,t){try{return Promise.resolve(this.messageService.getMessages(e,t))}catch(e){return Promise.reject(e)}},t.getConversations=function(){try{return Promise.resolve(this.messageService.getUserConversations())}catch(e){return Promise.reject(e)}},t.getConversationByUserId=function(e){try{return Promise.resolve(this.messageService.getConversationByUserId(e))}catch(e){return Promise.reject(e)}},t.sendMessage=function(e){try{return Promise.resolve(this.messageService.sendMessage(e))}catch(e){return Promise.reject(e)}},e}();g=r.__decorate([t.injectable(),r.__param(0,t.inject(o.ConversationService)),r.__metadata("design:paramtypes",[Object])],g);var C=function(){function e(e){this.whiteBoardService=e}var t=e.prototype;return t.createWhiteboard=function(e,t){return this.whiteBoardService.createWhiteboard(e,t)},t.renameWhiteboard=function(e,t){return this.whiteBoardService.renameWhiteboard(e,t)},t.addWhiteboardMetadata=function(e,t){return this.whiteBoardService.addWhiteboardMetadata(e,t)},t.removeWhiteboard=function(e){return this.whiteBoardService.removeWhiteboard(e)},t.addWhiteboardObject=function(e,t,r){return this.whiteBoardService.addWhiteboardObject(e,t,r)},t.removeWhiteBoardObject=function(e,t,r){return this.whiteBoardService.removeWhiteBoardObject(e,t,r)},e}();C=r.__decorate([t.injectable(),r.__param(0,t.inject(o.WhiteboardService)),r.__metadata("design:paramtypes",[Object])],C);var _=function(){function e(e){this.callService=e}var t=e.prototype;return t.endCamera=function(){return this.callService.endCamera()},t.hangUp=function(e){return this.callService.hangUp(e)},t.makeVideoCall=function(e){return this.callService.makeCall(e,"video")},t.makeVoiceCall=function(e){return this.callService.makeCall(e,"voice")},t.send=function(e,t){return this.callService.send(e,t)},t.sendCallDecline=function(e){return this.send("private_event",{payload:"call_decline",recipient:e})},t.sendCallEvent=function(e,t,r){this.send("private_event",{recipient:e,payload:t+"_call_"+r})},t.sendVideoCallAccept=function(e){return this.sendCallEvent(e,"video","accept")},t.sendVideoCallRequest=function(e){return this.sendCallEvent(e,"video","request")},t.sendVoiceCallAccept=function(e){return this.sendCallEvent(e,"audio","accept")},t.sendVoiceCallRequest=function(e){return this.sendCallEvent(e,"audio","request")},t.shareScreen=function(e){return this.callService.shareScreen(e)},t.startCamera=function(){return this.callService.startDevice("camera")},t.startMic=function(){return this.callService.startDevice("screen")},t.toggleMic=function(){return this.callService.toggleMedia("mic")},t.toggleVideo=function(){return this.callService.toggleMedia("camera")},e}();_=r.__decorate([t.injectable(),r.__param(0,t.inject(o.CallService)),r.__metadata("design:paramtypes",[Object])],_);var y=function(){function e(e){this.attachmentService=e}var t=e.prototype;return t.uploadAttachment=function(e,t){try{return Promise.resolve(this.attachmentService.uploadAttachment(e,t))}catch(e){return Promise.reject(e)}},t.getRoomFiles=function(e){try{return Promise.resolve(this.attachmentService.getRoomFiles(e))}catch(e){return Promise.reject(e)}},e}();y=r.__decorate([t.injectable(),r.__param(0,t.inject(o.AttachmentService)),r.__metadata("design:paramtypes",[Object])],y);var j=new function(){this.bootstrap=new b("main"),this.Attachment=this.bootstrap.diContainer.resolve(y),this.Call=this.bootstrap.diContainer.resolve(_),this.Messaging=this.bootstrap.diContainer.resolve(g),this.Whiteboard=this.bootstrap.diContainer.resolve(C)},E=j.Call,P=j.Messaging,w=j.Whiteboard;exports.Attachment=j.Attachment,exports.Call=E,exports.Messaging=P,exports.Whiteboard=w,exports.default=j;
//# sourceMappingURL=conectar-middleware.cjs.production.min.js.map

@@ -253,17 +253,2 @@ import 'reflect-metadata';

function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
// A type of promise-like that resolves synchronously and supports only one observer

@@ -835,19 +820,11 @@ const _Pact = /*#__PURE__*/(function() {

_proto.prepareTime = function prepareTime(_ref) {
var timestamp = _ref.timestamp,
rest = _objectWithoutPropertiesLoose(_ref, ["timestamp"]);
return _extends(_extends({}, rest), {}, {
timestamp: new Date(timestamp * 1000)
});
};
_proto.createObservableSocket = function createObservableSocket(conversationRequest) {
var _this = this;
var _ref2 = [this.config.getBaseUrl(), this.config.getApiToken()],
baseUrl = _ref2[0],
token = _ref2[1];
var protocol = 'wss'; //if (window.location.protocol !== 'http:') protocol += 's';
var _ref = [this.config.getBaseUrl(), this.config.getApiToken()],
baseUrl = _ref[0],
token = _ref[1];
var protocol = 'ws';
if (window.location.protocol !== 'http:') protocol += 's';
console.log(conversationRequest);
var formattedBaseUrl = baseUrl.split('//')[1];

@@ -867,3 +844,3 @@ console.log(conversationRequest.ConversationId);

_this.eventService.publish(message.action, _this.prepareTime(message)); // TODO: Look into the private event here
_this.eventService.publish(message.action, message); // TODO: Look into the private event here
// Found that the private event is kinda broken or maybe there's something missing

@@ -870,0 +847,0 @@ // sending a request for a call only sends the id of the call receiver, but somehow

@@ -10,5 +10,4 @@ import { IWebsocketService } from '../interfaces';

constructor(eventService: IEventService, config: IConfigService);
private prepareTime;
createObservableSocket(conversationRequest: ConversationRequest): void;
send(payload: any): string;
}
{
"version": "0.1.8",
"version": "0.1.9",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -17,15 +17,8 @@ import { inject, injectable } from 'inversify';

private prepareTime({ timestamp, ...rest }: { timestamp: number }) {
return {
...rest,
timestamp: new Date(timestamp * 1000),
};
}
createObservableSocket(conversationRequest: ConversationRequest) {
const [baseUrl, token] = [this.config.getBaseUrl(), this.config.getApiToken()];
let protocol = 'wss';
//if (window.location.protocol !== 'http:') protocol += 's';
let protocol = 'ws';
if (window.location.protocol !== 'http:') protocol += 's';
console.log(conversationRequest);
const formattedBaseUrl = baseUrl.split('//')[1];

@@ -44,3 +37,3 @@ console.log(conversationRequest.ConversationId);

const message = JSON.parse(event.data);
this.eventService.publish(message.action, this.prepareTime(message));
this.eventService.publish(message.action, message);
// TODO: Look into the private event here

@@ -47,0 +40,0 @@ // Found that the private event is kinda broken or maybe there's something missing

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