n8n-nodes-digit 0.1.14 → 0.1.15
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 +29 -23
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/nodes/DIGIT.node.js
CHANGED
|
@@ -74,9 +74,9 @@ class DIGIT {
|
|
|
74
74
|
this.description = exports.description;
|
|
75
75
|
}
|
|
76
76
|
async execute() {
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
77
|
+
// --------------------------------------------------
|
|
78
|
+
// Credentials
|
|
79
|
+
// --------------------------------------------------
|
|
80
80
|
var _a;
|
|
81
81
|
const credentials = await this.getCredentials('digitApi');
|
|
82
82
|
let baseUrl = credentials === null || credentials === void 0 ? void 0 : credentials.baseUrl;
|
|
@@ -86,17 +86,10 @@ class DIGIT {
|
|
|
86
86
|
if (!baseUrl.startsWith('http')) {
|
|
87
87
|
throw new Error('DIGIT Credentials: Base URL must start with http:// or https://');
|
|
88
88
|
}
|
|
89
|
-
// Normalize trailing slash
|
|
90
89
|
baseUrl = baseUrl.replace(/\/+$/, '');
|
|
91
|
-
// -------------------------------
|
|
92
|
-
// Detect gateway environment
|
|
93
|
-
// -------------------------------
|
|
94
90
|
const isGatewayEnv = baseUrl.includes('digit.org') ||
|
|
95
91
|
baseUrl.includes('digit-lts') ||
|
|
96
92
|
baseUrl.includes('gateway');
|
|
97
|
-
// -------------------------------
|
|
98
|
-
// Setup
|
|
99
|
-
// -------------------------------
|
|
100
93
|
const resource = this.getNodeParameter('resource', 0);
|
|
101
94
|
const items = this.getInputData();
|
|
102
95
|
const returnData = [];
|
|
@@ -113,7 +106,7 @@ class DIGIT {
|
|
|
113
106
|
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
114
107
|
const payload = JSON.parse(buffer_1.Buffer.from(base64, 'base64').toString('utf8'));
|
|
115
108
|
let tenant = '';
|
|
116
|
-
if (payload.iss) {
|
|
109
|
+
if (payload === null || payload === void 0 ? void 0 : payload.iss) {
|
|
117
110
|
const parts = payload.iss.split('/');
|
|
118
111
|
tenant = parts[parts.length - 1];
|
|
119
112
|
}
|
|
@@ -123,9 +116,9 @@ class DIGIT {
|
|
|
123
116
|
roles: ((_a = payload === null || payload === void 0 ? void 0 : payload.realm_access) === null || _a === void 0 ? void 0 : _a.roles) || [],
|
|
124
117
|
clientId: (payload === null || payload === void 0 ? void 0 : payload.azp) || '',
|
|
125
118
|
tenantId: tenant,
|
|
126
|
-
username: payload.preferred_username || '',
|
|
127
|
-
email: payload.email || '',
|
|
128
|
-
exp: payload.exp,
|
|
119
|
+
username: (payload === null || payload === void 0 ? void 0 : payload.preferred_username) || '',
|
|
120
|
+
email: (payload === null || payload === void 0 ? void 0 : payload.email) || '',
|
|
121
|
+
exp: payload === null || payload === void 0 ? void 0 : payload.exp,
|
|
129
122
|
},
|
|
130
123
|
});
|
|
131
124
|
}
|
|
@@ -133,7 +126,7 @@ class DIGIT {
|
|
|
133
126
|
}
|
|
134
127
|
}
|
|
135
128
|
// ==================================================
|
|
136
|
-
// FILESTORE —
|
|
129
|
+
// FILESTORE — FETCH
|
|
137
130
|
// ==================================================
|
|
138
131
|
if (resource === 'filestore') {
|
|
139
132
|
const operation = this.getNodeParameter('filestoreOperation', 0);
|
|
@@ -143,7 +136,7 @@ class DIGIT {
|
|
|
143
136
|
const tenantId = this.getNodeParameter('tenantId', i);
|
|
144
137
|
const accessToken = this.getNodeParameter('accessToken', i);
|
|
145
138
|
const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
|
|
146
|
-
const
|
|
139
|
+
const apiResponse = await this.helpers.httpRequest({
|
|
147
140
|
method: 'GET',
|
|
148
141
|
url: new URL(`/filestore/v1/files/${fileId}`, baseUrl).toString(),
|
|
149
142
|
qs: { tenantId },
|
|
@@ -153,7 +146,9 @@ class DIGIT {
|
|
|
153
146
|
},
|
|
154
147
|
json: true,
|
|
155
148
|
});
|
|
156
|
-
returnData.push({
|
|
149
|
+
returnData.push({
|
|
150
|
+
json: JSON.parse(JSON.stringify(apiResponse)),
|
|
151
|
+
});
|
|
157
152
|
}
|
|
158
153
|
return [returnData];
|
|
159
154
|
}
|
|
@@ -169,7 +164,7 @@ class DIGIT {
|
|
|
169
164
|
const codes = this.getNodeParameter('codes', i);
|
|
170
165
|
const accessToken = this.getNodeParameter('accessToken', i);
|
|
171
166
|
const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
|
|
172
|
-
const
|
|
167
|
+
const apiResponse = await this.helpers.httpRequest({
|
|
173
168
|
method: 'GET',
|
|
174
169
|
url: new URL('/egov-location/location/v11/boundarys/_search', baseUrl).toString(),
|
|
175
170
|
qs: {
|
|
@@ -182,13 +177,15 @@ class DIGIT {
|
|
|
182
177
|
},
|
|
183
178
|
json: true,
|
|
184
179
|
});
|
|
185
|
-
returnData.push({
|
|
180
|
+
returnData.push({
|
|
181
|
+
json: JSON.parse(JSON.stringify(apiResponse)),
|
|
182
|
+
});
|
|
186
183
|
}
|
|
187
184
|
return [returnData];
|
|
188
185
|
}
|
|
189
186
|
}
|
|
190
187
|
// ==================================================
|
|
191
|
-
// IDGEN — GENERATE
|
|
188
|
+
// IDGEN — GENERATE
|
|
192
189
|
// ==================================================
|
|
193
190
|
if (resource === 'idgen') {
|
|
194
191
|
const operation = this.getNodeParameter('idgenOperation', 0);
|
|
@@ -203,10 +200,17 @@ class DIGIT {
|
|
|
203
200
|
catch {
|
|
204
201
|
throw new Error('Invalid JSON in Request Body');
|
|
205
202
|
}
|
|
203
|
+
// Core expects RequestInfo wrapper
|
|
204
|
+
if (!body.RequestInfo) {
|
|
205
|
+
body = {
|
|
206
|
+
RequestInfo: {},
|
|
207
|
+
...body,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
206
210
|
const idgenPath = isGatewayEnv
|
|
207
211
|
? '/idgen/v1/generate'
|
|
208
212
|
: '/egov-idgen/id/_generate';
|
|
209
|
-
const
|
|
213
|
+
const apiResponse = await this.helpers.httpRequest({
|
|
210
214
|
method: 'POST',
|
|
211
215
|
url: new URL(idgenPath, baseUrl).toString(),
|
|
212
216
|
headers: {
|
|
@@ -215,12 +219,14 @@ class DIGIT {
|
|
|
215
219
|
body,
|
|
216
220
|
json: true,
|
|
217
221
|
});
|
|
218
|
-
returnData.push({
|
|
222
|
+
returnData.push({
|
|
223
|
+
json: JSON.parse(JSON.stringify(apiResponse)),
|
|
224
|
+
});
|
|
219
225
|
}
|
|
220
226
|
return [returnData];
|
|
221
227
|
}
|
|
222
228
|
}
|
|
223
|
-
throw new Error('DIGIT node: Unsupported resource/operation combination');
|
|
229
|
+
throw new Error('DIGIT node: Unsupported resource / operation combination');
|
|
224
230
|
}
|
|
225
231
|
}
|
|
226
232
|
exports.DIGIT = DIGIT;
|
package/dist/package.json
CHANGED