@frontmcp/guard 1.0.0-beta.1 → 1.0.0-beta.3
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/esm/index.mjs +21 -21
- package/esm/package.json +2 -2
- package/index.js +21 -21
- package/package.json +2 -2
- package/schemas/index.d.ts +1 -0
- package/schemas/schemas.generated.d.ts +102 -0
package/esm/index.mjs
CHANGED
|
@@ -54,35 +54,35 @@ var partitionKeySchema = z.union([
|
|
|
54
54
|
)
|
|
55
55
|
]);
|
|
56
56
|
var rateLimitConfigSchema = z.object({
|
|
57
|
-
maxRequests: z.number().int().positive(),
|
|
58
|
-
windowMs: z.number().int().positive().optional().default(6e4),
|
|
59
|
-
partitionBy: partitionKeySchema.optional().default("global")
|
|
57
|
+
maxRequests: z.number().int().positive().describe("Maximum number of requests allowed within the window."),
|
|
58
|
+
windowMs: z.number().int().positive().optional().default(6e4).describe("Time window in milliseconds."),
|
|
59
|
+
partitionBy: partitionKeySchema.optional().default("global").describe("Partition key strategy.")
|
|
60
60
|
});
|
|
61
61
|
var concurrencyConfigSchema = z.object({
|
|
62
|
-
maxConcurrent: z.number().int().positive(),
|
|
63
|
-
queueTimeoutMs: z.number().int().nonnegative().optional().default(0),
|
|
64
|
-
partitionBy: partitionKeySchema.optional().default("global")
|
|
62
|
+
maxConcurrent: z.number().int().positive().describe("Maximum number of concurrent executions allowed."),
|
|
63
|
+
queueTimeoutMs: z.number().int().nonnegative().optional().default(0).describe("Maximum time in ms to wait in queue (0 = no wait)."),
|
|
64
|
+
partitionBy: partitionKeySchema.optional().default("global").describe("Partition key strategy.")
|
|
65
65
|
});
|
|
66
66
|
var timeoutConfigSchema = z.object({
|
|
67
|
-
executeMs: z.number().int().positive()
|
|
67
|
+
executeMs: z.number().int().positive().describe("Maximum execution time in milliseconds.")
|
|
68
68
|
});
|
|
69
69
|
var ipFilterConfigSchema = z.object({
|
|
70
|
-
allowList: z.array(z.string()).optional(),
|
|
71
|
-
denyList: z.array(z.string()).optional(),
|
|
72
|
-
defaultAction: z.enum(["allow", "deny"]).optional().default("allow"),
|
|
73
|
-
trustProxy: z.boolean().optional().default(false),
|
|
74
|
-
trustedProxyDepth: z.number().int().positive().optional().default(1)
|
|
70
|
+
allowList: z.array(z.string()).optional().describe("IP addresses or CIDR ranges to always allow."),
|
|
71
|
+
denyList: z.array(z.string()).optional().describe("IP addresses or CIDR ranges to always block."),
|
|
72
|
+
defaultAction: z.enum(["allow", "deny"]).optional().default("allow").describe("Default action when IP matches neither list."),
|
|
73
|
+
trustProxy: z.boolean().optional().default(false).describe("Trust X-Forwarded-For header."),
|
|
74
|
+
trustedProxyDepth: z.number().int().positive().optional().default(1).describe("Max number of proxies to trust from X-Forwarded-For.")
|
|
75
75
|
});
|
|
76
76
|
var guardConfigSchema = z.object({
|
|
77
|
-
enabled: z.boolean(),
|
|
78
|
-
storage: z.looseObject({}).optional(),
|
|
79
|
-
keyPrefix: z.string().optional().default("mcp:guard:"),
|
|
80
|
-
global: rateLimitConfigSchema.optional(),
|
|
81
|
-
globalConcurrency: concurrencyConfigSchema.optional(),
|
|
82
|
-
defaultRateLimit: rateLimitConfigSchema.optional(),
|
|
83
|
-
defaultConcurrency: concurrencyConfigSchema.optional(),
|
|
84
|
-
defaultTimeout: timeoutConfigSchema.optional(),
|
|
85
|
-
ipFilter: ipFilterConfigSchema.optional()
|
|
77
|
+
enabled: z.boolean().describe("Whether the guard system is enabled."),
|
|
78
|
+
storage: z.looseObject({}).optional().describe("Storage backend configuration."),
|
|
79
|
+
keyPrefix: z.string().optional().default("mcp:guard:").describe("Key prefix for all storage keys."),
|
|
80
|
+
global: rateLimitConfigSchema.optional().describe("Global rate limit applied to all requests."),
|
|
81
|
+
globalConcurrency: concurrencyConfigSchema.optional().describe("Global concurrency limit."),
|
|
82
|
+
defaultRateLimit: rateLimitConfigSchema.optional().describe("Default rate limit for entities without explicit config."),
|
|
83
|
+
defaultConcurrency: concurrencyConfigSchema.optional().describe("Default concurrency for entities without explicit config."),
|
|
84
|
+
defaultTimeout: timeoutConfigSchema.optional().describe("Default timeout for entity execution."),
|
|
85
|
+
ipFilter: ipFilterConfigSchema.optional().describe("IP filtering configuration.")
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// libs/guard/src/partition-key/partition-key.resolver.ts
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/guard",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Rate limiting, concurrency control, timeout, IP filtering, and traffic guard utilities for FrontMCP",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"node": ">=22.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@frontmcp/utils": "1.0.0-beta.
|
|
51
|
+
"@frontmcp/utils": "1.0.0-beta.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^4.0.0"
|
package/index.js
CHANGED
|
@@ -99,35 +99,35 @@ var partitionKeySchema = import_zod.z.union([
|
|
|
99
99
|
)
|
|
100
100
|
]);
|
|
101
101
|
var rateLimitConfigSchema = import_zod.z.object({
|
|
102
|
-
maxRequests: import_zod.z.number().int().positive(),
|
|
103
|
-
windowMs: import_zod.z.number().int().positive().optional().default(6e4),
|
|
104
|
-
partitionBy: partitionKeySchema.optional().default("global")
|
|
102
|
+
maxRequests: import_zod.z.number().int().positive().describe("Maximum number of requests allowed within the window."),
|
|
103
|
+
windowMs: import_zod.z.number().int().positive().optional().default(6e4).describe("Time window in milliseconds."),
|
|
104
|
+
partitionBy: partitionKeySchema.optional().default("global").describe("Partition key strategy.")
|
|
105
105
|
});
|
|
106
106
|
var concurrencyConfigSchema = import_zod.z.object({
|
|
107
|
-
maxConcurrent: import_zod.z.number().int().positive(),
|
|
108
|
-
queueTimeoutMs: import_zod.z.number().int().nonnegative().optional().default(0),
|
|
109
|
-
partitionBy: partitionKeySchema.optional().default("global")
|
|
107
|
+
maxConcurrent: import_zod.z.number().int().positive().describe("Maximum number of concurrent executions allowed."),
|
|
108
|
+
queueTimeoutMs: import_zod.z.number().int().nonnegative().optional().default(0).describe("Maximum time in ms to wait in queue (0 = no wait)."),
|
|
109
|
+
partitionBy: partitionKeySchema.optional().default("global").describe("Partition key strategy.")
|
|
110
110
|
});
|
|
111
111
|
var timeoutConfigSchema = import_zod.z.object({
|
|
112
|
-
executeMs: import_zod.z.number().int().positive()
|
|
112
|
+
executeMs: import_zod.z.number().int().positive().describe("Maximum execution time in milliseconds.")
|
|
113
113
|
});
|
|
114
114
|
var ipFilterConfigSchema = import_zod.z.object({
|
|
115
|
-
allowList: import_zod.z.array(import_zod.z.string()).optional(),
|
|
116
|
-
denyList: import_zod.z.array(import_zod.z.string()).optional(),
|
|
117
|
-
defaultAction: import_zod.z.enum(["allow", "deny"]).optional().default("allow"),
|
|
118
|
-
trustProxy: import_zod.z.boolean().optional().default(false),
|
|
119
|
-
trustedProxyDepth: import_zod.z.number().int().positive().optional().default(1)
|
|
115
|
+
allowList: import_zod.z.array(import_zod.z.string()).optional().describe("IP addresses or CIDR ranges to always allow."),
|
|
116
|
+
denyList: import_zod.z.array(import_zod.z.string()).optional().describe("IP addresses or CIDR ranges to always block."),
|
|
117
|
+
defaultAction: import_zod.z.enum(["allow", "deny"]).optional().default("allow").describe("Default action when IP matches neither list."),
|
|
118
|
+
trustProxy: import_zod.z.boolean().optional().default(false).describe("Trust X-Forwarded-For header."),
|
|
119
|
+
trustedProxyDepth: import_zod.z.number().int().positive().optional().default(1).describe("Max number of proxies to trust from X-Forwarded-For.")
|
|
120
120
|
});
|
|
121
121
|
var guardConfigSchema = import_zod.z.object({
|
|
122
|
-
enabled: import_zod.z.boolean(),
|
|
123
|
-
storage: import_zod.z.looseObject({}).optional(),
|
|
124
|
-
keyPrefix: import_zod.z.string().optional().default("mcp:guard:"),
|
|
125
|
-
global: rateLimitConfigSchema.optional(),
|
|
126
|
-
globalConcurrency: concurrencyConfigSchema.optional(),
|
|
127
|
-
defaultRateLimit: rateLimitConfigSchema.optional(),
|
|
128
|
-
defaultConcurrency: concurrencyConfigSchema.optional(),
|
|
129
|
-
defaultTimeout: timeoutConfigSchema.optional(),
|
|
130
|
-
ipFilter: ipFilterConfigSchema.optional()
|
|
122
|
+
enabled: import_zod.z.boolean().describe("Whether the guard system is enabled."),
|
|
123
|
+
storage: import_zod.z.looseObject({}).optional().describe("Storage backend configuration."),
|
|
124
|
+
keyPrefix: import_zod.z.string().optional().default("mcp:guard:").describe("Key prefix for all storage keys."),
|
|
125
|
+
global: rateLimitConfigSchema.optional().describe("Global rate limit applied to all requests."),
|
|
126
|
+
globalConcurrency: concurrencyConfigSchema.optional().describe("Global concurrency limit."),
|
|
127
|
+
defaultRateLimit: rateLimitConfigSchema.optional().describe("Default rate limit for entities without explicit config."),
|
|
128
|
+
defaultConcurrency: concurrencyConfigSchema.optional().describe("Default concurrency for entities without explicit config."),
|
|
129
|
+
defaultTimeout: timeoutConfigSchema.optional().describe("Default timeout for entity execution."),
|
|
130
|
+
ipFilter: ipFilterConfigSchema.optional().describe("IP filtering configuration.")
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
// libs/guard/src/partition-key/partition-key.resolver.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/guard",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Rate limiting, concurrency control, timeout, IP filtering, and traffic guard utilities for FrontMCP",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"node": ">=22.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@frontmcp/utils": "1.0.0-beta.
|
|
51
|
+
"@frontmcp/utils": "1.0.0-beta.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^4.0.0"
|
package/schemas/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export { partitionKeySchema, rateLimitConfigSchema, concurrencyConfigSchema, timeoutConfigSchema, ipFilterConfigSchema, guardConfigSchema, } from './schemas';
|
|
2
|
+
export type { ConcurrencyConfigInput, RateLimitConfigInput, TimeoutConfigInput, IpFilterConfigInput, GuardConfigInput, } from './schemas.generated';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { PartitionKey } from '../partition-key/types';
|
|
2
|
+
/**
|
|
3
|
+
* Input type for concurrency control configuration.
|
|
4
|
+
* All fields are optional for IDE autocomplete; required fields
|
|
5
|
+
* are validated at runtime by concurrencyConfigSchema.
|
|
6
|
+
*/
|
|
7
|
+
export interface ConcurrencyConfigInput {
|
|
8
|
+
/** Maximum number of concurrent executions allowed. */
|
|
9
|
+
maxConcurrent?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum time in ms to wait in queue (0 = no wait).
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
14
|
+
queueTimeoutMs?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Partition key strategy.
|
|
17
|
+
* @default "global"
|
|
18
|
+
*/
|
|
19
|
+
partitionBy?: PartitionKey;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Input type for rate limiting configuration.
|
|
23
|
+
* All fields are optional for IDE autocomplete; required fields
|
|
24
|
+
* are validated at runtime by rateLimitConfigSchema.
|
|
25
|
+
*/
|
|
26
|
+
export interface RateLimitConfigInput {
|
|
27
|
+
/** Maximum number of requests allowed within the window. */
|
|
28
|
+
maxRequests?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Time window in milliseconds.
|
|
31
|
+
* @default 60000
|
|
32
|
+
*/
|
|
33
|
+
windowMs?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Partition key strategy.
|
|
36
|
+
* @default "global"
|
|
37
|
+
*/
|
|
38
|
+
partitionBy?: PartitionKey;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Input type for timeout configuration.
|
|
42
|
+
* All fields are optional for IDE autocomplete; required fields
|
|
43
|
+
* are validated at runtime by timeoutConfigSchema.
|
|
44
|
+
*/
|
|
45
|
+
export interface TimeoutConfigInput {
|
|
46
|
+
/** Maximum execution time in milliseconds. */
|
|
47
|
+
executeMs?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Input type for IP filtering configuration.
|
|
51
|
+
* All fields are optional for IDE autocomplete; required fields
|
|
52
|
+
* are validated at runtime by ipFilterConfigSchema.
|
|
53
|
+
*/
|
|
54
|
+
export interface IpFilterConfigInput {
|
|
55
|
+
/** IP addresses or CIDR ranges to always allow. */
|
|
56
|
+
allowList?: Array<string>;
|
|
57
|
+
/** IP addresses or CIDR ranges to always block. */
|
|
58
|
+
denyList?: Array<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Default action when IP matches neither list.
|
|
61
|
+
* @default "allow"
|
|
62
|
+
*/
|
|
63
|
+
defaultAction?: 'allow' | 'deny';
|
|
64
|
+
/**
|
|
65
|
+
* Trust X-Forwarded-For header.
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
trustProxy?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Max number of proxies to trust from X-Forwarded-For.
|
|
71
|
+
* @default 1
|
|
72
|
+
*/
|
|
73
|
+
trustedProxyDepth?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Input type for guard system configuration.
|
|
77
|
+
* All fields are optional for IDE autocomplete; required fields
|
|
78
|
+
* are validated at runtime by guardConfigSchema.
|
|
79
|
+
*/
|
|
80
|
+
export interface GuardConfigInput {
|
|
81
|
+
/** Whether the guard system is enabled. */
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
/** Storage backend configuration. */
|
|
84
|
+
storage?: Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Key prefix for all storage keys.
|
|
87
|
+
* @default "mcp:guard:"
|
|
88
|
+
*/
|
|
89
|
+
keyPrefix?: string;
|
|
90
|
+
/** Global rate limit applied to all requests. */
|
|
91
|
+
global?: RateLimitConfigInput;
|
|
92
|
+
/** Global concurrency limit. */
|
|
93
|
+
globalConcurrency?: ConcurrencyConfigInput;
|
|
94
|
+
/** Default rate limit for entities without explicit config. */
|
|
95
|
+
defaultRateLimit?: RateLimitConfigInput;
|
|
96
|
+
/** Default concurrency for entities without explicit config. */
|
|
97
|
+
defaultConcurrency?: ConcurrencyConfigInput;
|
|
98
|
+
/** Default timeout for entity execution. */
|
|
99
|
+
defaultTimeout?: TimeoutConfigInput;
|
|
100
|
+
/** IP filtering configuration. */
|
|
101
|
+
ipFilter?: IpFilterConfigInput;
|
|
102
|
+
}
|