mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 09:59:10 +00:00
fix(interactions): deployment + handler
This commit is contained in:
parent
3ca37cff17
commit
61b1146774
7 changed files with 58 additions and 12 deletions
|
@ -1,7 +1,11 @@
|
|||
import { publicKey } from '@roleypoly/interactions/utils/config';
|
||||
import { InteractionRequest } from '@roleypoly/types';
|
||||
import nacl from 'tweetnacl';
|
||||
|
||||
export const verifyRequest = async (request: Request): Promise<boolean> => {
|
||||
export const verifyRequest = (
|
||||
request: Request,
|
||||
interaction: InteractionRequest
|
||||
): boolean => {
|
||||
const timestamp = request.headers.get('x-signature-timestamp');
|
||||
const signature = request.headers.get('x-signature-ed25519');
|
||||
|
||||
|
@ -9,11 +13,9 @@ export const verifyRequest = async (request: Request): Promise<boolean> => {
|
|||
return false;
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
|
||||
if (
|
||||
!nacl.sign.detached.verify(
|
||||
Buffer.from(timestamp + JSON.stringify(body)),
|
||||
Buffer.from(timestamp + JSON.stringify(interaction)),
|
||||
Buffer.from(signature, 'hex'),
|
||||
Buffer.from(publicKey, 'hex')
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue