feat(backend): cache by optional kid param in loadClerkJWKFromLocal #5035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Updates
loadClerkJWKFromLocal
to accept an optional second parameterkid
that allows overriding the defaultlocal
cache key.Original behaviour preserved using default value for new
kid
field.I also updated the
loads the local key in PEM format
test to make use of the cache key override, because the original test would always be successful since the firstloads the local key
test would create a cache entry, so the logic to parse the key in the second test was skipped.A secondary note, while adding this and updating tests, I noticed the
throws an error if no key has been provided
test will only ever succeed if there is nothing in the cache for the cache key. I haven't changed this test as part of this PR but thought it was worth raising that the test does not work when there is a cached value, allowing passingundefined
to be successful. (I actually make use of this in a test to demonstrateloadClerkJWKFromLocal
using a custom cache key).Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change