| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 /** @constructor */ | 10 /** @constructor */ |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 /** @type {remoting.HostController} */ | 126 /** @type {remoting.HostController} */ |
| 127 var that = this; | 127 var that = this; |
| 128 | 128 |
| 129 /** @return {string} */ | 129 /** @return {string} */ |
| 130 function generateUuid() { | 130 function generateUuid() { |
| 131 var random = new Uint16Array(8); | 131 var random = new Uint16Array(8); |
| 132 window.crypto.getRandomValues(random); | 132 window.crypto.getRandomValues(random); |
| 133 /** @type {Array.<string>} */ | 133 /** @type {Array.<string>} */ |
| 134 var e = new Array(); | 134 var e = new Array(); |
| 135 for (var i = 0; i < 8; i++) { | 135 for (var i = 0; i < 8; i++) { |
| 136 e[i] = (/** @type {number} */random[i] + 0x10000). | 136 e[i] = (/** @type {number} */ (random[i]) + 0x10000). |
| 137 toString(16).substring(1); | 137 toString(16).substring(1); |
| 138 } | 138 } |
| 139 return e[0] + e[1] + '-' + e[2] + '-' + e[3] + '-' + | 139 return e[0] + e[1] + '-' + e[2] + '-' + e[3] + '-' + |
| 140 e[4] + '-' + e[5] + e[6] + e[7]; | 140 e[4] + '-' + e[5] + e[6] + e[7]; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 var newHostId = generateUuid(); | 143 var newHostId = generateUuid(); |
| 144 | 144 |
| 145 /** @param {remoting.Error} error */ | 145 /** @param {remoting.Error} error */ |
| 146 function onStartError(error) { | 146 function onStartError(error) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 162 onStartError(remoting.Error.CANCELLED); | 162 onStartError(remoting.Error.CANCELLED); |
| 163 } else { | 163 } else { |
| 164 onStartError(remoting.Error.UNEXPECTED); | 164 onStartError(remoting.Error.UNEXPECTED); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @param {string} hostName | 169 * @param {string} hostName |
| 170 * @param {string} publicKey | 170 * @param {string} publicKey |
| 171 * @param {string} privateKey | 171 * @param {string} privateKey |
| 172 * @param {string} xmppLogin | 172 * @param {?string} xmppLogin |
| 173 * @param {string} refreshToken | 173 * @param {?string} refreshToken |
| 174 * @param {string} clientBaseJid | 174 * @param {?string} clientBaseJid |
| 175 * @param {string} hostSecretHash | 175 * @param {string} hostSecretHash |
| 176 */ | 176 */ |
| 177 function startHostWithHash(hostName, publicKey, privateKey, xmppLogin, | 177 function startHostWithHash(hostName, publicKey, privateKey, xmppLogin, |
| 178 refreshToken, clientBaseJid, hostSecretHash) { | 178 refreshToken, clientBaseJid, hostSecretHash) { |
| 179 var hostConfig = { | 179 var hostConfig = { |
| 180 xmpp_login: xmppLogin, | 180 xmpp_login: xmppLogin, |
| 181 oauth_refresh_token: refreshToken, | 181 oauth_refresh_token: refreshToken, |
| 182 host_id: newHostId, | 182 host_id: newHostId, |
| 183 host_name: hostName, | 183 host_name: hostName, |
| 184 host_secret_hash: hostSecretHash, | 184 host_secret_hash: hostSecretHash, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 console.log('Failed to register the host. Status: ' + xhr.status + | 261 console.log('Failed to register the host. Status: ' + xhr.status + |
| 262 ' response: ' + xhr.responseText); | 262 ' response: ' + xhr.responseText); |
| 263 onError(remoting.Error.REGISTRATION_FAILED); | 263 onError(remoting.Error.REGISTRATION_FAILED); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * @param {string} hostName | 268 * @param {string} hostName |
| 269 * @param {string} privateKey | 269 * @param {string} privateKey |
| 270 * @param {string} publicKey | 270 * @param {string} publicKey |
| 271 * @param {string} hostClientId | 271 * @param {?string} hostClientId |
| 272 * @param {string} oauthToken | 272 * @param {string} oauthToken |
| 273 */ | 273 */ |
| 274 function doRegisterHost( | 274 function doRegisterHost( |
| 275 hostName, privateKey, publicKey, hostClientId, oauthToken) { | 275 hostName, privateKey, publicKey, hostClientId, oauthToken) { |
| 276 var headers = { | 276 var headers = { |
| 277 'Authorization': 'OAuth ' + oauthToken, | 277 'Authorization': 'OAuth ' + oauthToken, |
| 278 'Content-type' : 'application/json; charset=UTF-8' | 278 'Content-type' : 'application/json; charset=UTF-8' |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 var newHostDetails = { data: { | 281 var newHostDetails = { data: { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 * | 467 * |
| 468 * @param {function(string?):void} onDone Completion callback. | 468 * @param {function(string?):void} onDone Completion callback. |
| 469 */ | 469 */ |
| 470 remoting.HostController.prototype.getLocalHostId = function(onDone) { | 470 remoting.HostController.prototype.getLocalHostId = function(onDone) { |
| 471 /** @type {remoting.HostController} */ | 471 /** @type {remoting.HostController} */ |
| 472 var that = this; | 472 var that = this; |
| 473 /** @param {Object} config */ | 473 /** @param {Object} config */ |
| 474 function onConfig(config) { | 474 function onConfig(config) { |
| 475 var hostId = null; | 475 var hostId = null; |
| 476 if (isHostConfigValid_(config)) { | 476 if (isHostConfigValid_(config)) { |
| 477 hostId = /** @type {string} */ config['host_id']; | 477 hostId = /** @type {string} */ (config['host_id']); |
| 478 } | 478 } |
| 479 onDone(hostId); | 479 onDone(hostId); |
| 480 }; | 480 }; |
| 481 | 481 |
| 482 this.hostDaemonFacade_.getDaemonConfig(onConfig, function(error) { | 482 this.hostDaemonFacade_.getDaemonConfig(onConfig, function(error) { |
| 483 onDone(null); | 483 onDone(null); |
| 484 }); | 484 }); |
| 485 }; | 485 }; |
| 486 | 486 |
| 487 /** | 487 /** |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 function connectSignalingWithTokenAndEmail(token, email) { | 569 function connectSignalingWithTokenAndEmail(token, email) { |
| 570 signalStrategy.connect( | 570 signalStrategy.connect( |
| 571 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); | 571 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); |
| 572 } | 572 } |
| 573 | 573 |
| 574 remoting.identity.callWithToken(connectSignalingWithToken, onError); | 574 remoting.identity.callWithToken(connectSignalingWithToken, onError); |
| 575 }; | 575 }; |
| 576 | 576 |
| 577 /** @type {remoting.HostController} */ | 577 /** @type {remoting.HostController} */ |
| 578 remoting.hostController = null; | 578 remoting.hostController = null; |
| OLD | NEW |