hap-nodejs 0.9.5 → 0.9.8
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/README.md +1 -1
- package/dist/BridgedCore.js +3 -3
- package/dist/BridgedCore.js.map +1 -1
- package/dist/Core.js +3 -3
- package/dist/Core.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +8 -8
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +2 -2
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +4 -4
- package/dist/accessories/gstreamer-audioProducer.js +7 -7
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/dist/lib/Accessory.d.ts +20 -3
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +114 -81
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/AccessoryLoader.js +5 -5
- package/dist/lib/AccessoryLoader.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +2 -2
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +32 -24
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.js +1 -1
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.js +48 -48
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.js +26 -26
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +29 -25
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.js +1 -1
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +2 -2
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +16 -15
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/index.js +3 -3
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +12 -12
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.js +5 -5
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/DoorbellController.js +1 -1
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.js +20 -20
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.js +5 -5
- package/dist/lib/controller/index.js.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +3 -3
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +15 -15
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +10 -10
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.js +3 -3
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +249 -249
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +75 -75
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +59 -59
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +2 -2
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.js +2 -2
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +9 -9
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.js +6 -6
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.js +1 -1
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.js +2 -2
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +2 -2
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/clone.js +4 -4
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.js +2 -2
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.js +32 -32
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +20 -7
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.js +2 -2
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.js +6 -6
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.js +1 -1
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +2 -0
- package/dist/lib/util/promise-utils.d.ts.map +1 -0
- package/dist/lib/util/promise-utils.js +10 -0
- package/dist/lib/util/promise-utils.js.map +1 -0
- package/dist/lib/util/time.js +3 -3
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.js +6 -6
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.js +1 -1
- package/dist/lib/util/uuid.js.map +1 -1
- package/package.json +16 -16
package/dist/lib/Accessory.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Accessory = exports.AccessoryEventTypes = exports.MDNSAdvertiser = exports.CharacteristicWarningType = exports.Categories = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
var crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
7
|
-
var debug_1 = tslib_1.__importDefault(require("debug"));
|
|
5
|
+
var assert_1 = (0, tslib_1.__importDefault)(require("assert"));
|
|
6
|
+
var crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
|
|
7
|
+
var debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
8
8
|
var events_1 = require("events");
|
|
9
|
-
var net_1 = tslib_1.__importDefault(require("net"));
|
|
9
|
+
var net_1 = (0, tslib_1.__importDefault)(require("net"));
|
|
10
10
|
var Advertiser_1 = require("./Advertiser");
|
|
11
11
|
// noinspection JSDeprecatedSymbols
|
|
12
12
|
var camera_1 = require("./camera");
|
|
@@ -19,9 +19,9 @@ var IdentifierCache_1 = require("./model/IdentifierCache");
|
|
|
19
19
|
var Service_1 = require("./Service");
|
|
20
20
|
var clone_1 = require("./util/clone");
|
|
21
21
|
var request_util_1 = require("./util/request-util");
|
|
22
|
-
var uuid = tslib_1.__importStar(require("./util/uuid"));
|
|
22
|
+
var uuid = (0, tslib_1.__importStar)(require("./util/uuid"));
|
|
23
23
|
var uuid_1 = require("./util/uuid");
|
|
24
|
-
var debug = debug_1.default('HAP-NodeJS:Accessory');
|
|
24
|
+
var debug = (0, debug_1.default)('HAP-NodeJS:Accessory');
|
|
25
25
|
var MAX_ACCESSORIES = 149; // Maximum number of bridged accessories per bridge.
|
|
26
26
|
var MAX_SERVICES = 100;
|
|
27
27
|
// Known category values. Category is a hint to iOS clients about what "type" of Accessory this represents, for UI only.
|
|
@@ -105,7 +105,16 @@ var AccessoryEventTypes;
|
|
|
105
105
|
* You must call the callback for identification to be successful.
|
|
106
106
|
*/
|
|
107
107
|
AccessoryEventTypes["IDENTIFY"] = "identify";
|
|
108
|
+
/**
|
|
109
|
+
* This event is emitted once the HAP TCP socket is bound.
|
|
110
|
+
* At this point the mdns advertisement isn't yet available. Use the {@link ADVERTISED} if you require the accessory to be discoverable.
|
|
111
|
+
*/
|
|
108
112
|
AccessoryEventTypes["LISTENING"] = "listening";
|
|
113
|
+
/**
|
|
114
|
+
* This event is emitted once the mDNS suite has fully advertised the presence of the accessory.
|
|
115
|
+
* This event is guaranteed to be called after {@link LISTENING}.
|
|
116
|
+
*/
|
|
117
|
+
AccessoryEventTypes["ADVERTISED"] = "advertised";
|
|
109
118
|
AccessoryEventTypes["SERVICE_CONFIGURATION_CHANGE"] = "service-configurationChange";
|
|
110
119
|
/**
|
|
111
120
|
* Emitted after a change in the value of one of the provided Service's Characteristics.
|
|
@@ -125,7 +134,7 @@ var AccessoryEventTypes;
|
|
|
125
134
|
* Accessories, Services, and Characteristics for iOS clients to reference later.
|
|
126
135
|
*/
|
|
127
136
|
var Accessory = /** @class */ (function (_super) {
|
|
128
|
-
tslib_1.__extends(Accessory, _super);
|
|
137
|
+
(0, tslib_1.__extends)(Accessory, _super);
|
|
129
138
|
function Accessory(displayName, UUID) {
|
|
130
139
|
var _this = _super.call(this) || this;
|
|
131
140
|
_this.displayName = displayName;
|
|
@@ -139,11 +148,17 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
139
148
|
_this.category = 1 /* OTHER */;
|
|
140
149
|
_this.services = [];
|
|
141
150
|
_this.shouldPurgeUnusedIDs = true; // Purge unused ids by default
|
|
151
|
+
/**
|
|
152
|
+
* Captures if initialization steps inside {@link publish} have been called.
|
|
153
|
+
* This is important when calling {@link publish} multiple times (e.g. after calling {@link unpublish}).
|
|
154
|
+
* @private Private API
|
|
155
|
+
*/
|
|
156
|
+
_this.initialized = false;
|
|
142
157
|
_this.controllers = {};
|
|
143
158
|
_this._setupID = null;
|
|
144
159
|
_this.controllerStorage = new ControllerStorage_1.ControllerStorage(_this);
|
|
145
160
|
/**
|
|
146
|
-
* This property captures the time when we last
|
|
161
|
+
* This property captures the time when we last served a /accessories request.
|
|
147
162
|
* For multiple bursts of /accessories request we don't want to always contact GET handlers
|
|
148
163
|
*/
|
|
149
164
|
_this.lastAccessoriesRequest = 0;
|
|
@@ -175,9 +190,9 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
175
190
|
//Revert back the purge mechanism state
|
|
176
191
|
_this.shouldPurgeUnusedIDs = oldValue;
|
|
177
192
|
};
|
|
178
|
-
assert_1.default(displayName, "Accessories must be created with a non-empty displayName.");
|
|
179
|
-
assert_1.default(UUID, "Accessories must be created with a valid UUID.");
|
|
180
|
-
assert_1.default(uuid.isValid(UUID), "UUID '" + UUID + "' is not a valid UUID. Try using the provided 'generateUUID' function to create a valid UUID from any arbitrary string, like a serial number.");
|
|
193
|
+
(0, assert_1.default)(displayName, "Accessories must be created with a non-empty displayName.");
|
|
194
|
+
(0, assert_1.default)(UUID, "Accessories must be created with a valid UUID.");
|
|
195
|
+
(0, assert_1.default)(uuid.isValid(UUID), "UUID '" + UUID + "' is not a valid UUID. Try using the provided 'generateUUID' function to create a valid UUID from any arbitrary string, like a serial number.");
|
|
181
196
|
// create our initial "Accessory Information" Service that all Accessories are expected to have
|
|
182
197
|
_this.addService(Service_1.Service.AccessoryInformation)
|
|
183
198
|
.setCharacteristic(Characteristic_1.Characteristic.Name, displayName);
|
|
@@ -218,7 +233,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
218
233
|
: serviceParam;
|
|
219
234
|
try {
|
|
220
235
|
// check for UUID+subtype conflict
|
|
221
|
-
for (var _b = tslib_1.__values(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
236
|
+
for (var _b = (0, tslib_1.__values)(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
222
237
|
var existing = _c.value;
|
|
223
238
|
if (existing.UUID === service.UUID) {
|
|
224
239
|
// OK we have two Services with the same UUID. Check that each defines a `subtype` property and that each is unique.
|
|
@@ -281,7 +296,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
281
296
|
Accessory.prototype.removeLinkedService = function (removed) {
|
|
282
297
|
var e_2, _a;
|
|
283
298
|
try {
|
|
284
|
-
for (var _b = tslib_1.__values(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
299
|
+
for (var _b = (0, tslib_1.__values)(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
285
300
|
var service = _c.value;
|
|
286
301
|
service.removeLinkedService(removed);
|
|
287
302
|
}
|
|
@@ -297,10 +312,11 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
297
312
|
Accessory.prototype.getService = function (name) {
|
|
298
313
|
var e_3, _a;
|
|
299
314
|
try {
|
|
300
|
-
for (var _b = tslib_1.__values(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
315
|
+
for (var _b = (0, tslib_1.__values)(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
301
316
|
var service = _c.value;
|
|
302
317
|
if (typeof name === 'string' && (service.displayName === name || service.name === name || service.subtype === name)) {
|
|
303
318
|
return service;
|
|
319
|
+
// @ts-expect-error
|
|
304
320
|
}
|
|
305
321
|
else if (typeof name === 'function' && ((service instanceof name) || (name.UUID === service.UUID))) {
|
|
306
322
|
return service;
|
|
@@ -319,10 +335,11 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
319
335
|
Accessory.prototype.getServiceById = function (uuid, subType) {
|
|
320
336
|
var e_4, _a;
|
|
321
337
|
try {
|
|
322
|
-
for (var _b = tslib_1.__values(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
338
|
+
for (var _b = (0, tslib_1.__values)(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
323
339
|
var service = _c.value;
|
|
324
340
|
if (typeof uuid === "string" && (service.displayName === uuid || service.name === uuid) && service.subtype === subType) {
|
|
325
341
|
return service;
|
|
342
|
+
// @ts-expect-error
|
|
326
343
|
}
|
|
327
344
|
else if (typeof uuid === "function" && ((service instanceof uuid) || (uuid.UUID === service.UUID)) && service.subtype === subType) {
|
|
328
345
|
return service;
|
|
@@ -356,7 +373,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
356
373
|
}
|
|
357
374
|
try {
|
|
358
375
|
// check for UUID conflict
|
|
359
|
-
for (var _b = tslib_1.__values(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
376
|
+
for (var _b = (0, tslib_1.__values)(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
360
377
|
var existing = _c.value;
|
|
361
378
|
if (existing.UUID === accessory.UUID) {
|
|
362
379
|
throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);
|
|
@@ -389,7 +406,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
389
406
|
Accessory.prototype.addBridgedAccessories = function (accessories) {
|
|
390
407
|
var e_6, _a;
|
|
391
408
|
try {
|
|
392
|
-
for (var accessories_1 = tslib_1.__values(accessories), accessories_1_1 = accessories_1.next(); !accessories_1_1.done; accessories_1_1 = accessories_1.next()) {
|
|
409
|
+
for (var accessories_1 = (0, tslib_1.__values)(accessories), accessories_1_1 = accessories_1.next(); !accessories_1_1.done; accessories_1_1 = accessories_1.next()) {
|
|
393
410
|
var accessory = accessories_1_1.value;
|
|
394
411
|
this.addBridgedAccessory(accessory, true);
|
|
395
412
|
}
|
|
@@ -421,7 +438,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
421
438
|
Accessory.prototype.removeBridgedAccessories = function (accessories) {
|
|
422
439
|
var e_7, _a;
|
|
423
440
|
try {
|
|
424
|
-
for (var accessories_2 = tslib_1.__values(accessories), accessories_2_1 = accessories_2.next(); !accessories_2_1.done; accessories_2_1 = accessories_2.next()) {
|
|
441
|
+
for (var accessories_2 = (0, tslib_1.__values)(accessories), accessories_2_1 = accessories_2.next(); !accessories_2_1.done; accessories_2_1 = accessories_2.next()) {
|
|
425
442
|
var accessory = accessories_2_1.value;
|
|
426
443
|
this.removeBridgedAccessory(accessory, true);
|
|
427
444
|
}
|
|
@@ -444,7 +461,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
444
461
|
Accessory.prototype.getCharacteristicByIID = function (iid) {
|
|
445
462
|
var e_8, _a;
|
|
446
463
|
try {
|
|
447
|
-
for (var _b = tslib_1.__values(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
464
|
+
for (var _b = (0, tslib_1.__values)(this.services), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
448
465
|
var service = _c.value;
|
|
449
466
|
var characteristic = service.getCharacteristicByIID(iid);
|
|
450
467
|
if (characteristic) {
|
|
@@ -466,7 +483,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
466
483
|
return this;
|
|
467
484
|
}
|
|
468
485
|
try {
|
|
469
|
-
for (var _b = tslib_1.__values(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
486
|
+
for (var _b = (0, tslib_1.__values)(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
470
487
|
var accessory = _c.value;
|
|
471
488
|
if (accessory.aid === aid) {
|
|
472
489
|
return accessory;
|
|
@@ -563,7 +580,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
563
580
|
var savedServiceMap = this.serializedControllers && this.serializedControllers[id];
|
|
564
581
|
var serviceMap;
|
|
565
582
|
if (savedServiceMap) { // we found data to restore from
|
|
566
|
-
var clonedServiceMap = clone_1.clone(savedServiceMap);
|
|
583
|
+
var clonedServiceMap = (0, clone_1.clone)(savedServiceMap);
|
|
567
584
|
var updatedServiceMap = controller.initWithServices(savedServiceMap); // init controller with existing services
|
|
568
585
|
serviceMap = updatedServiceMap || savedServiceMap; // initWithServices could return a updated serviceMap, otherwise just use the existing one
|
|
569
586
|
if (updatedServiceMap) { // controller returned a ServiceMap and thus signaled a updated set of services
|
|
@@ -591,7 +608,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
591
608
|
controller: controller,
|
|
592
609
|
serviceMap: serviceMap,
|
|
593
610
|
};
|
|
594
|
-
if (controller_1.isSerializableController(controller)) {
|
|
611
|
+
if ((0, controller_1.isSerializableController)(controller)) {
|
|
595
612
|
this.controllerStorage.trackController(controller);
|
|
596
613
|
}
|
|
597
614
|
this.controllers[id] = context;
|
|
@@ -614,7 +631,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
614
631
|
if (storedController.controller !== controller) {
|
|
615
632
|
throw new Error("[" + this.displayName + "] tried removing a controller with the id/type '" + id + "' though provided controller isn't the same which is registered!");
|
|
616
633
|
}
|
|
617
|
-
if (controller_1.isSerializableController(controller)) {
|
|
634
|
+
if ((0, controller_1.isSerializableController)(controller)) {
|
|
618
635
|
// this will reset the state change delegate before we call handleControllerRemoved()
|
|
619
636
|
this.controllerStorage.untrackController(controller);
|
|
620
637
|
}
|
|
@@ -639,13 +656,13 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
639
656
|
Accessory.prototype.handleAccessoryUnpairedForControllers = function () {
|
|
640
657
|
var e_10, _a;
|
|
641
658
|
try {
|
|
642
|
-
for (var _b = tslib_1.__values(Object.values(this.controllers)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
659
|
+
for (var _b = (0, tslib_1.__values)(Object.values(this.controllers)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
643
660
|
var context = _c.value;
|
|
644
661
|
var controller = context.controller;
|
|
645
662
|
if (controller.handleFactoryReset) { // if the controller implements handleFactoryReset, setup event handlers for this controller
|
|
646
663
|
controller.handleFactoryReset();
|
|
647
664
|
}
|
|
648
|
-
if (controller_1.isSerializableController(controller)) {
|
|
665
|
+
if ((0, controller_1.isSerializableController)(controller)) {
|
|
649
666
|
this.controllerStorage.purgeControllerData(controller);
|
|
650
667
|
}
|
|
651
668
|
}
|
|
@@ -660,7 +677,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
660
677
|
};
|
|
661
678
|
Accessory.prototype.handleUpdatedControllerServiceMap = function (originalServiceMap, updatedServiceMap) {
|
|
662
679
|
var _this = this;
|
|
663
|
-
updatedServiceMap = clone_1.clone(updatedServiceMap); // clone it so we can alter it
|
|
680
|
+
updatedServiceMap = (0, clone_1.clone)(updatedServiceMap); // clone it so we can alter it
|
|
664
681
|
Object.keys(originalServiceMap).forEach(function (name) {
|
|
665
682
|
var service = originalServiceMap[name];
|
|
666
683
|
var updatedService = updatedServiceMap[name];
|
|
@@ -739,7 +756,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
739
756
|
}
|
|
740
757
|
if (mainAccessory) {
|
|
741
758
|
// the main accessory which is advertised via bonjour must have a name with length <= 63 (limitation of DNS FQDN names)
|
|
742
|
-
assert_1.default(Buffer.from(this.displayName, "utf8").length <= 63, "Accessory displayName cannot be longer than 63 bytes!");
|
|
759
|
+
(0, assert_1.default)(Buffer.from(this.displayName, "utf8").length <= 63, "Accessory displayName cannot be longer than 63 bytes!");
|
|
743
760
|
}
|
|
744
761
|
if (this.bridged) {
|
|
745
762
|
this.bridgedAccessories.forEach(function (accessory) { return accessory.validateAccessory(); });
|
|
@@ -767,7 +784,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
767
784
|
this.aid = 1;
|
|
768
785
|
}
|
|
769
786
|
try {
|
|
770
|
-
for (var _c = tslib_1.__values(this.services), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
787
|
+
for (var _c = (0, tslib_1.__values)(this.services), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
771
788
|
var service = _d.value;
|
|
772
789
|
if (this._isBridge) {
|
|
773
790
|
service._assignIDs(identifierCache, this.UUID, 2000000000);
|
|
@@ -786,7 +803,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
786
803
|
}
|
|
787
804
|
try {
|
|
788
805
|
// now assign IDs for any Accessories we are bridging
|
|
789
|
-
for (var _e = tslib_1.__values(this.bridgedAccessories), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
806
|
+
for (var _e = (0, tslib_1.__values)(this.bridgedAccessories), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
790
807
|
var accessory = _f.value;
|
|
791
808
|
accessory._assignIDs(identifierCache);
|
|
792
809
|
}
|
|
@@ -813,14 +830,14 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
813
830
|
*/
|
|
814
831
|
Accessory.prototype.toHAP = function (connection, contactGetHandlers) {
|
|
815
832
|
if (contactGetHandlers === void 0) { contactGetHandlers = true; }
|
|
816
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
833
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
817
834
|
var accessory, accessories, _a, _b, _c, _d;
|
|
818
835
|
var _e;
|
|
819
|
-
return tslib_1.__generator(this, function (_f) {
|
|
836
|
+
return (0, tslib_1.__generator)(this, function (_f) {
|
|
820
837
|
switch (_f.label) {
|
|
821
838
|
case 0:
|
|
822
|
-
assert_1.default(this.aid, "aid cannot be undefined for accessory '" + this.displayName + "'");
|
|
823
|
-
assert_1.default(this.services.length, "accessory '" + this.displayName + "' does not have any services!");
|
|
839
|
+
(0, assert_1.default)(this.aid, "aid cannot be undefined for accessory '" + this.displayName + "'");
|
|
840
|
+
(0, assert_1.default)(this.services.length, "accessory '" + this.displayName + "' does not have any services!");
|
|
824
841
|
_e = {
|
|
825
842
|
aid: this.aid
|
|
826
843
|
};
|
|
@@ -836,7 +853,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
836
853
|
return [4 /*yield*/, Promise.all(this.bridgedAccessories
|
|
837
854
|
.map(function (accessory) { return accessory.toHAP(connection, contactGetHandlers).then(function (value) { return value[0]; }); }))];
|
|
838
855
|
case 2:
|
|
839
|
-
_b.apply(_a, _c.concat([tslib_1.__spreadArray.apply(void 0, _d.concat([tslib_1.__read.apply(void 0, [_f.sent()])]))]));
|
|
856
|
+
_b.apply(_a, _c.concat([tslib_1.__spreadArray.apply(void 0, _d.concat([tslib_1.__read.apply(void 0, [_f.sent()]), false]))]));
|
|
840
857
|
_f.label = 3;
|
|
841
858
|
case 3: return [2 /*return*/, accessories];
|
|
842
859
|
}
|
|
@@ -852,8 +869,8 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
852
869
|
if (assignIds) {
|
|
853
870
|
this._assignIDs(this._identifierCache); // make sure our aid/iid's are all assigned
|
|
854
871
|
}
|
|
855
|
-
assert_1.default(this.aid, "aid cannot be undefined for accessory '" + this.displayName + "'");
|
|
856
|
-
assert_1.default(this.services.length, "accessory '" + this.displayName + "' does not have any services!");
|
|
872
|
+
(0, assert_1.default)(this.aid, "aid cannot be undefined for accessory '" + this.displayName + "'");
|
|
873
|
+
(0, assert_1.default)(this.services.length, "accessory '" + this.displayName + "' does not have any services!");
|
|
857
874
|
var accessory = {
|
|
858
875
|
aid: this.aid,
|
|
859
876
|
services: this.services.map(function (service) { return service.internalHAPRepresentation(); }),
|
|
@@ -861,7 +878,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
861
878
|
var accessories = [accessory];
|
|
862
879
|
if (!this.bridged) {
|
|
863
880
|
try {
|
|
864
|
-
for (var _b = tslib_1.__values(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
881
|
+
for (var _b = (0, tslib_1.__values)(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
865
882
|
var accessory_1 = _c.value;
|
|
866
883
|
accessories.push(accessory_1.internalHAPRepresentation(false)[0]);
|
|
867
884
|
}
|
|
@@ -913,8 +930,8 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
913
930
|
if (this.lastKnownUsername && this.lastKnownUsername !== info.username) { // username changed since last publish
|
|
914
931
|
Accessory.cleanupAccessoryData(this.lastKnownUsername); // delete old Accessory data
|
|
915
932
|
}
|
|
916
|
-
if ((_a = info.addIdentifyingMaterial) !== null && _a !== void 0 ? _a : true) {
|
|
917
|
-
// adding some identifying material to our displayName
|
|
933
|
+
if (!this.initialized && ((_a = info.addIdentifyingMaterial) !== null && _a !== void 0 ? _a : true)) {
|
|
934
|
+
// adding some identifying material to our displayName if its our first publish() call
|
|
918
935
|
this.displayName = this.displayName + " " + crypto_1.default.createHash('sha512')
|
|
919
936
|
.update(info.username, 'utf8')
|
|
920
937
|
.digest('hex').slice(0, 4).toUpperCase();
|
|
@@ -958,7 +975,9 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
958
975
|
this.disableUnusedIDPurge();
|
|
959
976
|
this.controllerStorage.purgeUnidentifiedAccessoryData = false;
|
|
960
977
|
}
|
|
961
|
-
this.
|
|
978
|
+
if (!this.initialized) { // controller storage is only loaded from disk the first time we publish!
|
|
979
|
+
this.controllerStorage.load(info.username); // initializing controller data
|
|
980
|
+
}
|
|
962
981
|
// assign aid/iid
|
|
963
982
|
this._assignIDs(this._identifierCache);
|
|
964
983
|
// get our accessory information in HAP format and determine if our configuration (that is, our
|
|
@@ -1015,6 +1034,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1015
1034
|
this._server.on("connection-closed" /* CONNECTION_CLOSED */, this.handleHAPConnectionClosed.bind(this));
|
|
1016
1035
|
this._server.on("request-resource" /* REQUEST_RESOURCE */, this.handleResource.bind(this));
|
|
1017
1036
|
this._server.listen(info.port, parsed.serverAddress);
|
|
1037
|
+
this.initialized = true;
|
|
1018
1038
|
};
|
|
1019
1039
|
/**
|
|
1020
1040
|
* Removes this Accessory from the local network
|
|
@@ -1022,7 +1042,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1022
1042
|
* Trying to invoke publish() on the object will result undefined behavior
|
|
1023
1043
|
*/
|
|
1024
1044
|
Accessory.prototype.destroy = function () {
|
|
1025
|
-
this.unpublish();
|
|
1045
|
+
var promise = this.unpublish();
|
|
1026
1046
|
if (this._accessoryInfo) {
|
|
1027
1047
|
Accessory.cleanupAccessoryData(this._accessoryInfo.username);
|
|
1028
1048
|
this._accessoryInfo = undefined;
|
|
@@ -1030,17 +1050,29 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1030
1050
|
this.controllerStorage = new ControllerStorage_1.ControllerStorage(this);
|
|
1031
1051
|
}
|
|
1032
1052
|
this.removeAllListeners();
|
|
1053
|
+
return promise;
|
|
1033
1054
|
};
|
|
1034
1055
|
Accessory.prototype.unpublish = function () {
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1056
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1057
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1058
|
+
switch (_a.label) {
|
|
1059
|
+
case 0:
|
|
1060
|
+
if (this._server) {
|
|
1061
|
+
this._server.destroy();
|
|
1062
|
+
this._server = undefined;
|
|
1063
|
+
}
|
|
1064
|
+
if (!this._advertiser) return [3 /*break*/, 2];
|
|
1065
|
+
// noinspection JSIgnoredPromiseFromCall
|
|
1066
|
+
return [4 /*yield*/, this._advertiser.destroy()];
|
|
1067
|
+
case 1:
|
|
1068
|
+
// noinspection JSIgnoredPromiseFromCall
|
|
1069
|
+
_a.sent();
|
|
1070
|
+
this._advertiser = undefined;
|
|
1071
|
+
_a.label = 2;
|
|
1072
|
+
case 2: return [2 /*return*/];
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
});
|
|
1044
1076
|
};
|
|
1045
1077
|
Accessory.prototype.enqueueConfigurationUpdate = function () {
|
|
1046
1078
|
var _this = this;
|
|
@@ -1066,11 +1098,12 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1066
1098
|
// not responding or new accessories/services not yet shown
|
|
1067
1099
|
};
|
|
1068
1100
|
Accessory.prototype.onListening = function (port, hostname) {
|
|
1069
|
-
|
|
1101
|
+
var _this = this;
|
|
1102
|
+
(0, assert_1.default)(this._advertiser, "Advertiser wasn't created at onListening!");
|
|
1070
1103
|
// the HAP server is listening, so we can now start advertising our presence.
|
|
1071
1104
|
this._advertiser.initPort(port);
|
|
1072
|
-
|
|
1073
|
-
|
|
1105
|
+
this._advertiser.startAdvertising()
|
|
1106
|
+
.then(function () { return _this.emit("advertised" /* ADVERTISED */); });
|
|
1074
1107
|
this.emit("listening" /* LISTENING */, port, hostname);
|
|
1075
1108
|
};
|
|
1076
1109
|
Accessory.prototype.handleInitialPairSetupFinished = function (username, publicKey, callback) {
|
|
@@ -1124,7 +1157,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1124
1157
|
this.emit("unpaired" /* UNPAIRED */);
|
|
1125
1158
|
this.handleAccessoryUnpairedForControllers();
|
|
1126
1159
|
try {
|
|
1127
|
-
for (var _b = tslib_1.__values(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1160
|
+
for (var _b = (0, tslib_1.__values)(this.bridgedAccessories), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1128
1161
|
var accessory = _c.value;
|
|
1129
1162
|
accessory.handleAccessoryUnpairedForControllers();
|
|
1130
1163
|
}
|
|
@@ -1178,7 +1211,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1178
1211
|
var timeout = setTimeout(function () {
|
|
1179
1212
|
var e_16, _a;
|
|
1180
1213
|
try {
|
|
1181
|
-
for (var missingCharacteristics_1 = tslib_1.__values(missingCharacteristics), missingCharacteristics_1_1 = missingCharacteristics_1.next(); !missingCharacteristics_1_1.done; missingCharacteristics_1_1 = missingCharacteristics_1.next()) {
|
|
1214
|
+
for (var missingCharacteristics_1 = (0, tslib_1.__values)(missingCharacteristics), missingCharacteristics_1_1 = missingCharacteristics_1.next(); !missingCharacteristics_1_1.done; missingCharacteristics_1_1 = missingCharacteristics_1.next()) {
|
|
1182
1215
|
var id = missingCharacteristics_1_1.value;
|
|
1183
1216
|
var split = id.split(".");
|
|
1184
1217
|
var aid = parseInt(split[0], 10);
|
|
@@ -1201,7 +1234,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1201
1234
|
var e_17, _a;
|
|
1202
1235
|
timeout = undefined;
|
|
1203
1236
|
try {
|
|
1204
|
-
for (var missingCharacteristics_2 = tslib_1.__values(missingCharacteristics), missingCharacteristics_2_1 = missingCharacteristics_2.next(); !missingCharacteristics_2_1.done; missingCharacteristics_2_1 = missingCharacteristics_2.next()) {
|
|
1237
|
+
for (var missingCharacteristics_2 = (0, tslib_1.__values)(missingCharacteristics), missingCharacteristics_2_1 = missingCharacteristics_2.next(); !missingCharacteristics_2_1.done; missingCharacteristics_2_1 = missingCharacteristics_2.next()) {
|
|
1205
1238
|
var id = missingCharacteristics_2_1.value;
|
|
1206
1239
|
var split = id.split(".");
|
|
1207
1240
|
var aid = parseInt(split[0], 10);
|
|
@@ -1233,7 +1266,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1233
1266
|
var _loop_1 = function (id) {
|
|
1234
1267
|
var name = id.aid + "." + id.iid;
|
|
1235
1268
|
this_1.handleCharacteristicRead(connection, id, request).then(function (value) {
|
|
1236
|
-
return tslib_1.__assign({ aid: id.aid, iid: id.iid }, value);
|
|
1269
|
+
return (0, tslib_1.__assign)({ aid: id.aid, iid: id.iid }, value);
|
|
1237
1270
|
}, function (reason) {
|
|
1238
1271
|
console.error("[" + _this.displayName + "] Read request for characteristic " + name + " encountered an error: " + reason.stack);
|
|
1239
1272
|
return {
|
|
@@ -1258,7 +1291,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1258
1291
|
};
|
|
1259
1292
|
var this_1 = this;
|
|
1260
1293
|
try {
|
|
1261
|
-
for (var _b = tslib_1.__values(request.ids), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1294
|
+
for (var _b = (0, tslib_1.__values)(request.ids), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1262
1295
|
var id = _c.value;
|
|
1263
1296
|
_loop_1(id);
|
|
1264
1297
|
}
|
|
@@ -1272,10 +1305,10 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1272
1305
|
}
|
|
1273
1306
|
};
|
|
1274
1307
|
Accessory.prototype.handleCharacteristicRead = function (connection, id, request) {
|
|
1275
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1308
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1276
1309
|
var characteristic, verifiable;
|
|
1277
1310
|
var _this = this;
|
|
1278
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1311
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1279
1312
|
characteristic = this.findCharacteristic(id.aid, id.iid);
|
|
1280
1313
|
if (!characteristic) {
|
|
1281
1314
|
debug('[%s] Could not find a Characteristic with aid of %s and iid of %s', this.displayName, id.aid, id.iid);
|
|
@@ -1296,7 +1329,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1296
1329
|
}
|
|
1297
1330
|
}
|
|
1298
1331
|
return [2 /*return*/, characteristic.handleGetRequest(connection).then(function (value) {
|
|
1299
|
-
value = request_util_1.formatOutgoingCharacteristicValue(value, characteristic.props);
|
|
1332
|
+
value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, characteristic.props);
|
|
1300
1333
|
debug('[%s] Got Characteristic "%s" value: "%s"', _this.displayName, characteristic.displayName, value);
|
|
1301
1334
|
var data = {
|
|
1302
1335
|
value: value == undefined ? null : value,
|
|
@@ -1313,7 +1346,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1313
1346
|
data.perms = characteristic.props.perms;
|
|
1314
1347
|
}
|
|
1315
1348
|
if (request.includeType) {
|
|
1316
|
-
data.type = uuid_1.toShortForm(_this.UUID);
|
|
1349
|
+
data.type = (0, uuid_1.toShortForm)(_this.UUID);
|
|
1317
1350
|
}
|
|
1318
1351
|
if (request.includeEvent) {
|
|
1319
1352
|
data.ev = connection.hasEventNotifications(id.aid, id.iid);
|
|
@@ -1357,7 +1390,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1357
1390
|
var timeout = setTimeout(function () {
|
|
1358
1391
|
var e_19, _a;
|
|
1359
1392
|
try {
|
|
1360
|
-
for (var missingCharacteristics_3 = tslib_1.__values(missingCharacteristics), missingCharacteristics_3_1 = missingCharacteristics_3.next(); !missingCharacteristics_3_1.done; missingCharacteristics_3_1 = missingCharacteristics_3.next()) {
|
|
1393
|
+
for (var missingCharacteristics_3 = (0, tslib_1.__values)(missingCharacteristics), missingCharacteristics_3_1 = missingCharacteristics_3.next(); !missingCharacteristics_3_1.done; missingCharacteristics_3_1 = missingCharacteristics_3.next()) {
|
|
1361
1394
|
var id = missingCharacteristics_3_1.value;
|
|
1362
1395
|
var split = id.split(".");
|
|
1363
1396
|
var aid = parseInt(split[0], 10);
|
|
@@ -1380,7 +1413,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1380
1413
|
var e_20, _a;
|
|
1381
1414
|
timeout = undefined;
|
|
1382
1415
|
try {
|
|
1383
|
-
for (var missingCharacteristics_4 = tslib_1.__values(missingCharacteristics), missingCharacteristics_4_1 = missingCharacteristics_4.next(); !missingCharacteristics_4_1.done; missingCharacteristics_4_1 = missingCharacteristics_4.next()) {
|
|
1416
|
+
for (var missingCharacteristics_4 = (0, tslib_1.__values)(missingCharacteristics), missingCharacteristics_4_1 = missingCharacteristics_4.next(); !missingCharacteristics_4_1.done; missingCharacteristics_4_1 = missingCharacteristics_4.next()) {
|
|
1384
1417
|
var id = missingCharacteristics_4_1.value;
|
|
1385
1418
|
var split = id.split(".");
|
|
1386
1419
|
var aid = parseInt(split[0], 10);
|
|
@@ -1412,7 +1445,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1412
1445
|
var _loop_2 = function (data) {
|
|
1413
1446
|
var name = data.aid + "." + data.iid;
|
|
1414
1447
|
this_2.handleCharacteristicWrite(connection, data, writeState).then(function (value) {
|
|
1415
|
-
return tslib_1.__assign({ aid: data.aid, iid: data.iid }, value);
|
|
1448
|
+
return (0, tslib_1.__assign)({ aid: data.aid, iid: data.iid }, value);
|
|
1416
1449
|
}, function (reason) {
|
|
1417
1450
|
console.error("[" + _this.displayName + "] Write request for characteristic " + name + " encountered an error: " + reason.stack);
|
|
1418
1451
|
return {
|
|
@@ -1437,7 +1470,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1437
1470
|
};
|
|
1438
1471
|
var this_2 = this;
|
|
1439
1472
|
try {
|
|
1440
|
-
for (var _b = tslib_1.__values(writeRequest.characteristics), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1473
|
+
for (var _b = (0, tslib_1.__values)(writeRequest.characteristics), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1441
1474
|
var data = _c.value;
|
|
1442
1475
|
_loop_2(data);
|
|
1443
1476
|
}
|
|
@@ -1451,10 +1484,10 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1451
1484
|
}
|
|
1452
1485
|
};
|
|
1453
1486
|
Accessory.prototype.handleCharacteristicWrite = function (connection, data, writeState) {
|
|
1454
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1487
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1455
1488
|
var characteristic, evResponse, notificationsEnabled, verifiable, verifiable, allowWrite;
|
|
1456
1489
|
var _this = this;
|
|
1457
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1490
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1458
1491
|
characteristic = this.findCharacteristic(data.aid, data.iid);
|
|
1459
1492
|
evResponse = undefined;
|
|
1460
1493
|
if (!characteristic) {
|
|
@@ -1520,7 +1553,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1520
1553
|
allowWrite = characteristic.additionalAuthorizationHandler(data.authData);
|
|
1521
1554
|
}
|
|
1522
1555
|
catch (error) {
|
|
1523
|
-
console.
|
|
1556
|
+
console.warn("[" + this.displayName + "] Additional authorization handler has thrown an error when checking authData: " + error.stack);
|
|
1524
1557
|
allowWrite = false;
|
|
1525
1558
|
}
|
|
1526
1559
|
if (!allowWrite) {
|
|
@@ -1534,7 +1567,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1534
1567
|
return [2 /*return*/, characteristic.handleSetRequest(data.value, connection).then(function (value) {
|
|
1535
1568
|
debug('[%s] Setting Characteristic "%s" to value %s', _this.displayName, characteristic.displayName, data.value);
|
|
1536
1569
|
return {
|
|
1537
|
-
value: data.r && value ? request_util_1.formatOutgoingCharacteristicValue(value, characteristic.props) : undefined,
|
|
1570
|
+
value: data.r && value ? (0, request_util_1.formatOutgoingCharacteristicValue)(value, characteristic.props) : undefined,
|
|
1538
1571
|
ev: evResponse,
|
|
1539
1572
|
};
|
|
1540
1573
|
}, function (status) {
|
|
@@ -1587,7 +1620,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1587
1620
|
this.activeCameraController.handleCloseConnection(connection.sessionID);
|
|
1588
1621
|
}
|
|
1589
1622
|
try {
|
|
1590
|
-
for (var _b = tslib_1.__values(connection.getRegisteredEvents()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1623
|
+
for (var _b = (0, tslib_1.__values)(connection.getRegisteredEvents()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1591
1624
|
var event = _c.value;
|
|
1592
1625
|
var ids = event.split(".");
|
|
1593
1626
|
var aid = parseInt(ids[0], 10);
|
|
@@ -1628,7 +1661,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1628
1661
|
};
|
|
1629
1662
|
Accessory.prototype.handleCharacteristicChangeEvent = function (accessory, service, change) {
|
|
1630
1663
|
if (this.bridged) { // forward this to our main accessory
|
|
1631
|
-
this.emit("service-characteristic-change" /* SERVICE_CHARACTERISTIC_CHANGE */, tslib_1.__assign(tslib_1.__assign({}, change), { service: service }));
|
|
1664
|
+
this.emit("service-characteristic-change" /* SERVICE_CHARACTERISTIC_CHANGE */, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, change), { service: service }));
|
|
1632
1665
|
}
|
|
1633
1666
|
else {
|
|
1634
1667
|
if (!this._server) {
|
|
@@ -1654,7 +1687,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1654
1687
|
var uuid_2 = change.characteristic.UUID;
|
|
1655
1688
|
var immediateDelivery = uuid_2 === Characteristic_1.Characteristic.ButtonEvent.UUID || uuid_2 === Characteristic_1.Characteristic.ProgrammableSwitchEvent.UUID
|
|
1656
1689
|
|| uuid_2 === Characteristic_1.Characteristic.MotionDetected.UUID || uuid_2 === Characteristic_1.Characteristic.ContactSensorState.UUID;
|
|
1657
|
-
var value = request_util_1.formatOutgoingCharacteristicValue(change.newValue, change.characteristic.props);
|
|
1690
|
+
var value = (0, request_util_1.formatOutgoingCharacteristicValue)(change.newValue, change.characteristic.props);
|
|
1658
1691
|
this._server.sendEventNotifications(accessory.aid, change.characteristic.iid, value, change.originator, immediateDelivery);
|
|
1659
1692
|
}
|
|
1660
1693
|
};
|
|
@@ -1669,7 +1702,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1669
1702
|
};
|
|
1670
1703
|
Accessory.prototype.handleCharacteristicWarning = function (warning) {
|
|
1671
1704
|
var _a;
|
|
1672
|
-
warning.originatorChain = tslib_1.__spreadArray([this.displayName], tslib_1.__read(warning.originatorChain));
|
|
1705
|
+
warning.originatorChain = (0, tslib_1.__spreadArray)([this.displayName], (0, tslib_1.__read)(warning.originatorChain), false);
|
|
1673
1706
|
var emitted = this.emit("characteristic-warning" /* CHARACTERISTIC_WARNING */, warning);
|
|
1674
1707
|
if (!emitted) {
|
|
1675
1708
|
var message = "[" + warning.originatorChain.join("@") + "] " + warning.message;
|
|
@@ -1692,7 +1725,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1692
1725
|
var e_22, _a;
|
|
1693
1726
|
var _this = this;
|
|
1694
1727
|
try {
|
|
1695
|
-
for (var targetServices_1 = tslib_1.__values(targetServices), targetServices_1_1 = targetServices_1.next(); !targetServices_1_1.done; targetServices_1_1 = targetServices_1.next()) {
|
|
1728
|
+
for (var targetServices_1 = (0, tslib_1.__values)(targetServices), targetServices_1_1 = targetServices_1.next(); !targetServices_1_1.done; targetServices_1_1 = targetServices_1.next()) {
|
|
1696
1729
|
var service = targetServices_1_1.value;
|
|
1697
1730
|
this.setupServiceEventHandlers(service);
|
|
1698
1731
|
}
|
|
@@ -1761,7 +1794,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1761
1794
|
});
|
|
1762
1795
|
// also save controller which didn't get initialized (could lead to service duplication if we throw that data away)
|
|
1763
1796
|
accessory.serializedControllers && Object.entries(accessory.serializedControllers).forEach(function (_a) {
|
|
1764
|
-
var _b = tslib_1.__read(_a, 2), id = _b[0], serviceMap = _b[1];
|
|
1797
|
+
var _b = (0, tslib_1.__read)(_a, 2), id = _b[0], serviceMap = _b[1];
|
|
1765
1798
|
controllers.push({
|
|
1766
1799
|
type: id,
|
|
1767
1800
|
services: Accessory.serializeServiceMap(serviceMap),
|
|
@@ -1798,8 +1831,8 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1798
1831
|
});
|
|
1799
1832
|
};
|
|
1800
1833
|
try {
|
|
1801
|
-
for (var _b = tslib_1.__values(Object.entries(json.linkedServices)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1802
|
-
var _d = tslib_1.__read(_c.value, 2), serviceId = _d[0], linkedServicesKeys = _d[1];
|
|
1834
|
+
for (var _b = (0, tslib_1.__values)(Object.entries(json.linkedServices)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1835
|
+
var _d = (0, tslib_1.__read)(_c.value, 2), serviceId = _d[0], linkedServicesKeys = _d[1];
|
|
1803
1836
|
_loop_3(serviceId, linkedServicesKeys);
|
|
1804
1837
|
}
|
|
1805
1838
|
}
|
|
@@ -1828,7 +1861,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1828
1861
|
Accessory.serializeServiceMap = function (serviceMap) {
|
|
1829
1862
|
var serialized = {};
|
|
1830
1863
|
Object.entries(serviceMap).forEach(function (_a) {
|
|
1831
|
-
var _b = tslib_1.__read(_a, 2), name = _b[0], service = _b[1];
|
|
1864
|
+
var _b = (0, tslib_1.__read)(_a, 2), name = _b[0], service = _b[1];
|
|
1832
1865
|
if (!service) {
|
|
1833
1866
|
return;
|
|
1834
1867
|
}
|
|
@@ -1839,7 +1872,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1839
1872
|
Accessory.deserializeServiceMap = function (serializedServiceMap, servicesMap) {
|
|
1840
1873
|
var controllerServiceMap = {};
|
|
1841
1874
|
Object.entries(serializedServiceMap).forEach(function (_a) {
|
|
1842
|
-
var _b = tslib_1.__read(_a, 2), name = _b[0], serviceId = _b[1];
|
|
1875
|
+
var _b = (0, tslib_1.__read)(_a, 2), name = _b[0], serviceId = _b[1];
|
|
1843
1876
|
var service = servicesMap[serviceId];
|
|
1844
1877
|
if (service) {
|
|
1845
1878
|
controllerServiceMap[name] = service;
|
|
@@ -1884,7 +1917,7 @@ var Accessory = /** @class */ (function (_super) {
|
|
|
1884
1917
|
advertiserAddress = Array.from(entries);
|
|
1885
1918
|
var bindUnspecifiedIpv6 = false; // we bind on "::" if there are interface names, or we detect ipv6 addresses
|
|
1886
1919
|
try {
|
|
1887
|
-
for (var entries_1 = tslib_1.__values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
1920
|
+
for (var entries_1 = (0, tslib_1.__values)(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
1888
1921
|
var entry = entries_1_1.value;
|
|
1889
1922
|
var version = net_1.default.isIP(entry);
|
|
1890
1923
|
if (version === 0 || version === 6) {
|