#Sëths

1 messages · Page 1 of 1 (latest)

summer spadeBOT
jagged vigil
#

👋 happy to help

vivid stratus
#

hi tarzan!

jagged vigil
vivid stratus
#

yeah, but this throw me an error from express.raw

jagged vigil
#

you shouldn't use express.raw if you're using another node.js framework/library

#

you need to find the appropriate function that does that in the module you're using

vivid stratus
#

i need to know how can i get from json the correct format

jagged vigil
#

in lambda-api you have a property on the request field called rawBody you can use that instead

vivid stratus
#

i think

#

let me check

jagged vigil
#

yes please do

#

I'm no expert in lamda-api, I was just looking at their npm readme

vivid stratus
#

yeah there is a tricky method when i debug in local, i have another module named lambda-local, its like a proxy

jagged vigil
#

I guess that should be it but I'm not sure

#

because rawBody shouldn't format or do anything with the request body

vivid stratus
#

i trying to stringify with parameters null,2 but there is still not working :S. there is more info how signature works and why is so strict?

jagged vigil
#

do you have a middleware configured somewhere at the top of your code?

#

for reading Jsons?

#

you shouldn't parse the body for the signature to work

#

this is why we use express.raw in our example

vivid stratus
#

im using local script for simulate lambda with lambda-local

#

on this script i have express

#

and im using bodyparser

#

im trying to do this

hot pulsar
vivid stratus
#

hi pompey

#

im checking

vivid stratus
#

i dont know why but lambda api is parsing my rawBody

#

there is not any other format to transform json to a valid format?

hot pulsar
#

Stripe's libraries need the raw request body, even changing things like whitespace will mean that an incorrect signature is calculated.

#

Are you saying that the body is being transformed before it even gets to your code?

#

In that case we might need to look in to workarounds for that too

hot pulsar
#

Would it be feasible here for you to direct your webhooks to a URL that isn't at /api/v1 on your server so they won't have this middleware apply?

vivid stratus
#

this is only for development purpose, but without this i cant develop in local

#

i detect why is diferent when is rawBody and body with json stringify

#

first is stringify

#

and the second is the raw body

somber cloak
#

Hello 👋
Stepping in as Pompey needs to step away
Give me a moment to catch up on the thread

vivid stratus
#

hi hanzo

somber cloak
#

Okay yeah, as Pompey mentioned the libraries expect a rawBody for security purposes
There isn't a workaround for this unfortunately. You'd want to tweak your code to avoid parsing the payload when it comes from our servers

#

The only one that I can think of is what my colleagues already suggested where you direct your webhook to a URL that isn't part of /api/v1