1 | /// <reference types="node" />
|
2 | /**
|
3 | * @see https://github.com/mqttjs/MQTT.js/
|
4 | *
|
5 | * @publicApi
|
6 | */
|
7 | export declare type QoS = 0 | 1 | 2;
|
8 | export interface MqttClientOptions extends ISecureClientOptions {
|
9 | port?: number;
|
10 | host?: string;
|
11 | hostname?: string;
|
12 | path?: string;
|
13 | protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';
|
14 | wsOptions?: {
|
15 | [x: string]: any;
|
16 | };
|
17 | /**
|
18 | * 10 seconds, set to 0 to disable
|
19 | */
|
20 | keepalive?: number;
|
21 | /**
|
22 | * 'mqttjs_' + Math.random().toString(16).substr(2, 8)
|
23 | */
|
24 | clientId?: string;
|
25 | /**
|
26 | * 'MQTT'
|
27 | */
|
28 | protocolId?: string;
|
29 | /**
|
30 | * 4
|
31 | */
|
32 | protocolVersion?: number;
|
33 | /**
|
34 | * true, set to false to receive QoS 1 and 2 messages while offline
|
35 | */
|
36 | clean?: boolean;
|
37 | /**
|
38 | * 1000 milliseconds, interval between two reconnections
|
39 | */
|
40 | reconnectPeriod?: number;
|
41 | /**
|
42 | * 30 * 1000 milliseconds, time to wait before a CONNACK is received
|
43 | */
|
44 | connectTimeout?: number;
|
45 | /**
|
46 | * the username required by your broker, if any
|
47 | */
|
48 | username?: string;
|
49 | /**
|
50 | * the password required by your broker, if any
|
51 | */
|
52 | password?: string;
|
53 | /**
|
54 | * a any for the incoming packets
|
55 | */
|
56 | incomingStore?: any;
|
57 | /**
|
58 | * a any for the outgoing packets
|
59 | */
|
60 | outgoingStore?: any;
|
61 | queueQoSZero?: boolean;
|
62 | /**
|
63 | * properties MQTT 5.0.
|
64 | */
|
65 | properties?: {
|
66 | /**
|
67 | * representing the Session Expiry Interval in seconds
|
68 | */
|
69 | sessionExpiryInterval?: number;
|
70 | /**
|
71 | * representing the Receive Maximum
|
72 | */
|
73 | receiveMaximum?: number;
|
74 | /**
|
75 | * representing the Maximum Packet Size the Client is willing to accept
|
76 | */
|
77 | maximumPacketSize?: number;
|
78 | /**
|
79 | * representing the Topic Alias Maximum value indicates the highest value that the Client will accept as a Topic Alias sent by the Server
|
80 | */
|
81 | topicAliasMaximum?: number;
|
82 | /**
|
83 | * The Client uses this value to request the Server to return Response Information in the CONNACK
|
84 | */
|
85 | requestResponseInformation?: boolean;
|
86 | /**
|
87 | * The Client uses this value to indicate whether the Reason String or User Properties are sent in the case of failures
|
88 | */
|
89 | requestProblemInformation?: boolean;
|
90 | /**
|
91 | * The User Property is allowed to appear multiple times to represent multiple name, value pairs
|
92 | */
|
93 | userProperties?: object;
|
94 | /**
|
95 | * the name of the authentication method used for extended authentication
|
96 | */
|
97 | authenticationMethod?: string;
|
98 | /**
|
99 | * * Binary Data containing authentication data (binary type)
|
100 | * */
|
101 | authenticationData?: any;
|
102 | };
|
103 | reschedulePings?: boolean;
|
104 | servers?: Array<{
|
105 | host: string;
|
106 | port: number;
|
107 | }>;
|
108 | /**
|
109 | * true, set to false to disable re-subscribe functionality
|
110 | */
|
111 | resubscribe?: boolean;
|
112 | /**
|
113 | * a message that will sent by the broker automatically when the client disconnect badly.
|
114 | */
|
115 | will?: {
|
116 | /**
|
117 | * the topic to publish
|
118 | */
|
119 | topic: string;
|
120 | /**
|
121 | * the message to publish
|
122 | */
|
123 | payload: string;
|
124 | /**
|
125 | * the QoS
|
126 | */
|
127 | qos: QoS;
|
128 | /**
|
129 | * the retain flag
|
130 | */
|
131 | retain: boolean;
|
132 | };
|
133 | transformWsUrl?: (url: string, options: any, client: any) => string;
|
134 | }
|
135 | export interface ISecureClientOptions {
|
136 | /**
|
137 | * optional private keys in PEM format
|
138 | */
|
139 | key?: string | string[] | Buffer | Buffer[] | Record<string, any>[];
|
140 | /**
|
141 | * optional cert chains in PEM format
|
142 | */
|
143 | cert?: string | string[] | Buffer | Buffer[];
|
144 | /**
|
145 | * Optionally override the trusted CA certificates in PEM format
|
146 | */
|
147 | ca?: string | string[] | Buffer | Buffer[];
|
148 | rejectUnauthorized?: boolean;
|
149 | }
|
150 | export interface IClientPublishOptions {
|
151 | /**
|
152 | * the QoS
|
153 | */
|
154 | qos: QoS;
|
155 | /**
|
156 | * the retain flag
|
157 | */
|
158 | retain?: boolean;
|
159 | /**
|
160 | * whether or not mark a message as duplicate
|
161 | */
|
162 | dup?: boolean;
|
163 | }
|
164 | export interface IClientSubscribeOptions {
|
165 | /**
|
166 | * the QoS
|
167 | */
|
168 | qos: QoS;
|
169 | }
|
170 | export interface IClientReconnectOptions {
|
171 | /**
|
172 | * a any for the incoming packets
|
173 | */
|
174 | incomingStore?: any;
|
175 | /**
|
176 | * a any for the outgoing packets
|
177 | */
|
178 | outgoingStore?: any;
|
179 | }
|