Skip to content

Commit 36d4fb1

Browse files
test(compat): import OAuth subclasses from public surface; add StreamableHTTPError instanceof+status assertion; drop redundant cast
1 parent 28c5c7a commit 36d4fb1

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

packages/client/test/client/streamableHttp.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,9 @@ describe('StreamableHTTPClientTransport', () => {
18721872

18731873
const error = await transport.send(message).catch(e => e);
18741874
expect(error).toBeInstanceOf(SdkError);
1875+
expect(error).toBeInstanceOf(StreamableHTTPError);
18751876
expect((error as SdkError).code).toBe(SdkErrorCode.ClientHttpAuthentication);
1877+
expect((error as StreamableHTTPError).status).toBe(401);
18761878
expect(mockAuthProvider.saveTokens).toHaveBeenCalledWith({
18771879
access_token: 'new-access-token',
18781880
token_type: 'Bearer',

packages/core/src/errors/oauthErrorsCompat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type OAuthErrorSubclass = {
1717

1818
function sub(code: OAuthErrorCode, name: string): OAuthErrorSubclass {
1919
const Sub = class extends OAuthError {
20-
static errorCode = code as string;
20+
static errorCode = code;
2121
constructor(message: string, errorUri?: string) {
2222
super(code, message, errorUri);
2323
this.name = name;

packages/core/test/errors/compat.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it, vi } from 'vitest';
22
import {
3+
CustomOAuthError,
34
ErrorCode,
45
InvalidTokenError,
56
McpError,
@@ -9,9 +10,9 @@ import {
910
ProtocolErrorCode,
1011
SdkError,
1112
SdkErrorCode,
13+
ServerError,
1214
StreamableHTTPError
1315
} from '../../src/exports/public/index.js';
14-
import { CustomOAuthError, ServerError } from '../../src/errors/oauthErrorsCompat.js';
1516

1617
describe('v1-compat error aliases', () => {
1718
it('McpError / ErrorCode alias ProtocolError / ProtocolErrorCode (+ ConnectionClosed/RequestTimeout from SdkErrorCode)', () => {

0 commit comments

Comments
 (0)