Skip to content

Conversation

DanOnCall
Copy link

@DanOnCall DanOnCall commented Apr 28, 2025

Please see the Changelog.md file for an outline of the changes this PR introduces. In summary:

  • Migrate to TypeScript.
  • Add support for Express v5.x.x.
  • Improve testing.
  • Align API with express-jwt.
  • Bump version to 3.0.0.

Testing Done

The existing test suite was migrated to TypeScript and expanded to validate all new and existing functionality. All tests pass successfully.

The testing strategy includes:

  • Full API Coverage: Validated all public functions and configuration options, including checkAllScopes, customUserKey, customScopeKey, and failWithError.
  • Authorization Logic: Confirmed correct handling of "any" vs. "all" scope checks, for both string-based and array-based scope claims in the JWT.
  • Robust Error Handling: Ensured that all documented error scenarios—such as insufficient scope, malformed JWT payloads, or invalid scope formats—produce the correct 403 error response or call next(err) as expected.
  • Express Compatibility: The full test suite was executed against both Express v4 and Express v5 to guarantee compatibility.
  • Static Type-Checking: The entire project, including tests, now passes strict TypeScript validation, ensuring the new type definitions are accurate and effective.

This ensures the v3.0.0 release is robust, type-safe, and backward-compatible with supported Express versions.

@gyaneshgouraw-okta
Copy link

Hey @DanOnCall can you also update the PR description with required testing you have done to validate the changes made.


### BREAKING CHANGES

- **Export Method:** The library now uses a named export (`export const jwtAuthz`) instead of `module.exports`. CommonJS consumers must update their `require` statements from `const jwtAuthz = require('express-jwt-authz');` to `const { jwtAuthz } = require('express-jwt-authz');`. ES Module imports (`import { jwtAuthz } from ...`) remain unchanged.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @DanOnCall
Can you also add a migration guide from v2 to v3 to follow up this changelog.
That would assist developers in quickly grasping the changes required to to move to v3.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added such document. Thanks for pointing this out. 🙏

package.json Outdated
@@ -41,7 +55,6 @@
"node": ">=6"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanOnCall have we verified if this supported node version with new major version still holds true ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Thank you. I bumped the supported min version to 14 and documented the reasoning in the changelog.

@johnmcase johnmcase mentioned this pull request Jun 6, 2025
4 tasks
@DanOnCall
Copy link
Author

Hey @DanOnCall can you also update the PR description with required testing you have done to validate the changes made.

All done! Thanks for your review 🙏

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

Successfully merging this pull request may close these issues.

2 participants