UNPKG

n8n-nodes-binalyze-air

Version:

Binalyze AIR nodes for automating DFIR with n8n workflows

58 lines 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.api = void 0; const helpers_1 = require("../../utils/helpers"); exports.api = { async acquireBaseline(context, credentials, request) { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', '/api/public/baseline/acquire'); requestOptions.body = request; const response = await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, 'acquire baseline'); return response; }, async compareBaseline(context, credentials, request) { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', '/api/public/baseline/compare'); requestOptions.body = request; const response = await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, 'compare baseline'); return response; }, async getComparisonReport(context, credentials, endpointId, taskId) { var _a; const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', `/api/public/baseline/comparison/report/${endpointId}/${taskId}`); requestOptions.json = false; requestOptions.headers['Accept'] = 'text/html'; try { const response = await context.helpers.httpRequest(requestOptions); if (typeof response === 'string' && response.includes('<html')) { const scriptMatch = response.match(/<script\s+id="dronejson"\s+type="text\/plain">\s*([^<]+)\s*<\/script>/); if (scriptMatch && scriptMatch[1]) { try { const base64String = scriptMatch[1].trim(); const decodedString = Buffer.from(base64String, 'base64').toString('utf-8'); const reportJson = JSON.parse(decodedString); return { success: true, message: `Comparison report retrieved successfully for endpoint ${endpointId} and task ${taskId}`, reportJson }; } catch (decodeError) { throw new Error(`Failed to decode comparison report: ${decodeError.message}`); } } else { throw new Error('Could not find comparison report data in the HTML response'); } } else { throw new Error('Expected HTML response but received different format'); } } catch (error) { if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) { throw new Error(`Comparison report not found for endpoint ${endpointId} and task ${taskId}`); } throw error; } } }; //# sourceMappingURL=baseline.js.map