fastmcp 4.0.0 → 4.0.1
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 +2 -2
- package/dist/FastMCP.js +1 -1
- package/dist/{chunk-JP7QSER3.cjs → chunk-EXZZ3NKL.cjs} +102 -89
- package/dist/chunk-EXZZ3NKL.cjs.map +1 -0
- package/dist/{chunk-UVX47AE5.js → chunk-TNX4H4LB.js} +102 -89
- package/dist/{chunk-UVX47AE5.js.map → chunk-TNX4H4LB.js.map} +1 -1
- package/dist/examples/custom-routes.cjs +2 -2
- package/dist/examples/custom-routes.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-JP7QSER3.cjs.map +0 -1
|
@@ -1819,23 +1819,26 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1819
1819
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
1820
1820
|
try {
|
|
1821
1821
|
if (req.method === "POST" && url2.pathname === "/oauth/register") {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
error
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1822
|
+
await new Promise((resolve) => {
|
|
1823
|
+
let body = "";
|
|
1824
|
+
req.on("data", (chunk) => body += chunk);
|
|
1825
|
+
req.on("end", async () => {
|
|
1826
|
+
try {
|
|
1827
|
+
const request = JSON.parse(body);
|
|
1828
|
+
const response = await oauthProxy.registerClient(request);
|
|
1829
|
+
res.writeHead(201, { "Content-Type": "application/json" }).end(JSON.stringify(response));
|
|
1830
|
+
} catch (error) {
|
|
1831
|
+
const statusCode = error.statusCode || 400;
|
|
1832
|
+
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
1833
|
+
JSON.stringify(
|
|
1834
|
+
error.toJSON?.() || {
|
|
1835
|
+
error: "invalid_request"
|
|
1836
|
+
}
|
|
1837
|
+
)
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
resolve();
|
|
1841
|
+
});
|
|
1839
1842
|
});
|
|
1840
1843
|
return;
|
|
1841
1844
|
}
|
|
@@ -1886,82 +1889,93 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1886
1889
|
return;
|
|
1887
1890
|
}
|
|
1888
1891
|
if (req.method === "POST" && url2.pathname === "/oauth/consent") {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
if (location) {
|
|
1903
|
-
res.writeHead(response.status, { Location: location }).end();
|
|
1904
|
-
} else {
|
|
1905
|
-
const text = await response.text();
|
|
1906
|
-
res.writeHead(response.status).end(text);
|
|
1907
|
-
}
|
|
1908
|
-
} catch (error) {
|
|
1909
|
-
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
1910
|
-
JSON.stringify(
|
|
1911
|
-
error.toJSON?.() || {
|
|
1912
|
-
error: "server_error"
|
|
1892
|
+
await new Promise((resolve) => {
|
|
1893
|
+
let body = "";
|
|
1894
|
+
req.on("data", (chunk) => body += chunk);
|
|
1895
|
+
req.on("end", async () => {
|
|
1896
|
+
try {
|
|
1897
|
+
const mockRequest = new Request(
|
|
1898
|
+
`http://${host}/oauth/consent`,
|
|
1899
|
+
{
|
|
1900
|
+
body,
|
|
1901
|
+
headers: {
|
|
1902
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1903
|
+
},
|
|
1904
|
+
method: "POST"
|
|
1913
1905
|
}
|
|
1914
|
-
)
|
|
1915
|
-
|
|
1916
|
-
|
|
1906
|
+
);
|
|
1907
|
+
const response = await oauthProxy.handleConsent(mockRequest);
|
|
1908
|
+
const location = response.headers.get("Location");
|
|
1909
|
+
if (location) {
|
|
1910
|
+
res.writeHead(response.status, { Location: location }).end();
|
|
1911
|
+
} else {
|
|
1912
|
+
const text = await response.text();
|
|
1913
|
+
res.writeHead(response.status).end(text);
|
|
1914
|
+
}
|
|
1915
|
+
} catch (error) {
|
|
1916
|
+
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
1917
|
+
JSON.stringify(
|
|
1918
|
+
error.toJSON?.() || {
|
|
1919
|
+
error: "server_error"
|
|
1920
|
+
}
|
|
1921
|
+
)
|
|
1922
|
+
);
|
|
1923
|
+
}
|
|
1924
|
+
resolve();
|
|
1925
|
+
});
|
|
1917
1926
|
});
|
|
1918
1927
|
return;
|
|
1919
1928
|
}
|
|
1920
1929
|
if (req.method === "POST" && url2.pathname === "/oauth/token") {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1930
|
+
await new Promise((resolve) => {
|
|
1931
|
+
let body = "";
|
|
1932
|
+
req.on("data", (chunk) => body += chunk);
|
|
1933
|
+
req.on("end", async () => {
|
|
1934
|
+
try {
|
|
1935
|
+
const params = new URLSearchParams(body);
|
|
1936
|
+
const grantType = params.get("grant_type");
|
|
1937
|
+
const basicAuth = parseBasicAuthHeader(
|
|
1938
|
+
req.headers.authorization
|
|
1939
|
+
);
|
|
1940
|
+
const clientId = basicAuth?.clientId || params.get("client_id") || "";
|
|
1941
|
+
const clientSecret = basicAuth?.clientSecret ?? params.get("client_secret") ?? void 0;
|
|
1942
|
+
let response;
|
|
1943
|
+
if (grantType === "authorization_code") {
|
|
1944
|
+
response = await oauthProxy.exchangeAuthorizationCode({
|
|
1945
|
+
client_id: clientId,
|
|
1946
|
+
client_secret: clientSecret,
|
|
1947
|
+
code: params.get("code") || "",
|
|
1948
|
+
code_verifier: params.get("code_verifier") || void 0,
|
|
1949
|
+
grant_type: "authorization_code",
|
|
1950
|
+
redirect_uri: params.get("redirect_uri") || ""
|
|
1951
|
+
});
|
|
1952
|
+
} else if (grantType === "refresh_token") {
|
|
1953
|
+
response = await oauthProxy.exchangeRefreshToken({
|
|
1954
|
+
client_id: clientId,
|
|
1955
|
+
client_secret: clientSecret,
|
|
1956
|
+
grant_type: "refresh_token",
|
|
1957
|
+
refresh_token: params.get("refresh_token") || "",
|
|
1958
|
+
scope: params.get("scope") || void 0
|
|
1959
|
+
});
|
|
1960
|
+
} else {
|
|
1961
|
+
throw {
|
|
1962
|
+
statusCode: 400,
|
|
1963
|
+
toJSON: () => ({ error: "unsupported_grant_type" })
|
|
1964
|
+
};
|
|
1965
|
+
}
|
|
1966
|
+
res.writeHead(200, { "Content-Type": "application/json" }).end(JSON.stringify(response));
|
|
1967
|
+
} catch (error) {
|
|
1968
|
+
const statusCode = error.statusCode || 400;
|
|
1969
|
+
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
1970
|
+
JSON.stringify(
|
|
1971
|
+
error.toJSON?.() || {
|
|
1972
|
+
error: "invalid_request"
|
|
1973
|
+
}
|
|
1974
|
+
)
|
|
1975
|
+
);
|
|
1953
1976
|
}
|
|
1954
|
-
|
|
1955
|
-
}
|
|
1956
|
-
const statusCode = error.statusCode || 400;
|
|
1957
|
-
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
1958
|
-
JSON.stringify(
|
|
1959
|
-
error.toJSON?.() || {
|
|
1960
|
-
error: "invalid_request"
|
|
1961
|
-
}
|
|
1962
|
-
)
|
|
1963
|
-
);
|
|
1964
|
-
}
|
|
1977
|
+
resolve();
|
|
1978
|
+
});
|
|
1965
1979
|
});
|
|
1966
1980
|
return;
|
|
1967
1981
|
}
|
|
@@ -1971,7 +1985,6 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1971
1985
|
return;
|
|
1972
1986
|
}
|
|
1973
1987
|
}
|
|
1974
|
-
res.writeHead(404).end();
|
|
1975
1988
|
};
|
|
1976
1989
|
/**
|
|
1977
1990
|
* Converts Node.js IncomingMessage to Web Request for Hono
|
|
@@ -2107,4 +2120,4 @@ export {
|
|
|
2107
2120
|
FastMCPSession,
|
|
2108
2121
|
FastMCP
|
|
2109
2122
|
};
|
|
2110
|
-
//# sourceMappingURL=chunk-
|
|
2123
|
+
//# sourceMappingURL=chunk-TNX4H4LB.js.map
|