dressed
Version:
A sleek, serverless-ready Discord bot framework.
16 lines • 614 B
JavaScript
import nacl from "tweetnacl";
import { Buffer } from "node:buffer";
import { botEnv } from "../utils/env.js";
/**
* Verifies the signature of the POST request
*/
export function verifySignature(body, signature, timestamp) {
if (!signature ||
!timestamp ||
typeof signature !== "string" ||
typeof timestamp !== "string") {
return false;
}
return nacl.sign.detached.verify(new Uint8Array(Buffer.from(timestamp + body)), new Uint8Array(Buffer.from(signature, "hex")), new Uint8Array(Buffer.from(botEnv.DISCORD_PUBLIC_KEY, "hex")));
}
//# sourceMappingURL=signature.js.map