n8n-nodes-jygse-vw-weconnect 0.1.12 → 0.1.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.
@@ -179,8 +179,23 @@ async function vwLogin(context, email, password) {
179
179
  try {
180
180
  const traceId = generateTraceId();
181
181
  const nonce = generateNonce();
182
- // Common headers used for all requests (matching WeConnect-python v0.60.9 exactly)
183
- const commonHeaders = {
182
+ // Browser-like headers for initial authorization request
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)
198
+ const apiHeaders = {
184
199
  'User-Agent': VW_USER_AGENT,
185
200
  'Accept': '*/*',
186
201
  'Accept-Language': VW_ACCEPT_LANGUAGE,
@@ -199,10 +214,11 @@ async function vwLogin(context, email, password) {
199
214
  redirect_uri: VW_REDIRECT_URI,
200
215
  nonce: nonce,
201
216
  });
217
+ // Use browser-like headers for the initial CARIAD BFF request
202
218
  const authorizeResponse = await context.helpers.httpRequest({
203
219
  method: 'GET',
204
220
  url: `${authorizeUrl}?${authorizeParams.toString()}`,
205
- headers: commonHeaders,
221
+ headers: browserHeaders,
206
222
  encoding: 'text',
207
223
  returnFullResponse: true,
208
224
  ignoreHttpStatusErrors: true,
@@ -212,12 +228,14 @@ async function vwLogin(context, email, password) {
212
228
  let htmlContent;
213
229
  let currentUrl = '';
214
230
  let stateToken = '';
231
+ let httpStatusCode = 0;
215
232
  if (typeof authorizeResponse === 'string') {
216
233
  htmlContent = authorizeResponse;
217
234
  }
218
235
  else if (authorizeResponse && typeof authorizeResponse === 'object') {
219
236
  const respObj = authorizeResponse;
220
237
  const respHeaders = respObj.headers;
238
+ httpStatusCode = respObj.statusCode || 0;
221
239
  // Check for redirect in headers (case-insensitive)
222
240
  if (respHeaders) {
223
241
  const locationHeader = respHeaders.location || respHeaders.Location;
@@ -238,6 +256,11 @@ async function vwLogin(context, email, password) {
238
256
  else {
239
257
  htmlContent = String(authorizeResponse);
240
258
  }
259
+ // Debug: If we got an error page (status 400/500 or "Oops" in content), throw with details
260
+ if (httpStatusCode >= 400 || htmlContent.includes('Oops!, something went wrong')) {
261
+ const preview = htmlContent.substring(0, 1000);
262
+ throw new Error(`CARIAD BFF Error (HTTP ${httpStatusCode}): ${preview}`);
263
+ }
241
264
  // Follow redirects manually to capture the state parameter
242
265
  let maxInitialRedirects = 5;
243
266
  while (currentUrl && maxInitialRedirects > 0) {
@@ -250,12 +273,12 @@ async function vwLogin(context, email, password) {
250
273
  if (currentUrl.includes('/u/login') && stateToken) {
251
274
  break;
252
275
  }
253
- // Follow the redirect
276
+ // Follow the redirect using browser-like headers
254
277
  const followUrl = currentUrl.startsWith('http') ? currentUrl : `https://identity.vwgroup.io${currentUrl}`;
255
278
  const followResponse = await context.helpers.httpRequest({
256
279
  method: 'GET',
257
280
  url: followUrl,
258
- headers: commonHeaders,
281
+ headers: browserHeaders,
259
282
  encoding: 'text',
260
283
  returnFullResponse: true,
261
284
  ignoreHttpStatusErrors: true,
@@ -458,7 +481,9 @@ async function vwLogin(context, email, password) {
458
481
  method: 'POST',
459
482
  url: `https://identity.vwgroup.io/u/login?state=${encodeURIComponent(stateToken)}`,
460
483
  headers: {
461
- ...commonHeaders,
484
+ 'User-Agent': browserHeaders['User-Agent'],
485
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
486
+ 'Accept-Language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7',
462
487
  'Content-Type': 'application/x-www-form-urlencoded',
463
488
  'Origin': 'https://identity.vwgroup.io',
464
489
  'Referer': `https://identity.vwgroup.io/u/login?state=${encodeURIComponent(stateToken)}`,
@@ -536,7 +561,7 @@ async function vwLogin(context, email, password) {
536
561
  const followResponse = await context.helpers.httpRequest({
537
562
  method: 'GET',
538
563
  url: redirectUrl.startsWith('http') ? redirectUrl : `https://identity.vwgroup.io${redirectUrl}`,
539
- headers: commonHeaders,
564
+ headers: browserHeaders,
540
565
  encoding: 'text',
541
566
  returnFullResponse: true,
542
567
  ignoreHttpStatusErrors: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-jygse-vw-weconnect",
3
- "version": "0.1.12",
3
+ "version": "0.1.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",