src/listen.js
function handleValidation(req, res, next) {
      var payload = JSON.stringify(req.body);
      var nodeVersion = Number(process.version.replace(/^v/, '').split(/\./)[0]);

      var utf8safe = nodeVersion >= 6 ? payload : unescape(encodeURIComponent(payload));
      var hash = crypto.createHmac('sha1', secret).update(utf8safe).digest('hex');
      var signature = req.get('layer-webhook-signature');

      if (hash === signature) next();
      else {
        loggerError('Computed HMAC Signature ' + hash + ' did not match signed header ' + signature + '. Returning Error.  Config:', JSON.stringify(payload.config || {}));
        res.sendStatus(403);
      }
    }
function handleValidation(req, res, next) {
      var payload = JSON.stringify(req.body);
      var nodeVersion = Number(process.version.replace(/^v/, '').split(/\./)[0]);

      var utf8safe = nodeVersion >= 6 ? payload : unescape(encodeURIComponent(payload));
      var hash = crypto.createHmac('sha1', secret).update(utf8safe).digest('hex');
      var signature = req.get('layer-webhook-signature');

      if (hash === signature) next();
      else {
        loggerError('Computed HMAC Signature ' + hash + ' did not match signed header ' + signature + '. Returning Error.  Config:', JSON.stringify(payload.config || {}));
        res.sendStatus(403);
      }
    }
function handleValidation ( req , res , next ) { var payload = JSON . stringify ( req . body ) ; var nodeVersion = Number ( process . version . replace ( / ^v / , '' ) . split ( / \. / ) [ 0 ] ) ; var utf8safe = nodeVersion >= 6 ? payload : unescape ( encodeURIComponent ( payload ) ) ; var hash = crypto . createHmac ( 'sha1' , secret ) . update ( utf8safe ) . digest ( 'hex' ) ; var signature = req . get ( 'layer-webhook-signature' ) ; if ( hash === signature ) next ( ) ; else { loggerError ( 'Computed HMAC Signature ' + hash + ' did not match signed header ' + signature + '. Returning Error.  Config:' , JSON . stringify ( payload . config || { } ) ) ; res . sendStatus ( 403 ) ; } }
Validate that the request comes from Layer services by comparing the secret
provided when registering the webhook with the 'layer-webhook-signature' header.
Validate that the request comes from Layer services by comparing the secret provided when registering the webhook with the layer - webhook - signature header .