UNPKG

n8n-nodes-arubaclearpass

Version:

n8n community node for Aruba ClearPass API integration with comprehensive identity, policy, and enforcement profile management

59 lines (58 loc) 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSelfSignedCert = createSelfSignedCert; // methods/PlatformCertificates/SelfSignedCert.methods.ts const n8n_workflow_1 = require("n8n-workflow"); const apiRequest_1 = require("../../helpers/apiRequest"); const responseFormatter_1 = require("../../helpers/responseFormatter"); /** * Create a self-signed certificate * POST /self-signed-cert * * Required: certificate_type, server, type, subject_CN, * private_key_password, private_key_type, digest_algorithm * Optional: subject_O, subject_OU, subject_L, subject_ST, subject_C, subject_SAN */ async function createSelfSignedCert() { try { const body = { certificate_type: this.getNodeParameter('certificate_type', 0), server: this.getNodeParameter('server', 0), type: this.getNodeParameter('type', 0), subject_CN: this.getNodeParameter('subject_CN', 0), private_key_password: this.getNodeParameter('private_key_password', 0), private_key_type: this.getNodeParameter('private_key_type', 0), digest_algorithm: this.getNodeParameter('digest_algorithm', 0), }; // Optional subject fields from the collection const additionalSubject = this.getNodeParameter('additionalSubject', 0, {}); const optionalFields = [ 'subject_O', 'subject_OU', 'subject_L', 'subject_ST', 'subject_C', 'subject_SAN', ]; for (const field of optionalFields) { if (additionalSubject[field]) { body[field] = additionalSubject[field]; } } const responseData = await apiRequest_1.apiRequest.call(this, 'POST', '/self-signed-cert', body); return responseFormatter_1.formatResponse.call(this, responseData); } catch (error) { const errorObject = {}; if (error instanceof Error) { errorObject.message = error.message; if (error.stack) { errorObject.stackTrace = error.stack; } } else { errorObject.message = 'Unknown error in createSelfSignedCert'; } throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject); } }