(PS-383) Dist folder removed from git #3
|
|
@ -1,4 +1,5 @@
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
.n8n
|
.n8n
|
||||||
.devcontainer
|
.devcontainer
|
||||||
|
dist
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import { ICredentialTestRequest, ICredentialType, INodeProperties, Icon } from 'n8n-workflow';
|
|
||||||
export declare class SecloreProtectApi implements ICredentialType {
|
|
||||||
name: string;
|
|
||||||
displayName: string;
|
|
||||||
documentationUrl: string;
|
|
||||||
icon: Icon;
|
|
||||||
properties: INodeProperties[];
|
|
||||||
test: ICredentialTestRequest;
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.SecloreProtectApi = void 0;
|
|
||||||
class SecloreProtectApi {
|
|
||||||
constructor() {
|
|
||||||
this.name = 'secloreProtectApi';
|
|
||||||
this.displayName = 'Seclore API';
|
|
||||||
this.documentationUrl = 'https://docs.seclore.com/';
|
|
||||||
this.icon = 'file:../icons/seclore.svg';
|
|
||||||
this.properties = [
|
|
||||||
{
|
|
||||||
displayName: 'Base URL',
|
|
||||||
name: 'baseUrl',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
placeholder: 'https://api.seclore.com',
|
|
||||||
description: 'The base URL of your Seclore DRM Server',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Tenant ID',
|
|
||||||
name: 'tenantId',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
placeholder: 'your-tenant-id',
|
|
||||||
description: 'Your Seclore tenant ID',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Tenant Secret',
|
|
||||||
name: 'tenantSecret',
|
|
||||||
type: 'string',
|
|
||||||
typeOptions: {
|
|
||||||
password: true,
|
|
||||||
},
|
|
||||||
default: '',
|
|
||||||
description: 'Your Seclore tenant secret',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
this.test = {
|
|
||||||
request: {
|
|
||||||
baseURL: '={{$credentials.baseUrl}}',
|
|
||||||
url: '/seclore/drm/1.0/auth/login',
|
|
||||||
method: 'POST',
|
|
||||||
body: {
|
|
||||||
tenantId: '={{$credentials.tenantId}}',
|
|
||||||
tenantSecret: '={{$credentials.tenantSecret}}',
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SecloreProtectApi = SecloreProtectApi;
|
|
||||||
//# sourceMappingURL=SecloreProtectApi.credentials.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"SecloreProtectApi.credentials.js","sourceRoot":"","sources":["../../credentials/SecloreProtectApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAA9B;QACC,SAAI,GAAG,mBAAmB,CAAC;QAC3B,gBAAW,GAAG,aAAa,CAAC;QAC5B,qBAAgB,GAAG,2BAA2B,CAAC;QAC/C,SAAI,GAAS,2BAA2B,CAAC;QACzC,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,yBAAyB;gBACtC,WAAW,EAAE,yCAAyC;gBACtD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,gBAAgB;gBAC7B,WAAW,EAAE,wBAAwB;gBACrC,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,4BAA4B;gBACzC,QAAQ,EAAE,IAAI;aACd;SACD,CAAC;QAGF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,6BAA6B;gBAClC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACL,QAAQ,EAAE,4BAA4B;oBACtC,YAAY,EAAE,gCAAgC;iBAC9C;gBACD,OAAO,EAAE;oBACR,cAAc,EAAE,kBAAkB;iBAClC;aACD;SACD,CAAC;IACH,CAAC;CAAA;AApDD,8CAoDC"}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080">
|
|
||||||
<defs>
|
|
||||||
<style>
|
|
||||||
.cls-1 {
|
|
||||||
fill: #e6244e;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</defs>
|
|
||||||
<path class="cls-1" d="M1410.69,1080H336.23v-225.18h983.63v-196.85H538.82c-135.08-7.21-202.59-53.13-202.59-137.81V128.33C336.23,49.07,403.68,6.3,538.62,0H1583.77V230.56H596.13v199.54h813.03c108.4,0,166.61,37.75,174.6,113.27v404.49c-8,88.11-65.68,132.14-173.08,132.14Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 506 B |
|
|
@ -1,14 +0,0 @@
|
||||||
import { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
||||||
import { protectWithHotFolder } from './operations/protectWithHotFolder';
|
|
||||||
import { unprotect } from './operations/unprotect';
|
|
||||||
export declare class SecloreProtect implements INodeType {
|
|
||||||
description: INodeTypeDescription;
|
|
||||||
customOperations: {
|
|
||||||
drmProtection: {
|
|
||||||
protectWithHotFolder: typeof protectWithHotFolder;
|
|
||||||
};
|
|
||||||
drmUnprotection: {
|
|
||||||
unprotect: typeof unprotect;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,170 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.SecloreProtect = void 0;
|
|
||||||
const protectWithHotFolder_1 = require("./operations/protectWithHotFolder");
|
|
||||||
const unprotect_1 = require("./operations/unprotect");
|
|
||||||
class SecloreProtect {
|
|
||||||
constructor() {
|
|
||||||
this.description = {
|
|
||||||
displayName: 'Seclore',
|
|
||||||
name: 'secloreProtect',
|
|
||||||
icon: 'file:../../icons/seclore.svg',
|
|
||||||
usableAsTool: true,
|
|
||||||
group: ['transform'],
|
|
||||||
version: 1,
|
|
||||||
subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
|
|
||||||
description: 'Protect files using Seclore DRM',
|
|
||||||
defaults: {
|
|
||||||
name: 'Seclore',
|
|
||||||
},
|
|
||||||
inputs: ['main'],
|
|
||||||
outputs: ['main'],
|
|
||||||
credentials: [
|
|
||||||
{
|
|
||||||
name: 'secloreProtectApi',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
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',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: 'drmProtection',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Operation',
|
|
||||||
name: 'operation',
|
|
||||||
type: 'options',
|
|
||||||
noDataExpression: true,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: ['drmProtection'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'Protect Using Policy',
|
|
||||||
value: 'protectWithHotFolder',
|
|
||||||
description: 'Protect a file using HotFolder ID configuration',
|
|
||||||
action: 'Protect file using policy',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: 'protectWithHotFolder',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Operation',
|
|
||||||
name: 'operation',
|
|
||||||
type: 'options',
|
|
||||||
noDataExpression: true,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: ['drmUnprotection'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'Unprotect',
|
|
||||||
value: 'unprotect',
|
|
||||||
description: 'Unprotect a protected file',
|
|
||||||
action: 'Unprotect file',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: 'unprotect',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'HotFolder ID',
|
|
||||||
name: 'hotfolderId',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
default: '',
|
|
||||||
placeholder: '',
|
|
||||||
description: 'The ID of the HotFolder configuration to use for protection',
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: ['drmProtection'],
|
|
||||||
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'],
|
|
||||||
operation: ['protectWithHotFolder'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Retry Count',
|
|
||||||
name: 'retryCount',
|
|
||||||
type: 'number',
|
|
||||||
default: 3,
|
|
||||||
description: 'Number of retry attempts for failed requests',
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: ['drmProtection'],
|
|
||||||
operation: ['protectWithHotFolder'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Input Binary Property',
|
|
||||||
name: 'binaryPropertyName',
|
|
||||||
type: 'string',
|
|
||||||
default: 'data',
|
|
||||||
required: true,
|
|
||||||
description: 'Name of the binary property that contains the protected file to unprotect',
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: ['drmUnprotection'],
|
|
||||||
operation: ['unprotect'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Retry Count',
|
|
||||||
name: 'retryCount',
|
|
||||||
type: 'number',
|
|
||||||
default: 3,
|
|
||||||
description: 'Number of retry attempts for failed requests',
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: ['drmUnprotection'],
|
|
||||||
operation: ['unprotect'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
this.customOperations = {
|
|
||||||
drmProtection: {
|
|
||||||
protectWithHotFolder: protectWithHotFolder_1.protectWithHotFolder,
|
|
||||||
},
|
|
||||||
drmUnprotection: {
|
|
||||||
unprotect: unprotect_1.unprotect,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SecloreProtect = SecloreProtect;
|
|
||||||
//# sourceMappingURL=SecloreProtect.node.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"SecloreProtect.node.js","sourceRoot":"","sources":["../../../nodes/SecloreProtect/SecloreProtect.node.ts"],"names":[],"mappings":";;;AAKA,4EAAyE;AACzE,sDAAmD;AAEnD,MAAa,cAAc;IAA3B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,8BAA8B;YACpC,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE;gBACT,IAAI,EAAE,SAAS;aACf;YACD,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,mBAAmB;oBACzB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,UAAU,EAAE;gBACX;oBACC,WAAW,EAAE,UAAU;oBACvB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,gBAAgB;4BACtB,KAAK,EAAE,eAAe;4BACtB,WAAW,EAAE,gCAAgC;yBAC7C;wBACD;4BACC,IAAI,EAAE,kBAAkB;4BACxB,KAAK,EAAE,iBAAiB;4BACxB,WAAW,EAAE,kCAAkC;yBAC/C;qBACD;oBACD,OAAO,EAAE,eAAe;iBACxB;gBACD;oBACC,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,eAAe,CAAC;yBAC3B;qBACD;oBACD,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,sBAAsB;4BAC5B,KAAK,EAAE,sBAAsB;4BAC7B,WAAW,EAAE,iDAAiD;4BAC9D,MAAM,EAAE,2BAA2B;yBACnC;qBACD;oBACD,OAAO,EAAE,sBAAsB;iBAC/B;gBACD;oBACC,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;oBACf,gBAAgB,EAAE,IAAI;oBACtB,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,iBAAiB,CAAC;yBAC7B;qBACD;oBACD,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,WAAW;4BACjB,KAAK,EAAE,WAAW;4BAClB,WAAW,EAAE,4BAA4B;4BACzC,MAAM,EAAE,gBAAgB;yBACxB;qBACD;oBACD,OAAO,EAAE,WAAW;iBACpB;gBACD;oBACC,WAAW,EAAE,cAAc;oBAC3B,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,EAAE;oBACf,WAAW,EAAE,6DAA6D;oBAC1E,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,eAAe,CAAC;4BAC3B,SAAS,EAAE,CAAC,sBAAsB,CAAC;yBACnC;qBACD;iBACD;gBACD;oBACC,WAAW,EAAE,uBAAuB;oBACpC,IAAI,EAAE,oBAAoB;oBAC1B,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,MAAM;oBACf,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,+DAA+D;oBAC5E,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,eAAe,CAAC;4BAC3B,SAAS,EAAE,CAAC,sBAAsB,CAAC;yBACnC;qBACD;iBACD;gBACD;oBACC,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,CAAC;oBACV,WAAW,EAAE,8CAA8C;oBAC3D,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,eAAe,CAAC;4BAC3B,SAAS,EAAE,CAAC,sBAAsB,CAAC;yBACnC;qBACD;iBACD;gBAED;oBACC,WAAW,EAAE,uBAAuB;oBACpC,IAAI,EAAE,oBAAoB;oBAC1B,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,MAAM;oBACf,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,2EAA2E;oBACxF,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,iBAAiB,CAAC;4BAC7B,SAAS,EAAE,CAAC,WAAW,CAAC;yBACxB;qBACD;iBACD;gBACD;oBACC,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,CAAC;oBACV,WAAW,EAAE,8CAA8C;oBAC3D,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,QAAQ,EAAE,CAAC,iBAAiB,CAAC;4BAC7B,SAAS,EAAE,CAAC,WAAW,CAAC;yBACxB;qBACD;iBACD;aACD;SACD,CAAC;QAEF,qBAAgB,GAAG;YAClB,aAAa,EAAE;gBACd,oBAAoB,EAApB,2CAAoB;aACpB;YACD,eAAe,EAAE;gBAChB,SAAS,EAAT,qBAAS;aACT;SACD,CAAC;IAEH,CAAC;CAAA;AAnKD,wCAmKC"}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"node": "dist/nodes/SecloreProtect/SecloreProtect.node.js",
|
|
||||||
"credentials": "dist/credentials/SecloreProtectApi.credentials.js"
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
export interface IErrorResponse {
|
|
||||||
errorCode: string;
|
|
||||||
errorMessage: string;
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=ErrorInterfaces.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"ErrorInterfaces.js","sourceRoot":"","sources":["../../../../../nodes/SecloreProtect/Services/Interfaces/ErrorInterfaces.ts"],"names":[],"mappings":""}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
export interface IFileUploadResponse {
|
|
||||||
fileStorageId: string;
|
|
||||||
fileName: string;
|
|
||||||
downloadUrl: string;
|
|
||||||
fileType: string;
|
|
||||||
fileSize: number;
|
|
||||||
secloreFileId: string;
|
|
||||||
protected: boolean;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface IFileDownloadResponse {
|
|
||||||
data: Uint8Array;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface IFileDeleteResponse {
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=FileStorageInterfaces.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"FileStorageInterfaces.js","sourceRoot":"","sources":["../../../../../nodes/SecloreProtect/Services/Interfaces/FileStorageInterfaces.ts"],"names":[],"mappings":""}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
export interface ILoginRequest {
|
|
||||||
tenantId: string;
|
|
||||||
tenantSecret: string;
|
|
||||||
}
|
|
||||||
export interface ILoginResponse {
|
|
||||||
accessToken: string;
|
|
||||||
refreshToken: string;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface IRefreshTokenRequest {
|
|
||||||
refreshToken: string;
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=LoginInterfaces.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"LoginInterfaces.js","sourceRoot":"","sources":["../../../../../nodes/SecloreProtect/Services/Interfaces/LoginInterfaces.ts"],"names":[],"mappings":""}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
export interface IExtRefProtectionDetail {
|
|
||||||
externalReferenceId: string;
|
|
||||||
externalReferenceName?: string;
|
|
||||||
externalReferenceData?: string;
|
|
||||||
externalAppId?: string;
|
|
||||||
}
|
|
||||||
export interface IProtectWithExternalRefIdRequest {
|
|
||||||
hotfolderExternalReference: IExtRefProtectionDetail;
|
|
||||||
fileExternalReference?: IExtRefProtectionDetail;
|
|
||||||
fileStorageId: string;
|
|
||||||
}
|
|
||||||
export interface IProtectWithExternalRefIdResponse {
|
|
||||||
fileStorageId: string;
|
|
||||||
secloreFileId: string;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface IProtectWithFileIdRequest {
|
|
||||||
existingProtectedFileId: string;
|
|
||||||
fileStorageId: string;
|
|
||||||
}
|
|
||||||
export interface IProtectWithFileIdResponse {
|
|
||||||
fileStorageId: string;
|
|
||||||
secloreFileId: string;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface IProtectWithHotFolderRequest {
|
|
||||||
hotfolderId: string;
|
|
||||||
fileStorageId: string;
|
|
||||||
}
|
|
||||||
export interface IProtectWithHotFolderResponse {
|
|
||||||
fileStorageId: string;
|
|
||||||
secloreFileId: string;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=ProtectInterfaces.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"ProtectInterfaces.js","sourceRoot":"","sources":["../../../../../nodes/SecloreProtect/Services/Interfaces/ProtectInterfaces.ts"],"names":[],"mappings":""}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
export interface IUnprotectRequest {
|
|
||||||
fileStorageId: string;
|
|
||||||
}
|
|
||||||
export interface IUnprotectResponse {
|
|
||||||
fileStorageId: string;
|
|
||||||
headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=UnprotectInterfaces.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"UnprotectInterfaces.js","sourceRoot":"","sources":["../../../../../nodes/SecloreProtect/Services/Interfaces/UnprotectInterfaces.ts"],"names":[],"mappings":""}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import { IExecuteFunctions } from 'n8n-workflow';
|
|
||||||
import { IFileUploadResponse, IFileDownloadResponse, IFileDeleteResponse } from './Interfaces/FileStorageInterfaces';
|
|
||||||
import { ILoginResponse } from './Interfaces/LoginInterfaces';
|
|
||||||
import { IProtectWithExternalRefIdRequest, IProtectWithExternalRefIdResponse, IProtectWithFileIdRequest, IProtectWithFileIdResponse, IProtectWithHotFolderRequest, IProtectWithHotFolderResponse } from './Interfaces/ProtectInterfaces';
|
|
||||||
import { IUnprotectRequest, IUnprotectResponse } from './Interfaces/UnprotectInterfaces';
|
|
||||||
export declare class SecloreDRMApiService {
|
|
||||||
private context;
|
|
||||||
private baseUrl;
|
|
||||||
constructor(context: IExecuteFunctions, baseUrl: string);
|
|
||||||
private handleHttpError;
|
|
||||||
login(tenantId: string, tenantSecret: string, correlationId?: string): Promise<ILoginResponse>;
|
|
||||||
refreshToken(refreshToken: string, correlationId?: string): Promise<ILoginResponse>;
|
|
||||||
protectWithExternalRefId(protectRequest: IProtectWithExternalRefIdRequest, accessToken: string, correlationId?: string): Promise<IProtectWithExternalRefIdResponse>;
|
|
||||||
protectWithFileId(protectRequest: IProtectWithFileIdRequest, accessToken: string, correlationId?: string): Promise<IProtectWithFileIdResponse>;
|
|
||||||
protectWithHotFolder(protectRequest: IProtectWithHotFolderRequest, accessToken: string, correlationId?: string): Promise<IProtectWithHotFolderResponse>;
|
|
||||||
unprotect(unprotectRequest: IUnprotectRequest, accessToken: string, correlationId?: string): Promise<IUnprotectResponse>;
|
|
||||||
uploadFile(fileBuffer: Uint8Array, fileName: string, accessToken: string, correlationId?: string): Promise<IFileUploadResponse>;
|
|
||||||
downloadFile(fileStorageId: string, accessToken: string, correlationId?: string): Promise<IFileDownloadResponse>;
|
|
||||||
deleteFile(fileStorageId: string, accessToken: string, correlationId?: string): Promise<IFileDeleteResponse>;
|
|
||||||
}
|
|
||||||
|
|
@ -1,403 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.SecloreDRMApiService = void 0;
|
|
||||||
const n8n_workflow_1 = require("n8n-workflow");
|
|
||||||
class SecloreDRMApiService {
|
|
||||||
constructor(context, baseUrl) {
|
|
||||||
this.context = context;
|
|
||||||
this.baseUrl = baseUrl;
|
|
||||||
}
|
|
||||||
handleHttpError(error, customMessages) {
|
|
||||||
var _a;
|
|
||||||
const statusCode = parseInt((_a = error.httpCode) !== null && _a !== void 0 ? _a : '0');
|
|
||||||
const errorResponse = error.errorResponse;
|
|
||||||
if (customMessages && customMessages[statusCode]) {
|
|
||||||
throw new Error(`${customMessages[statusCode]}: ${(errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.errorMessage) || 'Unknown error'}`);
|
|
||||||
}
|
|
||||||
switch (statusCode) {
|
|
||||||
case 400:
|
|
||||||
throw new Error(`Bad Request: ${(errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.errorMessage) || 'Invalid request data'}`);
|
|
||||||
case 401:
|
|
||||||
throw new Error(`Unauthorized: ${(errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.errorMessage) || 'Invalid credentials'}`);
|
|
||||||
case 413:
|
|
||||||
throw new Error(`Payload Too Large: ${(errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.errorMessage) || 'File size exceeds limit'}`);
|
|
||||||
case 500:
|
|
||||||
throw new Error(`Server Error: ${(errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.errorMessage) || 'Internal server error'}`);
|
|
||||||
default:
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async login(tenantId, tenantSecret, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::login:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Attempting login', { tenantId, correlationId });
|
|
||||||
const requestBody = {
|
|
||||||
tenantId,
|
|
||||||
tenantSecret,
|
|
||||||
};
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/1.0/auth/login`,
|
|
||||||
headers,
|
|
||||||
body: requestBody,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Login successful', { tenantId, correlationId });
|
|
||||||
const loginResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return loginResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Login failed', { error, tenantId, correlationId });
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async refreshToken(refreshToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::refreshToken:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Attempting token refresh', { correlationId });
|
|
||||||
const requestBody = {
|
|
||||||
refreshToken,
|
|
||||||
};
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/1.0/auth/refresh`,
|
|
||||||
headers,
|
|
||||||
body: requestBody,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Token refresh successful', { correlationId });
|
|
||||||
const refreshResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return refreshResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Token refresh failed', { error, correlationId });
|
|
||||||
this.handleHttpError(error, { 401: 'Unauthorized' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async protectWithExternalRefId(protectRequest, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::protectWithExternalRefId:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with external ref ID', {
|
|
||||||
fileStorageId: protectRequest.fileStorageId,
|
|
||||||
hotfolderExternalReferenceId: protectRequest.hotfolderExternalReference.externalReferenceId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/1.0/protect/externalref`,
|
|
||||||
headers,
|
|
||||||
body: protectRequest,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protection with external ref ID successful', {
|
|
||||||
fileStorageId: protectRequest.fileStorageId,
|
|
||||||
secloreFileId: response.body.secloreFileId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const protectResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return protectResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protection with external ref ID failed', {
|
|
||||||
error,
|
|
||||||
fileStorageId: protectRequest.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async protectWithFileId(protectRequest, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::protectWithFileId:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with file ID', {
|
|
||||||
existingProtectedFileId: protectRequest.existingProtectedFileId,
|
|
||||||
fileStorageId: protectRequest.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/1.0/protect/fileid`,
|
|
||||||
headers,
|
|
||||||
body: protectRequest,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protection with file ID successful', {
|
|
||||||
existingProtectedFileId: protectRequest.existingProtectedFileId,
|
|
||||||
secloreFileId: response.body.secloreFileId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const protectResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return protectResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protection with file ID failed', {
|
|
||||||
error,
|
|
||||||
existingProtectedFileId: protectRequest.existingProtectedFileId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async protectWithHotFolder(protectRequest, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::protectWithHotFolder:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with hot folder', {
|
|
||||||
hotfolderId: protectRequest.hotfolderId,
|
|
||||||
fileStorageId: protectRequest.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/1.0/protect/hf`,
|
|
||||||
headers,
|
|
||||||
body: protectRequest,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protection with hot folder successful', {
|
|
||||||
hotfolderId: protectRequest.hotfolderId,
|
|
||||||
secloreFileId: response.body.secloreFileId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const protectResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return protectResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protection with hot folder failed', {
|
|
||||||
error,
|
|
||||||
hotfolderId: protectRequest.hotfolderId,
|
|
||||||
fileStorageId: protectRequest.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async unprotect(unprotectRequest, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::unprotect:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotecting file', {
|
|
||||||
fileStorageId: unprotectRequest.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/1.0/unprotect`,
|
|
||||||
headers,
|
|
||||||
body: unprotectRequest,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotection successful', {
|
|
||||||
originalFileStorageId: unprotectRequest.fileStorageId,
|
|
||||||
unprotectedFileStorageId: response.body.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const unprotectResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return unprotectResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Unprotection failed', {
|
|
||||||
error,
|
|
||||||
fileStorageId: unprotectRequest.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async uploadFile(fileBuffer, fileName, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::uploadFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Uploading file', {
|
|
||||||
fileName,
|
|
||||||
fileSize: fileBuffer.length,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const formData = new FormData();
|
|
||||||
const file = new Blob([fileBuffer], { type: 'application/octet-stream' });
|
|
||||||
formData.append('file', file, fileName);
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/filestorage/1.0/upload`,
|
|
||||||
headers,
|
|
||||||
body: formData,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, fileName, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File upload successful', {
|
|
||||||
fileName,
|
|
||||||
fileStorageId: response.body.fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const uploadResponse = {
|
|
||||||
...response.body,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return uploadResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'File upload failed', {
|
|
||||||
error,
|
|
||||||
fileName,
|
|
||||||
fileSize: fileBuffer.length,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async downloadFile(fileStorageId, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::downloadFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Downloading file', {
|
|
||||||
fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'GET',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/filestorage/1.0/download/${fileStorageId}`,
|
|
||||||
headers,
|
|
||||||
encoding: 'arraybuffer',
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, fileStorageId, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
const fileData = new Uint8Array(response.body);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File download successful', {
|
|
||||||
fileStorageId,
|
|
||||||
fileSize: fileData.length,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const downloadResponse = {
|
|
||||||
data: fileData,
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return downloadResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'File download failed', {
|
|
||||||
error,
|
|
||||||
fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async deleteFile(fileStorageId, accessToken, correlationId) {
|
|
||||||
const who = "SecloreDRMApiService::deleteFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Deleting file', {
|
|
||||||
fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const headers = {
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
};
|
|
||||||
if (correlationId) {
|
|
||||||
headers['X-SECLORE-CORRELATION-ID'] = correlationId;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
method: 'DELETE',
|
|
||||||
url: `${this.baseUrl}/seclore/drm/filestorage/1.0/${fileStorageId}`,
|
|
||||||
headers,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Making HTTP request', { url: options.url, method: options.method, fileStorageId, correlationId });
|
|
||||||
const response = await this.context.helpers.httpRequest({ ...options, returnFullResponse: true });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File deletion successful', {
|
|
||||||
fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const deleteResponse = {
|
|
||||||
headers: response.headers
|
|
||||||
};
|
|
||||||
return deleteResponse;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'File deletion failed', {
|
|
||||||
error,
|
|
||||||
fileStorageId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
this.handleHttpError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SecloreDRMApiService = SecloreDRMApiService;
|
|
||||||
//# sourceMappingURL=SecloreDRMApiService.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,31 +0,0 @@
|
||||||
import { IExecuteFunctions } from 'n8n-workflow';
|
|
||||||
import { IFileDownloadResponse, IFileUploadResponse } from './Interfaces/FileStorageInterfaces';
|
|
||||||
import { IProtectWithExternalRefIdRequest, IProtectWithExternalRefIdResponse, IProtectWithFileIdRequest, IProtectWithFileIdResponse, IProtectWithHotFolderRequest, IProtectWithHotFolderResponse } from './Interfaces/ProtectInterfaces';
|
|
||||||
import { IUnprotectRequest, IUnprotectResponse } from './Interfaces/UnprotectInterfaces';
|
|
||||||
export declare class SecloreDRMFileService {
|
|
||||||
private defaultRetryCount;
|
|
||||||
private apiService;
|
|
||||||
private tenantId;
|
|
||||||
private tenantSecret;
|
|
||||||
private accessToken?;
|
|
||||||
private refreshToken?;
|
|
||||||
private tokenExpiry?;
|
|
||||||
private refreshPromise?;
|
|
||||||
private loginPromise?;
|
|
||||||
constructor(context: IExecuteFunctions, baseUrl: string, tenantId: string, tenantSecret: string, defaultRetryCount?: number);
|
|
||||||
private ensureAuthenticated;
|
|
||||||
private login;
|
|
||||||
private refreshAccessToken;
|
|
||||||
private performTokenRefresh;
|
|
||||||
private clearTokens;
|
|
||||||
private executeWithRetry;
|
|
||||||
protectWithExternalRefId(protectRequest: IProtectWithExternalRefIdRequest, correlationId?: string, retryCount?: number): Promise<IProtectWithExternalRefIdResponse>;
|
|
||||||
protectWithFileId(protectRequest: IProtectWithFileIdRequest, correlationId?: string, retryCount?: number): Promise<IProtectWithFileIdResponse>;
|
|
||||||
protectWithHotFolder(protectRequest: IProtectWithHotFolderRequest, correlationId?: string, retryCount?: number): Promise<IProtectWithHotFolderResponse>;
|
|
||||||
unprotect(unprotectRequest: IUnprotectRequest, correlationId?: string, retryCount?: number): Promise<IUnprotectResponse>;
|
|
||||||
uploadFile(fileBuffer: Uint8Array, fileName: string, correlationId?: string, retryCount?: number): Promise<IFileUploadResponse>;
|
|
||||||
downloadFile(fileStorageId: string, correlationId?: string, retryCount?: number): Promise<IFileDownloadResponse>;
|
|
||||||
deleteFile(fileStorageId: string, correlationId?: string, retryCount?: number): Promise<void>;
|
|
||||||
getAccessToken(): string | undefined;
|
|
||||||
isAuthenticated(): boolean;
|
|
||||||
}
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.SecloreDRMFileService = void 0;
|
|
||||||
const n8n_workflow_1 = require("n8n-workflow");
|
|
||||||
const SecloreDRMApiService_1 = require("./SecloreDRMApiService");
|
|
||||||
class SecloreDRMFileService {
|
|
||||||
constructor(context, baseUrl, tenantId, tenantSecret, defaultRetryCount = 3) {
|
|
||||||
this.defaultRetryCount = defaultRetryCount;
|
|
||||||
this.apiService = new SecloreDRMApiService_1.SecloreDRMApiService(context, baseUrl);
|
|
||||||
this.tenantId = tenantId;
|
|
||||||
this.tenantSecret = tenantSecret;
|
|
||||||
}
|
|
||||||
async ensureAuthenticated(correlationId) {
|
|
||||||
if (!this.accessToken || (this.tokenExpiry && new Date() >= this.tokenExpiry)) {
|
|
||||||
if (this.loginPromise) {
|
|
||||||
await this.loginPromise;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.loginPromise = this.login(correlationId);
|
|
||||||
try {
|
|
||||||
await this.loginPromise;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
this.loginPromise = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async login(correlationId) {
|
|
||||||
const who = "SecloreDRMFileService::login:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Attempting login', { tenantId: this.tenantId, correlationId });
|
|
||||||
const loginResponse = await this.apiService.login(this.tenantId, this.tenantSecret, correlationId);
|
|
||||||
this.accessToken = loginResponse.accessToken;
|
|
||||||
this.refreshToken = loginResponse.refreshToken;
|
|
||||||
this.tokenExpiry = new Date(Date.now() + 50 * 60 * 1000);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'Login successful', { tenantId: this.tenantId, correlationId });
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Login failed', { error, tenantId: this.tenantId, correlationId });
|
|
||||||
this.clearTokens();
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async refreshAccessToken(correlationId) {
|
|
||||||
if (this.refreshPromise) {
|
|
||||||
await this.refreshPromise;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.refreshToken) {
|
|
||||||
throw new Error('No refresh token available');
|
|
||||||
}
|
|
||||||
this.refreshPromise = this.performTokenRefresh(correlationId);
|
|
||||||
try {
|
|
||||||
await this.refreshPromise;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
this.refreshPromise = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async performTokenRefresh(correlationId) {
|
|
||||||
const who = "SecloreDRMFileService::performTokenRefresh:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Attempting token refresh', { correlationId });
|
|
||||||
const refreshResponse = await this.apiService.refreshToken(this.refreshToken, correlationId);
|
|
||||||
this.accessToken = refreshResponse.accessToken;
|
|
||||||
this.refreshToken = refreshResponse.refreshToken;
|
|
||||||
this.tokenExpiry = new Date(Date.now() + 50 * 60 * 1000);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'Token refresh successful', { correlationId });
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Token refresh failed', { error, correlationId });
|
|
||||||
this.clearTokens();
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clearTokens() {
|
|
||||||
this.accessToken = undefined;
|
|
||||||
this.refreshToken = undefined;
|
|
||||||
this.tokenExpiry = undefined;
|
|
||||||
this.refreshPromise = undefined;
|
|
||||||
this.loginPromise = undefined;
|
|
||||||
}
|
|
||||||
async executeWithRetry(apiCall, retryCount = this.defaultRetryCount, correlationId) {
|
|
||||||
let lastError;
|
|
||||||
for (let attempt = 0; attempt <= retryCount; attempt++) {
|
|
||||||
try {
|
|
||||||
await this.ensureAuthenticated(correlationId);
|
|
||||||
if (!this.accessToken) {
|
|
||||||
throw new Error('Failed to obtain access token');
|
|
||||||
}
|
|
||||||
return await apiCall(this.accessToken);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
lastError = error;
|
|
||||||
if (error.message.includes('Unauthorized') && attempt < retryCount) {
|
|
||||||
try {
|
|
||||||
await this.refreshAccessToken(correlationId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
catch (refreshError) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error('SecloreDRMFileService::executeWithRetry:: Token refresh failed', { refreshError, correlationId });
|
|
||||||
this.clearTokens();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (attempt === retryCount) {
|
|
||||||
throw lastError;
|
|
||||||
}
|
|
||||||
await new Promise((resolve) => {
|
|
||||||
const delay = Math.pow(2, attempt) * 1000;
|
|
||||||
const start = Date.now();
|
|
||||||
while (Date.now() - start < delay) {
|
|
||||||
}
|
|
||||||
resolve(undefined);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw lastError;
|
|
||||||
}
|
|
||||||
async protectWithExternalRefId(protectRequest, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::protectWithExternalRefId:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with external ref ID', { fileStorageId: protectRequest.fileStorageId, hotfolderExternalReferenceId: protectRequest.hotfolderExternalReference.externalReferenceId, correlationId });
|
|
||||||
const result = await this.executeWithRetry((accessToken) => this.apiService.protectWithExternalRefId(protectRequest, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File protected with external ref ID successfully', { fileStorageId: protectRequest.fileStorageId, secloreFileId: result.secloreFileId, correlationId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protect with external ref ID failed', { error, fileStorageId: protectRequest.fileStorageId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async protectWithFileId(protectRequest, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::protectWithFileId:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with file ID', { existingProtectedFileId: protectRequest.existingProtectedFileId, fileStorageId: protectRequest.fileStorageId, correlationId });
|
|
||||||
const result = await this.executeWithRetry((accessToken) => this.apiService.protectWithFileId(protectRequest, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File protected with file ID successfully', { existingProtectedFileId: protectRequest.existingProtectedFileId, secloreFileId: result.secloreFileId, correlationId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protect with file ID failed', { error, existingProtectedFileId: protectRequest.existingProtectedFileId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async protectWithHotFolder(protectRequest, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::protectWithHotFolder:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with hot folder', { hotfolderId: protectRequest.hotfolderId, fileStorageId: protectRequest.fileStorageId, correlationId });
|
|
||||||
const result = await this.executeWithRetry((accessToken) => this.apiService.protectWithHotFolder(protectRequest, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File protected with hot folder successfully', { hotfolderId: protectRequest.hotfolderId, fileStorageId: protectRequest.fileStorageId, secloreFileId: result.secloreFileId, correlationId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protect with hot folder failed', { error, hotfolderId: protectRequest.hotfolderId, fileStorageId: protectRequest.fileStorageId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async unprotect(unprotectRequest, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::unprotect:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotecting file', { fileStorageId: unprotectRequest.fileStorageId, correlationId });
|
|
||||||
const result = await this.executeWithRetry((accessToken) => this.apiService.unprotect(unprotectRequest, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File unprotected successfully', { originalFileStorageId: unprotectRequest.fileStorageId, unprotectedFileStorageId: result.fileStorageId, correlationId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Unprotect file failed', { error, fileStorageId: unprotectRequest.fileStorageId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async uploadFile(fileBuffer, fileName, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::uploadFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Uploading file', { fileName, correlationId });
|
|
||||||
const result = await this.executeWithRetry((accessToken) => this.apiService.uploadFile(fileBuffer, fileName, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File uploaded successfully', { fileName, correlationId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Upload file failed', { error, fileName, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async downloadFile(fileStorageId, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::downloadFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Downloading file', { fileStorageId, correlationId });
|
|
||||||
const result = await this.executeWithRetry((accessToken) => this.apiService.downloadFile(fileStorageId, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File downloaded successfully', { fileStorageId, fileSize: result.data.length, correlationId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Download file failed', { error, fileStorageId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async deleteFile(fileStorageId, correlationId, retryCount) {
|
|
||||||
const who = "SecloreDRMFileService::deleteFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Deleting file', { fileStorageId, correlationId });
|
|
||||||
await this.executeWithRetry((accessToken) => this.apiService.deleteFile(fileStorageId, accessToken, correlationId), retryCount, correlationId);
|
|
||||||
n8n_workflow_1.LoggerProxy.info(who + 'File deleted successfully', { fileStorageId, correlationId });
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Delete file failed', { error, fileStorageId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getAccessToken() {
|
|
||||||
return this.accessToken;
|
|
||||||
}
|
|
||||||
isAuthenticated() {
|
|
||||||
return !!this.accessToken && (!this.tokenExpiry || new Date() < this.tokenExpiry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SecloreDRMFileService = SecloreDRMFileService;
|
|
||||||
//# sourceMappingURL=SecloreDRMFileService.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,3 +0,0 @@
|
||||||
export declare function getFileNameFromHeaders(headers?: {
|
|
||||||
[key: string]: string;
|
|
||||||
}): string | null;
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.getFileNameFromHeaders = getFileNameFromHeaders;
|
|
||||||
const n8n_workflow_1 = require("n8n-workflow");
|
|
||||||
function getFileNameFromHeaders(headers) {
|
|
||||||
const who = "Utils::getFileNameFromHeaders:: ";
|
|
||||||
if (!headers) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'No headers provided');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const contentDisposition = Object.keys(headers).find(key => key.toLowerCase() === 'content-disposition');
|
|
||||||
if (!contentDisposition || !headers[contentDisposition]) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Content-Disposition header not found');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const headerValue = headers[contentDisposition];
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Found Content-Disposition header', { headerValue });
|
|
||||||
const utf8Match = headerValue.match(/filename\*=UTF-8''([^;]+)/i);
|
|
||||||
if (utf8Match) {
|
|
||||||
try {
|
|
||||||
const decodedFilename = decodeURIComponent(utf8Match[1]);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Extracted filename from UTF-8 format', { filename: decodedFilename });
|
|
||||||
return decodedFilename;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Failed to decode UTF-8 filename', { error, encodedFilename: utf8Match[1] });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const quotedMatch = headerValue.match(/filename="([^"]+)"/i);
|
|
||||||
if (quotedMatch) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Extracted filename from quoted format', { filename: quotedMatch[1] });
|
|
||||||
return quotedMatch[1];
|
|
||||||
}
|
|
||||||
const unquotedMatch = headerValue.match(/filename=([^;]+)/i);
|
|
||||||
if (unquotedMatch) {
|
|
||||||
const filename = unquotedMatch[1].trim();
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Extracted filename from unquoted format', { filename });
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Could not extract filename from Content-Disposition header', { headerValue });
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=Utils.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../nodes/SecloreProtect/Services/Utils.ts"],"names":[],"mappings":";;AAOA,wDAmDC;AA1DD,+CAAqD;AAOrD,SAAgB,sBAAsB,CAAC,OAAmC;IACzE,MAAM,GAAG,GAAG,kCAAkC,CAAC;IAE/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,qBAAqB,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACb,CAAC;IAGD,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAC1D,GAAG,CAAC,WAAW,EAAE,KAAK,qBAAqB,CAC3C,CAAC;IAEF,IAAI,CAAC,kBAAkB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACzD,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,sCAAsC,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChD,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,kCAAkC,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAIxE,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClE,IAAI,SAAS,EAAE,CAAC;QACf,IAAI,CAAC;YACJ,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACzD,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,sCAAsC,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;YAC1F,OAAO,eAAe,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,iCAAiC,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACjG,CAAC;IACF,CAAC;IAGD,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC7D,IAAI,WAAW,EAAE,CAAC;QACjB,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,uCAAuC,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC1F,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAGD,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC7D,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,yCAAyC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5E,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,0BAAM,CAAC,KAAK,CAAC,GAAG,GAAG,4DAA4D,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAClG,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import { IExecuteFunctions, NodeOutput } from 'n8n-workflow';
|
|
||||||
export declare function protectWithHotFolder(this: IExecuteFunctions): Promise<NodeOutput>;
|
|
||||||
|
|
@ -1,205 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.protectWithHotFolder = protectWithHotFolder;
|
|
||||||
const n8n_workflow_1 = require("n8n-workflow");
|
|
||||||
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
||||||
const SecloreDRMFileService_1 = require("../Services/SecloreDRMFileService");
|
|
||||||
const Utils_1 = require("../Services/Utils");
|
|
||||||
async function deleteFile(fileService, fileStorageId, correlationId, retryCount = 3) {
|
|
||||||
const who = "protectWithHotFolder::deleteFile:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Attempting to delete file', { fileStorageId, correlationId, retryCount });
|
|
||||||
await fileService.deleteFile(fileStorageId, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File deleted successfully', { fileStorageId, correlationId });
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'File deletion failed, continuing operation', {
|
|
||||||
error,
|
|
||||||
fileStorageId,
|
|
||||||
correlationId,
|
|
||||||
message: 'This is a cleanup operation, continuing despite deletion failure'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function protectFileWithHotFolder(fileService, fileBuffer, fileName, hotfolderId, correlationId, retryCount = 3) {
|
|
||||||
const who = "protectWithHotFolder::protectFileWithHotFolder:: ";
|
|
||||||
let originalFileStorageId = '';
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Starting protect file with hot folder operation', { fileName, fileSize: fileBuffer.length, hotfolderId, correlationId, retryCount });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Uploading file', { fileName, fileSize: fileBuffer.length, correlationId });
|
|
||||||
const uploadResult = await fileService.uploadFile(new Uint8Array(fileBuffer), fileName, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File uploaded successfully', { fileStorageId: uploadResult.fileStorageId, fileName, correlationId });
|
|
||||||
if (uploadResult.protected) {
|
|
||||||
throw new Error('File is already protected');
|
|
||||||
}
|
|
||||||
originalFileStorageId = uploadResult.fileStorageId;
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protecting file with hot folder', { fileStorageId: uploadResult.fileStorageId, hotfolderId, fileName, correlationId });
|
|
||||||
const protectResult = await fileService.protectWithHotFolder({
|
|
||||||
hotfolderId,
|
|
||||||
fileStorageId: uploadResult.fileStorageId,
|
|
||||||
}, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File protected successfully', {
|
|
||||||
originalFileStorageId: uploadResult.fileStorageId,
|
|
||||||
protectedFileStorageId: protectResult.fileStorageId,
|
|
||||||
secloreFileId: protectResult.secloreFileId,
|
|
||||||
hotfolderId,
|
|
||||||
fileName,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Downloading protected file', { fileStorageId: protectResult.fileStorageId, fileName, correlationId });
|
|
||||||
const protectedFileData = await fileService.downloadFile(protectResult.fileStorageId, correlationId, retryCount);
|
|
||||||
const actualFileName = (0, Utils_1.getFileNameFromHeaders)(protectedFileData.headers) || fileName;
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protected file downloaded successfully', {
|
|
||||||
fileStorageId: protectResult.fileStorageId,
|
|
||||||
fileSize: protectedFileData.data.length,
|
|
||||||
originalFileName: fileName,
|
|
||||||
actualFileName,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const result = {
|
|
||||||
protectedFileData: protectedFileData.data,
|
|
||||||
originalFileStorageId: uploadResult.fileStorageId,
|
|
||||||
protectedFileStorageId: protectResult.fileStorageId,
|
|
||||||
secloreFileId: protectResult.secloreFileId,
|
|
||||||
fileName: actualFileName,
|
|
||||||
fileSize: protectedFileData.data.length,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protect file with hot folder operation completed successfully', {
|
|
||||||
fileName: result.fileName,
|
|
||||||
originalFileStorageId: result.originalFileStorageId,
|
|
||||||
protectedFileStorageId: result.protectedFileStorageId,
|
|
||||||
secloreFileId: result.secloreFileId,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
hotfolderId,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protect file with hot folder operation failed', { error, fileName, hotfolderId, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (originalFileStorageId !== '') {
|
|
||||||
await deleteFile(fileService, originalFileStorageId, correlationId, retryCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function protectWithHotFolder() {
|
|
||||||
const who = "protectWithHotFolder::protectWithHotFolder:: ";
|
|
||||||
const items = this.getInputData();
|
|
||||||
const returnData = [];
|
|
||||||
n8n_workflow_1.LoggerProxy.init(this.logger);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Seclore Protect with HotFolder operation started', { itemCount: items.length });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Getting credentials', {});
|
|
||||||
const credentials = await this.getCredentials('secloreProtectApi');
|
|
||||||
const baseUrl = credentials.baseUrl;
|
|
||||||
const tenantId = credentials.tenantId;
|
|
||||||
const tenantSecret = credentials.tenantSecret;
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Initializing file service', { baseUrl, tenantId });
|
|
||||||
const fileService = new SecloreDRMFileService_1.SecloreDRMFileService(this, baseUrl, tenantId, tenantSecret);
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Processing item', { itemIndex: i });
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Getting node parameters', { itemIndex: i });
|
|
||||||
const hotfolderId = this.getNodeParameter('hotfolderId', i);
|
|
||||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
||||||
const correlationId = node_crypto_1.default.randomUUID();
|
|
||||||
const retryCount = this.getNodeParameter('retryCount', i);
|
|
||||||
if (!hotfolderId) {
|
|
||||||
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'HotFolder ID is required', {
|
|
||||||
itemIndex: i,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Asserting binary data', { binaryPropertyName, itemIndex: i });
|
|
||||||
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Getting binary data buffer', { binaryPropertyName, itemIndex: i });
|
|
||||||
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Binary data retrieved', {
|
|
||||||
fileName: binaryData.fileName,
|
|
||||||
fileSize: fileBuffer.length,
|
|
||||||
mimeType: binaryData.mimeType,
|
|
||||||
itemIndex: i,
|
|
||||||
correlationId,
|
|
||||||
retryCount
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Starting protect file with hot folder operation', {
|
|
||||||
fileName: binaryData.fileName,
|
|
||||||
hotfolderId,
|
|
||||||
correlationId,
|
|
||||||
retryCount,
|
|
||||||
itemIndex: i
|
|
||||||
});
|
|
||||||
const result = await protectFileWithHotFolder(fileService, fileBuffer, binaryData.fileName || 'file', hotfolderId, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Protect file with hot folder operation completed successfully', {
|
|
||||||
fileName: result.fileName,
|
|
||||||
originalFileStorageId: result.originalFileStorageId,
|
|
||||||
protectedFileStorageId: result.protectedFileStorageId,
|
|
||||||
secloreFileId: result.secloreFileId,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
hotfolderId,
|
|
||||||
itemIndex: i,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Preparing binary data for output', {
|
|
||||||
fileName: result.fileName,
|
|
||||||
mimeType: binaryData.mimeType,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
itemIndex: i
|
|
||||||
});
|
|
||||||
const outputBinaryData = await this.helpers.prepareBinaryData(Buffer.from(result.protectedFileData), result.fileName, binaryData.mimeType);
|
|
||||||
const returnItem = {
|
|
||||||
json: {
|
|
||||||
success: true,
|
|
||||||
originalFileStorageId: result.originalFileStorageId,
|
|
||||||
protectedFileStorageId: result.protectedFileStorageId,
|
|
||||||
secloreFileId: result.secloreFileId,
|
|
||||||
hotfolderId,
|
|
||||||
fileName: result.fileName,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
correlationId: correlationId,
|
|
||||||
},
|
|
||||||
binary: {
|
|
||||||
data: outputBinaryData,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Adding result to return data', { itemIndex: i, success: true });
|
|
||||||
returnData.push(returnItem);
|
|
||||||
}
|
|
||||||
catch (protectError) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Protect file with hot folder operation failed', { protectError, itemIndex: i });
|
|
||||||
throw protectError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Item processing failed', { error, itemIndex: i });
|
|
||||||
if (this.continueOnFail()) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Continuing on fail, adding error item', { itemIndex: i, errorMessage: error.message });
|
|
||||||
const returnItem = {
|
|
||||||
json: {
|
|
||||||
success: false,
|
|
||||||
error: error.message,
|
|
||||||
itemIndex: i,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
returnData.push(returnItem);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Throwing NodeOperationError', { error: error.message, itemIndex: i });
|
|
||||||
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, {
|
|
||||||
itemIndex: i,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Seclore Protect with HotFolder operation completed', {
|
|
||||||
processedItems: returnData.length,
|
|
||||||
successfulItems: returnData.filter(item => item.json.success).length
|
|
||||||
});
|
|
||||||
return [returnData];
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=protectWithHotFolder.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +0,0 @@
|
||||||
import { IExecuteFunctions, NodeOutput } from 'n8n-workflow';
|
|
||||||
export declare function unprotect(this: IExecuteFunctions): Promise<NodeOutput>;
|
|
||||||
|
|
@ -1,195 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.unprotect = unprotect;
|
|
||||||
const n8n_workflow_1 = require("n8n-workflow");
|
|
||||||
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
||||||
const SecloreDRMFileService_1 = require("../Services/SecloreDRMFileService");
|
|
||||||
const Utils_1 = require("../Services/Utils");
|
|
||||||
async function deleteFile(fileService, fileStorageId, correlationId, retryCount = 3) {
|
|
||||||
const who = "unprotect::deleteFileWithErrorHandling:: ";
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Attempting to delete file', { fileStorageId, correlationId, retryCount });
|
|
||||||
await fileService.deleteFile(fileStorageId, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File deleted successfully', { fileStorageId, correlationId });
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'File deletion failed, continuing operation', {
|
|
||||||
error,
|
|
||||||
fileStorageId,
|
|
||||||
correlationId,
|
|
||||||
message: 'This is a cleanup operation, continuing despite deletion failure'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function unprotectFile(fileService, fileBuffer, fileName, correlationId, retryCount = 3) {
|
|
||||||
const who = "unprotect::unprotectFile:: ";
|
|
||||||
let originalFileStorageId = '';
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Starting unprotect file operation', { fileName, fileSize: fileBuffer.length, correlationId, retryCount });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Uploading protected file', { fileName, fileSize: fileBuffer.length, correlationId });
|
|
||||||
const uploadResult = await fileService.uploadFile(new Uint8Array(fileBuffer), fileName, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File uploaded successfully', { fileStorageId: uploadResult.fileStorageId, fileName, correlationId });
|
|
||||||
originalFileStorageId = uploadResult.fileStorageId;
|
|
||||||
if (!uploadResult.protected) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File is already unprotected', { fileStorageId: uploadResult.fileStorageId, fileName, correlationId });
|
|
||||||
return {
|
|
||||||
unprotectedFileData: fileBuffer,
|
|
||||||
originalFileStorageId: uploadResult.fileStorageId,
|
|
||||||
unprotectedFileStorageId: uploadResult.fileStorageId,
|
|
||||||
fileName,
|
|
||||||
fileSize: fileBuffer.length,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotecting file', { fileStorageId: uploadResult.fileStorageId, fileName, correlationId });
|
|
||||||
const unprotectResult = await fileService.unprotect({
|
|
||||||
fileStorageId: uploadResult.fileStorageId,
|
|
||||||
}, correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'File unprotected successfully', {
|
|
||||||
originalFileStorageId: uploadResult.fileStorageId,
|
|
||||||
unprotectedFileStorageId: unprotectResult.fileStorageId,
|
|
||||||
fileName,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Downloading unprotected file', { fileStorageId: unprotectResult.fileStorageId, fileName, correlationId });
|
|
||||||
const unprotectedFileData = await fileService.downloadFile(unprotectResult.fileStorageId, correlationId, retryCount);
|
|
||||||
const actualFileName = (0, Utils_1.getFileNameFromHeaders)(unprotectedFileData.headers) || fileName;
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotected file downloaded successfully', {
|
|
||||||
fileStorageId: unprotectResult.fileStorageId,
|
|
||||||
fileSize: unprotectedFileData.data.length,
|
|
||||||
originalFileName: fileName,
|
|
||||||
actualFileName: actualFileName,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
const result = {
|
|
||||||
unprotectedFileData: unprotectedFileData.data,
|
|
||||||
originalFileStorageId: uploadResult.fileStorageId,
|
|
||||||
unprotectedFileStorageId: unprotectResult.fileStorageId,
|
|
||||||
fileName: actualFileName,
|
|
||||||
fileSize: unprotectedFileData.data.length,
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotect file operation completed successfully', {
|
|
||||||
fileName: result.fileName,
|
|
||||||
originalFileStorageId: result.originalFileStorageId,
|
|
||||||
unprotectedFileStorageId: result.unprotectedFileStorageId,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Unprotect file operation failed', { error, fileName, correlationId });
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (originalFileStorageId !== '') {
|
|
||||||
await deleteFile(fileService, originalFileStorageId, correlationId, retryCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function unprotect() {
|
|
||||||
const who = "unprotect::unprotect:: ";
|
|
||||||
const items = this.getInputData();
|
|
||||||
const returnData = [];
|
|
||||||
n8n_workflow_1.LoggerProxy.init(this.logger);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Seclore Unprotect operation started', { itemCount: items.length });
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Getting credentials', {});
|
|
||||||
const credentials = await this.getCredentials('secloreProtectApi');
|
|
||||||
const baseUrl = credentials.baseUrl;
|
|
||||||
const tenantId = credentials.tenantId;
|
|
||||||
const tenantSecret = credentials.tenantSecret;
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Initializing file service', { baseUrl, tenantId });
|
|
||||||
const fileService = new SecloreDRMFileService_1.SecloreDRMFileService(this, baseUrl, tenantId, tenantSecret);
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Processing item', { itemIndex: i });
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Getting node parameters', { itemIndex: i });
|
|
||||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
||||||
const correlationId = node_crypto_1.default.randomUUID();
|
|
||||||
const retryCount = this.getNodeParameter('retryCount', i);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Asserting binary data', { binaryPropertyName, itemIndex: i });
|
|
||||||
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Getting binary data buffer', { binaryPropertyName, itemIndex: i });
|
|
||||||
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Binary data retrieved', {
|
|
||||||
fileName: binaryData.fileName,
|
|
||||||
fileSize: fileBuffer.length,
|
|
||||||
mimeType: binaryData.mimeType,
|
|
||||||
itemIndex: i,
|
|
||||||
correlationId,
|
|
||||||
retryCount
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Starting unprotect file operation', {
|
|
||||||
fileName: binaryData.fileName,
|
|
||||||
correlationId,
|
|
||||||
retryCount,
|
|
||||||
itemIndex: i
|
|
||||||
});
|
|
||||||
const result = await unprotectFile(fileService, fileBuffer, binaryData.fileName || 'protected_file', correlationId, retryCount);
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Unprotect file operation completed successfully', {
|
|
||||||
fileName: result.fileName,
|
|
||||||
originalFileStorageId: result.originalFileStorageId,
|
|
||||||
unprotectedFileStorageId: result.unprotectedFileStorageId,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
itemIndex: i,
|
|
||||||
correlationId
|
|
||||||
});
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Preparing binary data for output', {
|
|
||||||
fileName: binaryData.fileName,
|
|
||||||
mimeType: binaryData.mimeType,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
itemIndex: i
|
|
||||||
});
|
|
||||||
const outputBinaryData = await this.helpers.prepareBinaryData(Buffer.from(result.unprotectedFileData), result.fileName, binaryData.mimeType);
|
|
||||||
const returnItem = {
|
|
||||||
json: {
|
|
||||||
success: true,
|
|
||||||
originalFileStorageId: result.originalFileStorageId,
|
|
||||||
unprotectedFileStorageId: result.unprotectedFileStorageId,
|
|
||||||
fileName: result.fileName,
|
|
||||||
fileSize: result.fileSize,
|
|
||||||
correlationId: correlationId,
|
|
||||||
},
|
|
||||||
binary: {
|
|
||||||
data: outputBinaryData,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Adding result to return data', { itemIndex: i, success: true });
|
|
||||||
returnData.push(returnItem);
|
|
||||||
}
|
|
||||||
catch (unprotectError) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Unprotect file operation failed', { unprotectError, itemIndex: i });
|
|
||||||
throw unprotectError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Item processing failed', { error, itemIndex: i });
|
|
||||||
if (this.continueOnFail()) {
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Continuing on fail, adding error item', { itemIndex: i, errorMessage: error.message });
|
|
||||||
const returnItem = {
|
|
||||||
json: {
|
|
||||||
success: false,
|
|
||||||
error: error.message,
|
|
||||||
itemIndex: i,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
returnData.push(returnItem);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
n8n_workflow_1.LoggerProxy.error(who + 'Throwing NodeOperationError', { error: error.message, itemIndex: i });
|
|
||||||
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, {
|
|
||||||
itemIndex: i,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n8n_workflow_1.LoggerProxy.debug(who + 'Seclore Unprotect operation completed', {
|
|
||||||
processedItems: returnData.length,
|
|
||||||
successfulItems: returnData.filter(item => item.json.success).length
|
|
||||||
});
|
|
||||||
return [returnData];
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=unprotect.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,51 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@seclore/n8n-nodes-seclore",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"description": "n8n community node for Seclore Protect - secure file protection using DRM technology",
|
|
||||||
"license": "MIT",
|
|
||||||
"homepage": "",
|
|
||||||
"keywords": [
|
|
||||||
"n8n-community-node-package"
|
|
||||||
],
|
|
||||||
"author": {
|
|
||||||
"name": "Seclore Technology",
|
|
||||||
"email": "support@seclore.com"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://repo.seclore.com/public/n8n-nodes-seclore.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "n8n-node build",
|
|
||||||
"build:watch": "tsc --watch",
|
|
||||||
"dev": "n8n-node dev",
|
|
||||||
"lint": "n8n-node lint",
|
|
||||||
"lint:fix": "n8n-node lint --fix",
|
|
||||||
"release": "n8n-node release",
|
|
||||||
"prepublishOnly": "n8n-node prerelease"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"n8n": {
|
|
||||||
"n8nNodesApiVersion": 1,
|
|
||||||
"strict": true,
|
|
||||||
"credentials": [
|
|
||||||
"dist/credentials/SecloreProtectApi.credentials.js"
|
|
||||||
],
|
|
||||||
"nodes": [
|
|
||||||
"dist/nodes/SecloreProtect/SecloreProtect.node.js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@n8n/node-cli": "*",
|
|
||||||
"@types/node": "^24.9.1",
|
|
||||||
"eslint": "9.32.0",
|
|
||||||
"prettier": "3.6.2",
|
|
||||||
"release-it": "^19.0.4",
|
|
||||||
"typescript": "5.9.2"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"n8n-workflow": "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue