mhart / aws4

Signs and prepares Node.js requests using AWS Signature Version 4
MIT License
703 stars 176 forks source link

Request body should allow Buffer object #146

Open aleclarson opened 2 years ago

aleclarson commented 2 years ago

…and it shouldn't assume UTF8 encoding.

Currently, when calculating the content hash, UTF8 encoding is assumed: https://github.com/mhart/aws4/blob/a413aadd9e4b4e58842937a9ad53354be41ef4a1/aws4.js#L14-L15

sspiff commented 2 months ago

According to https://nodejs.org/api/crypto.html#hashupdatedata-inputencoding, hash.update() will ignore the given encoding ('utf8' here) when the given data (string here) is already a Buffer. So maybe it already admits body as a Buffer? Admittedly, I haven't tested this.