diff --git a/lib/sources/minimedcarelink/index.js b/lib/sources/minimedcarelink/index.js index c45dfa9..10b36f5 100644 --- a/lib/sources/minimedcarelink/index.js +++ b/lib/sources/minimedcarelink/index.js @@ -2,11 +2,13 @@ var qs = require('qs'); var url = require('url'); var tough = require('tough-cookie'); +var crypto = require('crypto'); var ACS = require('axios-cookiejar-support'); var software = require('../../../package.json'); -//var user_agent_string = [software.name, `${software.name}@${software.version}`, 'M2M@V6', software.homepage].join(', '); -var user_agent_string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46"; +var software_string = [software.name, `${software.name}/${software.version}`, '(M2M@V6)', software.homepage].join(' '); +var browser_string = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46 ${software.name}/${software.version} (M2M/V6)`; +var user_agent_string = software_string; // https://github.com/NightscoutFoundation/xDrip/blob/990df119a8404cff56cb68b92a7e0bb640da95ef/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow/client/CareLinkClient.java#L559 // https://github.com/nightscout/minimed-connect-to-nightscout/blob/master/carelink.js @@ -221,7 +223,7 @@ function carelinkSource (opts, axios) { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' , 'Accept-Language': "en;q=0.9, *;q=0.8" , 'sec-ch-ua': "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"" - , "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" + , "User-Agent": browser_string }; @@ -236,19 +238,22 @@ function carelinkSource (opts, axios) { country: opts.countryCode , lang: opts.languageCode }; - var headers = { }; + var headers = { + 'x-uniq-req': crypto.randomUUID() + , ...html_headers + }; console.log("AUTH WITH", modDefaults.login_url, params, headers); return http.get(modDefaults.login_url, { params, headers }).then((resp) => { console.log("FIRST STEP LOGIN FLOW", resp.headers, resp.data); - let regex = /(