aws-sign-web icon indicating copy to clipboard operation
aws-sign-web copied to clipboard

buildCanonicalRequest fails when using query params

Open instantdelay opened this issue 5 years ago • 3 comments

buildCanonicalRequest doesn't appear to work when query params are specified in the request. For example

signer.sign({
  method: 'GET',
  url: '/someurl',
  params: { myId: 'abc' }
});

This line breaks because ws.uri.queryParams[key] is a string and doesn't have sort(). It looks like this assumes the param values are always arrays. That's true if they came from SimpleQueryParser but normal params (merged with extend in prepare) are just strings/numbers.

I tried working around this by adding my own interceptor to wrap all may params in arrays but that doesn't work because Axios then appends [] to the key names.

instantdelay avatar Apr 23 '21 08:04 instantdelay

I just noticed that my issue https://github.com/danieljoos/aws-sign-web/issues/20 is about the same problem. I did some research and I have a workaround in that issue that you might be interested in.

mrmilosz avatar Jun 30 '22 04:06 mrmilosz

I've created a new pull request that should resolve this issue: https://github.com/danieljoos/aws-sign-web/pull/21

mrmilosz avatar Jul 04 '22 10:07 mrmilosz

I've created a second pull request to bump the version: https://github.com/danieljoos/aws-sign-web/pull/22. I've also closed my own issue about this as it's a duplicate anyway: https://github.com/danieljoos/aws-sign-web/issues/20

We can close this one as soon as the version bump is done.

mrmilosz avatar Jul 05 '22 01:07 mrmilosz