I was using atob to decode the mac secret that is why it was not working.
This piece of code worked !
const macSecretFromCreate = "<mac_secret_string_from_create_endpoint>";
const macSecretDecoded = new Buffer(macSecretFromCreate, 'base64');
// example request body
const requestBody = '{"base":{"id":"<the app id>"},"webhook":
{"id":"<the webhook id>"},"timestamp":"<timestamp value"}'
const hmac = require('crypto').createHmac('sha256', macSecretDecoded);
hmac.update(requestBody.toString(), 'ascii');
const expectedContentHmac = 'hmac-sha256=' + hmac.digest('hex');