n8n-nodes-jygse-vw-weconnect 0.2.13 → 0.2.14
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.
|
@@ -32,10 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.VwWeConnect = void 0;
|
|
37
40
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
38
41
|
const crypto = __importStar(require("crypto"));
|
|
42
|
+
const axios_1 = __importDefault(require("axios"));
|
|
39
43
|
class VwWeConnect {
|
|
40
44
|
constructor() {
|
|
41
45
|
this.description = {
|
|
@@ -238,48 +242,40 @@ async function vwLogin(context, email, password) {
|
|
|
238
242
|
'&state=' + state +
|
|
239
243
|
'&code_challenge=' + codeChallenge +
|
|
240
244
|
'&code_challenge_method=S256';
|
|
241
|
-
// Use
|
|
242
|
-
//
|
|
243
|
-
const authorizeResponse = await
|
|
244
|
-
method: 'GET',
|
|
245
|
-
url: authorizeUrl,
|
|
245
|
+
// Use axios directly to have full control over redirect handling
|
|
246
|
+
// n8n's httpRequest helper has issues with custom scheme redirects
|
|
247
|
+
const authorizeResponse = await axios_1.default.get(authorizeUrl, {
|
|
246
248
|
headers: browserHeaders,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
maxRedirects: 0, // Don't follow any redirects
|
|
250
|
+
validateStatus: () => true, // Accept any status code
|
|
251
|
+
}).catch(err => {
|
|
252
|
+
// axios throws on redirect when maxRedirects=0, but we can get the response
|
|
253
|
+
if (err.response)
|
|
254
|
+
return err.response;
|
|
255
|
+
throw err;
|
|
251
256
|
});
|
|
252
|
-
// Extract response body and check for redirect
|
|
257
|
+
// Extract response body and check for redirect (axios format)
|
|
253
258
|
let htmlContent;
|
|
254
259
|
let currentUrl = '';
|
|
255
260
|
let stateToken = '';
|
|
256
261
|
let httpStatusCode = 0;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
// Check for redirect in headers (case-insensitive)
|
|
265
|
-
if (respHeaders) {
|
|
266
|
-
const locationHeader = respHeaders.location || respHeaders.Location;
|
|
267
|
-
if (locationHeader) {
|
|
268
|
-
currentUrl = locationHeader;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (respObj.body && typeof respObj.body === 'string') {
|
|
272
|
-
htmlContent = respObj.body;
|
|
273
|
-
}
|
|
274
|
-
else if (respObj.data && typeof respObj.data === 'string') {
|
|
275
|
-
htmlContent = respObj.data;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
htmlContent = JSON.stringify(respObj);
|
|
262
|
+
// axios response format: { data, status, headers, ... }
|
|
263
|
+
httpStatusCode = authorizeResponse.status || 0;
|
|
264
|
+
// Check for redirect in headers
|
|
265
|
+
if (authorizeResponse.headers) {
|
|
266
|
+
const locationHeader = authorizeResponse.headers.location || authorizeResponse.headers.Location;
|
|
267
|
+
if (locationHeader) {
|
|
268
|
+
currentUrl = locationHeader;
|
|
279
269
|
}
|
|
280
270
|
}
|
|
271
|
+
if (typeof authorizeResponse.data === 'string') {
|
|
272
|
+
htmlContent = authorizeResponse.data;
|
|
273
|
+
}
|
|
274
|
+
else if (authorizeResponse.data) {
|
|
275
|
+
htmlContent = JSON.stringify(authorizeResponse.data);
|
|
276
|
+
}
|
|
281
277
|
else {
|
|
282
|
-
htmlContent =
|
|
278
|
+
htmlContent = '';
|
|
283
279
|
}
|
|
284
280
|
// Debug: If we got an error page (status 400/500 or "Oops" in content), throw with details
|
|
285
281
|
if (httpStatusCode >= 400 || htmlContent.includes('Oops!, something went wrong')) {
|
|
@@ -306,38 +302,23 @@ async function vwLogin(context, email, password) {
|
|
|
306
302
|
if (!currentUrl.startsWith('http') && !currentUrl.startsWith('/')) {
|
|
307
303
|
break;
|
|
308
304
|
}
|
|
309
|
-
// Follow the redirect using
|
|
305
|
+
// Follow the redirect using axios
|
|
310
306
|
const followUrl = currentUrl.startsWith('http') ? currentUrl : `https://identity.vwgroup.io${currentUrl}`;
|
|
311
|
-
const followResponse = await
|
|
312
|
-
method: 'GET',
|
|
313
|
-
url: followUrl,
|
|
307
|
+
const followResponse = await axios_1.default.get(followUrl, {
|
|
314
308
|
headers: browserHeaders,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
else if (followResponse && typeof followResponse === 'object') {
|
|
325
|
-
const respObj = followResponse;
|
|
326
|
-
const respHeaders = respObj.headers;
|
|
327
|
-
currentUrl = '';
|
|
328
|
-
if (respHeaders) {
|
|
329
|
-
const locationHeader = respHeaders.location || respHeaders.Location;
|
|
330
|
-
if (locationHeader) {
|
|
331
|
-
currentUrl = locationHeader;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (respObj.body && typeof respObj.body === 'string') {
|
|
335
|
-
htmlContent = respObj.body;
|
|
336
|
-
}
|
|
337
|
-
else if (respObj.data && typeof respObj.data === 'string') {
|
|
338
|
-
htmlContent = respObj.data;
|
|
309
|
+
maxRedirects: 0,
|
|
310
|
+
validateStatus: () => true,
|
|
311
|
+
}).catch(err => err.response || { data: '', headers: {}, status: 0 });
|
|
312
|
+
currentUrl = '';
|
|
313
|
+
if (followResponse.headers) {
|
|
314
|
+
const locationHeader = followResponse.headers.location || followResponse.headers.Location;
|
|
315
|
+
if (locationHeader) {
|
|
316
|
+
currentUrl = locationHeader;
|
|
339
317
|
}
|
|
340
318
|
}
|
|
319
|
+
if (typeof followResponse.data === 'string') {
|
|
320
|
+
htmlContent = followResponse.data;
|
|
321
|
+
}
|
|
341
322
|
maxInitialRedirects--;
|
|
342
323
|
}
|
|
343
324
|
// Try to extract state token from the final HTML if not found in URL
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-jygse-vw-weconnect",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "n8n community node for VW We Connect - Control your Volkswagen T6.1 and other VW vehicles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -43,6 +43,9 @@
|
|
|
43
43
|
"dist/nodes/VwWeConnect/VwWeConnect.node.js"
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"axios": "^1.6.0"
|
|
48
|
+
},
|
|
46
49
|
"devDependencies": {
|
|
47
50
|
"@types/node": "^20.10.0",
|
|
48
51
|
"@typescript-eslint/parser": "^6.0.0",
|