homebridge-xbox-tv 3.1.3 → 3.1.4-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 +1 -1
- package/src/localApi/xboxlocalapi.js +21 -22
package/package.json
CHANGED
|
@@ -31,7 +31,6 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
31
31
|
this.channels = [];
|
|
32
32
|
this.channelRequestId = 0;
|
|
33
33
|
this.mediaRequestId = 0;
|
|
34
|
-
this.emitDevInfo = true;
|
|
35
34
|
this.startPrepareAccessory = true;
|
|
36
35
|
};
|
|
37
36
|
|
|
@@ -151,9 +150,10 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
151
150
|
connectRequest.set('publicKey', data.publicKey);
|
|
152
151
|
connectRequest.set('iv', data.iv);
|
|
153
152
|
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
|
|
153
|
+
const token = await this.readData(this.tokensFile);
|
|
154
|
+
const parseTokenData = JSON.parse(token);
|
|
155
|
+
const tokenData = parseTokenData.xsts.Token.length > 0 ? parseTokenData : false;
|
|
156
|
+
if (tokenData) {
|
|
157
157
|
connectRequest.set('userHash', tokenData.xsts.DisplayClaims.xui[0].uhs, true);
|
|
158
158
|
connectRequest.set('jwt', tokenData.xsts.Token, true);
|
|
159
159
|
}
|
|
@@ -246,9 +246,18 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
246
246
|
const locale = packet.payloadProtected.locale;
|
|
247
247
|
const firmwareRevision = `${majorVersion}.${minorVersion}.${buildNumber}`;
|
|
248
248
|
|
|
249
|
+
const obj = {
|
|
250
|
+
manufacturer: 'Microsoft',
|
|
251
|
+
modelName: 'Xbox',
|
|
252
|
+
serialNumber: this.xboxLiveId,
|
|
253
|
+
firmwareRevision: firmwareRevision,
|
|
254
|
+
locale: locale
|
|
255
|
+
};
|
|
256
|
+
|
|
249
257
|
//save device info to the file
|
|
250
|
-
await this.
|
|
258
|
+
await this.saveData(this.devInfoFile, obj)
|
|
251
259
|
|
|
260
|
+
//emit device info
|
|
252
261
|
this.emit('deviceInfo', firmwareRevision, locale);
|
|
253
262
|
this.emitDevInfo = false;
|
|
254
263
|
};
|
|
@@ -319,6 +328,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
319
328
|
const address = socket.address();
|
|
320
329
|
const debug = this.debugLog ? this.emit('debug', `Server start listening: ${address.address}:${address.port}.`) : false;
|
|
321
330
|
this.socket = socket;
|
|
331
|
+
this.emitDevInfo = true;
|
|
322
332
|
|
|
323
333
|
//ping console
|
|
324
334
|
setInterval(async () => {
|
|
@@ -374,29 +384,19 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
374
384
|
}
|
|
375
385
|
};
|
|
376
386
|
|
|
377
|
-
async
|
|
387
|
+
async readData(path) {
|
|
378
388
|
try {
|
|
379
|
-
const data = await fsPromises.readFile(
|
|
380
|
-
|
|
381
|
-
const tokenData = parseData.xsts.Token.length > 0 ? parseData : false;
|
|
382
|
-
return tokenData;
|
|
389
|
+
const data = await fsPromises.readFile(path);
|
|
390
|
+
return data;
|
|
383
391
|
} catch (error) {
|
|
384
392
|
throw new Error(`Read token error: ${error}`);
|
|
385
393
|
}
|
|
386
394
|
}
|
|
387
395
|
|
|
388
|
-
async
|
|
396
|
+
async saveData(path, data) {
|
|
389
397
|
try {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
modelName: 'Xbox',
|
|
393
|
-
serialNumber: this.xboxLiveId,
|
|
394
|
-
firmwareRevision: firmwareRevision,
|
|
395
|
-
locale: locale
|
|
396
|
-
};
|
|
397
|
-
const devInfo = JSON.stringify(obj, null, 2);
|
|
398
|
-
await fsPromises.writeFile(path, devInfo);
|
|
399
|
-
const debug = this.debugLog ? this.emit('debug', `Saved device info: ${devInfo}`) : false;
|
|
398
|
+
await fsPromises.writeFile(path, JSON.stringify(data, null, 2));
|
|
399
|
+
const debug = this.debugLog ? this.emit('debug', `Saved data: ${JSON.stringify(data, null, 2)}`) : false;
|
|
400
400
|
|
|
401
401
|
return true;
|
|
402
402
|
} catch (error) {
|
|
@@ -603,7 +603,6 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
603
603
|
this.channels = [];
|
|
604
604
|
this.channelRequestId = 0;
|
|
605
605
|
this.mediaRequestId = 0;
|
|
606
|
-
this.emitDevInfo = true;
|
|
607
606
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
608
607
|
this.emit('stateChanged', false, 0, true, 0, -1, -1);
|
|
609
608
|
this.emit('disconnected', 'Disconnected.');
|