homebridge-xbox-tv 3.0.2-beta.6 → 3.0.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/CHANGELOG.md CHANGED
@@ -7,7 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ### NOTE
9
9
 
10
- ## After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
10
+ ### After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
11
+ ### After update to v3.0.0 RESTFull and MQTT config settings need to be updated
12
+
13
+ ## [3.0.2] - (18.08.2024)
14
+
15
+ ## Changes
16
+
17
+ - fixed authorization manager [#204](https://github.com/grzegorz914/homebridge-xbox-tv/issues/204)
18
+ - cleanup
11
19
 
12
20
  ## [3.0.0] - (14.08.2024)
13
21
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "3.0.2-beta.6",
4
+ "version": "3.0.2",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -4,11 +4,9 @@ const Crypto = require('crypto');
4
4
  const EOL = require('os').EOL;
5
5
  const EC = require('elliptic').ec;
6
6
  const IV = Buffer.from('\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00');
7
- const EventEmitter = require('events');
8
7
 
9
- class SGCRYPTO extends EventEmitter {
8
+ class SGCRYPTO {
10
9
  constructor() {
11
- super();
12
10
  this.key = false;
13
11
  this.iv = false;
14
12
  this.hashKey = false;
@@ -61,7 +59,7 @@ class SGCRYPTO extends EventEmitter {
61
59
 
62
60
  return data;
63
61
  } catch (error) {
64
- this.emit('error', `sign public key error: ${error}`);
62
+ throw new Error(`sign public key error: ${error}`);
65
63
  };
66
64
  };
67
65
 
@@ -16,9 +16,6 @@ class XBOXLOCALAPI extends EventEmitter {
16
16
  super();
17
17
 
18
18
  this.crypto = new SGCrypto();
19
- this.crypto.on('error', (error) => {
20
- this.emit('error', error);
21
- });
22
19
 
23
20
  this.host = config.host;
24
21
  this.xboxLiveId = config.xboxLiveId;
@@ -373,7 +370,7 @@ class XBOXLOCALAPI extends EventEmitter {
373
370
  const tokenData = parseData.xsts.Token.length > 0 ? parseData : false;
374
371
  return tokenData;
375
372
  } catch (error) {
376
- this.emit('error', `Read token error: ${error}`);
373
+ throw new Error(`Read token error: ${error}`);
377
374
  }
378
375
  }
379
376
 
@@ -392,7 +389,7 @@ class XBOXLOCALAPI extends EventEmitter {
392
389
 
393
390
  return true;
394
391
  } catch (error) {
395
- this.emit('error', error);
392
+ throw new Error(error);
396
393
  };
397
394
  };
398
395
 
@@ -408,7 +405,7 @@ class XBOXLOCALAPI extends EventEmitter {
408
405
  await this.sendSocketMessage(message, 'acknowledge');
409
406
  return true;
410
407
  } catch (error) {
411
- this.emit('error', error);
408
+ throw new Error(error);
412
409
  };
413
410
  }
414
411
 
@@ -427,7 +424,7 @@ class XBOXLOCALAPI extends EventEmitter {
427
424
  await this.sendSocketMessage(message, 'channelStartRequest');
428
425
  return true;
429
426
  } catch (error) {
430
- this.emit('error', error);
427
+ throw new Error(error);
431
428
  }
432
429
  }
433
430
 
@@ -454,7 +451,7 @@ class XBOXLOCALAPI extends EventEmitter {
454
451
  this.emit('disconnected', 'Power On failed, please try again.');
455
452
  } catch (error) {
456
453
  this.emit('disconnected', 'Power On error, please try again.');
457
- this.emit('error', error);
454
+ throw new Error(error);
458
455
  };
459
456
  };
460
457
 
@@ -475,7 +472,7 @@ class XBOXLOCALAPI extends EventEmitter {
475
472
  await this.disconnect();
476
473
  return true;
477
474
  } catch (error) {
478
- this.emit('error', error);
475
+ throw new Error(error);
479
476
  };
480
477
 
481
478
  };
@@ -495,7 +492,7 @@ class XBOXLOCALAPI extends EventEmitter {
495
492
  await this.sendSocketMessage(message, 'recordGameDvr');
496
493
  return true;
497
494
  } catch (error) {
498
- this.emit('error', error);
495
+ throw new Error(error);
499
496
  };
500
497
  };
501
498
 
@@ -509,7 +506,7 @@ class XBOXLOCALAPI extends EventEmitter {
509
506
  const channelOpen = this.channels[requestId].open;
510
507
 
511
508
  if (channelCommunicationId === -1 || !channelOpen) {
512
- this.emit('error', `Channel Id: ${channelCommunicationId}, state: ${channelOpen ? 'Open' : 'Closed'}, trying to open it.`);
509
+ this.emit('error', `Channel Id: ${channelCommunicationId}, state: ${channelOpen ? 'Open' : 'Closed'}, trying to open it.`);
513
510
  };
514
511
 
515
512
  command = CONSTANTS.LocalApi.Channels.System[channelName][command];
@@ -534,7 +531,7 @@ class XBOXLOCALAPI extends EventEmitter {
534
531
  await this.sendSocketMessage(message, 'gamepadUnpress');
535
532
  }, 150)
536
533
  } catch (error) {
537
- this.emit('error', `Send system input command error: ${error}`)
534
+ this.emit('error', `Send system input command error: ${error}`)
538
535
  };
539
536
  break;
540
537
  case 1:
@@ -554,7 +551,7 @@ class XBOXLOCALAPI extends EventEmitter {
554
551
  const message = json.pack(this.crypto, sequenceNumber1, this.sourceParticipantId, channelCommunicationId);
555
552
  this.sendSocketMessage(message, 'json');
556
553
  } catch (error) {
557
- this.emit('error', `Send tv remote command error: ${error}`)
554
+ this.emit('error', `Send tv remote command error: ${error}`)
558
555
  };
559
556
  break;
560
557
  case 2:
@@ -571,7 +568,7 @@ class XBOXLOCALAPI extends EventEmitter {
571
568
  this.sendSocketMessage(message, 'mediaCommand');
572
569
  this.mediaRequestId++;
573
570
  } catch (error) {
574
- this.emit('error', `Send system media command error: ${error}`)
571
+ this.emit('error', `Send system media command error: ${error}`)
575
572
  };
576
573
  break;
577
574
  }
@@ -601,7 +598,7 @@ class XBOXLOCALAPI extends EventEmitter {
601
598
  this.emit('disconnected', 'Disconnected.');
602
599
  return true;
603
600
  } catch (error) {
604
- this.emit('error', error);
601
+ throw new Error(error);
605
602
  };
606
603
  };
607
604
 
@@ -617,7 +614,7 @@ class XBOXLOCALAPI extends EventEmitter {
617
614
 
618
615
  this.socket.send(message, offset, length, 5050, this.host, (error, bytes) => {
619
616
  if (error) {
620
- this.emit('error', error);
617
+ throw new Error(error);
621
618
  }
622
619
 
623
620
  const debug = this.debugLog ? this.emit('debug', `Socket send: ${type}, ${bytes}B.`) : false;
@@ -86,7 +86,7 @@ class XBOXWEBAPI extends EventEmitter {
86
86
  //await this.userProfile();
87
87
  return true;;
88
88
  } catch (error) {
89
- this.emit('error', `get xbox live data error: ${error}`);
89
+ throw new Error(`get xbox live data error: ${error}`);
90
90
  };
91
91
  };
92
92
 
@@ -121,7 +121,7 @@ class XBOXWEBAPI extends EventEmitter {
121
121
 
122
122
  return remoteManagementEnabled;
123
123
  } catch (error) {
124
- this.emit('error', `get status error: ${error}`);
124
+ throw new Error(`get status error: ${error}`);
125
125
  };
126
126
  }
127
127
 
@@ -201,7 +201,7 @@ class XBOXWEBAPI extends EventEmitter {
201
201
 
202
202
  return true;
203
203
  } catch (error) {
204
- this.emit('error', `Consoles list error: ${error}`);
204
+ throw new Error(`Consoles list error: ${error}`);
205
205
  };
206
206
  }
207
207
 
@@ -252,7 +252,7 @@ class XBOXWEBAPI extends EventEmitter {
252
252
 
253
253
  return true;
254
254
  } catch (error) {
255
- this.emit('error', `get installed apps error: ${error}`);
255
+ throw new Error(`get installed apps error: ${error}`);
256
256
  };
257
257
  }
258
258
 
@@ -295,7 +295,7 @@ class XBOXWEBAPI extends EventEmitter {
295
295
 
296
296
  return true;
297
297
  } catch (error) {
298
- this.emit('error', `get storage devices error: ${error}`);
298
+ throw new Error(`get storage devices error: ${error}`);
299
299
  };
300
300
  }
301
301
 
@@ -338,7 +338,7 @@ class XBOXWEBAPI extends EventEmitter {
338
338
 
339
339
  return true;
340
340
  } catch (error) {
341
- this.emit('error', `User profile error: ${error}`);
341
+ throw new Error(`User profile error: ${error}`);
342
342
  };
343
343
  }
344
344
 
@@ -362,7 +362,7 @@ class XBOXWEBAPI extends EventEmitter {
362
362
 
363
363
  return true;
364
364
  } catch (error) {
365
- this.emit('error', error);
365
+ throw new Error(error);
366
366
  }
367
367
  };
368
368
 
@@ -371,7 +371,7 @@ class XBOXWEBAPI extends EventEmitter {
371
371
  await this.send('Media', 'Next');
372
372
  return true;;
373
373
  } catch (error) {
374
- this.emit('error', error);
374
+ throw new Error(error);
375
375
  };
376
376
  }
377
377
 
@@ -380,7 +380,7 @@ class XBOXWEBAPI extends EventEmitter {
380
380
  await this.send('Media', 'Previous');
381
381
  return true;;
382
382
  } catch (error) {
383
- this.emit('error', error);
383
+ throw new Error(error);
384
384
  };
385
385
  }
386
386
 
@@ -389,7 +389,7 @@ class XBOXWEBAPI extends EventEmitter {
389
389
  await this.send('Media', 'Pause');
390
390
  return true;;
391
391
  } catch (error) {
392
- this.emit('error', error);
392
+ throw new Error(error);
393
393
  };
394
394
  }
395
395
 
@@ -398,7 +398,7 @@ class XBOXWEBAPI extends EventEmitter {
398
398
  await this.send('Media', 'Play');
399
399
  return true;;
400
400
  } catch (error) {
401
- this.emit('error', error);
401
+ throw new Error(error);
402
402
  };
403
403
  }
404
404
 
@@ -407,13 +407,13 @@ class XBOXWEBAPI extends EventEmitter {
407
407
  await this.send('Shell', 'GoBack');
408
408
  return true;;
409
409
  } catch (error) {
410
- this.emit('error', error);
410
+ throw new Error(error);
411
411
  };
412
412
  }
413
413
 
414
414
  async send(commandType, command, payload) {
415
415
  if (!this.authorized) {
416
- this.emit('error', 'not authorized.');
416
+ throw new Error('not authorized.');
417
417
  };
418
418
 
419
419
  const sessionid = UuIdv4();
@@ -440,7 +440,7 @@ class XBOXWEBAPI extends EventEmitter {
440
440
 
441
441
  return true;
442
442
  } catch (error) {
443
- this.emit('error', `send command type: ${commandType}, command: ${command}, params: ${params}, error: ${error}`);
443
+ throw new Error(`send command type: ${commandType}, command: ${command}, params: ${params}, error: ${error}`);
444
444
  };
445
445
  }
446
446
  }