Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Execution Error #2

Open
antonismladenis opened this issue Sep 25, 2018 · 2 comments
Open

Execution Error #2

antonismladenis opened this issue Sep 25, 2018 · 2 comments

Comments

@antonismladenis
Copy link

Hi,

I tried to execute the code as an AWS Lambda Function, but I get an error response about the 'async function fetchKeys()'. What am I missing?

//required params
const params = {
  region: '<your-aws-region>',
  userPoolId: '<your-user-pool-id>'
}
 
//optional claims examples
const claims = {
  aud: '<your-app-client-id>',
  email_verified: true,
  auth_time: time => time <= 1524588564,
  'cognito:groups': groups => groups.includes('Admins')
}
 
const Verifier = require('verify-cognito-token');
const verifier = new Verifier(params, claims);
 
verifier.verify(token)
.then(result =>{
  //result will be `true` if token is valid, non-expired, and has matching claims
  //result will be `false` if token is invalid, expired or fails the claims check
})

Response:
{
"errorMessage": "RequestId: 4f8d8756-c097-11e8-8adf-6f88f5e6d44a Process exited before completing request"
}

Request ID:
"4f8d8756-c097-11e8-8adf-6f88f5e6d44a"

Function Logs:
START RequestId: 4f8d8756-c097-11e8-8adf-6f88f5e6d44a Version: $LATEST
2018-09-25T07:47:54.317Z 4f8d8756-c097-11e8-8adf-6f88f5e6d44a /var/task/node_modules/verify-cognito-token/index.js:6
async function fetchKeys() {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at exports.handler (/var/task/index.js:17:22)
END RequestId: 4f8d8756-c097-11e8-8adf-6f88f5e6d44a
REPORT RequestId: 4f8d8756-c097-11e8-8adf-6f88f5e6d44a Duration: 191.85 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 19 MB
RequestId: 4f8d8756-c097-11e8-8adf-6f88f5e6d44a Process exited before completing request

@pianosnake
Copy link
Owner

The Lambda runtime environment should be set to Node 8.10 or higher to support async functions.

@antonismladenis
Copy link
Author

Thanks, now it works.

I guess the verification of token works only for AccessToken and IdToken and not for refreshToken because it has a different format, right?

Do you know how I could verify the refresh token too?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants