Browse Source

Improved auth key logging, og meta tags

master
Igor Zhukov 11 years ago
parent
commit
57e00bc8ef
  1. 6
      app/index.html
  2. 35
      app/js/controllers.js
  3. 8
      app/js/lib/mtproto.js

6
app/index.html

@ -11,7 +11,7 @@
<link rel="icon" href="favicon.ico" type="image/x-icon"> <link rel="icon" href="favicon.ico" type="image/x-icon">
<meta property="og:title" content="Webogram"> <meta property="og:title" content="Webogram">
<meta property="og:url" content="http://zhukov.github.io/webogram"> <meta property="og:url" content="http://zhukov.github.io/webogram/">
<meta property="og:image" content="http://zhukov.github.io/webogram/img/Logo_2x.png"> <meta property="og:image" content="http://zhukov.github.io/webogram/img/Logo_2x.png">
<meta property="og:site_name" content="Webogram"> <meta property="og:site_name" content="Webogram">
<meta property="og:description" content="Welcome to an experimental web-client of Telegram messenger. See https://github.com/zhukov/webogram for more info."> <meta property="og:description" content="Welcome to an experimental web-client of Telegram messenger. See https://github.com/zhukov/webogram for more info.">
@ -37,12 +37,12 @@
<script type="text/javascript" src="js/lib/config.js"></script> <script type="text/javascript" src="js/lib/config.js"></script>
<script type="text/javascript" src="js/lib/mtproto.js?8"></script> <script type="text/javascript" src="js/lib/mtproto.js?9"></script>
<script type="text/javascript" src="js/util.js"></script> <script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/app.js?4"></script> <script type="text/javascript" src="js/app.js?4"></script>
<script type="text/javascript" src="js/services.js?6"></script> <script type="text/javascript" src="js/services.js?6"></script>
<script type="text/javascript" src="js/controllers.js?8"></script> <script type="text/javascript" src="js/controllers.js?9"></script>
<script type="text/javascript" src="js/filters.js?3"></script> <script type="text/javascript" src="js/filters.js?3"></script>
<script type="text/javascript" src="js/directives.js?6"></script> <script type="text/javascript" src="js/directives.js?6"></script>

35
app/js/controllers.js

@ -410,7 +410,7 @@ angular.module('myApp.controllers', [])
$scope.$on('user_update', angular.noop); $scope.$on('user_update', angular.noop);
}) })
.controller('AppImSendController', function ($scope, MtpApiManager, AppPeersManager, AppMessagesManager, ApiUpdatesManager, MtpApiFileManager) { .controller('AppImSendController', function ($scope, $timeout, MtpApiManager, AppPeersManager, AppMessagesManager, ApiUpdatesManager, MtpApiFileManager) {
$scope.$watch('curDialog.peer', resetDraft); $scope.$watch('curDialog.peer', resetDraft);
$scope.$on('user_update', angular.noop); $scope.$on('user_update', angular.noop);
@ -438,27 +438,28 @@ angular.module('myApp.controllers', [])
$scope.$watch('draftMessage.files', onFilesSelected); $scope.$watch('draftMessage.files', onFilesSelected);
function sendMessage (e) { function sendMessage (e) {
cancelEvent(e);
var text = $scope.draftMessage.text; $timeout(function () {
var text = $scope.draftMessage.text;
if (!text.length) { if (!text.length) {
return false; return false;
}
text = text.replace(/:\s*(.+?)\s*:/g, function (all, name) {
var utfChar = $.emojiarea.reverseIcons[name];
if (utfChar !== undefined) {
return utfChar;
} }
return all;
});
AppMessagesManager.sendText($scope.curDialog.peerID, text); text = text.replace(/:\s*(.+?)\s*:/g, function (all, name) {
resetDraft(); var utfChar = $.emojiarea.reverseIcons[name];
$scope.$broadcast('ui_message_send'); if (utfChar !== undefined) {
return utfChar;
}
return all;
});
AppMessagesManager.sendText($scope.curDialog.peerID, text);
resetDraft();
$scope.$broadcast('ui_message_send');
});
return false; return cancelEvent(e);
} }

8
app/js/lib/mtproto.js

@ -1099,6 +1099,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
request.storeMethod('req_pq', {nonce: auth.nonce}); request.storeMethod('req_pq', {nonce: auth.nonce});
dLog('Send req_pq', bytesToHex(auth.nonce));
mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) { mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) {
var deserializer = result.data; var deserializer = result.data;
var response = deserializer.fetchObject('ResPQ'); var response = deserializer.fetchObject('ResPQ');
@ -1115,7 +1116,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
auth.pq = response.pq; auth.pq = response.pq;
auth.fingerprints = response.server_public_key_fingerprints; auth.fingerprints = response.server_public_key_fingerprints;
// dLog('ResPQ', bytesToHex(auth.serverNonce), bytesToHex(auth.pq), auth.fingerprints); dLog('Got ResPQ', bytesToHex(auth.serverNonce), bytesToHex(auth.pq), auth.fingerprints);
auth.publicKey = MtpRsaKeysManager.select(auth.fingerprints); auth.publicKey = MtpRsaKeysManager.select(auth.fingerprints);
@ -1123,6 +1124,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
throw new Error('No public key found'); throw new Error('No public key found');
} }
dLog('PQ factorization start');
if (!!window.Worker) { if (!!window.Worker) {
var worker = new Worker('js/lib/pq_worker.js'); var worker = new Worker('js/lib/pq_worker.js');
@ -1181,6 +1183,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
encrypted_data: rsaEncrypt(auth.publicKey, dataWithHash) encrypted_data: rsaEncrypt(auth.publicKey, dataWithHash)
}); });
dLog('Send req_DH_params');
mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) { mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) {
var deserializer = result.data; var deserializer = result.data;
var response = deserializer.fetchObject('Server_DH_Params', 'RESPONSE'); var response = deserializer.fetchObject('Server_DH_Params', 'RESPONSE');
@ -1250,6 +1253,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
throw new Error('server_DH_inner_data serverNonce mismatch'); throw new Error('server_DH_inner_data serverNonce mismatch');
} }
dLog('Done decrypting answer');
auth.g = response.g; auth.g = response.g;
auth.dhPrime = response.dh_prime; auth.dhPrime = response.dh_prime;
auth.gA = response.g_a; auth.gA = response.g_a;
@ -1296,6 +1300,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
encrypted_data: encryptedData encrypted_data: encryptedData
}); });
dLog('Send set_client_DH_params');
mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) { mtpSendPlainRequest(auth.dcID, request.getBuffer()).then(function (result) {
var deserializer = result.data; var deserializer = result.data;
var response = deserializer.fetchObject('Set_client_DH_params_answer'); var response = deserializer.fetchObject('Set_client_DH_params_answer');
@ -1323,6 +1328,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
authKeyAux = authKeyHash.slice(0, 8), authKeyAux = authKeyHash.slice(0, 8),
authKeyID = authKeyHash.slice(-8); authKeyID = authKeyHash.slice(-8);
dLog('Got Set_client_DH_params_answer', response._);
switch (response._) { switch (response._) {
case 'dh_gen_ok': case 'dh_gen_ok':
var newNonceHash1 = sha1Hash(auth.newNonce.concat([1], authKeyAux)).slice(-16); var newNonceHash1 = sha1Hash(auth.newNonce.concat([1], authKeyAux)).slice(-16);

Loading…
Cancel
Save