Enable require() in Node.js Functions on FlowFuse Instance(s)

We're attempting to build a workflow where we need to validate the incoming webhook POST with a hashed value that's calculated from a shared key.

We're currently leveraging the node-red-contrib-crypto-js module but it requires the Shared Key/Secret Key field to be static/set in the ui field.

This is a multi-tenant workflow we need.

Is it possible to enable the ability to leverage require() in Function modules?

My engineer has asked so that we can attempt a solution "using crypto/crypto-js directly in a Function".

If this is not the best solution/not possible, we'd appreciate any other guidance. Would it be to just use multiple node-red-contrib-crypto-js modules on our workflow canvas and route to each one based on the tenant each event is assigned to for HMAC verification, then route back into our unified workflow?

Hi @JeremyCee welcome to the forum.

No, but you don't realy need to

You can simply add crypto-js to the setup tab.

Setup

Demo

Function code

const secretKey = 'mySecretKey'
msg.payload = CryptoJS.AES.encrypt(msg.payload, secretKey).toString()
return msg
1 Like

Ahhh, that's the button we needed! Showing our newness to the community in more ways than one. Thank you for the clear steps/visuals.

2 Likes