Skip to content

Commit

Permalink
FIX: Accept consent when login in
Browse files Browse the repository at this point in the history
The Consent was changed and it seems like the API only accepts a German consent. So that's what I changed and VW, AUDI, SEAT and CUPRA are working again.
  • Loading branch information
martijnpoppen committed Dec 12, 2024
1 parent fee8953 commit 9d5018a
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,22 +683,24 @@ class VwWeconnect extends utils.Adapter {
//check for empty form object
if (Object.keys(form).length === 0 && form.constructor === Object) {
try {
const stringJson = body
.split("window._IDK = ")[1]
.split("</")[0]
.replace(/\n/g, "")
.replace(/:\/\//g, "")
.replace(/local:/g, "");
const json = stringJson
.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/g, '"$2": ')
.replace(/'/g, '"')
.replace(/""/g, '"');
const parsedJson = JSON.parse(json);
form._csrf = parsedJson.csrf_token;
form.hmac = parsedJson.templateModel.hmac;
form.relayState = parsedJson.templateModel.relayState;
form.legalDocuments = parsedJson.templateModel.legalDocuments;
} catch (error) {
const stringJson = body
.split("window._IDK = ")[1]
.split("</")[0]

let json = stringJson.replace(/([{,]\s*)(\w+)\s*:/g, '$1"$2":') // Add quotes around property names
json = json.replace(/'/g, '"')
json = json.replace(/,\s*}/g, '}') // Remove trailing commas

const parsedJson = JSON.parse(json);

form._csrf = parsedJson.csrf_token;
form.hmac = parsedJson.templateModel.hmac;
form.relayState = parsedJson.templateModel.relayState;
form.legalDocuments = parsedJson.templateModel.legalDocuments;
form.countryOfResidence = 'DE';
form.countryOfJurisdiction = 'DE';

} catch (error) {
this.log.error(
"Error in consent form. Please accept the Data Privacy Statement in the app after relogin",
);
Expand Down Expand Up @@ -803,6 +805,7 @@ class VwWeconnect extends utils.Adapter {
);
this.log.info(getRequest.uri.href);
const form = this.extractHidden(body);

getRequest = request.post(
{
url: getRequest.uri.href,
Expand Down Expand Up @@ -6355,4 +6358,4 @@ if (module.parent) {
} else {
// otherwise start the instance directly
new VwWeconnect();
}
}

0 comments on commit 9d5018a

Please sign in to comment.