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

@openreplay/tracker-assist

Package Overview
Dependencies
Maintainers
3
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openreplay/tracker-assist - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

cjs/ConfirmWindow.d.ts

346

cjs/index-1.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const peerjs_1 = require("peerjs");
const Mouse_1 = require("./Mouse");
const CallWindow_1 = require("./CallWindow");
const Confirm_1 = require("./Confirm");
var CallingState;
(function (CallingState) {
CallingState[CallingState["Requesting"] = 0] = "Requesting";
CallingState[CallingState["True"] = 1] = "True";
CallingState[CallingState["False"] = 2] = "False";
})(CallingState || (CallingState = {}));
;
function default_1(opts = {}) {
const options = Object.assign({
confirmText: "You have a call. Do you want to answer?",
confirmStyle: {},
}, opts);
return function (app, appOptions = {}) {
var _a;
// @ts-ignore
if (app === null || !((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) { // 93.04% browsers
return;
}
app.attachStartCallback(function () {
// @ts-ignore
const peerID = `${app.projectKey}-${app.getSessionID()}`;
const peer = new peerjs_1.default(peerID, {
// @ts-ignore
host: app.getHost(),
path: '/assist',
port: location.protocol === 'http:' && appOptions.__DISABLE_SECURE_MODE ? 80 : 443,
});
console.log('OpenReplay tracker-assist peerID:', peerID);
peer.on('connection', function (conn) {
window.addEventListener("beforeunload", () => conn.open && conn.send("unload"));
peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e));
console.log('OpenReplay tracker-assist: Connecting...');
conn.on('open', function () {
console.log('OpenReplay tracker-assist: connection opened.');
// TODO: onClose
const buffer = [];
let buffering = false;
function sendNext() {
if (buffer.length) {
setTimeout(() => {
conn.send(buffer.shift());
sendNext();
}, 50);
}
else {
buffering = false;
}
}
app.stop();
//@ts-ignore (should update tracker dependency)
app.addCommitCallback((messages) => {
let i = 0;
while (i < messages.length) {
buffer.push(messages.slice(i, i += 1000));
}
if (!buffering) {
buffering = true;
sendNext();
}
});
app.start();
});
});
let calling = CallingState.False;
peer.on('call', function (call) {
const dataConn = peer
.connections[call.peer].find(c => c.type === 'data');
if (calling !== CallingState.False || !dataConn) {
call.close();
return;
}
calling = CallingState.Requesting;
const notifyCallEnd = () => {
dataConn.open && dataConn.send("call_end");
};
const confirm = new Confirm_1.default(options.confirmText, options.confirmStyle);
dataConn.on('data', (data) => {
if (data === "call_end") {
//console.log('OpenReplay tracker-assist: receiving callend onconfirm')
calling = CallingState.False;
confirm.remove();
}
});
confirm.mount();
confirm.onAnswer(agreed => {
if (!agreed || !dataConn.open) {
call.close();
notifyCallEnd();
calling = CallingState.False;
return;
}
const mouse = new Mouse_1.default();
let callUI;
const onCallConnect = lStream => {
const onCallEnd = () => {
//console.log("on callend", call.open)
mouse.remove();
callUI === null || callUI === void 0 ? void 0 : callUI.remove();
lStream.getTracks().forEach(t => t.stop());
calling = CallingState.False;
};
const initiateCallEnd = () => {
//console.log("callend initiated")
call.close();
notifyCallEnd();
onCallEnd();
};
call.answer(lStream);
dataConn.on("close", onCallEnd);
//call.on('close', onClose); // Works from time to time (peerjs bug)
const intervalID = setInterval(() => {
if (!dataConn.open) {
initiateCallEnd();
clearInterval(intervalID);
}
if (!call.open) {
onCallEnd();
clearInterval(intervalID);
}
}, 3000);
call.on('error', initiateCallEnd);
callUI = new CallWindow_1.default(initiateCallEnd);
callUI.setLocalStream(lStream);
call.on('stream', function (rStream) {
callUI.setRemoteStream(rStream, () => navigator.mediaDevices.getUserMedia({ video: true }).then(stream => {
const videoTrack = stream.getVideoTracks()[0];
//call.peerConnection.addTrack(videoTrack);
// call.peerConnection.getSenders()
const sender = call.peerConnection.getSenders().find(function (s) {
return s.track && s.track.kind == videoTrack.kind;
});
console.log("sender", sender, "senders", call.peerConnection.getSenders());
sender === null || sender === void 0 ? void 0 : sender.replaceTrack(videoTrack);
return videoTrack;
}));
});
dataConn.on('data', (data) => {
if (data === "call_end") {
//console.log('receiving callend on call')
onCallEnd();
return;
}
if (data && typeof data.name === 'string') {
//console.log("name",data)
callUI.setAssistentName(data.name);
}
if (data && typeof data.x === 'number' && typeof data.y === 'number') {
mouse.move(data);
}
});
};
navigator.mediaDevices.getUserMedia({ audio: true })
.then(onCallConnect)
.catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e));
//_ => { // TODO retry only if specific error
//navigator.mediaDevices.getUserMedia({audio:true}) // in case there is no camera on device
//.then(onCallConnect)
//.catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e));
//});
});
});
});
};
}
exports.default = default_1;
// import Peer, { MediaConnection } from 'peerjs';
// import type { DataConnection } from 'peerjs';
// import { App, Messages } from '@openreplay/tracker/cjs';
// import type Message from '@openreplay/tracker/cjs';
// import Mouse from './Mouse';
// import CallWindow from './CallWindow';
// import Confirm from './Confirm';
// export interface Options {
// confirmText: string,
// confirmStyle: Object, // Styles object
// }
// enum CallingState {
// Requesting,
// True,
// False,
// };
// export default function(opts: Partial<Options> = {}) {
// const options: Options = Object.assign(
// {
// confirmText: "You have a call. Do you want to answer?",
// confirmStyle: {},
// },
// opts,
// );
// return function(app: App | null, appOptions: { __DISABLE_SECURE_MODE?: boolean } = {}) {
// // @ts-ignore
// if (app === null || !navigator?.mediaDevices?.getUserMedia) { // 93.04% browsers
// return;
// }
// app.attachStartCallback(function() {
// // @ts-ignore
// const peerID = `${app.projectKey}-${app.getSessionID()}`
// const peer = new Peer(peerID, {
// // @ts-ignore
// host: app.getHost(),
// path: '/assist',
// port: location.protocol === 'http:' && appOptions.__DISABLE_SECURE_MODE ? 80 : 443,
// });
// console.log('OpenReplay tracker-assist peerID:', peerID)
// peer.on('connection', function(conn) {
// window.addEventListener("beforeunload", () => conn.open && conn.send("unload"));
// peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e))
// console.log('OpenReplay tracker-assist: Connecting...')
// conn.on('open', function() {
// console.log('OpenReplay tracker-assist: connection opened.')
// // TODO: onClose
// const buffer: Message[][] = [];
// let buffering = false;
// function sendNext() {
// if (buffer.length) {
// setTimeout(() => {
// conn.send(buffer.shift());
// sendNext();
// }, 50);
// } else {
// buffering = false;
// }
// }
// app.stop();
// //@ts-ignore (should update tracker dependency)
// app.addCommitCallback((messages: Array<Message>): void => {
// let i = 0;
// while (i < messages.length) {
// buffer.push(messages.slice(i, i+=1000));
// }
// if (!buffering) {
// buffering = true;
// sendNext();
// }
// });
// app.start();
// });
// });
// let calling: CallingState = CallingState.False;
// peer.on('call', function(call) {
// const dataConn: DataConnection | undefined = peer
// .connections[call.peer].find(c => c.type === 'data');
// if (calling !== CallingState.False || !dataConn) {
// call.close();
// return;
// }
// calling = CallingState.Requesting;
// const notifyCallEnd = () => {
// dataConn.open && dataConn.send("call_end");
// }
// const confirm = new Confirm(options.confirmText, options.confirmStyle);
// dataConn.on('data', (data) => { // if call closed by a caller before confirm
// if (data === "call_end") {
// //console.log('OpenReplay tracker-assist: receiving callend onconfirm')
// calling = CallingState.False;
// confirm.remove();
// }
// });
// confirm.mount();
// confirm.onAnswer(agreed => {
// if (!agreed || !dataConn.open) {
// call.close();
// notifyCallEnd();
// calling = CallingState.False;
// return;
// }
// const mouse = new Mouse();
// let callUI;
// const onCallConnect = lStream => {
// const onCallEnd = () => {
// //console.log("on callend", call.open)
// mouse.remove();
// callUI?.remove();
// lStream.getTracks().forEach(t => t.stop());
// calling = CallingState.False;
// }
// const initiateCallEnd = () => {
// //console.log("callend initiated")
// call.close()
// notifyCallEnd();
// onCallEnd();
// }
// call.answer(lStream);
// dataConn.on("close", onCallEnd);
// //call.on('close', onClose); // Works from time to time (peerjs bug)
// const intervalID = setInterval(() => {
// if (!dataConn.open) {
// initiateCallEnd();
// clearInterval(intervalID);
// }
// if (!call.open) {
// onCallEnd();
// clearInterval(intervalID);
// }
// }, 3000);
// call.on('error', initiateCallEnd);
// callUI = new CallWindow(initiateCallEnd);
// callUI.setLocalStream(lStream);
// call.on('stream', function(rStream) {
// callUI.setRemoteStream(rStream, () =>
// navigator.mediaDevices.getUserMedia({video:true}).then(stream => {
// const videoTrack = stream.getVideoTracks()[0];
// //call.peerConnection.addTrack(videoTrack);
// // call.peerConnection.getSenders()
// const sender = call.peerConnection.getSenders().find(function(s) {
// return s.track && s.track.kind == videoTrack.kind;
// });
// console.log("sender",sender, "senders", call.peerConnection.getSenders())
// sender?.replaceTrack(videoTrack);
// return videoTrack;
// })
// );
// });
// dataConn.on('data', (data: any) => {
// if (data === "call_end") {
// //console.log('receiving callend on call')
// onCallEnd();
// return;
// }
// if (data && typeof data.name === 'string') {
// //console.log("name",data)
// callUI.setAssistentName(data.name);
// }
// if (data && typeof data.x === 'number' && typeof data.y === 'number') {
// mouse.move(data);
// }
// });
// }
// navigator.mediaDevices.getUserMedia({audio:true})
// .then(onCallConnect)
// .catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e))
// //_ => { // TODO retry only if specific error
// //navigator.mediaDevices.getUserMedia({audio:true}) // in case there is no camera on device
// //.then(onCallConnect)
// //.catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e));
// //});
// });
// });
// });
// }
// }

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

const CallWindow_1 = require("./CallWindow");
const Confirm_1 = require("./Confirm");
const ConfirmWindow_1 = require("./ConfirmWindow");
var CallingState;

@@ -26,10 +26,16 @@ (function (CallingState) {

}
let observerRestart = false;
let assistDemandedRestart = false;
let peer = null;
app.attachStopCallback(function () {
if (assistDemandedRestart) {
return;
}
peer && peer.destroy();
});
app.attachStartCallback(function () {
if (observerRestart) {
if (assistDemandedRestart) {
return;
}
// @ts-ignore
const peerID = `${app.projectKey}-${app.getSessionID()}`;
const peer = new peerjs_1.default(peerID, {
peer = new peerjs_1.default(peerID, {
// @ts-ignore

@@ -41,5 +47,5 @@ host: app.getHost(),

console.log('OpenReplay tracker-assist peerID:', peerID);
peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e));
peer.on('connection', function (conn) {
window.addEventListener("beforeunload", () => conn.open && conn.send("unload"));
peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e));
console.log('OpenReplay tracker-assist: Connecting...');

@@ -62,6 +68,9 @@ conn.on('open', function () {

}
observerRestart = true;
assistDemandedRestart = true;
app.stop();
//@ts-ignore (should update tracker dependency)
app.addCommitCallback((messages) => {
if (!conn.open) {
return;
} // TODO: clear commit callbacks on connection close
let i = 0;

@@ -76,22 +85,25 @@ while (i < messages.length) {

});
app.start().then(() => { observerRestart = false; });
app.start().then(() => { assistDemandedRestart = false; });
});
});
let calling = CallingState.False;
let callingState = CallingState.False;
peer.on('call', function (call) {
if (!peer) {
return;
}
const dataConn = peer
.connections[call.peer].find(c => c.type === 'data');
if (calling !== CallingState.False || !dataConn) {
if (callingState !== CallingState.False || !dataConn) {
call.close();
return;
}
calling = CallingState.Requesting;
const notifyCallEnd = () => {
dataConn.open && dataConn.send("call_end");
};
const confirm = new Confirm_1.default(options.confirmText, options.confirmStyle);
callingState = CallingState.Requesting;
const confirm = new ConfirmWindow_1.default(options.confirmText, options.confirmStyle);
dataConn.on('data', (data) => {
if (data === "call_end") {
//console.log('OpenReplay tracker-assist: receiving callend onconfirm')
calling = CallingState.False;
callingState = CallingState.False;
confirm.remove();

@@ -105,3 +117,3 @@ }

notifyCallEnd();
calling = CallingState.False;
callingState = CallingState.False;
return;

@@ -117,3 +129,3 @@ }

lStream.getTracks().forEach(t => t.stop());
calling = CallingState.False;
callingState = CallingState.False;
};

@@ -120,0 +132,0 @@ const initiateCallEnd = () => {

@@ -1,168 +0,177 @@

import Peer from 'peerjs';
import Mouse from './Mouse';
import CallWindow from './CallWindow';
import Confirm from './Confirm';
var CallingState;
(function (CallingState) {
CallingState[CallingState["Requesting"] = 0] = "Requesting";
CallingState[CallingState["True"] = 1] = "True";
CallingState[CallingState["False"] = 2] = "False";
})(CallingState || (CallingState = {}));
;
export default function (opts = {}) {
const options = Object.assign({
confirmText: "You have a call. Do you want to answer?",
confirmStyle: {},
}, opts);
return function (app, appOptions = {}) {
var _a;
// @ts-ignore
if (app === null || !((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) { // 93.04% browsers
return;
}
app.attachStartCallback(function () {
// @ts-ignore
const peerID = `${app.projectKey}-${app.getSessionID()}`;
const peer = new Peer(peerID, {
// @ts-ignore
host: app.getHost(),
path: '/assist',
port: location.protocol === 'http:' && appOptions.__DISABLE_SECURE_MODE ? 80 : 443,
});
console.log('OpenReplay tracker-assist peerID:', peerID);
peer.on('connection', function (conn) {
window.addEventListener("beforeunload", () => conn.open && conn.send("unload"));
peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e));
console.log('OpenReplay tracker-assist: Connecting...');
conn.on('open', function () {
console.log('OpenReplay tracker-assist: connection opened.');
// TODO: onClose
const buffer = [];
let buffering = false;
function sendNext() {
if (buffer.length) {
setTimeout(() => {
conn.send(buffer.shift());
sendNext();
}, 50);
}
else {
buffering = false;
}
}
app.stop();
//@ts-ignore (should update tracker dependency)
app.addCommitCallback((messages) => {
let i = 0;
while (i < messages.length) {
buffer.push(messages.slice(i, i += 1000));
}
if (!buffering) {
buffering = true;
sendNext();
}
});
app.start();
});
});
let calling = CallingState.False;
peer.on('call', function (call) {
const dataConn = peer
.connections[call.peer].find(c => c.type === 'data');
if (calling !== CallingState.False || !dataConn) {
call.close();
return;
}
calling = CallingState.Requesting;
const notifyCallEnd = () => {
dataConn.open && dataConn.send("call_end");
};
const confirm = new Confirm(options.confirmText, options.confirmStyle);
dataConn.on('data', (data) => {
if (data === "call_end") {
//console.log('OpenReplay tracker-assist: receiving callend onconfirm')
calling = CallingState.False;
confirm.remove();
}
});
confirm.mount();
confirm.onAnswer(agreed => {
if (!agreed || !dataConn.open) {
call.close();
notifyCallEnd();
calling = CallingState.False;
return;
}
const mouse = new Mouse();
let callUI;
const onCallConnect = lStream => {
const onCallEnd = () => {
//console.log("on callend", call.open)
mouse.remove();
callUI === null || callUI === void 0 ? void 0 : callUI.remove();
lStream.getTracks().forEach(t => t.stop());
calling = CallingState.False;
};
const initiateCallEnd = () => {
//console.log("callend initiated")
call.close();
notifyCallEnd();
onCallEnd();
};
call.answer(lStream);
dataConn.on("close", onCallEnd);
//call.on('close', onClose); // Works from time to time (peerjs bug)
const intervalID = setInterval(() => {
if (!dataConn.open) {
initiateCallEnd();
clearInterval(intervalID);
}
if (!call.open) {
onCallEnd();
clearInterval(intervalID);
}
}, 3000);
call.on('error', initiateCallEnd);
callUI = new CallWindow(initiateCallEnd);
callUI.setLocalStream(lStream);
call.on('stream', function (rStream) {
callUI.setRemoteStream(rStream, () => navigator.mediaDevices.getUserMedia({ video: true }).then(stream => {
const videoTrack = stream.getVideoTracks()[0];
//call.peerConnection.addTrack(videoTrack);
// call.peerConnection.getSenders()
const sender = call.peerConnection.getSenders().find(function (s) {
return s.track && s.track.kind == videoTrack.kind;
});
console.log("sender", sender, "senders", call.peerConnection.getSenders());
sender === null || sender === void 0 ? void 0 : sender.replaceTrack(videoTrack);
return videoTrack;
}));
});
dataConn.on('data', (data) => {
if (data === "call_end") {
//console.log('receiving callend on call')
onCallEnd();
return;
}
if (data && typeof data.name === 'string') {
//console.log("name",data)
callUI.setAssistentName(data.name);
}
if (data && typeof data.x === 'number' && typeof data.y === 'number') {
mouse.move(data);
}
});
};
navigator.mediaDevices.getUserMedia({ audio: true })
.then(onCallConnect)
.catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e));
//_ => { // TODO retry only if specific error
//navigator.mediaDevices.getUserMedia({audio:true}) // in case there is no camera on device
//.then(onCallConnect)
//.catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e));
//});
});
});
});
};
}
"use strict";
// import Peer, { MediaConnection } from 'peerjs';
// import type { DataConnection } from 'peerjs';
// import { App, Messages } from '@openreplay/tracker';
// import type Message from '@openreplay/tracker';
// import Mouse from './Mouse';
// import CallWindow from './CallWindow';
// import Confirm from './Confirm';
// export interface Options {
// confirmText: string,
// confirmStyle: Object, // Styles object
// }
// enum CallingState {
// Requesting,
// True,
// False,
// };
// export default function(opts: Partial<Options> = {}) {
// const options: Options = Object.assign(
// {
// confirmText: "You have a call. Do you want to answer?",
// confirmStyle: {},
// },
// opts,
// );
// return function(app: App | null, appOptions: { __DISABLE_SECURE_MODE?: boolean } = {}) {
// // @ts-ignore
// if (app === null || !navigator?.mediaDevices?.getUserMedia) { // 93.04% browsers
// return;
// }
// app.attachStartCallback(function() {
// // @ts-ignore
// const peerID = `${app.projectKey}-${app.getSessionID()}`
// const peer = new Peer(peerID, {
// // @ts-ignore
// host: app.getHost(),
// path: '/assist',
// port: location.protocol === 'http:' && appOptions.__DISABLE_SECURE_MODE ? 80 : 443,
// });
// console.log('OpenReplay tracker-assist peerID:', peerID)
// peer.on('connection', function(conn) {
// window.addEventListener("beforeunload", () => conn.open && conn.send("unload"));
// peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e))
// console.log('OpenReplay tracker-assist: Connecting...')
// conn.on('open', function() {
// console.log('OpenReplay tracker-assist: connection opened.')
// // TODO: onClose
// const buffer: Message[][] = [];
// let buffering = false;
// function sendNext() {
// if (buffer.length) {
// setTimeout(() => {
// conn.send(buffer.shift());
// sendNext();
// }, 50);
// } else {
// buffering = false;
// }
// }
// app.stop();
// //@ts-ignore (should update tracker dependency)
// app.addCommitCallback((messages: Array<Message>): void => {
// let i = 0;
// while (i < messages.length) {
// buffer.push(messages.slice(i, i+=1000));
// }
// if (!buffering) {
// buffering = true;
// sendNext();
// }
// });
// app.start();
// });
// });
// let calling: CallingState = CallingState.False;
// peer.on('call', function(call) {
// const dataConn: DataConnection | undefined = peer
// .connections[call.peer].find(c => c.type === 'data');
// if (calling !== CallingState.False || !dataConn) {
// call.close();
// return;
// }
// calling = CallingState.Requesting;
// const notifyCallEnd = () => {
// dataConn.open && dataConn.send("call_end");
// }
// const confirm = new Confirm(options.confirmText, options.confirmStyle);
// dataConn.on('data', (data) => { // if call closed by a caller before confirm
// if (data === "call_end") {
// //console.log('OpenReplay tracker-assist: receiving callend onconfirm')
// calling = CallingState.False;
// confirm.remove();
// }
// });
// confirm.mount();
// confirm.onAnswer(agreed => {
// if (!agreed || !dataConn.open) {
// call.close();
// notifyCallEnd();
// calling = CallingState.False;
// return;
// }
// const mouse = new Mouse();
// let callUI;
// const onCallConnect = lStream => {
// const onCallEnd = () => {
// //console.log("on callend", call.open)
// mouse.remove();
// callUI?.remove();
// lStream.getTracks().forEach(t => t.stop());
// calling = CallingState.False;
// }
// const initiateCallEnd = () => {
// //console.log("callend initiated")
// call.close()
// notifyCallEnd();
// onCallEnd();
// }
// call.answer(lStream);
// dataConn.on("close", onCallEnd);
// //call.on('close', onClose); // Works from time to time (peerjs bug)
// const intervalID = setInterval(() => {
// if (!dataConn.open) {
// initiateCallEnd();
// clearInterval(intervalID);
// }
// if (!call.open) {
// onCallEnd();
// clearInterval(intervalID);
// }
// }, 3000);
// call.on('error', initiateCallEnd);
// callUI = new CallWindow(initiateCallEnd);
// callUI.setLocalStream(lStream);
// call.on('stream', function(rStream) {
// callUI.setRemoteStream(rStream, () =>
// navigator.mediaDevices.getUserMedia({video:true}).then(stream => {
// const videoTrack = stream.getVideoTracks()[0];
// //call.peerConnection.addTrack(videoTrack);
// // call.peerConnection.getSenders()
// const sender = call.peerConnection.getSenders().find(function(s) {
// return s.track && s.track.kind == videoTrack.kind;
// });
// console.log("sender",sender, "senders", call.peerConnection.getSenders())
// sender?.replaceTrack(videoTrack);
// return videoTrack;
// })
// );
// });
// dataConn.on('data', (data: any) => {
// if (data === "call_end") {
// //console.log('receiving callend on call')
// onCallEnd();
// return;
// }
// if (data && typeof data.name === 'string') {
// //console.log("name",data)
// callUI.setAssistentName(data.name);
// }
// if (data && typeof data.x === 'number' && typeof data.y === 'number') {
// mouse.move(data);
// }
// });
// }
// navigator.mediaDevices.getUserMedia({audio:true})
// .then(onCallConnect)
// .catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e))
// //_ => { // TODO retry only if specific error
// //navigator.mediaDevices.getUserMedia({audio:true}) // in case there is no camera on device
// //.then(onCallConnect)
// //.catch(e => console.log("OpenReplay tracker-assist: cant reach media devices. ", e));
// //});
// });
// });
// });
// }
// }
import Peer from 'peerjs';
import Mouse from './Mouse';
import CallWindow from './CallWindow';
import Confirm from './Confirm';
import ConfirmWindow from './ConfirmWindow';
var CallingState;

@@ -23,10 +23,16 @@ (function (CallingState) {

}
let observerRestart = false;
let assistDemandedRestart = false;
let peer = null;
app.attachStopCallback(function () {
if (assistDemandedRestart) {
return;
}
peer && peer.destroy();
});
app.attachStartCallback(function () {
if (observerRestart) {
if (assistDemandedRestart) {
return;
}
// @ts-ignore
const peerID = `${app.projectKey}-${app.getSessionID()}`;
const peer = new Peer(peerID, {
peer = new Peer(peerID, {
// @ts-ignore

@@ -38,5 +44,5 @@ host: app.getHost(),

console.log('OpenReplay tracker-assist peerID:', peerID);
peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e));
peer.on('connection', function (conn) {
window.addEventListener("beforeunload", () => conn.open && conn.send("unload"));
peer.on('error', e => console.log("OpenReplay tracker-assist peer error: ", e.type, e));
console.log('OpenReplay tracker-assist: Connecting...');

@@ -59,6 +65,9 @@ conn.on('open', function () {

}
observerRestart = true;
assistDemandedRestart = true;
app.stop();
//@ts-ignore (should update tracker dependency)
app.addCommitCallback((messages) => {
if (!conn.open) {
return;
} // TODO: clear commit callbacks on connection close
let i = 0;

@@ -73,22 +82,25 @@ while (i < messages.length) {

});
app.start().then(() => { observerRestart = false; });
app.start().then(() => { assistDemandedRestart = false; });
});
});
let calling = CallingState.False;
let callingState = CallingState.False;
peer.on('call', function (call) {
if (!peer) {
return;
}
const dataConn = peer
.connections[call.peer].find(c => c.type === 'data');
if (calling !== CallingState.False || !dataConn) {
if (callingState !== CallingState.False || !dataConn) {
call.close();
return;
}
calling = CallingState.Requesting;
const notifyCallEnd = () => {
dataConn.open && dataConn.send("call_end");
};
const confirm = new Confirm(options.confirmText, options.confirmStyle);
callingState = CallingState.Requesting;
const confirm = new ConfirmWindow(options.confirmText, options.confirmStyle);
dataConn.on('data', (data) => {
if (data === "call_end") {
//console.log('OpenReplay tracker-assist: receiving callend onconfirm')
calling = CallingState.False;
callingState = CallingState.False;
confirm.remove();

@@ -102,3 +114,3 @@ }

notifyCallEnd();
calling = CallingState.False;
callingState = CallingState.False;
return;

@@ -114,3 +126,3 @@ }

lStream.getTracks().forEach(t => t.stop());
calling = CallingState.False;
callingState = CallingState.False;
};

@@ -117,0 +129,0 @@ const initiateCallEnd = () => {

{
"name": "@openreplay/tracker-assist",
"description": "Tracker plugin for screen assistance through the WebRTC",
"version": "3.1.0",
"version": "3.1.1",
"keywords": [

@@ -6,0 +6,0 @@ "WebRTC",

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