[Snyk] Upgrade: debug, mongoose, shutterstock-api, telegraf #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade multiple dependencies.
👯♂ The following dependencies are linked and will therefore be updated together.ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
debug
from 4.3.3 to 4.3.6 | 3 versions ahead of your current version | 2 months ago
on 2024-07-27
mongoose
from 6.0.12 to 6.13.0 | 97 versions ahead of your current version | 3 months ago
on 2024-06-06
shutterstock-api
from 1.1.12 to 1.1.41 | 26 versions ahead of your current version | 3 months ago
on 2024-06-20
telegraf
from 4.5.2 to 4.16.3 | 58 versions ahead of your current version | 7 months ago
on 2024-02-29
Issues fixed by the recommended upgrade:
SNYK-JS-MONGOOSE-2961688
SNYK-JS-MONGOOSE-5777721
SNYK-JS-MONGODB-5871303
SNYK-JS-MINIMIST-2429795
Release notes
Package name: debug
What's Changed
New Contributors
Full Changelog: 4.3.5...4.3.6
Patch
Thank you @ calvintwr for the fix.
What's Changed
New Contributors
Full Changelog: 4.3.3...4.3.4
Patch Release 4.3.3
This is a documentation-only release. Further, the repository was transferred. Please see notes below.
Thank you to @ taylor1791 and @ kristofkalocsai for their contributions.
Repository Migration Information
I've formatted this as a FAQ, please feel free to open an issue for any additional question and I'll add the response here.
Q: What impact will this have on me?
In most cases, you shouldn't notice any change.
The only exception I can think of is if you pull code directly from https://github.com/visionmedia/debug, e.g. via a
"debug": "visionmedia/debug"
-type version entry in your package.json - in which case, you should still be fine due to the automatic redirection Github sets up, but you should also update any references as soon as possible.Q: What are the security implications of this change?
If you pull code directly from the old URL, you should update the URL to https://github.com/debug-js/debug as soon as possible. The old organization has many approved owners and thus a new repository could (in theory) be created at the old URL, circumventing Github's automatic redirect that is in place now and serving malicious code. I (@ Qix-) also wouldn't have access to that repository, so while I don't think it would happen, it's still something to consider.
Even in such a case, however, the officially released package on npm (
debug
) would not be affected. That package is still very much under control (even more than it used to be).Q: What should I do if I encounter an issue related to the migration?
Search the issues first to see if someone has already reported it, and then open a new issue if someone has not.
Q: Why was this done as a 'patch' release? Isn't this breaking?
No, it shouldn't be breaking. The package on npm shouldn't be affected (aside from this patch release) and any references to the old repository should automatically redirect.
Thus, according to all of the "APIs" (loosely put) involved, nothing should have broken.
I understand there are a lot of edge cases so please open issues as needed so I can assist in any way necessary.
Q: Why was the repository transferred?
I'll just list them off in no particular order.
debug
ecosystem intends to grow beyond a single package, and since new packages could not be created in the old org (nor did it make sense for them to live there), a new org made the most sense - especially from a security point of view.Q: Was this approved?
Yes.[archive]
Q: Do I need to worry about another migration sometime in the future?
No.
Package name: mongoose
Package name: telegraf
link_preview_options.url
caused client to try sending it as mediaCommandContextExtn
type toComposer::{start|help|settings}
(adds ctx.command, payload, args)Fixed
Context::text
: was undefined if entities was undefined. Thanks to @ AnotiaWang.Fixed
Context::from
: now usescallbackQuery.from
instead ofmsg.from
Phew, what a feature-packed release! 🎉
🆙 Bot API Updates
👍 Working with Reactions
To listen on reaction addition and removal, use
Composer.reaction
:// user added a 👍 reaction
});
// prefix with - to listen to reaction removal
bot.reaction("-👍", (ctx) => {
// user removed a 👍 reaction
});
This also just works with custom emoji IDs.
// user added a reaction with the given custom emoji ID
});
bot.reaction("-5368742036629364794", (ctx) => {
// user removed a reaction with the given custom emoji ID
});
You can probe and inspect the reaction list with the
ctx.reactions
smart object:// remember that ctx.reactions is a smart object, but not an array
// message has a 👍 reaction
ctx.reactions.has("👍");
// message has a reaction with the given custom emoji ID
ctx.reactions.has("5368742036629364794");
// number of reactions from this user on the message
ctx.reaction.count;
// indexed access is allowed:
const first = ctx.reactions[0];
// the 👍 emoji was added in this update
if (ctx.reactions.added.has("👍")) {
// user added a 👍 reaction
await User.updateOne({ id: ctx.from.id }, { $inc: { likes: 1 } });
}
// the 👍 emoji was removed in this update
if (ctx.reactions.removed.has("👍")) {
// user removed a 👍 reaction
await User.updateOne({ id: ctx.from.id }, { $inc: { likes: -1 } });
};
// to copy any of these smart objects into an array, call the
toArray
methodconst reactions = ctx.reactions.toArray();
const added = ctx.reactions.added.toArray();
const removed = ctx.reactions.removed.toArray();
});
To react to a message, use
ctx.react
:You can also react to a message with a custom emoji ID:
The
bot.telegram.setMessageReaction
method is also available.💅
Context::text
andContext::entities()
helpersAdded the
ctx.entities()
method to fetch entities in any message.Not only does this method fetch entities from any message, but also works with captions, game text, and poll explanations. In short, if an update has any text and entities, this method will find them.
ctx.text
is the companion toctx.entities()
. It fetches the text from the update, and works with any message type. This includes message text, media captions, game text, and poll explanations.// fetch the text from the update
const text = ctx.text;
});
bot.on(message("photo"), (ctx) => {
// fetch the caption from the photo
const caption = ctx.text;
});
🎁 Bonus! Every entity in the
ctx.entities()
array will have a fragment of the text they represent!📬
Context::msg
andContext::msgId
shorthandsContext::msg
shorthand to get any message in the update.ctx.msg
is decorated with theisAccessible
andhas
methods. Thehas
method works similarly to themessage()
filter inbot.on
. It checks if the message has a certain property.// msg is accessible, not deleted or otherwise unavailable
// this is a type-guard based on the runtime check for msg.date === 0
}
if (ctx.msg.has("text")) {
// ctx.msg.text exists
}
Context::msgId
shorthand to get any available message ID in the update. This also includesmessage_id
present in updates that do not contain a message, such asmessage_reaction
, andmessage_reaction_count
.🚀
bot.launch
takes an onLaunch callbackbot.launch
now takes an optional callback that is called when the bot is launched.If you pass LaunchOptions, the callback goes after the options.
This is useful for running some code when the bot is launched, such as logging to the console, or sending a message to a channel. Remember that errors thrown in this callback will not be caught by the bot's error handler. You must handle them yourself.
🖍 Format helpers
quote
format helper for Blockquotes.pre
within another entity.🔧 Other fixes and improvements
ctx.match
forComposer.command
(#1938).ctx.chat
now includeschat
fromthis.messageReaction ?? this.messageReactionCount ?? this.removedChatBoost
.ctx.from
now includes the fielduser
fromctx.messageReaction ?? ctx.pollAnswer ?? ctx.chatBoost?.boost.source
, in addition to fetchingfrom
in other updates.useNewReplies
usesctx.msgId
instead ofctx.message.message_id
to reply to messages, which works for more update types than before.types
,scenes
,filters
,format
,future
,utils
,markup
,session
. For example, viaimport { WizardScene } from "telegraf/scenes"
. This was previously available in v3, and was removed in v4.💔 Minor breaking changes
Markup.button.userRequest
will takeextra
instead ofuser_is_premium
as the third parameter.Markup.button.botRequest
will takeextra
beforehide
as the third parameter.reply_to_message_id
andallow_sending_without_reply
replaced byreply_parameters
.disable_web_page_preview
andlink_preview_options
replaced bylink_preview_options
.🎉 BIG announcement 🥳
Telegraf v4 - Last Major Update
This will be the last major update for Telegraf v4.
What to Expect
If you are currently using Telegraf v4, you can continue using it as you have been. Telegraf v4 will be supported until February 2025, with the following commitments:
Introducing Telegraf v5
In the coming weeks, we plan to release Telegraf v5. v5 will bring a revamped API, new functionalities, numerous convenient helpers, an improved approach to handling updates, and enhanced documentation.
One of the key highlights of Telegraf v5 is its platform-agnostic nature, allowing you to run it on any JavaScript runtime environment, including Deno, Bun, edge runtimes (such as Cloudflare Workers and Vercel), browsers, and more.
Smooth Transition to v5
If you have closely followed the development of v4 in the past year and stayed updated with deprecation notices, the transition to v5 will be relatively seamless for you. For those still using v4, we will provide a comprehensive migration guide to assist you in upgrading to v5. Stay tuned for more information on the release of v5!
Thanks for all the love ❤️! Go follow the releases channel on Telegram: t.me/Telegraf_JS.
You can sponsor the maintainer (@ MKRhere) via GitHub Sponsors, Patreon, or Ko-fi.
thumbnail
is now respected in all APIs that accept itEXPERIMENTAL_SESSION_CHECKS
introduced in the last minor release had been reporting false positives. This has been fixed; it will now work as intended.🔧 Fixed
sendPhoto
and friends irrecoverably erroring if passed an invalid path, such as a directory.EXPERIMENTAL_SESSION_CHECKS=1
to catch session bugs in your code.When this is enabled, Telegraf will throw errors if you access/assign to session after Telegraf thinks the middleware chain has exhausted. This can happen if you're missing awaits in async code, and session changes might not get persisted! Previously, these bugs were silently ignored until someone noticed their session was not saved. It's always safe to enable this feature. This behaviour may be default in v5.
This is a rather minor release.
anyOf
andallOf
filter combinatorsv4.11.0 introduced support for type-guard filters in
Composer::on
, which allowed you to filter updates based on their content.This release adds two new combinators to the filter API:
anyOf
andallOf
. This will play very nicely with custom filters. For example:// must match all filters
bot.on(allOf(message(), isGroup), ctx => {
// ...
});
Deprecating
hookPath
The confusingly named
hookPath
inbot.launch
webhook options is now deprecated. It will be removed in the next major release. You can start usingpath
instead, today.Meanwhile, we're working on new modules to add to the Telegraf ecosystem. Look forward to them, and join discussions in the official Telegraf chat!
Markup.keyboard([]).persistent()
methodImportant
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: