homebridge-lg-thinq-2 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/lib/Auth.js +2 -2
- package/dist/lib/request.js +15 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## v2.0.4
|
|
4
|
+
|
|
5
|
+
### Dependencies
|
|
6
|
+
|
|
7
|
+
* Raised the minimum axios version to 1.21.1 (was 1.16.0). axios versions before 1.16.1 send HTTPS requests to an HTTPS proxy as plain requests instead of opening a `CONNECT` tunnel, so proxies reject them (HTTP 405). With 1.21.1, requests through an `HTTPS_PROXY` work. Installs from npm already resolved to a newer axios, so this mainly guarantees the plugin never runs with an affected version.
|
|
8
|
+
* The axios update also brings patched `follow-redirects` and `form-data` versions, and lowers the dependency issues reported by `npm audit` for the published package from 12 to 9 (high: from 6 to 3). The remaining ones come from `aws-iot-device-sdk` (through `mqtt` and `glob`).
|
|
9
|
+
|
|
10
|
+
## v2.0.3
|
|
11
|
+
|
|
12
|
+
### Login
|
|
13
|
+
|
|
14
|
+
* Fixed LG account login failing with `LG pre-login failed: Request failed with status code 403`. LG's account servers now reject requests that identify as axios (the default `axios/<version>` User-Agent), so all plugin requests send a browser User-Agent unless they set their own. Requests to the ThinQ API keep their `okhttp` User-Agent. This affects login from the Homebridge UI, the `thinq` CLI, and username/password config. Based on [nVuln/homebridge-lg-thinq#400](https://github.com/nVuln/homebridge-lg-thinq/pull/400), fixing [nVuln/homebridge-lg-thinq#402](https://github.com/nVuln/homebridge-lg-thinq/issues/402).
|
|
15
|
+
* Added tests that run the login against a local server that rejects the axios User-Agent like LG does.
|
|
16
|
+
|
|
3
17
|
## v2.0.2
|
|
4
18
|
|
|
5
19
|
### Packaging and Releases
|
package/dist/lib/Auth.js
CHANGED
|
@@ -4,7 +4,7 @@ import qs from 'qs';
|
|
|
4
4
|
import { URL } from 'url';
|
|
5
5
|
import { AuthenticationError, ManualProcessNeededErrorCode, TokenError } from '../errors/index.js';
|
|
6
6
|
import * as constants from './constants.js';
|
|
7
|
-
import { requestClient } from './request.js';
|
|
7
|
+
import { BROWSER_USER_AGENT, requestClient } from './request.js';
|
|
8
8
|
import { Session } from './Session.js';
|
|
9
9
|
import { createNoopLogger } from './noopLogger.js';
|
|
10
10
|
function recordValue(value) {
|
|
@@ -152,7 +152,7 @@ export class Auth {
|
|
|
152
152
|
'Access-Control-Allow-Origin': '*',
|
|
153
153
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
154
154
|
'Accept-Language': 'en-US,en;q=0.9',
|
|
155
|
-
'User-Agent':
|
|
155
|
+
'User-Agent': BROWSER_USER_AGENT,
|
|
156
156
|
};
|
|
157
157
|
// create emp session and get access token
|
|
158
158
|
const authorize = await requestClient.get(empUrl.href, {
|
package/dist/lib/request.js
CHANGED
|
@@ -21,7 +21,21 @@ function errorWithCause(error, cause) {
|
|
|
21
21
|
error.cause = cause;
|
|
22
22
|
return error;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* User-Agent sent with every request unless the caller sets its own.
|
|
26
|
+
*
|
|
27
|
+
* LG's account servers reject requests that identify as axios (the default
|
|
28
|
+
* "axios/<version>" User-Agent) with HTTP 403, for example on POST /spx/preLogin,
|
|
29
|
+
* which made login fail. A browser User-Agent is accepted.
|
|
30
|
+
* See nVuln/homebridge-lg-thinq#402 and nVuln/homebridge-lg-thinq#400.
|
|
31
|
+
*/
|
|
32
|
+
export const BROWSER_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 '
|
|
33
|
+
+ '(KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36 Edg/93.0.961.44';
|
|
34
|
+
const client = axios.create({
|
|
35
|
+
headers: {
|
|
36
|
+
'User-Agent': BROWSER_USER_AGENT,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
25
39
|
client.defaults.timeout = 60000; // 60s timeout
|
|
26
40
|
client.interceptors.request.use((config) => {
|
|
27
41
|
return new Promise((resolve) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Homebridge LG ThinQ 2",
|
|
3
3
|
"name": "homebridge-lg-thinq-2",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.4",
|
|
5
5
|
"description": "Community-maintained continuation of homebridge-lg-thinq: a Homebridge plugin for controlling/monitoring LG ThinQ devices via the LG ThinQ platform.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@homebridge/plugin-ui-utils": "^2.2.3",
|
|
78
78
|
"aws-iot-device-sdk": "^2.2.16",
|
|
79
|
-
"axios": "^1.
|
|
79
|
+
"axios": "^1.21.1",
|
|
80
80
|
"axios-retry": "^4.5.0",
|
|
81
81
|
"commander": "^14.0.3",
|
|
82
82
|
"luxon": "^3.7.2",
|