n8n-nodes-seclore/nodes/SecloreProtect/SecloreProtect.node.ts

173 lines
3.8 KiB
TypeScript
Raw Normal View History

2025-10-22 09:19:18 +00:00
import {
2025-10-22 10:14:14 +00:00
INodeType,
INodeTypeDescription,
2025-10-22 09:19:18 +00:00
} from 'n8n-workflow';
2025-10-27 12:17:21 +00:00
import { protectWithHotFolder } from './operations/protectWithHotFolder';
import { unprotect } from './operations/unprotect';
2025-10-22 09:19:18 +00:00
export class SecloreProtect implements INodeType {
2025-10-22 10:14:14 +00:00
description: INodeTypeDescription = {
2025-10-28 07:10:08 +00:00
displayName: 'Seclore',
2025-10-22 10:14:14 +00:00
name: 'secloreProtect',
2025-10-27 12:17:21 +00:00
icon: 'file:../../icons/seclore.svg',
2025-10-24 06:10:55 +00:00
usableAsTool: true, // TODO: make it false/ don't allow it to be used as a tool
2025-10-22 10:14:14 +00:00
group: ['transform'],
version: 1,
2025-10-27 12:06:40 +00:00
subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
description: 'Protect files using Seclore DRM',
2025-10-22 10:14:14 +00:00
defaults: {
2025-10-28 07:10:08 +00:00
name: 'Seclore',
2025-10-22 10:14:14 +00:00
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'secloreProtectApi',
required: true,
},
],
properties: [
2025-10-27 12:06:40 +00:00
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'DRM Protection',
value: 'drmProtection',
description: 'DRM file protection operations',
},
{
name: 'DRM Unprotection',
value: 'drmUnprotection',
description: 'DRM file unprotection operations',
2025-10-27 12:06:40 +00:00
},
],
default: 'drmProtection',
2025-10-27 12:06:40 +00:00
},
2025-10-22 10:14:14 +00:00
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
2025-10-27 12:06:40 +00:00
displayOptions: {
show: {
resource: ['drmProtection'],
2025-10-27 12:06:40 +00:00
},
},
2025-10-22 10:14:14 +00:00
options: [
{
name: 'Protect using Policy',
2025-10-22 10:14:14 +00:00
value: 'protectWithHotFolder',
description: 'Protect a file using HotFolder ID configuration',
action: 'Protect file using policy',
2025-10-22 10:14:14 +00:00
},
],
default: 'protectWithHotFolder',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['drmUnprotection'],
},
},
options: [
2025-10-27 12:06:40 +00:00
{
name: 'Unprotect',
value: 'unprotect',
description: 'Unprotect a protected file',
action: 'Unprotect file',
2025-10-27 12:06:40 +00:00
},
2025-10-22 10:14:14 +00:00
],
default: 'unprotect',
2025-10-22 10:14:14 +00:00
},
{
displayName: 'HotFolder ID',
name: 'hotfolderId',
type: 'string',
required: true,
default: '',
placeholder: '',
2025-10-22 10:14:14 +00:00
description: 'The ID of the HotFolder configuration to use for protection',
displayOptions: {
show: {
resource: ['drmProtection'],
2025-10-22 10:14:14 +00:00
operation: ['protectWithHotFolder'],
},
},
},
{
displayName: 'Input Binary Property',
name: 'binaryPropertyName',
type: 'string',
default: 'data',
required: true,
description: 'Name of the binary property that contains the file to protect',
displayOptions: {
show: {
resource: ['drmProtection'],
2025-10-22 10:14:14 +00:00
operation: ['protectWithHotFolder'],
},
},
},
{
displayName: 'Retry Count',
name: 'retryCount',
type: 'number',
default: 3,
description: 'Number of retry attempts for failed requests',
displayOptions: {
show: {
resource: ['drmProtection'],
2025-10-22 10:14:14 +00:00
operation: ['protectWithHotFolder'],
},
},
},
2025-10-27 12:06:40 +00:00
// Unprotect operation parameters
{
2025-10-27 12:17:21 +00:00
displayName: 'Input Binary Property',
name: 'binaryPropertyName',
2025-10-27 12:06:40 +00:00
type: 'string',
default: 'data',
required: true,
2025-10-27 12:17:21 +00:00
description: 'Name of the binary property that contains the protected file to unprotect',
2025-10-27 12:06:40 +00:00
displayOptions: {
show: {
resource: ['drmUnprotection'],
2025-10-27 12:06:40 +00:00
operation: ['unprotect'],
},
},
},
{
displayName: 'Retry Count',
name: 'retryCount',
type: 'number',
default: 3,
description: 'Number of retry attempts for failed requests',
displayOptions: {
show: {
resource: ['drmUnprotection'],
2025-10-27 12:06:40 +00:00
operation: ['unprotect'],
},
},
},
2025-10-22 10:14:14 +00:00
],
};
2025-10-27 12:06:40 +00:00
customOperations = {
drmProtection: {
2025-10-27 12:17:21 +00:00
protectWithHotFolder,
},
drmUnprotection: {
2025-10-27 12:17:21 +00:00
unprotect,
2025-10-27 12:06:40 +00:00
},
};
2025-10-22 09:19:18 +00:00
}