
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Actual Telegram bot API JS implementation
npm install --save tgapi
yarn add tgapi
In order to send requests to API, we need to create the Bot
instance.
The Bot
is an object that contains all bot API methods.
Each bot API method returns a promise, on successful execution of which the
result will be the response object of the API server
described in the documentation.
In this example, we call getMe and sendPhoto methods:
const { Bot } = require('tgapi')
const fs = require('fs')
const bot = new Bot('<your bot token>')
bot
.getMe()
.then(console.log)
// { ok: true,
// result: {
// id: 12345,
// is_bot: true,
// first_name: "My awesome bot",
// username: "myawesomebot" } }
const chat_id = 100500
const photo = fs.createReadStream('./path/to/photo.jpg')
bot
.sendPhoto({ chat_id, photo })
.then(console.log)
// { ok: true, result: { Message object } }
bot
.sendPhoto({
chat_id,
photo: fs.createReadStream('./path/to/photo.jpg'),
})
.then(console.log)
// { ok: true, result: { Message object } }
Etc. for all other methods.
Telegram requires serializing some parameters of methods. You do not need to do this, because this is done automatically.
EventEmitter
// All options are optioal
const polling = bot.polling({
limit: 50,
timeout: 60,
allowedUpdates: [ ... ],
})
polling.on('update', update => { ... })
polling.on('message', message => { ... })
polling.on('error', error => { ... })
const { from } = require('most')
const updates$ = from(polling)
const messages$ = updates$
.map(update => update.message)
.filter(Boolean)
FAQs
Actual Telegram bot API JS implementation
The npm package tgapi receives a total of 32 weekly downloads. As such, tgapi popularity was classified as not popular.
We found that tgapi 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.