From d3e547c2f72aacbe0bde5d4f911ecb9978b5c165 Mon Sep 17 00:00:00 2001 From: Frigyes Bartha Date: Tue, 30 Jun 2020 16:38:21 +0200 Subject: [PATCH] changeOrigin: true for all request (because of some user get ERR_TLS_CERT_ALTNAME_INVALID error) some typo --- carelink.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/carelink.js b/carelink.js index 679839d..d0c6d17 100644 --- a/carelink.js +++ b/carelink.js @@ -35,6 +35,7 @@ function reqOptions(extra) { jar: true, followRedirect: false, rejectUnauthorized: false, + changeOrigin: true, headers: { Host: carelinkServerAddress, Connection: 'keep-alive', @@ -123,7 +124,9 @@ var Client = exports.Client = function (options) { logger.log('GET ' + CARELINK_AFTER_LOGIN_URL); request.get( CARELINK_AFTER_LOGIN_URL, - reqOptions({jar: jar}), + reqOptions({ + jar: jar + }), checkResponseThen(next) ); } @@ -177,7 +180,6 @@ var Client = exports.Client = function (options) { CARELINKEU_LOGIN3_URL, reqOptions({ jar: jar, - changeOrigin: true, gzip: true, form: { sessionID: ps.sessionID, @@ -205,7 +207,6 @@ var Client = exports.Client = function (options) { CARELINKEU_LOGIN4_URL, reqOptions({ jar: jar, - changeOrigin: true, form: { action: "consent", sessionID: ps.sessionID, @@ -227,20 +228,18 @@ var Client = exports.Client = function (options) { url, reqOptions({ jar: jar, - changeOrigin: true, }), checkResponseThen(next) ); } - function refreshTokenEu(response, next) { + function refreshTokenEu(next) { logger.log('Refresh auth token'); request.post( CARELINKEU_REFRESH_TOKEN_URL, reqOptions({ jar: jar, - changeOrigin: true, gzip: true, json: true, headers: { @@ -255,7 +254,10 @@ var Client = exports.Client = function (options) { var url = carelinkJsonUrlNow(); logger.log('GET ' + url); - var reqO = {jar: jar, gzip: true}; + var reqO = { + jar: jar, + gzip: true + }; if (CARELINK_EU) { reqO.headers = { Authorization: "Bearer " + _.get(getCookie(CARELINKEU_TOKEN_COOKIE), 'value', ''), @@ -303,7 +305,7 @@ var Client = exports.Client = function (options) { let expire = new Date(Date.parse( _.get(getCookie(CARELINKEU_TOKENEXPIRE_COOKIE), 'value', '1970-01-01'))); if (expire < new Date(Date.now() - 5 * 1000 * 60)) { - refreshTokenEu(null, next); + refreshTokenEu(next); } else { next(null, null); }