AMI Security with Non-Python (Node.js)

I found this thread AMI fails to validate from Media page which solved my issue.

The final working example is (NOTICE the && v, and the \r\n movement, those were both needed!):

const key = 'my-key';

const sortedParams = [];
for (const [k, v] of Object.entries(form)) {
    if (k !== 'signature' && v) {
        sortedParams.push(`${k}=${v}\r\n`);
    }
}
sortedParams.sort();

const stringToVerify = sortedParams.join('');
console.log('stringToVerify:');
console.log(stringToVerify);

const signature = crypto.createHmac('sha1', key).update(stringToVerify).digest('hex');
app.log.info('signature (form):', form.signature);
app.log.info('signature (hmac):', signature);