Repository navigation
fix(client/auth): sign private_key_jwt with an Ed25519 PEM key - #3165
Open
rodrigogaraujo wants to merge 1 commit into
Open
rodrigogaraujo wants to merge 1 commit into
rodrigogaraujo wants to merge 1 commit into
Conversation
createPrivateKeyJwtAuth() routed a PEM string to importPKCS8 only for RS*, ES* and PS* algorithms, so PrivateKeyJwtProvider with algorithm 'EdDSA' or 'Ed25519' threw "Unsupported algorithm EdDSA" before signing. The same key passed as a Uint8Array or a JWK already worked. Route Ed* algorithms to importPKCS8 as well; jose still rejects any it does not support. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d6034ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This branch has not been deployed
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.
createPrivateKeyJwtAuth(), whichPrivateKeyJwtProvideruses, now imports a PEM string key forEdDSAandEd25519instead of throwingUnsupported algorithm EdDSA.Motivation and Context
docs/clients/machine-auth.mdsaysprivateKey"accepts a PEM string, aUint8Array, or a JWK object". With an Ed25519 PKCS#8 PEM string andalgorithm: 'EdDSA',addClientAuthenticationthrows before the token request, soauth()fails. The same key works as aUint8Arrayholding the same PEM text, or as a JWK:On
main(1e608ca):The string-key branch in
packages/client/src/client/authExtensions.tssent onlyRS*,ES*andPS*tojose.importPKCS8;HS*is a shared secret and anything else throws. This change addsalg.startsWith('Ed')to that branch. jose 6 imports Ed25519 PKCS#8 keys for bothEdDSAandEd25519and rejects anything it does not support.nonestill throwsUnsupported algorithm none, as the existing tests expect. The SDK's DPoP support already listsEdDSAinDPOP_SUPPORTED_ALGS.How Has This Been Tested?
it.each(['EdDSA', 'Ed25519'])test inpackages/client/test/client/authExtensions.test.ts. It generates an Ed25519 key, passes it as a PEM string, and verifies the signed assertion with the public key (jose.jwtVerify). Both cases fail on unmodifiedmainwithError: Unsupported algorithm EdDSA/Ed25519and pass with this change.pnpm --filter @modelcontextprotocol/client testpasses (44 files, 1080 tests), as dotypecheckandlint.Breaking Changes
None. Only algorithms that used to throw before signing are affected.
Types of changes
Checklist
Additional context
Includes a patch changeset for
@modelcontextprotocol/client. The allow-list stays, sononeand unknown values keep the SDK's own error; jose 6 would also import ML-DSA keys, which this change leaves out to stay with the reported case.v1.xhas the same check insrc/client/auth-extensions.ts.AI assistance
Prepared with Claude Code (Claude Opus 5.5): investigation, fix, tests and this description. The reproduction was run on
main; the tests listed above were run onmainand with this change.🤖 Generated with Claude Code