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

@conectar/conectar-ws

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@conectar/conectar-ws - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

dist/wire.js

17

index.js

@@ -0,5 +1,6 @@

/* eslint-disable no-tabs */
import Wire from './lib/wire';
const globalConfigObject = {
httpHeaders: {}
httpHeaders: {},
};

@@ -19,9 +20,10 @@

export const setConfig = (config = {}) => {
Object.keys(config).forEach(option => {
Object.keys(config).forEach((option) => {
const globalOption = globalConfigObject[option];
if (!globalOption) {
console.error(
// eslint-disable-next-line
console.error(
`WIRE: Unknown option ${option}. Available options are ${Object.keys(
globalConfigObject
).join(', ')}`
globalConfigObject,
).join(', ')}`,
);

@@ -31,5 +33,6 @@ return;

if (typeof globalOption !== typeof config[option]) {
// eslint-disable-next-lines
console.error(
`WIRE: Expected ${option} to be of type ${typeof globalOption} instead` +
` found ${typeof config[option]}`
`WIRE: Expected ${option} to be of type ${typeof globalOption} instead`
+ ` found ${typeof config[option]}`,
);

@@ -36,0 +39,0 @@ return;

@@ -12,4 +12,4 @@ export default class Wire {

{
urls: 'stun:stun.l.google.com:19302'
}
urls: 'stun:stun.l.google.com:19302',
},
];

@@ -23,6 +23,3 @@ this.listeners = {};

if (
window.location.hostname === 'localhost' ||
window.location.hostname === '127.0.0.1'
) {
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
this.host = 'localhost:8081';

@@ -40,3 +37,3 @@ } else if(window.location.hostname === 'staging.conectar.ru') {

ws: 'ws:',
http: 'http:'
http: 'http:',
};

@@ -46,3 +43,3 @@ } else {

ws: 'wss:',
http: 'https:'
http: 'https:',
};

@@ -54,3 +51,3 @@ }

if (this.listeners[event]) {
this.listeners[event].forEach(listener => {
this.listeners[event].forEach((listener) => {
listener(...params);

@@ -81,5 +78,3 @@ });

this.connection = new WebSocket(
`${this.protocols.ws}//${this.host}${url}`
);
this.connection = new WebSocket(`${this.protocols.ws}//${this.host}${url}`);
this.connection.onopen = () => {

@@ -91,3 +86,4 @@ this.wait_to_reconnect = 1;

this.connection.onclose = () => {
console.error('WIRE: websocket connection closed, reconnecting...');
// eslint-disable-next-line
console.error('WIRE: websocket connection closed, reconnecting...');
setTimeout(() => {

@@ -97,3 +93,3 @@ this.connect();

};
this.connection.onmessage = event => {
this.connection.onmessage = (event) => {
const data = JSON.parse(event.data);

@@ -111,7 +107,5 @@ switch (data.action) {

delete this.peers[data.user_id];
Object.entries(this.peer_connections[data.user_id]).forEach(
([tag, pc]) => {
pc.close();
}
);
Object.entries(this.peer_connections[data.user_id]).forEach(([tag, pc]) => {
pc.close();
});
delete this.peer_connections[data.user_id];

@@ -139,3 +133,4 @@ this.run_listeners('left', this.prepare_time(data));

default:
console.error(`unknown wrtc type ${data.type}`);
// eslint-disable-next-line
console.error(`unknown wrtc type ${data.type}`);
}

@@ -154,4 +149,4 @@ break;

action,
...data
})
...data,
}),
);

@@ -163,3 +158,3 @@ }

recipient,
text
text,
});

@@ -171,3 +166,3 @@ }

payload: 'voice_call_request',
recipient
recipient,
});

@@ -179,3 +174,3 @@ }

payload: 'voice_call_accept',
recipient
recipient,
});

@@ -187,3 +182,3 @@ }

payload: 'video_call_request',
recipient
recipient,
});

@@ -195,3 +190,3 @@ }

payload: 'video_call_accept',
recipient
recipient,
});

@@ -204,3 +199,3 @@ }

whiteboard_id,
whiteboard_name
whiteboard_name,
});

@@ -213,3 +208,3 @@ }

whiteboard_id,
whiteboard_name
whiteboard_name,
});

@@ -222,3 +217,3 @@ }

whiteboard_id,
whiteboard_meta
whiteboard_meta,
});

@@ -230,3 +225,3 @@ }

action: 'update_room_meta',
meta
meta,
});

@@ -238,3 +233,3 @@ }

action: 'remove_whiteboard',
whiteboard_id
whiteboard_id,
});

@@ -248,3 +243,3 @@ }

object_id,
object
object,
});

@@ -257,3 +252,3 @@ }

whiteboard_id,
object_id
object_id,
});

@@ -266,3 +261,3 @@ }

payload: 'call_decline',
recipient
recipient,
};

@@ -275,3 +270,3 @@ this.connection.send(JSON.stringify(payload));

.fetch(`${this.protocols.http}//${this.host}/${roomId}/whiteboards/`, {
headers: this.options.httpHeaders
headers: this.options.httpHeaders,
})

@@ -285,3 +280,3 @@ .then(res => res.json());

headers: this.options.httpHeaders,
credentials: 'include'
credentials: 'include',
})

@@ -299,4 +294,4 @@ .then(res => res.json());

headers: this.options.httpHeaders,
credentials: 'include'
}
credentials: 'include',
},
)

@@ -310,3 +305,3 @@ .then(res => res.json());

headers: this.options.httpHeaders,
credentials: 'include'
credentials: 'include',
})

@@ -318,14 +313,7 @@ .then(res => res.json());

return window
.fetch(
`${this.protocols.http}//${
this.host
}/conversations/${user_id}/messages/`,
{
credentials: 'include',
headers: this.options.httpHeaders
}
)
.then(response => {
return response.json() || response;
});
.fetch(`${this.protocols.http}//${this.host}/conversations/${user_id}/messages/`, {
credentials: 'include',
headers: this.options.httpHeaders,
})
.then(response => response.json() || response);
}

@@ -337,7 +325,5 @@

credentials: 'include',
headers: this.options.httpHeaders
headers: this.options.httpHeaders,
})
.then(response => {
return response.json() || response;
});
.then(response => response.json() || response);
}

@@ -350,10 +336,10 @@

credentials: 'include',
headers: this.options.httpHeaders
headers: this.options.httpHeaders,
})
.then(response => {
return response.json() || response;
});
.then(response => response.json() || response);
}
handle_remote_offer({ sender, media, direction, payload }) {
handle_remote_offer({
sender, media, direction, payload,
}) {
const pc = this.get_peerconnection(sender, media, direction);

@@ -363,3 +349,3 @@

type: 'offer',
sdp: payload
sdp: payload,
});

@@ -376,3 +362,3 @@

direction,
payload: pc.localDescription.sdp
payload: pc.localDescription.sdp,
});

@@ -389,3 +375,3 @@ });

direction,
payload: JSON.stringify(event.candidate.toJSON())
payload: JSON.stringify(event.candidate.toJSON()),
});

@@ -395,6 +381,9 @@ }

handle_remote_candidate({ sender, media, direction, payload }) {
handle_remote_candidate({
sender, media, direction, payload,
}) {
const candidate = new RTCIceCandidate(JSON.parse(payload));
const pc = this.get_peerconnection(sender, media, direction);
pc.addIceCandidate(candidate).catch(console.error);
// eslint-disable-next-line
pc.addIceCandidate(candidate).catch(console.error);
}

@@ -413,3 +402,3 @@

direction,
payload: pc.localDescription.sdp
payload: pc.localDescription.sdp,
});

@@ -419,7 +408,9 @@ });

handle_remote_answer({ sender, media, direction, payload }) {
handle_remote_answer({
sender, media, direction, payload,
}) {
const pc = this.get_peerconnection(sender, media, direction);
const desc = new RTCSessionDescription({
type: 'answer',
sdp: payload
sdp: payload,
});

@@ -439,5 +430,4 @@ pc.setRemoteDescription(desc);

case 'failed':
console.error(
`Peer connection ${user_id} ${media}_${direction} failed`
);
// eslint-disable-next-line
console.error(`Peer connection ${user_id} ${media}_${direction} failed`);
break;

@@ -449,3 +439,3 @@ case 'disconnected':

media,
direction
direction,
});

@@ -462,6 +452,3 @@ break;

get_peerconnection(user_id, media, direction) {
if (
this.peer_connections[user_id] &&
this.peer_connections[user_id][`${media}_${direction}`]
) {
if (this.peer_connections[user_id] && this.peer_connections[user_id][`${media}_${direction}`]) {
return this.peer_connections[user_id][`${media}_${direction}`];

@@ -473,9 +460,9 @@ }

const pc = new RTCPeerConnection({
iceServers: this.iceServers
iceServers: this.iceServers,
});
this.peer_connections[user_id][`${media}_${direction}`] = pc;
pc.addEventListener('icecandidate', event => {
pc.addEventListener('icecandidate', (event) => {
this.handle_local_candidate(user_id, media, direction, event);
});
pc.addEventListener('track', event => {
pc.addEventListener('track', (event) => {
this.handle_remote_track(user_id, media, event);

@@ -486,6 +473,6 @@ });

});
pc.addEventListener('removetrack', event => {
pc.addEventListener('removetrack', (event) => {
this.handle_remove_track(user_id, media, event);
});
pc.addEventListener('iceconnectionstatechange', event => {
pc.addEventListener('iceconnectionstatechange', (event) => {
this.handle_ice_connection_state_change(user_id, media, direction, event);

@@ -534,3 +521,3 @@ });

if (!this.local_streams.mic) {
this.start_mic().then(stream => {
this.start_mic().then((stream) => {
this.add_stream(stream, 'mic', peer_id);

@@ -545,3 +532,3 @@ });

if (!this.local_streams.mic) {
this.start_mic().then(stream => {
this.start_mic().then((stream) => {
this.add_stream(stream, 'mic', peer_id);

@@ -553,3 +540,3 @@ });

if (!this.local_streams.camera) {
this.start_camera().then(stream => {
this.start_camera().then((stream) => {
this.add_stream(stream, 'camera', peer_id);

@@ -565,5 +552,5 @@ });

.getUserMedia({
video: true
video: true,
})
.then(stream => {
.then((stream) => {
this.local_streams.camera = stream;

@@ -580,5 +567,5 @@ return stream;

.getUserMedia({
audio: true
audio: true,
})
.then(stream => {
.then((stream) => {
this.local_streams.mic = stream;

@@ -595,3 +582,3 @@ return stream;

this.start_screensharing()
.then(stream => {
.then((stream) => {
this.add_stream(stream, 'screen', peer_id);

@@ -603,3 +590,3 @@ })

this.start_mic()
.then(stream => {
.then((stream) => {
this.add_stream(stream, 'mic', peer_id);

@@ -639,3 +626,3 @@ resolve();

payload: 'hang_up',
recipient
recipient,
});

@@ -658,13 +645,10 @@ this.end_mic();

direction: 'p2e',
...message
...message,
},
window.origin
window.origin,
);
};
window.addEventListener('message', event => {
if (
event.data.extension_tag === extension_tag &&
event.data.direction === 'e2p'
) {
window.addEventListener('message', (event) => {
if (event.data.extension_tag === extension_tag && event.data.direction === 'e2p') {
switch (event.data.type) {

@@ -683,7 +667,7 @@ case 'helo':

maxHeight: 1080,
chromeMediaSourceId: event.data.streamId
}
}
chromeMediaSourceId: event.data.streamId,
},
},
})
.then(stream => {
.then((stream) => {
resolve(stream);

@@ -698,3 +682,3 @@ });

send_ext({
type: 'ehlo'
type: 'ehlo',
});

@@ -706,3 +690,3 @@ setTimeout(() => {

send_ext({
type: 'chooseDesktopMedia'
type: 'chooseDesktopMedia',
});

@@ -715,6 +699,6 @@ }

video: {
mediaSource: 'screen'
}
mediaSource: 'screen',
},
})
.then(stream => {
.then((stream) => {
resolve(stream);

@@ -729,5 +713,5 @@ });

timestamp: new Date(timestamp * 1000),
...rest
...rest,
};
}
}
{
"name": "@conectar/conectar-ws",
"version": "0.0.22",
"version": "0.0.23",
"description": "Conectar WS connections",

@@ -22,9 +22,8 @@ "main": "dist/wire.js",

},
"author": "Ashinze Ekene",
"author": "Conectar LLC",
"license": "MIT",
"devDependencies": {
"babel": "^6.23.0",
"babel-core": "^6.26.3",
"babel-env": "^2.4.1",
"babel-jest": "^23.6.0",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"babel-cli": "^6.26.0",
"cypress": "^3.1.4",

@@ -34,3 +33,2 @@ "eslint": "^5.11.1",

"eslint-plugin-import": "^2.14.0",
"regenerator-runtime": "^0.13.1",
"webpack": "^4.28.3",

@@ -37,0 +35,0 @@ "webpack-cli": "^3.1.2"

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