chore: switch to module ESNext + moduleResolution bundler (#2095)
This commit is contained in:
parent
c59dc3aa1a
commit
ee732d64b6
10 changed files with 668 additions and 863 deletions
|
|
@ -3,7 +3,7 @@ import { LATEST_PROTOCOL_VERSION, OAuthError, OAuthErrorCode } from '@modelconte
|
|||
import type { Mock } from 'vitest';
|
||||
import { expect, vi } from 'vitest';
|
||||
|
||||
import type { OAuthClientProvider } from '../../src/client/auth.js';
|
||||
import type { OAuthClientProvider } from '../../src/client/auth';
|
||||
import {
|
||||
auth,
|
||||
buildDiscoveryUrls,
|
||||
|
|
@ -20,8 +20,8 @@ import {
|
|||
selectClientAuthMethod,
|
||||
startAuthorization,
|
||||
validateClientMetadataUrl
|
||||
} from '../../src/client/auth.js';
|
||||
import { createPrivateKeyJwtAuth } from '../../src/client/authExtensions.js';
|
||||
} from '../../src/client/auth';
|
||||
import { createPrivateKeyJwtAuth } from '../../src/client/authExtensions';
|
||||
|
||||
// Mock pkce-challenge
|
||||
vi.mock('pkce-challenge', () => ({
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { createMockOAuthFetch } from '@modelcontextprotocol/test-helpers';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { auth } from '../../src/client/auth.js';
|
||||
import { auth } from '../../src/client/auth';
|
||||
import {
|
||||
ClientCredentialsProvider,
|
||||
createPrivateKeyJwtAuth,
|
||||
CrossAppAccessProvider,
|
||||
PrivateKeyJwtProvider,
|
||||
StaticPrivateKeyJwtProvider
|
||||
} from '../../src/client/authExtensions.js';
|
||||
} from '../../src/client/authExtensions';
|
||||
|
||||
const RESOURCE_SERVER_URL = 'https://resource.example.com/';
|
||||
const AUTH_SERVER_URL = 'https://auth.example.com';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { FetchLike } from '@modelcontextprotocol/core';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { discoverAndRequestJwtAuthGrant, exchangeJwtAuthGrant, requestJwtAuthorizationGrant } from '../../src/client/crossAppAccess.js';
|
||||
import { discoverAndRequestJwtAuthGrant, exchangeJwtAuthGrant, requestJwtAuthorizationGrant } from '../../src/client/crossAppAccess';
|
||||
|
||||
describe('crossAppAccess', () => {
|
||||
describe('requestJwtAuthorizationGrant', () => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import type { JSONRPCMessage } from '@modelcontextprotocol/core';
|
|||
import spawn from 'cross-spawn';
|
||||
import type { Mock, MockedFunction } from 'vitest';
|
||||
|
||||
import { getDefaultEnvironment, StdioClientTransport } from '../../src/client/stdio.js';
|
||||
import { getDefaultEnvironment, StdioClientTransport } from '../../src/client/stdio';
|
||||
|
||||
// mock cross-spawn
|
||||
vi.mock('cross-spawn');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { JSONRPCMessage, JsonSchemaType, JsonSchemaValidatorResult, jsonSchemaValidator } from '@modelcontextprotocol/core';
|
||||
import { InMemoryTransport, LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/core';
|
||||
import { Client } from '../../src/client/client.js';
|
||||
import { fromJsonSchema } from '../../src/fromJsonSchema.js';
|
||||
import { Client } from '../../src/client/client';
|
||||
import { fromJsonSchema } from '../../src/fromJsonSchema';
|
||||
|
||||
class RecordingValidator implements jsonSchemaValidator {
|
||||
schemas: JsonSchemaType[] = [];
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import type { FetchLike } from '@modelcontextprotocol/core';
|
||||
import type { Mocked, MockedFunction, MockInstance } from 'vitest';
|
||||
|
||||
import type { OAuthClientProvider } from '../../src/client/auth.js';
|
||||
import { applyMiddlewares, createMiddleware, withLogging, withOAuth } from '../../src/client/middleware.js';
|
||||
import type { OAuthClientProvider } from '../../src/client/auth';
|
||||
import { applyMiddlewares, createMiddleware, withLogging, withOAuth } from '../../src/client/middleware';
|
||||
|
||||
vi.mock('../../src/client/auth.js', async () => {
|
||||
const actual = await vi.importActual<typeof import('../../src/client/auth.js')>('../../src/client/auth.js');
|
||||
vi.mock('../../src/client/auth', async () => {
|
||||
const actual = await vi.importActual<typeof import('../../src/client/auth')>('../../src/client/auth');
|
||||
return {
|
||||
...actual,
|
||||
auth: vi.fn(),
|
||||
|
|
@ -13,7 +13,7 @@ vi.mock('../../src/client/auth.js', async () => {
|
|||
};
|
||||
});
|
||||
|
||||
import { auth, extractWWWAuthenticateParams } from '../../src/client/auth.js';
|
||||
import { auth, extractWWWAuthenticateParams } from '../../src/client/auth';
|
||||
|
||||
const mockAuth = auth as MockedFunction<typeof auth>;
|
||||
const mockExtractWWWAuthenticateParams = extractWWWAuthenticateParams as MockedFunction<typeof extractWWWAuthenticateParams>;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import { OAuthError, OAuthErrorCode, SdkErrorCode, SdkHttpError } from '@modelco
|
|||
import { listenOnRandomPort } from '@modelcontextprotocol/test-helpers';
|
||||
import type { Mock, Mocked, MockedFunction, MockInstance } from 'vitest';
|
||||
|
||||
import type { AuthProvider, OAuthClientProvider } from '../../src/client/auth.js';
|
||||
import { UnauthorizedError } from '../../src/client/auth.js';
|
||||
import { SSEClientTransport } from '../../src/client/sse.js';
|
||||
import type { AuthProvider, OAuthClientProvider } from '../../src/client/auth';
|
||||
import { UnauthorizedError } from '../../src/client/auth';
|
||||
import { SSEClientTransport } from '../../src/client/sse';
|
||||
|
||||
/**
|
||||
* Parses HTTP Basic auth from a request's Authorization header.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { JSONRPCMessage } from '@modelcontextprotocol/core';
|
||||
|
||||
import type { StdioServerParameters } from '../../src/client/stdio.js';
|
||||
import { StdioClientTransport } from '../../src/client/stdio.js';
|
||||
import type { StdioServerParameters } from '../../src/client/stdio';
|
||||
import { StdioClientTransport } from '../../src/client/stdio';
|
||||
|
||||
// Configure default server parameters based on OS
|
||||
// Uses 'more' command for Windows and 'tee' command for Unix/Linux
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import type { JSONRPCMessage, JSONRPCRequest } from '@modelcontextprotocol/core'
|
|||
import { OAuthError, OAuthErrorCode, SdkErrorCode, SdkHttpError } from '@modelcontextprotocol/core';
|
||||
import type { Mock, Mocked } from 'vitest';
|
||||
|
||||
import type { OAuthClientProvider } from '../../src/client/auth.js';
|
||||
import { UnauthorizedError } from '../../src/client/auth.js';
|
||||
import type { ReconnectionScheduler, StartSSEOptions, StreamableHTTPReconnectionOptions } from '../../src/client/streamableHttp.js';
|
||||
import { StreamableHTTPClientTransport } from '../../src/client/streamableHttp.js';
|
||||
import type { OAuthClientProvider } from '../../src/client/auth';
|
||||
import { UnauthorizedError } from '../../src/client/auth';
|
||||
import type { ReconnectionScheduler, StartSSEOptions, StreamableHTTPReconnectionOptions } from '../../src/client/streamableHttp';
|
||||
import { StreamableHTTPClientTransport } from '../../src/client/streamableHttp';
|
||||
|
||||
describe('StreamableHTTPClientTransport', () => {
|
||||
let transport: StreamableHTTPClientTransport;
|
||||
|
|
@ -813,7 +813,7 @@ describe('StreamableHTTPClientTransport', () => {
|
|||
});
|
||||
|
||||
// Spy on the imported auth function and mock successful authorization
|
||||
const authModule = await import('../../src/client/auth.js');
|
||||
const authModule = await import('../../src/client/auth');
|
||||
const authSpy = vi.spyOn(authModule, 'auth');
|
||||
authSpy.mockResolvedValue('AUTHORIZED');
|
||||
|
||||
|
|
@ -855,8 +855,8 @@ describe('StreamableHTTPClientTransport', () => {
|
|||
});
|
||||
|
||||
// Spy on the imported auth function and mock successful authorization
|
||||
const authModule = await import('../../src/client/auth.js');
|
||||
const authSpy = vi.spyOn(authModule as typeof import('../../src/client/auth.js'), 'auth');
|
||||
const authModule = await import('../../src/client/auth');
|
||||
const authSpy = vi.spyOn(authModule as typeof import('../../src/client/auth'), 'auth');
|
||||
authSpy.mockResolvedValue('AUTHORIZED');
|
||||
|
||||
// First send: should trigger upscoping
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import { SdkErrorCode, SdkHttpError } from '@modelcontextprotocol/core';
|
|||
import { listenOnRandomPort } from '@modelcontextprotocol/test-helpers';
|
||||
import type { Mock } from 'vitest';
|
||||
|
||||
import type { AuthProvider, OAuthClientProvider } from '../../src/client/auth.js';
|
||||
import { UnauthorizedError } from '../../src/client/auth.js';
|
||||
import { StreamableHTTPClientTransport } from '../../src/client/streamableHttp.js';
|
||||
import type { AuthProvider, OAuthClientProvider } from '../../src/client/auth';
|
||||
import { UnauthorizedError } from '../../src/client/auth';
|
||||
import { StreamableHTTPClientTransport } from '../../src/client/streamableHttp';
|
||||
|
||||
describe('StreamableHTTPClientTransport with AuthProvider', () => {
|
||||
let transport: StreamableHTTPClientTransport;
|
||||
|
|
|
|||
Loading…
Reference in a new issue