Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
discord-interactions
Advanced tools
Types and helper functions that may come in handy when you implement a Discord Interactions webhook.
npm install discord-interactions
Use the InteractionType
and InteractionResponseType
enums to figure out how to respond to a webhook.
Use verifyKey
to check a request signature (requires installation of noble-ed25519
package):
const signature = req.get('X-Signature-Ed25519');
const timestamp = req.get('X-Signature-Timestamp');
const isValidRequest = await verifyKey(req.rawBody, signature, timestamp, 'MY_CLIENT_PUBLIC_KEY');
if (!isValidRequest) {
return res.status(401).end('Bad request signature');
}
Note that req.rawBody
must be populated by a middleware (it is also set by some cloud function providers).
If you're using an express-like API, you can simplify things by using the verifyKeyMiddleware
. For example:
app.post('/interactions', verifyKeyMiddleware('MY_CLIENT_PUBLIC_KEY'), (req, res) => {
const message = req.body;
if (message.type === InteractionType.COMMAND) {
res.send({
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
content: 'Hello world',
},
});
}
});
Make sure that you do not use other middlewares like body-parser
, which tamper with the request body, for interaction routes.
This module exports the following:
An enum of interaction types that can be POSTed to your webhook endpoint.
An enum of response types you may provide in reply to Discord's webhook.
An enum of flags you can set on your response data.
Verify a signed payload POSTed to your webhook endpoint.
Express-style middleware that will verify request signatures (make sure you include this before any other middleware that modifies the request body).
FAQs
Helpers for discord interactions
The npm package discord-interactions receives a total of 3,939 weekly downloads. As such, discord-interactions popularity was classified as popular.
We found that discord-interactions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.