diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 04ba17c90..4b08021a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 18.17.0 # Test on minimum supported version cache: npm - run: npm ci diff --git a/package.json b/package.json index 31bc3562c..1f1431fce 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "git+https://github.com/modelcontextprotocol/typescript-sdk.git" }, "engines": { - "node": ">=18" + "node": ">=18.17.0" }, "keywords": [ "modelcontextprotocol", diff --git a/src/shared/url-canparse.test.ts b/src/shared/url-canparse.test.ts new file mode 100644 index 000000000..2075d0945 --- /dev/null +++ b/src/shared/url-canparse.test.ts @@ -0,0 +1,22 @@ +import { describe, it, expect } from '@jest/globals'; + +describe('URL.canParse compatibility', () => { + it('should use URL.canParse which requires Node.js 18.17.0+', () => { + // This test will fail on Node.js < 18.17.0 + expect(typeof URL.canParse).toBe('function'); + + // Test that it works correctly + expect(URL.canParse('https://example.com')).toBe(true); + expect(URL.canParse('not-a-url')).toBe(false); + }); + + it('demonstrates the actual usage in our codebase', () => { + // This mimics how we use URL.canParse in auth.ts + const validateRedirectUri = (uri: string) => { + return URL.canParse(uri); + }; + + expect(validateRedirectUri('https://example.com/callback')).toBe(true); + expect(validateRedirectUri('invalid://[not-valid')).toBe(false); + }); +}); \ No newline at end of file