homebridge-xbox-tv 3.0.2-beta.0 → 3.0.2-beta.2
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
|
@@ -183,8 +183,9 @@ class Authentication extends EventEmitter{
|
|
|
183
183
|
try {
|
|
184
184
|
const tokens = await this.readTokens();
|
|
185
185
|
this.tokens = !tokens ? this.tokens : tokens;
|
|
186
|
+
const refreshToken = this.tokens.oauth.refresh_token ?? false;
|
|
186
187
|
|
|
187
|
-
if (
|
|
188
|
+
if (refreshToken) {
|
|
188
189
|
await this.refreshTokens('user');
|
|
189
190
|
await this.saveTokens(this.tokens);
|
|
190
191
|
return { headers: `XBL3.0 x=${this.tokens.xsts.DisplayClaims.xui[0].uhs};${this.tokens.xsts.Token}`, tokens: this.tokens };
|
|
@@ -192,7 +193,7 @@ class Authentication extends EventEmitter{
|
|
|
192
193
|
this.emit('error', 'No oauth token found. Use authorization manager first.')
|
|
193
194
|
}
|
|
194
195
|
} catch (error) {
|
|
195
|
-
|
|
196
|
+
throw new Error(error);
|
|
196
197
|
};
|
|
197
198
|
} else {
|
|
198
199
|
this.emit('error', `Authorization not possible, check plugin settings - Client Id: ${this.webApiClientId}`);
|
|
@@ -219,7 +220,7 @@ class Authentication extends EventEmitter{
|
|
|
219
220
|
async readTokens() {
|
|
220
221
|
try {
|
|
221
222
|
const data = await fsPromises.readFile(this.tokensFile);
|
|
222
|
-
const tokens = data.
|
|
223
|
+
const tokens = data.length > 0 ? JSON.parse(data) : false;
|
|
223
224
|
return tokens;
|
|
224
225
|
} catch (error) {
|
|
225
226
|
this.emit('error', error);
|