diff --git a/Publish/bmw-linker.js b/Publish/bmw-linker.js index b3a359d..f2c6d08 100644 --- a/Publish/bmw-linker.js +++ b/Publish/bmw-linker.js @@ -869,13 +869,11 @@ const Running = async (Widget, default_args = '') => { }; let WIDGET_FILE_NAME = 'bmw-linker.js'; -let WIDGET_VERSION = 'v2.2.0'; -let WIDGET_BUILD = '22050701'; +let WIDGET_VERSION = 'v2.2.1'; +let WIDGET_BUILD = '22050702'; let WIDGET_PREFIX = '[bmw-linker] '; -let DEPENDENCIES = [ - 'jsencrypt.js' //本地化加密 -]; +let DEPENDENCIES = []; let WIDGET_FONT = 'SF UI Display'; let WIDGET_FONT_BOLD = 'SF UI Display Bold'; @@ -973,7 +971,7 @@ class Widget extends Base { constructor(arg) { super(arg); - this.name = 'BMW-Linker'; + this.name = 'BMW-Linker ' + WIDGET_VERSION; this.desc = '宝马My BMW互联App小组件'; // load settings @@ -1120,7 +1118,7 @@ class Widget extends Base { userLoginAlert.title = '配置BMW登录'; userLoginAlert.message = '使用短信授权登录'; - userLoginAlert.addTextField('短信验证码', this.userConfigData['pass_code']); + userLoginAlert.addTextField('短信验证码', null); userLoginAlert.addAction('确定'); userLoginAlert.addCancelAction('取消'); @@ -1130,7 +1128,7 @@ class Widget extends Base { if (id == -1) { return; } - this.userConfigData['pass_code'] = userLoginAlert.textFieldValue(0); + let passCode = userLoginAlert.textFieldValue(0); let req = new Request(BMW_SERVER_HOST + `/eadrax-coas/v1/login/sms`); req.method = 'POST'; @@ -1138,7 +1136,7 @@ class Widget extends Base { req.body = JSON.stringify({ mobile: Number(this.userConfigData.username).toString(), otpId: otpId, - otpMsg: Number(this.userConfigData['pass_code']).toString() + otpMsg: Number(passCode).toString() }); req.headers = BMW_HEADERS; @@ -1324,10 +1322,10 @@ class Widget extends Base { console.warn('hasUpdate'); const updateAlert = new Alert(); updateAlert.title = '暂无更新'; + let changeLogText = await this.loadChangeLogs(); if (hasUpdate) { // load changes log - let changeLogText = await this.loadChangeLogs(); updateAlert.title = '找到更新'; updateAlert.message = changeLogText; @@ -1336,7 +1334,7 @@ class Widget extends Base { updateAlert.addAction('开始下载'); } else { - updateAlert.message = '但您可重新下载小组件\n\r\n是否重新下载?'; + updateAlert.message = '但您可重新下载小组件\n\r\n是否重新下载? \n\r\n' + changeLogText; updateAlert.addAction('重新下载'); } @@ -2544,21 +2542,6 @@ class Widget extends Base { return await this.getVehicleDetails(accessToken, forceRefresh); } - async getPublicKey() { - let req = new Request(BMW_SERVER_HOST + '/eadrax-coas/v1/cop/publickey'); - - req.headers = {}; - - const res = await req.loadJSON(); - if (res.code == 200 && res.data.value) { - console.log('Getting public key success'); - return res.data.value; - } else { - console.log('Getting public key failed'); - return ''; - } - } - async getAccessToken(forceRefresh = false) { let accessToken = ''; let refreshToken = Keychain.get(MY_BMW_REFRESH_TOKEN); @@ -2635,23 +2618,6 @@ class Widget extends Base { return null; } - async getEncryptedPassword() { - let publicKey = await this.getPublicKey(); - - try { - // 感谢沙包大佬提供思路 - let JSEncrypt = importModule(`lib/jsencrypt`); - - let encrypt = new JSEncrypt(); - encrypt.setPublicKey(publicKey); - - return encrypt.encrypt(this.userConfigData.password); - } catch (e) { - console.error('Encrypt error ' + e.message); - return null; - } - } - async refreshToken(refresh_token) { let req = new Request(BMW_SERVER_HOST + '/eadrax-coas/v1/oauth/token'); req.headers = { diff --git a/Publish/change_logs.text b/Publish/change_logs.text index 92d22ed..d50cfba 100644 --- a/Publish/change_logs.text +++ b/Publish/change_logs.text @@ -1,4 +1,3 @@ *修复 - 之前由于BMW更换新的接口,导致无法登录,现在经由BMW官方短信验证登录 - -希望BMW以后能出官方的接口方便我们第三方软件使用 +*优化 - 删除部分冗余代码 diff --git a/Publish/installer.js b/Publish/installer.js index 667760b..38a34c4 100644 --- a/Publish/installer.js +++ b/Publish/installer.js @@ -3,7 +3,7 @@ let files = FILE_MGR.listContents(FILE_MGR.documentsDirectory()); await Promise.all( ['bmw-linker.js'].map(async (js) => { - const REQ = new Request(`https://cdn.jsdelivr.net/gh/opp100/bmw-scriptable-widgets@latest/Publish/${encodeURIComponent(js)}`); + const REQ = new Request(`https://cdn.jsdelivr.net/gh/opp100/bmw-scriptable-widgets@main/Publish/${encodeURIComponent(js)}`); const RES = await REQ.load(); try { FILE_MGR.remove(FILE_MGR.joinPath(FILE_MGR.documentsDirectory(), js)); diff --git a/Publish/version.json b/Publish/version.json index 24e5a1e..5ea2c1c 100644 --- a/Publish/version.json +++ b/Publish/version.json @@ -1,5 +1,5 @@ { - "WIDGET_VERSION": "v2.2.0", - "WIDGET_BUILD": "22050701", + "WIDGET_VERSION": "v2.2.1", + "WIDGET_BUILD": "22050702", "BMW_USER_AGENT": "ios(15.4.1);bmw;2.3.0(13603)" } diff --git "a/Scripts/\343\200\214\346\272\220\347\240\201\343\200\215bmw-linker.js" "b/Scripts/\343\200\214\346\272\220\347\240\201\343\200\215bmw-linker.js" index 070697f..8ccbb06 100644 --- "a/Scripts/\343\200\214\346\272\220\347\240\201\343\200\215bmw-linker.js" +++ "b/Scripts/\343\200\214\346\272\220\347\240\201\343\200\215bmw-linker.js" @@ -13,12 +13,11 @@ const {Base} = require('./「小件件」开发环境'); // @组件代码开始 let WIDGET_FILE_NAME = 'bmw-linker.js'; -let WIDGET_VERSION = 'v2.2.0'; -let WIDGET_BUILD = '22050701'; +let WIDGET_VERSION = 'v2.2.1'; +let WIDGET_BUILD = '22050702'; let WIDGET_PREFIX = '[bmw-linker] '; let DEPENDENCIES = [ - 'jsencrypt.js' //本地化加密 ]; let WIDGET_FONT = 'SF UI Display'; @@ -117,7 +116,7 @@ class Widget extends Base { constructor(arg) { super(arg); - this.name = 'BMW-Linker'; + this.name = 'BMW-Linker ' + WIDGET_VERSION; this.desc = '宝马My BMW互联App小组件'; // load settings @@ -264,7 +263,7 @@ class Widget extends Base { userLoginAlert.title = '配置BMW登录'; userLoginAlert.message = '使用短信授权登录'; - userLoginAlert.addTextField('短信验证码', this.userConfigData['pass_code']); + userLoginAlert.addTextField('短信验证码', null); userLoginAlert.addAction('确定'); userLoginAlert.addCancelAction('取消'); @@ -274,7 +273,7 @@ class Widget extends Base { if (id == -1) { return; } - this.userConfigData['pass_code'] = userLoginAlert.textFieldValue(0); + let passCode = userLoginAlert.textFieldValue(0); let req = new Request(BMW_SERVER_HOST + `/eadrax-coas/v1/login/sms`); req.method = 'POST'; @@ -282,7 +281,7 @@ class Widget extends Base { req.body = JSON.stringify({ mobile: Number(this.userConfigData.username).toString(), otpId: otpId, - otpMsg: Number(this.userConfigData['pass_code']).toString() + otpMsg: Number(passCode).toString() }); req.headers = BMW_HEADERS; @@ -468,10 +467,10 @@ class Widget extends Base { console.warn('hasUpdate'); const updateAlert = new Alert(); updateAlert.title = '暂无更新'; + let changeLogText = await this.loadChangeLogs(); if (hasUpdate) { // load changes log - let changeLogText = await this.loadChangeLogs(); updateAlert.title = '找到更新'; updateAlert.message = changeLogText; @@ -480,7 +479,7 @@ class Widget extends Base { updateAlert.addAction('开始下载'); } else { - updateAlert.message = '但您可重新下载小组件\n\r\n是否重新下载?'; + updateAlert.message = '但您可重新下载小组件\n\r\n是否重新下载? \n\r\n' + changeLogText; updateAlert.addAction('重新下载'); } @@ -1688,21 +1687,6 @@ class Widget extends Base { return await this.getVehicleDetails(accessToken, forceRefresh); } - async getPublicKey() { - let req = new Request(BMW_SERVER_HOST + '/eadrax-coas/v1/cop/publickey'); - - req.headers = {}; - - const res = await req.loadJSON(); - if (res.code == 200 && res.data.value) { - console.log('Getting public key success'); - return res.data.value; - } else { - console.log('Getting public key failed'); - return ''; - } - } - async getAccessToken(forceRefresh = false) { let accessToken = ''; let refreshToken = Keychain.get(MY_BMW_REFRESH_TOKEN); @@ -1779,23 +1763,6 @@ class Widget extends Base { return null; } - async getEncryptedPassword() { - let publicKey = await this.getPublicKey(); - - try { - // 感谢沙包大佬提供思路 - let JSEncrypt = importModule(`lib/jsencrypt`); - - let encrypt = new JSEncrypt(); - encrypt.setPublicKey(publicKey); - - return encrypt.encrypt(this.userConfigData.password); - } catch (e) { - console.error('Encrypt error ' + e.message); - return null; - } - } - async refreshToken(refresh_token) { let req = new Request(BMW_SERVER_HOST + '/eadrax-coas/v1/oauth/token'); req.headers = {