UNPKG

3.06 kBTypeScriptView Raw
1import { AccessoryJsonObject, MacAddress } from "../../types";
2import { Categories } from "../Accessory";
3import { HAPConnection, HAPUsername } from "../util/eventedhttp";
4/**
5 * @group Model
6 */
7export declare const enum PermissionTypes {
8 USER = 0,
9 ADMIN = 1
10}
11/**
12 * @group Model
13 */
14export interface PairingInformation {
15 username: HAPUsername;
16 publicKey: Buffer;
17 permission: PermissionTypes;
18}
19/**
20 * AccessoryInfo is a model class containing a subset of Accessory data relevant to the internal HAP server,
21 * such as encryption keys and username. It is persisted to disk.
22 * @group Model
23 */
24export declare class AccessoryInfo {
25 static readonly deviceIdPattern: RegExp;
26 username: MacAddress;
27 displayName: string;
28 model: string;
29 category: Categories;
30 pincode: string;
31 signSk: Buffer;
32 signPk: Buffer;
33 pairedClients: Record<HAPUsername, PairingInformation>;
34 pairedAdminClients: number;
35 private configVersion;
36 private configHash;
37 setupID: string;
38 private lastFirmwareVersion;
39 private constructor();
40 /**
41 * Add a paired client to memory.
42 * @param {HAPUsername} username
43 * @param {Buffer} publicKey
44 * @param {PermissionTypes} permission
45 */
46 addPairedClient(username: HAPUsername, publicKey: Buffer, permission: PermissionTypes): void;
47 updatePermission(username: HAPUsername, permission: PermissionTypes): void;
48 listPairings(): PairingInformation[];
49 /**
50 * Remove a paired client from memory.
51 * @param connection - the session of the connection initiated the removal of the pairing
52 * @param {string} username
53 */
54 removePairedClient(connection: HAPConnection, username: HAPUsername): void;
55 private _removePairedClient0;
56 /**
57 * Check if username is paired
58 * @param username
59 */
60 isPaired(username: HAPUsername): boolean;
61 hasAdminPermissions(username: HAPUsername): boolean;
62 getClientPublicKey(username: HAPUsername): Buffer | undefined;
63 paired: () => boolean;
64 /**
65 * Checks based on the current accessory configuration if the current configuration number needs to be incremented.
66 * Additionally, if desired, it checks if the firmware version was incremented (aka the HAP-NodeJS) version did grow.
67 *
68 * @param configuration - The current accessory configuration.
69 * @param checkFirmwareIncrement
70 * @returns True if the current configuration number was incremented and thus a new TXT must be advertised.
71 */
72 checkForCurrentConfigurationNumberIncrement(configuration: AccessoryJsonObject[], checkFirmwareIncrement?: boolean): boolean;
73 getConfigVersion(): number;
74 private ensureConfigVersionBounds;
75 save(): void;
76 static persistKey(username: MacAddress): string;
77 static create(username: MacAddress): AccessoryInfo;
78 static load(username: MacAddress): AccessoryInfo | null;
79 static remove(username: MacAddress): void;
80 static assertValidUsername(username: MacAddress): void;
81}
82//# sourceMappingURL=AccessoryInfo.d.ts.map
\No newline at end of file