Hook utilities

Your hook might need functionality that is usually implemented in a package or library. However, importing packages in hooks is disabled due to security and performance reasons.

Cloudhooks adds some utility packages and functions to the hook's javascript VM directly.

The hookUtils variable contains an object with the following packages and functions:

Name Type Description
crypto package The built-in crypto package of NodeJS.

You can use the crypto package as follows:

module.exports = async function(payload, actions, context) {

  const secret = 'abcdefg';
  const hash = hookUtils.crypto.createHmac('sha256', secret)
                 .update('I love cupcakes')
                 .digest('hex');

  console.log('Generated hash: ', hash);
}