@aiteza/n8n-nodes-aiteza 1.0.1 → 1.1.0
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.
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AitezaTrigger = void 0;
|
|
4
|
+
function timingSafeEqual(a, b) {
|
|
5
|
+
if (a.length !== b.length)
|
|
6
|
+
return false;
|
|
7
|
+
let diff = 0;
|
|
8
|
+
for (let i = 0; i < a.length; i++) {
|
|
9
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
10
|
+
}
|
|
11
|
+
return diff === 0;
|
|
12
|
+
}
|
|
13
|
+
async function getWebhookApiKey(ctx) {
|
|
14
|
+
try {
|
|
15
|
+
const credentials = await ctx.getCredentials('aitezaWebhookApi');
|
|
16
|
+
return (credentials?.apiKey ?? '').trim();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
4
22
|
class AitezaTrigger {
|
|
5
23
|
description = {
|
|
6
24
|
displayName: 'AITEZA Trigger',
|
|
@@ -12,7 +30,12 @@ class AitezaTrigger {
|
|
|
12
30
|
defaults: { name: 'AITEZA Trigger' },
|
|
13
31
|
inputs: [],
|
|
14
32
|
outputs: ['main'],
|
|
15
|
-
credentials: [
|
|
33
|
+
credentials: [
|
|
34
|
+
{
|
|
35
|
+
name: 'aitezaWebhookApi',
|
|
36
|
+
required: false,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
16
39
|
webhooks: [
|
|
17
40
|
{
|
|
18
41
|
name: 'default',
|
|
@@ -71,6 +94,12 @@ class AitezaTrigger {
|
|
|
71
94
|
const userBearer = user.bearerToken ?? '';
|
|
72
95
|
const authHeader = headers.authorization || headers.Authorization || '';
|
|
73
96
|
const headerToken = authHeader.replace(/^Bearer\s+/i, '');
|
|
97
|
+
const expectedApiKey = await getWebhookApiKey(this);
|
|
98
|
+
if (expectedApiKey && !timingSafeEqual(headerToken, expectedApiKey)) {
|
|
99
|
+
const res = this.getResponseObject();
|
|
100
|
+
res.status(401).json({ error: 'Unauthorized' });
|
|
101
|
+
return { noWebhookResponse: true };
|
|
102
|
+
}
|
|
74
103
|
const authToken = userBearer || headerToken;
|
|
75
104
|
const baseUrl = this.getNodeParameter('baseUrl', '').replace(/\/+$/, '');
|
|
76
105
|
const outputData = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiteza/n8n-nodes-aiteza",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "n8n Community Node for the AITEZA REST API (Datarooms, Files, Chat, Search, Workflows)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"n8n": {
|
|
31
31
|
"n8nNodesApiVersion": 1,
|
|
32
32
|
"credentials": [
|
|
33
|
-
"dist/credentials/AitezaOAuth2Api.credentials.js"
|
|
33
|
+
"dist/credentials/AitezaOAuth2Api.credentials.js",
|
|
34
|
+
"dist/credentials/AitezaWebhookApi.credentials.js"
|
|
34
35
|
],
|
|
35
36
|
"nodes": [
|
|
36
37
|
"dist/nodes/Aiteza/Aiteza.node.js",
|