npm build successful
This commit is contained in:
parent
23179f4513
commit
9f6db09edf
|
|
@ -1,2 +1,4 @@
|
||||||
dist
|
dist
|
||||||
node_modules
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
.n8n/.env
|
||||||
|
|
@ -1,229 +1,227 @@
|
||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
NodeOperationError,
|
NodeOperationError,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import { SecloreDRMFileService } from './Services/SecloreDRMFileService';
|
import { SecloreDRMFileService } from './Services/SecloreDRMFileService';
|
||||||
|
|
||||||
export class SecloreProtect implements INodeType {
|
export class SecloreProtect implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'Seclore Protect',
|
displayName: 'Seclore Protect',
|
||||||
name: 'secloreProtect',
|
name: 'secloreProtect',
|
||||||
icon: 'file:SecloreProtect.svg',
|
icon: 'file:SecloreProtect.svg',
|
||||||
group: ['transform'],
|
group: ['transform'],
|
||||||
version: 1,
|
version: 1,
|
||||||
subtitle: '={{$parameter["operation"]}}',
|
subtitle: '={{$parameter["operation"]}}',
|
||||||
description: 'Protect files using Seclore DRM with HotFolder configuration',
|
description: 'Protect files using Seclore DRM with HotFolder configuration',
|
||||||
defaults: {
|
defaults: {
|
||||||
name: 'Seclore Protect',
|
name: 'Seclore Protect',
|
||||||
},
|
},
|
||||||
inputs: ['main'],
|
inputs: ['main'],
|
||||||
outputs: ['main'],
|
outputs: ['main'],
|
||||||
credentials: [
|
credentials: [
|
||||||
{
|
{
|
||||||
name: 'secloreProtectApi',
|
name: 'secloreProtectApi',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
noDataExpression: true,
|
noDataExpression: true,
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Protect File with HotFolder',
|
name: 'Protect File with HotFolder',
|
||||||
value: 'protectWithHotFolder',
|
value: 'protectWithHotFolder',
|
||||||
description: 'Protect a file using HotFolder ID configuration',
|
description: 'Protect a file using HotFolder ID configuration',
|
||||||
action: 'Protect file with HotFolder',
|
action: 'Protect file with HotFolder',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'protectWithHotFolder',
|
default: 'protectWithHotFolder',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'HotFolder ID',
|
displayName: 'HotFolder ID',
|
||||||
name: 'hotfolderId',
|
name: 'hotfolderId',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
default: '',
|
default: '',
|
||||||
placeholder: 'e.g., hf-12345',
|
placeholder: 'e.g., hf-12345',
|
||||||
description: 'The ID of the HotFolder configuration to use for protection',
|
description: 'The ID of the HotFolder configuration to use for protection',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: ['protectWithHotFolder'],
|
operation: ['protectWithHotFolder'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Input Binary Property',
|
displayName: 'Input Binary Property',
|
||||||
name: 'binaryPropertyName',
|
name: 'binaryPropertyName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'data',
|
default: 'data',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'Name of the binary property that contains the file to protect',
|
description: 'Name of the binary property that contains the file to protect',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: ['protectWithHotFolder'],
|
operation: ['protectWithHotFolder'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Output Binary Property',
|
displayName: 'Output Binary Property',
|
||||||
name: 'outputBinaryPropertyName',
|
name: 'outputBinaryPropertyName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'data',
|
default: 'data',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'Name of the binary property where the protected file will be stored',
|
description: 'Name of the binary property where the protected file will be stored',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: ['protectWithHotFolder'],
|
operation: ['protectWithHotFolder'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Correlation ID',
|
displayName: 'Correlation ID',
|
||||||
name: 'correlationId',
|
name: 'correlationId',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
placeholder: 'e.g., req-12345',
|
placeholder: 'e.g., req-12345',
|
||||||
description: 'Optional correlation ID for request tracking and logging',
|
description: 'Optional correlation ID for request tracking and logging',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: ['protectWithHotFolder'],
|
operation: ['protectWithHotFolder'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Retry Count',
|
displayName: 'Retry Count',
|
||||||
name: 'retryCount',
|
name: 'retryCount',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
default: 3,
|
default: 3,
|
||||||
description: 'Number of retry attempts for failed requests',
|
description: 'Number of retry attempts for failed requests',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: ['protectWithHotFolder'],
|
operation: ['protectWithHotFolder'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
const returnData: INodeExecutionData[] = [];
|
const returnData: INodeExecutionData[] = [];
|
||||||
|
|
||||||
// Get credentials
|
// Get credentials
|
||||||
const credentials = await this.getCredentials('secloreProtectApi');
|
const credentials = await this.getCredentials('secloreProtectApi');
|
||||||
const baseUrl = credentials.baseUrl as string;
|
const baseUrl = credentials.baseUrl as string;
|
||||||
const tenantId = credentials.tenantId as string;
|
const tenantId = credentials.tenantId as string;
|
||||||
const tenantSecret = credentials.tenantSecret as string;
|
const tenantSecret = credentials.tenantSecret as string;
|
||||||
|
|
||||||
// Initialize the file service
|
// Initialize the file service
|
||||||
const fileService = new SecloreDRMFileService(
|
const fileService = new SecloreDRMFileService(this, baseUrl, tenantId, tenantSecret);
|
||||||
this,
|
|
||||||
baseUrl,
|
|
||||||
tenantId,
|
|
||||||
tenantSecret
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get node parameters
|
// Get node parameters
|
||||||
const operation = this.getNodeParameter('operation', 0) as string;
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
try {
|
try {
|
||||||
if (operation === 'protectWithHotFolder') {
|
if (operation === 'protectWithHotFolder') {
|
||||||
// Get parameters for this item
|
// Get parameters for this item
|
||||||
const hotfolderId = this.getNodeParameter('hotfolderId', i) as string;
|
const hotfolderId = this.getNodeParameter('hotfolderId', i) as string;
|
||||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
|
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||||
const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', i) as string;
|
const outputBinaryPropertyName = this.getNodeParameter(
|
||||||
const correlationId = this.getNodeParameter('correlationId', i) as string;
|
'outputBinaryPropertyName',
|
||||||
const retryCount = this.getNodeParameter('retryCount', i) as number;
|
i,
|
||||||
|
) as string;
|
||||||
|
const correlationId = this.getNodeParameter('correlationId', i) as string;
|
||||||
|
const retryCount = this.getNodeParameter('retryCount', i) as number;
|
||||||
|
|
||||||
// Validate required parameters
|
// Validate required parameters
|
||||||
if (!hotfolderId) {
|
if (!hotfolderId) {
|
||||||
throw new NodeOperationError(this.getNode(), 'HotFolder ID is required', {
|
throw new NodeOperationError(this.getNode(), 'HotFolder ID is required', {
|
||||||
itemIndex: i,
|
itemIndex: i,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get input binary data
|
// Get input binary data
|
||||||
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
||||||
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||||
|
|
||||||
// Upload the file first
|
// Upload the file first
|
||||||
const uploadResult = await fileService.uploadFile(
|
const uploadResult = await fileService.uploadFile(
|
||||||
new Uint8Array(fileBuffer),
|
new Uint8Array(fileBuffer),
|
||||||
binaryData.fileName || 'file',
|
binaryData.fileName || 'file',
|
||||||
correlationId || undefined,
|
correlationId || undefined,
|
||||||
retryCount
|
retryCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Protect the uploaded file with HotFolder
|
// Protect the uploaded file with HotFolder
|
||||||
const protectResult = await fileService.protectWithHotFolder(
|
const protectResult = await fileService.protectWithHotFolder(
|
||||||
{
|
{
|
||||||
hotfolderId,
|
hotfolderId,
|
||||||
fileStorageId: uploadResult.fileStorageId,
|
fileStorageId: uploadResult.fileStorageId,
|
||||||
},
|
},
|
||||||
correlationId || undefined,
|
correlationId || undefined,
|
||||||
retryCount
|
retryCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Download the protected file
|
// Download the protected file
|
||||||
const protectedFileData = await fileService.downloadFile(
|
const protectedFileData = await fileService.downloadFile(
|
||||||
protectResult.fileStorageId,
|
protectResult.fileStorageId,
|
||||||
correlationId || undefined,
|
correlationId || undefined,
|
||||||
retryCount
|
retryCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create output binary data
|
// Create output binary data
|
||||||
const outputBinaryData = await this.helpers.prepareBinaryData(
|
const outputBinaryData = await this.helpers.prepareBinaryData(
|
||||||
protectedFileData.buffer,
|
Buffer.from(protectedFileData),
|
||||||
binaryData.fileName || 'protected_file',
|
binaryData.fileName || 'protected_file',
|
||||||
binaryData.mimeType
|
binaryData.mimeType,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create return item with binary data and metadata
|
// Create return item with binary data and metadata
|
||||||
const returnItem: INodeExecutionData = {
|
const returnItem: INodeExecutionData = {
|
||||||
json: {
|
json: {
|
||||||
success: true,
|
success: true,
|
||||||
originalFileStorageId: uploadResult.fileStorageId,
|
originalFileStorageId: uploadResult.fileStorageId,
|
||||||
protectedFileStorageId: protectResult.fileStorageId,
|
protectedFileStorageId: protectResult.fileStorageId,
|
||||||
secloreFileId: protectResult.secloreFileId,
|
secloreFileId: protectResult.secloreFileId,
|
||||||
hotfolderId,
|
hotfolderId,
|
||||||
fileName: binaryData.fileName,
|
fileName: binaryData.fileName,
|
||||||
fileSize: protectedFileData.length,
|
fileSize: protectedFileData.length,
|
||||||
correlationId: correlationId || null,
|
correlationId: correlationId || null,
|
||||||
},
|
},
|
||||||
binary: {
|
binary: {
|
||||||
[outputBinaryPropertyName]: outputBinaryData,
|
[outputBinaryPropertyName]: outputBinaryData,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
returnData.push(returnItem);
|
returnData.push(returnItem);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle errors gracefully
|
// Handle errors gracefully
|
||||||
if (this.continueOnFail()) {
|
if (this.continueOnFail()) {
|
||||||
const returnItem: INodeExecutionData = {
|
const returnItem: INodeExecutionData = {
|
||||||
json: {
|
json: {
|
||||||
success: false,
|
success: false,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
itemIndex: i,
|
itemIndex: i,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
returnData.push(returnItem);
|
returnData.push(returnItem);
|
||||||
} else {
|
} else {
|
||||||
throw new NodeOperationError(this.getNode(), error.message, {
|
throw new NodeOperationError(this.getNode(), error.message, {
|
||||||
itemIndex: i,
|
itemIndex: i,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [returnData];
|
return [returnData];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "n8n-nodes-secloreprotect",
|
"name": "n8n-nodes-secloreprotect",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "",
|
"description": "n8n community node for Seclore Protect - secure file protection using DRM technology",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"n8n-community-node-package"
|
"n8n-community-node-package"
|
||||||
],
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "",
|
"name": "Seclore Technology",
|
||||||
"email": ""
|
"email": "support@seclore.com"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@n8n/node-cli": "*",
|
"@n8n/node-cli": "*",
|
||||||
|
"@types/node": "^24.9.1",
|
||||||
"eslint": "9.32.0",
|
"eslint": "9.32.0",
|
||||||
"prettier": "3.6.2",
|
"prettier": "3.6.2",
|
||||||
"release-it": "^19.0.4",
|
"release-it": "^19.0.4",
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"outDir": "./dist/"
|
"outDir": "./dist/",
|
||||||
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"include": ["credentials/**/*", "nodes/**/*", "nodes/**/*.json", "package.json"]
|
"include": ["credentials/**/*", "nodes/**/*", "nodes/**/*.json", "package.json"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue