From bcbbd0208347242320a27deccc204b5b9a5faeca Mon Sep 17 00:00:00 2001 From: HJD Date: Wed, 10 Jul 2024 08:40:30 -0500 Subject: [PATCH 1/5] Remove the long-deprecated init(). --- src/index.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/index.ts b/src/index.ts index af9a15816..f911f6978 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,23 +57,6 @@ function printInit() { } printInit(); -/** - * - * @param {string} storagePath - * @deprecated the need to manually initialize the internal storage was removed. If you want to set a custom - * storage path location, please use {@link HAPStorage.setCustomStoragePath} directly. - * - * @group Utils - */ -export function init(storagePath?: string): void { - console.log("DEPRECATED: The need to manually initialize HAP (by calling the init method) was removed. " + - "If you want to set a custom storage path location, please ust HAPStorage.setCustomStoragePath directly. " + - "This method will be removed in the next major update!"); - if (storagePath) { - HAPStorage.setCustomStoragePath(storagePath); - } -} - import * as Services from "./lib/definitions/ServiceDefinitions"; import * as Characteristics from "./lib/definitions/CharacteristicDefinitions"; From 57f1be7734ab3a577ad70e9f602a671b2f317e74 Mon Sep 17 00:00:00 2001 From: HJD Date: Wed, 10 Jul 2024 08:40:47 -0500 Subject: [PATCH 2/5] Remove the long-deprecated Core and BridgedCore capabilities. --- src/BridgedCore.ts | 49 --------------------------------------- src/Core.ts | 57 ---------------------------------------------- 2 files changed, 106 deletions(-) delete mode 100644 src/BridgedCore.ts delete mode 100644 src/Core.ts diff --git a/src/BridgedCore.ts b/src/BridgedCore.ts deleted file mode 100644 index c676989ab..000000000 --- a/src/BridgedCore.ts +++ /dev/null @@ -1,49 +0,0 @@ -import path from "path"; - -import storage from "node-persist"; - -import { Accessory, AccessoryEventTypes, AccessoryLoader, Bridge, Categories, HAPLibraryVersion, uuid, VoidCallback } from "./"; - -console.log(`HAP-NodeJS v${HAPLibraryVersion()} starting...`); - -console.warn("DEPRECATION NOTICE: The use of Core and BridgeCore is deprecated and is scheduled to be removed in a future version."); -console.warn("For more information and some guidance on how to migrate, have a look at" - + " https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore"); - -// Initialize our storage system -storage.initSync(); - -// Start by creating our Bridge which will host all loaded Accessories -const bridge = new Bridge("Node Bridge", uuid.generate("Node Bridge")); - -// Listen for bridge identification event -bridge.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => { - console.log("Node Bridge identify"); - callback(); // success -}); - -// Load up all accessories in the /accessories folder -const dir = path.join(__dirname, "accessories"); -const accessories = AccessoryLoader.loadDirectory(dir); - -// Add them all to the bridge -accessories.forEach((accessory: Accessory) => { - bridge.addBridgedAccessory(accessory); -}); - -// Publish the Bridge on the local network. -bridge.publish({ - username: "CC:22:3D:E3:CE:F6", - port: 51826, - pincode: "031-45-154", - category: Categories.BRIDGE, -}); - -const signals = { "SIGINT": 2, "SIGTERM": 15 } as Record; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -Object.keys(signals).forEach((signal: any) => { - process.on(signal, () => { - bridge.unpublish() - .then(() => setTimeout(() => process.exit(128 + signals[signal]), 1000)); - }); -}); diff --git a/src/Core.ts b/src/Core.ts deleted file mode 100644 index 7112c3790..000000000 --- a/src/Core.ts +++ /dev/null @@ -1,57 +0,0 @@ -import path from "path"; - -import storage from "node-persist"; - -import { AccessoryLoader, HAPLibraryVersion } from "./"; - -console.log(`HAP-NodeJS v${HAPLibraryVersion()} starting...`); - -console.warn("DEPRECATION NOTICE: The use of Core and BridgeCore is deprecated and is scheduled to be removed in a future version."); -console.warn("For more information and some guidance on how to migrate, have a look at" - + " https://github.com/homebridge/HAP-NodeJS/wiki/Deprecation-of-Core-and-BridgeCore"); - -// Initialize our storage system -storage.initSync(); - -// Our Accessories will each have their own HAP server; we will assign ports sequentially -let targetPort = 51826; - -// Load up all accessories in the /accessories folder -const dir = path.join(__dirname, "accessories"); -const accessories = AccessoryLoader.loadDirectory(dir); - -// Publish them all separately (as opposed to BridgedCore which publishes them behind a single Bridge accessory) -accessories.forEach((accessory) => { - - // To push Accessories separately, we'll need a few extra properties - // @ts-expect-error: Core/BridgeCore API - if (!accessory.username) { - throw new Error("Username not found on accessory '" + accessory.displayName + - "'. Core.js requires all accessories to define a unique 'username' property."); - } - - // @ts-expect-error: Core/BridgeCore API - if (!accessory.pincode) { - throw new Error("Pincode not found on accessory '" + accessory.displayName + - "'. Core.js requires all accessories to define a 'pincode' property."); - } - - // publish this Accessory on the local network - accessory.publish({ - port: targetPort++, - // @ts-expect-error: Core/BridgeCore API - username: accessory.username, - // @ts-expect-error: Core/BridgeCore API - pincode: accessory.pincode, - category: accessory.category, - }); -}); - -const signals = { "SIGINT": 2, "SIGTERM": 15 } as Record; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -Object.keys(signals).forEach((signal: any) => { - process.on(signal, () => { - Promise.all(accessories.map(a => a.unpublish())) - .then(() => setTimeout(() => process.exit(128 + signals[signal]), 1000)); - }); -}); From eddf940e09526b86e454723d6da58b1fb5a1c12b Mon Sep 17 00:00:00 2001 From: HJD Date: Wed, 10 Jul 2024 08:43:56 -0500 Subject: [PATCH 3/5] Remove long-deprecated Camera options. --- src/types.ts | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/types.ts b/src/types.ts index b5452ab1f..179a1cfd0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -82,40 +82,6 @@ export type PrimitiveTypes = string | number | boolean; */ export type CharacteristicValue = PrimitiveTypes | PrimitiveTypes[] | { [key: string]: PrimitiveTypes }; -/** - * @group Camera - * @deprecated replaced by {@link AudioStreamingCodec} - */ -export type AudioCodec = { - samplerate: number; - type: string; -} -/** - * @group Camera - * @deprecated replaced by {@link H264CodecParameters} - */ -export type VideoCodec = { - levels: number[]; - profiles: number[]; -} -/** - * @group Camera - * @deprecated replaced by {@link AudioStreamingOptions} - */ -export type StreamAudioParams = { - comfort_noise: boolean; - // noinspection JSDeprecatedSymbols - codecs: AudioCodec[]; -}; -/** - * @group Camera - * @deprecated replaced by {@link VideoStreamingOptions} - */ -export type StreamVideoParams = { - // noinspection JSDeprecatedSymbols - codec?: VideoCodec; - resolutions: [number, number, number][]; // width, height, framerate -}; /** * @group HAP Accessory Server @@ -262,9 +228,6 @@ export interface CharacteristicWrite { ev?: boolean, // enable/disable event notifications for the accessory authData?: string, // base64 encoded string used for custom authorisation - /** - * @deprecated This indicated if access was done via the old iCloud relay - */ remote?: boolean, // remote access used r?: boolean, // write response } From b32b64330239a342c7e6658507db6e5b299ff514 Mon Sep 17 00:00:00 2001 From: HJD Date: Wed, 10 Jul 2024 11:08:54 -0500 Subject: [PATCH 4/5] Linting. --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index f911f6978..910afda05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,6 @@ import "source-map-support/register"; // registering node-source-map-support for typescript stack traces import "./lib/definitions"; // must be loaded before Characteristic and Service class import createDebug from "debug"; -import { HAPStorage } from "./lib/model/HAPStorage"; /** * @group Utils From 0949c451de2e0f0128c15f896b9a25304870f7be Mon Sep 17 00:00:00 2001 From: HJD Date: Wed, 10 Jul 2024 16:41:44 -0500 Subject: [PATCH 5/5] Deprecation cleanup. --- src/index.ts | 5 - src/lib/Accessory.spec.ts | 40 +-- src/lib/Accessory.ts | 135 +--------- src/lib/AccessoryLoader.ts | 197 -------------- src/lib/Advertiser.ts | 6 +- src/lib/Characteristic.spec.ts | 26 -- src/lib/Characteristic.ts | 213 +-------------- src/lib/HAPServer.ts | 15 -- src/lib/Service.ts | 56 ---- src/lib/camera/Camera.ts | 92 ------- src/lib/camera/RTPStreamManagement.ts | 85 +----- src/lib/camera/index.ts | 1 - src/lib/controller/CameraController.spec.ts | 47 ---- src/lib/controller/CameraController.ts | 11 - src/lib/controller/RemoteController.ts | 17 -- src/lib/datastream/DataStreamServer.ts | 5 - .../CharacteristicDefinitions.spec.ts | 72 ----- .../definitions/CharacteristicDefinitions.ts | 254 +----------------- .../definitions/ServiceDefinitions.spec.ts | 103 ------- src/lib/definitions/ServiceDefinitions.ts | 111 -------- src/lib/util/tlv.spec.ts | 5 - src/lib/util/tlv.ts | 68 +---- src/lib/util/uuid.ts | 24 -- 23 files changed, 19 insertions(+), 1569 deletions(-) delete mode 100644 src/lib/AccessoryLoader.ts delete mode 100644 src/lib/camera/Camera.ts diff --git a/src/index.ts b/src/index.ts index 910afda05..50158e173 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,10 +2,6 @@ import "source-map-support/register"; // registering node-source-map-support for import "./lib/definitions"; // must be loaded before Characteristic and Service class import createDebug from "debug"; -/** - * @group Utils - */ -export * as AccessoryLoader from "./lib/AccessoryLoader"; /** * @group Utils */ @@ -15,7 +11,6 @@ export * from "./lib/Accessory"; export * from "./lib/Bridge"; export * from "./lib/Service"; export * from "./lib/Characteristic"; -export * from "./lib/AccessoryLoader"; export * from "./lib/camera"; export * from "./lib/tv/AccessControlManagement"; export * from "./lib/HAPServer"; diff --git a/src/lib/Accessory.spec.ts b/src/lib/Accessory.spec.ts index f462f0cb3..3eddf61cd 100644 --- a/src/lib/Accessory.spec.ts +++ b/src/lib/Accessory.spec.ts @@ -28,7 +28,7 @@ import { Units, } from "./Characteristic"; import { CameraController, Controller, ControllerIdentifier, ControllerServiceMap } from "./controller"; -import { createCameraControllerOptions, MOCK_IMAGE, MockLegacyCameraSource } from "./controller/CameraController.spec"; +import { createCameraControllerOptions, MOCK_IMAGE } from "./controller/CameraController.spec"; import { HAPHTTPCode, HAPStatus, IdentifyCallback, TLVErrorCode } from "./HAPServer"; import { AccessoryInfo, PairingInformation, PermissionTypes } from "./model/AccessoryInfo"; import { IdentifierCache } from "./model/IdentifierCache"; @@ -201,8 +201,7 @@ describe("Accessory", () => { expect(accessory.primaryService).toBe(instance); const outlet = new Service.Outlet("Outlet"); - // noinspection JSDeprecatedSymbols - accessory.setPrimaryService(outlet); + outlet.setPrimaryService(); accessory.addService(outlet); // @ts-expect-error: private access @@ -307,41 +306,6 @@ describe("Accessory", () => { expect(restoredAccessory.getService(Service.Outlet)).toBeDefined(); expect(restoredAccessory.getService(Service.Switch)).toBeUndefined(); }); - - test("legacy configure camera source", async () => { - const microphone = new Service.Microphone(); - const source = new MockLegacyCameraSource(2); - source.services.push(microphone); - - const expectedOptions = source.streamControllers[0].options; - - // noinspection JSDeprecatedSymbols - accessory.configureCameraSource(source); - - expect(accessory.getServiceById(Service.CameraRTPStreamManagement, "0")).toBeDefined(); - expect(accessory.getServiceById(Service.CameraRTPStreamManagement, "1")).toBeDefined(); - expect(accessory.getService(Service.Microphone)).toBe(microphone); - - // @ts-expect-error: private access - const cameraController = accessory.activeCameraController!; - expect(cameraController).toBeDefined(); - - // @ts-expect-error: private access - expect(cameraController.streamCount).toEqual(2); - // @ts-expect-error: private access - expect(cameraController.streamingOptions).toEqual(expectedOptions); - - // @ts-expect-error: private access - accessory.handleResource({ - "resource-type": ResourceRequestType.IMAGE, - "image-width": 200, - "image-height": 200, - }, callback); - - await callbackPromise; - - expect(callback).toHaveBeenCalledWith(undefined, MOCK_IMAGE); - }); }); describe("publish", () => { diff --git a/src/lib/Accessory.ts b/src/lib/Accessory.ts index 5b09318d4..1784fec42 100644 --- a/src/lib/Accessory.ts +++ b/src/lib/Accessory.ts @@ -1,5 +1,4 @@ import assert from "assert"; -import { MulticastOptions } from "bonjour-hap"; import crypto from "crypto"; import createDebug from "debug"; import { EventEmitter } from "events"; @@ -30,7 +29,6 @@ import { } from "../types"; import { Advertiser, AdvertiserEvent, AvahiAdvertiser, BonjourHAPAdvertiser, CiaoAdvertiser, ResolvedAdvertiser } from "./Advertiser"; // noinspection JSDeprecatedSymbols -import { LegacyCameraSource, LegacyCameraSourceAdapter, StreamController } from "./camera"; import { Access, ChangeReason, @@ -42,7 +40,6 @@ import { } from "./Characteristic"; import { CameraController, - CameraControllerOptions, Controller, ControllerConstructor, ControllerIdentifier, @@ -188,13 +185,6 @@ export interface CharacteristicWarning { stack?: string, } -/** - * @group Characteristic - * @deprecated - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export type CharacteristicEvents = Record; - /** * @group Accessory */ @@ -268,11 +258,6 @@ export interface PublishInfo { * When undefined port 0 will be used resulting in a random port. */ port?: number; - /** - * Used to define custom MDNS options. Is not used anymore. - * @deprecated - */ - mdns?: MulticastOptions; /** * If this option is set to true, HAP-NodeJS will add identifying material (based on {@link username}) * to the end of the accessory display name (and bonjour instance name). @@ -283,11 +268,6 @@ export interface PublishInfo { * Defines the advertiser used with the published Accessory. */ advertiser?: MDNSAdvertiser; - /** - * Use the legacy bonjour-hap as advertiser. - * @deprecated - */ - useLegacyAdvertiser?: boolean; } /** @@ -336,13 +316,6 @@ const enum WriteRequestState { TIMED_WRITE_REJECTED } -// noinspection JSUnusedGlobalSymbols -/** - * @deprecated Use AccessoryEventTypes instead - * @group Accessory - */ -export type EventAccessory = "identify" | "listening" | "service-configurationChange" | "service-characteristic-change"; - /** * @group Accessory */ @@ -421,15 +394,9 @@ export declare interface Accessory { */ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging export class Accessory extends EventEmitter { - /** - * @deprecated Please use the Categories const enum above. - */ - // @ts-expect-error: forceConsistentCasingInFileNames compiler option - static Categories = Categories; - - /// Timeout in milliseconds until a characteristic warning is issue + // Timeout in milliseconds until a characteristic warning is issue private static readonly TIMEOUT_WARNING = 3000; - /// Timeout in milliseconds after `TIMEOUT_WARNING` until the operation on the characteristic is considered timed out. + // Timeout in milliseconds after `TIMEOUT_WARNING` until the operation on the characteristic is considered timed out. private static readonly TIMEOUT_AFTER_WARNING = 6000; // NOTICE: when adding/changing properties, remember to possibly adjust the serialize/deserialize functions @@ -591,13 +558,6 @@ export class Accessory extends EventEmitter { return service; } - /** - * @deprecated use {@link Service.setPrimaryService} directly - */ - public setPrimaryService(service: Service): void { - service.setPrimaryService(); - } - public removeService(service: Service): void { const index = this.services.indexOf(service); @@ -665,18 +625,6 @@ export class Accessory extends EventEmitter { return this.bridged? this.bridge!: this; }; - /** - * @deprecated Not supported anymore - */ - public updateReachability(reachable: boolean): void { - if (!this.bridged) { - throw new Error("Cannot update reachability on non-bridged accessory!"); - } - this.reachable = reachable; - - debug("Reachability update is no longer being supported."); - } - public addBridgedAccessory(accessory: Accessory, deferUpdate = false): Accessory { if (accessory._isBridge || accessory === this) { throw new Error("Illegal state: either trying to bridge a bridge or trying to bridge itself!"); @@ -778,63 +726,6 @@ export class Accessory extends EventEmitter { return accessory && accessory.getCharacteristicByIID(iid); } - // noinspection JSDeprecatedSymbols - /** - * Method is used to configure an old style CameraSource. - * The CameraSource API was fully replaced by the new Controller API used by {@link CameraController}. - * The {@link CameraStreamingDelegate} used by the CameraController is the equivalent to the old CameraSource. - * - * The new Controller API is much more refined and robust way of "grouping" services together. - * It especially is intended to fully support serialization/deserialization to/from persistent storage. - * This feature is also gained when using the old style CameraSource API. - * The {@link CameraStreamingDelegate} improves on the overall camera API though and provides some reworked - * type definitions and a refined callback interface to better signal errors to the requesting HomeKit device. - * It is advised to update to it. - * - * Full backwards compatibility is currently maintained. A legacy CameraSource will be wrapped into an Adapter. - * All legacy StreamControllers in the "streamControllers" property will be replaced by CameraRTPManagement instances. - * Any services in the "services" property which are one of the following are ignored: - * - CameraRTPStreamManagement - * - CameraOperatingMode - * - CameraEventRecordingManagement - * - * @param cameraSource - The instance of the legacy camera source - * @deprecated please refer to the new {@link CameraController} API and {@link configureController} - */ - public configureCameraSource(cameraSource: LegacyCameraSource): CameraController { - if (cameraSource.streamControllers.length === 0) { - throw new Error("Malformed legacy CameraSource. Did not expose any StreamControllers!"); - } - - const options = cameraSource.streamControllers[0].options; // grab options from one of the StreamControllers - const cameraControllerOptions: CameraControllerOptions = { // build new options set - cameraStreamCount: cameraSource.streamControllers.length, - streamingOptions: options, - delegate: new LegacyCameraSourceAdapter(cameraSource), - }; - - const cameraController = new CameraController(cameraControllerOptions, true); // create CameraController in legacy mode - this.configureController(cameraController); - - // we try here to be as good as possibly of keeping current behaviour - cameraSource.services.forEach(service => { - if (service.UUID === Service.CameraRTPStreamManagement.UUID || service.UUID === Service.CameraOperatingMode.UUID - || service.UUID === Service.CameraRecordingManagement.UUID) { - return; // ignore those services, as they get replaced by the RTPStreamManagement - } - - // all other services get added. We can't really control possibly linking to any of those ignored services - // so this is really only half-baked stuff. - this.addService(service); - }); - - // replace stream controllers; basically only to still support the "forceStop" call - // noinspection JSDeprecatedSymbols - cameraSource.streamControllers = cameraController.streamManagements as StreamController[]; - - return cameraController; // return the reference for the controller (maybe this could be useful?) - } - /** * This method is used to set up a new Controller for this accessory. See {@link Controller} for a more detailed * explanation what a Controller is and what it is capable of. @@ -1213,21 +1104,6 @@ export class Accessory extends EventEmitter { throw new Error("Can't publish in accessory which is bridged by another accessory. Bridged by " + this.bridge?.displayName); } - // noinspection JSDeprecatedSymbols - if (!info.advertiser && info.useLegacyAdvertiser != null) { - // noinspection JSDeprecatedSymbols - info.advertiser = info.useLegacyAdvertiser? MDNSAdvertiser.BONJOUR: MDNSAdvertiser.CIAO; - console.warn("DEPRECATED The PublishInfo.useLegacyAdvertiser option has been removed. " + - "Please use the PublishInfo.advertiser property to enable \"ciao\" (useLegacyAdvertiser=false) " + - "or \"bonjour-hap\" (useLegacyAdvertiser=true) mdns advertiser libraries!"); - } - - // noinspection JSDeprecatedSymbols - if (info.mdns && info.advertiser !== MDNSAdvertiser.BONJOUR) { - console.log("DEPRECATED user supplied a custom 'mdns' option. This option is deprecated and ignored. " + - "Please move to the new 'bind' option."); - } - let service = this.getService(Service.ProtocolInformation); if (!service) { service = this.addService(Service.ProtocolInformation); // add the protocol information service to the primary accessory @@ -1332,8 +1208,7 @@ export class Accessory extends EventEmitter { }); break; case MDNSAdvertiser.BONJOUR: - // noinspection JSDeprecatedSymbols - this._advertiser = new BonjourHAPAdvertiser(this._accessoryInfo, info.mdns, { + this._advertiser = new BonjourHAPAdvertiser(this._accessoryInfo, { restrictedAddresses: parsed.serviceRestrictedAddress, disabledIpv6: parsed.serviceDisableIpv6, }); @@ -1960,10 +1835,6 @@ export class Accessory extends EventEmitter { } private handleHAPConnectionClosed(connection: HAPConnection): void { - if (this.activeCameraController) { - this.activeCameraController.handleCloseConnection(connection.sessionID); - } - for (const event of connection.getRegisteredEvents()) { const ids = event.split("."); const aid = parseInt(ids[0], 10); diff --git a/src/lib/AccessoryLoader.ts b/src/lib/AccessoryLoader.ts deleted file mode 100644 index 172a24263..000000000 --- a/src/lib/AccessoryLoader.ts +++ /dev/null @@ -1,197 +0,0 @@ -import createDebug from "debug"; -import fs from "fs"; -import path from "path"; -import { CharacteristicValue, Nullable } from "../types"; -import { Accessory } from "./Accessory"; -import { - Characteristic, - CharacteristicEventTypes, - CharacteristicGetCallback, - CharacteristicSetCallback, -} from "./Characteristic"; -import { Service } from "./Service"; -import * as uuid from "./util/uuid"; - -const debug = createDebug("HAP-NodeJS:AccessoryLoader"); - -/** - * @group Utils - * @deprecated Legacy Accessory Loader - */ -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any -export function parseCharacteristicJSON(json: any): Characteristic { - const characteristicUUID = json.cType; - - const characteristic = new Characteristic(json.manfDescription || characteristicUUID, characteristicUUID, { - format: json.format, // example: "int" - minValue: json.designedMinValue, - maxValue: json.designedMaxValue, - minStep: json.designedMinStep, - unit: json.unit, - perms: json.perms, // example: ["pw","pr","ev"] - }); - - // copy simple properties - characteristic.value = json.initialValue; - - // @ts-expect-error: monkey-patch legacy "locals" property which used to exist. - characteristic.locals = json.locals; - - const updateFunc = json.onUpdate; // optional function(value) - const readFunc = json.onRead; // optional function(callback(value)) - const registerFunc = json.onRegister; // optional function - - if (updateFunc) { - characteristic.on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => { - updateFunc(value); - callback && callback(); - }); - } - - if (readFunc) { - characteristic.on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - readFunc((value: any) => { - callback(null, value); // old onRead callbacks don't use Error as first param - }); - }); - } - - if (registerFunc) { - registerFunc(characteristic); - } - - return characteristic; -} - -/** - * @group Utils - * @deprecated Legacy Accessory Loader - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types -export function parseServiceJSON(json: any): Service { - const serviceUUID = json.sType; - - // build characteristics first, so we can extract the Name (if present) - const characteristics: Characteristic[] = []; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - json.characteristics.forEach((characteristicJSON: any) => { - const characteristic = parseCharacteristicJSON(characteristicJSON); - characteristics.push(characteristic); - }); - - let displayName: Nullable = null; - - // extract the "Name" characteristic to use for 'type' discrimination if necessary - characteristics.forEach((characteristic) => { - if (characteristic.UUID === "00000023-0000-1000-8000-0026BB765291") { // Characteristic.Name.UUID - displayName = characteristic.value; - } - }); - - // Use UUID for "displayName" if necessary, as the JSON structures don't have a value for this - const service = new Service(displayName || serviceUUID, serviceUUID, `${displayName}`); - - characteristics.forEach((characteristic) => { - if (characteristic.UUID !== "00000023-0000-1000-8000-0026BB765291") { // Characteristic.Name.UUID, already present in all Services - service.addCharacteristic(characteristic); - } - }); - - return service; -} - - -/** - * Accepts object-literal JSON structures from previous versions of HAP-NodeJS and parses them into - * newer-style structures of Accessory/Service/Characteristic objects. - * @group Utils - * @deprecated Legacy Accessory Loader - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types -export function parseAccessoryJSON(json: any): Accessory { - - // parse services first so we can extract the accessory name - const services: Service[] = []; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - json.services.forEach((serviceJSON: any) => { - const service = parseServiceJSON(serviceJSON); - services.push(service); - }); - - let displayName = json.displayName; - - services.forEach((service) => { - if (service.UUID === "0000003E-0000-1000-8000-0026BB765291") { // Service.AccessoryInformation.UUID - service.characteristics.forEach((characteristic) => { - if (characteristic.UUID === "00000023-0000-1000-8000-0026BB765291") {// Characteristic.Name.UUID - displayName = characteristic.value; - } - }); - } - }); - - const accessory = new Accessory(displayName, uuid.generate(displayName)); - - // create custom properties for "username" and "pincode" for Core.js to find later (if using Core.js) - // @ts-expect-error: Core/BridgeCore API - accessory.username = json.username; - // @ts-expect-error: Core/BridgeCore API - accessory.pincode = json.pincode; - - // clear out the default services - accessory.services.length = 0; - - // add services - services.forEach((service) => { - accessory.addService(service); - }); - - return accessory; -} - -/** - * Loads all accessories from the given folder. Handles object-literal-style accessories, "accessory factories", - * and new-API style modules. - * @group Utils - * @deprecated Legacy Accessory Loader - */ -export function loadDirectory(dir: string): Accessory[] { - - // exported accessory objects loaded from this dir - let accessories: unknown[] = []; - - fs.readdirSync(dir).forEach((file) => { - const suffix = file.split("_").pop(); - - // "Accessories" are modules that export a single accessory. - if (suffix === "accessory.js" || suffix === "accessory.ts") { - debug("Parsing accessory: %s", file); - // eslint-disable-next-line @typescript-eslint/no-var-requires - const loadedAccessory = require(path.join(dir, file)).accessory; - accessories.push(loadedAccessory); - } else if (suffix === "accfactory.js" ||suffix === "accfactory.ts") { // "Accessory Factories" are modules that export an array of accessories. - debug("Parsing accessory factory: %s", file); - - // should return an array of objects { accessory: accessory-json } - // eslint-disable-next-line @typescript-eslint/no-var-requires - const loadedAccessories = require(path.join(dir, file)); - accessories = accessories.concat(loadedAccessories); - } - }); - - // now we need to coerce all accessory objects into instances of Accessory (some or all of them may - // be object-literal JSON-style accessories) - return accessories.map((accessory) => { - if(accessory === null || accessory === undefined) { //check if accessory is not empty - console.log("Invalid accessory!"); - return false; - } else { - return (accessory instanceof Accessory) ? accessory : parseAccessoryJSON(accessory); - } - }).filter((accessory: Accessory | false) => { - return !!accessory; - }) as Accessory[]; -} diff --git a/src/lib/Advertiser.ts b/src/lib/Advertiser.ts index 2ec2a23a4..301e075c8 100644 --- a/src/lib/Advertiser.ts +++ b/src/lib/Advertiser.ts @@ -4,7 +4,7 @@ import ciao, { CiaoService, MDNSServerOptions, Responder, ServiceEvent, ServiceT import { InterfaceName, IPAddress } from "@homebridge/ciao/lib/NetworkManager"; import dbus, { DBusInterface, MessageBus } from "@homebridge/dbus-native"; import assert from "assert"; -import bonjour, { BonjourHAP, BonjourHAPService, MulticastOptions } from "bonjour-hap"; +import bonjour, { BonjourHAP, BonjourHAPService } from "bonjour-hap"; import crypto from "crypto"; import createDebug from "debug"; import { EventEmitter } from "events"; @@ -216,13 +216,13 @@ export class BonjourHAPAdvertiser extends EventEmitter implements Advertiser { private port?: number; private destroyed = false; - constructor(accessoryInfo: AccessoryInfo, responderOptions?: MulticastOptions, serviceOptions?: ServiceNetworkOptions) { + constructor(accessoryInfo: AccessoryInfo, serviceOptions?: ServiceNetworkOptions) { super(); this.accessoryInfo = accessoryInfo; this.setupHash = CiaoAdvertiser.computeSetupHash(accessoryInfo); this.serviceOptions = serviceOptions; - this.bonjour = bonjour(responderOptions); + this.bonjour = bonjour(); debug(`Preparing Advertiser for '${this.accessoryInfo.displayName}' using bonjour-hap backend!`); } diff --git a/src/lib/Characteristic.spec.ts b/src/lib/Characteristic.spec.ts index 5c8825cc1..5bf0e5994 100644 --- a/src/lib/Characteristic.spec.ts +++ b/src/lib/Characteristic.spec.ts @@ -1102,20 +1102,6 @@ describe("Characteristic", () => { expect(characteristic.validateUserInput(VALUE)).toEqual(VALUE); }); - it("should validate a dictionary property", () => { - const VALUE = {}; - const characteristic = createCharacteristic(Formats.DICTIONARY); - // @ts-expect-error: private access - expect(characteristic.validateUserInput(VALUE)).toEqual(VALUE); - }); - - it("should validate an array property", () => { - const VALUE = ["asd"]; - const characteristic = createCharacteristic(Formats.ARRAY); - // @ts-expect-error: private access - expect(characteristic.validateUserInput(VALUE)).toEqual(VALUE); - }); - it("should validate boolean inputs", () => { const characteristic = createCharacteristicWithProps({ format: Formats.BOOL, @@ -1619,18 +1605,6 @@ describe("Characteristic", () => { expect(characteristic.getDefaultValue()).toEqual(""); }); - it("should get the correct default value for a dictionary property", () => { - const characteristic = createCharacteristic(Formats.DICTIONARY); - // @ts-expect-error: private access - expect(characteristic.getDefaultValue()).toEqual({}); - }); - - it("should get the correct default value for an array property", () => { - const characteristic = createCharacteristic(Formats.ARRAY); - // @ts-expect-error: private access - expect(characteristic.getDefaultValue()).toEqual([]); - }); - it("should get the correct default value a UINT8 property without minValue", () => { const characteristic = createCharacteristicWithProps({ format: Formats.UINT8, diff --git a/src/lib/Characteristic.ts b/src/lib/Characteristic.ts index 6aa78036e..b33f61426 100644 --- a/src/lib/Characteristic.ts +++ b/src/lib/Characteristic.ts @@ -30,7 +30,6 @@ import type { CarbonMonoxideDetected, CarbonMonoxideLevel, CarbonMonoxidePeakLevel, - Category, CCAEnergyDetectThreshold, CCASignalDetectThreshold, CharacteristicValueActiveTransitionCount, @@ -39,8 +38,6 @@ import type { ClosedCaptions, ColorTemperature, ConfigurationState, - ConfigureBridgedAccessory, - ConfigureBridgedAccessoryStatus, ConfiguredName, ContactSensorState, CoolingThresholdTemperature, @@ -59,17 +56,13 @@ import type { CurrentSlatState, CurrentTemperature, CurrentTiltAngle, - CurrentTime, CurrentTransport, CurrentVerticalTiltAngle, CurrentVisibilityState, DataStreamHAPTransport, DataStreamHAPTransportInterrupt, - DayoftheWeek, DiagonalFieldOfView, DigitalZoom, - DiscoverBridgedAccessories, - DiscoveredBridgedAccessories, DisplayOrder, EventRetransmissionMaximum, EventSnapshotsActive, @@ -95,7 +88,6 @@ import type { InUse, IsConfigured, LeakDetected, - LinkQuality, ListPairings, LockControlPoint, LockCurrentState, @@ -145,7 +137,6 @@ import type { ProgrammableSwitchEvent, ProgrammableSwitchOutputState, ProgramMode, - Reachable, ReceivedSignalStrengthIndication, ReceiverSensitivity, RecordingAudioActive, @@ -216,7 +207,6 @@ import type { SwingMode, TapType, TargetAirPurifierState, - TargetAirQuality, TargetControlList, TargetControlSupportedConfiguration, TargetDoorState, @@ -228,7 +218,6 @@ import type { TargetMediaState, TargetPosition, TargetRelativeHumidity, - TargetSlatState, TargetTemperature, TargetTiltAngle, TargetVerticalTiltAngle, @@ -239,7 +228,6 @@ import type { ThreadNodeCapabilities, ThreadOpenThreadVersion, ThreadStatus, - TimeUpdate, Token, TransmitPower, TunnelConnectionTimeout, @@ -320,15 +308,7 @@ export const enum Formats { /** * Base64 encoded tlv8 string. */ - TLV8 = "tlv8", - /** - * @deprecated Not contained in the HAP spec - */ - ARRAY = "array", - /** - * @deprecated Not contained in the HAP spec - */ - DICTIONARY = "dict", + TLV8 = "tlv8" } /** @@ -351,15 +331,6 @@ export const enum Units { * @group Characteristic */ export const enum Perms { - // noinspection JSUnusedGlobalSymbols - /** - * @deprecated replaced by {@link PAIRED_READ}. Kept for backwards compatibility. - */ - READ = "pr", - /** - * @deprecated replaced by {@link PAIRED_WRITE}. Kept for backwards compatibility. - */ - WRITE = "pw", // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values PAIRED_READ = "pr", // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values @@ -701,22 +672,6 @@ function minWithUndefined(a?: number, b?: number): number | undefined { // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging export class Characteristic extends EventEmitter { - /** - * @deprecated Please use the Formats const enum above. - */ - // @ts-expect-error: forceConsistentCasingInFileNames compiler option - static Formats = Formats; - /** - * @deprecated Please use the Units const enum above. - */ - // @ts-expect-error: forceConsistentCasingInFileNames compiler option - static Units = Units; - /** - * @deprecated Please use the Perms const enum above. - */ - // @ts-expect-error: forceConsistentCasingInFileNames compiler option - static Perms = Perms; - // Pattern below is for automatic detection of the section of defined characteristics. Used by the generator // -=-=-=-=-=-=-=-=-=-=-=-=-=-=- /** @@ -823,11 +778,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static CarbonMonoxidePeakLevel: typeof CarbonMonoxidePeakLevel; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static Category: typeof Category; /** * @group Characteristic Definitions */ @@ -860,16 +810,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static ConfigurationState: typeof ConfigurationState; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static ConfigureBridgedAccessory: typeof ConfigureBridgedAccessory; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static ConfigureBridgedAccessoryStatus: typeof ConfigureBridgedAccessoryStatus; /** * @group Characteristic Definitions */ @@ -942,11 +882,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static CurrentTiltAngle: typeof CurrentTiltAngle; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static CurrentTime: typeof CurrentTime; /** * @group Characteristic Definitions */ @@ -967,11 +902,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static DataStreamHAPTransportInterrupt: typeof DataStreamHAPTransportInterrupt; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static DayoftheWeek: typeof DayoftheWeek; /** * @group Characteristic Definitions */ @@ -980,16 +910,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static DigitalZoom: typeof DigitalZoom; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static DiscoverBridgedAccessories: typeof DiscoverBridgedAccessories; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static DiscoveredBridgedAccessories: typeof DiscoveredBridgedAccessories; /** * @group Characteristic Definitions */ @@ -1090,11 +1010,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static LeakDetected: typeof LeakDetected; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static LinkQuality: typeof LinkQuality; /** * @group Characteristic Definitions */ @@ -1291,11 +1206,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static ProgramMode: typeof ProgramMode; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static Reachable: typeof Reachable; /** * @group Characteristic Definitions */ @@ -1576,11 +1486,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static TargetAirPurifierState: typeof TargetAirPurifierState; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static TargetAirQuality: typeof TargetAirQuality; /** * @group Characteristic Definitions */ @@ -1625,11 +1530,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static TargetRelativeHumidity: typeof TargetRelativeHumidity; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static TargetSlatState: typeof TargetSlatState; /** * @group Characteristic Definitions */ @@ -1670,11 +1570,6 @@ export class Characteristic extends EventEmitter { * @group Characteristic Definitions */ public static ThreadStatus: typeof ThreadStatus; - /** - * @group Characteristic Definitions - * @deprecated Removed and not used anymore - */ - public static TimeUpdate: typeof TimeUpdate; /** * @group Characteristic Definitions */ @@ -1762,11 +1657,6 @@ export class Characteristic extends EventEmitter { public UUID: string; iid: Nullable = null; value: Nullable = null; - /** - * @deprecated replaced by {@link statusCode} - * @private - */ - status: Nullable = null; /** * @private */ @@ -2124,27 +2014,6 @@ export class Characteristic extends EventEmitter { this.additionalAuthorizationHandler = handler; } - /** - * Updates the current value of the characteristic. - * - * @param callback - * @param context - * @private use to return the current value on HAP requests - * - * @deprecated - */ - getValue(callback?: CharacteristicGetCallback, context?: CharacteristicContext): void { - this.handleGetRequest(undefined, context).then(value => { - if (callback) { - callback(null, value); - } - }, reason => { - if (callback) { - callback(reason); - } - }); - } - /** * This updates the value by calling the {@link CharacteristicEventTypes.SET} event handler associated with the characteristic. * This acts the same way as when a HomeKit controller sends a `/characteristics` request to update the characteristic. @@ -2182,23 +2051,6 @@ export class Characteristic extends EventEmitter { * any {@link onGet} or {@link CharacteristicEventTypes.GET} handlers have precedence. */ setValue(error: HapStatusError | Error): Characteristic; - /** - * This updates the value by calling the {@link CharacteristicEventTypes.SET} event handler associated with the characteristic. - * This acts the same way as when a HomeKit controller sends a `/characteristics` request to update the characteristic. - * An event notification will be sent to all connected HomeKit controllers which are registered - * to receive event notifications for this characteristic. - * - * This method behaves like a {@link updateValue} call with the addition that the own {@link CharacteristicEventTypes.SET} - * event handler is called. - * - * @param value - The new value. - * @param callback - Deprecated parameter there to provide backwards compatibility. Called once the - * {@link CharacteristicEventTypes.SET} event handler returns. - * @param context - Passed to the {@link CharacteristicEventTypes.SET} and {@link CharacteristicEventTypes.CHANGE} event handler. - * - * @deprecated Parameter `callback` is deprecated. - */ - setValue(value: CharacteristicValue, callback?: CharacteristicSetCallback, context?: CharacteristicContext): Characteristic /** * This updates the value by calling the {@link CharacteristicEventTypes.SET} event handler associated with the characteristic. * This acts the same way as when a HomeKit controller sends a `/characteristics` request to update the characteristic. @@ -2217,8 +2069,6 @@ export class Characteristic extends EventEmitter { setValue(value: CharacteristicValue | Error, callback?: CharacteristicSetCallback, context?: CharacteristicContext): Characteristic { if (value instanceof Error) { this.statusCode = value instanceof HapStatusError? value.hapStatus: extractHAPStatusFromError(value); - // noinspection JSDeprecatedSymbols - this.status = value; if (callback) { callback(); @@ -2294,17 +2144,6 @@ export class Characteristic extends EventEmitter { * any {@link onGet} or {@link CharacteristicEventTypes.GET} handlers have precedence. */ updateValue(error: Error | HapStatusError): Characteristic; - /** - * This updates the value of the characteristic. If the value changed, an event notification will be sent to all connected - * HomeKit controllers which are registered to receive event notifications for this characteristic. - * - * @param value - The new value. - * @param callback - Deprecated parameter there to provide backwards compatibility. Callback is called instantly. - * @param context - Passed to the {@link CharacteristicEventTypes.CHANGE} event handler. - * - * @deprecated Parameter `callback` is deprecated. - */ - updateValue(value: Nullable, callback?: () => void, context?: CharacteristicContext): Characteristic; /** * This updates the value of the characteristic. If the value changed, an event notification will be sent to all connected * HomeKit controllers which are registered to receive event notifications for this characteristic. @@ -2316,8 +2155,6 @@ export class Characteristic extends EventEmitter { updateValue(value: Nullable | Error | HapStatusError, callback?: () => void, context?: CharacteristicContext): Characteristic { if (value instanceof Error) { this.statusCode = value instanceof HapStatusError? value.hapStatus: extractHAPStatusFromError(value); - // noinspection JSDeprecatedSymbols - this.status = value; if (callback) { callback(); @@ -2341,8 +2178,6 @@ export class Characteristic extends EventEmitter { } this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; const oldValue = this.value; this.value = value; @@ -2367,8 +2202,6 @@ export class Characteristic extends EventEmitter { */ public sendEventNotification(value: CharacteristicValue, context?: CharacteristicContext): Characteristic { this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; value = this.validateUserInput(value)!; const oldValue = this.value; @@ -2404,8 +2237,6 @@ export class Characteristic extends EventEmitter { try { let value = await this.getHandler(context, connection); this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; try { value = this.validateUserInput(value); @@ -2413,8 +2244,6 @@ export class Characteristic extends EventEmitter { this.characteristicWarning(`An illegal value was supplied by the read handler for characteristic: ${error?.message}`, CharacteristicWarningType.WARN_MESSAGE, error?.stack); this.statusCode = HAPStatus.SERVICE_COMMUNICATION_FAILURE; - // noinspection JSDeprecatedSymbols - this.status = error; return Promise.reject(HAPStatus.SERVICE_COMMUNICATION_FAILURE); } @@ -2433,18 +2262,12 @@ export class Characteristic extends EventEmitter { if (typeof error === "number") { const hapStatusError = new HapStatusError(error); this.statusCode = hapStatusError.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = hapStatusError; } else if (error instanceof HapStatusError) { this.statusCode = error.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = error; } else { this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, CharacteristicWarningType.ERROR_MESSAGE, error?.stack); this.statusCode = HAPStatus.SERVICE_COMMUNICATION_FAILURE; - // noinspection JSDeprecatedSymbols - this.status = error; } throw this.statusCode; } @@ -2471,25 +2294,17 @@ export class Characteristic extends EventEmitter { if (typeof status === "number") { const hapStatusError = new HapStatusError(status); this.statusCode = hapStatusError.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = hapStatusError; } else if (status instanceof HapStatusError) { this.statusCode = status.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = status; } else { debug("[%s] Received error from get handler %s", this.displayName, status.stack); this.statusCode = extractHAPStatusFromError(status); - // noinspection JSDeprecatedSymbols - this.status = status; } reject(this.statusCode); return; } this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; value = this.validateUserInput(value); const oldValue = this.value; @@ -2508,8 +2323,6 @@ export class Characteristic extends EventEmitter { this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, CharacteristicWarningType.ERROR_MESSAGE, error?.stack); this.statusCode = HAPStatus.SERVICE_COMMUNICATION_FAILURE; - // noinspection JSDeprecatedSymbols - this.status = error; reject(HAPStatus.SERVICE_COMMUNICATION_FAILURE); } }); @@ -2528,8 +2341,6 @@ export class Characteristic extends EventEmitter { */ async handleSetRequest(value: CharacteristicValue, connection?: HAPConnection, context?: CharacteristicContext): Promise { this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; if (connection !== undefined) { // if connection is undefined, the set "request" comes from the setValue method. @@ -2552,8 +2363,6 @@ export class Characteristic extends EventEmitter { try { const writeResponse = await this.setHandler(value, context, connection); this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; if (writeResponse != null && this.props.perms.includes(Perms.WRITE_RESPONSE)) { this.value = this.validateUserInput(writeResponse); @@ -2575,18 +2384,12 @@ export class Characteristic extends EventEmitter { if (typeof error === "number") { const hapStatusError = new HapStatusError(error); this.statusCode = hapStatusError.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = hapStatusError; } else if (error instanceof HapStatusError) { this.statusCode = error.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = error; } else { this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, CharacteristicWarningType.ERROR_MESSAGE, error?.stack); this.statusCode = HAPStatus.SERVICE_COMMUNICATION_FAILURE; - // noinspection JSDeprecatedSymbols - this.status = error; } throw this.statusCode; } @@ -2604,25 +2407,17 @@ export class Characteristic extends EventEmitter { if (typeof status === "number") { const hapStatusError = new HapStatusError(status); this.statusCode = hapStatusError.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = hapStatusError; } else if (status instanceof HapStatusError) { this.statusCode = status.hapStatus; - // noinspection JSDeprecatedSymbols - this.status = status; } else { debug("[%s] Received error from set handler %s", this.displayName, status.stack); this.statusCode = extractHAPStatusFromError(status); - // noinspection JSDeprecatedSymbols - this.status = status; } reject(this.statusCode); return; } this.statusCode = HAPStatus.SUCCESS; - // noinspection JSDeprecatedSymbols - this.status = null; if (writeResponse != null && this.props.perms.includes(Perms.WRITE_RESPONSE)) { // support write response simply by letting the implementor pass the response as second argument to the callback @@ -2646,8 +2441,6 @@ export class Characteristic extends EventEmitter { this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, CharacteristicWarningType.ERROR_MESSAGE, error?.stack); this.statusCode = HAPStatus.SERVICE_COMMUNICATION_FAILURE; - // noinspection JSDeprecatedSymbols - this.status = error; reject(HAPStatus.SERVICE_COMMUNICATION_FAILURE); } }); @@ -2701,10 +2494,6 @@ export class Characteristic extends EventEmitter { return ""; // who knows! case Formats.TLV8: return ""; // who knows! - case Formats.DICTIONARY: - return {}; - case Formats.ARRAY: - return []; case Formats.INT: case Formats.FLOAT: case Formats.UINT8: diff --git a/src/lib/HAPServer.ts b/src/lib/HAPServer.ts index f6abd7596..de3e29fa6 100644 --- a/src/lib/HAPServer.ts +++ b/src/lib/HAPServer.ts @@ -121,21 +121,6 @@ export function IsKnownHAPStatusError(status: HAPStatus): boolean { ); } -// noinspection JSUnusedGlobalSymbols -/** - * @group HAP Accessory Server - * @deprecated please use {@link TLVErrorCode} as naming is more precise - */ -// @ts-expect-error (as we use const enums with --preserveConstEnums) -export const Codes = TLVErrorCode; -// noinspection JSUnusedGlobalSymbols -/** - * @group HAP Accessory Server - * @deprecated please use {@link HAPStatus} as naming is more precise - */ -// @ts-expect-error (as we use const enums with --preserveConstEnums) -export const Status = HAPStatus; - /** * Those status codes are the one listed as appropriate for the HAP spec! * diff --git a/src/lib/Service.ts b/src/lib/Service.ts index 1dd05592f..99987a2ec 100644 --- a/src/lib/Service.ts +++ b/src/lib/Service.ts @@ -16,9 +16,6 @@ import type { Assistant, AudioStreamManagement, Battery, - BridgeConfiguration, - BridgingState, - CameraControl, CameraOperatingMode, CameraRecordingManagement, CameraRTPStreamManagement, @@ -73,7 +70,6 @@ import type { TemperatureSensor, Thermostat, ThreadTransport, - TimeInformation, TransferTransportManagement, Tunnel, Valve, @@ -124,13 +120,6 @@ export type ServiceId = string; */ export type ServiceCharacteristicChange = CharacteristicChange & { characteristic: Characteristic }; -// noinspection JSUnusedGlobalSymbols -/** - * @deprecated Use ServiceEventTypes instead - * @group Service - */ -export type EventService = ServiceEventTypes.CHARACTERISTIC_CHANGE | ServiceEventTypes.SERVICE_CONFIGURATION_CHANGE; - /** * @group Service */ @@ -226,31 +215,6 @@ export class Service extends EventEmitter { * @group Service Definitions */ public static Battery: typeof Battery; - /** - * @group Service Definitions - * @deprecated Please use {@link Service.Battery}. - */ - public static BatteryService: typeof Battery; - /** - * @group Service Definitions - * @deprecated Removed and not used anymore - */ - public static BridgeConfiguration: typeof BridgeConfiguration; - /** - * @group Service Definitions - * @deprecated Removed and not used anymore - */ - public static BridgingState: typeof BridgingState; - /** - * @group Service Definitions - * @deprecated This service has no usage anymore and will be ignored by iOS - */ - public static CameraControl: typeof CameraControl; - /** - * @group Service Definitions - * @deprecated Please use {@link Service.CameraRecordingManagement}. - */ - public static CameraEventRecordingManagement: typeof CameraRecordingManagement; /** * @group Service Definitions */ @@ -391,11 +355,6 @@ export class Service extends EventEmitter { * @group Service Definitions */ public static ProtocolInformation: typeof ProtocolInformation; - /** - * @group Service Definitions - * @deprecated Please use {@link Service.CloudRelay}. - */ - public static Relay: typeof CloudRelay; /** * @group Service Definitions */ @@ -412,11 +371,6 @@ export class Service extends EventEmitter { * @group Service Definitions */ public static SiriEndpoint: typeof SiriEndpoint; - /** - * @group Service Definitions - * @deprecated Please use {@link Service.Slats}. - */ - public static Slat: typeof Slats; /** * @group Service Definitions */ @@ -477,11 +431,6 @@ export class Service extends EventEmitter { * @group Service Definitions */ public static ThreadTransport: typeof ThreadTransport; - /** - * @group Service Definitions - * @deprecated Removed and not used anymore - */ - public static TimeInformation: typeof TimeInformation; /** * @group Service Definitions */ @@ -490,11 +439,6 @@ export class Service extends EventEmitter { * @group Service Definitions */ public static Tunnel: typeof Tunnel; - /** - * @group Service Definitions - * @deprecated Please use {@link Service.Tunnel}. - */ - public static TunneledBTLEAccessoryService: typeof Tunnel; /** * @group Service Definitions */ diff --git a/src/lib/camera/Camera.ts b/src/lib/camera/Camera.ts deleted file mode 100644 index ed7d5c6db..000000000 --- a/src/lib/camera/Camera.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { Service } from "../Service"; -// noinspection JSDeprecatedSymbols -import { - CameraStreamingDelegate, - PrepareStreamCallback, - PrepareStreamRequest, - PrepareStreamResponse, - SnapshotRequest, - SnapshotRequestCallback, - StreamController, - StreamingRequest, - StreamRequest, - StreamRequestCallback, -} from "../.."; -import { NodeCallback, SessionIdentifier } from "../../types"; - -// noinspection JSDeprecatedSymbols -/** - * @group Camera - * @deprecated - */ -export type PreparedStreamRequestCallback = (response: PreparedStreamResponse) => void; -/** - * @group Camera - * @deprecated - */ -export type PreparedStreamResponse = PrepareStreamResponse; - -/** - * @group Camera - */ -// noinspection JSDeprecatedSymbols,JSUnusedGlobalSymbols -export type Camera = LegacyCameraSource; // provide backwards compatibility -// noinspection JSDeprecatedSymbols -/** - * Interface of and old style CameraSource. See {@link Accessory.configureCameraSource} for more Information. - * - * @group Camera - * @deprecated was replaced by {@link CameraStreamingDelegate} utilized by the {@link CameraController} - */ -export interface LegacyCameraSource { - - services: Service[]; - streamControllers: StreamController[]; - - handleSnapshotRequest(request: SnapshotRequest, callback: NodeCallback): void; - - prepareStream(request: PrepareStreamRequest, callback: PreparedStreamRequestCallback): void; - handleStreamRequest(request: StreamRequest): void; - - handleCloseConnection(connectionID: SessionIdentifier): void; - -} - -/** - * @group Camera - */ -// noinspection JSDeprecatedSymbols -export class LegacyCameraSourceAdapter implements CameraStreamingDelegate { - - private readonly cameraSource: LegacyCameraSource; - - constructor(cameraSource: LegacyCameraSource) { - this.cameraSource = cameraSource; - } - - handleSnapshotRequest(request: SnapshotRequest, callback: SnapshotRequestCallback): void { - this.cameraSource.handleSnapshotRequest(request, (error, buffer) => { - callback(error? error: undefined, buffer); - }); - } - - prepareStream(request: PrepareStreamRequest, callback: PrepareStreamCallback): void { - this.cameraSource.prepareStream(request, response => { - callback(undefined, response); - }); - } - - handleStreamRequest(request: StreamingRequest, callback: StreamRequestCallback): void { - // @ts-expect-error: compatible types - this.cameraSource.handleStreamRequest(request); - callback(); - } - - forwardCloseConnection(sessionID: SessionIdentifier): void { - // In the legacy type CameraSource API it was required that the plugin dev would forward this call to the - // handleCloseConnection of the "StreamController". This is not needed anymore and is automatically handled - // by HAP-NodeJS. However, devs could possibly define other stuff in there so we still forward this call. - this.cameraSource.handleCloseConnection(sessionID); - } - -} diff --git a/src/lib/camera/RTPStreamManagement.ts b/src/lib/camera/RTPStreamManagement.ts index bfcb11d91..18a753f0c 100644 --- a/src/lib/camera/RTPStreamManagement.ts +++ b/src/lib/camera/RTPStreamManagement.ts @@ -2,10 +2,10 @@ import assert from "assert"; import crypto from "crypto"; import createDebug from "debug"; import net from "net"; -import { CharacteristicValue, SessionIdentifier } from "../../types"; import { Access, Characteristic, CharacteristicEventTypes, CharacteristicSetCallback } from "../Characteristic"; import { CameraController, CameraStreamingDelegate, ResourceRequestReason, StateChangeDelegate } from "../controller"; import type { CameraRTPStreamManagement } from "../definitions"; +import { CharacteristicValue } from "../../types"; import { HAPStatus } from "../HAPServer"; import { Service } from "../Service"; import { HAPConnection, HAPConnectionEvent } from "../util/eventedhttp"; @@ -13,8 +13,6 @@ import { HapStatusError } from "../util/hapStatusError"; import { once } from "../util/once"; import * as tlv from "../util/tlv"; import * as uuid from "../util/uuid"; -// noinspection JSDeprecatedSymbols -import { LegacyCameraSource, LegacyCameraSourceAdapter } from "./Camera"; import RTPProxy from "./RTPProxy"; const debug = createDebug("HAP-NodeJS:Camera:RTPStreamManagement"); @@ -259,11 +257,6 @@ const enum AudioRTPParametersTypes { // ---------------------------------- TLV DEFINITIONS END ------------------------------------ -/** - * @group Camera - * @deprecated renamed to {@link CameraStreamingOptions} - */ -export type StreamControllerOptions = CameraStreamingOptions; /** * @group Camera */ @@ -417,11 +410,6 @@ export type Source = { * @group Camera */ export type PrepareStreamResponse = { - /** - * @deprecated The local ip address will be automatically determined by HAP-NodeJS. - * Any value set will be ignored. You may only still set a value to support version prior to 0.7.9 - */ - address?: string | Address; /** * Any value set to this optional property will overwrite the automatically determined local address, * which is sent as RTP endpoint to the iOS device. @@ -433,15 +421,6 @@ export type PrepareStreamResponse = { audio?: SourceResponse | ProxiedSourceResponse; } -/** - * @group Camera - * @deprecated just supply the address directly in {@link PrepareStreamRequest} - */ -export type Address = { - address: string; - type?: "v4" | "v6"; -} - /** * @group Camera */ @@ -476,16 +455,6 @@ export const enum StreamRequestTypes { * @group Camera */ export type StreamingRequest = StartStreamRequest | ReconfigureStreamRequest | StopStreamRequest; -/** - * @group Camera - * @deprecated replaced by {@link StreamingRequest} - */ -export type StreamRequest = { - sessionID: SessionIdentifier; - type: StreamRequestTypes; - video?: VideoInfo; - audio?: AudioInfo; -} /** * @group Camera @@ -579,21 +548,6 @@ export interface RTPStreamManagementState { * @group Camera */ export class RTPStreamManagement { - /** - * @deprecated Please use the SRTPCryptoSuites const enum above. - */ - // @ts-expect-error: forceConsistentCasingInFileNames compiler option - static SRTPCryptoSuites = SRTPCryptoSuites; - /** - * @deprecated Please use the H264Profile const enum above. - */ - // @ts-expect-error: forceConsistentCasingInFileNames compiler option - static VideoCodecParamProfileIDTypes = H264Profile; - /** - * @deprecated won't be updated anymore. Please use the H264Level const enum above. - */ - static VideoCodecParamLevelTypes = Object.freeze({ TYPE3_1: 0, TYPE3_2: 1, TYPE4_0: 2 }); - private readonly id: number; private readonly delegate: CameraStreamingDelegate; readonly service: CameraRTPStreamManagement; @@ -609,10 +563,6 @@ export class RTPStreamManagement { readonly supportedVideoStreamConfiguration: string; readonly supportedAudioStreamConfiguration: string; - /** - * @deprecated - */ - connectionID?: SessionIdentifier; private activeConnection?: HAPConnection; private readonly activeConnectionClosedListener: (callback?: CharacteristicSetCallback) => void; sessionIdentifier?: StreamSessionIdentifier = undefined; @@ -690,17 +640,6 @@ export class RTPStreamManagement { return this.service; } - // noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols - /** - * @deprecated - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - handleCloseConnection(connectionID: SessionIdentifier): void { - // This method is only here for legacy compatibility. It used to be called by legacy style CameraSource - // implementations to signal that the associated HAP connection was closed. - // This is now handled automatically. Thus, we don't need to do anything anymore. - } - handleFactoryReset(): void { this.resetSelectedStreamConfiguration(); this.resetSetupEndpointsResponse(); @@ -790,8 +729,6 @@ export class RTPStreamManagement { this._updateStreamStatus(StreamingStatus.AVAILABLE); this.sessionIdentifier = undefined; - // noinspection JSDeprecatedSymbols - this.connectionID = undefined; this.ipVersion = undefined; if (this.videoProxy) { @@ -1102,8 +1039,6 @@ export class RTPStreamManagement { this.activeConnection.setMaxListeners(this.activeConnection.getMaxListeners() + 1); this.activeConnection.on(HAPConnectionEvent.CLOSED, this.activeConnectionClosedListener); - // noinspection JSDeprecatedSymbols - this.connectionID = connection.sessionID; this.sessionIdentifier = sessionIdentifier; this._updateStreamStatus(StreamingStatus.IN_USE); @@ -1589,21 +1524,3 @@ export class RTPStreamManagement { } } -/** - * @group Camera - * @deprecated - only there for backwards compatibility, please use {@link RTPStreamManagement} directly - */ -export class StreamController extends RTPStreamManagement { - - /** - * options get saved so we can still support {@link Accessory.configureCameraSource} - */ - options: CameraStreamingOptions; - - // noinspection JSDeprecatedSymbols - constructor(id: number, options: CameraStreamingOptions, delegate: LegacyCameraSource, service?: CameraRTPStreamManagement) { - super(id, options, new LegacyCameraSourceAdapter(delegate), service); - this.options = options; - } - -} diff --git a/src/lib/camera/index.ts b/src/lib/camera/index.ts index db1350996..341a0ce87 100644 --- a/src/lib/camera/index.ts +++ b/src/lib/camera/index.ts @@ -1,4 +1,3 @@ -export * from "./Camera"; export * from "./RTPProxy"; export * from "./RTPStreamManagement"; export * from "./RecordingManagement"; diff --git a/src/lib/controller/CameraController.spec.ts b/src/lib/controller/CameraController.spec.ts index 98d3c0ceb..1a6433836 100644 --- a/src/lib/controller/CameraController.spec.ts +++ b/src/lib/controller/CameraController.spec.ts @@ -10,14 +10,12 @@ import { SnapshotRequestCallback, StreamRequestCallback, } from "."; -import { NodeCallback, SessionIdentifier } from "../../types"; import { AudioBitrate, AudioRecordingCodecType, AudioRecordingSamplerate, AudioStreamingCodecType, AudioStreamingSamplerate, - Camera, CameraRecordingConfiguration, CameraRecordingOptions, CameraStreamingOptions, @@ -25,21 +23,17 @@ import { H264Level, H264Profile, MediaContainerType, - PreparedStreamRequestCallback, PrepareStreamRequest, RecordingPacket, SnapshotRequest, SRTPCryptoSuites, - StreamController, StreamingRequest, - StreamRequest, VideoCodecType, } from "../camera"; import { Characteristic } from "../Characteristic"; import { HDSProtocolSpecificErrorReason } from "../datastream"; import "../definitions"; import { HAPStatus } from "../HAPServer"; -import { Service } from "../Service"; export const MOCK_IMAGE = crypto.randomBytes(64); @@ -131,47 +125,6 @@ export class MockDelegate implements CameraStreamingDelegate, CameraRecordingDel } } -export class MockLegacyCameraSource implements Camera { - services: Service[] = []; - // noinspection JSDeprecatedSymbols - streamControllers: StreamController[] = []; - - constructor(size: number, options?: CameraStreamingOptions) { - const opt = options ?? { - video: mockStreamingOptions.video, - audio: mockStreamingOptions.audio, - srtp: true, - }; - - for (let i = 0; i < size; i++) { - const controller = new StreamController(i, opt, this); - this.streamControllers.push(controller); - this.services.push(controller.getService()); - } - } - - handleCloseConnection(connectionID: SessionIdentifier): void { - for (const controller of this.streamControllers) { - // noinspection JSDeprecatedSymbols - controller.handleCloseConnection(connectionID); - } - } - - handleSnapshotRequest(request: SnapshotRequest, callback: NodeCallback): void { - callback(undefined, MOCK_IMAGE); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - handleStreamRequest(request: StreamRequest): void { - throw Error("Unsupported!"); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - prepareStream(request: PrepareStreamRequest, callback: PreparedStreamRequestCallback): void { - throw Error("Unsupported!"); - } -} - export function createCameraControllerOptions( recordingOptions: CameraRecordingOptions = mockRecordingOptions, streamingOptions: CameraStreamingOptions = mockStreamingOptions, diff --git a/src/lib/controller/CameraController.ts b/src/lib/controller/CameraController.ts index 175f5c061..f8124508e 100644 --- a/src/lib/controller/CameraController.ts +++ b/src/lib/controller/CameraController.ts @@ -7,7 +7,6 @@ import { CameraRecordingOptions, CameraStreamingOptions, EventTriggerOption, - LegacyCameraSourceAdapter, PrepareStreamRequest, PrepareStreamResponse, RecordingManagement, @@ -1071,14 +1070,4 @@ export class CameraController extends EventEmitter implements SerializableContro } }); } - - /** - * @private - */ - handleCloseConnection(sessionID: SessionIdentifier): void { - if (this.delegate instanceof LegacyCameraSourceAdapter) { - this.delegate.forwardCloseConnection(sessionID); - } - } - } diff --git a/src/lib/controller/RemoteController.ts b/src/lib/controller/RemoteController.ts index 3c996630a..5bbeb2864 100644 --- a/src/lib/controller/RemoteController.ts +++ b/src/lib/controller/RemoteController.ts @@ -2,7 +2,6 @@ import assert from "assert"; import createDebug from "debug"; import { EventEmitter } from "events"; import { CharacteristicValue } from "../../types"; -import { Accessory } from "../Accessory"; import { AudioBitrate, AudioSamplerate } from "../camera"; import { Characteristic, @@ -583,16 +582,6 @@ export class RemoteController extends EventEmitter setTimeout(() => this.releaseButton(button), time); } - /** - * This method adds and configures the remote services for a give accessory. - * - * @param accessory - the give accessory this remote should be added to - * @deprecated - use {@link Accessory.configureController} instead - */ - addServicesToAccessory(accessory: Accessory): void { - accessory.configureController(this); - } - // ---------------------------------- CONFIGURATION ---------------------------------- // override methods if you would like to change anything (but should not be necessary most likely) @@ -1394,12 +1383,6 @@ export class RemoteController extends EventEmitter } } -// noinspection JSUnusedGlobalSymbols -/** - * @deprecated - only there for backwards compatibility, please use {@link RemoteController} directly - * @group Apple TV Remote - */ -export class HomeKitRemoteController extends RemoteController {} // backwards compatibility /** * @group Apple TV Remote diff --git a/src/lib/datastream/DataStreamServer.ts b/src/lib/datastream/DataStreamServer.ts index 292351e9b..f5fb37dc1 100644 --- a/src/lib/datastream/DataStreamServer.ts +++ b/src/lib/datastream/DataStreamServer.ts @@ -108,11 +108,6 @@ export enum HDSStatus { PROTOCOL_SPECIFIC_ERROR = 6, } -/** - * @group HomeKit Data Streams (HDS) - * @deprecated Renamed to {@link HDSProtocolSpecificErrorReason}. - */ -export type DataSendCloseReason = HDSProtocolSpecificErrorReason; /** * @group HomeKit Data Streams (HDS) */ diff --git a/src/lib/definitions/CharacteristicDefinitions.spec.ts b/src/lib/definitions/CharacteristicDefinitions.spec.ts index b0e82202f..7394ba7e8 100644 --- a/src/lib/definitions/CharacteristicDefinitions.spec.ts +++ b/src/lib/definitions/CharacteristicDefinitions.spec.ts @@ -160,12 +160,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("Category", () => { - it("should be able to construct", () => { - new Characteristic.Category(); - }); - }); - describe("CCAEnergyDetectThreshold", () => { it("should be able to construct", () => { new Characteristic.CCAEnergyDetectThreshold(); @@ -214,18 +208,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("ConfigureBridgedAccessory", () => { - it("should be able to construct", () => { - new Characteristic.ConfigureBridgedAccessory(); - }); - }); - - describe("ConfigureBridgedAccessoryStatus", () => { - it("should be able to construct", () => { - new Characteristic.ConfigureBridgedAccessoryStatus(); - }); - }); - describe("ConfiguredName", () => { it("should be able to construct", () => { new Characteristic.ConfiguredName(); @@ -334,12 +316,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("CurrentTime", () => { - it("should be able to construct", () => { - new Characteristic.CurrentTime(); - }); - }); - describe("CurrentTransport", () => { it("should be able to construct", () => { new Characteristic.CurrentTransport(); @@ -370,12 +346,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("DayoftheWeek", () => { - it("should be able to construct", () => { - new Characteristic.DayoftheWeek(); - }); - }); - describe("DiagonalFieldOfView", () => { it("should be able to construct", () => { new Characteristic.DiagonalFieldOfView(); @@ -388,18 +358,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("DiscoverBridgedAccessories", () => { - it("should be able to construct", () => { - new Characteristic.DiscoverBridgedAccessories(); - }); - }); - - describe("DiscoveredBridgedAccessories", () => { - it("should be able to construct", () => { - new Characteristic.DiscoveredBridgedAccessories(); - }); - }); - describe("DisplayOrder", () => { it("should be able to construct", () => { new Characteristic.DisplayOrder(); @@ -550,12 +508,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("LinkQuality", () => { - it("should be able to construct", () => { - new Characteristic.LinkQuality(); - }); - }); - describe("ListPairings", () => { it("should be able to construct", () => { new Characteristic.ListPairings(); @@ -850,12 +802,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("Reachable", () => { - it("should be able to construct", () => { - new Characteristic.Reachable(); - }); - }); - describe("ReceivedSignalStrengthIndication", () => { it("should be able to construct", () => { new Characteristic.ReceivedSignalStrengthIndication(); @@ -1276,12 +1222,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("TargetAirQuality", () => { - it("should be able to construct", () => { - new Characteristic.TargetAirQuality(); - }); - }); - describe("TargetControlList", () => { it("should be able to construct", () => { new Characteristic.TargetControlList(); @@ -1348,12 +1288,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("TargetSlatState", () => { - it("should be able to construct", () => { - new Characteristic.TargetSlatState(); - }); - }); - describe("TargetTemperature", () => { it("should be able to construct", () => { new Characteristic.TargetTemperature(); @@ -1414,12 +1348,6 @@ describe("CharacteristicDefinitions", () => { }); }); - describe("TimeUpdate", () => { - it("should be able to construct", () => { - new Characteristic.TimeUpdate(); - }); - }); - describe("Token", () => { it("should be able to construct", () => { new Characteristic.Token(); diff --git a/src/lib/definitions/CharacteristicDefinitions.ts b/src/lib/definitions/CharacteristicDefinitions.ts index 2b9ba1dc0..86b7531f9 100644 --- a/src/lib/definitions/CharacteristicDefinitions.ts +++ b/src/lib/definitions/CharacteristicDefinitions.ts @@ -523,27 +523,6 @@ export class CarbonMonoxidePeakLevel extends Characteristic { } Characteristic.CarbonMonoxidePeakLevel = CarbonMonoxidePeakLevel; -/** - * Characteristic "Category" - * @deprecated Removed and not used anymore - */ -export class Category extends Characteristic { - - public static readonly UUID: string = "000000A3-0000-1000-8000-0026BB765291"; - - constructor() { - super("Category", Category.UUID, { - format: Formats.UINT16, - perms: [Perms.NOTIFY, Perms.PAIRED_READ], - minValue: 1, - maxValue: 16, - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.Category = Category; - /** * Characteristic "CCA Energy Detect Threshold" * @since iOS 14 @@ -703,44 +682,6 @@ export class ConfigurationState extends Characteristic { } Characteristic.ConfigurationState = ConfigurationState; -/** - * Characteristic "Configure Bridged Accessory" - * @deprecated Removed and not used anymore - */ -export class ConfigureBridgedAccessory extends Characteristic { - - public static readonly UUID: string = "000000A0-0000-1000-8000-0026BB765291"; - - constructor() { - super("Configure Bridged Accessory", ConfigureBridgedAccessory.UUID, { - format: Formats.TLV8, - perms: [Perms.PAIRED_WRITE], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.ConfigureBridgedAccessory = ConfigureBridgedAccessory; - -/** - * Characteristic "Configure Bridged Accessory Status" - * @deprecated Removed and not used anymore - */ -export class ConfigureBridgedAccessoryStatus extends Characteristic { - - public static readonly UUID: string = "0000009D-0000-1000-8000-0026BB765291"; - - constructor() { - super("Configure Bridged Accessory Status", ConfigureBridgedAccessoryStatus.UUID, { - format: Formats.TLV8, - perms: [Perms.NOTIFY, Perms.PAIRED_READ], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.ConfigureBridgedAccessoryStatus = ConfigureBridgedAccessoryStatus; - /** * Characteristic "Configured Name" */ @@ -1151,25 +1092,6 @@ export class CurrentTiltAngle extends Characteristic { } Characteristic.CurrentTiltAngle = CurrentTiltAngle; -/** - * Characteristic "Current Time" - * @deprecated Removed and not used anymore - */ -export class CurrentTime extends Characteristic { - - public static readonly UUID: string = "0000009B-0000-1000-8000-0026BB765291"; - - constructor() { - super("Current Time", CurrentTime.UUID, { - format: Formats.STRING, - perms: [Perms.PAIRED_READ, Perms.PAIRED_WRITE], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.CurrentTime = CurrentTime; - /** * Characteristic "Current Transport" * @since iOS 14 @@ -1269,27 +1191,6 @@ export class DataStreamHAPTransportInterrupt extends Characteristic { } Characteristic.DataStreamHAPTransportInterrupt = DataStreamHAPTransportInterrupt; -/** - * Characteristic "Day of the Week" - * @deprecated Removed and not used anymore - */ -export class DayoftheWeek extends Characteristic { - - public static readonly UUID: string = "00000098-0000-1000-8000-0026BB765291"; - - constructor() { - super("Day of the Week", DayoftheWeek.UUID, { - format: Formats.UINT8, - perms: [Perms.PAIRED_READ, Perms.PAIRED_WRITE], - minValue: 1, - maxValue: 7, - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.DayoftheWeek = DayoftheWeek; - /** * Characteristic "Diagonal Field Of View" * @since iOS 13.2 @@ -1329,44 +1230,6 @@ export class DigitalZoom extends Characteristic { } Characteristic.DigitalZoom = DigitalZoom; -/** - * Characteristic "Discover Bridged Accessories" - * @deprecated Removed and not used anymore - */ -export class DiscoverBridgedAccessories extends Characteristic { - - public static readonly UUID: string = "0000009E-0000-1000-8000-0026BB765291"; - - constructor() { - super("Discover Bridged Accessories", DiscoverBridgedAccessories.UUID, { - format: Formats.UINT8, - perms: [Perms.NOTIFY, Perms.PAIRED_READ, Perms.PAIRED_WRITE], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.DiscoverBridgedAccessories = DiscoverBridgedAccessories; - -/** - * Characteristic "Discovered Bridged Accessories" - * @deprecated Removed and not used anymore - */ -export class DiscoveredBridgedAccessories extends Characteristic { - - public static readonly UUID: string = "0000009F-0000-1000-8000-0026BB765291"; - - constructor() { - super("Discovered Bridged Accessories", DiscoveredBridgedAccessories.UUID, { - format: Formats.UINT16, - perms: [Perms.NOTIFY, Perms.PAIRED_READ], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.DiscoveredBridgedAccessories = DiscoveredBridgedAccessories; - /** * Characteristic "Display Order" */ @@ -1878,27 +1741,6 @@ export class LeakDetected extends Characteristic { } Characteristic.LeakDetected = LeakDetected; -/** - * Characteristic "Link Quality" - * @deprecated Removed and not used anymore - */ -export class LinkQuality extends Characteristic { - - public static readonly UUID: string = "0000009C-0000-1000-8000-0026BB765291"; - - constructor() { - super("Link Quality", LinkQuality.UUID, { - format: Formats.UINT8, - perms: [Perms.NOTIFY, Perms.PAIRED_READ], - minValue: 1, - maxValue: 4, - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.LinkQuality = LinkQuality; - /** * Characteristic "List Pairings" */ @@ -2848,7 +2690,7 @@ export class ProgramMode extends Characteristic { public static readonly NO_PROGRAM_SCHEDULED = 0; public static readonly PROGRAM_SCHEDULED = 1; - public static readonly PROGRAM_SCHEDULED_MANUAL_MODE_ = 2; + public static readonly PROGRAM_SCHEDULED_MANUAL_MODE = 2; constructor() { super("Program Mode", ProgramMode.UUID, { @@ -2864,25 +2706,6 @@ export class ProgramMode extends Characteristic { } Characteristic.ProgramMode = ProgramMode; -/** - * Characteristic "Reachable" - * @deprecated Removed and not used anymore - */ -export class Reachable extends Characteristic { - - public static readonly UUID: string = "00000063-0000-1000-8000-0026BB765291"; - - constructor() { - super("Reachable", Reachable.UUID, { - format: Formats.BOOL, - perms: [Perms.PAIRED_READ, Perms.PAIRED_WRITE], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.Reachable = Reachable; - /** * Characteristic "Received Signal Strength Indication" * @since iOS 14 @@ -4260,32 +4083,6 @@ export class TargetAirPurifierState extends Characteristic { } Characteristic.TargetAirPurifierState = TargetAirPurifierState; -/** - * Characteristic "Target Air Quality" - * @deprecated Removed and not used anymore - */ -export class TargetAirQuality extends Characteristic { - - public static readonly UUID: string = "000000AE-0000-1000-8000-0026BB765291"; - - public static readonly EXCELLENT = 0; - public static readonly GOOD = 1; - public static readonly FAIR = 2; - - constructor() { - super("Target Air Quality", TargetAirQuality.UUID, { - format: Formats.UINT8, - perms: [Perms.NOTIFY, Perms.PAIRED_READ, Perms.PAIRED_WRITE], - minValue: 0, - maxValue: 2, - validValues: [0, 1, 2], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.TargetAirQuality = TargetAirQuality; - /** * Characteristic "Target Control List" */ @@ -4448,11 +4245,6 @@ export class TargetHumidifierDehumidifierState extends Characteristic { public static readonly UUID: string = "000000B4-0000-1000-8000-0026BB765291"; - /** - * @deprecated Removed in iOS 11. Use {@link HUMIDIFIER_OR_DEHUMIDIFIER} instead. - */ - public static readonly AUTO = 0; - public static readonly HUMIDIFIER_OR_DEHUMIDIFIER = 0; public static readonly HUMIDIFIER = 1; public static readonly DEHUMIDIFIER = 2; @@ -4538,31 +4330,6 @@ export class TargetRelativeHumidity extends Characteristic { } Characteristic.TargetRelativeHumidity = TargetRelativeHumidity; -/** - * Characteristic "Target Slat State" - * @deprecated Removed and not used anymore - */ -export class TargetSlatState extends Characteristic { - - public static readonly UUID: string = "000000BE-0000-1000-8000-0026BB765291"; - - public static readonly MANUAL = 0; - public static readonly AUTO = 1; - - constructor() { - super("Target Slat State", TargetSlatState.UUID, { - format: Formats.UINT8, - perms: [Perms.NOTIFY, Perms.PAIRED_READ, Perms.PAIRED_WRITE], - minValue: 0, - maxValue: 1, - validValues: [0, 1], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.TargetSlatState = TargetSlatState; - /** * Characteristic "Target Temperature" */ @@ -4769,25 +4536,6 @@ export class ThreadStatus extends Characteristic { } Characteristic.ThreadStatus = ThreadStatus; -/** - * Characteristic "Time Update" - * @deprecated Removed and not used anymore - */ -export class TimeUpdate extends Characteristic { - - public static readonly UUID: string = "0000009A-0000-1000-8000-0026BB765291"; - - constructor() { - super("Time Update", TimeUpdate.UUID, { - format: Formats.BOOL, - perms: [Perms.PAIRED_READ, Perms.PAIRED_WRITE], - }); - this.value = this.getDefaultValue(); - } -} -// noinspection JSDeprecatedSymbols -Characteristic.TimeUpdate = TimeUpdate; - /** * Characteristic "Token" */ diff --git a/src/lib/definitions/ServiceDefinitions.spec.ts b/src/lib/definitions/ServiceDefinitions.spec.ts index 91515668b..2a17fe5d3 100644 --- a/src/lib/definitions/ServiceDefinitions.spec.ts +++ b/src/lib/definitions/ServiceDefinitions.spec.ts @@ -240,75 +240,6 @@ describe("ServiceDefinitions", () => { expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name"); expect(service1.subtype).toBeUndefined(); - expect(service2.displayName).toBe("test name"); - expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service2.subtype).toBe("test sub type"); - // noinspection JSDeprecatedSymbols - - new Service.BatteryService(); - }); - }); - - describe("BridgeConfiguration", () => { - it("should be able to construct", () => { - const service0 = new Service.BridgeConfiguration(); - const service1 = new Service.BridgeConfiguration("test name"); - const service2 = new Service.BridgeConfiguration("test name", "test sub type"); - - expect(service0.displayName).toBe(""); - expect(service0.testCharacteristic(Characteristic.Name)).toBe(false); - expect(service0.subtype).toBeUndefined(); - - expect(service1.displayName).toBe("test name"); - expect(service1.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service1.subtype).toBeUndefined(); - - expect(service2.displayName).toBe("test name"); - expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service2.subtype).toBe("test sub type"); - }); - }); - - describe("BridgingState", () => { - it("should be able to construct", () => { - const service0 = new Service.BridgingState(); - const service1 = new Service.BridgingState("test name"); - const service2 = new Service.BridgingState("test name", "test sub type"); - - expect(service0.displayName).toBe(""); - expect(service0.testCharacteristic(Characteristic.Name)).toBe(false); - expect(service0.subtype).toBeUndefined(); - - expect(service1.displayName).toBe("test name"); - expect(service1.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service1.subtype).toBeUndefined(); - - expect(service2.displayName).toBe("test name"); - expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service2.subtype).toBe("test sub type"); - }); - }); - - describe("CameraControl", () => { - it("should be able to construct", () => { - const service0 = new Service.CameraControl(); - const service1 = new Service.CameraControl("test name"); - const service2 = new Service.CameraControl("test name", "test sub type"); - - expect(service0.displayName).toBe(""); - expect(service0.testCharacteristic(Characteristic.Name)).toBe(false); - expect(service0.subtype).toBeUndefined(); - - expect(service1.displayName).toBe("test name"); - expect(service1.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service1.subtype).toBeUndefined(); - expect(service2.displayName).toBe("test name"); expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); @@ -357,9 +288,6 @@ describe("ServiceDefinitions", () => { expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); expect(service2.subtype).toBe("test sub type"); - // noinspection JSDeprecatedSymbols - - new Service.CameraEventRecordingManagement(); }); }); @@ -448,9 +376,6 @@ describe("ServiceDefinitions", () => { expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); expect(service2.subtype).toBe("test sub type"); - // noinspection JSDeprecatedSymbols - - new Service.Relay(); }); }); @@ -1199,9 +1124,6 @@ describe("ServiceDefinitions", () => { expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); expect(service2.subtype).toBe("test sub type"); - // noinspection JSDeprecatedSymbols - - new Service.Slat(); }); }); @@ -1513,28 +1435,6 @@ describe("ServiceDefinitions", () => { }); }); - describe("TimeInformation", () => { - it("should be able to construct", () => { - const service0 = new Service.TimeInformation(); - const service1 = new Service.TimeInformation("test name"); - const service2 = new Service.TimeInformation("test name", "test sub type"); - - expect(service0.displayName).toBe(""); - expect(service0.testCharacteristic(Characteristic.Name)).toBe(false); - expect(service0.subtype).toBeUndefined(); - - expect(service1.displayName).toBe("test name"); - expect(service1.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service1.subtype).toBeUndefined(); - - expect(service2.displayName).toBe("test name"); - expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); - expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); - expect(service2.subtype).toBe("test sub type"); - }); - }); - describe("TransferTransportManagement", () => { it("should be able to construct", () => { const service0 = new Service.TransferTransportManagement(); @@ -1576,9 +1476,6 @@ describe("ServiceDefinitions", () => { expect(service2.testCharacteristic(Characteristic.Name)).toBe(true); expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name"); expect(service2.subtype).toBe("test sub type"); - // noinspection JSDeprecatedSymbols - - new Service.TunneledBTLEAccessoryService(); }); }); diff --git a/src/lib/definitions/ServiceDefinitions.ts b/src/lib/definitions/ServiceDefinitions.ts index fe3341e35..09897ea04 100644 --- a/src/lib/definitions/ServiceDefinitions.ts +++ b/src/lib/definitions/ServiceDefinitions.ts @@ -239,88 +239,8 @@ export class Battery extends Service { this.addOptionalCharacteristic(Characteristic.Name); } } -// noinspection JSDeprecatedSymbols -Service.BatteryService = Battery; Service.Battery = Battery; -/** - * Service "Bridge Configuration" - * @deprecated Removed and not used anymore - */ -export class BridgeConfiguration extends Service { - - public static readonly UUID: string = "000000A1-0000-1000-8000-0026BB765291"; - - constructor(displayName?: string, subtype?: string) { - super(displayName, BridgeConfiguration.UUID, subtype); - - // Required Characteristics - this.addCharacteristic(Characteristic.ConfigureBridgedAccessoryStatus); - this.addCharacteristic(Characteristic.DiscoverBridgedAccessories); - this.addCharacteristic(Characteristic.DiscoveredBridgedAccessories); - this.addCharacteristic(Characteristic.ConfigureBridgedAccessory); - - // Optional Characteristics - this.addOptionalCharacteristic(Characteristic.Name); - } -} -// noinspection JSDeprecatedSymbols -Service.BridgeConfiguration = BridgeConfiguration; - -/** - * Service "Bridging State" - * @deprecated Removed and not used anymore - */ -export class BridgingState extends Service { - - public static readonly UUID: string = "00000062-0000-1000-8000-0026BB765291"; - - constructor(displayName?: string, subtype?: string) { - super(displayName, BridgingState.UUID, subtype); - - // Required Characteristics - this.addCharacteristic(Characteristic.Reachable); - this.addCharacteristic(Characteristic.LinkQuality); - this.addCharacteristic(Characteristic.AccessoryIdentifier); - this.addCharacteristic(Characteristic.Category); - - // Optional Characteristics - this.addOptionalCharacteristic(Characteristic.Name); - } -} -// noinspection JSDeprecatedSymbols -Service.BridgingState = BridgingState; - -/** - * Service "Camera Control" - * @deprecated This service has no usage anymore and will be ignored by iOS - */ -export class CameraControl extends Service { - - public static readonly UUID: string = "00000111-0000-1000-8000-0026BB765291"; - - constructor(displayName?: string, subtype?: string) { - super(displayName, CameraControl.UUID, subtype); - - // Required Characteristics - this.addCharacteristic(Characteristic.On); - - // Optional Characteristics - this.addOptionalCharacteristic(Characteristic.CurrentHorizontalTiltAngle); - this.addOptionalCharacteristic(Characteristic.CurrentVerticalTiltAngle); - this.addOptionalCharacteristic(Characteristic.TargetHorizontalTiltAngle); - this.addOptionalCharacteristic(Characteristic.TargetVerticalTiltAngle); - this.addOptionalCharacteristic(Characteristic.NightVision); - this.addOptionalCharacteristic(Characteristic.OpticalZoom); - this.addOptionalCharacteristic(Characteristic.DigitalZoom); - this.addOptionalCharacteristic(Characteristic.ImageRotation); - this.addOptionalCharacteristic(Characteristic.ImageMirroring); - this.addOptionalCharacteristic(Characteristic.Name); - } -} -// noinspection JSDeprecatedSymbols -Service.CameraControl = CameraControl; - /** * Service "Camera Operating Mode" */ @@ -367,8 +287,6 @@ export class CameraRecordingManagement extends Service { this.addOptionalCharacteristic(Characteristic.RecordingAudioActive); } } -// noinspection JSDeprecatedSymbols -Service.CameraEventRecordingManagement = CameraRecordingManagement; Service.CameraRecordingManagement = CameraRecordingManagement; /** @@ -461,8 +379,6 @@ export class CloudRelay extends Service { this.addCharacteristic(Characteristic.RelayEnabled); } } -// noinspection JSDeprecatedSymbols -Service.Relay = CloudRelay; Service.CloudRelay = CloudRelay; /** @@ -1215,8 +1131,6 @@ export class Slats extends Service { this.addOptionalCharacteristic(Characteristic.TargetTiltAngle); } } -// noinspection JSDeprecatedSymbols -Service.Slat = Slats; Service.Slats = Slats; /** @@ -1538,29 +1452,6 @@ export class ThreadTransport extends Service { } Service.ThreadTransport = ThreadTransport; -/** - * Service "Time Information" - * @deprecated Removed and not used anymore - */ -export class TimeInformation extends Service { - - public static readonly UUID: string = "00000099-0000-1000-8000-0026BB765291"; - - constructor(displayName?: string, subtype?: string) { - super(displayName, TimeInformation.UUID, subtype); - - // Required Characteristics - this.addCharacteristic(Characteristic.CurrentTime); - this.addCharacteristic(Characteristic.DayoftheWeek); - this.addCharacteristic(Characteristic.TimeUpdate); - - // Optional Characteristics - this.addOptionalCharacteristic(Characteristic.Name); - } -} -// noinspection JSDeprecatedSymbols -Service.TimeInformation = TimeInformation; - /** * Service "Transfer Transport Management" */ @@ -1596,8 +1487,6 @@ export class Tunnel extends Service { this.addCharacteristic(Characteristic.TunneledAccessoryStateNumber); } } -// noinspection JSDeprecatedSymbols -Service.TunneledBTLEAccessoryService = Tunnel; Service.Tunnel = Tunnel; /** diff --git a/src/lib/util/tlv.spec.ts b/src/lib/util/tlv.spec.ts index ec85d627c..807bb126e 100644 --- a/src/lib/util/tlv.spec.ts +++ b/src/lib/util/tlv.spec.ts @@ -235,11 +235,6 @@ describe("tlv", () => { expect(() => writeVariableUIntLE(-1)) .toThrowError(); - // offset must be zero - // noinspection JSDeprecatedSymbols - expect(() => writeVariableUIntLE(1, 1)) - .toThrowError(); - const input8 = 128; const buffer8 = writeVariableUIntLE(input8); expect(buffer8.length).toBe(1); diff --git a/src/lib/util/tlv.ts b/src/lib/util/tlv.ts index 1510ea687..f13469069 100644 --- a/src/lib/util/tlv.ts +++ b/src/lib/util/tlv.ts @@ -233,35 +233,6 @@ export function decodeList(data: Buffer, entryStartId: number): Record= 0, "Can't encode a negative integer as unsigned integer"); - assert(offset === 0, "Can't define a offset different than 0!"); if (number <= 255) { const buffer = Buffer.alloc(1); - buffer.writeUInt8(number, offset); + buffer.writeUInt8(number, 0); return buffer; } else if (number <= 65535) { return writeUInt16(number); @@ -387,7 +335,7 @@ export function writeVariableUIntLE(number: number, offset = 0): Buffer { return writeUInt32(number); } else { const buffer = Buffer.alloc(8); - hapCrypto.writeUInt64LE(number, buffer, offset); + hapCrypto.writeUInt64LE(number, buffer, 0); return buffer; } } diff --git a/src/lib/util/uuid.ts b/src/lib/util/uuid.ts index 4457915c5..c1603f006 100644 --- a/src/lib/util/uuid.ts +++ b/src/lib/util/uuid.ts @@ -30,15 +30,6 @@ export function isValid(UUID: string): boolean { } -/** - * Returns the identity of the passed argument. - * - * @param buf - The string argument which is returned - * @deprecated Most certainly the API you are using this function with changed from returning a Buffer to returning - * the actual uuid string. You can safely remove the call to unparse. Most certainly this call to unparse - * is located in you CameraSource which you converted from the old style CameraSource API to the new CameraControllers. - */ -export function unparse(buf: string): string /** * Parses the uuid as a string from the given Buffer. * The parser will use the first 8 bytes. @@ -53,21 +44,6 @@ export function unparse(buf: Buffer): string */ export function unparse(buf: Buffer, offset: number): string export function unparse(buf: Buffer | string, offset = 0): string { - if (typeof buf === "string" && isValid(buf)) { - /* - This check was added to fix backwards compatibility with the old style CameraSource API. - The old StreamController implementation would not unparse the HAP provided sessionId for the current streaming session. - This was changed when the new Controller API was introduced, which now turns the sessionId Buffer into a string - and passes it to the implementor of the Camera. - Old style CameraSource implementations would use this unparse function to turn the Buffer into a string. - As the sessionId is already a string we just return it here. - - The buf attribute being a also type of "string" as actually an error. Also I don't know who decided to - not unparse the sessionId. I'm only here to fix things. - */ - return buf; - } - let i = offset; return buf.toString("hex", i, (i += 4)) + "-" +