AnomalyInnovations / aws-api-gateway-cli-test

A simple CLI to test API Gateway endpoints with IAM authorization
MIT License
120 stars 29 forks source link

Expected params.AuthParameters['USERNAME'] to be a string #9

Open jeremyhodges opened 6 years ago

jeremyhodges commented 6 years ago

My AWS user pool is setup to use only phone numbers as the username. When I try to make an API call with this test cli I get the following message:

Authenticating with User Pool Expected params.AuthParameters['USERNAME'] to be a string

I tried wrapping the username parameter in both single and double quotes. Same result.

npx aws-api-gateway-cli-test \
--username='15555555555' \
--password='Passw0rd!' \
...
jayair commented 6 years ago

@jeremyhodges I haven't tested it with phone numbers but we aren't doing anything specific for string based user names. We simply pass it to the Cognito JS SDK. Can you confirm that you are able to use the Cognito SDK to authenticate in your app?

sjl2 commented 5 years ago

Looks like yargs will take the input here for username, but the problem for phone numbers is that they're probably getting converted to numbers.

Every argument that looks like a number (!isNaN(Number(arg))) is converted to one. This way you can just net.createConnection(argv.port) and you can add numbers out of argv with + without having that mean concatenation, which is super frustrating. Reference

PoC

node
> !isNaN(Number('+013333333333'))
true

Looks like the username argument will need to be coerced to a string.

jayair commented 5 years ago

@sjl2 Good catch! Thanks for looking into it. I'll test it out and update it.

jmazala commented 4 years ago

man this is irritating indeed lol

jayair commented 4 years ago

Fixed this in 1.3.1.