|
|
@ -18,7 +18,7 @@ |
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigScreen, moment) { |
|
|
|
define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function(_, BigScreen, moment, sjcl) { |
|
|
|
|
|
|
|
|
|
|
|
return ["$scope", "$rootScope", "$element", "$window", "$timeout", "safeDisplayName", "safeApply", "mediaStream", "appData", "playSound", "desktopNotify", "alertify", "toastr", "translation", "fileDownload", function($scope, $rootScope, $element, $window, $timeout, safeDisplayName, safeApply, mediaStream, appData, playSound, desktopNotify, alertify, toastr, translation, fileDownload) { |
|
|
|
return ["$scope", "$rootScope", "$element", "$window", "$timeout", "safeDisplayName", "safeApply", "mediaStream", "appData", "playSound", "desktopNotify", "alertify", "toastr", "translation", "fileDownload", function($scope, $rootScope, $element, $window, $timeout, safeDisplayName, safeApply, mediaStream, appData, playSound, desktopNotify, alertify, toastr, translation, fileDownload) { |
|
|
|
|
|
|
|
|
|
|
@ -130,6 +130,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS |
|
|
|
// Default scope data.
|
|
|
|
// Default scope data.
|
|
|
|
$scope.status = "initializing"; |
|
|
|
$scope.status = "initializing"; |
|
|
|
$scope.id = null; |
|
|
|
$scope.id = null; |
|
|
|
|
|
|
|
$scope.userid = null; |
|
|
|
$scope.peer = null; |
|
|
|
$scope.peer = null; |
|
|
|
$scope.dialing = null; |
|
|
|
$scope.dialing = null; |
|
|
|
$scope.conference = null; |
|
|
|
$scope.conference = null; |
|
|
@ -153,6 +154,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS |
|
|
|
language: "" |
|
|
|
language: "" |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
$scope.withStoredLogin = false; |
|
|
|
|
|
|
|
|
|
|
|
// Data voids.
|
|
|
|
// Data voids.
|
|
|
|
var cache = {}; |
|
|
|
var cache = {}; |
|
|
@ -365,9 +367,11 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS |
|
|
|
var reloadDialog = false; |
|
|
|
var reloadDialog = false; |
|
|
|
|
|
|
|
|
|
|
|
mediaStream.api.e.on("received.self", function(event, data) { |
|
|
|
mediaStream.api.e.on("received.self", function(event, data) { |
|
|
|
|
|
|
|
|
|
|
|
$timeout.cancel(ttlTimeout); |
|
|
|
$timeout.cancel(ttlTimeout); |
|
|
|
safeApply($scope, function(scope) { |
|
|
|
safeApply($scope, function(scope) { |
|
|
|
scope.id = scope.myid = data.Id; |
|
|
|
scope.id = scope.myid = data.Id; |
|
|
|
|
|
|
|
scope.userid = data.Userid; |
|
|
|
scope.turn = data.Turn; |
|
|
|
scope.turn = data.Turn; |
|
|
|
scope.stun = data.Stun; |
|
|
|
scope.stun = data.Stun; |
|
|
|
scope.refreshWebrtcSettings(); |
|
|
|
scope.refreshWebrtcSettings(); |
|
|
@ -385,6 +389,66 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS |
|
|
|
}, 300); |
|
|
|
}, 300); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Support authentication.
|
|
|
|
|
|
|
|
if (!data.Userid && mediaStream.config.UsersEnabled) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var key = mediaStream.config.Token; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if we have something in store.
|
|
|
|
|
|
|
|
var login = localStorage.getItem("mediastream-login"); |
|
|
|
|
|
|
|
if (login) { |
|
|
|
|
|
|
|
safeApply($scope, function(scope) { |
|
|
|
|
|
|
|
scope.withStoredLogin = true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
login = sjcl.decrypt(key, login); |
|
|
|
|
|
|
|
login = JSON.parse(login) |
|
|
|
|
|
|
|
} catch(err) { |
|
|
|
|
|
|
|
console.error("Failed to parse login data", err); |
|
|
|
|
|
|
|
login = {}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log("Trying to authorize with stored credentials ..."); |
|
|
|
|
|
|
|
switch (login.v) { |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
var useridCombo = login.a; |
|
|
|
|
|
|
|
var secret = login.b; |
|
|
|
|
|
|
|
var expiry = login.t; |
|
|
|
|
|
|
|
if (useridCombo && secret) { |
|
|
|
|
|
|
|
mediaStream.users.authorize(useridCombo, secret, function(data) { |
|
|
|
|
|
|
|
console.info("Retrieved nonce - authenticating as user:", data.userid); |
|
|
|
|
|
|
|
mediaStream.api.requestAuthentication(data.userid, data.nonce); |
|
|
|
|
|
|
|
delete data.nonce; |
|
|
|
|
|
|
|
}, function(data, status) { |
|
|
|
|
|
|
|
console.error("Failed to authorize session", status, data); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
console.warn("Unknown stored credentials", login.v); |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!login && mediaStream.config.UsersAllowRegistration) { |
|
|
|
|
|
|
|
console.log("No userid - creating one ..."); |
|
|
|
|
|
|
|
mediaStream.users.register(function(data) { |
|
|
|
|
|
|
|
var login = sjcl.encrypt(key, JSON.stringify({ |
|
|
|
|
|
|
|
v: 1, |
|
|
|
|
|
|
|
t: data.timestamp || "", |
|
|
|
|
|
|
|
a: data.useridcombo, |
|
|
|
|
|
|
|
b: data.secret, |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
localStorage.setItem("mediastream-login", login); |
|
|
|
|
|
|
|
console.info("Created new userid:", data.userid); |
|
|
|
|
|
|
|
mediaStream.api.requestAuthentication(data.userid, data.nonce); |
|
|
|
|
|
|
|
delete data.nonce; |
|
|
|
|
|
|
|
}, function(data, status) { |
|
|
|
|
|
|
|
console.error("Failed to create userid", status, data); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Support to upgrade stuff when ttl was reached.
|
|
|
|
// Support to upgrade stuff when ttl was reached.
|
|
|
|
if (data.Turn.ttl) { |
|
|
|
if (data.Turn.ttl) { |
|
|
|
ttlTimeout = $timeout(function() { |
|
|
|
ttlTimeout = $timeout(function() { |
|
|
@ -519,6 +583,7 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS |
|
|
|
if (opts.soft) { |
|
|
|
if (opts.soft) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$scope.userid = null; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "error": |
|
|
|
case "error": |
|
|
|
if (reconnecting || connected) { |
|
|
|
if (reconnecting || connected) { |
|
|
@ -593,6 +658,12 @@ define(['underscore', 'bigscreen', 'moment', 'webrtc.adapter'], function(_, BigS |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$watch("userid", function(userid) { |
|
|
|
|
|
|
|
if (userid) { |
|
|
|
|
|
|
|
console.info("Session is now authenticated:", userid); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Apply all layout stuff as classes to our element.
|
|
|
|
// Apply all layout stuff as classes to our element.
|
|
|
|
$scope.$watch("layout", (function() { |
|
|
|
$scope.$watch("layout", (function() { |
|
|
|
var makeName = function(prefix, n) { |
|
|
|
var makeName = function(prefix, n) { |
|
|
|