File tree Expand file tree Collapse file tree
packages/client/test/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -783,14 +783,18 @@ include task vocabulary; the deprecated `Task*` types remain importable on their
783783| ` JSONRPCErrorSchema ` | ` JSONRPCErrorResponseSchema ` |
784784| ` isJSONRPCError ` | ` isJSONRPCErrorResponse ` |
785785| ` isJSONRPCResponse ` (deprecated in v1) | ` isJSONRPCResultResponse ` ² |
786+ | ` JSONRPCResponseSchema ` (result-only in v1) | ` JSONRPCResultResponseSchema ` ² |
787+ | ` JSONRPCResponse ` (result-only in v1) | ` JSONRPCResultResponse ` ² |
786788| ` ResourceReference ` / ` ResourceReferenceSchema ` | ` ResourceTemplateReference ` / ` ResourceTemplateReferenceSchema ` |
787789| ` IsomorphicHeaders ` | Web Standard ` Headers ` |
788790| ` RequestHandlerExtra ` | ` ServerContext ` / ` ClientContext ` / ` BaseContext ` |
789791| ` ResourceTemplate ` (the spec wire ** type** from ` sdk/types.js ` ) | ` ResourceTemplateType ` ³ |
790792
791- ² v2 introduces a ** new** ` isJSONRPCResponse ` with corrected semantics — it matches
792- ** both** result and error responses. v1's ` isJSONRPCResponse ` only matched results. To
793- preserve v1 behavior, rename to ` isJSONRPCResultResponse ` (the codemod does this).
793+ ² v2 introduces ** new** ` isJSONRPCResponse ` / ` JSONRPCResponse ` / ` JSONRPCResponseSchema `
794+ with corrected semantics — they match ** both** result and error responses (the schema is
795+ ` z.union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]) ` ). v1's symbols only
796+ matched results. To preserve v1 behavior, rename to ` isJSONRPCResultResponse ` /
797+ ` JSONRPCResultResponse ` / ` JSONRPCResultResponseSchema ` (the codemod does this).
794798
795799³ The ` ResourceTemplate ` URI-template helper ** class** (from ` sdk/server/mcp.js ` ) is
796800** unchanged** — keep ` new ResourceTemplate(...) ` as-is. Only the like-named spec wire
Original file line number Diff line number Diff line change @@ -155,6 +155,25 @@ describe('OAuth Authorization', () => {
155155 expect ( extractWWWAuthenticateParams ( mockResponse ) ) . toEqual ( { error : 'insufficient_scope' , scope : 'admin' } ) ;
156156 } ) ;
157157
158+ it ( 'parses invalid_token challenges with protected resource metadata' , async ( ) => {
159+ const resourceUrl = 'https://resource.example.com/.well-known/oauth-protected-resource/mcp' ;
160+ const mockResponse = {
161+ headers : {
162+ get : vi . fn ( name =>
163+ name === 'WWW-Authenticate'
164+ ? `Bearer resource_metadata="${ resourceUrl } ", error="invalid_token", error_description="The access token expired"`
165+ : null
166+ )
167+ }
168+ } as unknown as Response ;
169+
170+ expect ( extractWWWAuthenticateParams ( mockResponse ) ) . toEqual ( {
171+ resourceMetadataUrl : new URL ( resourceUrl ) ,
172+ error : 'invalid_token' ,
173+ errorDescription : 'The access token expired'
174+ } ) ;
175+ } ) ;
176+
158177 it ( 'returns error_description when present' , async ( ) => {
159178 const mockResponse = {
160179 headers : {
You can’t perform that action at this time.
0 commit comments