fix(core): updated for newer mtproto schema
This commit is contained in:
parent
cc8c974e23
commit
7f112f51a2
1 changed files with 12 additions and 9 deletions
|
@ -83,15 +83,17 @@ export async function doAuthorization(
|
||||||
|
|
||||||
const newNonce = randomBytes(32)
|
const newNonce = randomBytes(32)
|
||||||
|
|
||||||
|
|
||||||
const pqInnerData = BinaryWriter.serializeObject({
|
const pqInnerData = BinaryWriter.serializeObject({
|
||||||
_: 'mt_p_q_inner_data',
|
_: 'mt_p_q_inner_data_dc',
|
||||||
pq: resPq.pq,
|
pq: resPq.pq,
|
||||||
p,
|
p,
|
||||||
q,
|
q,
|
||||||
nonce,
|
nonce,
|
||||||
newNonce,
|
newNonce,
|
||||||
serverNonce: resPq.serverNonce,
|
serverNonce: resPq.serverNonce,
|
||||||
} as tl.mtproto.RawP_q_inner_data)
|
dc: connection.params.dc.id
|
||||||
|
} as tl.mtproto.RawP_q_inner_data_dc)
|
||||||
const encryptedData = await crypto.rsaEncrypt(pqInnerData, publicKey)
|
const encryptedData = await crypto.rsaEncrypt(pqInnerData, publicKey)
|
||||||
debug('%s: requesting DH params', connection.params.dc.ipAddress)
|
debug('%s: requesting DH params', connection.params.dc.ipAddress)
|
||||||
|
|
||||||
|
@ -117,13 +119,14 @@ export async function doAuthorization(
|
||||||
if (!buffersEqual(serverDhParams.serverNonce, resPq.serverNonce))
|
if (!buffersEqual(serverDhParams.serverNonce, resPq.serverNonce))
|
||||||
throw Error('Step 2: invalid server nonce from server')
|
throw Error('Step 2: invalid server nonce from server')
|
||||||
|
|
||||||
if (serverDhParams._ === 'mt_server_DH_params_fail') {
|
// type was removed from schema in July 2021
|
||||||
// why would i want to do that? we are gonna fail anyways.
|
// if (serverDhParams._ === 'mt_server_DH_params_fail') {
|
||||||
// let expectedNnh = (await crypto.sha1(newNonce)).slice(4, 20)
|
// // why would i want to do that? we are gonna fail anyways.
|
||||||
// if (!buffersEqual(serverDhParams.newNonceHash, expectedNnh))
|
// // let expectedNnh = (await crypto.sha1(newNonce)).slice(4, 20)
|
||||||
// throw new Error('Step 2: invalid DH fail nonce from server')
|
// // if (!buffersEqual(serverDhParams.newNonceHash, expectedNnh))
|
||||||
throw new Error('Step 2: server DH failed')
|
// // throw new Error('Step 2: invalid DH fail nonce from server')
|
||||||
}
|
// throw new Error('Step 2: server DH failed')
|
||||||
|
// }
|
||||||
|
|
||||||
debug('%s: server DH ok', connection.params.dc.ipAddress)
|
debug('%s: server DH ok', connection.params.dc.ipAddress)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue