n8n-nodes-jygse-vw-weconnect 0.1.13 → 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.
|
@@ -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,
|
|
@@ -228,12 +213,14 @@ async function vwLogin(context, email, password) {
|
|
|
228
213
|
let htmlContent;
|
|
229
214
|
let currentUrl = '';
|
|
230
215
|
let stateToken = '';
|
|
216
|
+
let httpStatusCode = 0;
|
|
231
217
|
if (typeof authorizeResponse === 'string') {
|
|
232
218
|
htmlContent = authorizeResponse;
|
|
233
219
|
}
|
|
234
220
|
else if (authorizeResponse && typeof authorizeResponse === 'object') {
|
|
235
221
|
const respObj = authorizeResponse;
|
|
236
222
|
const respHeaders = respObj.headers;
|
|
223
|
+
httpStatusCode = respObj.statusCode || 0;
|
|
237
224
|
// Check for redirect in headers (case-insensitive)
|
|
238
225
|
if (respHeaders) {
|
|
239
226
|
const locationHeader = respHeaders.location || respHeaders.Location;
|
|
@@ -254,6 +241,11 @@ async function vwLogin(context, email, password) {
|
|
|
254
241
|
else {
|
|
255
242
|
htmlContent = String(authorizeResponse);
|
|
256
243
|
}
|
|
244
|
+
// Debug: If we got an error page (status 400/500 or "Oops" in content), throw with details
|
|
245
|
+
if (httpStatusCode >= 400 || htmlContent.includes('Oops!, something went wrong')) {
|
|
246
|
+
const preview = htmlContent.substring(0, 1000);
|
|
247
|
+
throw new Error(`CARIAD BFF Error (HTTP ${httpStatusCode}): ${preview}`);
|
|
248
|
+
}
|
|
257
249
|
// Follow redirects manually to capture the state parameter
|
|
258
250
|
let maxInitialRedirects = 5;
|
|
259
251
|
while (currentUrl && maxInitialRedirects > 0) {
|
|
@@ -266,12 +258,12 @@ async function vwLogin(context, email, password) {
|
|
|
266
258
|
if (currentUrl.includes('/u/login') && stateToken) {
|
|
267
259
|
break;
|
|
268
260
|
}
|
|
269
|
-
// Follow the redirect using
|
|
261
|
+
// Follow the redirect using API headers
|
|
270
262
|
const followUrl = currentUrl.startsWith('http') ? currentUrl : `https://identity.vwgroup.io${currentUrl}`;
|
|
271
263
|
const followResponse = await context.helpers.httpRequest({
|
|
272
264
|
method: 'GET',
|
|
273
265
|
url: followUrl,
|
|
274
|
-
headers:
|
|
266
|
+
headers: apiHeaders,
|
|
275
267
|
encoding: 'text',
|
|
276
268
|
returnFullResponse: true,
|
|
277
269
|
ignoreHttpStatusErrors: true,
|
|
@@ -474,9 +466,9 @@ async function vwLogin(context, email, password) {
|
|
|
474
466
|
method: 'POST',
|
|
475
467
|
url: `https://identity.vwgroup.io/u/login?state=${encodeURIComponent(stateToken)}`,
|
|
476
468
|
headers: {
|
|
477
|
-
'User-Agent':
|
|
478
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9
|
|
479
|
-
'Accept-Language':
|
|
469
|
+
'User-Agent': VW_USER_AGENT,
|
|
470
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
471
|
+
'Accept-Language': VW_ACCEPT_LANGUAGE,
|
|
480
472
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
481
473
|
'Origin': 'https://identity.vwgroup.io',
|
|
482
474
|
'Referer': `https://identity.vwgroup.io/u/login?state=${encodeURIComponent(stateToken)}`,
|
|
@@ -554,7 +546,7 @@ async function vwLogin(context, email, password) {
|
|
|
554
546
|
const followResponse = await context.helpers.httpRequest({
|
|
555
547
|
method: 'GET',
|
|
556
548
|
url: redirectUrl.startsWith('http') ? redirectUrl : `https://identity.vwgroup.io${redirectUrl}`,
|
|
557
|
-
headers:
|
|
549
|
+
headers: apiHeaders,
|
|
558
550
|
encoding: 'text',
|
|
559
551
|
returnFullResponse: true,
|
|
560
552
|
ignoreHttpStatusErrors: true,
|
package/package.json
CHANGED