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

navigator is not defined? #2

Closed icj217 closed 7 years ago

icj217 commented 7 years ago

Not sure if this is a quirk in how I have my User Pool configured, but I was getting the following error when using the command provided in the serverless stack guide:

Command (with values removed): apig-test --username='' --password='' --user-pool-id='' --app-client-id='' --cognito-region='us-east-1' --identity-pool-id='' --invoke-url='' --api-gateway-region='us-east-1' --path-template='/subscriptions' --method='POST' --body=""

Error:

Authenticating with User Pool
/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

ReferenceError: navigator is not defined
    at CognitoUser.authenticateUserInternal (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:343:19)
    at /usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:283:22
    at Response.<anonymous> (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:249:18)
    at Request.<anonymous> (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:364:18)
    at Request.callListeners (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /usr/local/lib/node_modules/aws-api-gateway-cli-test/node_modules/aws-sdk/lib/state_machine.js:26:10

I was able to get past the error and get the command to work by commenting out lines 343 and 604 in _/usr/local/lib/node_modules/aws-api-gateway-cli-test/nodemodules/amazon-cognito-identity-js/lib/CognitoUser.js that reference the navigator.

jayair commented 7 years ago

@icj217 Thanks for the detailed report.

I found some more info on this - https://stackoverflow.com/questions/40219518/aws-cognito-unauthenticated-login-error-window-is-not-defined-js. I'll add that in to get around the issue.

jayair commented 7 years ago

@icj217 I just published a new update (1.1.1) fixing this issue. Do you mind testing it and reporting back? You can install the new update using npm install -g aws-api-gateway-cli-test.

icj217 commented 7 years ago

@jayair I installed the new version and uncommented the navigator lines and was able to run the tool successfully!