FastComments.com
Here you can edit and run the code snippet from our documentation.
Example Code Snippet "웹훅 서명 검증 예제"
import crypto from 'crypto'; function verifyAgentWebhook(rawBody, signatureHeader, timestampHeader, secret) { const expected = 'sha256=' + crypto .createHmac('sha256', secret) .update(`${timestampHeader}.${rawBody}`) .digest('hex'); return crypto.timingSafeEqual( Buffer.from(expected), Buffer.from(signatureHeader), ); }
Result