n8n-nodes-digit 0.1.10 → 0.1.12
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/DIGIT.node.js +31 -25
- package/package.json +1 -1
- package/dist/package.json +0 -19
package/dist/nodes/DIGIT.node.js
CHANGED
|
@@ -34,6 +34,9 @@ exports.description = {
|
|
|
34
34
|
required: true,
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
|
+
// NOTE:
|
|
38
|
+
// baseURL intentionally NOT set here
|
|
39
|
+
// URLs are built safely inside execute()
|
|
37
40
|
requestDefaults: {
|
|
38
41
|
headers: {
|
|
39
42
|
Accept: 'application/json',
|
|
@@ -74,9 +77,9 @@ class DIGIT {
|
|
|
74
77
|
this.description = exports.description;
|
|
75
78
|
}
|
|
76
79
|
async execute() {
|
|
77
|
-
//
|
|
78
|
-
// Load
|
|
79
|
-
//
|
|
80
|
+
// -------------------------------
|
|
81
|
+
// Load & validate credentials
|
|
82
|
+
// -------------------------------
|
|
80
83
|
var _a;
|
|
81
84
|
const credentials = await this.getCredentials('digitApi');
|
|
82
85
|
let baseUrl = credentials === null || credentials === void 0 ? void 0 : credentials.baseUrl;
|
|
@@ -86,14 +89,16 @@ class DIGIT {
|
|
|
86
89
|
if (!baseUrl.startsWith('http')) {
|
|
87
90
|
throw new Error('DIGIT Credentials: Base URL must start with http:// or https://');
|
|
88
91
|
}
|
|
89
|
-
//
|
|
92
|
+
// Normalize trailing slash
|
|
90
93
|
baseUrl = baseUrl.replace(/\/+$/, '');
|
|
91
|
-
//
|
|
94
|
+
// -------------------------------
|
|
95
|
+
// Setup
|
|
96
|
+
// -------------------------------
|
|
92
97
|
const resource = this.getNodeParameter('resource', 0);
|
|
93
98
|
const items = this.getInputData();
|
|
94
99
|
const returnData = [];
|
|
95
100
|
// ==================================================
|
|
96
|
-
// AUTH — TOKEN DECODE (LOCAL)
|
|
101
|
+
// AUTH — TOKEN DECODE (LOCAL ONLY)
|
|
97
102
|
// ==================================================
|
|
98
103
|
if (resource === 'auth') {
|
|
99
104
|
const operation = this.getNodeParameter('authOperation', 0);
|
|
@@ -105,21 +110,23 @@ class DIGIT {
|
|
|
105
110
|
const base64Url = raw.split('.')[1];
|
|
106
111
|
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
107
112
|
const payload = JSON.parse(buffer_1.Buffer.from(base64, 'base64').toString('utf8'));
|
|
113
|
+
const roles = ((_a = payload === null || payload === void 0 ? void 0 : payload.realm_access) === null || _a === void 0 ? void 0 : _a.roles) || [];
|
|
114
|
+
const clientId = (payload === null || payload === void 0 ? void 0 : payload.azp) || '';
|
|
108
115
|
let tenant = '';
|
|
109
|
-
if (payload
|
|
116
|
+
if (payload.iss) {
|
|
110
117
|
const parts = payload.iss.split('/');
|
|
111
118
|
tenant = parts[parts.length - 1];
|
|
112
119
|
}
|
|
113
120
|
returnData.push({
|
|
114
121
|
json: {
|
|
115
122
|
authToken: `Bearer ${raw}`,
|
|
116
|
-
roles
|
|
117
|
-
clientId
|
|
123
|
+
roles,
|
|
124
|
+
clientId,
|
|
118
125
|
tenantId: tenant,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
exp: payload
|
|
126
|
+
subject: payload.sub,
|
|
127
|
+
username: payload.preferred_username || '',
|
|
128
|
+
email: payload.email || '',
|
|
129
|
+
exp: payload.exp,
|
|
123
130
|
},
|
|
124
131
|
});
|
|
125
132
|
}
|
|
@@ -136,7 +143,7 @@ class DIGIT {
|
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
// ==================================================
|
|
139
|
-
// FILESTORE — FETCH
|
|
146
|
+
// FILESTORE — FILE FETCH
|
|
140
147
|
// ==================================================
|
|
141
148
|
if (resource === 'filestore') {
|
|
142
149
|
const operation = this.getNodeParameter('filestoreOperation', 0);
|
|
@@ -146,10 +153,9 @@ class DIGIT {
|
|
|
146
153
|
const fileId = this.getNodeParameter('fileId', i);
|
|
147
154
|
const tenantId = this.getNodeParameter('tenantId', i);
|
|
148
155
|
const accessToken = this.getNodeParameter('accessToken', i);
|
|
149
|
-
const url = new URL(`/filestore/v1/files/${fileId}`, baseUrl).toString();
|
|
150
156
|
const response = await this.helpers.httpRequest({
|
|
151
157
|
method: 'GET',
|
|
152
|
-
url,
|
|
158
|
+
url: new URL(`/filestore/v1/files/${fileId}`, baseUrl).toString(),
|
|
153
159
|
qs: { tenantId },
|
|
154
160
|
headers: {
|
|
155
161
|
'X-Tenant-Id': tenantId,
|
|
@@ -158,6 +164,8 @@ class DIGIT {
|
|
|
158
164
|
: `Bearer ${accessToken}`,
|
|
159
165
|
},
|
|
160
166
|
json: true,
|
|
167
|
+
resolveWithFullResponse: false,
|
|
168
|
+
simple: true,
|
|
161
169
|
});
|
|
162
170
|
returnData.push({ json: response });
|
|
163
171
|
}
|
|
@@ -185,10 +193,9 @@ class DIGIT {
|
|
|
185
193
|
const codes = this.getNodeParameter('codes', i);
|
|
186
194
|
const accessToken = this.getNodeParameter('accessToken', i);
|
|
187
195
|
const clientId = this.getNodeParameter('clientId', i);
|
|
188
|
-
const url = new URL('/egov-location/location/v11/boundarys/_search', baseUrl).toString();
|
|
189
196
|
const response = await this.helpers.httpRequest({
|
|
190
197
|
method: 'GET',
|
|
191
|
-
url,
|
|
198
|
+
url: new URL('/egov-location/location/v11/boundarys/_search', baseUrl).toString(),
|
|
192
199
|
qs: {
|
|
193
200
|
tenantId,
|
|
194
201
|
boundaryCodes: codes,
|
|
@@ -201,6 +208,8 @@ class DIGIT {
|
|
|
201
208
|
: `Bearer ${accessToken}`,
|
|
202
209
|
},
|
|
203
210
|
json: true,
|
|
211
|
+
resolveWithFullResponse: false,
|
|
212
|
+
simple: true,
|
|
204
213
|
});
|
|
205
214
|
returnData.push({ json: response });
|
|
206
215
|
}
|
|
@@ -234,14 +243,9 @@ class DIGIT {
|
|
|
234
243
|
catch {
|
|
235
244
|
throw new Error('Invalid JSON in Request Body');
|
|
236
245
|
}
|
|
237
|
-
body = {
|
|
238
|
-
RequestInfo: {},
|
|
239
|
-
...body,
|
|
240
|
-
};
|
|
241
|
-
const url = new URL('/egov-idgen/id/_generate', baseUrl).toString();
|
|
242
246
|
const response = await this.helpers.httpRequest({
|
|
243
247
|
method: 'POST',
|
|
244
|
-
url,
|
|
248
|
+
url: new URL('/egov-idgen/id/_generate', baseUrl).toString(),
|
|
245
249
|
headers: {
|
|
246
250
|
'X-Tenant-Id': tenantId,
|
|
247
251
|
'X-Client-Id': clientId,
|
|
@@ -251,6 +255,8 @@ class DIGIT {
|
|
|
251
255
|
},
|
|
252
256
|
body,
|
|
253
257
|
json: true,
|
|
258
|
+
resolveWithFullResponse: false,
|
|
259
|
+
simple: true,
|
|
254
260
|
});
|
|
255
261
|
returnData.push({ json: response });
|
|
256
262
|
}
|
|
@@ -266,7 +272,7 @@ class DIGIT {
|
|
|
266
272
|
return [returnData];
|
|
267
273
|
}
|
|
268
274
|
}
|
|
269
|
-
throw new Error('DIGIT node: Unsupported resource
|
|
275
|
+
throw new Error('DIGIT node: Unsupported resource/operation combination');
|
|
270
276
|
}
|
|
271
277
|
}
|
|
272
278
|
exports.DIGIT = DIGIT;
|
package/package.json
CHANGED
package/dist/package.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "n8n-nodes-digit",
|
|
3
|
-
"version": "0.1.9",
|
|
4
|
-
"description": "DIGIT Platform nodes for n8n",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"n8n": {
|
|
11
|
-
"nodes": [
|
|
12
|
-
"nodes/DIGIT.node.js"
|
|
13
|
-
],
|
|
14
|
-
"credentials": [
|
|
15
|
-
"credentials/DIGITApi.credentials.js"
|
|
16
|
-
]
|
|
17
|
-
},
|
|
18
|
-
"license": "MIT"
|
|
19
|
-
}
|