@aiteza/n8n-nodes-aiteza 1.0.1 → 1.1.1

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,16 @@
1
+ import type { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ /**
3
+ * Shared secret used by the AITEZA Trigger node to authenticate incoming
4
+ * webhook requests. The caller must send this value as an
5
+ * "Authorization: Bearer <apiKey>" header.
6
+ */
7
+ export declare class AitezaWebhookApi implements ICredentialType {
8
+ name: string;
9
+ displayName: string;
10
+ documentationUrl: string;
11
+ icon: {
12
+ readonly light: "file:aiteza.svg";
13
+ readonly dark: "file:aiteza.svg";
14
+ };
15
+ properties: INodeProperties[];
16
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AitezaWebhookApi = void 0;
4
+ /**
5
+ * Shared secret used by the AITEZA Trigger node to authenticate incoming
6
+ * webhook requests. The caller must send this value as an
7
+ * "Authorization: Bearer <apiKey>" header.
8
+ */
9
+ class AitezaWebhookApi {
10
+ name = 'aitezaWebhookApi';
11
+ displayName = 'AITEZA Webhook API Key';
12
+ documentationUrl = 'https://docs.aiteza.com';
13
+ icon = { light: 'file:aiteza.svg', dark: 'file:aiteza.svg' };
14
+ properties = [
15
+ {
16
+ displayName: 'API Key',
17
+ name: 'apiKey',
18
+ type: 'string',
19
+ typeOptions: { password: true },
20
+ default: '',
21
+ required: true,
22
+ description: 'The shared secret that incoming webhook requests must send as an "Authorization: Bearer <apiKey>" header.',
23
+ },
24
+ ];
25
+ }
26
+ exports.AitezaWebhookApi = AitezaWebhookApi;
@@ -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.1",
3
+ "version": "1.1.1",
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",