UNPKG

3.14 kBTypeScriptView Raw
1import { EventEmitter } from "events";
2import type { AccessControl } from "../definitions";
3/**
4 * This defines the Access Level for TVs and Speakers. It is pretty much only used for the AirPlay 2 protocol
5 * so this information is not really useful.
6 *
7 * @group Television
8 */
9export declare const enum AccessLevel {
10 /**
11 * This access level is set when the users selects "Anyone" or "Anyone On The Same Network"
12 * in the Access Control settings.
13 */
14 ANYONE = 0,
15 /**
16 * This access level is set when the users selects "Only People Sharing this Home" in the
17 * Access Control settings.
18 * On this level password setting is ignored.
19 * Requests to the HAPServer can only come from Home members anyways, so there is no real use to it.
20 * This is pretty much only used for the AirPlay 2 protocol.
21 */
22 HOME_MEMBERS_ONLY = 1
23}
24/**
25 * @group Television
26 */
27export declare const enum AccessControlEvent {
28 ACCESS_LEVEL_UPDATED = "update-control-level",
29 PASSWORD_SETTING_UPDATED = "update-password"
30}
31/**
32 * @group Television
33 */
34export declare interface AccessControlManagement {
35 on(event: "update-control-level", listener: (accessLevel: AccessLevel) => void): this;
36 on(event: "update-password", listener: (password: string | undefined, passwordRequired: boolean) => void): this;
37 emit(event: "update-control-level", accessLevel: AccessLevel): boolean;
38 emit(event: "update-password", password: string | undefined, passwordRequired: boolean): boolean;
39}
40/**
41 * @group Television
42 */
43export declare class AccessControlManagement extends EventEmitter {
44 private readonly accessControlService;
45 /**
46 * The current access level set for the Home
47 */
48 private accessLevel;
49 private passwordRequired;
50 private password?;
51 /**
52 * Instantiates a new AccessControlManagement.
53 *
54 * @param {boolean} password - if set to true the service will listen for password settings
55 */
56 constructor(password?: boolean);
57 /**
58 * Instantiates a new AccessControlManagement.
59 *
60 * @param {boolean} password - if set to true the service will listen for password settings
61 * @param {AccessControl} service - supply your own instance to sideload the AccessControl service
62 */
63 constructor(password?: boolean, service?: AccessControl);
64 /**
65 * @returns the AccessControl service
66 */
67 getService(): AccessControl;
68 /**
69 * @returns the current {@link AccessLevel} configured for the Home
70 */
71 getAccessLevel(): AccessLevel;
72 /**
73 * @returns the current password configured for the Home or `undefined` if no password is required.
74 */
75 getPassword(): string | undefined;
76 /**
77 * This destroys the AccessControlManagement.
78 * It unregisters all GET or SET handler it has associated with the given AccessControl service.
79 * It removes all event handlers which were registered to this object.
80 */
81 destroy(): void;
82 private handleAccessLevelChange;
83 private handlePasswordChange;
84 private setupServiceHandlers;
85}
86//# sourceMappingURL=AccessControlManagement.d.ts.map
\No newline at end of file