Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

add xspace-agent/xspace-agent/src/server/middleware/security.ts

overstepping32c2bc9dab3c
diff --git a/xspace-agent/xspace-agent/src/server/middleware/security.ts b/xspace-agent/xspace-agent/src/server/middleware/security.ts
new file mode 100644
index 000000000..7c0d7c62d
--- /dev/null
+++ b/xspace-agent/xspace-agent/src/server/middleware/security.ts
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§73]
+
+import helmet from "helmet"
+import type { RequestHandler } from "express"
+
+export function createSecurityMiddleware(): RequestHandler {
+ return helmet({
+ contentSecurityPolicy: {
+ directives: {
+ defaultSrc: ["'self'"],
+ scriptSrc: ["'self'", "'unsafe-inline'"],
+ styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com"],
+ fontSrc: ["'self'", "https://fonts.gstatic.com"],
+ imgSrc: ["'self'", "data:", "blob:"],
+ connectSrc: ["'self'", "ws:", "wss:"],
+ frameSrc: ["'none'"],
+ objectSrc: ["'none'"],
+ baseUri: ["'self'"],
+ },
+ },
+ xFrameOptions: { action: "deny" },
+ referrerPolicy: { policy: "strict-origin-when-cross-origin" },
+ xContentTypeOptions: true,
+ }) as RequestHandler
+}
+
+