awslabs / aws-jwt-verify

JS library for verifying JWTs signed by Amazon Cognito, and any OIDC-compatible IDP that signs JWTs with RS256, RS384, and RS512
Apache License 2.0
606 stars 42 forks source link

[BUG] TypeScript error "verifier.verify()" is expecting 4 parameters #45

Closed ghost closed 2 years ago

ghost commented 2 years ago

Describe the bug The package breaks at build

Versions Which version of aws-jwt-verify are you using? - aws-jwt-verify@2.1.0 Which version of Node.js are you using? (Should be at least 14) - 16 If using TypeScript, which version of TypeScript are you using? (Should be at least 4) - 4.5.4

To Reproduce

const verifier = CognitoJwtVerifier.create({
  userPoolId: userPoolId,
  tokenUse: 'id',
  clientId: clientId,
});

const verifierResult = await verifier.verify(token); // it breaks here

the error: semantic error TS2554: Expected 4 arguments, but got 1.

This breaks only when I build the project. VSCode intelisense doesn't display any issue with the code.

ottokruse commented 2 years ago

So far we've only seen this error on TypeScript < 4

Can you tell more about what building the project actually entails in your case? You mean just run npx tsc? It does look like that uses a different TypeScript version in your setup than your intellisense uses.

Note that if you use tsc (instead of npx tsc) you are invoking global TypeScript install, maybe that's what's goes wrong?

ghost commented 2 years ago

I'm building it with the latest version of tsdx (https://tsdx.io) - https://github.com/jaredpalmer/tsdx

Which, by the looks of it, uses whatever typescript version I have currently in the project: https://github.com/jaredpalmer/tsdx/issues/852#issuecomment-687824789

And in my case, it is indeed, 4.5.4 image

ottokruse commented 2 years ago

Please ensure that tsdx actually uses that.

E.g. by commenting out our lib for a minute and put a TS >4 construct in your source code, does that then work?

e.g.:

function foo(...args: [string, number]): void {
    // ...
}

let a = undefined;
a ||= "value";

https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#labeled-tuple-elements https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#short-circuiting-assignment-operators

ottokruse commented 2 years ago

Any luck @andreifullview ?