Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expressJwtSecret can return undefined which is not reflected in GetVerificationKey type #328

Closed
AaronMoat opened this issue Oct 10, 2022 · 2 comments · Fixed by #329
Closed
Labels

Comments

@AaronMoat
Copy link
Contributor

AaronMoat commented Oct 10, 2022

Describe the problem

expressJwtSecret in the GetVerificationKey mode can return a Promise of undefined, e.g. here:

    if (!token) { return; }

but GetVerificationKey returns Secret | Promise<Secret> to which undefined or Promise are not assignable.

What was the expected behavior?

The typing for GetVerificationKey should include undefined.

Reproduction

This fails to compile:

const x: Awaited<ReturnType<GetVerificationKey>> = undefined;

Environment

  • Version of this library used:: 2.1.4
@adamjmcgrath
Copy link
Contributor

Hi @AaronMoat - thanks for raising this

GetVerificationKey should either return a key or throw an error

It shouldn't be possibly to return any falsey value for key - so the types look ok to me

@adamjmcgrath
Copy link
Contributor

Ah no, my bad - I see what you mean

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

Successfully merging a pull request may close this issue.

2 participants