@connectorx/n8n-nodes-cortex 0.1.19 → 0.1.21
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.
- package/dist/nodes/Cortex/CortexTrigger.node.js +39 -25
- package/package.json +46 -46
|
@@ -22,7 +22,7 @@ class CortexTrigger {
|
|
|
22
22
|
type: 'string',
|
|
23
23
|
default: '',
|
|
24
24
|
placeholder: 'your-secret-token',
|
|
25
|
-
description: 'The secret token to validate incoming requests (
|
|
25
|
+
description: 'The secret token to validate incoming requests. Used for both verification (hub.verify_token) and data reception (Bearer token).',
|
|
26
26
|
required: true,
|
|
27
27
|
},
|
|
28
28
|
],
|
|
@@ -44,36 +44,50 @@ class CortexTrigger {
|
|
|
44
44
|
}
|
|
45
45
|
async webhook() {
|
|
46
46
|
const httpMethod = this.getRequestObject().method;
|
|
47
|
+
const query = this.getQueryData();
|
|
47
48
|
const headers = this.getHeaderData();
|
|
48
49
|
const body = this.getBodyData();
|
|
49
50
|
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
51
|
if (httpMethod === 'GET') {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
}
|
|
75
71
|
}
|
|
76
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
|
+
}
|
|
77
91
|
return {
|
|
78
92
|
workflowData: [
|
|
79
93
|
this.helpers.returnJsonArray(body),
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@connectorx/n8n-nodes-cortex",
|
|
3
|
+
"version": "0.1.21",
|
|
4
|
+
"description": "n8n nodes for Cortex API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": {
|
|
10
|
+
"name": "Adriano Azevedo",
|
|
11
|
+
"email": "adriano@connectorx.com.br"
|
|
12
|
+
},
|
|
13
|
+
"main": "index.js",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "node node_modules/typescript/lib/tsc.js && npm run copy-files",
|
|
16
|
+
"copy-files": "node node_modules/copyfiles/index.js -u 1 \"nodes/**/*.svg\" \"nodes/**/*.png\" dist/nodes && node node_modules/copyfiles/index.js -u 1 \"credentials/**/*.svg\" \"credentials/**/*.png\" dist/credentials",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"lint": "eslint nodes credentials --ext .ts",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"n8n": {
|
|
25
|
+
"nodes": [
|
|
26
|
+
"dist/nodes/Cortex/Cortex.node.js",
|
|
27
|
+
"dist/nodes/Cortex/CortexTrigger.node.js"
|
|
7
28
|
],
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
],
|
|
29
|
-
"credentials": [
|
|
30
|
-
"dist/credentials/CortexApi.credentials.js"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/express": "^4.17.6",
|
|
35
|
-
"@types/node": "^14.14.41",
|
|
36
|
-
"@types/request-promise-native": "~1.0.15",
|
|
37
|
-
"@typescript-eslint/parser": "~4.22.0",
|
|
38
|
-
"copyfiles": "^2.4.1",
|
|
39
|
-
"eslint": "~7.25.0",
|
|
40
|
-
"n8n-core": "~0.119.0",
|
|
41
|
-
"n8n-workflow": "~0.119.0",
|
|
42
|
-
"prettier": "^2.2.1",
|
|
43
|
-
"typescript": "~4.2.4"
|
|
44
|
-
},
|
|
45
|
-
"peerDependencies": {
|
|
46
|
-
"n8n-workflow": "*"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
29
|
+
"credentials": [
|
|
30
|
+
"dist/credentials/CortexApi.credentials.js"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/express": "^4.17.6",
|
|
35
|
+
"@types/node": "^14.14.41",
|
|
36
|
+
"@types/request-promise-native": "~1.0.15",
|
|
37
|
+
"@typescript-eslint/parser": "~4.22.0",
|
|
38
|
+
"copyfiles": "^2.4.1",
|
|
39
|
+
"eslint": "~7.25.0",
|
|
40
|
+
"n8n-core": "~0.119.0",
|
|
41
|
+
"n8n-workflow": "~0.119.0",
|
|
42
|
+
"prettier": "^2.2.1",
|
|
43
|
+
"typescript": "~4.2.4"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"n8n-workflow": "*"
|
|
47
|
+
}
|
|
48
|
+
}
|