Firebase functions webhook validation

I am working in a nodejs firebase functions environment. Has anybody actually been able to get the webhook verified. I can send a request ok and validation works. Its just the incoming webhook. I have a feeling it might be to do with the body encoding and firebase functions doesn’t let you get to the raw body… here is my code:
const validateRapydSignature = (req) => {
const signature = req.header(‘signature’)
const urlPath = req.protocol + ‘://’ + req.headers.host + req.originalUrl
const salt = req.header(‘salt’)
const timestamp = req.header(‘timestamp’)
const bodyString = req.body
const secretKey = ‘…’
const accessKey = '…

const dataToHash =
urlPath +
salt +
timestamp +
accessKey+
secretKey+
bodyString

let hash = crypto.createHmac(‘sha256’, secretKey)
hash.update(dataToHash)
const generatedSignature = Buffer.from(hash.digest(‘hex’)).toString(‘base64’)

return signature === generatedSignature
}

1 Like

Hey, @blakejp1 - are you still having this challenge? This doesn’t appear to be an issue with the Rapyd API if I am reading correctly. Can you share your logs – also is this in the production or sandbox environment of Rapyd?

Hi Drew. thanks for the response. Yes I still have the challenge. I had to move on for now because I can’t solve it but obviously I need to get it solved before going live. As an update I tried it with firebase functions req.rawBody instead of just req.body and I still get the issue. I am not saying its a rapyd issue, yet :} hence the question asking if anyone actually got it working with firebase functions version 2? I am wondering if they play with the rawBody or if the encoding is different or something. Like I say I can send to rapyd with a signature fine. not sure which logs you want but will get something over to you in the next couple of days.

1 Like

Sounds good. I will keep asking around if anyone else is having this challenge with Firebase and webhook validation.

Appreciated. And I forgot to add: yes its in the sandbox environment and associated keys

1 Like