n8n-nodes-digit 0.1.8 → 0.1.10

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.
@@ -35,7 +35,6 @@ exports.description = {
35
35
  },
36
36
  ],
37
37
  requestDefaults: {
38
- baseURL: '={{ $credentials.baseUrl }}',
39
38
  headers: {
40
39
  Accept: 'application/json',
41
40
  'Content-Type': 'application/json',
@@ -75,12 +74,26 @@ class DIGIT {
75
74
  this.description = exports.description;
76
75
  }
77
76
  async execute() {
77
+ // --------------------------------------------------
78
+ // Load Credentials
79
+ // --------------------------------------------------
78
80
  var _a;
81
+ const credentials = await this.getCredentials('digitApi');
82
+ let baseUrl = credentials === null || credentials === void 0 ? void 0 : credentials.baseUrl;
83
+ if (!baseUrl) {
84
+ throw new Error('DIGIT Credentials: Base URL is missing');
85
+ }
86
+ if (!baseUrl.startsWith('http')) {
87
+ throw new Error('DIGIT Credentials: Base URL must start with http:// or https://');
88
+ }
89
+ // normalize trailing slash
90
+ baseUrl = baseUrl.replace(/\/+$/, '');
91
+ // --------------------------------------------------
79
92
  const resource = this.getNodeParameter('resource', 0);
80
93
  const items = this.getInputData();
81
94
  const returnData = [];
82
95
  // ==================================================
83
- // AUTH — TOKEN DECODE
96
+ // AUTH — TOKEN DECODE (LOCAL)
84
97
  // ==================================================
85
98
  if (resource === 'auth') {
86
99
  const operation = this.getNodeParameter('authOperation', 0);
@@ -92,23 +105,21 @@ class DIGIT {
92
105
  const base64Url = raw.split('.')[1];
93
106
  const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
94
107
  const payload = JSON.parse(buffer_1.Buffer.from(base64, 'base64').toString('utf8'));
95
- const roles = ((_a = payload === null || payload === void 0 ? void 0 : payload.realm_access) === null || _a === void 0 ? void 0 : _a.roles) || [];
96
- const clientId = (payload === null || payload === void 0 ? void 0 : payload.azp) || '';
97
108
  let tenant = '';
98
- if (payload.iss) {
109
+ if (payload === null || payload === void 0 ? void 0 : payload.iss) {
99
110
  const parts = payload.iss.split('/');
100
111
  tenant = parts[parts.length - 1];
101
112
  }
102
113
  returnData.push({
103
114
  json: {
104
115
  authToken: `Bearer ${raw}`,
105
- roles,
106
- clientId,
116
+ roles: ((_a = payload === null || payload === void 0 ? void 0 : payload.realm_access) === null || _a === void 0 ? void 0 : _a.roles) || [],
117
+ clientId: (payload === null || payload === void 0 ? void 0 : payload.azp) || '',
107
118
  tenantId: tenant,
108
- subject: payload.sub,
109
- username: payload.preferred_username || '',
110
- email: payload.email || '',
111
- 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
+ subject: payload === null || payload === void 0 ? void 0 : payload.sub,
122
+ exp: payload === null || payload === void 0 ? void 0 : payload.exp,
112
123
  },
113
124
  });
114
125
  }
@@ -125,7 +136,7 @@ class DIGIT {
125
136
  }
126
137
  }
127
138
  // ==================================================
128
- // FILESTORE — FILE FETCH
139
+ // FILESTORE — FETCH FILE
129
140
  // ==================================================
130
141
  if (resource === 'filestore') {
131
142
  const operation = this.getNodeParameter('filestoreOperation', 0);
@@ -135,9 +146,10 @@ class DIGIT {
135
146
  const fileId = this.getNodeParameter('fileId', i);
136
147
  const tenantId = this.getNodeParameter('tenantId', i);
137
148
  const accessToken = this.getNodeParameter('accessToken', i);
149
+ const url = new URL(`/filestore/v1/files/${fileId}`, baseUrl).toString();
138
150
  const response = await this.helpers.httpRequest({
139
151
  method: 'GET',
140
- url: `/filestore/v1/files/${fileId}`,
152
+ url,
141
153
  qs: { tenantId },
142
154
  headers: {
143
155
  'X-Tenant-Id': tenantId,
@@ -173,10 +185,14 @@ class DIGIT {
173
185
  const codes = this.getNodeParameter('codes', i);
174
186
  const accessToken = this.getNodeParameter('accessToken', i);
175
187
  const clientId = this.getNodeParameter('clientId', i);
188
+ const url = new URL('/egov-location/location/v11/boundarys/_search', baseUrl).toString();
176
189
  const response = await this.helpers.httpRequest({
177
190
  method: 'GET',
178
- url: `/boundary/v1`,
179
- qs: { codes },
191
+ url,
192
+ qs: {
193
+ tenantId,
194
+ boundaryCodes: codes,
195
+ },
180
196
  headers: {
181
197
  'X-Tenant-Id': tenantId,
182
198
  'X-Client-Id': clientId,
@@ -218,9 +234,14 @@ class DIGIT {
218
234
  catch {
219
235
  throw new Error('Invalid JSON in Request Body');
220
236
  }
237
+ body = {
238
+ RequestInfo: {},
239
+ ...body,
240
+ };
241
+ const url = new URL('/egov-idgen/id/_generate', baseUrl).toString();
221
242
  const response = await this.helpers.httpRequest({
222
243
  method: 'POST',
223
- url: `/idgen/v1/generate`,
244
+ url,
224
245
  headers: {
225
246
  'X-Tenant-Id': tenantId,
226
247
  'X-Client-Id': clientId,
@@ -245,7 +266,7 @@ class DIGIT {
245
266
  return [returnData];
246
267
  }
247
268
  }
248
- throw new Error('DIGIT node: Unsupported resource/operation combination');
269
+ throw new Error('DIGIT node: Unsupported resource / operation combination');
249
270
  }
250
271
  }
251
272
  exports.DIGIT = DIGIT;
@@ -0,0 +1,19 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digit",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "DIGIT Platform nodes for n8n",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,10 +9,10 @@
9
9
  ],
10
10
  "n8n": {
11
11
  "nodes": [
12
- "dist/nodes"
12
+ "dist/nodes/DIGIT.node.js"
13
13
  ],
14
14
  "credentials": [
15
- "dist/credentials"
15
+ "dist/credentials/DIGITApi.credentials.js"
16
16
  ]
17
17
  },
18
18
  "scripts": {
@@ -20,6 +20,8 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "devDependencies": {
23
+ "gulp": "^5.0.1",
24
+ "gulp-cli": "^3.1.0",
23
25
  "typescript": "^5.9.3"
24
26
  }
25
27
  }