homebridge-xbox-tv 2.8.19-beta.21 → 2.8.19-beta.22

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "2.8.19-beta.21",
4
+ "version": "2.8.19-beta.22",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -74,12 +74,7 @@ class AUTHENTICATION {
74
74
  switch (tokenExpired) {
75
75
  case true:
76
76
  try {
77
- this.tokens.xsts = {};
78
- await this.saveTokens(this.tokens);
79
-
80
- const userToken = await this.getXstsToken(this.tokens.user.Token);
81
- this.tokens.xsts = userToken;
82
- await this.saveTokens(this.tokens);
77
+ await this.getXstsToken(this.tokens.user.Token);
83
78
  await this.refreshTokens('xsts');
84
79
  resolve();
85
80
  } catch (error) {
@@ -99,17 +94,14 @@ class AUTHENTICATION {
99
94
  }
100
95
  } else {
101
96
  try {
102
- const userToken = await this.getXstsToken(this.tokens.user.Token);
103
- this.tokens.xsts = userToken;
104
- await this.saveTokens(this.tokens);
105
-
106
- this.user.gtg = userToken.DisplayClaims.xui[0].gtg;
107
- this.user.xid = userToken.DisplayClaims.xui[0].xid;
108
- this.user.uhs = userToken.DisplayClaims.xui[0].uhs;
109
- this.user.usr = userToken.DisplayClaims.xui[0].usr;
110
- this.user.utr = userToken.DisplayClaims.xui[0].utr;
111
- this.user.prv = userToken.DisplayClaims.xui[0].prv;
112
- this.user.agg = userToken.DisplayClaims.xui[0].agg;
97
+ const xstsToken = await this.getXstsToken(this.tokens.user.Token);
98
+ this.user.gtg = xstsToken.DisplayClaims.xui[0].gtg;
99
+ this.user.xid = xstsToken.DisplayClaims.xui[0].xid;
100
+ this.user.uhs = xstsToken.DisplayClaims.xui[0].uhs;
101
+ this.user.usr = xstsToken.DisplayClaims.xui[0].usr;
102
+ this.user.utr = xstsToken.DisplayClaims.xui[0].utr;
103
+ this.user.prv = xstsToken.DisplayClaims.xui[0].prv;
104
+ this.user.agg = xstsToken.DisplayClaims.xui[0].agg;
113
105
  resolve();
114
106
  } catch (error) {
115
107
  reject(error);
@@ -240,8 +232,10 @@ class AUTHENTICATION {
240
232
  const postData = JSON.stringify(payload);
241
233
  const headers = { 'Content-Type': 'application/json', 'x-xbl-contract-version': '1' };
242
234
  const data = await this.httpClient.post(CONSTANS.Url.XtsxToken, headers, postData);
243
- const token = JSON.parse(data);
244
- resolve(token);
235
+ const xstsToken = JSON.parse(data);
236
+ this.tokens.xsts = xstsToken;
237
+ await this.saveTokens(this.tokens);
238
+ resolve(xstsToken);
245
239
  } catch (error) {
246
240
  reject(error);
247
241
  };