UNPKG

3.08 kBTypeScriptView Raw
1/// <reference types="node" />
2/**
3 * @see https://github.com/mqttjs/MQTT.js/
4 */
5export declare type QoS = 0 | 1 | 2;
6export interface MqttClientOptions extends ISecureClientOptions {
7 port?: number;
8 host?: string;
9 hostname?: string;
10 path?: string;
11 protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';
12 wsOptions?: {
13 [x: string]: any;
14 };
15 /**
16 * 10 seconds, set to 0 to disable
17 */
18 keepalive?: number;
19 /**
20 * 'mqttjs_' + Math.random().toString(16).substr(2, 8)
21 */
22 clientId?: string;
23 /**
24 * 'MQTT'
25 */
26 protocolId?: string;
27 /**
28 * 4
29 */
30 protocolVersion?: number;
31 /**
32 * true, set to false to receive QoS 1 and 2 messages while offline
33 */
34 clean?: boolean;
35 /**
36 * 1000 milliseconds, interval between two reconnections
37 */
38 reconnectPeriod?: number;
39 /**
40 * 30 * 1000 milliseconds, time to wait before a CONNACK is received
41 */
42 connectTimeout?: number;
43 /**
44 * the username required by your broker, if any
45 */
46 username?: string;
47 /**
48 * the password required by your broker, if any
49 */
50 password?: string;
51 /**
52 * a any for the incoming packets
53 */
54 incomingStore?: any;
55 /**
56 * a any for the outgoing packets
57 */
58 outgoingStore?: any;
59 queueQoSZero?: boolean;
60 reschedulePings?: boolean;
61 servers?: Array<{
62 host: string;
63 port: number;
64 }>;
65 /**
66 * true, set to false to disable re-subscribe functionality
67 */
68 resubscribe?: boolean;
69 /**
70 * a message that will sent by the broker automatically when the client disconnect badly.
71 */
72 will?: {
73 /**
74 * the topic to publish
75 */
76 topic: string;
77 /**
78 * the message to publish
79 */
80 payload: string;
81 /**
82 * the QoS
83 */
84 qos: QoS;
85 /**
86 * the retain flag
87 */
88 retain: boolean;
89 };
90 transformWsUrl?: (url: string, options: any, client: any) => string;
91}
92export interface ISecureClientOptions {
93 /**
94 * optional private keys in PEM format
95 */
96 key?: string | string[] | Buffer | Buffer[] | Record<string, any>[];
97 /**
98 * optional cert chains in PEM format
99 */
100 cert?: string | string[] | Buffer | Buffer[];
101 /**
102 * Optionally override the trusted CA certificates in PEM format
103 */
104 ca?: string | string[] | Buffer | Buffer[];
105 rejectUnauthorized?: boolean;
106}
107export interface IClientPublishOptions {
108 /**
109 * the QoS
110 */
111 qos: QoS;
112 /**
113 * the retain flag
114 */
115 retain?: boolean;
116 /**
117 * whether or not mark a message as duplicate
118 */
119 dup?: boolean;
120}
121export interface IClientSubscribeOptions {
122 /**
123 * the QoS
124 */
125 qos: QoS;
126}
127export interface IClientReconnectOptions {
128 /**
129 * a any for the incoming packets
130 */
131 incomingStore?: any;
132 /**
133 * a any for the outgoing packets
134 */
135 outgoingStore?: any;
136}