2024-08-29 06:55:53 -07:00
|
|
|
import {
|
|
|
|
type IExecuteFunctions,
|
|
|
|
type IDataObject,
|
|
|
|
type ILoadOptionsFunctions,
|
|
|
|
type INodeExecutionData,
|
|
|
|
type INodePropertyOptions,
|
|
|
|
type INodeType,
|
|
|
|
type INodeTypeDescription,
|
|
|
|
NodeConnectionType,
|
2022-10-07 06:48:45 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
import { encryptPassphrase, venafiApiRequest, venafiApiRequestAllItems } from './GenericFunctions';
|
|
|
|
|
|
|
|
import { certificateFields, certificateOperations } from './CertificateDescription';
|
|
|
|
|
|
|
|
import {
|
|
|
|
certificateRequestFields,
|
|
|
|
certificateRequestOperations,
|
|
|
|
} from './CertificateRequestDescription';
|
|
|
|
|
2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-10-07 06:48:45 -07:00
|
|
|
ICertficateKeystoreRequest,
|
|
|
|
ICertficateRequest,
|
|
|
|
ICsrAttributes,
|
|
|
|
IKeyTypeParameters,
|
|
|
|
ISubjectAltNamesByType,
|
|
|
|
} from './CertificateInterface';
|
|
|
|
|
|
|
|
export class VenafiTlsProtectCloud implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'Venafi TLS Protect Cloud',
|
|
|
|
name: 'venafiTlsProtectCloud',
|
|
|
|
icon: 'file:../venafi.svg',
|
|
|
|
group: ['input'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
feat(editor): Node creator actions (#4696)
* WIP: Node Actions List UI
* WIP: Recommended Actions and preseting of fields
* WIP: Resource category
* :art: Moved actions categorisation to the server
* :label: Add missing INodeAction type
* :sparkles: Improve SSR categorisation, fix adding of mixed actions
* :recycle: Refactor CategorizedItems to composition api, style fixes
* WIP: Adding multiple nodes
* :recycle: Refactor rest of the NodeCreator component to composition API, conver globalLinkActions to composable
* :sparkles: Allow actions dragging, fix search and refactor passing of actions to categorized items
* :lipstick: Fix node actions title
* Migrate to the pinia store, add posthog feature and various fixes
* :bug: Fix filtering of trigger actions when not merged
* fix: N8N-5439 — Do not use simple node item when at NodeHelperPanel root
* :bug: Design review fixes
* :bug: Fix disabling of merged actions
* Fix trigger root filtering
* :sparkles: Allow for custom node actions parser, introduce hubspot parser
* :bug: Fix initial node params validation, fix position of second added node
* :bug: Introduce operations category, removed canvas node names overrride, fix API actions display and prevent dragging of action nodes
* :sparkles: Prevent NDV auto-open feature flag
* :bug: Inject recommened action for trigger nodes without actions
* Refactored NodeCreatorNode to Storybook, change filtering of merged nodes for the trigger helper panel, minor fixes
* Improve rendering of app nodes and animation
* Cleanup, any only enable accordion transition on triggerhelperpanel
* Hide node creator scrollbars in Firefox
* Minor styles fixes
* Do not copy the array in rendering method
* Removed unused props
* Fix memory leak
* Fix categorisation of regular nodes with a single resource
* Implement telemetry calls for node actions
* Move categorization to FE
* Fix client side actions categorisation
* Skip custom action show
* Only load tooltip for NodeIcon if necessary
* Fix lodash startCase import
* Remove lodash.startcase
* Cleanup
* Fix node creator autofocus on "tab"
* Prevent posthog getFeatureFlag from crashing
* Debugging preview env search issues
* Remove logs
* Make sure the pre-filled params are update not overwritten
* Get rid of transition in itemiterator
* WIP: Rough version of NodeActions keyboard navigation, replace nodeCreator composable with Pinia store module
* Rewrite to add support for ActionItem to ItemIterator and make CategorizedItems accept items props
* Fix category item counter & cleanup
* Add APIHint to actions search no-result, clean up NodeCreatorNode
* Improve node actions no results message
* Remove logging, fix filtering of recommended placeholder category
* Remove unused NodeActions component and node merging feature falg
* Do not show regular nodes without actions
* Make sure to add manual trigger when adding http node via actions hint
* Fixed api hint footer line height
* Prevent pointer-events od NodeIcon img and remove "this" from template
* Address PR points
* Fix e2e specs
* Make sure canvas ia loaded
* Make sure canvas ia loaded before opening nodeCreator in e2e spec
* Fix flaky workflows tags e2e getter
* Imrpove node creator click outside UX, add manual node to regular nodes added from trigger panel
* Add manual trigger node if dragging regular from trigger panel
2022-12-09 01:56:36 -08:00
|
|
|
description: 'Consume Venafi TLS Protect Cloud API',
|
2022-10-07 06:48:45 -07:00
|
|
|
defaults: {
|
feat(editor): Node creator actions (#4696)
* WIP: Node Actions List UI
* WIP: Recommended Actions and preseting of fields
* WIP: Resource category
* :art: Moved actions categorisation to the server
* :label: Add missing INodeAction type
* :sparkles: Improve SSR categorisation, fix adding of mixed actions
* :recycle: Refactor CategorizedItems to composition api, style fixes
* WIP: Adding multiple nodes
* :recycle: Refactor rest of the NodeCreator component to composition API, conver globalLinkActions to composable
* :sparkles: Allow actions dragging, fix search and refactor passing of actions to categorized items
* :lipstick: Fix node actions title
* Migrate to the pinia store, add posthog feature and various fixes
* :bug: Fix filtering of trigger actions when not merged
* fix: N8N-5439 — Do not use simple node item when at NodeHelperPanel root
* :bug: Design review fixes
* :bug: Fix disabling of merged actions
* Fix trigger root filtering
* :sparkles: Allow for custom node actions parser, introduce hubspot parser
* :bug: Fix initial node params validation, fix position of second added node
* :bug: Introduce operations category, removed canvas node names overrride, fix API actions display and prevent dragging of action nodes
* :sparkles: Prevent NDV auto-open feature flag
* :bug: Inject recommened action for trigger nodes without actions
* Refactored NodeCreatorNode to Storybook, change filtering of merged nodes for the trigger helper panel, minor fixes
* Improve rendering of app nodes and animation
* Cleanup, any only enable accordion transition on triggerhelperpanel
* Hide node creator scrollbars in Firefox
* Minor styles fixes
* Do not copy the array in rendering method
* Removed unused props
* Fix memory leak
* Fix categorisation of regular nodes with a single resource
* Implement telemetry calls for node actions
* Move categorization to FE
* Fix client side actions categorisation
* Skip custom action show
* Only load tooltip for NodeIcon if necessary
* Fix lodash startCase import
* Remove lodash.startcase
* Cleanup
* Fix node creator autofocus on "tab"
* Prevent posthog getFeatureFlag from crashing
* Debugging preview env search issues
* Remove logs
* Make sure the pre-filled params are update not overwritten
* Get rid of transition in itemiterator
* WIP: Rough version of NodeActions keyboard navigation, replace nodeCreator composable with Pinia store module
* Rewrite to add support for ActionItem to ItemIterator and make CategorizedItems accept items props
* Fix category item counter & cleanup
* Add APIHint to actions search no-result, clean up NodeCreatorNode
* Improve node actions no results message
* Remove logging, fix filtering of recommended placeholder category
* Remove unused NodeActions component and node merging feature falg
* Do not show regular nodes without actions
* Make sure to add manual trigger when adding http node via actions hint
* Fixed api hint footer line height
* Prevent pointer-events od NodeIcon img and remove "this" from template
* Address PR points
* Fix e2e specs
* Make sure canvas ia loaded
* Make sure canvas ia loaded before opening nodeCreator in e2e spec
* Fix flaky workflows tags e2e getter
* Imrpove node creator click outside UX, add manual node to regular nodes added from trigger panel
* Add manual trigger node if dragging regular from trigger panel
2022-12-09 01:56:36 -08:00
|
|
|
name: 'Venafi TLS Protect Cloud',
|
2022-10-07 06:48:45 -07:00
|
|
|
},
|
2024-08-29 06:55:53 -07:00
|
|
|
inputs: [NodeConnectionType.Main],
|
|
|
|
outputs: [NodeConnectionType.Main],
|
2022-10-07 06:48:45 -07:00
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'venafiTlsProtectCloudApi',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
properties: [
|
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
noDataExpression: true,
|
|
|
|
type: 'options',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Certificate',
|
|
|
|
value: 'certificate',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Certificate Request',
|
|
|
|
value: 'certificateRequest',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'certificateRequest',
|
|
|
|
},
|
|
|
|
...certificateOperations,
|
|
|
|
...certificateFields,
|
|
|
|
...certificateRequestOperations,
|
|
|
|
...certificateRequestFields,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
loadOptions: {
|
|
|
|
async getApplications(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
|
|
|
const { applications } = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
'/outagedetection/v1/applications',
|
|
|
|
);
|
2022-11-01 06:56:00 -07:00
|
|
|
|
2022-10-07 06:48:45 -07:00
|
|
|
for (const application of applications) {
|
|
|
|
returnData.push({
|
|
|
|
name: application.name,
|
|
|
|
value: application.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
async getCertificateIssuingTemplates(
|
|
|
|
this: ILoadOptionsFunctions,
|
|
|
|
): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
2022-11-01 06:56:00 -07:00
|
|
|
const currentApplication: string = this.getCurrentNodeParameter('applicationId') as string;
|
|
|
|
|
2022-11-18 06:26:22 -08:00
|
|
|
const { certificateIssuingTemplateAliasIdMap } = (await venafiApiRequest.call(
|
2022-10-07 06:48:45 -07:00
|
|
|
this,
|
|
|
|
'GET',
|
2022-11-01 06:56:00 -07:00
|
|
|
`/outagedetection/v1/applications/${currentApplication}`,
|
2022-11-18 06:26:22 -08:00
|
|
|
)) as { certificateIssuingTemplateAliasIdMap: { [key: string]: string } };
|
2022-11-01 06:56:00 -07:00
|
|
|
|
2022-11-18 06:26:22 -08:00
|
|
|
for (const [templateName, templateId] of Object.entries(
|
|
|
|
certificateIssuingTemplateAliasIdMap,
|
|
|
|
)) {
|
2022-10-07 06:48:45 -07:00
|
|
|
returnData.push({
|
2022-11-01 06:56:00 -07:00
|
|
|
name: templateName,
|
|
|
|
value: templateId,
|
2022-10-07 06:48:45 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
|
|
|
const returnData: IDataObject[] = [];
|
|
|
|
const length = items.length;
|
|
|
|
const qs: IDataObject = {};
|
|
|
|
let responseData;
|
2022-12-02 03:53:59 -08:00
|
|
|
const resource = this.getNodeParameter('resource', 0);
|
|
|
|
const operation = this.getNodeParameter('operation', 0);
|
2022-10-07 06:48:45 -07:00
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
try {
|
|
|
|
if (resource === 'certificateRequest') {
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config&urls.primaryName=outagedetection-service#//v1/certificaterequests_create
|
|
|
|
if (operation === 'create') {
|
|
|
|
const applicationId = this.getNodeParameter('applicationId', i) as string;
|
|
|
|
const certificateIssuingTemplateId = this.getNodeParameter(
|
|
|
|
'certificateIssuingTemplateId',
|
|
|
|
i,
|
|
|
|
) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const options = this.getNodeParameter('options', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
const generateCsr = this.getNodeParameter('generateCsr', i) as boolean;
|
|
|
|
|
|
|
|
const body: ICertficateRequest = {
|
|
|
|
applicationId,
|
|
|
|
certificateIssuingTemplateId,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (generateCsr) {
|
|
|
|
const commonName = this.getNodeParameter('commonName', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
|
|
|
|
const keyTypeDetails: IKeyTypeParameters = {};
|
|
|
|
const csrAttributes: ICsrAttributes = {};
|
|
|
|
const subjectAltNamesByType: ISubjectAltNamesByType = {};
|
|
|
|
|
|
|
|
body.isVaaSGenerated = true;
|
|
|
|
|
2022-12-02 12:54:28 -08:00
|
|
|
csrAttributes.commonName = commonName;
|
2022-10-07 06:48:45 -07:00
|
|
|
|
|
|
|
// Csr Generation
|
|
|
|
if (additionalFields.organization) {
|
|
|
|
csrAttributes.organization = additionalFields.organization as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.organizationalUnits) {
|
|
|
|
csrAttributes.organizationalUnits =
|
|
|
|
additionalFields.organizationalUnits as string[];
|
|
|
|
}
|
|
|
|
if (additionalFields.locality) {
|
|
|
|
csrAttributes.locality = additionalFields.locality as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.state) {
|
|
|
|
csrAttributes.state = additionalFields.state as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.country) {
|
|
|
|
csrAttributes.country = additionalFields.country as string;
|
|
|
|
}
|
|
|
|
body.csrAttributes = csrAttributes;
|
|
|
|
|
|
|
|
// Key type
|
|
|
|
if (additionalFields.keyType) {
|
|
|
|
keyTypeDetails.keyType = additionalFields.keyType as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.keyCurve) {
|
|
|
|
keyTypeDetails.keyCurve = additionalFields.keyCurve as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.keyLength) {
|
|
|
|
keyTypeDetails.keyLength = additionalFields.keyLength as number;
|
|
|
|
}
|
|
|
|
if (Object.keys(keyTypeDetails).length !== 0) {
|
|
|
|
body.csrAttributes.keyTypeParameters = keyTypeDetails;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SAN
|
|
|
|
if (additionalFields.SubjectAltNamesUi) {
|
|
|
|
for (const key of (additionalFields.SubjectAltNamesUi as IDataObject)
|
|
|
|
.SubjectAltNamesValues as IDataObject[]) {
|
|
|
|
if (key.Typename === 'dnsNames') {
|
|
|
|
subjectAltNamesByType.dnsNames
|
|
|
|
? subjectAltNamesByType.dnsNames.push(key.name as string)
|
|
|
|
: (subjectAltNamesByType.dnsNames = [key.name as string]);
|
|
|
|
}
|
|
|
|
/*if (key.Typename === 'ipAddresses') {
|
|
|
|
subjectAltNamesByType.ipAddresses ? subjectAltNamesByType.ipAddresses.push(key.name as string) : subjectAltNamesByType.ipAddresses = [key.name as string];
|
|
|
|
}
|
|
|
|
if (key.Typename === 'rfc822Names') {
|
|
|
|
subjectAltNamesByType.rfc822Names ? subjectAltNamesByType.rfc822Names.push(key.name as string) : subjectAltNamesByType.rfc822Names = [key.name as string];
|
|
|
|
}
|
|
|
|
if (key.Typename === 'uniformResourceIdentifiers') {
|
|
|
|
subjectAltNamesByType.uniformResourceIdentifiers ? subjectAltNamesByType.uniformResourceIdentifiers.push(key.name as string) : subjectAltNamesByType.uniformResourceIdentifiers = [key.name as string];
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Object.keys(subjectAltNamesByType).length !== 0) {
|
|
|
|
body.csrAttributes.subjectAlternativeNamesByType = subjectAltNamesByType;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const certificateSigningRequest = this.getNodeParameter(
|
|
|
|
'certificateSigningRequest',
|
|
|
|
i,
|
|
|
|
) as string;
|
|
|
|
body.isVaaSGenerated = false;
|
|
|
|
body.certificateSigningRequest = certificateSigningRequest;
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.assign(body, options);
|
|
|
|
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificaterequests',
|
2022-10-07 06:48:45 -07:00
|
|
|
body,
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
|
|
|
|
responseData = responseData.certificateRequests;
|
|
|
|
}
|
|
|
|
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config&urls.primaryName=outagedetection-service#//v1/certificaterequests_getById
|
|
|
|
if (operation === 'get') {
|
|
|
|
const certificateId = this.getNodeParameter('certificateRequestId', i) as string;
|
|
|
|
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/outagedetection/v1/certificaterequests/${certificateId}`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config&urls.primaryName=outagedetection-service#//v1/certificaterequests_getAll
|
|
|
|
if (operation === 'getMany') {
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
|
|
|
|
if (returnAll) {
|
|
|
|
responseData = await venafiApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'certificateRequests',
|
|
|
|
'GET',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificaterequests',
|
2022-10-07 06:48:45 -07:00
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
const limit = this.getNodeParameter('limit', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificaterequests',
|
2022-10-07 06:48:45 -07:00
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
|
|
|
|
responseData = responseData.certificateRequests.splice(0, limit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resource === 'certificate') {
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config&urls.primaryName=outagedetection-service#/%2Fv1/certificateretirement_deleteCertificates
|
|
|
|
if (operation === 'delete') {
|
|
|
|
const certificateId = this.getNodeParameter('certificateId', i) as string;
|
|
|
|
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificates/deletion',
|
2022-10-07 06:48:45 -07:00
|
|
|
{ certificateIds: [certificateId] },
|
|
|
|
);
|
|
|
|
|
|
|
|
responseData = responseData.certificates;
|
|
|
|
}
|
|
|
|
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config&urls.primaryName=outagedetection-service#/
|
|
|
|
if (operation === 'download') {
|
|
|
|
const certificateId = this.getNodeParameter('certificateId', i) as string;
|
2022-12-02 03:53:59 -08:00
|
|
|
const binaryProperty = this.getNodeParameter('binaryProperty', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
const downloadItem = this.getNodeParameter('downloadItem', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const options = this.getNodeParameter('options', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
|
|
|
|
// Cert Download
|
|
|
|
if (downloadItem === 'certificate') {
|
|
|
|
Object.assign(qs, options);
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/outagedetection/v1/certificates/${certificateId}/contents`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
{ encoding: null, json: false, resolveWithFullResponse: true, cert: true },
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
const exportFormat = this.getNodeParameter('keystoreType', i) as string;
|
|
|
|
|
|
|
|
const body: ICertficateKeystoreRequest = {
|
|
|
|
exportFormat,
|
|
|
|
};
|
|
|
|
|
|
|
|
const privateKeyPassphrase = this.getNodeParameter(
|
|
|
|
'privateKeyPassphrase',
|
|
|
|
i,
|
|
|
|
) as string;
|
|
|
|
const certificateLabel = this.getNodeParameter('certificateLabel', i) as string;
|
|
|
|
|
|
|
|
body.certificateLabel = certificateLabel;
|
|
|
|
|
|
|
|
let keystorePassphrase = '';
|
|
|
|
|
|
|
|
if (exportFormat === 'JKS') {
|
|
|
|
keystorePassphrase = this.getNodeParameter('keystorePassphrase', i) as string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const encryptedValues = (await encryptPassphrase.call(
|
|
|
|
this,
|
|
|
|
certificateId,
|
|
|
|
privateKeyPassphrase,
|
|
|
|
keystorePassphrase,
|
|
|
|
)) as string;
|
|
|
|
body.encryptedPrivateKeyPassphrase = encryptedValues[0];
|
|
|
|
if (exportFormat === 'JKS') {
|
|
|
|
body.encryptedKeystorePassphrase = encryptedValues[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
`/outagedetection/v1/certificates/${certificateId}/keystore`,
|
|
|
|
body,
|
|
|
|
{},
|
|
|
|
{ encoding: null, json: false, resolveWithFullResponse: true },
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-27 19:39:43 -08:00
|
|
|
const contentDisposition: string = responseData.headers['content-disposition'];
|
2022-10-07 06:48:45 -07:00
|
|
|
const fileNameRegex = /(?<=filename=").*\b/;
|
|
|
|
const match = fileNameRegex.exec(contentDisposition);
|
|
|
|
let fileName = '';
|
|
|
|
|
|
|
|
if (match !== null) {
|
|
|
|
fileName = match[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
const binaryData = await this.helpers.prepareBinaryData(
|
2023-02-27 19:39:43 -08:00
|
|
|
Buffer.from(responseData.body as Buffer),
|
2022-10-07 06:48:45 -07:00
|
|
|
fileName,
|
|
|
|
);
|
|
|
|
|
|
|
|
responseData = {
|
|
|
|
json: {},
|
|
|
|
binary: {
|
|
|
|
[binaryProperty]: binaryData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config&urls.primaryName=outagedetection-service#/%2Fv1/certificates_getById
|
|
|
|
if (operation === 'get') {
|
|
|
|
const certificateId = this.getNodeParameter('certificateId', i) as string;
|
|
|
|
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/outagedetection/v1/certificates/${certificateId}`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//https://api.venafi.cloud/webjars/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config&urls.primaryName=outagedetection-service#/%2Fv1/certificates_getAllAsCsv
|
|
|
|
if (operation === 'getMany') {
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', i);
|
2022-11-18 07:29:44 -08:00
|
|
|
const filters = this.getNodeParameter('filters', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
|
|
|
|
Object.assign(qs, filters);
|
|
|
|
|
|
|
|
if (returnAll) {
|
|
|
|
responseData = await venafiApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'certificates',
|
|
|
|
'GET',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificates',
|
2022-10-07 06:48:45 -07:00
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
qs.limit = this.getNodeParameter('limit', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificates',
|
2022-10-07 06:48:45 -07:00
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
|
|
|
|
responseData = responseData.certificates;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//https://docs.venafi.cloud/api/t-cloud-api-renew-cert/
|
|
|
|
if (operation === 'renew') {
|
|
|
|
const applicationId = this.getNodeParameter('applicationId', i) as string;
|
|
|
|
const certificateIssuingTemplateId = this.getNodeParameter(
|
|
|
|
'certificateIssuingTemplateId',
|
|
|
|
i,
|
|
|
|
) as string;
|
|
|
|
const certificateSigningRequest = this.getNodeParameter(
|
|
|
|
'certificateSigningRequest',
|
|
|
|
i,
|
|
|
|
) as string;
|
|
|
|
const existingCertificateId = this.getNodeParameter(
|
|
|
|
'existingCertificateId',
|
|
|
|
i,
|
|
|
|
) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const options = this.getNodeParameter('options', i);
|
2022-10-07 06:48:45 -07:00
|
|
|
|
|
|
|
const body: IDataObject = {
|
|
|
|
certificateSigningRequest,
|
|
|
|
certificateIssuingTemplateId,
|
|
|
|
applicationId,
|
|
|
|
existingCertificateId,
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.assign(body, options);
|
|
|
|
|
|
|
|
responseData = await venafiApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
2022-12-29 03:20:43 -08:00
|
|
|
'/outagedetection/v1/certificaterequests',
|
2022-10-07 06:48:45 -07:00
|
|
|
body,
|
|
|
|
qs,
|
|
|
|
);
|
|
|
|
|
|
|
|
responseData = responseData.certificateRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
returnData.push(
|
2023-02-27 19:39:43 -08:00
|
|
|
...this.helpers.constructExecutionMetaData(
|
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
|
|
|
{
|
|
|
|
itemData: { item: i },
|
|
|
|
},
|
|
|
|
),
|
2022-10-07 06:48:45 -07:00
|
|
|
);
|
|
|
|
} catch (error) {
|
2024-08-30 00:59:30 -07:00
|
|
|
if (this.continueOnFail()) {
|
2022-10-07 06:48:45 -07:00
|
|
|
returnData.push({ json: { error: error.message } });
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [returnData as INodeExecutionData[]];
|
|
|
|
}
|
|
|
|
}
|