Buffer.from(str, 'base64') fails to decode valid Base64
I wanted to try out LLRT, but I failed to get base64 decoding to work.
Buffer.from(str, 'base64');
Hi there. Thanks for the issue. Do you have an example string?
Hey there, I've been browsing this project as I work with AWS daily, excited to see where it goes! Took some time to investigate this myself to see if I could reproduce the issue. The only time I was able to produce an error was when decoding a Buffer into ascii, but this seems like it's probably intended behavior.
@dforsber Here's an example project that will get you started with a zip file that you can deploy to AWS. Here's the output you should expect when you test the lambda:
Please note: you will need to provide your own llrt binary for security purposes
Welcome to Node.js v18.18.2.
Type ".help" for more information.
> Buffer.from('eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6IlRhcFRva2VuIn0', 'base64').toString()
'{"alg":"HS512","typ":"JWT","kid":"TapToken"}'
./llrt -e 'Buffer.from("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6IlRhcFRva2VuIn0", "base64").toString()'
Error: Base64Error
at <eval> (eval_script:1:8)
==> It seems I need to add = to the end.
./llrt -e 'console.log(Buffer.from("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6IlRhcFRva2VuIn0=", "base64").toString())'
{"alg":"HS512","typ":"JWT","kid":"TapToken"}
Ah right, thank you. This is a padding issue. Will fix 👌