@aikidosec/firewall
Version:
Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks
25 lines (24 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTestAgent = createTestAgent;
const Agent_1 = require("../agent/Agent");
const AgentSingleton_1 = require("../agent/AgentSingleton");
const ReportingAPIForTesting_1 = require("../agent/api/ReportingAPIForTesting");
const LoggerNoop_1 = require("../agent/logger/LoggerNoop");
const wrap_1 = require("./wrap");
/**
* Create a test agent for testing purposes
*/
function createTestAgent(opts) {
var _a, _b, _c, _d;
if ((_a = opts === null || opts === void 0 ? void 0 : opts.suppressConsoleLog) !== null && _a !== void 0 ? _a : true) {
(0, wrap_1.wrap)(console, "log", function log() {
return function log() { };
});
}
const agent = new Agent_1.Agent((_b = opts === null || opts === void 0 ? void 0 : opts.block) !== null && _b !== void 0 ? _b : true, (_c = opts === null || opts === void 0 ? void 0 : opts.logger) !== null && _c !== void 0 ? _c : new LoggerNoop_1.LoggerNoop(), (_d = opts === null || opts === void 0 ? void 0 : opts.api) !== null && _d !== void 0 ? _d : new ReportingAPIForTesting_1.ReportingAPIForTesting(), opts === null || opts === void 0 ? void 0 : opts.token, // Defaults to undefined
opts === null || opts === void 0 ? void 0 : opts.serverless // Defaults to undefined
);
(0, AgentSingleton_1.setInstance)(agent);
return agent;
}