-
Notifications
You must be signed in to change notification settings - Fork 234
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: types-compabitility for express-jwt @ 7 #301
Conversation
tests/ts-definitions.tests.ts
Outdated
@@ -44,4 +46,22 @@ describe('typescript definition', () => { | |||
const key = await client.getSigningKey('NkFCNEE1NDFDNTQ5RTQ5OTE1QzRBMjYyMzY0NEJCQTJBMjJBQkZCMA'); | |||
expect(key.kid).to.equal('NkFCNEE1NDFDNTQ5RTQ5OTE1QzRBMjYyMzY0NEJCQTJBMjJBQkZCMA'); | |||
}); | |||
|
|||
it.skip('Types-Only Validation with express-jwt', () => { |
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.
it.skip('Types-Only Validation with express-jwt', () => { | |
it('Types-Only Validation with express-jwt', () => { |
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.
I had a skip
marker here as I was only testing the transpilation, which was the issue at hand.
I've removed the skip marker in c98ac1f
Now, the test may fail at transpilation due to mismatched types.
Or it may fail if something throws at initialization.
I've purposely not duplicated the test suite from tests/express.es5.tests.js
as I didn't see any gains from doing so
@@ -24,7 +26,7 @@ describe('typescript definition', () => { | |||
}); | |||
}); | |||
|
|||
describe('getKeysInterceptor', async () => { | |||
it('getKeysInterceptor', async () => { |
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 spotting this, looks like you've uncovered a failing test.
Could you replace keySetResponse
with https://github.com/auth0/node-jwks-rsa/blob/master/tests/keys.js#L2 to fix
Going from types-only test to types & unexpected throw at initialization...
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 @carboneater!
import { Agent as HttpAgent } from 'http'; | ||
import { Agent as HttpsAgent } from 'https'; | ||
import type {Jwt, Secret} from 'jsonwebtoken' |
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 change makes jwks-rsa only compatible with Typescript 3.8+ as the type-only imports and exports feature was release with TS 3.8. For one of my projects, we are on TS 3.7.3, which means this breaks our compatibility
Also - this line is missing a semicolon :)
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.
Oops, my bad.
Internally, I'd say update typescript on the project.
If that's not possible, then you may want to open a merge request to address that issue
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.
No problem - we just attempted to upgrade and ran into a couple of other issues. We will be putting up a pull request soon!
By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.
Description
As described in #299, although the lib is able to use
express-jwt@7
, its type definitions were conflicting preventing any and all typescript users to usejwks-rsa@2
withexpress-jwt@7
References
#299
Testing
Testing of the types changes can be confirmed using
npm run clean:ts
npx tsc
(There won't be output, which is a success when compared to the errors we had previously)
Checklist
master