n8n-nodes-jygse-vw-weconnect 0.1.14 → 0.1.16
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.
|
@@ -179,22 +179,7 @@ async function vwLogin(context, email, password) {
|
|
|
179
179
|
try {
|
|
180
180
|
const traceId = generateTraceId();
|
|
181
181
|
const nonce = generateNonce();
|
|
182
|
-
//
|
|
183
|
-
// The CARIAD BFF expects a browser-style request, not an API-style request
|
|
184
|
-
const browserHeaders = {
|
|
185
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
186
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
|
|
187
|
-
'Accept-Language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7',
|
|
188
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
189
|
-
'Connection': 'keep-alive',
|
|
190
|
-
'Upgrade-Insecure-Requests': '1',
|
|
191
|
-
'Sec-Fetch-Dest': 'document',
|
|
192
|
-
'Sec-Fetch-Mode': 'navigate',
|
|
193
|
-
'Sec-Fetch-Site': 'none',
|
|
194
|
-
'Sec-Fetch-User': '?1',
|
|
195
|
-
'Cache-Control': 'max-age=0',
|
|
196
|
-
};
|
|
197
|
-
// API headers for subsequent requests (WeConnect-python style)
|
|
182
|
+
// API headers matching WeConnect-python v0.60.11 exactly
|
|
198
183
|
const apiHeaders = {
|
|
199
184
|
'User-Agent': VW_USER_AGENT,
|
|
200
185
|
'Accept': '*/*',
|
|
@@ -214,11 +199,11 @@ async function vwLogin(context, email, password) {
|
|
|
214
199
|
redirect_uri: VW_REDIRECT_URI,
|
|
215
200
|
nonce: nonce,
|
|
216
201
|
});
|
|
217
|
-
// Use
|
|
202
|
+
// Use WeConnect-python API headers for the initial CARIAD BFF request
|
|
218
203
|
const authorizeResponse = await context.helpers.httpRequest({
|
|
219
204
|
method: 'GET',
|
|
220
205
|
url: `${authorizeUrl}?${authorizeParams.toString()}`,
|
|
221
|
-
headers:
|
|
206
|
+
headers: apiHeaders,
|
|
222
207
|
encoding: 'text',
|
|
223
208
|
returnFullResponse: true,
|
|
224
209
|
ignoreHttpStatusErrors: true,
|
|
@@ -258,8 +243,17 @@ async function vwLogin(context, email, password) {
|
|
|
258
243
|
}
|
|
259
244
|
// Debug: If we got an error page (status 400/500 or "Oops" in content), throw with details
|
|
260
245
|
if (httpStatusCode >= 400 || htmlContent.includes('Oops!, something went wrong')) {
|
|
261
|
-
|
|
262
|
-
|
|
246
|
+
// Include all response headers for debugging
|
|
247
|
+
let headersInfo = 'none';
|
|
248
|
+
if (authorizeResponse && typeof authorizeResponse === 'object') {
|
|
249
|
+
const respObj = authorizeResponse;
|
|
250
|
+
const respHeaders = respObj.headers;
|
|
251
|
+
if (respHeaders) {
|
|
252
|
+
headersInfo = Object.keys(respHeaders).join(', ');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const preview = htmlContent.substring(0, 600);
|
|
256
|
+
throw new Error(`CARIAD BFF Error (HTTP ${httpStatusCode}). Response headers: [${headersInfo}]. URL: ${authorizeUrl}?${authorizeParams.toString()}. Body preview: ${preview}`);
|
|
263
257
|
}
|
|
264
258
|
// Follow redirects manually to capture the state parameter
|
|
265
259
|
let maxInitialRedirects = 5;
|
|
@@ -273,12 +267,12 @@ async function vwLogin(context, email, password) {
|
|
|
273
267
|
if (currentUrl.includes('/u/login') && stateToken) {
|
|
274
268
|
break;
|
|
275
269
|
}
|
|
276
|
-
// Follow the redirect using
|
|
270
|
+
// Follow the redirect using API headers
|
|
277
271
|
const followUrl = currentUrl.startsWith('http') ? currentUrl : `https://identity.vwgroup.io${currentUrl}`;
|
|
278
272
|
const followResponse = await context.helpers.httpRequest({
|
|
279
273
|
method: 'GET',
|
|
280
274
|
url: followUrl,
|
|
281
|
-
headers:
|
|
275
|
+
headers: apiHeaders,
|
|
282
276
|
encoding: 'text',
|
|
283
277
|
returnFullResponse: true,
|
|
284
278
|
ignoreHttpStatusErrors: true,
|
|
@@ -481,9 +475,9 @@ async function vwLogin(context, email, password) {
|
|
|
481
475
|
method: 'POST',
|
|
482
476
|
url: `https://identity.vwgroup.io/u/login?state=${encodeURIComponent(stateToken)}`,
|
|
483
477
|
headers: {
|
|
484
|
-
'User-Agent':
|
|
485
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9
|
|
486
|
-
'Accept-Language':
|
|
478
|
+
'User-Agent': VW_USER_AGENT,
|
|
479
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
480
|
+
'Accept-Language': VW_ACCEPT_LANGUAGE,
|
|
487
481
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
488
482
|
'Origin': 'https://identity.vwgroup.io',
|
|
489
483
|
'Referer': `https://identity.vwgroup.io/u/login?state=${encodeURIComponent(stateToken)}`,
|
|
@@ -561,7 +555,7 @@ async function vwLogin(context, email, password) {
|
|
|
561
555
|
const followResponse = await context.helpers.httpRequest({
|
|
562
556
|
method: 'GET',
|
|
563
557
|
url: redirectUrl.startsWith('http') ? redirectUrl : `https://identity.vwgroup.io${redirectUrl}`,
|
|
564
|
-
headers:
|
|
558
|
+
headers: apiHeaders,
|
|
565
559
|
encoding: 'text',
|
|
566
560
|
returnFullResponse: true,
|
|
567
561
|
ignoreHttpStatusErrors: true,
|
package/package.json
CHANGED