awslabs/aws-jwt-verify

[BUG] Type error with CognitoJwtVerifier.create

etroynov opened this issue · 2 comments

When i try use configuration from var i got an error:

Screenshot 2023-03-29 at 13 38 45

But when i do it directly:
Screenshot 2023-03-29 at 13 39 15

everything is fine.

Versions

  • aws-jwt-verify: 4.0.0;
  • env: lambda@edge
  • typescript: 5.0.2

This is expected I think, because if you predefine the config object like you did, TypeScript types each member as string but tokenUse must be access or id, a mere string won't do.

This should work:

const config = {
    userPoolId: "xxxxxxxxxxx",
    tokenUse: "access" as const, // changed
    clientId: "xxxxxxxxxxxx"
}

const verifier = CognitoJwtVerifier.create(config);