madeline-ton
Version:
Pure JS client-side implementation of the Telegram TON blockchain protocol
839 lines (680 loc) • 30.8 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _tools = require("./tools");
var _stream = _interopRequireDefault(require("./TL/stream"));
var _leemon = require("leemon");
var _permAuthKey = _interopRequireDefault(require("./session/permAuthKey"));
var _tempAuthKey = _interopRequireDefault(require("./session/tempAuthKey"));
var _crypto = require("./crypto-sync/crypto");
var keys = [{
e: (0, _leemon.str2bigInt)("010001", 16),
fp: [1827171105, 3283364610],
n: (0, _leemon.str2bigInt)("c150023e2f70db7985ded064759cfecf0af328e69a41daf4d6f01b538135a6f91f8f8b2a0ec9ba9720ce352efcf6c5680ffc424bd634864902de0b4bd6d49f4e580230e3ae97d95c8b19442b3c0a10d8f5633fecedd6926a7f6dab0ddb7d457f9ea81b8465fcd6fffeed114011df91c059caedaf97625f6c96ecc74725556934ef781d866b34f011fce4d835a090196e9a5f0e4449af7eb697ddb9076494ca5f81104a305b6dd27665722c46b60e5df680fb16b210607ef217652e60236c255f6a28315f4083a96791d7214bf64c1df4fd0db1944fb26a2a57031b32eee64ad15a8ba68885cde74a5bfc920f6abf59ba5c75506373e7130f9042da922179251f", 16)
}, {
e: (0, _leemon.str2bigInt)("010001", 16),
fp: [2971431579, 2593745437],
n: (0, _leemon.str2bigInt)("c6aeda78b02a251db4b6441031f467fa871faed32526c436524b1fb3b5dca28efb8c089dd1b46d92c895993d87108254951c5f001a0f055f3063dcd14d431a300eb9e29517e359a1c9537e5e87ab1b116faecf5d17546ebc21db234d9d336a693efcb2b6fbcca1e7d1a0be414dca408a11609b9c4269a920b09fed1f9a1597be02761430f09e4bc48fcafbe289054c99dba51b6b5eb7d9c3a2ab4e490545b4676bd620e93804bcac93bf94f73f92c729ca899477ff17625ef14a934d51dc11d5f8650a3364586b3a52fcff2fedec8a8406cac4e751705a472e55707e3c8cd5594342b119c6c3293532d85dbe9271ed54a2fd18b4dc79c04a30951107d5639397", 16)
}, {
e: (0, _leemon.str2bigInt)("010001", 16),
fp: [1892543096, 2958764655],
n: (0, _leemon.str2bigInt)("b1066749655935f0a5936f517034c943bea7f3365a8931ae52c8bcb14856f004b83d26cf2839be0f22607470d67481771c1ce5ec31de16b20bbaa4ecd2f7d2ecf6b6356f27501c226984263edc046b89fb6d3981546b01d7bd34fedcfcc1058e2d494bda732ff813e50e1c6ae249890b225f82b22b1e55fcb063dc3c0e18e91c28d0c4aa627dec8353eee6038a95a4fd1ca984eb09f94aeb7a2220635a8ceb450ea7e61d915cdb4eecedaa083aa3801daf071855ec1fb38516cb6c2996d2d60c0ecbcfa57e4cf1fb0ed39b2f37e94ab4202ecf595e167b3ca62669a6da520859fb6d6c6203dfdfc79c75ec3ee97da8774b2da903e3435f2cd294670a75a526c1", 16)
}, {
e: (0, _leemon.str2bigInt)("010001", 16),
fp: [3344970723, 1910515126],
n: (0, _leemon.str2bigInt)("c2a8c55b4a62e2b78a19b91cf692bcdc4ba7c23fe4d06f194e2a0c30f6d9996f7d1a2bcc89bc1ac4333d44359a6c433252d1a8402d9970378b5912b75bc8cc3fa76710a025bcb9032df0b87d7607cc53b928712a174ea2a80a8176623588119d42ffce40205c6d72160860d8d80b22a8b8651907cf388effbef29cd7cf2b4eb8a872052da1351cfe7fec214ce48304ea472bd66329d60115b3420d08f6894b0410b6ab9450249967617670c932f7cbdb5d6fbcce1e492c595f483109999b2661fcdeec31b196429b7834c7211a93c6789d9ee601c18c39e521fda9d7264e61e518add6f0712d2d5228204b851e13c4f322e5c5431c3b7f31089668486aadc59f", 16)
}];
var Auther =
/*#__PURE__*/
function () {
/**
*
* @param {API} API
*/
function Auther(API) {
(0, _classCallCheck2["default"])(this, Auther);
this.API = API;
this.TL = API.getTL();
this.datacenter = API.getDatacenter();
}
(0, _createClass2["default"])(Auther, [{
key: "createAuthKey",
value: function () {
var _createAuthKey = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(expires_in, dcId) {
var crypto, x, nonce, res, chosenKey, fp, k, _k, server_nonce, pq, new_nonce, payload, dhParams, serverNewHash, newServerHash, newNewHash, tmpAesKey, tmpAesIv, answer, answerHash, innerDh, g, g_a, p, retry_id, b, g_b, clientDhParams, authKey, authKeySha, authKeyShaAux, new_nonce_hash1, key, new_nonce_hash2, new_nonce_hash3;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
crypto = this.datacenter.sockets[dcId].ctx.getCrypto();
x = 0;
case 2:
if (!(x < 5)) {
_context.next = 220;
break;
}
_context.prev = 3;
_context.next = 6;
return crypto.secureRandom(new Uint32Array(4));
case 6:
nonce = _context.sent;
_context.next = 9;
return this.API.methodCall('req_pq_multi', {
nonce: nonce
}, {
dcId: dcId
});
case 9:
res = _context.sent;
if ((0, _tools.bufferViewEqual)(nonce, res['nonce'])) {
_context.next = 12;
break;
}
throw new Error('Nonce mismatch!');
case 12:
chosenKey = void 0;
_context.t0 = _regenerator["default"].keys(res['server_public_key_fingerprints']);
case 14:
if ((_context.t1 = _context.t0()).done) {
_context.next = 29;
break;
}
k = _context.t1.value;
fp = res['server_public_key_fingerprints'][k];
_context.t2 = _regenerator["default"].keys(keys);
case 18:
if ((_context.t3 = _context.t2()).done) {
_context.next = 25;
break;
}
_k = _context.t3.value;
if (!(0, _tools.bufferViewEqual)(keys[_k]['fp'], fp)) {
_context.next = 23;
break;
}
chosenKey = keys[_k];
return _context.abrupt("break", 25);
case 23:
_context.next = 18;
break;
case 25:
if (!chosenKey) {
_context.next = 27;
break;
}
return _context.abrupt("break", 29);
case 27:
_context.next = 14;
break;
case 29:
if (chosenKey) {
_context.next = 31;
break;
}
throw new Error("Couldn't find our key in the fingerprint vector!");
case 31:
server_nonce = res['server_nonce'];
_context.next = 34;
return crypto.factorize(res['pq']);
case 34:
pq = _context.sent;
_context.next = 37;
return crypto.secureRandom(new Uint32Array(8));
case 37:
new_nonce = _context.sent;
payload = new _stream["default"](new Uint32Array(5).buffer);
payload.pos += 5;
this.TL.serialize(payload, {
_: 'p_q_inner_data' + (expires_in < 0 ? '' : '_temp'),
pq: res['pq'],
p: pq[0],
q: pq[1],
dc: dcId,
nonce: nonce,
server_nonce: server_nonce,
new_nonce: new_nonce,
expires_in: expires_in
});
payload.prepareLength(64 - payload.pos);
_context.t4 = payload.bBuf;
_context.t5 = Uint8Array;
_context.next = 46;
return crypto.sha1(payload.uBuf.slice(5, payload.pos));
case 46:
_context.t6 = _context.sent;
_context.t7 = new _context.t5(_context.t6);
_context.t4.set.call(_context.t4, _context.t7, 0);
payload = (0, _leemon.str2bigInt)((0, _tools.bytesToHex)(payload.bBuf.subarray(0, 255)), 16);
_context.t8 = _tools.hexToBytes;
_context.t9 = _leemon.bigInt2str;
_context.next = 54;
return crypto.powMod(payload, chosenKey['e'], chosenKey['n']);
case 54:
_context.t10 = _context.sent;
_context.t11 = (0, _context.t9)(_context.t10, 16);
payload = (0, _context.t8)(_context.t11);
_context.next = 59;
return this.API.methodCall('req_DH_params', {
nonce: nonce,
server_nonce: server_nonce,
p: pq[0],
q: pq[1],
public_key_fingerprint: fp,
encrypted_data: payload
}, {
dcId: dcId
});
case 59:
dhParams = _context.sent;
if ((0, _tools.bufferViewEqual)(nonce, dhParams['nonce'])) {
_context.next = 62;
break;
}
throw new Error('Nonce mismatch!');
case 62:
if ((0, _tools.bufferViewEqual)(server_nonce, dhParams['server_nonce'])) {
_context.next = 64;
break;
}
throw new Error('Server nonce mismatch!');
case 64:
if (!(dhParams['_'] === 'server_DH_params_fail')) {
_context.next = 76;
break;
}
_context.t12 = _tools.bufferViewEqual;
_context.t13 = Uint8Array;
_context.next = 69;
return crypto.sha1(new_nonce);
case 69:
_context.t14 = _context.sent;
_context.t15 = -32;
_context.t16 = new _context.t13(_context.t14, _context.t15);
_context.t17 = dhParams['new_nonce_hash'];
if ((0, _context.t12)(_context.t16, _context.t17)) {
_context.next = 75;
break;
}
throw new Error('New nonce hash mismatch!');
case 75:
return _context.abrupt("continue", 217);
case 76:
new_nonce = new Uint8Array(new_nonce.buffer);
dhParams['server_nonce'] = new Uint8Array(dhParams['server_nonce'].buffer);
_context.t18 = Uint8Array;
_context.next = 81;
return crypto.sha1((0, _tools.bufferConcat)(dhParams['server_nonce'], new_nonce));
case 81:
_context.t19 = _context.sent;
serverNewHash = new _context.t18(_context.t19);
_context.t20 = Uint8Array;
_context.next = 86;
return crypto.sha1((0, _tools.bufferConcat)(new_nonce, dhParams['server_nonce']));
case 86:
_context.t21 = _context.sent;
newServerHash = new _context.t20(_context.t21);
_context.t22 = Uint8Array;
_context.next = 91;
return crypto.sha1((0, _tools.bufferConcat)(new_nonce, new_nonce));
case 91:
_context.t23 = _context.sent;
newNewHash = new _context.t22(_context.t23);
tmpAesKey = new Uint32Array((0, _tools.bufferConcat)(newServerHash, serverNewHash.subarray(0, 12)).buffer);
tmpAesIv = new Uint32Array((0, _tools.bufferConcat)(serverNewHash.subarray(12, 20), newNewHash, new_nonce.subarray(0, 4)).buffer);
_context.t24 = _stream["default"];
_context.next = 98;
return crypto.igeDecrypt(new Uint32Array(dhParams['encrypted_answer'].buffer), tmpAesKey, tmpAesIv);
case 98:
_context.t25 = _context.sent;
answer = new _context.t24(_context.t25);
answerHash = answer.readUnsignedInts(5);
innerDh = this.TL.deserialize(answer);
_context.t26 = _tools.bufferViewEqual;
_context.t27 = answerHash;
_context.t28 = Uint32Array;
_context.next = 107;
return crypto.sha1(answer.uBuf.slice(5, answer.getPos()));
case 107:
_context.t29 = _context.sent;
_context.t30 = new _context.t28(_context.t29);
if ((0, _context.t26)(_context.t27, _context.t30)) {
_context.next = 111;
break;
}
throw new Error('Answer hash mismatch!');
case 111:
if ((0, _tools.bufferViewEqual)(nonce, innerDh['nonce'])) {
_context.next = 113;
break;
}
throw new Error('Nonce mismatch!');
case 113:
if ((0, _tools.bufferViewEqual)(server_nonce, innerDh['server_nonce'])) {
_context.next = 115;
break;
}
throw new Error('Server nonce mismatch!');
case 115:
g = (0, _leemon.str2bigInt)(innerDh['g'].toString(16), 16);
g_a = (0, _leemon.str2bigInt)((0, _tools.bytesToHex)(innerDh['g_a']), 16);
p = (0, _leemon.str2bigInt)((0, _tools.bytesToHex)(innerDh['dh_prime']), 16);
_context.next = 120;
return crypto.checkAll(p, g, g_a);
case 120:
retry_id = 0;
case 121:
if (!(retry_id < 5)) {
_context.next = 211;
break;
}
_context.t31 = _leemon.str2bigInt;
_context.t32 = _tools.bytesToHex;
_context.next = 126;
return crypto.secureRandom(new Uint8Array(256));
case 126:
_context.t33 = _context.sent;
_context.t34 = (0, _context.t32)(_context.t33);
b = (0, _context.t31)(_context.t34, 16);
_context.next = 131;
return crypto.powMod(g, b, p);
case 131:
g_b = _context.sent;
_context.next = 134;
return crypto.checkG(g_b, p);
case 134:
g_b = (0, _tools.hexToBytes)((0, _leemon.bigInt2str)(g_b, 16));
payload = new _stream["default"](new Uint32Array(5).buffer);
payload.pos += 5;
this.TL.serialize(payload, {
_: 'client_DH_inner_data',
nonce: nonce,
server_nonce: server_nonce,
retry_id: retry_id,
g_b: g_b
});
_context.t35 = payload.bBuf;
_context.t36 = Uint8Array;
_context.next = 142;
return crypto.sha1(payload.uBuf.slice(5, payload.pos));
case 142:
_context.t37 = _context.sent;
_context.t38 = new _context.t36(_context.t37);
_context.t35.set.call(_context.t35, _context.t38, 0);
payload.prepareLength((0, _tools.posMod)(-payload.getByteLength(), 16) / 4);
_context.next = 148;
return crypto.igeEncrypt(payload.uBuf, tmpAesKey, tmpAesIv);
case 148:
payload = _context.sent;
_context.next = 151;
return this.API.methodCall('set_client_DH_params', {
nonce: nonce,
server_nonce: server_nonce,
encrypted_data: new Uint8Array(payload)
}, {
dcId: dcId
});
case 151:
clientDhParams = _context.sent;
if ((0, _tools.bufferViewEqual)(nonce, clientDhParams['nonce'])) {
_context.next = 154;
break;
}
throw new Error('Nonce mismatch!');
case 154:
if ((0, _tools.bufferViewEqual)(server_nonce, clientDhParams['server_nonce'])) {
_context.next = 156;
break;
}
throw new Error('Server nonce mismatch!');
case 156:
_context.t39 = _tools.hexToBytes;
_context.t40 = _leemon.bigInt2str;
_context.next = 160;
return crypto.powMod(g_a, b, p);
case 160:
_context.t41 = _context.sent;
_context.t42 = (0, _context.t40)(_context.t41, 16);
authKey = (0, _context.t39)(_context.t42);
_context.t43 = Uint8Array;
_context.next = 166;
return crypto.sha1(authKey);
case 166:
_context.t44 = _context.sent;
authKeySha = new _context.t43(_context.t44);
authKeyShaAux = authKeySha.subarray(0, 8);
_context.t45 = clientDhParams['_'];
_context.next = _context.t45 === 'dh_gen_ok' ? 172 : _context.t45 === 'dh_gen_retry' ? 189 : _context.t45 === 'dh_gen_fail' ? 199 : 208;
break;
case 172:
_context.t46 = Uint32Array;
_context.next = 175;
return crypto.sha1((0, _tools.bufferConcat)(new_nonce, new Uint8Array([1]), authKeyShaAux));
case 175:
_context.t47 = _context.sent;
_context.t48 = -4;
new_nonce_hash1 = new _context.t46(_context.t47).subarray(_context.t48);
if ((0, _tools.bufferViewEqual)(new_nonce_hash1, clientDhParams['new_nonce_hash1'])) {
_context.next = 180;
break;
}
throw new Error('Wrong new_nonce_hash1');
case 180:
key = expires_in < 0 ? new _permAuthKey["default"]() : new _tempAuthKey["default"]();
if (expires_in >= 0) {
key.expires(Date.now() / 1000 + expires_in);
}
key.setAuthKey(authKey, new Uint32Array(authKeySha.slice(-8).buffer));
new_nonce = new_nonce.subarray(0, 8);
server_nonce = server_nonce.subarray(0, 8);
(0, _tools.xorInPlace)(new_nonce, server_nonce);
key.setServerSalt(new Uint32Array(new_nonce.slice().buffer));
console.log("Sucessfully generated auth key (expires ".concat(expires_in, ") for DC ").concat(dcId));
return _context.abrupt("return", key);
case 189:
_context.t49 = Uint32Array;
_context.next = 192;
return crypto.sha1((0, _tools.bufferConcat)(new_nonce, new Uint8Array([2]), authKeyShaAux));
case 192:
_context.t50 = _context.sent;
_context.t51 = -4;
new_nonce_hash2 = new _context.t49(_context.t50).subarray(_context.t51);
if ((0, _tools.bufferViewEqual)(new_nonce_hash2, clientDhParams['new_nonce_hash2'])) {
_context.next = 197;
break;
}
throw new Error('Wrong new_nonce_hash2');
case 197:
console.log("Retrying auth");
return _context.abrupt("break", 208);
case 199:
_context.t52 = Uint32Array;
_context.next = 202;
return crypto.sha1((0, _tools.bufferConcat)(new_nonce, new Uint8Array([3]), authKeyShaAux));
case 202:
_context.t53 = _context.sent;
_context.t54 = -4;
new_nonce_hash3 = new _context.t52(_context.t53).subarray(_context.t54);
if ((0, _tools.bufferViewEqual)(new_nonce_hash3, clientDhParams['new_nonce_hash3'])) {
_context.next = 207;
break;
}
throw new Error('Wrong new_nonce_hash3');
case 207:
throw new Error('Auth failed');
case 208:
retry_id++;
_context.next = 121;
break;
case 211:
return _context.abrupt("return");
case 214:
_context.prev = 214;
_context.t55 = _context["catch"](3);
console.error("Error while generating auth key for DC ".concat(dcId, ": ").concat(_context.t55, ", retrying (try ").concat(x + 1, " out of 5)"));
case 217:
x++;
_context.next = 2;
break;
case 220:
throw new Error("Auth failed!");
case 221:
case "end":
return _context.stop();
}
}
}, _callee, this, [[3, 214]]);
}));
function createAuthKey(_x, _x2) {
return _createAuthKey.apply(this, arguments);
}
return createAuthKey;
}()
}, {
key: "bindTempAuthKey",
value: function () {
var _bindTempAuthKey = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(expires_in, dcId) {
var connection, crypto, authInfo, x, expires_at, nonce, temp_auth_key_id, perm_auth_key_id, temp_session_id, messageId, payload, length, messageKey, pair, encrypted_message, res;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
// This is unfinished
connection = this.datacenter.sockets[dcId];
crypto = connection.ctx.getCrypto();
authInfo = this.datacenter.authInfo[dcId];
console.log(authInfo.getAuthKey(true), authInfo.getAuthKey(false));
x = 0;
case 5:
if (!(x < 5)) {
_context2.next = 58;
break;
}
//try {
console.log("Binding auth keys DC " + dcId);
expires_at = Date.now() / 1000 + expires_in;
_context2.next = 10;
return crypto.secureRandom(new Uint32Array(2));
case 10:
nonce = _context2.sent;
temp_auth_key_id = authInfo.getAuthKey(true).getID();
perm_auth_key_id = authInfo.getAuthKey(false).getID();
temp_session_id = connection.sessionId;
messageId = connection.mIdHandler.generate();
payload = new _stream["default"](new Uint32Array(8).buffer);
_context2.t0 = payload;
_context2.next = 19;
return crypto.secureRandom(new Uint32Array(4));
case 19:
_context2.t1 = _context2.sent;
_context2.t0.writeUnsignedInts.call(_context2.t0, _context2.t1);
payload.writeSignedLong(messageId);
payload.writeUnsignedInt(0);
payload.pos += 1;
this.TL.serialize(payload, {
_: 'bind_auth_key_inner',
expires_at: expires_at,
nonce: nonce,
temp_auth_key_id: temp_auth_key_id,
perm_auth_key_id: perm_auth_key_id,
temp_session_id: temp_session_id
});
length = payload.pos - 8;
payload.pos = 7;
payload.writeUnsignedInt(length);
_context2.t2 = Uint8Array;
_context2.next = 31;
return crypto.sha1(payload.uBuf);
case 31:
_context2.t3 = -16;
_context2.t4 = _context2.sent.slice(_context2.t3);
messageKey = new _context2.t2(_context2.t4);
payload = new Uint32Array((0, _crypto.pad)(payload.bBuf, 16));
_context2.next = 37;
return crypto.oldAesCalculate(messageKey, authInfo.getAuthKey(false).getAuthKey());
case 37:
pair = _context2.sent;
encrypted_message = new Uint32Array(2 + 8 + payload.length);
encrypted_message.set(perm_auth_key_id, 0);
encrypted_message.set(messageKey, 2);
_context2.t5 = encrypted_message;
_context2.next = 44;
return crypto.igeEncrypt(payload, pair[0], pair[1]);
case 44:
_context2.t6 = _context2.sent;
_context2.t5.set.call(_context2.t5, _context2.t6, 10);
encrypted_message = new Uint8Array(encrypted_message.buffer);
console.log(encrypted_message);
_context2.next = 50;
return this.API.methodCall('auth.bindTempAuthKey', {
perm_auth_key_id: perm_auth_key_id,
nonce: nonce,
expires_at: expires_at,
encrypted_message: encrypted_message
}, {
dcId: dcId,
messageId: messageId
});
case 50:
res = _context2.sent;
if (!res) {
_context2.next = 55;
break;
}
console.log("Bound auth keys");
authInfo.bind();
return _context2.abrupt("return", true);
case 55:
x++;
_context2.next = 5;
break;
case 58:
throw new Error("Binding failed!");
case 59:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function bindTempAuthKey(_x3, _x4) {
return _bindTempAuthKey.apply(this, arguments);
}
return bindTempAuthKey;
}()
}, {
key: "auth",
value: function auth() {
var _this = this;
console.log(this.datacenter);
var promises = [];
var _loop = function _loop(x) {
promises.push(_this.datacenter.connect(x, _this.API).then(function () {
return _this.authDc(x);
}));
return "break";
};
for (var x = 1; x <= 5; x++) {
var _ret = _loop(x);
if (_ret === "break") break;
}
return Promise.all(promises).then(function () {
return _this.sync();
});
}
}, {
key: "authDc",
value: function () {
var _authDc = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee3(dcId) {
var authInfo;
return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return this.datacenter.sockets[dcId].createSession();
case 2:
authInfo = this.datacenter.authInfo[dcId];
if (!(!authInfo.hasAuthKey(false) || !authInfo.hasAuthKey(true) || !authInfo.isBound())) {
_context3.next = 29;
break;
}
if (authInfo.hasAuthKey(false)) {
_context3.next = 10;
break;
}
_context3.t0 = authInfo;
_context3.next = 8;
return this.createAuthKey(-1, dcId);
case 8:
_context3.t1 = _context3.sent;
_context3.t0.setAuthKey.call(_context3.t0, _context3.t1, false);
case 10:
if (!this.API.settings['pfs']) {
_context3.next = 21;
break;
}
authInfo.setAuthKey(undefined, true); // temporary
_context3.t2 = authInfo;
_context3.next = 15;
return this.createAuthKey(this.API.settings['pfs'], dcId);
case 15:
_context3.t3 = _context3.sent;
_context3.t2.setAuthKey.call(_context3.t2, _context3.t3, true);
_context3.next = 19;
return this.bindTempAuthKey(this.API.settings['pfs'], dcId);
case 19:
_context3.next = 29;
break;
case 21:
if (authInfo.hasAuthKey(true)) {
_context3.next = 29;
break;
}
// temporary
console.log("Bound without PFS");
authInfo.bindPfs(false); // No PFS for now, also for performance reasons + we already have TLS underneath (will implement later anyway)
_context3.t4 = console;
_context3.next = 27;
return this.API.methodCall('help.getConfig', {}, {
dcId: dcId
});
case 27:
_context3.t5 = _context3.sent;
_context3.t4.log.call(_context3.t4, _context3.t5);
case 29:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));
function authDc(_x5) {
return _authDc.apply(this, arguments);
}
return authDc;
}()
}, {
key: "sync",
value: function () {
var _sync = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee4() {
return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
if (this.API.loggedIn) {
_context4.next = 2;
break;
}
return _context4.abrupt("return");
case 2:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function sync() {
return _sync.apply(this, arguments);
}
return sync;
}()
}]);
return Auther;
}();
var _default = Auther;
exports["default"] = _default;