fastmcp 4.27.0 → 4.28.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 +4 -4
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +3 -3
- package/dist/{OAuthProvider-CUfrAKTR.d.cts → OAuthProvider-DvIxa9N1.d.cts} +8 -5
- package/dist/{OAuthProvider-CUfrAKTR.d.ts → OAuthProvider-DvIxa9N1.d.ts} +8 -5
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-SQ5JIDOQ.cjs → chunk-2ABBQFJB.cjs} +28 -13
- package/dist/chunk-2ABBQFJB.cjs.map +1 -0
- package/dist/chunk-2NZFMD6I.cjs +120 -0
- package/dist/chunk-2NZFMD6I.cjs.map +1 -0
- package/dist/{chunk-PKJVR5H3.cjs → chunk-3FM67CFK.cjs} +58 -49
- package/dist/chunk-3FM67CFK.cjs.map +1 -0
- package/dist/chunk-AM3HVK4Z.js +120 -0
- package/dist/chunk-AM3HVK4Z.js.map +1 -0
- package/dist/{chunk-TCXNF2SR.js → chunk-NRATQX66.js} +22 -7
- package/dist/chunk-NRATQX66.js.map +1 -0
- package/dist/{chunk-6L7ORLPC.js → chunk-PWSYODM5.js} +49 -40
- package/dist/chunk-PWSYODM5.js.map +1 -0
- package/dist/edge/index.cjs +114 -65
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.js +90 -41
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +4 -4
- package/dist/examples/custom-routes.js +3 -3
- package/dist/openapi/index.cjs +26 -15
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +4 -4
- package/dist/openapi/index.d.ts +4 -4
- package/dist/openapi/index.js +20 -9
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6L7ORLPC.js.map +0 -1
- package/dist/chunk-6TDYSPLC.cjs +0 -44
- package/dist/chunk-6TDYSPLC.cjs.map +0 -1
- package/dist/chunk-OKKFL2M4.js +0 -44
- package/dist/chunk-OKKFL2M4.js.map +0 -1
- package/dist/chunk-PKJVR5H3.cjs.map +0 -1
- package/dist/chunk-SQ5JIDOQ.cjs.map +0 -1
- package/dist/chunk-TCXNF2SR.js.map +0 -1
|
@@ -1322,6 +1322,7 @@ var MemoryTokenStorage = class {
|
|
|
1322
1322
|
() => void this.cleanup(),
|
|
1323
1323
|
cleanupIntervalMs
|
|
1324
1324
|
);
|
|
1325
|
+
this.cleanupInterval.unref?.();
|
|
1325
1326
|
}
|
|
1326
1327
|
async cleanup() {
|
|
1327
1328
|
const now = Date.now();
|
|
@@ -1394,7 +1395,8 @@ var DEFAULT_PORTS = {
|
|
|
1394
1395
|
"ws:": "80",
|
|
1395
1396
|
"wss:": "443"
|
|
1396
1397
|
};
|
|
1397
|
-
var
|
|
1398
|
+
var GENERATED_ID = /^[\w-]{43}$/;
|
|
1399
|
+
var OAUTH_ERROR_TEXT = /^[\x20-\x21\x23-\x5b\x5d-\x7e]+$/;
|
|
1398
1400
|
var MAX_CLIENT_REGISTRATION_BYTES = 32 * 1024;
|
|
1399
1401
|
var RESERVED_AUTHORIZATION_PARAMS = /* @__PURE__ */ new Set([
|
|
1400
1402
|
"client_id",
|
|
@@ -1416,11 +1418,9 @@ var OAuthProxy = class {
|
|
|
1416
1418
|
consentManager;
|
|
1417
1419
|
jwtIssuer;
|
|
1418
1420
|
/**
|
|
1419
|
-
* The fallback storage this proxy created for itself, if any.
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
* through nothing else. A caller-supplied storage is deliberately not
|
|
1423
|
-
* recorded here: its lifetime belongs to the caller.
|
|
1421
|
+
* The fallback storage this proxy created for itself, if any. Keep a
|
|
1422
|
+
* reference so `destroy()` can stop its cleanup timer even when the storage
|
|
1423
|
+
* is wrapped for encryption. Caller-supplied storage has its own lifetime.
|
|
1424
1424
|
*/
|
|
1425
1425
|
ownedTokenStorage = null;
|
|
1426
1426
|
/**
|
|
@@ -1728,25 +1728,35 @@ var OAuthProxy = class {
|
|
|
1728
1728
|
]
|
|
1729
1729
|
};
|
|
1730
1730
|
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Get the configured OAuth callback path, including the default.
|
|
1733
|
+
*/
|
|
1734
|
+
getRedirectPath() {
|
|
1735
|
+
return this.config.redirectPath;
|
|
1736
|
+
}
|
|
1731
1737
|
/**
|
|
1732
1738
|
* Handle OAuth callback from upstream provider
|
|
1733
1739
|
*/
|
|
1734
1740
|
async handleCallback(request) {
|
|
1735
1741
|
const url = new URL(request.url);
|
|
1736
|
-
const code = url.searchParams.get("code");
|
|
1742
|
+
const code = url.searchParams.get("code") ?? "";
|
|
1737
1743
|
const state = url.searchParams.get("state");
|
|
1738
1744
|
const error = url.searchParams.get("error");
|
|
1745
|
+
const description = url.searchParams.get("error_description") || void 0;
|
|
1739
1746
|
if (error) {
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
if (!code || !state) {
|
|
1747
|
+
if (!state || url.searchParams.getAll("state").length !== 1 || !GENERATED_ID.test(state) || !OAUTH_ERROR_TEXT.test(error) || description && !OAUTH_ERROR_TEXT.test(description) || (await this.stateStore.getTransaction(state))?.id !== state) {
|
|
1748
|
+
throw new OAuthProxyError(error, description);
|
|
1749
|
+
}
|
|
1750
|
+
} else if (!code || !state) {
|
|
1744
1751
|
throw new OAuthProxyError(
|
|
1745
1752
|
"invalid_request",
|
|
1746
1753
|
"Missing code or state parameter"
|
|
1747
1754
|
);
|
|
1748
1755
|
}
|
|
1749
1756
|
const transaction = await this.stateStore.consumeTransaction(state);
|
|
1757
|
+
if (error && (transaction?.id !== state || transaction.expiresAt.getTime() <= Date.now())) {
|
|
1758
|
+
throw new OAuthProxyError(error, description);
|
|
1759
|
+
}
|
|
1750
1760
|
if (!transaction) {
|
|
1751
1761
|
throw new OAuthProxyError("invalid_request", "Invalid or expired state");
|
|
1752
1762
|
}
|
|
@@ -1762,23 +1772,18 @@ var OAuthProxy = class {
|
|
|
1762
1772
|
"Transaction callback URL is not registered"
|
|
1763
1773
|
);
|
|
1764
1774
|
}
|
|
1775
|
+
if (error) {
|
|
1776
|
+
return this.redirectToClient(transaction, {
|
|
1777
|
+
error,
|
|
1778
|
+
error_description: description
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1765
1781
|
const upstreamTokens = await this.exchangeUpstreamCode(code, transaction);
|
|
1766
1782
|
const clientCode = await this.generateAuthorizationCode(
|
|
1767
1783
|
transaction,
|
|
1768
1784
|
upstreamTokens
|
|
1769
1785
|
);
|
|
1770
|
-
|
|
1771
|
-
redirectUrl.searchParams.set("code", clientCode);
|
|
1772
|
-
redirectUrl.searchParams.set("state", transaction.state);
|
|
1773
|
-
if (this.config.authorizationResponseIss) {
|
|
1774
|
-
redirectUrl.searchParams.set("iss", this.config.baseUrl);
|
|
1775
|
-
}
|
|
1776
|
-
return new Response(null, {
|
|
1777
|
-
headers: {
|
|
1778
|
-
Location: redirectUrl.toString()
|
|
1779
|
-
},
|
|
1780
|
-
status: 302
|
|
1781
|
-
});
|
|
1786
|
+
return this.redirectToClient(transaction, { code: clientCode });
|
|
1782
1787
|
}
|
|
1783
1788
|
/**
|
|
1784
1789
|
* Handle consent form submission
|
|
@@ -1817,21 +1822,9 @@ var OAuthProxy = class {
|
|
|
1817
1822
|
"Transaction callback URL is not registered"
|
|
1818
1823
|
);
|
|
1819
1824
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
"error_description",
|
|
1824
|
-
"User denied authorization"
|
|
1825
|
-
);
|
|
1826
|
-
redirectUrl.searchParams.set("state", transaction.state);
|
|
1827
|
-
if (this.config.authorizationResponseIss) {
|
|
1828
|
-
redirectUrl.searchParams.set("iss", this.config.baseUrl);
|
|
1829
|
-
}
|
|
1830
|
-
return new Response(null, {
|
|
1831
|
-
headers: {
|
|
1832
|
-
Location: redirectUrl.toString()
|
|
1833
|
-
},
|
|
1834
|
-
status: 302
|
|
1825
|
+
return this.redirectToClient(transaction, {
|
|
1826
|
+
error: "access_denied",
|
|
1827
|
+
error_description: "User denied authorization"
|
|
1835
1828
|
});
|
|
1836
1829
|
}
|
|
1837
1830
|
const approvedTransaction = {
|
|
@@ -2059,7 +2052,7 @@ var OAuthProxy = class {
|
|
|
2059
2052
|
const separator = pair.indexOf("=");
|
|
2060
2053
|
if (separator !== -1 && withoutOptionalWhitespace(pair.slice(0, separator)) === name) {
|
|
2061
2054
|
const value = withoutOptionalWhitespace(pair.slice(separator + 1));
|
|
2062
|
-
return
|
|
2055
|
+
return GENERATED_ID.test(value) ? value : void 0;
|
|
2063
2056
|
}
|
|
2064
2057
|
}
|
|
2065
2058
|
return void 0;
|
|
@@ -2690,6 +2683,20 @@ var OAuthProxy = class {
|
|
|
2690
2683
|
passthroughRefreshKey(refreshToken) {
|
|
2691
2684
|
return `passthrough-refresh:${sha256(refreshToken)}`;
|
|
2692
2685
|
}
|
|
2686
|
+
redirectToClient(transaction, params) {
|
|
2687
|
+
const url = new URL(transaction.clientCallbackUrl);
|
|
2688
|
+
for (const [name, value] of Object.entries(params)) {
|
|
2689
|
+
if (value !== void 0) url.searchParams.set(name, value);
|
|
2690
|
+
}
|
|
2691
|
+
url.searchParams.set("state", transaction.state);
|
|
2692
|
+
if (this.config.authorizationResponseIss) {
|
|
2693
|
+
url.searchParams.set("iss", this.config.baseUrl);
|
|
2694
|
+
}
|
|
2695
|
+
return new Response(null, {
|
|
2696
|
+
headers: { Location: url.toString() },
|
|
2697
|
+
status: 302
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2693
2700
|
/**
|
|
2694
2701
|
* Redirect to upstream OAuth provider
|
|
2695
2702
|
*/
|
|
@@ -2867,6 +2874,7 @@ var OAuthProxy = class {
|
|
|
2867
2874
|
this.cleanupInterval = setInterval(() => {
|
|
2868
2875
|
this.cleanup();
|
|
2869
2876
|
}, 6e4);
|
|
2877
|
+
this.cleanupInterval.unref?.();
|
|
2870
2878
|
}
|
|
2871
2879
|
/**
|
|
2872
2880
|
* Atomically claim a token mapping, mirroring `OAuthProxyStateStore`: at most
|
|
@@ -3253,6 +3261,7 @@ var DiskStore = class {
|
|
|
3253
3261
|
this.cleanupInterval = setInterval(() => {
|
|
3254
3262
|
void this.cleanup();
|
|
3255
3263
|
}, cleanupIntervalMs);
|
|
3264
|
+
this.cleanupInterval.unref?.();
|
|
3256
3265
|
}
|
|
3257
3266
|
/**
|
|
3258
3267
|
* Clean up expired entries
|
|
@@ -3605,4 +3614,4 @@ export {
|
|
|
3605
3614
|
DiskStore,
|
|
3606
3615
|
JWKSVerifier
|
|
3607
3616
|
};
|
|
3608
|
-
//# sourceMappingURL=chunk-
|
|
3617
|
+
//# sourceMappingURL=chunk-PWSYODM5.js.map
|