homebridge-xbox-tv 2.8.19-beta.21 → 2.8.19-beta.23
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 +1 -1
- package/src/webApi/authentication.js +31 -37
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.
|
|
4
|
+
"version": "2.8.19-beta.23",
|
|
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.
|
|
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
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.user.
|
|
107
|
-
this.user.
|
|
108
|
-
this.user.
|
|
109
|
-
this.user.
|
|
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);
|
|
@@ -122,28 +114,28 @@ class AUTHENTICATION {
|
|
|
122
114
|
|
|
123
115
|
checkAuthorization() {
|
|
124
116
|
return new Promise(async (resolve, reject) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
117
|
+
if (fs.existsSync(this.tokensFile) && fs.readFileSync(this.tokensFile).length > 30) {
|
|
118
|
+
const tokens = fs.readFileSync(this.tokensFile).toString();
|
|
119
|
+
this.tokens = JSON.parse(tokens);
|
|
120
|
+
}
|
|
130
121
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
122
|
+
if (this.clientId) {
|
|
123
|
+
if (!this.tokens.oauth.refresh_token) {
|
|
124
|
+
reject('No oauth token found. Use authorization manager first.')
|
|
125
|
+
return;
|
|
126
|
+
};
|
|
136
127
|
|
|
128
|
+
try {
|
|
137
129
|
await this.refreshTokens('user');
|
|
138
130
|
resolve();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
reject(
|
|
146
|
-
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
reject(error);
|
|
133
|
+
};
|
|
134
|
+
} else if (this.userToken && this.userHash) {
|
|
135
|
+
resolve();
|
|
136
|
+
} else {
|
|
137
|
+
reject('Not authorized, check client id in settings.');
|
|
138
|
+
}
|
|
147
139
|
})
|
|
148
140
|
}
|
|
149
141
|
|
|
@@ -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
|
|
244
|
-
|
|
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
|
};
|