gramjs
gramjs copied to clipboard
RPCError: 400: NEW_PASSWORD_BAD (caused by account.UpdatePasswordSettings)
I'm trying to create new 2FA (2 Factor Authentication) password via "Api.account.UpdatePasswordSettings". But I ran into this error:
Here is my code: (the client has already connected)
const result: Api.Bool = await client.invoke(
new Api.account.UpdatePasswordSettings({
password: new Api.InputCheckPasswordEmpty(),
newSettings: new Api.account.PasswordInputSettings({
newAlgo: resPass.newAlgo,
newPasswordHash: Buffer.from(password),
hint: hint,
email: recoverEmail,
newSecureSettings: new Api.SecureSecretSettings({
secureAlgo: resPass.newSecureAlgo,
secureSecret: Buffer.from(hint),
secureSecretId: BigInt(-4156887774564),
}),
}),
})
);
I also have a issue with typescript in "secureSecretId" field: Type 'bigint' is not assignable to type 'BigInteger'. The expected type comes from property 'secureSecretId' which is declared here on type '{ secureAlgo: TypeSecurePasswordKdfAlgo; secureSecret: Buffer; secureSecretId: BigInteger; }'
Any ideal?
Update:
- I have now fixed the typescript error by replace "BigInt(-4156887774564)" to "bigInt("-4156887774564")". But i still get the same error "RPCError: 400: NEW_PASSWORD_BAD" over and over again.
- Also, "resPass" is the password obj returned by Api.account.GetPassword().
there is already a helper method that does that, you should use it instead since it's a bit more complicated. https://gram.js.org/beta/classes/TelegramClient.html#updateTwoFaSettings
Wow, finally it works. I didn't know there is a helper for this. Thanks man, you made my day.