MTPProto GramJS InputCheckPasswordSRP 类型缓冲区错误

问题描述 投票:0回答:1

救命,我求你了,我什么都不懂了,我已经为此苦苦挣扎了一个星期了。



const allPassData = await client.invoke(new Api.account.GetPassword());
const { srpId, currentAlgo, srp_B } = allPassData;
const { salt1, salt2, g, p } = currentAlgo;

const { A, M1 } = await mtproto.crypto.getSRPParams({
      g,
      p,
      salt1,
      salt2,
      gB: srp_B,
      password: cloudPass, //String cloudpass
});

const result = await client.invoke(
    new Api.channels.EditCreator({
      channel: channel,
      userId: nextUser,
      password: new Api.InputCheckPasswordSRP({
        srpId: srpId,
        a: A,
        m1: M1,
      }),
    })
);


无论我尝试什么,我都会收到此类错误


CastError: Found wrong type for A. expected buffer but received undefined.If you
 think this is a mistake please report it.
    at VirtualClass.assertType (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBo
t_deepDev\node_modules\telegram\tl\api.js:352:43)
    at VirtualClass.validate (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_
deepDev\node_modules\telegram\tl\api.js:298:30)
    at VirtualClass.getBytes (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_
deepDev\node_modules\telegram\tl\api.js:359:26)
    at argToBytes (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepDev\nod
e_modules\telegram\tl\api.js:113:22)
    at VirtualClass.getBytes (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_
deepDev\node_modules\telegram\tl\api.js:415:42)
    at new RequestState (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepD
ev\node_modules\telegram\network\RequestState.js:13:29)
    at Object.invoke (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepDev\
node_modules\telegram\client\users.js:34:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5
)
    at async giftChannelNextUser (C:\Users\user\Desktop\Шаман\ShamanBots\renamer
Bot_deepDev\start.js:221:18)
CastError: Found wrong type for M1. expected buffer but received undefined.If yo
u think this is a mistake please report it.
    at VirtualClass.assertType (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBo
t_deepDev\node_modules\telegram\tl\api.js:352:43)
    at VirtualClass.validate (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_
deepDev\node_modules\telegram\tl\api.js:298:30)
    at VirtualClass.getBytes (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_
deepDev\node_modules\telegram\tl\api.js:359:26)
    at argToBytes (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepDev\nod
e_modules\telegram\tl\api.js:113:22)
    at VirtualClass.getBytes (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_
deepDev\node_modules\telegram\tl\api.js:415:42)
    at new RequestState (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepD
ev\node_modules\telegram\network\RequestState.js:13:29)
    at Object.invoke (C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepDev\
node_modules\telegram\client\users.js:34:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5
)
    at async giftChannelNextUser (C:\Users\user\Desktop\Шаман\ShamanBots\renamer
Bot_deepDev\start.js:221:18)
C:\Users\user\Desktop\Шаман\ShamanBots\renamerBot_deepDev\node_modules\telegram\
tl\generationHelpers.js:245
            throw Error(Bytes or str expected, not ${data.constructor.name});
                                                           ^

TypeError: Cannot read properties of undefined (reading 'constructor')
`

他需要什么?我不知道我做错了什么,我头上的头发已经没有了,我抚平了猫,让他从缅因猫变成了有瘀伤的斯芬克斯猫。求求你了,帮帮忙吧

将 A 和 M1 传递给模板字符串,并将其传递给 Buffer.from()

只需将 A 和 M1 传递给 Buffer.from

javascript node.js telegram mtproto
1个回答
0
投票

您遇到的问题似乎与 Telegram 的 mtproto API 有关。当尝试调用channels.EditCreator方法时,传递给InputCheckPasswordSRP对象的A参数是未定义的,而不是预期的Buffer类型。这会导致 CastError。 检查mtproto.crypto.getSRPParams的返回值:

确保 mtproto.crypto.getSRPParams 方法确实返回包含 A 和 M1 的对象。您可以通过打印该方法的返回值来检查这一点: const params = 等待 mtproto.crypto.getSRPParams({
克,
p,
盐1,
盐2,
gB:srp_B,
密码:cloudPass,
});
控制台.log(参数); // 检查返回的对象是否包含A和M1 查看 cloudPass 变量:

确保 cloudPass 变量包含正确的密码字符串。如果密码不正确或丢失,getSRPParams 可能无法正确生成 A。

验证当前Algo对象:

确保 currentAlgo 对象包含正确的 salt1、salt2、g 和 p 属性。这些属性对于生成 A 和 M1 是必需的。

© www.soinside.com 2019 - 2024. All rights reserved.