Discussions

Ask a Question
Back to All

Nodejs webhook itegration(signature check)

I'm trying to add a signature check to my integration. When I'm running code example that you have provided using Python - everything works fine

But, when I'm trying to implement this using node.js - my signatures are not the same and I don't know why.
Here is an example of my code. Could you provide a node.js example, please?

    const secret = 'bla_bla_bla';
    const signature = req.headers['signature'];
    const body = req.rawBody;

    const hmac = createHmac('sha256', secret);
    hmac.update(body);
    const computedSignature = hmac.digest('hex');

    if (computedSignature !== signature) {
      this.logger.log('Invalid signature');
      return false;
    }