fastmcp 4.12.2 → 4.12.4
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 +2 -0
- package/dist/FastMCP.cjs +5 -3
- package/dist/FastMCP.cjs.map +1 -1
- package/dist/FastMCP.d.cts +17 -12
- package/dist/FastMCP.d.ts +17 -12
- package/dist/FastMCP.js +4 -2
- package/dist/{OAuthProvider-BNqoBTYA.d.cts → OAuthProvider-B_E71LUD.d.cts} +9 -0
- package/dist/{OAuthProvider-BNqoBTYA.d.ts → OAuthProvider-B_E71LUD.d.ts} +9 -0
- 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-PNBJIDG6.js → chunk-2ZFQSPXZ.js} +34 -19
- package/dist/chunk-2ZFQSPXZ.js.map +1 -0
- package/dist/{chunk-POXZCEYE.cjs → chunk-DD63MJG7.cjs} +94 -42
- package/dist/chunk-DD63MJG7.cjs.map +1 -0
- package/dist/{chunk-RAIXP3PS.cjs → chunk-ENMHHQJF.cjs} +34 -19
- package/dist/chunk-ENMHHQJF.cjs.map +1 -0
- package/dist/{chunk-5BQXF2VT.js → chunk-FKX5QBJV.js} +56 -4
- package/dist/chunk-FKX5QBJV.js.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5BQXF2VT.js.map +0 -1
- package/dist/chunk-PNBJIDG6.js.map +0 -1
- package/dist/chunk-POXZCEYE.cjs.map +0 -1
- package/dist/chunk-RAIXP3PS.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -848,6 +848,7 @@ server.addTool({
|
|
|
848
848
|
The `imageContent` function takes the following options:
|
|
849
849
|
|
|
850
850
|
- `url`: The URL of the image.
|
|
851
|
+
- `timeoutMs`: Optional timeout for a URL download in milliseconds (defaults to 30 seconds).
|
|
851
852
|
- `path`: The path to the image file.
|
|
852
853
|
- `buffer`: The image data as a buffer.
|
|
853
854
|
|
|
@@ -1025,6 +1026,7 @@ server.addTool({
|
|
|
1025
1026
|
The `audioContent` function takes the following options:
|
|
1026
1027
|
|
|
1027
1028
|
- `url`: The URL of the audio.
|
|
1029
|
+
- `timeoutMs`: Optional timeout for a URL download in milliseconds (defaults to 30 seconds).
|
|
1028
1030
|
- `path`: The path to the audio file.
|
|
1029
1031
|
- `buffer`: The audio data as a buffer.
|
|
1030
1032
|
|
package/dist/FastMCP.cjs
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var _chunkPOXZCEYEcjs = require('./chunk-POXZCEYE.cjs');
|
|
14
13
|
|
|
14
|
+
var _chunkDD63MJG7cjs = require('./chunk-DD63MJG7.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -23,8 +23,8 @@ var _chunkPOXZCEYEcjs = require('./chunk-POXZCEYE.cjs');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var _chunkRAIXP3PScjs = require('./chunk-RAIXP3PS.cjs');
|
|
27
26
|
|
|
27
|
+
var _chunkENMHHQJFcjs = require('./chunk-ENMHHQJF.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -47,5 +47,7 @@ var _chunkRAIXP3PScjs = require('./chunk-RAIXP3PS.cjs');
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
exports.AuthProvider = _chunkENMHHQJFcjs.AuthProvider; exports.AzureProvider = _chunkENMHHQJFcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkDD63MJG7cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkDD63MJG7cjs.FastMCP; exports.FastMCPError = _chunkDD63MJG7cjs.FastMCPError; exports.FastMCPSession = _chunkDD63MJG7cjs.FastMCPSession; exports.GitHubProvider = _chunkENMHHQJFcjs.GitHubProvider; exports.GoogleProvider = _chunkENMHHQJFcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkDD63MJG7cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkENMHHQJFcjs.OAuthProvider; exports.ServerState = _chunkDD63MJG7cjs.ServerState; exports.SessionError = _chunkDD63MJG7cjs.SessionError; exports.UnexpectedStateError = _chunkDD63MJG7cjs.UnexpectedStateError; exports.UserError = _chunkDD63MJG7cjs.UserError; exports.audioContent = _chunkDD63MJG7cjs.audioContent; exports.getAuthSession = _chunkENMHHQJFcjs.getAuthSession; exports.imageContent = _chunkDD63MJG7cjs.imageContent; exports.jsonSchemaAdapter = _chunkDD63MJG7cjs.jsonSchemaAdapter; exports.requireAll = _chunkENMHHQJFcjs.requireAll; exports.requireAny = _chunkENMHHQJFcjs.requireAny; exports.requireAuth = _chunkENMHHQJFcjs.requireAuth; exports.requireRole = _chunkENMHHQJFcjs.requireRole; exports.requireScopes = _chunkENMHHQJFcjs.requireScopes;
|
|
51
53
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/fastmcp/fastmcp/dist/FastMCP.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/fastmcp/fastmcp/dist/FastMCP.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,0yCAAC","file":"/home/runner/work/fastmcp/fastmcp/dist/FastMCP.cjs"}
|
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-B_E71LUD.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-B_E71LUD.cjs';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
|
@@ -21,9 +21,11 @@ declare class DiscoveryDocumentCache {
|
|
|
21
21
|
get size(): number;
|
|
22
22
|
/**
|
|
23
23
|
* @param options - configuration options
|
|
24
|
+
* @param options.timeoutMs - timeout in miliseconds for the upstream fetch
|
|
24
25
|
* @param options.ttl - time-to-live in miliseconds
|
|
25
26
|
*/
|
|
26
27
|
constructor(options?: {
|
|
28
|
+
timeoutMs?: number;
|
|
27
29
|
ttl?: number;
|
|
28
30
|
});
|
|
29
31
|
/**
|
|
@@ -139,20 +141,23 @@ type FastMCPSessionEvents = {
|
|
|
139
141
|
roots: Root[];
|
|
140
142
|
}) => void;
|
|
141
143
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Timeout for image/audio URL fetches (in milliseconds). The OAuth upstream
|
|
146
|
+
* fetches (#304) use 10s because they are short interactive exchanges; media
|
|
147
|
+
* downloads can be larger and slower, so 30s is the balance between hanging
|
|
148
|
+
* forever on an unresponsive server and false positives on slow connections.
|
|
149
|
+
*/
|
|
150
|
+
declare const MEDIA_FETCH_TIMEOUT_MS = 30000;
|
|
151
|
+
type MediaContentInput = {
|
|
150
152
|
buffer: Buffer;
|
|
151
153
|
} | {
|
|
152
154
|
path: string;
|
|
153
155
|
} | {
|
|
156
|
+
timeoutMs?: number;
|
|
154
157
|
url: string;
|
|
155
|
-
}
|
|
158
|
+
};
|
|
159
|
+
declare const imageContent: (input: MediaContentInput) => Promise<ImageContent>;
|
|
160
|
+
declare const audioContent: (input: MediaContentInput) => Promise<AudioContent>;
|
|
156
161
|
type Context<T extends FastMCPSessionAuth> = {
|
|
157
162
|
client: {
|
|
158
163
|
version: ReturnType<Server["getClientVersion"]>;
|
|
@@ -1052,4 +1057,4 @@ declare class FastMCP<T extends FastMCPSessionAuth = FastMCPSessionAuth> extends
|
|
|
1052
1057
|
stop(): Promise<void>;
|
|
1053
1058
|
}
|
|
1054
1059
|
|
|
1055
|
-
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
|
1060
|
+
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, MEDIA_FETCH_TIMEOUT_MS, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
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-B_E71LUD.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-B_E71LUD.js';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
|
@@ -21,9 +21,11 @@ declare class DiscoveryDocumentCache {
|
|
|
21
21
|
get size(): number;
|
|
22
22
|
/**
|
|
23
23
|
* @param options - configuration options
|
|
24
|
+
* @param options.timeoutMs - timeout in miliseconds for the upstream fetch
|
|
24
25
|
* @param options.ttl - time-to-live in miliseconds
|
|
25
26
|
*/
|
|
26
27
|
constructor(options?: {
|
|
28
|
+
timeoutMs?: number;
|
|
27
29
|
ttl?: number;
|
|
28
30
|
});
|
|
29
31
|
/**
|
|
@@ -139,20 +141,23 @@ type FastMCPSessionEvents = {
|
|
|
139
141
|
roots: Root[];
|
|
140
142
|
}) => void;
|
|
141
143
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Timeout for image/audio URL fetches (in milliseconds). The OAuth upstream
|
|
146
|
+
* fetches (#304) use 10s because they are short interactive exchanges; media
|
|
147
|
+
* downloads can be larger and slower, so 30s is the balance between hanging
|
|
148
|
+
* forever on an unresponsive server and false positives on slow connections.
|
|
149
|
+
*/
|
|
150
|
+
declare const MEDIA_FETCH_TIMEOUT_MS = 30000;
|
|
151
|
+
type MediaContentInput = {
|
|
150
152
|
buffer: Buffer;
|
|
151
153
|
} | {
|
|
152
154
|
path: string;
|
|
153
155
|
} | {
|
|
156
|
+
timeoutMs?: number;
|
|
154
157
|
url: string;
|
|
155
|
-
}
|
|
158
|
+
};
|
|
159
|
+
declare const imageContent: (input: MediaContentInput) => Promise<ImageContent>;
|
|
160
|
+
declare const audioContent: (input: MediaContentInput) => Promise<AudioContent>;
|
|
156
161
|
type Context<T extends FastMCPSessionAuth> = {
|
|
157
162
|
client: {
|
|
158
163
|
version: ReturnType<Server["getClientVersion"]>;
|
|
@@ -1052,4 +1057,4 @@ declare class FastMCP<T extends FastMCPSessionAuth = FastMCPSessionAuth> extends
|
|
|
1052
1057
|
stop(): Promise<void>;
|
|
1053
1058
|
}
|
|
1054
1059
|
|
|
1055
|
-
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
|
1060
|
+
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, MEDIA_FETCH_TIMEOUT_MS, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
package/dist/FastMCP.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
FastMCP,
|
|
4
4
|
FastMCPError,
|
|
5
5
|
FastMCPSession,
|
|
6
|
+
MEDIA_FETCH_TIMEOUT_MS,
|
|
6
7
|
ServerState,
|
|
7
8
|
SessionError,
|
|
8
9
|
UnexpectedStateError,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
audioContent,
|
|
11
12
|
imageContent,
|
|
12
13
|
jsonSchemaAdapter
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FKX5QBJV.js";
|
|
14
15
|
import {
|
|
15
16
|
AuthProvider,
|
|
16
17
|
AzureProvider,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
requireAuth,
|
|
24
25
|
requireRole,
|
|
25
26
|
requireScopes
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-2ZFQSPXZ.js";
|
|
27
28
|
export {
|
|
28
29
|
AuthProvider,
|
|
29
30
|
AzureProvider,
|
|
@@ -33,6 +34,7 @@ export {
|
|
|
33
34
|
FastMCPSession,
|
|
34
35
|
GitHubProvider,
|
|
35
36
|
GoogleProvider,
|
|
37
|
+
MEDIA_FETCH_TIMEOUT_MS,
|
|
36
38
|
OAuthProvider,
|
|
37
39
|
ServerState,
|
|
38
40
|
SessionError,
|
|
@@ -260,6 +260,8 @@ interface OAuthProxyConfig {
|
|
|
260
260
|
upstreamClientId: string;
|
|
261
261
|
/** Pre-registered client secret with upstream provider */
|
|
262
262
|
upstreamClientSecret: string;
|
|
263
|
+
/** Timeout in milliseconds for upstream token/refresh HTTP requests (default: 10000) */
|
|
264
|
+
upstreamRequestTimeoutMs?: number;
|
|
263
265
|
/** Upstream provider's token endpoint URL */
|
|
264
266
|
upstreamTokenEndpoint: string;
|
|
265
267
|
/** Upstream token endpoint authentication method (default: "client_secret_basic") */
|
|
@@ -540,6 +542,13 @@ declare class OAuthProxy {
|
|
|
540
542
|
* Combines claims from access token and ID token (if present)
|
|
541
543
|
*/
|
|
542
544
|
private extractUpstreamClaims;
|
|
545
|
+
/**
|
|
546
|
+
* POST to the upstream token endpoint with a bounded wait.
|
|
547
|
+
*
|
|
548
|
+
* Maps an abort of the configured timeout signal to a clean OAuth error
|
|
549
|
+
* instead of letting the raw `TimeoutError`/`AbortError` propagate.
|
|
550
|
+
*/
|
|
551
|
+
private fetchUpstream;
|
|
543
552
|
/**
|
|
544
553
|
* Generate authorization code for client
|
|
545
554
|
*/
|
|
@@ -260,6 +260,8 @@ interface OAuthProxyConfig {
|
|
|
260
260
|
upstreamClientId: string;
|
|
261
261
|
/** Pre-registered client secret with upstream provider */
|
|
262
262
|
upstreamClientSecret: string;
|
|
263
|
+
/** Timeout in milliseconds for upstream token/refresh HTTP requests (default: 10000) */
|
|
264
|
+
upstreamRequestTimeoutMs?: number;
|
|
263
265
|
/** Upstream provider's token endpoint URL */
|
|
264
266
|
upstreamTokenEndpoint: string;
|
|
265
267
|
/** Upstream token endpoint authentication method (default: "client_secret_basic") */
|
|
@@ -540,6 +542,13 @@ declare class OAuthProxy {
|
|
|
540
542
|
* Combines claims from access token and ID token (if present)
|
|
541
543
|
*/
|
|
542
544
|
private extractUpstreamClaims;
|
|
545
|
+
/**
|
|
546
|
+
* POST to the upstream token endpoint with a bounded wait.
|
|
547
|
+
*
|
|
548
|
+
* Maps an abort of the configured timeout signal to a clean OAuth error
|
|
549
|
+
* instead of letting the raw `TimeoutError`/`AbortError` propagate.
|
|
550
|
+
*/
|
|
551
|
+
private fetchUpstream;
|
|
543
552
|
/**
|
|
544
553
|
* Generate authorization code for client
|
|
545
554
|
*/
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkENMHHQJFcjs = require('../chunk-ENMHHQJF.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunkRAIXP3PScjs = require('../chunk-RAIXP3PS.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkENMHHQJFcjs.AuthProvider; exports.AzureProvider = _chunkENMHHQJFcjs.AzureProvider; exports.ConsentManager = _chunkENMHHQJFcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkENMHHQJFcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkENMHHQJFcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkENMHHQJFcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkENMHHQJFcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkENMHHQJFcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkENMHHQJFcjs.DiskStore; exports.EncryptedTokenStorage = _chunkENMHHQJFcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkENMHHQJFcjs.GitHubProvider; exports.GoogleProvider = _chunkENMHHQJFcjs.GoogleProvider; exports.JWKSVerifier = _chunkENMHHQJFcjs.JWKSVerifier; exports.JWTIssuer = _chunkENMHHQJFcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkENMHHQJFcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkENMHHQJFcjs.OAuthProvider; exports.OAuthProxy = _chunkENMHHQJFcjs.OAuthProxy; exports.OAuthProxyError = _chunkENMHHQJFcjs.OAuthProxyError; exports.PKCEUtils = _chunkENMHHQJFcjs.PKCEUtils; exports.getAuthSession = _chunkENMHHQJFcjs.getAuthSession; exports.requireAll = _chunkENMHHQJFcjs.requireAll; exports.requireAny = _chunkENMHHQJFcjs.requireAny; exports.requireAuth = _chunkENMHHQJFcjs.requireAuth; exports.requireRole = _chunkENMHHQJFcjs.requireRole; exports.requireScopes = _chunkENMHHQJFcjs.requireScopes;
|
|
55
55
|
//# 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, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F 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, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N 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-B_E71LUD.cjs';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F 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, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N 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-B_E71LUD.cjs';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
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, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F 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, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N 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-B_E71LUD.js';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F 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, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N 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-B_E71LUD.js';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/auth/index.js
CHANGED
|
@@ -274,6 +274,7 @@ var DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = 31536e3;
|
|
|
274
274
|
var DEFAULT_REFRESH_TOKEN_TTL = 2592e3;
|
|
275
275
|
var DEFAULT_AUTHORIZATION_CODE_TTL = 300;
|
|
276
276
|
var DEFAULT_TRANSACTION_TTL = 600;
|
|
277
|
+
var DEFAULT_UPSTREAM_REQUEST_TIMEOUT_MS = 1e4;
|
|
277
278
|
|
|
278
279
|
// src/auth/utils/claimsExtractor.ts
|
|
279
280
|
var ClaimsExtractor = class {
|
|
@@ -1151,6 +1152,7 @@ var OAuthProxy = class {
|
|
|
1151
1152
|
// Enabled by default for security
|
|
1152
1153
|
redirectPath: "/oauth/callback",
|
|
1153
1154
|
transactionTtl: DEFAULT_TRANSACTION_TTL,
|
|
1155
|
+
upstreamRequestTimeoutMs: DEFAULT_UPSTREAM_REQUEST_TIMEOUT_MS,
|
|
1154
1156
|
upstreamTokenEndpointAuthMethod: "client_secret_basic",
|
|
1155
1157
|
...config
|
|
1156
1158
|
};
|
|
@@ -1595,11 +1597,7 @@ var OAuthProxy = class {
|
|
|
1595
1597
|
if (useBasicAuth) {
|
|
1596
1598
|
headers["Authorization"] = this.getBasicAuthHeader();
|
|
1597
1599
|
}
|
|
1598
|
-
const tokenResponse = await
|
|
1599
|
-
body: new URLSearchParams(bodyParams),
|
|
1600
|
-
headers,
|
|
1601
|
-
method: "POST"
|
|
1602
|
-
});
|
|
1600
|
+
const tokenResponse = await this.fetchUpstream(bodyParams, headers);
|
|
1603
1601
|
if (!tokenResponse.ok) {
|
|
1604
1602
|
let errorCode = "server_error";
|
|
1605
1603
|
let errorDescription;
|
|
@@ -1668,6 +1666,31 @@ var OAuthProxy = class {
|
|
|
1668
1666
|
}
|
|
1669
1667
|
return Object.keys(allClaims).length > 0 ? allClaims : null;
|
|
1670
1668
|
}
|
|
1669
|
+
/**
|
|
1670
|
+
* POST to the upstream token endpoint with a bounded wait.
|
|
1671
|
+
*
|
|
1672
|
+
* Maps an abort of the configured timeout signal to a clean OAuth error
|
|
1673
|
+
* instead of letting the raw `TimeoutError`/`AbortError` propagate.
|
|
1674
|
+
*/
|
|
1675
|
+
async fetchUpstream(bodyParams, headers) {
|
|
1676
|
+
let tokenResponse;
|
|
1677
|
+
try {
|
|
1678
|
+
tokenResponse = await fetch(this.config.upstreamTokenEndpoint, {
|
|
1679
|
+
body: new URLSearchParams(bodyParams),
|
|
1680
|
+
headers,
|
|
1681
|
+
method: "POST",
|
|
1682
|
+
signal: AbortSignal.timeout(
|
|
1683
|
+
this.config.upstreamRequestTimeoutMs ?? DEFAULT_UPSTREAM_REQUEST_TIMEOUT_MS
|
|
1684
|
+
)
|
|
1685
|
+
});
|
|
1686
|
+
} catch (error) {
|
|
1687
|
+
if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
1688
|
+
throw new OAuthProxyError("server_error", "Upstream request timed out");
|
|
1689
|
+
}
|
|
1690
|
+
throw error;
|
|
1691
|
+
}
|
|
1692
|
+
return tokenResponse;
|
|
1693
|
+
}
|
|
1671
1694
|
/**
|
|
1672
1695
|
* Generate authorization code for client
|
|
1673
1696
|
*/
|
|
@@ -1738,11 +1761,7 @@ var OAuthProxy = class {
|
|
|
1738
1761
|
if (useBasicAuth) {
|
|
1739
1762
|
headers["Authorization"] = this.getBasicAuthHeader();
|
|
1740
1763
|
}
|
|
1741
|
-
const tokenResponse = await
|
|
1742
|
-
body: new URLSearchParams(bodyParams),
|
|
1743
|
-
headers,
|
|
1744
|
-
method: "POST"
|
|
1745
|
-
});
|
|
1764
|
+
const tokenResponse = await this.fetchUpstream(bodyParams, headers);
|
|
1746
1765
|
if (!tokenResponse.ok) {
|
|
1747
1766
|
let errorCode = "invalid_grant";
|
|
1748
1767
|
let errorDescription;
|
|
@@ -2064,11 +2083,7 @@ var OAuthProxy = class {
|
|
|
2064
2083
|
if (useBasicAuth) {
|
|
2065
2084
|
headers["Authorization"] = this.getBasicAuthHeader();
|
|
2066
2085
|
}
|
|
2067
|
-
const tokenResponse = await
|
|
2068
|
-
body: new URLSearchParams(bodyParams),
|
|
2069
|
-
headers,
|
|
2070
|
-
method: "POST"
|
|
2071
|
-
});
|
|
2086
|
+
const tokenResponse = await this.fetchUpstream(bodyParams, headers);
|
|
2072
2087
|
if (!tokenResponse.ok) {
|
|
2073
2088
|
let errorCode = "invalid_grant";
|
|
2074
2089
|
let errorDescription = "Upstream refresh failed";
|
|
@@ -2623,15 +2638,15 @@ var JWKSVerifier = class {
|
|
|
2623
2638
|
verifyOptions
|
|
2624
2639
|
);
|
|
2625
2640
|
const claims = {
|
|
2641
|
+
...payload,
|
|
2642
|
+
// Include all other claims
|
|
2626
2643
|
aud: payload.aud,
|
|
2627
2644
|
client_id: payload.client_id || payload.sub,
|
|
2628
2645
|
exp: payload.exp,
|
|
2629
2646
|
iat: payload.iat,
|
|
2630
2647
|
iss: payload.iss,
|
|
2631
2648
|
jti: payload.jti || "",
|
|
2632
|
-
scope: this.parseScope(payload.scope)
|
|
2633
|
-
...payload
|
|
2634
|
-
// Include all other claims
|
|
2649
|
+
scope: this.parseScope(payload.scope)
|
|
2635
2650
|
};
|
|
2636
2651
|
return {
|
|
2637
2652
|
claims,
|
|
@@ -2718,4 +2733,4 @@ export {
|
|
|
2718
2733
|
DiskStore,
|
|
2719
2734
|
JWKSVerifier
|
|
2720
2735
|
};
|
|
2721
|
-
//# sourceMappingURL=chunk-
|
|
2736
|
+
//# sourceMappingURL=chunk-2ZFQSPXZ.js.map
|