homebridge-xbox-tv 2.7.4 → 2.7.5-beta.0

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.
@@ -147,14 +147,13 @@
147
147
 
148
148
  try {
149
149
  const host = document.querySelector('#deviceHostInput').value;
150
- const clientId = this.clientId !== undefined ? this.clientId : '5e5ead27-ed60-482d-b3fc-702b28a97404';
151
150
  const webApiToken = document.querySelector('#deviceTokenInput').value;
152
151
  const payload = {
153
152
  host: host,
154
- clientId: clientId,
155
- clientSecret: this.clientSecret,
156
- userToken: this.userToken,
157
- uhs: this.uhs,
153
+ clientId: this.clientId || '5e5ead27-ed60-482d-b3fc-702b28a97404',
154
+ clientSecret: this.clientSecret || '',
155
+ userToken: this.userToken || '',
156
+ uhs: this.uhs || '',
158
157
  webApiToken: webApiToken,
159
158
  };
160
159
 
@@ -213,4 +212,4 @@
213
212
  };
214
213
  });
215
214
  })();
216
- </script>
215
+ </script>
@@ -48,13 +48,14 @@ class PluginUiServer extends HomebridgePluginUiServer {
48
48
  const webApiToken = payload.webApiToken;
49
49
  const authTokenFile = `${this.homebridgeStoragePath}/xboxTv/authToken_${host.split('.').join('')}`;
50
50
 
51
- const authentication = new Authentication({
51
+ const authenticationConfig = {
52
52
  clientId: payload.clientId,
53
53
  clientSecret: payload.clientSecret,
54
54
  userToken: payload.userToken,
55
55
  uhs: payload.uhs,
56
56
  tokensFile: authTokenFile
57
- });
57
+ }
58
+ const authentication = new Authentication(authenticationConfig);
58
59
 
59
60
  try {
60
61
  await authentication.isAuthenticated();
package/index.js CHANGED
@@ -67,16 +67,6 @@ class XBOXDEVICE {
67
67
  this.host = config.host;
68
68
  this.xboxLiveId = config.xboxLiveId;
69
69
  this.webApiControl = config.webApiControl || false;
70
- this.clientId = config.clientId || '5e5ead27-ed60-482d-b3fc-702b28a97404';
71
- this.clientSecret = config.clientSecret;
72
- this.userToken = config.userToken || '';
73
- this.uhs = config.uhs || '';
74
- this.xboxWebApiToken = config.xboxWebApiToken || '';
75
- this.disableLogInfo = config.disableLogInfo || false;
76
- this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
77
- this.enableDebugMode = config.enableDebugMode || false;
78
- this.volumeControl = config.volumeControl || -1;
79
- this.infoButtonCommand = config.infoButtonCommand || 'nexus';
80
70
  this.getInputsFromDevice = config.getInputsFromDevice || false;
81
71
  this.filterGames = config.filterGames || false;
82
72
  this.filterApps = config.filterApps || false;
@@ -88,14 +78,24 @@ class XBOXDEVICE {
88
78
  this.sensorInput = config.sensorInput || false;
89
79
  this.sensorScreenSaver = config.sensorScreenSaver || false;
90
80
  this.sensorInputs = config.sensorInputs || [];
81
+ this.xboxWebApiToken = config.xboxWebApiToken || '';
82
+ this.clientId = config.clientId || '5e5ead27-ed60-482d-b3fc-702b28a97404';
83
+ this.clientSecret = config.clientSecret || '';
84
+ this.userToken = config.userToken || '';
85
+ this.uhs = config.uhs || '';
86
+ this.enableDebugMode = config.enableDebugMode || false;
87
+ this.disableLogInfo = config.disableLogInfo || false;
88
+ this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
89
+ this.infoButtonCommand = config.infoButtonCommand || 'nexus';
90
+ this.volumeControl = config.volumeControl || -1;
91
91
  this.mqttEnabled = config.enableMqtt || false;
92
+ this.mqttDebug = config.mqttDebug || false;
92
93
  this.mqttHost = config.mqttHost;
93
94
  this.mqttPort = config.mqttPort || 1883;
94
95
  this.mqttPrefix = config.mqttPrefix;
95
96
  this.mqttAuth = config.mqttAuth || false;
96
97
  this.mqttUser = config.mqttUser;
97
98
  this.mqttPasswd = config.mqttPasswd;
98
- this.mqttDebug = config.mqttDebug || false;
99
99
 
100
100
  //add configured inputs to the default inputs
101
101
  this.inputs = [...CONSTANS.DefaultInputs, ...this.inputs];
@@ -312,12 +312,10 @@ class XBOXDEVICE {
312
312
  userToken: this.userToken,
313
313
  uhs: this.uhs,
314
314
  tokensFile: this.authTokenFile,
315
- infoLog: this.disableLogInfo,
316
315
  debugLog: this.enableDebugMode
317
316
  });
318
317
 
319
318
  this.xboxWebApi.on('authenticated', (status) => {
320
-
321
319
  this.webApiEnabled = status;
322
320
  })
323
321
  .on('consoleStatus', (consoleStatusData, consoleType) => {
@@ -331,12 +329,9 @@ class XBOXDEVICE {
331
329
  //this.power = powerState;
332
330
  //this.mediaState = playbackState;
333
331
 
334
- //mqtt
335
332
  const mqtt = this.mqttEnabled ? this.mqtt.send('Status', JSON.stringify(consoleStatusData, null, 2)) : false;
336
333
  })
337
334
  .on('consolesList', (consolesList) => {
338
-
339
- //mqtt
340
335
  const mqtt = this.mqttEnabled ? this.mqtt.send('Consoles List', JSON.stringify(consolesList, null, 2)) : false;
341
336
  })
342
337
  .on('appsList', async (appsArray) => {
@@ -345,20 +340,15 @@ class XBOXDEVICE {
345
340
  await fsPromises.writeFile(this.inputsFile, apps);
346
341
  const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, saved apps: ${apps}`) : false;
347
342
 
348
- //mqtt
349
343
  const mqtt = this.mqttEnabled ? this.mqtt.send('Apps', JSON.stringify(apps, null, 2)) : false;
350
344
  } catch (error) {
351
345
  this.log.error(`Device: ${this.host} ${this.name}, save apps error: ${error}`);
352
346
  };
353
347
  })
354
348
  .on('storageDevices', (storageDevices) => {
355
-
356
- //mqtt
357
349
  const mqtt = this.mqttEnabled ? this.mqtt.send('Storages', JSON.stringify(storageDevices, null, 2)) : false;
358
350
  })
359
351
  .on('userProfile', (profileUsers) => {
360
-
361
- //mqtt
362
352
  const mqtt = this.mqttEnabled ? this.mqtt.send('Profile', JSON.stringify(profileUsers, null, 2)) : false;
363
353
  })
364
354
  .on('error', (error) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "2.7.4",
4
+ "version": "2.7.5-beta.0",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/constans.json CHANGED
@@ -19,7 +19,8 @@
19
19
  "Paused": 2,
20
20
  "Unknown": 3
21
21
  },
22
- "DefaultInputs": [{
22
+ "DefaultInputs": [
23
+ {
23
24
  "name": "Screensaver",
24
25
  "titleId": "851275400",
25
26
  "reference": "Xbox.IdleScreen_8wekyb3d8bbwe!Xbox.IdleScreen.Application",
@@ -83,7 +84,19 @@
83
84
  "contentType": "systemApp"
84
85
  }
85
86
  ],
86
- "InputSourceTypes": ["OTHER", "HOME_SCREEN", "TUNER", "HDMI", "COMPOSITE_VIDEO", "S_VIDEO", "COMPONENT_VIDEO", "DVI", "AIRPLAY", "USB", "APPLICATION"],
87
+ "InputSourceTypes": [
88
+ "OTHER",
89
+ "HOME_SCREEN",
90
+ "TUNER",
91
+ "HDMI",
92
+ "COMPOSITE_VIDEO",
93
+ "S_VIDEO",
94
+ "COMPONENT_VIDEO",
95
+ "DVI",
96
+ "AIRPLAY",
97
+ "USB",
98
+ "APPLICATION"
99
+ ],
87
100
  "SystemMediaCommands": {
88
101
  "play": 2,
89
102
  "pause": 4,
@@ -132,8 +145,19 @@
132
145
  "tvRemote": "d451e3b360bb4c71b3dbf994b1aca3a7",
133
146
  "sysConfig": "d451e3b360bb4c71b3dbf994b1aca3a7"
134
147
  },
135
- "ChannelNames": ["systemMedia", "systemInput", "tvRemote", "sysConfig"],
136
- "ConfigNames": ["GetConfiguration", "GetHeadendInfo", "GetLiveTVInfo", "GetTunerLineups", "GetAppChannelLineups"],
148
+ "ChannelNames": [
149
+ "systemMedia",
150
+ "systemInput",
151
+ "tvRemote",
152
+ "sysConfig"
153
+ ],
154
+ "ConfigNames": [
155
+ "GetConfiguration",
156
+ "GetHeadendInfo",
157
+ "GetLiveTVInfo",
158
+ "GetTunerLineups",
159
+ "GetAppChannelLineups"
160
+ ],
137
161
  "PlaybackStatus": {
138
162
  "0": "Closed",
139
163
  "1": "Changing",
@@ -161,5 +185,9 @@
161
185
  "dd00": "simple.discoveryRequest",
162
186
  "dd01": "simple.discoveryResponse",
163
187
  "dd02": "simple.powerOn"
164
- }
188
+ },
189
+ "Scopes": [
190
+ "XboxLive.signin",
191
+ "XboxLive.offline_access"
192
+ ]
165
193
  }
@@ -3,6 +3,7 @@ const QueryString = require('querystring');
3
3
  const fs = require('fs');
4
4
  const fsPromises = fs.promises;
5
5
  const HttpClient = require('./httpclient.js');
6
+ const CONSTANS = require('../constans.json');
6
7
 
7
8
  class AUTHENTICATION {
8
9
  constructor(config) {
@@ -12,7 +13,6 @@ class AUTHENTICATION {
12
13
  this.userToken = config.userToken;
13
14
  this.uhs = config.uhs;
14
15
  this.tokensFile = config.tokensFile;
15
- this.scopes = ['XboxLive.signin', 'XboxLive.offline_access'];
16
16
 
17
17
  this.user = {
18
18
  gtg: {},
@@ -142,7 +142,7 @@ class AUTHENTICATION {
142
142
  const tokenParams = {
143
143
  "client_id": this.clientId,
144
144
  "grant_type": "refresh_token",
145
- "scope": this.scopes.join(' '),
145
+ "scope": CONSTANS.Scopes.join(' '),
146
146
  "refresh_token": refreshToken,
147
147
  }
148
148
 
@@ -240,7 +240,7 @@ class AUTHENTICATION {
240
240
  const tokenParams = {
241
241
  "client_id": this.clientId,
242
242
  "grant_type": 'authorization_code',
243
- "scope": this.scopes.join(' '),
243
+ "scope": CONSTANS.Scopes.join(' '),
244
244
  "code": webApiToken,
245
245
  "redirect_uri": 'http://localhost:8581/auth/callback'
246
246
  }
@@ -271,7 +271,7 @@ class AUTHENTICATION {
271
271
  "client_id": this.clientId,
272
272
  "response_type": 'code',
273
273
  "approval_prompt": 'auto',
274
- "scope": this.scopes.join(' '),
274
+ "scope": CONSTANS.Scopes.join(' '),
275
275
  "redirect_uri": 'http://localhost:8581/auth/callback'
276
276
  }
277
277
  const params = QueryString.stringify(paramsObject);
@@ -22,14 +22,17 @@ class XBOXWEBAPI extends EventEmitter {
22
22
  super();
23
23
 
24
24
  this.xboxLiveId = config.xboxLiveId;
25
- this.infoLog = config.infoLog;
25
+ this.clientId = config.clientId;
26
+ this.clientSecret = config.clientSecret;
27
+ this.userToken = config.userToken;
28
+ this.uhs = config.uhs;
26
29
  this.debugLog = config.debugLog;
27
30
 
28
31
  const authenticationConfig = {
29
- clientId: config.clientId || '',
30
- clientSecret: config.clientSecret || '',
31
- userToken: config.userToken || '',
32
- uhs: config.uhs || '',
32
+ clientId: config.clientId,
33
+ clientSecret: config.clientSecret,
34
+ userToken: config.userToken,
35
+ uhs: config.uhs,
33
36
  tokensFile: config.tokensFile
34
37
  }
35
38
  this.authentication = new Authentication(authenticationConfig);
@@ -51,18 +54,16 @@ class XBOXWEBAPI extends EventEmitter {
51
54
  return;
52
55
  }
53
56
 
54
- this.emit('authenticated', true);
55
- this.headers = {
56
- 'Authorization': (this.authentication.userToken !== '' && this.authentication.uhs !== '') ? `XBL3.0 x=${this.authentication.uhs};${this.authentication.userToken}` : `XBL3.0 x=${this.authentication.user.uhs};${this.authentication.tokens.xsts.Token}`,
57
- 'Accept-Language': 'en-US',
58
- 'x-xbl-contract-version': '4',
59
- 'x-xbl-client-name': 'XboxApp',
60
- 'x-xbl-client-type': 'UWA',
61
- 'x-xbl-client-version': '39.39.22001.0'
62
- }
63
- this.achievements = new Achievements(this, this.headers);
64
-
65
57
  try {
58
+ this.emit('authenticated', true);
59
+ this.headers = {
60
+ 'Authorization': (this.userToken !== '' && this.uhs !== '') ? `XBL3.0 x=${this.uhs};${this.userToken}` : `XBL3.0 x=${this.authentication.user.uhs};${this.authentication.tokens.xsts.Token}`,
61
+ 'Accept-Language': 'en-US',
62
+ 'x-xbl-contract-version': '4',
63
+ 'x-xbl-client-name': 'XboxApp',
64
+ 'x-xbl-client-type': 'UWA',
65
+ 'x-xbl-client-version': '39.39.22001.0'
66
+ }
66
67
  const debug = this.debugLog ? this.emit(`message', 'authorized and web Api enabled.`) : false;
67
68
  const rmEnabled = await this.getWebApiConsoleStatus();
68
69
  const debug1 = !rmEnabled ? this.emit('message', `remote management not enabled, please check your console settings!!!.`) : false;