velocious 1.0.700 → 1.0.701
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/build/configuration-types.js +1 -1
- package/build/configuration.js +52 -17
- package/build/src/configuration-types.d.ts +2 -2
- package/build/src/configuration-types.js +2 -2
- package/build/src/configuration.d.ts +11 -0
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +50 -17
- package/package.json +1 -1
- package/src/configuration-types.js +1 -1
- package/src/configuration.js +52 -17
package/package.json
CHANGED
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
* @property {string} [host] - Hostname to bind the HTTP server to.
|
|
330
330
|
* @property {boolean} [inProcess] - Run HTTP handlers in the main thread instead of worker threads.
|
|
331
331
|
* @property {number} [maxBufferedResponseBodyBytes] - Maximum UTF-8/binary byte length accepted by buffered response bodies. Unbounded when absent; streamed file responses are unaffected.
|
|
332
|
-
* @property {number} [maxRequestBodyBytes] - Maximum decoded request-body bytes accepted before routing. Unbounded when absent.
|
|
332
|
+
* @property {number} [maxRequestBodyBytes] - Maximum decoded request-body bytes accepted before routing. Unbounded when absent, except the built-in MCP endpoint, which defaults to a 1 MiB cap that this option overrides.
|
|
333
333
|
* @property {HttpRequestBodyPolicyResolver} [requestBodyPolicyResolver] - Optional synchronous header-stage resolver for per-request limits and raw-body handling.
|
|
334
334
|
* @property {number} [maxWorkers] - Backward-compatible alias for workers.
|
|
335
335
|
* @property {number} [port] - Port to bind the HTTP server to.
|
package/src/configuration.js
CHANGED
|
@@ -229,6 +229,14 @@ function normalizeHttpCompression(value) {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Default request-body limit for the built-in MCP endpoint. JSON-RPC messages are small,
|
|
234
|
+
* so the framework caps them instead of making every app that enables `mcp: true` restate
|
|
235
|
+
* a request-body policy. Explicit `httpServer.maxRequestBodyBytes` or a resolver limit wins.
|
|
236
|
+
* @type {number}
|
|
237
|
+
*/
|
|
238
|
+
const DEFAULT_MCP_MAX_REQUEST_BODY_BYTES = 1024 * 1024
|
|
239
|
+
|
|
232
240
|
export default class VelociousConfiguration {
|
|
233
241
|
/**
|
|
234
242
|
* Close database connections promise.
|
|
@@ -776,31 +784,58 @@ export default class VelociousConfiguration {
|
|
|
776
784
|
resolveHttpRequestBodyPolicy(args) {
|
|
777
785
|
const resolver = this.httpServer.requestBodyPolicyResolver
|
|
778
786
|
const configuredPolicy = resolver ? resolver(args) : undefined
|
|
787
|
+
/** @type {import("./configuration-types.js").ResolvedHttpRequestBodyPolicy} */
|
|
788
|
+
let resolvedPolicy
|
|
779
789
|
|
|
780
790
|
if (configuredPolicy === undefined) {
|
|
781
|
-
|
|
782
|
-
}
|
|
791
|
+
resolvedPolicy = {maxRequestBodyBytes: this.httpServer.maxRequestBodyBytes, mode: "parsed"}
|
|
792
|
+
} else {
|
|
793
|
+
if (!configuredPolicy || typeof configuredPolicy !== "object" || Array.isArray(configuredPolicy)) {
|
|
794
|
+
throw new TypeError("httpServer.requestBodyPolicyResolver must return an object or undefined")
|
|
795
|
+
}
|
|
783
796
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
797
|
+
const {maxRequestBodyBytes, mode = "parsed", ...restPolicy} = configuredPolicy
|
|
798
|
+
const unknownKeys = Object.keys(restPolicy)
|
|
787
799
|
|
|
788
|
-
|
|
789
|
-
|
|
800
|
+
if (unknownKeys.length > 0) {
|
|
801
|
+
throw new TypeError(`httpServer.requestBodyPolicyResolver returned unknown keys: ${unknownKeys.join(", ")} (supported: maxRequestBodyBytes, mode)`)
|
|
802
|
+
}
|
|
803
|
+
if (mode !== "parsed" && mode !== "raw") {
|
|
804
|
+
throw new TypeError(`httpServer.requestBodyPolicyResolver mode must be "parsed" or "raw", got: ${String(mode)}`)
|
|
805
|
+
}
|
|
790
806
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
807
|
+
resolvedPolicy = {
|
|
808
|
+
maxRequestBodyBytes: maxRequestBodyBytes === undefined
|
|
809
|
+
? this.httpServer.maxRequestBodyBytes
|
|
810
|
+
: optionalPositiveSafeInteger(maxRequestBodyBytes, "httpServer.requestBodyPolicyResolver maxRequestBodyBytes"),
|
|
811
|
+
mode
|
|
812
|
+
}
|
|
796
813
|
}
|
|
797
814
|
|
|
798
|
-
return {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
815
|
+
return this._applyMcpRequestBodyPolicyDefaults({args, policy: resolvedPolicy})
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Enforces the built-in MCP endpoint's body contract without per-app plumbing: the
|
|
820
|
+
* JSON-RPC envelope is read from parsed params, so raw mode is rejected with an
|
|
821
|
+
* actionable error, and a framework default byte cap applies when the app configured none.
|
|
822
|
+
* @param {{args: import("./configuration-types.js").HttpRequestBodyPolicyResolverArgs, policy: import("./configuration-types.js").ResolvedHttpRequestBodyPolicy}} options - Resolution inputs.
|
|
823
|
+
* @returns {import("./configuration-types.js").ResolvedHttpRequestBodyPolicy} - Effective request policy.
|
|
824
|
+
*/
|
|
825
|
+
_applyMcpRequestBodyPolicyDefaults({args, policy}) {
|
|
826
|
+
if (!this._mcp.enabled) return policy
|
|
827
|
+
if (args.httpMethod !== "POST") return policy
|
|
828
|
+
if (args.path.split("?")[0] !== this._mcp.path) return policy
|
|
829
|
+
|
|
830
|
+
if (policy.mode === "raw") {
|
|
831
|
+
throw new TypeError(
|
|
832
|
+
`The built-in MCP endpoint at ${this._mcp.path} requires parsed request bodies because its JSON-RPC envelope is read from params. Remove the raw-mode httpServer.requestBodyPolicyResolver entry for this path.`
|
|
833
|
+
)
|
|
803
834
|
}
|
|
835
|
+
|
|
836
|
+
if (policy.maxRequestBodyBytes !== undefined) return policy
|
|
837
|
+
|
|
838
|
+
return {maxRequestBodyBytes: DEFAULT_MCP_MAX_REQUEST_BODY_BYTES, mode: policy.mode}
|
|
804
839
|
}
|
|
805
840
|
|
|
806
841
|
/**
|