
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@mtproto/core
Advanced tools
Telegram API (MTProto) client library for browser
yarn add @mtproto/core -E
You need api_id and api_hash. If you do not have them yet, then get them according to the official instructions: creating your Telegram application.
const MTProto = require('@mtproto/core');
// 1. Create an instance
const mtproto = new MTProto({
api_id: YOU_API_ID,
api_hash: YOU_API_HASH,
// Use test server
test: true,
});
// 2. Log in using phone number
// https://core.telegram.org/api/auth#test-phone-numbers
const phone = '+9996621111';
const code = '22222';
mtproto
.call('auth.sendCode', {
phone_number: phone,
settings: {
_: 'codeSettings',
},
})
.then(result => {
mtproto
.call('auth.signIn', {
phone_code: code,
phone_number: phone,
phone_code_hash: result.phone_code_hash,
})
.then(result => {
console.log(`auth.signIn[result]:`, result);
})
.catch(error => {
if (error.error_message === 'SESSION_PASSWORD_NEEDED') {
// Need use 2FA
}
});
});
const { getSRPParams } = require('@mtproto/core/utils');
const password = 'YOU_PASSWORD';
mtproto
.call('account.getPassword')
.then(async result => {
const { srp_id, current_algo, srp_B } = result;
const { salt1, salt2, g, p } = current_algo;
const { A, M1 } = await getSRPParams({
g,
p,
salt1,
salt2,
gB: srp_B,
password,
});
return mtproto.call('auth.checkPassword', {
password: {
_: 'inputCheckPasswordSRP',
srp_id,
A,
M1,
},
});
})
.then(result => {
console.log(`auth.checkPassword[result]:`, result);
});
FAQs
Telegram API JS (MTProto) client library for Node.js and browser
The npm package @mtproto/core receives a total of 919 weekly downloads. As such, @mtproto/core popularity was classified as not popular.
We found that @mtproto/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.