Open alirayaneh opened 3 years ago
Please attach a sample code so that I can reproduce the error
app.js==========>
` try { const mtp=new amoza(mynumber); const { srp_id, current_algo, srp_B } = await mtp.getPassword(); const { g, p, salt1, salt2 } = current_algo;
try {
const { A, M1 } = await getSRPParams({
g,
p,
salt1,
salt2,
gB: srp_B,
pass
});
try {
const authResult = await mtp.checkPassword({ srp_id, A, M1 });
if(authResult)
{
console.log("authResult:", authResult);
}
}catch (error3){
console.log({"error3":error3})
}
}
catch(error2) {
console.log({"error2":error2})
}
} catch (error1) {
console.log({"error1":error1})
}
`
class amoza.js
class amoza { constructor(dbvb) { const jstore= new jsonstorage("../mystore/"+dbvb+".json"); const mtproto = new MTProto({ api_id, api_hash ,customLocalStorage: jstore, test:false }); mtproto.updateInitConnectionParams({ app_version: '0.7.0', }); this.mtproto=mtproto; this.api = { call(method, params, options = {}) { return mtproto.call(method, params, options).catch(async error => { console.log(
${method} error:`, error);
const { error_code, error_message } = error;
if (error_code === 420) {
const seconds = +error_message.split('FLOOD_WAIT_')[1];
const ms = seconds * 1000;
await sleep(ms);
return this.call(method, params, options);
}
if (error_code === 303) {
const [type, dcId] = error_message.split('_MIGRATE_');
// If auth.sendCode call on incorrect DC need change default DC, because call auth.signIn on incorrect DC return PHONE_CODE_EXPIRED error
if (type === 'PHONE') {
await mtproto.setDefaultDc(+dcId);
} else {
options = {
...options,
dcId: +dcId,
};
}
return this.call(method, params, options);
}
return Promise.reject(error);
});
},
};
}
getUser(){
return this.api.call('users.getFullUser', {
id: {
_: 'inputUserSelf',
}
})
}
sendCode(phone) {
return this.api.call('auth.sendCode', {
phone_number: phone,
settings: {
_: 'codeSettings'
}
});
} signIn( code, phone, phone_code_hash ) {
return this.api.call('auth.signIn', {
phone_number: phone,
phone_code: code,
phone_code_hash: phone_code_hash
});
} getPassword() { return this.api.call('account.getPassword', {}); } checkPassword({ srpid, A, M1 }) { return this.api.call('auth.checkPassword', { password: { : 'inputCheckPasswordSRP', srp_id, A, M1 } }); }
}`
Have you fixed it?
hi ali when i try to use you r sample to login with password . this error happen PASSWORD_HASH_INVALID