fastmcp 4.23.11 → 4.23.12
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/FastMCP.cjs +3 -3
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +2 -2
- package/dist/{OAuthProvider-BcDb5bOz.d.cts → OAuthProvider-84BWWDBF.d.cts} +55 -1
- package/dist/{OAuthProvider-BcDb5bOz.d.ts → OAuthProvider-84BWWDBF.d.ts} +55 -1
- package/dist/auth/index.cjs +4 -2
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +10 -2
- package/dist/auth/index.d.ts +10 -2
- package/dist/auth/index.js +3 -1
- package/dist/{chunk-X5ITW7FV.cjs → chunk-4P2GDM7W.cjs} +74 -35
- package/dist/chunk-4P2GDM7W.cjs.map +1 -0
- package/dist/{chunk-4OWHPJEL.cjs → chunk-BV4PWTT6.cjs} +214 -43
- package/dist/chunk-BV4PWTT6.cjs.map +1 -0
- package/dist/{chunk-G44SPVP7.js → chunk-CAQLTSJ5.js} +211 -40
- package/dist/chunk-CAQLTSJ5.js.map +1 -0
- package/dist/{chunk-XUUJOVC7.js → chunk-ULNQF5KG.js} +57 -18
- package/dist/chunk-ULNQF5KG.js.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +7 -7
- package/dist/openapi/index.d.cts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4OWHPJEL.cjs.map +0 -1
- package/dist/chunk-G44SPVP7.js.map +0 -1
- package/dist/chunk-X5ITW7FV.cjs.map +0 -1
- package/dist/chunk-XUUJOVC7.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cancelResponseBody
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CAQLTSJ5.js";
|
|
4
4
|
import {
|
|
5
5
|
objectRootSchema,
|
|
6
6
|
strictInputSchema,
|
|
@@ -1914,15 +1914,20 @@ function normalizePath(path) {
|
|
|
1914
1914
|
return path.startsWith("/") ? path : `/${path}`;
|
|
1915
1915
|
}
|
|
1916
1916
|
function parseBasicAuthHeader(authHeader) {
|
|
1917
|
-
const basicMatch = authHeader?.match(/^Basic\s+(
|
|
1917
|
+
const basicMatch = authHeader?.match(/^Basic\s+(.*)$/i);
|
|
1918
1918
|
if (!basicMatch) return null;
|
|
1919
|
+
const credentials = Buffer.from(basicMatch[1].trim(), "base64").toString(
|
|
1920
|
+
"utf-8"
|
|
1921
|
+
);
|
|
1922
|
+
const separator = credentials.indexOf(":");
|
|
1923
|
+
if (separator <= 0) return "malformed";
|
|
1919
1924
|
try {
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1925
|
+
return {
|
|
1926
|
+
clientId: decodeURIComponent(credentials.slice(0, separator)),
|
|
1927
|
+
clientSecret: decodeURIComponent(credentials.slice(separator + 1))
|
|
1928
|
+
};
|
|
1924
1929
|
} catch {
|
|
1925
|
-
return
|
|
1930
|
+
return "malformed";
|
|
1926
1931
|
}
|
|
1927
1932
|
}
|
|
1928
1933
|
function parseBooleanSetting(value, source) {
|
|
@@ -1971,6 +1976,10 @@ var OAUTH_CREDENTIAL_RESPONSE_HEADERS = {
|
|
|
1971
1976
|
"Content-Type": "application/json",
|
|
1972
1977
|
Pragma: "no-cache"
|
|
1973
1978
|
};
|
|
1979
|
+
var OAUTH_INVALID_CLIENT_RESPONSE_HEADERS = {
|
|
1980
|
+
...OAUTH_CREDENTIAL_RESPONSE_HEADERS,
|
|
1981
|
+
"WWW-Authenticate": 'Basic realm="oauth", charset="UTF-8"'
|
|
1982
|
+
};
|
|
1974
1983
|
function stripBasePath(path, basePath) {
|
|
1975
1984
|
if (!basePath) {
|
|
1976
1985
|
return path;
|
|
@@ -3054,8 +3063,37 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3054
3063
|
const basicAuth = parseBasicAuthHeader(
|
|
3055
3064
|
req.headers.authorization
|
|
3056
3065
|
);
|
|
3057
|
-
|
|
3058
|
-
|
|
3066
|
+
if (basicAuth === "malformed") {
|
|
3067
|
+
throw {
|
|
3068
|
+
toJSON: () => ({
|
|
3069
|
+
error: "invalid_client",
|
|
3070
|
+
error_description: "Malformed Basic Authorization header"
|
|
3071
|
+
})
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
if (basicAuth) {
|
|
3075
|
+
if (params.has("client_secret")) {
|
|
3076
|
+
throw {
|
|
3077
|
+
statusCode: 400,
|
|
3078
|
+
toJSON: () => ({
|
|
3079
|
+
error: "invalid_request",
|
|
3080
|
+
error_description: "Send client credentials in the Authorization header or the request body, not both"
|
|
3081
|
+
})
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
const bodyClientId = params.get("client_id");
|
|
3085
|
+
if (bodyClientId !== null && bodyClientId !== basicAuth.clientId) {
|
|
3086
|
+
throw {
|
|
3087
|
+
statusCode: 400,
|
|
3088
|
+
toJSON: () => ({
|
|
3089
|
+
error: "invalid_request",
|
|
3090
|
+
error_description: "client_id in the request body does not match the Authorization header"
|
|
3091
|
+
})
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
const clientId = basicAuth ? basicAuth.clientId : params.get("client_id") || "";
|
|
3096
|
+
const clientSecret = basicAuth ? basicAuth.clientSecret : params.get("client_secret") ?? void 0;
|
|
3059
3097
|
let response;
|
|
3060
3098
|
if (grantType === "authorization_code") {
|
|
3061
3099
|
response = await oauthProxy.exchangeAuthorizationCode({
|
|
@@ -3082,14 +3120,15 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3082
3120
|
}
|
|
3083
3121
|
res.writeHead(200, OAUTH_CREDENTIAL_RESPONSE_HEADERS).end(JSON.stringify(response));
|
|
3084
3122
|
} catch (error) {
|
|
3085
|
-
const
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3123
|
+
const body = error.toJSON?.() || {
|
|
3124
|
+
error: "invalid_request"
|
|
3125
|
+
};
|
|
3126
|
+
if (body.error === "invalid_client") {
|
|
3127
|
+
res.writeHead(401, OAUTH_INVALID_CLIENT_RESPONSE_HEADERS).end(JSON.stringify(body));
|
|
3128
|
+
} else {
|
|
3129
|
+
const statusCode = error.statusCode || 400;
|
|
3130
|
+
res.writeHead(statusCode, OAUTH_CREDENTIAL_RESPONSE_HEADERS).end(JSON.stringify(body));
|
|
3131
|
+
}
|
|
3093
3132
|
}
|
|
3094
3133
|
resolve();
|
|
3095
3134
|
});
|
|
@@ -3355,4 +3394,4 @@ export {
|
|
|
3355
3394
|
FastMCPSession,
|
|
3356
3395
|
FastMCP
|
|
3357
3396
|
};
|
|
3358
|
-
//# sourceMappingURL=chunk-
|
|
3397
|
+
//# sourceMappingURL=chunk-ULNQF5KG.js.map
|