fix: drop dependency on jwk-to-pem by using native crypto#1283
Merged
coopernetes merged 7 commits intofinos:mainfrom Dec 15, 2025
Merged
fix: drop dependency on jwk-to-pem by using native crypto#1283coopernetes merged 7 commits intofinos:mainfrom
coopernetes merged 7 commits intofinos:mainfrom
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
|
|
This replaces jwk-to-pem with simply using crypto.createPublicKey. This further drops elliptic from the dependency tree, which has known security issues (note this is mostly for hygiene as jwk-to-pem doesn't use the vulnerable code paths, per Brightspace/node-jwk-to-pem#187).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1283 +/- ##
==========================================
+ Coverage 80.64% 80.65% +0.01%
==========================================
Files 65 65
Lines 4572 4575 +3
Branches 776 774 -2
==========================================
+ Hits 3687 3690 +3
Misses 870 870
Partials 15 15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jescalada
approved these changes
Nov 24, 2025
Contributor
jescalada
left a comment
There was a problem hiding this comment.
Looks good to me! I added a test that uses crypto.createPublicKey, but it still injects the getJwks stub function for validateJwt. Do you think this is sufficient? @dgl
it('should validate a JWT generated with crypto.createPublicKey', async () => {
const { privateKey, publicKey } = generateRsaKeyPair();
const jwk = publicKeyToJwk(publicKey, 'my-kid');
const tokenPayload = jwt.sign(
{
sub: 'user123',
azp: 'client-id',
admin: 'admin',
},
privateKey,
{
algorithm: 'RS256',
issuer: 'https://issuer.com',
audience: 'client-id',
keyid: 'my-kid',
}
);
const getJwksStub = sinon.stub().resolves([jwk]);
const { verifiedPayload, error } = await validateJwt(
tokenPayload,
'https://issuer.com',
'client-id',
'client-id',
getJwksStub
);
expect(error).to.be.null;
expect(verifiedPayload.sub).to.equal('user123');
expect(verifiedPayload.admin).to.equal('admin');
});
40 tasks
42 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This replaces jwk-to-pem with simply using crypto.createPublicKey. This further drops elliptic from the dependency tree, which has known security issues (note this is mostly for hygiene as jwk-to-pem doesn't use the vulnerable code paths, per
Brightspace/node-jwk-to-pem#187).