fastmcp 4.26.0 → 4.26.2
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/README.md +16 -6
- 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-CPC9zG96.d.cts → OAuthProvider-B7VDZGyx.d.cts} +55 -3
- package/dist/{OAuthProvider-CPC9zG96.d.ts → OAuthProvider-B7VDZGyx.d.ts} +55 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +17 -3
- package/dist/auth/index.d.ts +17 -3
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-LUGELV2V.js → chunk-ASOZUCE2.js} +180 -36
- package/dist/chunk-ASOZUCE2.js.map +1 -0
- package/dist/{chunk-AKHG27NY.cjs → chunk-HVKGDRTL.cjs} +286 -66
- package/dist/chunk-HVKGDRTL.cjs.map +1 -0
- package/dist/{chunk-ZHTH5HQD.cjs → chunk-UULT6NOS.cjs} +212 -68
- package/dist/chunk-UULT6NOS.cjs.map +1 -0
- package/dist/{chunk-3VYVXSBB.js → chunk-W6P57SNV.js} +272 -52
- package/dist/chunk-W6P57SNV.js.map +1 -0
- package/dist/edge/index.cjs +110 -16
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +7 -2
- package/dist/edge/index.d.ts +7 -2
- package/dist/edge/index.js +110 -16
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +8 -8
- 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-3VYVXSBB.js.map +0 -1
- package/dist/chunk-AKHG27NY.cjs.map +0 -1
- package/dist/chunk-LUGELV2V.js.map +0 -1
- package/dist/chunk-ZHTH5HQD.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -226,7 +226,11 @@ See the [https-server example](src/examples/https-server.ts) for a complete demo
|
|
|
226
226
|
|
|
227
227
|
##### CORS Configuration
|
|
228
228
|
|
|
229
|
-
By default, FastMCP enables CORS with a standard set of allowed headers.
|
|
229
|
+
By default, FastMCP enables CORS with a standard set of allowed headers.
|
|
230
|
+
|
|
231
|
+
A server bound to a loopback address, which is the default (`localhost`), answers browser requests from loopback origins only, such as `http://localhost:6274`. A page served from any other origin cannot open a session or send a message: those requests are refused with a 403. A local server is out of the network's reach but not out of a browser's: without this, any web page you visit could call its tools. Requests without an `Origin` header, which is every client that is not a web page, are not affected, and a server bound to another address answers every origin.
|
|
232
|
+
|
|
233
|
+
To answer pages served from elsewhere, name their origins in `cors.origin`. That list replaces the loopback default, so include a local page's origin too if you use one. Credentials (`credentials: true`) are only granted to origins named there.
|
|
230
234
|
|
|
231
235
|
```ts
|
|
232
236
|
server.start({
|
|
@@ -234,7 +238,7 @@ server.start({
|
|
|
234
238
|
httpStream: {
|
|
235
239
|
port: 8080,
|
|
236
240
|
cors: {
|
|
237
|
-
origin: "http://localhost:
|
|
241
|
+
origin: ["https://app.example.com", "http://localhost:6274"],
|
|
238
242
|
allowedHeaders: [
|
|
239
243
|
"Content-Type",
|
|
240
244
|
"Authorization",
|
|
@@ -252,10 +256,10 @@ server.start({
|
|
|
252
256
|
|
|
253
257
|
The `cors` option accepts:
|
|
254
258
|
|
|
255
|
-
- `true`
|
|
259
|
+
- `true` - enable CORS for every origin
|
|
256
260
|
- `false` - disable CORS entirely
|
|
257
261
|
- An object with these fields:
|
|
258
|
-
- `origin` - a string, array of strings, or a function `(origin: string) => boolean`
|
|
262
|
+
- `origin` - a string, array of strings, or a function `(origin: string) => boolean`. On a server bound to loopback these are the origins it answers, and `"*"` answers all of them. An extension's or app's origin, such as `chrome-extension://…`, can be named as it is
|
|
259
263
|
- `allowedHeaders` - a string or array of strings
|
|
260
264
|
- `methods` - array of allowed HTTP methods
|
|
261
265
|
- `exposedHeaders` - array of headers to expose
|
|
@@ -406,17 +410,19 @@ FastMCP supports edge runtimes like Cloudflare Workers, enabling deployment of M
|
|
|
406
410
|
|
|
407
411
|
> **Note:** Built-in authentication for EdgeFastMCP is planned for a future release. Both FastMCP and EdgeFastMCP use Hono internally, so there's no technical barrier—EdgeFastMCP was simply written before OAuth was added to FastMCP. PRs are welcome to add an `authenticate` option that accepts web `Request` instead of Node.js `http.IncomingMessage`.
|
|
408
412
|
>
|
|
409
|
-
> In the meantime, use Hono middleware
|
|
413
|
+
> In the meantime, use Hono middleware. Middleware (a handler that takes `next`) runs in front of the MCP endpoint as well as your own routes, however it is registered, so this protects `/mcp`:
|
|
410
414
|
>
|
|
411
415
|
> ```ts
|
|
412
416
|
> const app = server.getApp();
|
|
413
|
-
> app.use("/
|
|
417
|
+
> app.use("/mcp", async (c, next) => {
|
|
414
418
|
> if (c.req.header("authorization") !== "Bearer secret") {
|
|
415
419
|
> return c.json({ error: "Unauthorized" }, 401);
|
|
416
420
|
> }
|
|
417
421
|
> await next();
|
|
418
422
|
> });
|
|
419
423
|
> ```
|
|
424
|
+
>
|
|
425
|
+
> A handler that takes only the context is a route of its own and does not replace the MCP endpoint. The `/health` route is not covered by middleware.
|
|
420
426
|
|
|
421
427
|
##### Cloudflare Workers
|
|
422
428
|
|
|
@@ -754,6 +760,10 @@ server.addTool({
|
|
|
754
760
|
});
|
|
755
761
|
```
|
|
756
762
|
|
|
763
|
+
`canAccess` is synchronous, and only a boolean `true` allows access. An `async`
|
|
764
|
+
function returns a Promise, so the tool it guards is hidden from every session
|
|
765
|
+
and a warning is logged.
|
|
766
|
+
|
|
757
767
|
A server without an `authenticate` function has no auth to check, so every
|
|
758
768
|
session sees every tool. With one, a session that still ends up without auth —
|
|
759
769
|
on stdio, where the server carries on when `authenticate` throws or returns
|
package/dist/FastMCP.cjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkUULT6NOScjs = require('./chunk-UULT6NOS.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ var _chunkZHTH5HQDcjs = require('./chunk-ZHTH5HQD.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkHVKGDRTLcjs = require('./chunk-HVKGDRTL.cjs');
|
|
28
28
|
require('./chunk-6TDYSPLC.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
@@ -50,5 +50,5 @@ require('./chunk-6TDYSPLC.cjs');
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
exports.AuthProvider =
|
|
53
|
+
exports.AuthProvider = _chunkHVKGDRTLcjs.AuthProvider; exports.AzureProvider = _chunkHVKGDRTLcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkUULT6NOScjs.DiscoveryDocumentCache; exports.FastMCP = _chunkUULT6NOScjs.FastMCP; exports.FastMCPError = _chunkUULT6NOScjs.FastMCPError; exports.FastMCPSession = _chunkUULT6NOScjs.FastMCPSession; exports.GitHubProvider = _chunkHVKGDRTLcjs.GitHubProvider; exports.GoogleProvider = _chunkHVKGDRTLcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkUULT6NOScjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkHVKGDRTLcjs.OAuthProvider; exports.ServerState = _chunkUULT6NOScjs.ServerState; exports.SessionError = _chunkUULT6NOScjs.SessionError; exports.UnexpectedStateError = _chunkUULT6NOScjs.UnexpectedStateError; exports.UserError = _chunkUULT6NOScjs.UserError; exports.audioContent = _chunkUULT6NOScjs.audioContent; exports.getAuthSession = _chunkHVKGDRTLcjs.getAuthSession; exports.imageContent = _chunkUULT6NOScjs.imageContent; exports.jsonSchemaAdapter = _chunkUULT6NOScjs.jsonSchemaAdapter; exports.requireAll = _chunkHVKGDRTLcjs.requireAll; exports.requireAny = _chunkHVKGDRTLcjs.requireAny; exports.requireAuth = _chunkHVKGDRTLcjs.requireAuth; exports.requireRole = _chunkHVKGDRTLcjs.requireRole; exports.requireScopes = _chunkHVKGDRTLcjs.requireScopes;
|
|
54
54
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.d.cts
CHANGED
|
@@ -12,8 +12,8 @@ import { CorsOptions } from 'mcp-proxy';
|
|
|
12
12
|
export { CorsOptions } from 'mcp-proxy';
|
|
13
13
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
16
|
-
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-
|
|
15
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-B7VDZGyx.cjs';
|
|
16
|
+
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-B7VDZGyx.cjs';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
package/dist/FastMCP.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ import { CorsOptions } from 'mcp-proxy';
|
|
|
12
12
|
export { CorsOptions } from 'mcp-proxy';
|
|
13
13
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
16
|
-
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-
|
|
15
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-B7VDZGyx.js';
|
|
16
|
+
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-B7VDZGyx.js';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
package/dist/FastMCP.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
audioContent,
|
|
12
12
|
imageContent,
|
|
13
13
|
jsonSchemaAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ASOZUCE2.js";
|
|
15
15
|
import {
|
|
16
16
|
AuthProvider,
|
|
17
17
|
AzureProvider,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
requireAuth,
|
|
25
25
|
requireRole,
|
|
26
26
|
requireScopes
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-W6P57SNV.js";
|
|
28
28
|
import "./chunk-OKKFL2M4.js";
|
|
29
29
|
export {
|
|
30
30
|
AuthProvider,
|
|
@@ -59,6 +59,8 @@ interface ClientCode {
|
|
|
59
59
|
interface ConsentData {
|
|
60
60
|
clientName: string;
|
|
61
61
|
provider: string;
|
|
62
|
+
/** Where the client is sent once the user approves. */
|
|
63
|
+
redirectUri?: string;
|
|
62
64
|
scope: string[];
|
|
63
65
|
timestamp: number;
|
|
64
66
|
transactionId: string;
|
|
@@ -195,7 +197,14 @@ interface OAuthProxyConfig {
|
|
|
195
197
|
*
|
|
196
198
|
* A client calling POST /oauth/register must present a `redirect_uri` that
|
|
197
199
|
* matches one of these patterns (exact string or glob with `*` / `?`);
|
|
198
|
-
* otherwise the registration is rejected with `invalid_redirect_uri`.
|
|
200
|
+
* otherwise the registration is rejected with `invalid_redirect_uri`. The
|
|
201
|
+
* host the URI leads to must match the pattern's host as well, so a
|
|
202
|
+
* wildcard in the host, as in `https://*.example.com/*`, stands for part of
|
|
203
|
+
* a host name rather than for a path on some other host, and one that ends
|
|
204
|
+
* a host name does not reach into a longer one. A `?` in the host may also
|
|
205
|
+
* be read as the start of the query, as in a URL. The patterns are checked
|
|
206
|
+
* again at /oauth/authorize, so a registration they no longer allow cannot
|
|
207
|
+
* be used. Once
|
|
199
208
|
* registered, the same exact URI must be echoed back at /oauth/authorize —
|
|
200
209
|
* the proxy performs an exact per-client match per RFC 6749 §3.1.2.3.
|
|
201
210
|
*
|
|
@@ -318,6 +327,11 @@ interface OAuthTransaction {
|
|
|
318
327
|
clientCodeChallengeMethod: string;
|
|
319
328
|
/** Client ID from registration */
|
|
320
329
|
clientId: string;
|
|
330
|
+
/**
|
|
331
|
+
* Digest of the cookie held by the browser the consent screen was shown to.
|
|
332
|
+
* Approving the request and finishing it both take that cookie.
|
|
333
|
+
*/
|
|
334
|
+
consentBinding?: string;
|
|
321
335
|
/** Whether user consent was given */
|
|
322
336
|
consentGiven?: boolean;
|
|
323
337
|
/** Transaction creation timestamp */
|
|
@@ -554,7 +568,7 @@ declare class OAuthProxy {
|
|
|
554
568
|
/**
|
|
555
569
|
* OAuth authorization endpoint
|
|
556
570
|
*/
|
|
557
|
-
authorize(params: AuthorizationParams): Promise<Response>;
|
|
571
|
+
authorize(params: AuthorizationParams, request?: Request): Promise<Response>;
|
|
558
572
|
/**
|
|
559
573
|
* Stop cleanup interval and destroy resources
|
|
560
574
|
*/
|
|
@@ -631,6 +645,24 @@ declare class OAuthProxy {
|
|
|
631
645
|
* Periodic maintenance hook. Expiry is enforced by the token storage.
|
|
632
646
|
*/
|
|
633
647
|
private cleanup;
|
|
648
|
+
/**
|
|
649
|
+
* The cookie that ties consent requests to the browser they were shown to.
|
|
650
|
+
* A browser holds one, shared by every request it has open, and it lasts as
|
|
651
|
+
* long as a request does. `Lax` lets it travel with the provider's redirect
|
|
652
|
+
* back to the callback, which is a cross-site navigation. Over HTTPS the
|
|
653
|
+
* `__Host-` prefix keeps another host on the same site from setting it.
|
|
654
|
+
*/
|
|
655
|
+
private consentCookie;
|
|
656
|
+
private consentCookieName;
|
|
657
|
+
/**
|
|
658
|
+
* The consent cookie `request` carries, if it carries a well-formed one.
|
|
659
|
+
*
|
|
660
|
+
* Only the spaces and tabs that may surround a cookie are dropped. Trimming
|
|
661
|
+
* all white space would take a cookie whose name begins with, say, a
|
|
662
|
+
* no-break space for this one, and a browser does not hold such a name to
|
|
663
|
+
* the `__Host-` rules.
|
|
664
|
+
*/
|
|
665
|
+
private consentCookieValue;
|
|
634
666
|
/**
|
|
635
667
|
* Create a new OAuth transaction
|
|
636
668
|
*/
|
|
@@ -686,6 +718,14 @@ declare class OAuthProxy {
|
|
|
686
718
|
* Handle swap mode refresh - verify FastMCP JWT and issue new tokens
|
|
687
719
|
*/
|
|
688
720
|
private handleSwapModeRefresh;
|
|
721
|
+
/**
|
|
722
|
+
* Whether `request` comes from the browser the transaction's consent screen
|
|
723
|
+
* was shown to: it carries the cookie that screen set. A transaction that
|
|
724
|
+
* never had a consent screen is bound to no browser.
|
|
725
|
+
*/
|
|
726
|
+
private isConsentBoundTo;
|
|
727
|
+
/** Whether browsers reach this proxy over HTTPS, going by its `baseUrl`. */
|
|
728
|
+
private isServedOverHttps;
|
|
689
729
|
/**
|
|
690
730
|
* Issue swapped tokens (JWT pattern)
|
|
691
731
|
* Issues short-lived FastMCP JWTs and stores upstream tokens securely
|
|
@@ -705,7 +745,19 @@ declare class OAuthProxy {
|
|
|
705
745
|
*/
|
|
706
746
|
private isTransactionCallbackRegistered;
|
|
707
747
|
/**
|
|
708
|
-
*
|
|
748
|
+
* Whether a redirect URI matches a pattern.
|
|
749
|
+
*
|
|
750
|
+
* The pattern is a glob over the URI as it is written, and the host the URI
|
|
751
|
+
* really leads to must match the pattern's host as well: `*` runs past the
|
|
752
|
+
* end of a host, so the text of `https://*.example.com/*` could otherwise be
|
|
753
|
+
* found in the path of a URI on any host at all. The URI's host is the one
|
|
754
|
+
* a browser goes to, which a backslash or a tab can make other than it is
|
|
755
|
+
* written. The pattern's runs from after `://` to the first `/` or `#`.
|
|
756
|
+
*
|
|
757
|
+
* A `?` there may stand for a character, as in `localhost:30??`, or start
|
|
758
|
+
* the query, as in `https://app.example.com?source=*`, where the host ends.
|
|
759
|
+
* A URI may match the pattern read any of these ways, if its host matches
|
|
760
|
+
* the host that reading gives.
|
|
709
761
|
*/
|
|
710
762
|
private matchesPattern;
|
|
711
763
|
/**
|
|
@@ -59,6 +59,8 @@ interface ClientCode {
|
|
|
59
59
|
interface ConsentData {
|
|
60
60
|
clientName: string;
|
|
61
61
|
provider: string;
|
|
62
|
+
/** Where the client is sent once the user approves. */
|
|
63
|
+
redirectUri?: string;
|
|
62
64
|
scope: string[];
|
|
63
65
|
timestamp: number;
|
|
64
66
|
transactionId: string;
|
|
@@ -195,7 +197,14 @@ interface OAuthProxyConfig {
|
|
|
195
197
|
*
|
|
196
198
|
* A client calling POST /oauth/register must present a `redirect_uri` that
|
|
197
199
|
* matches one of these patterns (exact string or glob with `*` / `?`);
|
|
198
|
-
* otherwise the registration is rejected with `invalid_redirect_uri`.
|
|
200
|
+
* otherwise the registration is rejected with `invalid_redirect_uri`. The
|
|
201
|
+
* host the URI leads to must match the pattern's host as well, so a
|
|
202
|
+
* wildcard in the host, as in `https://*.example.com/*`, stands for part of
|
|
203
|
+
* a host name rather than for a path on some other host, and one that ends
|
|
204
|
+
* a host name does not reach into a longer one. A `?` in the host may also
|
|
205
|
+
* be read as the start of the query, as in a URL. The patterns are checked
|
|
206
|
+
* again at /oauth/authorize, so a registration they no longer allow cannot
|
|
207
|
+
* be used. Once
|
|
199
208
|
* registered, the same exact URI must be echoed back at /oauth/authorize —
|
|
200
209
|
* the proxy performs an exact per-client match per RFC 6749 §3.1.2.3.
|
|
201
210
|
*
|
|
@@ -318,6 +327,11 @@ interface OAuthTransaction {
|
|
|
318
327
|
clientCodeChallengeMethod: string;
|
|
319
328
|
/** Client ID from registration */
|
|
320
329
|
clientId: string;
|
|
330
|
+
/**
|
|
331
|
+
* Digest of the cookie held by the browser the consent screen was shown to.
|
|
332
|
+
* Approving the request and finishing it both take that cookie.
|
|
333
|
+
*/
|
|
334
|
+
consentBinding?: string;
|
|
321
335
|
/** Whether user consent was given */
|
|
322
336
|
consentGiven?: boolean;
|
|
323
337
|
/** Transaction creation timestamp */
|
|
@@ -554,7 +568,7 @@ declare class OAuthProxy {
|
|
|
554
568
|
/**
|
|
555
569
|
* OAuth authorization endpoint
|
|
556
570
|
*/
|
|
557
|
-
authorize(params: AuthorizationParams): Promise<Response>;
|
|
571
|
+
authorize(params: AuthorizationParams, request?: Request): Promise<Response>;
|
|
558
572
|
/**
|
|
559
573
|
* Stop cleanup interval and destroy resources
|
|
560
574
|
*/
|
|
@@ -631,6 +645,24 @@ declare class OAuthProxy {
|
|
|
631
645
|
* Periodic maintenance hook. Expiry is enforced by the token storage.
|
|
632
646
|
*/
|
|
633
647
|
private cleanup;
|
|
648
|
+
/**
|
|
649
|
+
* The cookie that ties consent requests to the browser they were shown to.
|
|
650
|
+
* A browser holds one, shared by every request it has open, and it lasts as
|
|
651
|
+
* long as a request does. `Lax` lets it travel with the provider's redirect
|
|
652
|
+
* back to the callback, which is a cross-site navigation. Over HTTPS the
|
|
653
|
+
* `__Host-` prefix keeps another host on the same site from setting it.
|
|
654
|
+
*/
|
|
655
|
+
private consentCookie;
|
|
656
|
+
private consentCookieName;
|
|
657
|
+
/**
|
|
658
|
+
* The consent cookie `request` carries, if it carries a well-formed one.
|
|
659
|
+
*
|
|
660
|
+
* Only the spaces and tabs that may surround a cookie are dropped. Trimming
|
|
661
|
+
* all white space would take a cookie whose name begins with, say, a
|
|
662
|
+
* no-break space for this one, and a browser does not hold such a name to
|
|
663
|
+
* the `__Host-` rules.
|
|
664
|
+
*/
|
|
665
|
+
private consentCookieValue;
|
|
634
666
|
/**
|
|
635
667
|
* Create a new OAuth transaction
|
|
636
668
|
*/
|
|
@@ -686,6 +718,14 @@ declare class OAuthProxy {
|
|
|
686
718
|
* Handle swap mode refresh - verify FastMCP JWT and issue new tokens
|
|
687
719
|
*/
|
|
688
720
|
private handleSwapModeRefresh;
|
|
721
|
+
/**
|
|
722
|
+
* Whether `request` comes from the browser the transaction's consent screen
|
|
723
|
+
* was shown to: it carries the cookie that screen set. A transaction that
|
|
724
|
+
* never had a consent screen is bound to no browser.
|
|
725
|
+
*/
|
|
726
|
+
private isConsentBoundTo;
|
|
727
|
+
/** Whether browsers reach this proxy over HTTPS, going by its `baseUrl`. */
|
|
728
|
+
private isServedOverHttps;
|
|
689
729
|
/**
|
|
690
730
|
* Issue swapped tokens (JWT pattern)
|
|
691
731
|
* Issues short-lived FastMCP JWTs and stores upstream tokens securely
|
|
@@ -705,7 +745,19 @@ declare class OAuthProxy {
|
|
|
705
745
|
*/
|
|
706
746
|
private isTransactionCallbackRegistered;
|
|
707
747
|
/**
|
|
708
|
-
*
|
|
748
|
+
* Whether a redirect URI matches a pattern.
|
|
749
|
+
*
|
|
750
|
+
* The pattern is a glob over the URI as it is written, and the host the URI
|
|
751
|
+
* really leads to must match the pattern's host as well: `*` runs past the
|
|
752
|
+
* end of a host, so the text of `https://*.example.com/*` could otherwise be
|
|
753
|
+
* found in the path of a URI on any host at all. The URI's host is the one
|
|
754
|
+
* a browser goes to, which a backslash or a tab can make other than it is
|
|
755
|
+
* written. The pattern's runs from after `://` to the first `/` or `#`.
|
|
756
|
+
*
|
|
757
|
+
* A `?` there may stand for a character, as in `localhost:30??`, or start
|
|
758
|
+
* the query, as in `https://app.example.com?source=*`, where the host ends.
|
|
759
|
+
* A URI may match the pattern read any of these ways, if its host matches
|
|
760
|
+
* the host that reading gives.
|
|
709
761
|
*/
|
|
710
762
|
private matchesPattern;
|
|
711
763
|
/**
|
package/dist/auth/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _chunkHVKGDRTLcjs = require('../chunk-HVKGDRTL.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
@@ -53,5 +53,5 @@ var _chunkAKHG27NYcjs = require('../chunk-AKHG27NY.cjs');
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
exports.AuthProvider =
|
|
56
|
+
exports.AuthProvider = _chunkHVKGDRTLcjs.AuthProvider; exports.AzureProvider = _chunkHVKGDRTLcjs.AzureProvider; exports.ConsentManager = _chunkHVKGDRTLcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkHVKGDRTLcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkHVKGDRTLcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkHVKGDRTLcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkHVKGDRTLcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkHVKGDRTLcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkHVKGDRTLcjs.DiskStore; exports.EncryptedTokenStorage = _chunkHVKGDRTLcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkHVKGDRTLcjs.GitHubProvider; exports.GoogleProvider = _chunkHVKGDRTLcjs.GoogleProvider; exports.JWKSVerifier = _chunkHVKGDRTLcjs.JWKSVerifier; exports.JWTIssuer = _chunkHVKGDRTLcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkHVKGDRTLcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkHVKGDRTLcjs.OAuthProvider; exports.OAuthProxy = _chunkHVKGDRTLcjs.OAuthProxy; exports.OAuthProxyError = _chunkHVKGDRTLcjs.OAuthProxyError; exports.PKCEUtils = _chunkHVKGDRTLcjs.PKCEUtils; exports.TOKEN_ENDPOINT_AUTH_METHODS = _chunkHVKGDRTLcjs.TOKEN_ENDPOINT_AUTH_METHODS; exports.getAuthSession = _chunkHVKGDRTLcjs.getAuthSession; exports.requireAll = _chunkHVKGDRTLcjs.requireAll; exports.requireAny = _chunkHVKGDRTLcjs.requireAny; exports.requireAuth = _chunkHVKGDRTLcjs.requireAuth; exports.requireRole = _chunkHVKGDRTLcjs.requireRole; exports.requireScopes = _chunkHVKGDRTLcjs.requireScopes;
|
|
57
57
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-
|
|
2
|
-
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, E as DCRClientMetadata, F as DCRRequest, H as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, I as OAuthError, d as OAuthProvider, J as OAuthProviderConfig, a as OAuthProxy, K as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, L as ProxyDCRClient, R as RefreshRequest, y as TOKEN_ENDPOINT_AUTH_METHODS, M as TokenEndpointAuthMethod, N as TokenMapping, Q as TokenRequest, S as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-
|
|
1
|
+
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-B7VDZGyx.cjs';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, E as DCRClientMetadata, F as DCRRequest, H as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, I as OAuthError, d as OAuthProvider, J as OAuthProviderConfig, a as OAuthProxy, K as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, L as ProxyDCRClient, R as RefreshRequest, y as TOKEN_ENDPOINT_AUTH_METHODS, M as TokenEndpointAuthMethod, N as TokenMapping, Q as TokenRequest, S as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-B7VDZGyx.cjs';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -15,8 +15,15 @@ declare class ConsentManager {
|
|
|
15
15
|
constructor(signingKey: string);
|
|
16
16
|
/**
|
|
17
17
|
* Create HTTP response with consent screen
|
|
18
|
+
*
|
|
19
|
+
* `cookie` is a `Set-Cookie` value that ties the request to the browser the
|
|
20
|
+
* screen is shown to. The screen may not be framed: a page that embeds it
|
|
21
|
+
* could have the user approve without seeing what they are approving.
|
|
18
22
|
*/
|
|
19
|
-
createConsentResponse(transaction: OAuthTransaction, provider: string
|
|
23
|
+
createConsentResponse(transaction: OAuthTransaction, provider: string, options?: {
|
|
24
|
+
clientName?: string;
|
|
25
|
+
cookie?: string;
|
|
26
|
+
}): Response;
|
|
20
27
|
/**
|
|
21
28
|
* Generate HTML for consent screen
|
|
22
29
|
*/
|
|
@@ -29,6 +36,13 @@ declare class ConsentManager {
|
|
|
29
36
|
* Validate and parse consent cookie
|
|
30
37
|
*/
|
|
31
38
|
validateConsentCookie(cookie: string): ConsentData | null;
|
|
39
|
+
/**
|
|
40
|
+
* Where a redirect URI leads, as the browser will read it rather than as it
|
|
41
|
+
* was typed: the parsed host, so that a look-alike character, a tab or a
|
|
42
|
+
* backslash shows for what it does. A long host keeps its end, which is the
|
|
43
|
+
* part that says whose it is.
|
|
44
|
+
*/
|
|
45
|
+
private describeDestination;
|
|
32
46
|
/**
|
|
33
47
|
* Escape HTML to prevent XSS
|
|
34
48
|
*/
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-
|
|
2
|
-
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, E as DCRClientMetadata, F as DCRRequest, H as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, I as OAuthError, d as OAuthProvider, J as OAuthProviderConfig, a as OAuthProxy, K as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, L as ProxyDCRClient, R as RefreshRequest, y as TOKEN_ENDPOINT_AUTH_METHODS, M as TokenEndpointAuthMethod, N as TokenMapping, Q as TokenRequest, S as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-
|
|
1
|
+
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-B7VDZGyx.js';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, E as DCRClientMetadata, F as DCRRequest, H as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, I as OAuthError, d as OAuthProvider, J as OAuthProviderConfig, a as OAuthProxy, K as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, L as ProxyDCRClient, R as RefreshRequest, y as TOKEN_ENDPOINT_AUTH_METHODS, M as TokenEndpointAuthMethod, N as TokenMapping, Q as TokenRequest, S as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-B7VDZGyx.js';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -15,8 +15,15 @@ declare class ConsentManager {
|
|
|
15
15
|
constructor(signingKey: string);
|
|
16
16
|
/**
|
|
17
17
|
* Create HTTP response with consent screen
|
|
18
|
+
*
|
|
19
|
+
* `cookie` is a `Set-Cookie` value that ties the request to the browser the
|
|
20
|
+
* screen is shown to. The screen may not be framed: a page that embeds it
|
|
21
|
+
* could have the user approve without seeing what they are approving.
|
|
18
22
|
*/
|
|
19
|
-
createConsentResponse(transaction: OAuthTransaction, provider: string
|
|
23
|
+
createConsentResponse(transaction: OAuthTransaction, provider: string, options?: {
|
|
24
|
+
clientName?: string;
|
|
25
|
+
cookie?: string;
|
|
26
|
+
}): Response;
|
|
20
27
|
/**
|
|
21
28
|
* Generate HTML for consent screen
|
|
22
29
|
*/
|
|
@@ -29,6 +36,13 @@ declare class ConsentManager {
|
|
|
29
36
|
* Validate and parse consent cookie
|
|
30
37
|
*/
|
|
31
38
|
validateConsentCookie(cookie: string): ConsentData | null;
|
|
39
|
+
/**
|
|
40
|
+
* Where a redirect URI leads, as the browser will read it rather than as it
|
|
41
|
+
* was typed: the parsed host, so that a look-alike character, a tab or a
|
|
42
|
+
* backslash shows for what it does. A long host keeps its end, which is the
|
|
43
|
+
* part that says whose it is.
|
|
44
|
+
*/
|
|
45
|
+
private describeDestination;
|
|
32
46
|
/**
|
|
33
47
|
* Escape HTML to prevent XSS
|
|
34
48
|
*/
|