UNPKG

n8n-nodes-tenable-community

Version:

n8n node for the Tenable One platform

44 lines (43 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.webAppScanningApiRequest = webAppScanningApiRequest; async function webAppScanningApiRequest(resource, operation, body = {}, qs = {}) { const credentials = await this.getCredentials('tenableApi'); const baseUrl = 'https://cloud.tenable.com/was/v2'; let endpoint = ''; let method = 'GET'; // The endpoint and method are now determined by the caller via the body/qs // This is a simplified example. A full implementation would be in the node. switch (resource) { case 'attachment': if (operation === 'download') { endpoint = `/attachments/${qs.attachmentId}`; method = 'GET'; } break; case 'configuration': if (operation === 'search') { endpoint = '/configs/search'; method = 'POST'; } break; // ... other resources would be handled by the node's execute method } const options = { headers: { 'X-ApiKeys': `accessKey=${credentials.accessKey};secretKey=${credentials.secretKey}`, 'Content-Type': 'application/json', }, method, url: `${baseUrl}${endpoint}`, body, json: true, }; if (Object.keys(body).length === 0) { delete options.body; } if (Object.keys(qs).length === 0) { delete options.qs; } return this.helpers.httpRequest(options); }