@mcp-ts/sdk 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -0
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.js +15 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +15 -0
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/server/mcp/oauth-client.ts +22 -0
package/dist/index.js
CHANGED
|
@@ -1783,6 +1783,13 @@ var RpcErrorCodes = {
|
|
|
1783
1783
|
};
|
|
1784
1784
|
|
|
1785
1785
|
// src/server/mcp/oauth-client.ts
|
|
1786
|
+
function isInvalidRefreshTokenError(error) {
|
|
1787
|
+
if (!(error instanceof Error)) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
const text = `${error.name} ${error.message}`.toLowerCase();
|
|
1791
|
+
return text.includes("invalidgrant") || text.includes("invalid_grant") || text.includes("invalid refresh token") || /refresh\s+token\s+(?:is\s+)?(?:invalid|expired|revoked)/i.test(text);
|
|
1792
|
+
}
|
|
1786
1793
|
var MCPClient = class _MCPClient {
|
|
1787
1794
|
/**
|
|
1788
1795
|
* Creates a new MCP client instance
|
|
@@ -2474,6 +2481,14 @@ var MCPClient = class _MCPClient {
|
|
|
2474
2481
|
return true;
|
|
2475
2482
|
} catch (error) {
|
|
2476
2483
|
console.error("[OAuth] Token refresh failed:", error);
|
|
2484
|
+
if (isInvalidRefreshTokenError(error)) {
|
|
2485
|
+
try {
|
|
2486
|
+
await this.oauthProvider.invalidateCredentials?.("tokens");
|
|
2487
|
+
this.emitProgress("OAuth refresh token is invalid; requesting reauthorization...");
|
|
2488
|
+
} catch (invalidateError) {
|
|
2489
|
+
console.warn("[OAuth] Failed to invalidate stale refresh token credentials:", invalidateError);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2477
2492
|
return false;
|
|
2478
2493
|
}
|
|
2479
2494
|
}
|