UNPKG

1.49 kBTypeScriptView Raw
1declare module "bonjour-hap" {
2
3 export const enum Protocols {
4 TCP = "tcp",
5 UDP = "udp",
6 }
7
8 export type Nullable<T> = T | null;
9 export type TxtRecord = Record<string, string>;
10
11 export class BonjourHAPService {
12 name: string;
13 type: string;
14 subtypes: Nullable<string[]>;
15 protocol: Protocols;
16 host: string;
17 port: number;
18 fqdn: string;
19 txt: Nullable<Record<string, string>>;
20 published: boolean;
21
22 start(): void;
23 stop(callback?: () => void): void;
24 destroy(): void;
25 updateTxt(txt: TxtRecord, silent?: boolean): void;
26 }
27
28 export type PublishOptions = {
29 // eslint-disable-next-line @typescript-eslint/no-explicit-any
30 category?: any,
31 host?: string;
32 name?: string;
33 pincode?: string;
34 port: number;
35 protocol?: Protocols;
36 subtypes?: string[];
37 txt?: Record<string, string>;
38 type?: string;
39 username?: string;
40
41 addUnsafeServiceEnumerationRecord?: boolean,
42
43 restrictedAddresses?: string[];
44 disabledIpv6?: boolean;
45 };
46
47 export class BonjourHAP {
48 publish(options: PublishOptions): BonjourHAPService;
49 unpublishAll(callback: () => void): void;
50 destroy(): void;
51 }
52
53
54 export type MulticastOptions = {
55 multicast?: boolean;
56 interface?: string;
57 port?: number;
58 ip?: string;
59 ttl?: number;
60 loopback?: boolean;
61 reuseAddr?: boolean;
62 };
63 function createWithOptions(options?: MulticastOptions): BonjourHAP;
64
65 export default createWithOptions;
66}