Skip to content

Conversation

@cschetan77
Copy link
Contributor

@cschetan77 cschetan77 commented Jan 20, 2026

Description

Problem

Previously, the SDK required consumers to always provide a jwksUri, even when a custom fetcher was supplied. However, when a custom fetcher is used (which can retrieve keys from any endpoint), requiring jwksUri is unnecessary and restrictive. The current type definitions did not reflect this flexibility, forcing consumers to provide redundant configuration.

Solution

This PR updates the type definitions to accurately model the intended usage:

The Options type is now a union:

  • When a fetcher is provided, jwksUri is optional.
  • When a fetcher is not provided, jwksUri is required.

Because TypeScript interfaces cannot extend union types, the following types have been changed from interfaces to type aliases using intersections:

  • ExpressJwtOptions
  • HapiJwtOptions
  • KoaJwtOptions

This change allows consumers to omit jwksUri when supplying a custom fetcher, improving developer experience and aligning the types with actual SDK behavior.

Potential Breakage

Since JwksRsa.Options has been changed from interface to type, if consumer tries to extend or implement Options, that will fail -

  • interfaces cannot extend a union type, interface X extends JwksRsa.Options {}.
  • classes cannot implement a union type.

References

#440

Testing

  • If fetcher is provided, jwksUri is optional to pass and typescript compilation does not throw any error.

@cschetan77 cschetan77 requested a review from a team as a code owner January 20, 2026 02:12
@cschetan77 cschetan77 added the gen-ai AI was used for this PR label Jan 20, 2026
nandan-bhat
nandan-bhat previously approved these changes Jan 22, 2026
@cschetan77 cschetan77 linked an issue Jan 23, 2026 that may be closed by this pull request
4 tasks
Bumps [jws](https://github.com/brianloveswords/node-jws) from 3.2.2 to 3.2.3.
- [Release notes](https://github.com/brianloveswords/node-jws/releases)
- [Changelog](https://github.com/auth0/node-jws/blob/master/CHANGELOG.md)
- [Commits](auth0/node-jws@v3.2.2...v3.2.3)

---
updated-dependencies:
- dependency-name: jws
  dependency-version: 3.2.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
@cschetan77 cschetan77 merged commit db11279 into master Jan 23, 2026
12 checks passed
@cschetan77 cschetan77 deleted the fix/jwksUri-optional branch January 23, 2026 09:25
@cschetan77 cschetan77 mentioned this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gen-ai AI was used for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jwksUri option should be optional

4 participants