decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
36 lines • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContext = getContext;
exports.setSchemaValidator = setSchemaValidator;
exports.setDOMParserOptions = setDOMParserOptions;
var xmldom_1 = require("@xmldom/xmldom");
var XXE_SAFE_OPTIONS = {
/**
* Treat XML parsing errors as fatal to prevent XXE attacks.
* Entity references (e.g. &xxe;) and malformed XML in SAML messages
* are not expected and may indicate an attack attempt.
*/
errorHandler: {
error: function (msg) { throw new Error("XML parsing error: ".concat(msg)); },
fatalError: function (msg) { throw new Error("XML fatal error: ".concat(msg)); },
},
};
var context = {
validate: undefined,
dom: new xmldom_1.DOMParser(XXE_SAFE_OPTIONS)
};
function getContext() {
return context;
}
function setSchemaValidator(params) {
if (typeof params.validate !== 'function') {
throw new Error('validate must be a callback function having one argument as xml input');
}
// assign the validate function to the context
context.validate = params.validate;
}
function setDOMParserOptions(options) {
if (options === void 0) { options = {}; }
context.dom = new xmldom_1.DOMParser(options);
}
//# sourceMappingURL=api.js.map