@connectorx/n8n-nodes-cortex 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CortexTrigger = void 0;
4
+ class CortexTrigger {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: 'Cortex Trigger',
8
+ name: 'cortexTrigger',
9
+ icon: 'file:cortex.png',
10
+ group: ['trigger'],
11
+ version: 1,
12
+ description: 'Handle Cortex Webhook Events',
13
+ defaults: {
14
+ name: 'Cortex Trigger',
15
+ },
16
+ inputs: [],
17
+ outputs: ['main'],
18
+ properties: [
19
+ {
20
+ displayName: 'Webhook Secret',
21
+ name: 'webhookSecret',
22
+ type: 'string',
23
+ default: '',
24
+ placeholder: 'your-secret-token',
25
+ description: 'The secret token to validate incoming requests (Authorization: Bearer <token>)',
26
+ required: true,
27
+ },
28
+ ],
29
+ webhooks: [
30
+ {
31
+ name: 'default',
32
+ httpMethod: 'POST',
33
+ responseMode: 'onReceived',
34
+ path: 'webhook',
35
+ },
36
+ {
37
+ name: 'setup',
38
+ httpMethod: 'GET',
39
+ responseMode: 'onReceived',
40
+ path: 'webhook',
41
+ },
42
+ ],
43
+ };
44
+ }
45
+ async webhook() {
46
+ const httpMethod = this.getRequestObject().method;
47
+ const headers = this.getHeaderData();
48
+ const body = this.getBodyData();
49
+ const webhookSecret = this.getNodeParameter('webhookSecret');
50
+ const authHeader = (headers['authorization'] || headers['Authorization']);
51
+ if (!authHeader) {
52
+ return {
53
+ webhookResponse: {
54
+ status: 401,
55
+ body: { error: 'Missing Authorization header' },
56
+ },
57
+ };
58
+ }
59
+ const [scheme, token] = authHeader.split(' ');
60
+ if (scheme !== 'Bearer' || token !== webhookSecret) {
61
+ return {
62
+ webhookResponse: {
63
+ status: 403,
64
+ body: { error: 'Invalid Token' },
65
+ },
66
+ };
67
+ }
68
+ if (httpMethod === 'GET') {
69
+ return {
70
+ webhookResponse: {
71
+ status: 200,
72
+ body: { status: 'success', message: 'Webhook validated' },
73
+ },
74
+ };
75
+ }
76
+ if (httpMethod === 'POST') {
77
+ return {
78
+ workflowData: [
79
+ this.helpers.returnJsonArray(body),
80
+ ],
81
+ };
82
+ }
83
+ return {
84
+ webhookResponse: {
85
+ status: 405,
86
+ body: { error: 'Method Not Allowed' },
87
+ },
88
+ };
89
+ }
90
+ }
91
+ exports.CortexTrigger = CortexTrigger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectorx/n8n-nodes-cortex",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "n8n nodes for Cortex API",
5
5
  "keywords": [
6
6
  "n8n-community-node-package"
@@ -23,7 +23,8 @@
23
23
  ],
24
24
  "n8n": {
25
25
  "nodes": [
26
- "dist/nodes/Cortex/Cortex.node.js"
26
+ "dist/nodes/Cortex/Cortex.node.js",
27
+ "dist/nodes/Cortex/CortexTrigger.node.js"
27
28
  ],
28
29
  "credentials": [
29
30
  "dist/credentials/CortexApi.credentials.js"