-
Notifications
You must be signed in to change notification settings - Fork 233
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
Fix typescript typings #80
Conversation
auth0, please merge this! |
Please! Merge! |
index.d.ts
Outdated
|
||
function koaJwtSecret(options: JwksRsa.Options): (name: string, scheme: string, options?: any) => void; | ||
function hapiJwt2KeyAsync(options: HapiJwtOptions): (decodedToken: DecodedToken) => Promise<{ key: SigningKey }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(decodedToken: DecodedToken) => Promise<{ key: SigningKey }>;
this is actually wrong. it does not return a promise of SigningKey
, they key
property is just a string with the value. See:
- https://github.com/auth0/node-jwks-rsa/blob/master/src/integrations/hapi.js#L25
- https://github.com/auth0/node-jwks-rsa/blob/master/src/integrations/hapi.js#L58
I wrote a test for verifying the typings here #98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! Fixed it.
@@ -5,6 +5,7 @@ | |||
"main": "lib/index.js", | |||
"types": "index.d.ts", | |||
"dependencies": { | |||
"@types/express-jwt": "0.0.41", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a dev dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeScript handbook recommends using dependencies
, because otherwise consumers will have to install @types/express-jwt
manually: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the link!
The typescript typings are not really accurate at the moment. This fixes them. Note that jwt-express types should be listed in dependencies (as they are now) because we re-export a type from that package.
Incorporates #73, #69, #54.
Fixes #46, #28, #78, #75.