@connectorx/n8n-nodes-cortex 0.1.18 → 0.1.20
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,105 @@
|
|
|
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. Used for both verification (hub.verify_token) and data reception (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 query = this.getQueryData();
|
|
48
|
+
const headers = this.getHeaderData();
|
|
49
|
+
const body = this.getBodyData();
|
|
50
|
+
const webhookSecret = this.getNodeParameter('webhookSecret');
|
|
51
|
+
if (httpMethod === 'GET') {
|
|
52
|
+
const mode = query['hub.mode'];
|
|
53
|
+
const token = query['hub.verify_token'];
|
|
54
|
+
const challenge = query['hub.challenge'];
|
|
55
|
+
if (mode === 'subscribe' && token === webhookSecret) {
|
|
56
|
+
return {
|
|
57
|
+
webhookResponse: {
|
|
58
|
+
status: 200,
|
|
59
|
+
body: challenge,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return {
|
|
65
|
+
webhookResponse: {
|
|
66
|
+
status: 403,
|
|
67
|
+
body: { error: 'Verification failed' },
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (httpMethod === 'POST') {
|
|
73
|
+
const authHeader = (headers['authorization'] || headers['Authorization']);
|
|
74
|
+
if (!authHeader) {
|
|
75
|
+
return {
|
|
76
|
+
webhookResponse: {
|
|
77
|
+
status: 401,
|
|
78
|
+
body: { error: 'Missing Authorization header' },
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const [scheme, token] = authHeader.split(' ');
|
|
83
|
+
if (scheme !== 'Bearer' || token !== webhookSecret) {
|
|
84
|
+
return {
|
|
85
|
+
webhookResponse: {
|
|
86
|
+
status: 403,
|
|
87
|
+
body: { error: 'Invalid Token' },
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
workflowData: [
|
|
93
|
+
this.helpers.returnJsonArray(body),
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
webhookResponse: {
|
|
99
|
+
status: 405,
|
|
100
|
+
body: { error: 'Method Not Allowed' },
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.CortexTrigger = CortexTrigger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@connectorx/n8n-nodes-cortex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
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"
|