@homebridge/hap-nodejs 2.3.1-beta.1 → 2.3.1-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/README.md +13 -4
- package/dist/accessories/types.d.ts +0 -1
- package/dist/hap.d.ts +1 -1
- package/dist/hap.js +6 -4
- package/dist/hap.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +6 -7
- package/dist/internal-types.js +1 -5
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +49 -25
- package/dist/lib/Accessory.js +275 -171
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +37 -18
- package/dist/lib/Advertiser.js +143 -62
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +1 -2
- package/dist/lib/Bridge.js +1 -1
- package/dist/lib/Characteristic.d.ts +19 -20
- package/dist/lib/Characteristic.js +187 -153
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +19 -13
- package/dist/lib/HAPServer.js +266 -220
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +11 -11
- package/dist/lib/Service.js +54 -37
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +5 -5
- package/dist/lib/camera/RTPProxy.js +48 -23
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +18 -13
- package/dist/lib/camera/RTPStreamManagement.js +247 -216
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +13 -13
- package/dist/lib/camera/RecordingManagement.js +115 -110
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +0 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +41 -36
- package/dist/lib/controller/AdaptiveLightingController.js +126 -113
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +17 -17
- package/dist/lib/controller/CameraController.js +30 -26
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +15 -12
- package/dist/lib/controller/Controller.js +0 -1
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +6 -6
- package/dist/lib/controller/DoorbellController.js +10 -3
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +46 -27
- package/dist/lib/controller/RemoteController.js +268 -178
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +0 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts +6 -6
- package/dist/lib/datastream/DataStreamManagement.js +30 -26
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +25 -8
- package/dist/lib/datastream/DataStreamParser.js +124 -105
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +47 -23
- package/dist/lib/datastream/DataStreamServer.js +285 -143
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +0 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +0 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +578 -578
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +0 -1
- package/dist/lib/definitions/index.d.ts +0 -1
- package/dist/lib/gen/HomeKit.d.ts +0 -1
- package/dist/lib/model/AccessoryInfo.d.ts +5 -6
- package/dist/lib/model/AccessoryInfo.js +23 -19
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +11 -5
- package/dist/lib/model/ControllerStorage.js +34 -8
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPFileStorage.d.ts +20 -2
- package/dist/lib/model/HAPFileStorage.js +59 -10
- package/dist/lib/model/HAPFileStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +0 -1
- package/dist/lib/model/HAPStorage.js +6 -3
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +2 -3
- package/dist/lib/model/IdentifierCache.js +26 -13
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +6 -7
- package/dist/lib/tv/AccessControlManagement.js +13 -19
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +1 -2
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.d.ts +0 -1
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +1 -2
- package/dist/lib/util/color-utils.js +1 -1
- package/dist/lib/util/errors.d.ts +4 -0
- package/dist/lib/util/errors.js +15 -0
- package/dist/lib/util/errors.js.map +1 -0
- package/dist/lib/util/eventedhttp.d.ts +63 -19
- package/dist/lib/util/eventedhttp.js +170 -48
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +1 -2
- package/dist/lib/util/hapCrypto.js +6 -7
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +0 -1
- package/dist/lib/util/hapStatusError.js +1 -1
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts +1 -2
- package/dist/lib/util/net-utils.js +6 -7
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.d.ts +0 -1
- package/dist/lib/util/promise-utils.d.ts +1 -2
- package/dist/lib/util/promise-utils.js +2 -1
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +4 -4
- package/dist/lib/util/request-util.js +29 -28
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +1 -2
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +4 -4
- package/dist/lib/util/tlv.js +16 -5
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +5 -2
- package/dist/lib/util/uuid.js +6 -0
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +20 -17
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -14
- package/dist/accessories/AirConditioner_accessory.d.ts +0 -2
- package/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
- package/dist/accessories/AirConditioner_accessory.js +0 -126
- package/dist/accessories/AirConditioner_accessory.js.map +0 -1
- package/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
- package/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
- package/dist/accessories/AppleTVRemote_accessory.js +0 -146
- package/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
- package/dist/accessories/Camera_accessory.d.ts +0 -2
- package/dist/accessories/Camera_accessory.d.ts.map +0 -1
- package/dist/accessories/Camera_accessory.js +0 -562
- package/dist/accessories/Camera_accessory.js.map +0 -1
- package/dist/accessories/Fan_accessory.d.ts +0 -2
- package/dist/accessories/Fan_accessory.d.ts.map +0 -1
- package/dist/accessories/Fan_accessory.js +0 -71
- package/dist/accessories/Fan_accessory.js.map +0 -1
- package/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
- package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +0 -76
- package/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
- package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -103
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
- package/dist/accessories/Light_accessory.d.ts +0 -2
- package/dist/accessories/Light_accessory.d.ts.map +0 -1
- package/dist/accessories/Light_accessory.js +0 -143
- package/dist/accessories/Light_accessory.js.map +0 -1
- package/dist/accessories/Lock_accessory.d.ts +0 -2
- package/dist/accessories/Lock_accessory.d.ts.map +0 -1
- package/dist/accessories/Lock_accessory.js +0 -74
- package/dist/accessories/Lock_accessory.js.map +0 -1
- package/dist/accessories/MotionSensor_accessory.d.ts +0 -2
- package/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
- package/dist/accessories/MotionSensor_accessory.js +0 -43
- package/dist/accessories/MotionSensor_accessory.js.map +0 -1
- package/dist/accessories/Outlet_accessory.d.ts +0 -2
- package/dist/accessories/Outlet_accessory.d.ts.map +0 -1
- package/dist/accessories/Outlet_accessory.js +0 -77
- package/dist/accessories/Outlet_accessory.js.map +0 -1
- package/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
- package/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
- package/dist/accessories/SmartSpeaker_accessory.js +0 -42
- package/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
- package/dist/accessories/Sprinkler_accessory.d.ts +0 -2
- package/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
- package/dist/accessories/Sprinkler_accessory.js +0 -126
- package/dist/accessories/Sprinkler_accessory.js.map +0 -1
- package/dist/accessories/TV_accessory.d.ts +0 -2
- package/dist/accessories/TV_accessory.d.ts.map +0 -1
- package/dist/accessories/TV_accessory.js +0 -99
- package/dist/accessories/TV_accessory.js.map +0 -1
- package/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
- package/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
- package/dist/accessories/TemperatureSensor_accessory.js +0 -42
- package/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +0 -14
- package/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +0 -16
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
- package/dist/accessories/gstreamer-audioProducer.js +0 -145
- package/dist/accessories/gstreamer-audioProducer.js.map +0 -1
- package/dist/accessories/types.d.ts.map +0 -1
- package/dist/hap.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal-types.d.ts.map +0 -1
- package/dist/lib/Accessory.d.ts.map +0 -1
- package/dist/lib/Advertiser.d.ts.map +0 -1
- package/dist/lib/Bridge.d.ts.map +0 -1
- package/dist/lib/Characteristic.d.ts.map +0 -1
- package/dist/lib/HAPServer.d.ts.map +0 -1
- package/dist/lib/Service.d.ts.map +0 -1
- package/dist/lib/camera/RTPProxy.d.ts.map +0 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
- package/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
- package/dist/lib/camera/index.d.ts.map +0 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
- package/dist/lib/controller/CameraController.d.ts.map +0 -1
- package/dist/lib/controller/Controller.d.ts.map +0 -1
- package/dist/lib/controller/DoorbellController.d.ts.map +0 -1
- package/dist/lib/controller/RemoteController.d.ts.map +0 -1
- package/dist/lib/controller/index.d.ts.map +0 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
- package/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
- package/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
- package/dist/lib/datastream/index.d.ts.map +0 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
- package/dist/lib/definitions/generate-definitions.d.ts +0 -34
- package/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
- package/dist/lib/definitions/generate-definitions.js +0 -624
- package/dist/lib/definitions/generate-definitions.js.map +0 -1
- package/dist/lib/definitions/generator-configuration.d.ts +0 -22
- package/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
- package/dist/lib/definitions/generator-configuration.js +0 -674
- package/dist/lib/definitions/generator-configuration.js.map +0 -1
- package/dist/lib/definitions/index.d.ts.map +0 -1
- package/dist/lib/gen/HomeKit.d.ts.map +0 -1
- package/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
- package/dist/lib/model/ControllerStorage.d.ts.map +0 -1
- package/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
- package/dist/lib/model/HAPStorage.d.ts.map +0 -1
- package/dist/lib/model/IdentifierCache.d.ts.map +0 -1
- package/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
- package/dist/lib/util/checkName.d.ts.map +0 -1
- package/dist/lib/util/clone.d.ts.map +0 -1
- package/dist/lib/util/color-utils.d.ts.map +0 -1
- package/dist/lib/util/eventedhttp.d.ts.map +0 -1
- package/dist/lib/util/hapCrypto.d.ts.map +0 -1
- package/dist/lib/util/hapStatusError.d.ts.map +0 -1
- package/dist/lib/util/net-utils.d.ts.map +0 -1
- package/dist/lib/util/once.d.ts.map +0 -1
- package/dist/lib/util/promise-utils.d.ts.map +0 -1
- package/dist/lib/util/request-util.d.ts.map +0 -1
- package/dist/lib/util/time.d.ts.map +0 -1
- package/dist/lib/util/tlv.d.ts.map +0 -1
- package/dist/lib/util/uuid.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
1
|
import util from 'node:util';
|
|
3
2
|
import { HAPStorage } from './HAPStorage.js';
|
|
4
3
|
/**
|
|
@@ -14,7 +13,8 @@ export class IdentifierCache {
|
|
|
14
13
|
username;
|
|
15
14
|
_cache = {}; // cache[key:string] = id:number
|
|
16
15
|
_usedCache = null; // for usage tracking and expiring old keys
|
|
17
|
-
|
|
16
|
+
// true when the cache differs from the saved file, so save() does not have to compare the whole cache on every call
|
|
17
|
+
dirty = true;
|
|
18
18
|
constructor(username) {
|
|
19
19
|
this.username = username;
|
|
20
20
|
}
|
|
@@ -22,8 +22,19 @@ export class IdentifierCache {
|
|
|
22
22
|
this._usedCache = {};
|
|
23
23
|
}
|
|
24
24
|
stopTrackingUsageAndExpireUnused() {
|
|
25
|
+
// The counter for the next accessory id is only touched when an id is handed out, so a pass without any bridged
|
|
26
|
+
// accessory would expire it, and an id HomeKit knows for a removed accessory would be given to a new one.
|
|
27
|
+
if (this._usedCache && this._cache['|nextAID'] !== undefined) {
|
|
28
|
+
this._usedCache['|nextAID'] = this._cache['|nextAID'];
|
|
29
|
+
}
|
|
25
30
|
// simply rotate in the new cache that was built during our normal getXYZ() calls.
|
|
26
|
-
|
|
31
|
+
if (this._usedCache) {
|
|
32
|
+
// the new cache only holds keys of the old one, so a different number of keys means some of them expired
|
|
33
|
+
if (Object.keys(this._usedCache).length !== Object.keys(this._cache).length) {
|
|
34
|
+
this.dirty = true;
|
|
35
|
+
}
|
|
36
|
+
this._cache = this._usedCache;
|
|
37
|
+
}
|
|
27
38
|
this._usedCache = null;
|
|
28
39
|
}
|
|
29
40
|
getCache(key) {
|
|
@@ -35,6 +46,9 @@ export class IdentifierCache {
|
|
|
35
46
|
return value;
|
|
36
47
|
}
|
|
37
48
|
setCache(key, value) {
|
|
49
|
+
if (this._cache[key] !== value) {
|
|
50
|
+
this.dirty = true;
|
|
51
|
+
}
|
|
38
52
|
this._cache[key] = value;
|
|
39
53
|
// track this cache item if needed
|
|
40
54
|
if (this._usedCache) {
|
|
@@ -71,15 +85,15 @@ export class IdentifierCache {
|
|
|
71
85
|
return nextIID;
|
|
72
86
|
}
|
|
73
87
|
save() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const saved = {
|
|
77
|
-
cache: this._cache,
|
|
78
|
-
};
|
|
79
|
-
const key = IdentifierCache.persistKey(this.username);
|
|
80
|
-
HAPStorage.storage().setItemSync(key, saved);
|
|
81
|
-
this._savedCacheHash = newCacheHash; // update hash of saved cache for future use
|
|
88
|
+
if (!this.dirty) {
|
|
89
|
+
return; // called on every pass over the accessories, which rarely changes an id
|
|
82
90
|
}
|
|
91
|
+
const saved = {
|
|
92
|
+
cache: this._cache,
|
|
93
|
+
};
|
|
94
|
+
const key = IdentifierCache.persistKey(this.username);
|
|
95
|
+
HAPStorage.storage().setItemSync(key, saved);
|
|
96
|
+
this.dirty = false;
|
|
83
97
|
}
|
|
84
98
|
/**
|
|
85
99
|
* Persisting to File System
|
|
@@ -94,8 +108,7 @@ export class IdentifierCache {
|
|
|
94
108
|
if (saved) {
|
|
95
109
|
const info = new IdentifierCache(username);
|
|
96
110
|
info._cache = saved.cache;
|
|
97
|
-
|
|
98
|
-
info._savedCacheHash = crypto.createHash('sha1').update(JSON.stringify(info._cache)).digest('hex');
|
|
111
|
+
info.dirty = false; // the cache is what the file holds
|
|
99
112
|
return info;
|
|
100
113
|
}
|
|
101
114
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierCache.js","sourceRoot":"","sources":["../../../src/lib/model/IdentifierCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IdentifierCache.js","sourceRoot":"","sources":["../../../src/lib/model/IdentifierCache.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAMP;IALnB,MAAM,GAA2B,EAAE,CAAA,CAAC,gCAAgC;IACpE,UAAU,GAAkC,IAAI,CAAA,CAAC,2CAA2C;IAC5F,oHAAoH;IAC5G,KAAK,GAAG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;YACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA,CAAC,mCAAmC;YACtD,OAAO,IAAI,CAAA;QACb,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,QAAoB;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QACrC,UAAU,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;CACF"}
|
|
@@ -6,17 +6,17 @@ import { EventEmitter } from 'node:events';
|
|
|
6
6
|
*
|
|
7
7
|
* @group Television
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare enum AccessLevel {
|
|
10
10
|
/**
|
|
11
|
-
* This access level is set when the
|
|
11
|
+
* This access level is set when the user selects "Anyone" or "Anyone On The Same Network"
|
|
12
12
|
* in the Access Control settings.
|
|
13
13
|
*/
|
|
14
14
|
ANYONE = 0,
|
|
15
15
|
/**
|
|
16
|
-
* This access level is set when the
|
|
16
|
+
* This access level is set when the user selects "Only People Sharing this Home" in the
|
|
17
17
|
* Access Control settings.
|
|
18
18
|
* On this level password setting is ignored.
|
|
19
|
-
* Requests to the HAPServer can only come from Home members
|
|
19
|
+
* Requests to the HAPServer can only come from Home members anyway, so there is no real use to it.
|
|
20
20
|
* This is pretty much only used for the AirPlay 2 protocol.
|
|
21
21
|
*/
|
|
22
22
|
HOME_MEMBERS_ONLY = 1
|
|
@@ -24,7 +24,7 @@ export declare const enum AccessLevel {
|
|
|
24
24
|
/**
|
|
25
25
|
* @group Television
|
|
26
26
|
*/
|
|
27
|
-
export declare
|
|
27
|
+
export declare enum AccessControlEvent {
|
|
28
28
|
ACCESS_LEVEL_UPDATED = "update-control-level",
|
|
29
29
|
PASSWORD_SETTING_UPDATED = "update-password"
|
|
30
30
|
}
|
|
@@ -72,7 +72,7 @@ export declare class AccessControlManagement extends EventEmitter {
|
|
|
72
72
|
getPassword(): string | undefined;
|
|
73
73
|
/**
|
|
74
74
|
* This destroys the AccessControlManagement.
|
|
75
|
-
* It unregisters all GET or SET
|
|
75
|
+
* It unregisters all GET or SET handlers it has associated with the given AccessControl service.
|
|
76
76
|
* It removes all event handlers which were registered to this object.
|
|
77
77
|
*/
|
|
78
78
|
destroy(): void;
|
|
@@ -80,4 +80,3 @@ export declare class AccessControlManagement extends EventEmitter {
|
|
|
80
80
|
private handlePasswordChange;
|
|
81
81
|
private setupServiceHandlers;
|
|
82
82
|
}
|
|
83
|
-
//# sourceMappingURL=AccessControlManagement.d.ts.map
|
|
@@ -3,7 +3,6 @@ import { EventEmitter } from 'node:events';
|
|
|
3
3
|
import { Characteristic } from '../Characteristic.js';
|
|
4
4
|
import { Service } from '../Service.js';
|
|
5
5
|
import * as tlv from '../util/tlv.js';
|
|
6
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
7
6
|
var AccessControlTypes;
|
|
8
7
|
(function (AccessControlTypes) {
|
|
9
8
|
AccessControlTypes[AccessControlTypes["PASSWORD"] = 1] = "PASSWORD";
|
|
@@ -15,20 +14,19 @@ var AccessControlTypes;
|
|
|
15
14
|
*
|
|
16
15
|
* @group Television
|
|
17
16
|
*/
|
|
18
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
19
17
|
export var AccessLevel;
|
|
20
18
|
(function (AccessLevel) {
|
|
21
19
|
// noinspection JSUnusedGlobalSymbols
|
|
22
20
|
/**
|
|
23
|
-
* This access level is set when the
|
|
21
|
+
* This access level is set when the user selects "Anyone" or "Anyone On The Same Network"
|
|
24
22
|
* in the Access Control settings.
|
|
25
23
|
*/
|
|
26
24
|
AccessLevel[AccessLevel["ANYONE"] = 0] = "ANYONE";
|
|
27
25
|
/**
|
|
28
|
-
* This access level is set when the
|
|
26
|
+
* This access level is set when the user selects "Only People Sharing this Home" in the
|
|
29
27
|
* Access Control settings.
|
|
30
28
|
* On this level password setting is ignored.
|
|
31
|
-
* Requests to the HAPServer can only come from Home members
|
|
29
|
+
* Requests to the HAPServer can only come from Home members anyway, so there is no real use to it.
|
|
32
30
|
* This is pretty much only used for the AirPlay 2 protocol.
|
|
33
31
|
*/
|
|
34
32
|
AccessLevel[AccessLevel["HOME_MEMBERS_ONLY"] = 1] = "HOME_MEMBERS_ONLY";
|
|
@@ -38,7 +36,6 @@ export var AccessLevel;
|
|
|
38
36
|
/**
|
|
39
37
|
* @group Television
|
|
40
38
|
*/
|
|
41
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
42
39
|
export var AccessControlEvent;
|
|
43
40
|
(function (AccessControlEvent) {
|
|
44
41
|
AccessControlEvent["ACCESS_LEVEL_UPDATED"] = "update-control-level";
|
|
@@ -47,7 +44,6 @@ export var AccessControlEvent;
|
|
|
47
44
|
/**
|
|
48
45
|
* @group Television
|
|
49
46
|
*/
|
|
50
|
-
// eslint-disable-next-line ts/no-unsafe-declaration-merging
|
|
51
47
|
export class AccessControlManagement extends EventEmitter {
|
|
52
48
|
accessControlService;
|
|
53
49
|
/**
|
|
@@ -55,7 +51,7 @@ export class AccessControlManagement extends EventEmitter {
|
|
|
55
51
|
*/
|
|
56
52
|
accessLevel = 0;
|
|
57
53
|
passwordRequired = false;
|
|
58
|
-
password; //
|
|
54
|
+
password; // kept when passwordRequired = false, but getPassword() does not return it then
|
|
59
55
|
constructor(password, service) {
|
|
60
56
|
super();
|
|
61
57
|
this.accessControlService = service || new Service.AccessControl();
|
|
@@ -81,7 +77,7 @@ export class AccessControlManagement extends EventEmitter {
|
|
|
81
77
|
}
|
|
82
78
|
/**
|
|
83
79
|
* This destroys the AccessControlManagement.
|
|
84
|
-
* It unregisters all GET or SET
|
|
80
|
+
* It unregisters all GET or SET handlers it has associated with the given AccessControl service.
|
|
85
81
|
* It removes all event handlers which were registered to this object.
|
|
86
82
|
*/
|
|
87
83
|
destroy() {
|
|
@@ -94,25 +90,23 @@ export class AccessControlManagement extends EventEmitter {
|
|
|
94
90
|
handleAccessLevelChange(value) {
|
|
95
91
|
this.accessLevel = value;
|
|
96
92
|
setTimeout(() => {
|
|
97
|
-
this
|
|
93
|
+
// the value of this write, not the state at the time the timer fires: another write may have followed by then
|
|
94
|
+
this.emit(AccessControlEvent.ACCESS_LEVEL_UPDATED, value);
|
|
98
95
|
}, 0).unref();
|
|
99
96
|
}
|
|
100
97
|
handlePasswordChange(value) {
|
|
101
98
|
const data = Buffer.from(value, 'base64');
|
|
102
99
|
const objects = tlv.decode(data);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.password = undefined;
|
|
108
|
-
}
|
|
109
|
-
this.passwordRequired = !!objects[2 /* AccessControlTypes.PASSWORD_REQUIRED */][0];
|
|
100
|
+
const password = objects[AccessControlTypes.PASSWORD]?.toString('utf8');
|
|
101
|
+
const passwordRequired = !!objects[AccessControlTypes.PASSWORD_REQUIRED][0];
|
|
102
|
+
this.password = password;
|
|
103
|
+
this.passwordRequired = passwordRequired;
|
|
110
104
|
setTimeout(() => {
|
|
111
|
-
|
|
105
|
+
// the values of this write, not the state at the time the timer fires: another write may have followed by then
|
|
106
|
+
this.emit(AccessControlEvent.PASSWORD_SETTING_UPDATED, password, passwordRequired);
|
|
112
107
|
}, 0).unref();
|
|
113
108
|
}
|
|
114
109
|
setupServiceHandlers(enabledPasswordCharacteristics) {
|
|
115
|
-
// perms: [Perms.NOTIFY, Perms.PAIRED_READ, Perms.PAIRED_WRITE],
|
|
116
110
|
this.accessControlService.getCharacteristic(Characteristic.AccessControlLevel)
|
|
117
111
|
.onSet(value => this.handleAccessLevelChange(value))
|
|
118
112
|
.updateValue(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessControlManagement.js","sourceRoot":"","sources":["../../../src/lib/tv/AccessControlManagement.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C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,MAAM,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;QACvE,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;QAE3E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QAExC,UAAU,CAAC,GAAG,EAAE;YACd,+GAA+G;YAC/G,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAA;QACpF,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;IACf,CAAC;IAEO,oBAAoB,CAAC,8BAAwC;QACnE,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,cAAc,CAAC,kBAAkB,CAAC;aAC3E,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,uBAAuB,CAAC,KAAe,CAAC,CAAC;aAC7D,WAAW,CAAC,CAAC,CAAC,CAAA;QAEjB,IAAI,8BAA8B,EAAE,CAAC;YACnC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC;iBACxE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAe,CAAC,CAAC;iBAC1D,WAAW,CAAC,EAAE,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CharacteristicValue, Nullable } from '../../types.js';
|
|
1
|
+
import type { CharacteristicValue, Nullable } from '../../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Checks that supplied field meets Apple HomeKit naming rules
|
|
4
4
|
* https://developer.apple.com/design/human-interface-guidelines/homekit#Help-people-choose-useful-names
|
|
5
5
|
* @private
|
|
6
6
|
*/
|
|
7
7
|
export declare function checkName(displayName: string, name: string, value: Nullable<CharacteristicValue>): void;
|
|
8
|
-
//# sourceMappingURL=checkName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkName.js","sourceRoot":"","sources":["../../../src/lib/util/checkName.ts"],"names":[],"mappings":"AAEA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"checkName.js","sourceRoot":"","sources":["../../../src/lib/util/checkName.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,WAAmB,EAAE,IAAY,EAAE,KAAoC;IAC/F,qEAAqE;IACrE,kEAAkE;IAClE,yCAAyC;IACzC,+EAA+E;IAC/E,qEAAqE;IACrE,0EAA0E;IAC1E,sCAAsC;IACtC,uEAAuE;IACvE,IACE,OAAO,KAAK,KAAK,QAAQ;WACtB,CAAC,uEAAuE,CAAC,IAAI,CAAC,KAAK,CAAC,EACvF,CAAC;QACD,OAAO,CAAC,IAAI,CACV,sCAAsC,WACtC,qBAAqB,IACrB,sBAAsB,KACtB,sEAAsE;cACpE,qEAAqE;cACrE,uEAAuE;cACvE,2EAA2E,CAC9E,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/lib/util/clone.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/lib/util/clone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAsB,MAAS,EAAE,MAAU;IAC9D,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/lib/util/clone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAsB,MAAS,EAAE,MAAU;IAC9D,MAAM,MAAM,GAA4B,EAAE,CAAA;IAE1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACrB,CAAC;IACH,CAAC;IAED,OAAO,MAAe,CAAA;AACxB,CAAC"}
|
|
@@ -8,11 +8,10 @@ export declare class ColorUtils {
|
|
|
8
8
|
* @param colorTemperature - The color temperature in mired.
|
|
9
9
|
* @param roundResults - The lookup table has a precision of .1 decimal places. The given characteristics only have a step value of 1.
|
|
10
10
|
* Thus, the method will round the results by default to an integer value. This can be turned off using this option.
|
|
11
|
-
* @returns An
|
|
11
|
+
* @returns An object with the saturation and the hue.
|
|
12
12
|
*/
|
|
13
13
|
static colorTemperatureToHueAndSaturation(colorTemperature: number, roundResults?: boolean): {
|
|
14
14
|
saturation: number;
|
|
15
15
|
hue: number;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=color-utils.d.ts.map
|
|
@@ -1615,7 +1615,7 @@ export class ColorUtils {
|
|
|
1615
1615
|
* @param colorTemperature - The color temperature in mired.
|
|
1616
1616
|
* @param roundResults - The lookup table has a precision of .1 decimal places. The given characteristics only have a step value of 1.
|
|
1617
1617
|
* Thus, the method will round the results by default to an integer value. This can be turned off using this option.
|
|
1618
|
-
* @returns An
|
|
1618
|
+
* @returns An object with the saturation and the hue.
|
|
1619
1619
|
*/
|
|
1620
1620
|
static colorTemperatureToHueAndSaturation(colorTemperature, roundResults = true) {
|
|
1621
1621
|
if (colorTemperature > 500) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Returns the message of a thrown value: its `message` when that is a string, otherwise the value as a string. */
|
|
2
|
+
export declare function errorMessage(error: unknown): string;
|
|
3
|
+
/** Returns the stack of a thrown value when it has one as a string, otherwise undefined. */
|
|
4
|
+
export declare function errorStack(error: unknown): string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Returns the message of a thrown value: its `message` when that is a string, otherwise the value as a string. */
|
|
2
|
+
export function errorMessage(error) {
|
|
3
|
+
if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {
|
|
4
|
+
return error.message;
|
|
5
|
+
}
|
|
6
|
+
return String(error);
|
|
7
|
+
}
|
|
8
|
+
/** Returns the stack of a thrown value when it has one as a string, otherwise undefined. */
|
|
9
|
+
export function errorStack(error) {
|
|
10
|
+
if (typeof error === 'object' && error !== null && 'stack' in error && typeof error.stack === 'string') {
|
|
11
|
+
return error.stack;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/lib/util/errors.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3G,OAAO,KAAK,CAAC,OAAO,CAAA;IACtB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvG,OAAO,KAAK,CAAC,KAAK,CAAA;IACpB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { SrpServer } from 'fast-srp-hap';
|
|
2
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import type { AddressInfo, Socket } from 'node:net';
|
|
4
|
+
import type { PairingStates } from '../../internal-types.js';
|
|
5
|
+
import type { CharacteristicValue, Nullable, SessionIdentifier } from '../../types.js';
|
|
1
6
|
import { Buffer } from 'node:buffer';
|
|
2
7
|
import { EventEmitter } from 'node:events';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
-
import { AddressInfo, Socket } from 'node:net';
|
|
5
|
-
import { SrpServer } from 'fast-srp-hap';
|
|
6
|
-
import { CharacteristicValue, Nullable, SessionIdentifier } from '../../types.js';
|
|
7
8
|
/**
|
|
8
9
|
* @group HAP Accessory Server
|
|
9
10
|
*/
|
|
@@ -33,7 +34,7 @@ export declare class HAPEncryption {
|
|
|
33
34
|
/**
|
|
34
35
|
* @group HAP Accessory Server
|
|
35
36
|
*/
|
|
36
|
-
export declare
|
|
37
|
+
export declare enum EventedHTTPServerEvent {
|
|
37
38
|
LISTENING = "listening",
|
|
38
39
|
CONNECTION_OPENED = "connection-opened",
|
|
39
40
|
REQUEST = "request",
|
|
@@ -54,7 +55,7 @@ export declare interface EventedHTTPServer {
|
|
|
54
55
|
*
|
|
55
56
|
* Implementation
|
|
56
57
|
* --------------
|
|
57
|
-
* In order to implement the "custom HTTP" server required by the HAP protocol (see HAPServer.
|
|
58
|
+
* In order to implement the "custom HTTP" server required by the HAP protocol (see HAPServer.ts) without completely
|
|
58
59
|
* reinventing the wheel, we create both a generic TCP socket server and a standard Node HTTP server.
|
|
59
60
|
* The TCP socket server acts as a proxy, allowing users of this class to transform data (for encryption) as necessary
|
|
60
61
|
* and passing through bytes directly to the HTTP server for processing. This way we get Node to do all
|
|
@@ -69,6 +70,7 @@ export declare interface EventedHTTPServer {
|
|
|
69
70
|
* @group HAP Accessory Server
|
|
70
71
|
*/
|
|
71
72
|
export declare class EventedHTTPServer extends EventEmitter {
|
|
73
|
+
private readonly owner?;
|
|
72
74
|
private static readonly CONNECTION_TIMEOUT_LIMIT;
|
|
73
75
|
private static readonly MAX_CONNECTION_IDLE_TIME;
|
|
74
76
|
private readonly tcpServer;
|
|
@@ -83,7 +85,20 @@ export declare class EventedHTTPServer extends EventEmitter {
|
|
|
83
85
|
private readonly connectionsByUsername;
|
|
84
86
|
private connectionIdleTimeout?;
|
|
85
87
|
private connectionLoggingInterval?;
|
|
86
|
-
|
|
88
|
+
/**
|
|
89
|
+
* The port {@link listen} was asked for, to name it when the server fails before it has an address.
|
|
90
|
+
*/
|
|
91
|
+
private requestedPort?;
|
|
92
|
+
/**
|
|
93
|
+
* @param owner - Names who the server belongs to, like the accessory. It is put in front of an error of the server.
|
|
94
|
+
*/
|
|
95
|
+
constructor(owner?: (() => string) | undefined);
|
|
96
|
+
/**
|
|
97
|
+
* An error of the server itself, like a port which is in use, ends the process: nothing can serve the accessory without it.
|
|
98
|
+
* Without a listener Node.js throws the bare error, which names neither the accessory nor the server it came from.
|
|
99
|
+
* This throws as well, so it reaches the same `uncaughtException` handler, but with a message which says whose server failed.
|
|
100
|
+
*/
|
|
101
|
+
private onServerError;
|
|
87
102
|
private scheduleNextConnectionIdleTimeout;
|
|
88
103
|
address(): AddressInfo;
|
|
89
104
|
listen(targetPort: number, hostname?: string): void;
|
|
@@ -97,7 +112,7 @@ export declare class EventedHTTPServer extends EventEmitter {
|
|
|
97
112
|
* @param iid - The instance id of the updated characteristic.
|
|
98
113
|
* @param value - The newly set value of the characteristic.
|
|
99
114
|
* @param originator - If specified, the connection will not get an event message.
|
|
100
|
-
* @param immediateDelivery - The HAP spec requires some characteristics to be
|
|
115
|
+
* @param immediateDelivery - The HAP spec requires some characteristics to be delivered immediately.
|
|
101
116
|
* Namely, for the {@link Characteristic.ButtonEvent} and the {@link Characteristic.ProgrammableSwitchEvent} characteristics.
|
|
102
117
|
*/
|
|
103
118
|
broadcastEvent(aid: number, iid: number, value: Nullable<CharacteristicValue>, originator?: HAPConnection, immediateDelivery?: boolean): void;
|
|
@@ -108,6 +123,13 @@ export declare class EventedHTTPServer extends EventEmitter {
|
|
|
108
123
|
* @returns the instance ids of the removed registrations, once for every connection that held one.
|
|
109
124
|
*/
|
|
110
125
|
disableEventNotificationsForAccessory(aid: number): number[];
|
|
126
|
+
/**
|
|
127
|
+
* Removes the event registrations every connection holds for a characteristic which does not exist anymore.
|
|
128
|
+
*
|
|
129
|
+
* @param exists - Tells if the characteristic with the given ids still exists.
|
|
130
|
+
* @returns the removed registrations, once for every connection that held one.
|
|
131
|
+
*/
|
|
132
|
+
disableStaleEventNotifications(exists: (aid: number, iid: number) => boolean): EventName[];
|
|
111
133
|
private onConnection;
|
|
112
134
|
private handleConnectionAuthenticated;
|
|
113
135
|
private handleConnectionClose;
|
|
@@ -115,7 +137,7 @@ export declare class EventedHTTPServer extends EventEmitter {
|
|
|
115
137
|
* This method is to be called when a given {@link HAPConnection} performs a request that should result in the disconnection
|
|
116
138
|
* of all other {@link HAPConnection} with the same {@link HAPUsername}.
|
|
117
139
|
*
|
|
118
|
-
* The initiator MUST be in the middle of a http request
|
|
140
|
+
* The initiator MUST be in the middle of a http request where the response was not served yet.
|
|
119
141
|
* Otherwise, the initiator connection might reside in a state where it isn't disconnected and can't make any further requests.
|
|
120
142
|
*
|
|
121
143
|
* @param initiator - The connection that requested to disconnect all connections of the same username.
|
|
@@ -127,7 +149,7 @@ export declare class EventedHTTPServer extends EventEmitter {
|
|
|
127
149
|
* @private
|
|
128
150
|
* @group HAP Accessory Server
|
|
129
151
|
*/
|
|
130
|
-
export declare
|
|
152
|
+
export declare enum HAPConnectionState {
|
|
131
153
|
CONNECTING = 0,// initial state, setup is going on
|
|
132
154
|
FULLY_SET_UP = 1,// internal http server is running and connection is established
|
|
133
155
|
AUTHENTICATED = 2,// encryption is set up
|
|
@@ -138,7 +160,7 @@ export declare const enum HAPConnectionState {
|
|
|
138
160
|
/**
|
|
139
161
|
* @group HAP Accessory Server
|
|
140
162
|
*/
|
|
141
|
-
export declare
|
|
163
|
+
export declare enum HAPConnectionEvent {
|
|
142
164
|
REQUEST = "request",
|
|
143
165
|
AUTHENTICATED = "authenticated",
|
|
144
166
|
CLOSED = "closed"
|
|
@@ -162,6 +184,11 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
162
184
|
* per change; events flagged for immediate delivery bypass this window entirely.
|
|
163
185
|
*/
|
|
164
186
|
static readonly EVENT_COALESCING_DELAY = 250;
|
|
187
|
+
/**
|
|
188
|
+
* Time in milliseconds after which data received from the controller, which did not turn into a request by then,
|
|
189
|
+
* no longer holds back event notifications.
|
|
190
|
+
*/
|
|
191
|
+
static readonly INCOMING_DATA_TIMEOUT = 500;
|
|
165
192
|
/**
|
|
166
193
|
* Local addresses {@link getLocalNetworkInterface} has already warned about. An address can stay unmatchable for
|
|
167
194
|
* good - Node.js leaves out interfaces that are up but have no link, like an unused docker0 bridge - and then
|
|
@@ -186,6 +213,14 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
186
213
|
lastSocketOperation: number;
|
|
187
214
|
private pendingClientSocketData?;
|
|
188
215
|
private handlingRequest;
|
|
216
|
+
/**
|
|
217
|
+
* The number of requests which arrived at the internal http server and were not answered yet.
|
|
218
|
+
*/
|
|
219
|
+
private pendingRequests;
|
|
220
|
+
/**
|
|
221
|
+
* Runs out when data arrived which did not turn into a request, see {@link onTCPSocketData}.
|
|
222
|
+
*/
|
|
223
|
+
private incomingDataTimeout?;
|
|
189
224
|
/**
|
|
190
225
|
* Byte offset in the stream read by {@link httpSocket} at which the last finished HTTP response ends.
|
|
191
226
|
* The internal HTTP server hands us a response in chunks of at most 64 KiB, so the first chunk is not the whole response.
|
|
@@ -194,8 +229,8 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
194
229
|
username?: HAPUsername;
|
|
195
230
|
encryption?: HAPEncryption;
|
|
196
231
|
srpServer?: SrpServer;
|
|
197
|
-
_pairSetupState?:
|
|
198
|
-
_pairVerifyState?:
|
|
232
|
+
_pairSetupState?: PairingStates;
|
|
233
|
+
_pairVerifyState?: PairingStates;
|
|
199
234
|
private registeredEvents;
|
|
200
235
|
private eventsTimer?;
|
|
201
236
|
private readonly queuedEvents;
|
|
@@ -212,7 +247,7 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
212
247
|
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
213
248
|
/**
|
|
214
249
|
* This method is called once the connection has gone through pair-verify.
|
|
215
|
-
* As any HomeKit controller will initiate a pair-verify after the pair-setup procedure, this method
|
|
250
|
+
* As any HomeKit controller will initiate a pair-verify after the pair-setup procedure, this method is
|
|
216
251
|
* not called on the initial pair-setup.
|
|
217
252
|
*
|
|
218
253
|
* Once this method has been called, the connection is authenticated and encryption is turned on.
|
|
@@ -226,8 +261,7 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
226
261
|
private writeQueuedEventNotifications;
|
|
227
262
|
/**
|
|
228
263
|
* This will create an EVENT/1.0 notification header with the provided event notification.
|
|
229
|
-
*
|
|
230
|
-
* added to the pending events list.
|
|
264
|
+
* It must not be called while an HTTP request is in progress: the events wait in the queue until the response went out.
|
|
231
265
|
*
|
|
232
266
|
* @param notification - The event which should be sent out
|
|
233
267
|
*/
|
|
@@ -241,6 +275,13 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
241
275
|
* @returns the instance ids of the removed registrations.
|
|
242
276
|
*/
|
|
243
277
|
disableEventNotificationsForAccessory(aid: number): number[];
|
|
278
|
+
/**
|
|
279
|
+
* Removes the event registrations of this connection for a characteristic which does not exist anymore.
|
|
280
|
+
*
|
|
281
|
+
* @param exists - Tells if the characteristic with the given ids still exists.
|
|
282
|
+
* @returns the removed registrations.
|
|
283
|
+
*/
|
|
284
|
+
disableStaleEventNotifications(exists: (aid: number, iid: number) => boolean): EventName[];
|
|
244
285
|
hasEventNotifications(aid: number, iid: number): boolean;
|
|
245
286
|
getRegisteredEvents(): Set<EventName>;
|
|
246
287
|
clearRegisteredEvents(): void;
|
|
@@ -249,7 +290,7 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
249
290
|
private onHttpServerListening;
|
|
250
291
|
/**
|
|
251
292
|
* This event handler is called when we receive data from a HomeKit controller on our tcp socket.
|
|
252
|
-
* We store the data if the internal http server is not
|
|
293
|
+
* We store the data if the internal http server is not ready yet, or forward it to the http server.
|
|
253
294
|
*/
|
|
254
295
|
private onTCPSocketData;
|
|
255
296
|
/**
|
|
@@ -260,7 +301,7 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
260
301
|
private onHttpServerConnection;
|
|
261
302
|
/**
|
|
262
303
|
* This event handler is called when the internal http server receives a request.
|
|
263
|
-
* Meaning we received data from the HomeKit controller in {@link onTCPSocketData}, which then
|
|
304
|
+
* Meaning we received data from the HomeKit controller in {@link onTCPSocketData}, which then sent the
|
|
264
305
|
* data unencrypted to the internal http server. And now it landed here, fully parsed as a http request.
|
|
265
306
|
*/
|
|
266
307
|
private handleHttpServerRequest;
|
|
@@ -276,6 +317,10 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
276
317
|
* in the middle of its body.
|
|
277
318
|
*/
|
|
278
319
|
private handleHttpResponseCompleteIfReceived;
|
|
320
|
+
/**
|
|
321
|
+
* Called once no request is left to answer: the events which had to wait may be written now.
|
|
322
|
+
*/
|
|
323
|
+
private requestHandlingFinished;
|
|
279
324
|
private handleTCPSocketWriteFulfilled;
|
|
280
325
|
private onTCPSocketError;
|
|
281
326
|
private onTCPSocketClose;
|
|
@@ -291,4 +336,3 @@ export declare class HAPConnection extends EventEmitter {
|
|
|
291
336
|
private static internalHttpServerListenAddress;
|
|
292
337
|
private static getLocalNetworkInterface;
|
|
293
338
|
}
|
|
294
|
-
//# sourceMappingURL=eventedhttp.d.ts.map
|