@frontmcp/guard 1.0.4 → 1.1.0
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 +1 -1
- package/esm/package.json +3 -3
- package/index.js +22 -22
- package/package.json +3 -3
- package/schemas/schemas.d.ts +63 -64
package/esm/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ var IpNotAllowedError = class extends GuardError {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// libs/guard/src/schemas/schemas.ts
|
|
49
|
-
import { z } from "zod";
|
|
49
|
+
import { z } from "@frontmcp/lazy-zod";
|
|
50
50
|
var partitionKeySchema = z.union([
|
|
51
51
|
z.enum(["ip", "session", "userId", "global"]),
|
|
52
52
|
z.custom(
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/guard",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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,10 +48,10 @@
|
|
|
48
48
|
"node": ">=24.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@frontmcp/utils": "1.0
|
|
51
|
+
"@frontmcp/utils": "1.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"zod": "
|
|
54
|
+
"@frontmcp/lazy-zod": "1.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^24.0.0",
|
package/index.js
CHANGED
|
@@ -91,37 +91,37 @@ var IpNotAllowedError = class extends GuardError {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// libs/guard/src/schemas/schemas.ts
|
|
94
|
-
var
|
|
95
|
-
var partitionKeySchema =
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
var import_lazy_zod = require("@frontmcp/lazy-zod");
|
|
95
|
+
var partitionKeySchema = import_lazy_zod.z.union([
|
|
96
|
+
import_lazy_zod.z.enum(["ip", "session", "userId", "global"]),
|
|
97
|
+
import_lazy_zod.z.custom(
|
|
98
98
|
(val) => typeof val === "function"
|
|
99
99
|
)
|
|
100
100
|
]);
|
|
101
|
-
var rateLimitConfigSchema =
|
|
102
|
-
maxRequests:
|
|
103
|
-
windowMs:
|
|
101
|
+
var rateLimitConfigSchema = import_lazy_zod.z.object({
|
|
102
|
+
maxRequests: import_lazy_zod.z.number().int().positive().describe("Maximum number of requests allowed within the window."),
|
|
103
|
+
windowMs: import_lazy_zod.z.number().int().positive().optional().default(6e4).describe("Time window in milliseconds."),
|
|
104
104
|
partitionBy: partitionKeySchema.optional().default("global").describe("Partition key strategy.")
|
|
105
105
|
});
|
|
106
|
-
var concurrencyConfigSchema =
|
|
107
|
-
maxConcurrent:
|
|
108
|
-
queueTimeoutMs:
|
|
106
|
+
var concurrencyConfigSchema = import_lazy_zod.z.object({
|
|
107
|
+
maxConcurrent: import_lazy_zod.z.number().int().positive().describe("Maximum number of concurrent executions allowed."),
|
|
108
|
+
queueTimeoutMs: import_lazy_zod.z.number().int().nonnegative().optional().default(0).describe("Maximum time in ms to wait in queue (0 = no wait)."),
|
|
109
109
|
partitionBy: partitionKeySchema.optional().default("global").describe("Partition key strategy.")
|
|
110
110
|
});
|
|
111
|
-
var timeoutConfigSchema =
|
|
112
|
-
executeMs:
|
|
111
|
+
var timeoutConfigSchema = import_lazy_zod.z.object({
|
|
112
|
+
executeMs: import_lazy_zod.z.number().int().positive().describe("Maximum execution time in milliseconds.")
|
|
113
113
|
});
|
|
114
|
-
var ipFilterConfigSchema =
|
|
115
|
-
allowList:
|
|
116
|
-
denyList:
|
|
117
|
-
defaultAction:
|
|
118
|
-
trustProxy:
|
|
119
|
-
trustedProxyDepth:
|
|
114
|
+
var ipFilterConfigSchema = import_lazy_zod.z.object({
|
|
115
|
+
allowList: import_lazy_zod.z.array(import_lazy_zod.z.string()).optional().describe("IP addresses or CIDR ranges to always allow."),
|
|
116
|
+
denyList: import_lazy_zod.z.array(import_lazy_zod.z.string()).optional().describe("IP addresses or CIDR ranges to always block."),
|
|
117
|
+
defaultAction: import_lazy_zod.z.enum(["allow", "deny"]).optional().default("allow").describe("Default action when IP matches neither list."),
|
|
118
|
+
trustProxy: import_lazy_zod.z.boolean().optional().default(false).describe("Trust X-Forwarded-For header."),
|
|
119
|
+
trustedProxyDepth: import_lazy_zod.z.number().int().positive().optional().default(1).describe("Max number of proxies to trust from X-Forwarded-For.")
|
|
120
120
|
});
|
|
121
|
-
var guardConfigSchema =
|
|
122
|
-
enabled:
|
|
123
|
-
storage:
|
|
124
|
-
keyPrefix:
|
|
121
|
+
var guardConfigSchema = import_lazy_zod.z.object({
|
|
122
|
+
enabled: import_lazy_zod.z.boolean().describe("Whether the guard system is enabled."),
|
|
123
|
+
storage: import_lazy_zod.z.looseObject({}).optional().describe("Storage backend configuration."),
|
|
124
|
+
keyPrefix: import_lazy_zod.z.string().optional().default("mcp:guard:").describe("Key prefix for all storage keys."),
|
|
125
125
|
global: rateLimitConfigSchema.optional().describe("Global rate limit applied to all requests."),
|
|
126
126
|
globalConcurrency: concurrencyConfigSchema.optional().describe("Global concurrency limit."),
|
|
127
127
|
defaultRateLimit: rateLimitConfigSchema.optional().describe("Default rate limit for entities without explicit config."),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/guard",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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,10 +48,10 @@
|
|
|
48
48
|
"node": ">=24.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@frontmcp/utils": "1.0
|
|
51
|
+
"@frontmcp/utils": "1.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"zod": "
|
|
54
|
+
"@frontmcp/lazy-zod": "1.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^24.0.0",
|
package/schemas/schemas.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Zod validation schemas for guard configuration.
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
export declare const partitionKeySchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
4
|
+
export declare const partitionKeySchema: import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
6
5
|
ip: "ip";
|
|
7
6
|
session: "session";
|
|
8
7
|
userId: "userId";
|
|
9
8
|
global: "global";
|
|
10
|
-
}>,
|
|
9
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
11
10
|
sessionId: string;
|
|
12
11
|
clientIp?: string;
|
|
13
12
|
userId?: string;
|
|
@@ -16,15 +15,15 @@ export declare const partitionKeySchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
16
15
|
clientIp?: string;
|
|
17
16
|
userId?: string;
|
|
18
17
|
}) => string>]>;
|
|
19
|
-
export declare const rateLimitConfigSchema:
|
|
20
|
-
maxRequests:
|
|
21
|
-
windowMs:
|
|
22
|
-
partitionBy:
|
|
18
|
+
export declare const rateLimitConfigSchema: import("@frontmcp/lazy-zod").ZodObject<{
|
|
19
|
+
maxRequests: import("@frontmcp/lazy-zod").ZodNumber;
|
|
20
|
+
windowMs: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
21
|
+
partitionBy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
23
22
|
ip: "ip";
|
|
24
23
|
session: "session";
|
|
25
24
|
userId: "userId";
|
|
26
25
|
global: "global";
|
|
27
|
-
}>,
|
|
26
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
28
27
|
sessionId: string;
|
|
29
28
|
clientIp?: string;
|
|
30
29
|
userId?: string;
|
|
@@ -33,16 +32,16 @@ export declare const rateLimitConfigSchema: z.ZodObject<{
|
|
|
33
32
|
clientIp?: string;
|
|
34
33
|
userId?: string;
|
|
35
34
|
}) => string>]>>>;
|
|
36
|
-
},
|
|
37
|
-
export declare const concurrencyConfigSchema:
|
|
38
|
-
maxConcurrent:
|
|
39
|
-
queueTimeoutMs:
|
|
40
|
-
partitionBy:
|
|
35
|
+
}, import("zod/v4/core").$strip>;
|
|
36
|
+
export declare const concurrencyConfigSchema: import("@frontmcp/lazy-zod").ZodObject<{
|
|
37
|
+
maxConcurrent: import("@frontmcp/lazy-zod").ZodNumber;
|
|
38
|
+
queueTimeoutMs: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
39
|
+
partitionBy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
41
40
|
ip: "ip";
|
|
42
41
|
session: "session";
|
|
43
42
|
userId: "userId";
|
|
44
43
|
global: "global";
|
|
45
|
-
}>,
|
|
44
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
46
45
|
sessionId: string;
|
|
47
46
|
clientIp?: string;
|
|
48
47
|
userId?: string;
|
|
@@ -51,33 +50,33 @@ export declare const concurrencyConfigSchema: z.ZodObject<{
|
|
|
51
50
|
clientIp?: string;
|
|
52
51
|
userId?: string;
|
|
53
52
|
}) => string>]>>>;
|
|
54
|
-
},
|
|
55
|
-
export declare const timeoutConfigSchema:
|
|
56
|
-
executeMs:
|
|
57
|
-
},
|
|
58
|
-
export declare const ipFilterConfigSchema:
|
|
59
|
-
allowList:
|
|
60
|
-
denyList:
|
|
61
|
-
defaultAction:
|
|
53
|
+
}, import("zod/v4/core").$strip>;
|
|
54
|
+
export declare const timeoutConfigSchema: import("@frontmcp/lazy-zod").ZodObject<{
|
|
55
|
+
executeMs: import("@frontmcp/lazy-zod").ZodNumber;
|
|
56
|
+
}, import("zod/v4/core").$strip>;
|
|
57
|
+
export declare const ipFilterConfigSchema: import("@frontmcp/lazy-zod").ZodObject<{
|
|
58
|
+
allowList: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
59
|
+
denyList: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
60
|
+
defaultAction: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodEnum<{
|
|
62
61
|
allow: "allow";
|
|
63
62
|
deny: "deny";
|
|
64
63
|
}>>>;
|
|
65
|
-
trustProxy:
|
|
66
|
-
trustedProxyDepth:
|
|
67
|
-
},
|
|
68
|
-
export declare const guardConfigSchema:
|
|
69
|
-
enabled:
|
|
70
|
-
storage:
|
|
71
|
-
keyPrefix:
|
|
72
|
-
global:
|
|
73
|
-
maxRequests:
|
|
74
|
-
windowMs:
|
|
75
|
-
partitionBy:
|
|
64
|
+
trustProxy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>>;
|
|
65
|
+
trustedProxyDepth: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
66
|
+
}, import("zod/v4/core").$strip>;
|
|
67
|
+
export declare const guardConfigSchema: import("@frontmcp/lazy-zod").ZodObject<{
|
|
68
|
+
enabled: import("@frontmcp/lazy-zod").ZodBoolean;
|
|
69
|
+
storage: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
70
|
+
keyPrefix: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>>;
|
|
71
|
+
global: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
72
|
+
maxRequests: import("@frontmcp/lazy-zod").ZodNumber;
|
|
73
|
+
windowMs: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
74
|
+
partitionBy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
76
75
|
ip: "ip";
|
|
77
76
|
session: "session";
|
|
78
77
|
userId: "userId";
|
|
79
78
|
global: "global";
|
|
80
|
-
}>,
|
|
79
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
81
80
|
sessionId: string;
|
|
82
81
|
clientIp?: string;
|
|
83
82
|
userId?: string;
|
|
@@ -86,16 +85,16 @@ export declare const guardConfigSchema: z.ZodObject<{
|
|
|
86
85
|
clientIp?: string;
|
|
87
86
|
userId?: string;
|
|
88
87
|
}) => string>]>>>;
|
|
89
|
-
},
|
|
90
|
-
globalConcurrency:
|
|
91
|
-
maxConcurrent:
|
|
92
|
-
queueTimeoutMs:
|
|
93
|
-
partitionBy:
|
|
88
|
+
}, import("zod/v4/core").$strip>>;
|
|
89
|
+
globalConcurrency: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
90
|
+
maxConcurrent: import("@frontmcp/lazy-zod").ZodNumber;
|
|
91
|
+
queueTimeoutMs: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
92
|
+
partitionBy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
94
93
|
ip: "ip";
|
|
95
94
|
session: "session";
|
|
96
95
|
userId: "userId";
|
|
97
96
|
global: "global";
|
|
98
|
-
}>,
|
|
97
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
99
98
|
sessionId: string;
|
|
100
99
|
clientIp?: string;
|
|
101
100
|
userId?: string;
|
|
@@ -104,16 +103,16 @@ export declare const guardConfigSchema: z.ZodObject<{
|
|
|
104
103
|
clientIp?: string;
|
|
105
104
|
userId?: string;
|
|
106
105
|
}) => string>]>>>;
|
|
107
|
-
},
|
|
108
|
-
defaultRateLimit:
|
|
109
|
-
maxRequests:
|
|
110
|
-
windowMs:
|
|
111
|
-
partitionBy:
|
|
106
|
+
}, import("zod/v4/core").$strip>>;
|
|
107
|
+
defaultRateLimit: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
108
|
+
maxRequests: import("@frontmcp/lazy-zod").ZodNumber;
|
|
109
|
+
windowMs: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
110
|
+
partitionBy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
112
111
|
ip: "ip";
|
|
113
112
|
session: "session";
|
|
114
113
|
userId: "userId";
|
|
115
114
|
global: "global";
|
|
116
|
-
}>,
|
|
115
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
117
116
|
sessionId: string;
|
|
118
117
|
clientIp?: string;
|
|
119
118
|
userId?: string;
|
|
@@ -122,16 +121,16 @@ export declare const guardConfigSchema: z.ZodObject<{
|
|
|
122
121
|
clientIp?: string;
|
|
123
122
|
userId?: string;
|
|
124
123
|
}) => string>]>>>;
|
|
125
|
-
},
|
|
126
|
-
defaultConcurrency:
|
|
127
|
-
maxConcurrent:
|
|
128
|
-
queueTimeoutMs:
|
|
129
|
-
partitionBy:
|
|
124
|
+
}, import("zod/v4/core").$strip>>;
|
|
125
|
+
defaultConcurrency: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
126
|
+
maxConcurrent: import("@frontmcp/lazy-zod").ZodNumber;
|
|
127
|
+
queueTimeoutMs: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
128
|
+
partitionBy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodEnum<{
|
|
130
129
|
ip: "ip";
|
|
131
130
|
session: "session";
|
|
132
131
|
userId: "userId";
|
|
133
132
|
global: "global";
|
|
134
|
-
}>,
|
|
133
|
+
}>, import("zod").ZodCustom<(ctx: {
|
|
135
134
|
sessionId: string;
|
|
136
135
|
clientIp?: string;
|
|
137
136
|
userId?: string;
|
|
@@ -140,18 +139,18 @@ export declare const guardConfigSchema: z.ZodObject<{
|
|
|
140
139
|
clientIp?: string;
|
|
141
140
|
userId?: string;
|
|
142
141
|
}) => string>]>>>;
|
|
143
|
-
},
|
|
144
|
-
defaultTimeout:
|
|
145
|
-
executeMs:
|
|
146
|
-
},
|
|
147
|
-
ipFilter:
|
|
148
|
-
allowList:
|
|
149
|
-
denyList:
|
|
150
|
-
defaultAction:
|
|
142
|
+
}, import("zod/v4/core").$strip>>;
|
|
143
|
+
defaultTimeout: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
144
|
+
executeMs: import("@frontmcp/lazy-zod").ZodNumber;
|
|
145
|
+
}, import("zod/v4/core").$strip>>;
|
|
146
|
+
ipFilter: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
147
|
+
allowList: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
148
|
+
denyList: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
149
|
+
defaultAction: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodEnum<{
|
|
151
150
|
allow: "allow";
|
|
152
151
|
deny: "deny";
|
|
153
152
|
}>>>;
|
|
154
|
-
trustProxy:
|
|
155
|
-
trustedProxyDepth:
|
|
156
|
-
},
|
|
157
|
-
},
|
|
153
|
+
trustProxy: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>>;
|
|
154
|
+
trustedProxyDepth: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
155
|
+
}, import("zod/v4/core").$strip>>;
|
|
156
|
+
}, import("zod/v4/core").$strip>;
|