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