@aiteza/n8n-nodes-aiteza 0.2.1 → 0.3.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.
- package/dist/nodes/Aiteza/Aiteza.node.js +284 -58
- package/dist/nodes/Aiteza/AitezaProgress.node.d.ts +5 -0
- package/dist/nodes/Aiteza/AitezaProgress.node.js +271 -0
- package/dist/nodes/Aiteza/AitezaTrigger.node.js +47 -12
- package/dist/nodes/Aiteza/AitezaWorkflowResult.node.d.ts +5 -0
- package/dist/nodes/Aiteza/AitezaWorkflowResult.node.js +261 -0
- package/dist/nodes/Aiteza/GenericFunctions.d.ts +7 -0
- package/dist/nodes/Aiteza/GenericFunctions.js +96 -1
- package/package.json +4 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUpstreamAuthToken = getUpstreamAuthToken;
|
|
4
|
+
exports.getUpstreamBaseUrl = getUpstreamBaseUrl;
|
|
5
|
+
exports.isJwtExpired = isJwtExpired;
|
|
4
6
|
exports.aitezaApiRequest = aitezaApiRequest;
|
|
5
7
|
exports.aitezaApiRequestFullResponse = aitezaApiRequestFullResponse;
|
|
6
8
|
exports.loadDatarooms = loadDatarooms;
|
|
@@ -14,7 +16,44 @@ exports.loadStandaloneFiles = loadStandaloneFiles;
|
|
|
14
16
|
exports.loadStandaloneImages = loadStandaloneImages;
|
|
15
17
|
exports.validateRequiredField = validateRequiredField;
|
|
16
18
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
19
|
+
// Match the AITEZA Trigger node by its type name. The full node-type string
|
|
20
|
+
// includes the package namespace (e.g. "@aiteza/n8n-nodes-aiteza.aitezaTrigger"),
|
|
21
|
+
// so we match on the suffix.
|
|
22
|
+
function isAitezaTriggerType(type) {
|
|
23
|
+
return typeof type === 'string' && /(^|\.)aitezaTrigger$/i.test(type);
|
|
24
|
+
}
|
|
25
|
+
function findAitezaTriggerParentName(ef) {
|
|
26
|
+
try {
|
|
27
|
+
const currentNodeName = ef.getNode().name;
|
|
28
|
+
const parents = ef.getParentNodes(currentNodeName);
|
|
29
|
+
const trigger = parents.find((p) => isAitezaTriggerType(p.type) && !p.disabled);
|
|
30
|
+
return trigger?.name;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function readFromTriggerItems(ef, picker) {
|
|
37
|
+
const triggerName = findAitezaTriggerParentName(ef);
|
|
38
|
+
if (!triggerName)
|
|
39
|
+
return undefined;
|
|
40
|
+
try {
|
|
41
|
+
const proxy = ef.getWorkflowDataProxy(0);
|
|
42
|
+
const triggerItems = proxy.$items(triggerName) ?? [];
|
|
43
|
+
for (const item of triggerItems) {
|
|
44
|
+
const value = picker(item?.json);
|
|
45
|
+
if (value !== undefined && value !== null && value !== '')
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// proxy/items unavailable – ignore
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
17
54
|
function getUpstreamAuthToken(ef) {
|
|
55
|
+
// 1. Prefer the token on the immediate input items (cheap and matches the
|
|
56
|
+
// documented contract of forwarding `_authToken`).
|
|
18
57
|
try {
|
|
19
58
|
const items = ef.getInputData();
|
|
20
59
|
for (const item of items) {
|
|
@@ -26,7 +65,63 @@ function getUpstreamAuthToken(ef) {
|
|
|
26
65
|
catch {
|
|
27
66
|
// getInputData may not be available in every context
|
|
28
67
|
}
|
|
29
|
-
|
|
68
|
+
// 2. Fall back to the AITEZA Trigger node's original output. This makes the
|
|
69
|
+
// node resilient to intermediate transformations (Set/Edit Fields, Split
|
|
70
|
+
// Out, IF, etc.) that strip the `_authToken` field from items.
|
|
71
|
+
return readFromTriggerItems(ef, (json) => json?._authToken);
|
|
72
|
+
}
|
|
73
|
+
function getUpstreamBaseUrl(ef) {
|
|
74
|
+
try {
|
|
75
|
+
const items = ef.getInputData();
|
|
76
|
+
for (const item of items) {
|
|
77
|
+
const url = item.json?._baseUrl;
|
|
78
|
+
if (url)
|
|
79
|
+
return url.replace(/\/+$/, '');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// ignore
|
|
84
|
+
}
|
|
85
|
+
const fromTrigger = readFromTriggerItems(ef, (json) => json?._baseUrl);
|
|
86
|
+
return fromTrigger ? fromTrigger.replace(/\/+$/, '') : undefined;
|
|
87
|
+
}
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// JWT helpers
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
function decodeJwtPayload(token) {
|
|
92
|
+
try {
|
|
93
|
+
const payload = token.split('.')[1];
|
|
94
|
+
if (!payload)
|
|
95
|
+
return undefined;
|
|
96
|
+
const normalized = payload.replace(/-/g, '+').replace(/_/g, '/');
|
|
97
|
+
const padded = normalized + '='.repeat((4 - (normalized.length % 4)) % 4);
|
|
98
|
+
// atob is available in Node 16+ and the browser; decodes base64 to a
|
|
99
|
+
// binary string. JWT payloads are UTF-8 JSON; for the `exp` claim a
|
|
100
|
+
// binary-string decode is sufficient.
|
|
101
|
+
const decoded = globalThis.atob
|
|
102
|
+
? globalThis.atob(padded)
|
|
103
|
+
: '';
|
|
104
|
+
if (!decoded)
|
|
105
|
+
return undefined;
|
|
106
|
+
return JSON.parse(decoded);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns true when the token is a JWT with an `exp` claim that is in the past
|
|
114
|
+
* (with a small skew). Returns false when the token is not a parsable JWT or
|
|
115
|
+
* has no `exp` (we assume valid in that case – the server is the source of truth).
|
|
116
|
+
*/
|
|
117
|
+
function isJwtExpired(token, skewSeconds = 30) {
|
|
118
|
+
if (!token)
|
|
119
|
+
return true;
|
|
120
|
+
const payload = decodeJwtPayload(token);
|
|
121
|
+
if (!payload?.exp)
|
|
122
|
+
return false;
|
|
123
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
124
|
+
return payload.exp <= nowSeconds + skewSeconds;
|
|
30
125
|
}
|
|
31
126
|
// ---------------------------------------------------------------------------
|
|
32
127
|
// Internal helpers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiteza/n8n-nodes-aiteza",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
],
|
|
35
35
|
"nodes": [
|
|
36
36
|
"dist/nodes/Aiteza/Aiteza.node.js",
|
|
37
|
-
"dist/nodes/Aiteza/AitezaTrigger.node.js"
|
|
37
|
+
"dist/nodes/Aiteza/AitezaTrigger.node.js",
|
|
38
|
+
"dist/nodes/Aiteza/AitezaProgress.node.js",
|
|
39
|
+
"dist/nodes/Aiteza/AitezaWorkflowResult.node.js"
|
|
38
40
|
]
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|