You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is not the first issue related to this problem (see #14#40#48#66#67#69#84#110), but as I see that most of them ended up being closed without a solution, I was thinking of opening it again, with some extra thoughts. So I searched the Internet, and the most possible source of the problem is here:
I am just curious if the following has been considered when the _verifyRequestSignature function was created?:
Please note that the calculation is made on the raw escaped unicode version of the payload, with lower case hex digits. For example, the string äöå will be escaped to \u00e4\u00f6\u00e5. The calculation also escapes / to /, < to \u003C, % to \u0025 and @ to \u0040. If you just calculate against the decoded bytes, you will end up with a different signature.
Source: https://developers.facebook.com/docs/messenger-platform/webhook/#security
If not, maybe this might be helpful?:
String.prototype.toUnicode=function(){varresult=""for(vari=0;i<this.length;i++){// Assumption: all characters are < 0xffffresult+="\\u"+("000"+this[i].charCodeAt(0).toString(16)).substr(-4)}returnresult}
UPDATE: Playing with it on a fork locally, I found out, that the Error that gets triggered is on line 684 in BootBot.js, cause signature is undefined. Now I am not an expert on this topic, so maybe is it me, who should send an X-Hub-Signature? I am testing with curl:
By doing that, I now actually get a different error:
BadRequestError: Missing X-Hub-Signature header
Which at least describes the problem a bit better. So at the end of the day, I still have the same problem, so if you can and could help me to explain what X-Hub-Signature's value should be, I would appreciate it!
Without this, I don't know how to develop/test locally, and I have to deploy every time I make a small change to test.
Hey @balazsorban44, I've actually never encountered this error myself, but since this error is thrown when your bot tries to verify that the request comes from Facebook, you can probably bypass the verification locally while you test it.
It's been a while since I've worked with this project, but one thing I can suggest is changing line 36 in BootBot.js from:
If that works, then we can probably make it an option in the bot's config object so that you can specify that you want to skip the signature verification when running it locally.
This is because your JSON is not being propery parsed. Body parser worked for me perfectly . example const bodyParser = require("body-parser"), app = express().use(bodyParser.json());
It is not the first issue related to this problem (see #14 #40 #48 #66 #67 #69 #84 #110), but as I see that most of them ended up being closed without a solution, I was thinking of opening it again, with some extra thoughts. So I searched the Internet, and the most possible source of the problem is here:
bootbot/lib/BootBot.js
Lines 681 to 698 in 8884e72
On another repo, some people claim they solved the problem:
botmasterai/botmaster-messenger#15 (comment)
I am just curious if the following has been considered when the
_verifyRequestSignature
function was created?:If not, maybe this might be helpful?:
UPDATE: Playing with it on a fork locally, I found out, that the Error that gets triggered is on line 684 in
BootBot.js
, cause signature isundefined
. Now I am not an expert on this topic, so maybe is it me, who should send anX-Hub-Signature
? I am testing with curl:Clearly, there is no x-hub header, not even in Facebook's example!
What I tried is to change the code on line 36
bootbot/lib/BootBot.js
Line 36 in 8884e72
to this (using x-hub-signature from npm):
By doing that, I now actually get a different error:
Which at least describes the problem a bit better. So at the end of the day, I still have the same problem, so if you can and could help me to explain what X-Hub-Signature's value should be, I would appreciate it!
Without this, I don't know how to develop/test locally, and I have to deploy every time I make a small change to test.
@Charca ?
The text was updated successfully, but these errors were encountered: