@homebridge/hap-nodejs 2.3.1-beta.0 → 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.
Files changed (254) hide show
  1. package/README.md +13 -4
  2. package/dist/accessories/types.d.ts +0 -1
  3. package/dist/hap.d.ts +1 -1
  4. package/dist/hap.js +6 -4
  5. package/dist/hap.js.map +1 -1
  6. package/dist/index.d.ts +4 -1
  7. package/dist/index.js +4 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal-types.d.ts +6 -7
  10. package/dist/internal-types.js +1 -5
  11. package/dist/internal-types.js.map +1 -1
  12. package/dist/lib/Accessory.d.ts +49 -25
  13. package/dist/lib/Accessory.js +275 -171
  14. package/dist/lib/Accessory.js.map +1 -1
  15. package/dist/lib/Advertiser.d.ts +37 -18
  16. package/dist/lib/Advertiser.js +143 -62
  17. package/dist/lib/Advertiser.js.map +1 -1
  18. package/dist/lib/Bridge.d.ts +1 -2
  19. package/dist/lib/Bridge.js +1 -1
  20. package/dist/lib/Characteristic.d.ts +40 -21
  21. package/dist/lib/Characteristic.js +207 -153
  22. package/dist/lib/Characteristic.js.map +1 -1
  23. package/dist/lib/HAPServer.d.ts +19 -13
  24. package/dist/lib/HAPServer.js +266 -220
  25. package/dist/lib/HAPServer.js.map +1 -1
  26. package/dist/lib/Service.d.ts +16 -12
  27. package/dist/lib/Service.js +58 -37
  28. package/dist/lib/Service.js.map +1 -1
  29. package/dist/lib/camera/RTPProxy.d.ts +5 -5
  30. package/dist/lib/camera/RTPProxy.js +48 -23
  31. package/dist/lib/camera/RTPProxy.js.map +1 -1
  32. package/dist/lib/camera/RTPStreamManagement.d.ts +18 -13
  33. package/dist/lib/camera/RTPStreamManagement.js +247 -216
  34. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  35. package/dist/lib/camera/RecordingManagement.d.ts +13 -13
  36. package/dist/lib/camera/RecordingManagement.js +115 -110
  37. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  38. package/dist/lib/camera/index.d.ts +0 -1
  39. package/dist/lib/controller/AdaptiveLightingController.d.ts +41 -36
  40. package/dist/lib/controller/AdaptiveLightingController.js +126 -113
  41. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  42. package/dist/lib/controller/CameraController.d.ts +17 -17
  43. package/dist/lib/controller/CameraController.js +30 -26
  44. package/dist/lib/controller/CameraController.js.map +1 -1
  45. package/dist/lib/controller/Controller.d.ts +15 -12
  46. package/dist/lib/controller/Controller.js +0 -1
  47. package/dist/lib/controller/Controller.js.map +1 -1
  48. package/dist/lib/controller/DoorbellController.d.ts +6 -6
  49. package/dist/lib/controller/DoorbellController.js +10 -3
  50. package/dist/lib/controller/DoorbellController.js.map +1 -1
  51. package/dist/lib/controller/RemoteController.d.ts +46 -27
  52. package/dist/lib/controller/RemoteController.js +268 -178
  53. package/dist/lib/controller/RemoteController.js.map +1 -1
  54. package/dist/lib/controller/index.d.ts +0 -1
  55. package/dist/lib/datastream/DataStreamManagement.d.ts +6 -6
  56. package/dist/lib/datastream/DataStreamManagement.js +30 -26
  57. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  58. package/dist/lib/datastream/DataStreamParser.d.ts +25 -8
  59. package/dist/lib/datastream/DataStreamParser.js +124 -105
  60. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  61. package/dist/lib/datastream/DataStreamServer.d.ts +47 -23
  62. package/dist/lib/datastream/DataStreamServer.js +285 -143
  63. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  64. package/dist/lib/datastream/index.d.ts +0 -1
  65. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +35 -1
  66. package/dist/lib/definitions/CharacteristicDefinitions.js +649 -568
  67. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  68. package/dist/lib/definitions/ServiceDefinitions.d.ts +7 -1
  69. package/dist/lib/definitions/ServiceDefinitions.js +16 -1
  70. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
  71. package/dist/lib/definitions/index.d.ts +0 -1
  72. package/dist/lib/gen/HomeKit.d.ts +0 -1
  73. package/dist/lib/model/AccessoryInfo.d.ts +5 -6
  74. package/dist/lib/model/AccessoryInfo.js +23 -19
  75. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  76. package/dist/lib/model/ControllerStorage.d.ts +11 -5
  77. package/dist/lib/model/ControllerStorage.js +34 -8
  78. package/dist/lib/model/ControllerStorage.js.map +1 -1
  79. package/dist/lib/model/HAPFileStorage.d.ts +20 -2
  80. package/dist/lib/model/HAPFileStorage.js +59 -10
  81. package/dist/lib/model/HAPFileStorage.js.map +1 -1
  82. package/dist/lib/model/HAPStorage.d.ts +0 -1
  83. package/dist/lib/model/HAPStorage.js +6 -3
  84. package/dist/lib/model/HAPStorage.js.map +1 -1
  85. package/dist/lib/model/IdentifierCache.d.ts +2 -3
  86. package/dist/lib/model/IdentifierCache.js +26 -13
  87. package/dist/lib/model/IdentifierCache.js.map +1 -1
  88. package/dist/lib/tv/AccessControlManagement.d.ts +6 -7
  89. package/dist/lib/tv/AccessControlManagement.js +13 -19
  90. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  91. package/dist/lib/util/checkName.d.ts +1 -2
  92. package/dist/lib/util/checkName.js.map +1 -1
  93. package/dist/lib/util/clone.d.ts +0 -1
  94. package/dist/lib/util/clone.js.map +1 -1
  95. package/dist/lib/util/color-utils.d.ts +1 -2
  96. package/dist/lib/util/color-utils.js +1 -1
  97. package/dist/lib/util/errors.d.ts +4 -0
  98. package/dist/lib/util/errors.js +15 -0
  99. package/dist/lib/util/errors.js.map +1 -0
  100. package/dist/lib/util/eventedhttp.d.ts +63 -19
  101. package/dist/lib/util/eventedhttp.js +170 -48
  102. package/dist/lib/util/eventedhttp.js.map +1 -1
  103. package/dist/lib/util/hapCrypto.d.ts +1 -2
  104. package/dist/lib/util/hapCrypto.js +6 -7
  105. package/dist/lib/util/hapCrypto.js.map +1 -1
  106. package/dist/lib/util/hapStatusError.d.ts +0 -1
  107. package/dist/lib/util/hapStatusError.js +1 -1
  108. package/dist/lib/util/hapStatusError.js.map +1 -1
  109. package/dist/lib/util/net-utils.d.ts +1 -2
  110. package/dist/lib/util/net-utils.js +6 -7
  111. package/dist/lib/util/net-utils.js.map +1 -1
  112. package/dist/lib/util/once.d.ts +0 -1
  113. package/dist/lib/util/promise-utils.d.ts +1 -2
  114. package/dist/lib/util/promise-utils.js +2 -1
  115. package/dist/lib/util/promise-utils.js.map +1 -1
  116. package/dist/lib/util/request-util.d.ts +4 -4
  117. package/dist/lib/util/request-util.js +29 -28
  118. package/dist/lib/util/request-util.js.map +1 -1
  119. package/dist/lib/util/time.d.ts +1 -2
  120. package/dist/lib/util/time.js.map +1 -1
  121. package/dist/lib/util/tlv.d.ts +4 -4
  122. package/dist/lib/util/tlv.js +16 -5
  123. package/dist/lib/util/tlv.js.map +1 -1
  124. package/dist/lib/util/uuid.d.ts +5 -2
  125. package/dist/lib/util/uuid.js +6 -0
  126. package/dist/lib/util/uuid.js.map +1 -1
  127. package/dist/types.d.ts +20 -17
  128. package/dist/types.js +0 -1
  129. package/dist/types.js.map +1 -1
  130. package/package.json +8 -14
  131. package/dist/accessories/AirConditioner_accessory.d.ts +0 -2
  132. package/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
  133. package/dist/accessories/AirConditioner_accessory.js +0 -126
  134. package/dist/accessories/AirConditioner_accessory.js.map +0 -1
  135. package/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
  136. package/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
  137. package/dist/accessories/AppleTVRemote_accessory.js +0 -146
  138. package/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
  139. package/dist/accessories/Camera_accessory.d.ts +0 -2
  140. package/dist/accessories/Camera_accessory.d.ts.map +0 -1
  141. package/dist/accessories/Camera_accessory.js +0 -562
  142. package/dist/accessories/Camera_accessory.js.map +0 -1
  143. package/dist/accessories/Fan_accessory.d.ts +0 -2
  144. package/dist/accessories/Fan_accessory.d.ts.map +0 -1
  145. package/dist/accessories/Fan_accessory.js +0 -71
  146. package/dist/accessories/Fan_accessory.js.map +0 -1
  147. package/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
  148. package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
  149. package/dist/accessories/GarageDoorOpener_accessory.js +0 -76
  150. package/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
  151. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
  152. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
  153. package/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -103
  154. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
  155. package/dist/accessories/Light_accessory.d.ts +0 -2
  156. package/dist/accessories/Light_accessory.d.ts.map +0 -1
  157. package/dist/accessories/Light_accessory.js +0 -143
  158. package/dist/accessories/Light_accessory.js.map +0 -1
  159. package/dist/accessories/Lock_accessory.d.ts +0 -2
  160. package/dist/accessories/Lock_accessory.d.ts.map +0 -1
  161. package/dist/accessories/Lock_accessory.js +0 -74
  162. package/dist/accessories/Lock_accessory.js.map +0 -1
  163. package/dist/accessories/MotionSensor_accessory.d.ts +0 -2
  164. package/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
  165. package/dist/accessories/MotionSensor_accessory.js +0 -43
  166. package/dist/accessories/MotionSensor_accessory.js.map +0 -1
  167. package/dist/accessories/Outlet_accessory.d.ts +0 -2
  168. package/dist/accessories/Outlet_accessory.d.ts.map +0 -1
  169. package/dist/accessories/Outlet_accessory.js +0 -77
  170. package/dist/accessories/Outlet_accessory.js.map +0 -1
  171. package/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
  172. package/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
  173. package/dist/accessories/SmartSpeaker_accessory.js +0 -42
  174. package/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
  175. package/dist/accessories/Sprinkler_accessory.d.ts +0 -2
  176. package/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
  177. package/dist/accessories/Sprinkler_accessory.js +0 -126
  178. package/dist/accessories/Sprinkler_accessory.js.map +0 -1
  179. package/dist/accessories/TV_accessory.d.ts +0 -2
  180. package/dist/accessories/TV_accessory.d.ts.map +0 -1
  181. package/dist/accessories/TV_accessory.js +0 -99
  182. package/dist/accessories/TV_accessory.js.map +0 -1
  183. package/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
  184. package/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
  185. package/dist/accessories/TemperatureSensor_accessory.js +0 -42
  186. package/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
  187. package/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
  188. package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
  189. package/dist/accessories/Wi-FiRouter_accessory.js +0 -14
  190. package/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
  191. package/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
  192. package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
  193. package/dist/accessories/Wi-FiSatellite_accessory.js +0 -16
  194. package/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
  195. package/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
  196. package/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
  197. package/dist/accessories/gstreamer-audioProducer.js +0 -145
  198. package/dist/accessories/gstreamer-audioProducer.js.map +0 -1
  199. package/dist/accessories/types.d.ts.map +0 -1
  200. package/dist/hap.d.ts.map +0 -1
  201. package/dist/index.d.ts.map +0 -1
  202. package/dist/internal-types.d.ts.map +0 -1
  203. package/dist/lib/Accessory.d.ts.map +0 -1
  204. package/dist/lib/Advertiser.d.ts.map +0 -1
  205. package/dist/lib/Bridge.d.ts.map +0 -1
  206. package/dist/lib/Characteristic.d.ts.map +0 -1
  207. package/dist/lib/HAPServer.d.ts.map +0 -1
  208. package/dist/lib/Service.d.ts.map +0 -1
  209. package/dist/lib/camera/RTPProxy.d.ts.map +0 -1
  210. package/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
  211. package/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
  212. package/dist/lib/camera/index.d.ts.map +0 -1
  213. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
  214. package/dist/lib/controller/CameraController.d.ts.map +0 -1
  215. package/dist/lib/controller/Controller.d.ts.map +0 -1
  216. package/dist/lib/controller/DoorbellController.d.ts.map +0 -1
  217. package/dist/lib/controller/RemoteController.d.ts.map +0 -1
  218. package/dist/lib/controller/index.d.ts.map +0 -1
  219. package/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
  220. package/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
  221. package/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
  222. package/dist/lib/datastream/index.d.ts.map +0 -1
  223. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
  224. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
  225. package/dist/lib/definitions/generate-definitions.d.ts +0 -34
  226. package/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
  227. package/dist/lib/definitions/generate-definitions.js +0 -624
  228. package/dist/lib/definitions/generate-definitions.js.map +0 -1
  229. package/dist/lib/definitions/generator-configuration.d.ts +0 -22
  230. package/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
  231. package/dist/lib/definitions/generator-configuration.js +0 -674
  232. package/dist/lib/definitions/generator-configuration.js.map +0 -1
  233. package/dist/lib/definitions/index.d.ts.map +0 -1
  234. package/dist/lib/gen/HomeKit.d.ts.map +0 -1
  235. package/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
  236. package/dist/lib/model/ControllerStorage.d.ts.map +0 -1
  237. package/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
  238. package/dist/lib/model/HAPStorage.d.ts.map +0 -1
  239. package/dist/lib/model/IdentifierCache.d.ts.map +0 -1
  240. package/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
  241. package/dist/lib/util/checkName.d.ts.map +0 -1
  242. package/dist/lib/util/clone.d.ts.map +0 -1
  243. package/dist/lib/util/color-utils.d.ts.map +0 -1
  244. package/dist/lib/util/eventedhttp.d.ts.map +0 -1
  245. package/dist/lib/util/hapCrypto.d.ts.map +0 -1
  246. package/dist/lib/util/hapStatusError.d.ts.map +0 -1
  247. package/dist/lib/util/net-utils.d.ts.map +0 -1
  248. package/dist/lib/util/once.d.ts.map +0 -1
  249. package/dist/lib/util/promise-utils.d.ts.map +0 -1
  250. package/dist/lib/util/request-util.d.ts.map +0 -1
  251. package/dist/lib/util/time.d.ts.map +0 -1
  252. package/dist/lib/util/tlv.d.ts.map +0 -1
  253. package/dist/lib/util/uuid.d.ts.map +0 -1
  254. package/dist/types.d.ts.map +0 -1
@@ -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 const enum EventedHTTPServerEvent {
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.js) without completely
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
- constructor();
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 delivery immediately.
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 were the response was not served yet.
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 const enum HAPConnectionState {
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 const enum HAPConnectionEvent {
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?: number;
198
- _pairVerifyState?: number;
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 gets
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
- * If currently an HTTP request is in progress the assembled packet will be
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 read yet, or forward it to the http server.
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 send the
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