Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
discord-verify
Advanced tools
A library for verifying the authenticity of requests coming from the Discord Interactions API
This package is used to efficiently verify Discord HTTP interactions.
npm install discord-verify
import { isValidRequest } from "discord-verify";
const isValid = await isValidRequest(request, publicKey);
import { isValidRequest } from "discord-verify/node";
const isValid = await isValidRequest(request, publicKey);
If you want to validate requests from frameworks such as Express or Fastify that have their own request classes, you can import the validate function and pass raw values to it.
import { validate } from "discord-verify";
async function handleRequest(
req: FastifyRequest<{
Body: APIInteraction;
Headers: {
"x-signature-ed25519": string;
"x-signature-timestamp": string;
};
}>,
res: FastifyReply
) {
const signature = req.headers["x-signature-ed25519"];
const timestamp = req.headers["x-signature-timestamp"];
const rawBody = JSON.stringify(req.body);
const isValid = await validate(
rawBody,
signature,
timestmap,
this.client.publicKey,
crypto.subtle
);
if (!isValid) {
return res.code(401).send("Invalid signature");
}
}
isValidRequest
takes an optional third argument to specify the algorithm to use. This can be a string or object containing name
and namedCurve
. For convenience, discord-verify
exports PlatformAlgorithm
that contains values used by common platforms. You can use it like this:
import { isValidRequest, PlatformAlgorithm } from "discord-verify";
const isValid = await isValidRequest(
request,
publicKey,
PlatformAlgorithm.Vercel
);
The following platforms are currently supported:
FAQs
A library for verifying the authenticity of requests coming from the Discord Interactions API
The npm package discord-verify receives a total of 2,416 weekly downloads. As such, discord-verify popularity was classified as popular.
We found that discord-verify 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.