Skip to content

Commit

Permalink
changeOrigin: true for all request (because of some user get ERR_TLS_…
Browse files Browse the repository at this point in the history
…CERT_ALTNAME_INVALID error)

some typo
  • Loading branch information
Frigyes Bartha committed Jun 30, 2020
1 parent 1e4b357 commit d3e547c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions carelink.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function reqOptions(extra) {
jar: true,
followRedirect: false,
rejectUnauthorized: false,
changeOrigin: true,
headers: {
Host: carelinkServerAddress,
Connection: 'keep-alive',
Expand Down Expand Up @@ -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)
);
}
Expand Down Expand Up @@ -177,7 +180,6 @@ var Client = exports.Client = function (options) {
CARELINKEU_LOGIN3_URL,
reqOptions({
jar: jar,
changeOrigin: true,
gzip: true,
form: {
sessionID: ps.sessionID,
Expand Down Expand Up @@ -205,7 +207,6 @@ var Client = exports.Client = function (options) {
CARELINKEU_LOGIN4_URL,
reqOptions({
jar: jar,
changeOrigin: true,
form: {
action: "consent",
sessionID: ps.sessionID,
Expand All @@ -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: {
Expand All @@ -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', ''),
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit d3e547c

Please sign in to comment.