Subir archivos a "integra-mcp"

This commit is contained in:
2026-11-08 18:57:59 +00:00
parent aa3d296160
commit 716f1f6bc7
5 changed files with 381 additions and 0 deletions

27
integra-mcp/security.mjs Normal file
View File

@@ -0,0 +1,27 @@
export function publicBillingSettings(value = {}) {
// Safe for the PUBLIC customer portal. Never return stripe_sk or other keys.
return Object.fromEntries(['iban', 'bank_name', 'account_holder', 'observations', 'stripe_enabled']
.filter(k => Object.hasOwn(value, k)).map(k => [k, value[k]]));
}
const secretKey = /password|secret|token|api[_-]?key|stripe[_-]?[sp]k|signature|pdf_base64|contract_pdf_url|pdf_raw_data/i;
export function redact(value) {
if (Array.isArray(value)) return value.map(redact);
if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value)
.filter(([key]) => !secretKey.test(key)).map(([key, val]) => [key, redact(val)]));
return value;
}
export function normalizeOrigin(value) {
const url = new URL(value);
if (url.protocol !== 'https:' || url.username || url.password || url.pathname !== '/' || url.search || url.hash)
throw new Error('INTEGRA_MCP_PUBLIC_ORIGIN debe ser un origen HTTPS sin ruta, por ejemplo https://tu-backend.es');
return url.origin;
}
export function safeRedirect(value) {
try {
const u = new URL(value);
return !u.username && !u.password && !u.hash && u.protocol === 'https:';
} catch { return false; }
}