Issues with webhook signature for payloads with emoji?
Hi! Not sure if i should open a new issue for this.
We’ve been using workflow webhooks with few issues but now on creating a new contact-based workflow we could not get the hash we calculated to match the signature we received. Now after trying with a different contact it matches. As i can’t be 100 % sure on the way HubSpot actually generates the signature, it’s difficult to debug the actual issue, but the only thing i can think of is that it treats certain characters like emojis differently.
Though i’m relieved our use case has worked, i’m worried future webhooks will fail because of a similar problem.
Just in case, i’ll include our signature verification implementation:
```
const verifySignature = (req) => {
const v2 = req.headers[‘X-HubSpot-Signature-Version’.toLowerCase()] === ‘v2’;
const unhashed = `${process.env.HUBSPOT_CLIENT_SECRET}${
v2 ? req.method : ‘’
}${v2 ? `${process.env.TALENT_API_ORIGIN}${req.originalUrl}` : ‘’}${
Object.keys(req.body).length ? JSON.stringify(req.body) : ‘’
}`;
const hash = crypto.createHash(‘sha256’).update(unhashed).digest(‘hex’);
const signature = req.headers[‘X-HubSpot-Signature’.toLowerCase()];
return signature && hash === signature;
};
```