mqtt 4.2.8 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,191 +1,204 @@
1
- import { MqttClient } from './client'
2
- import { Store } from './store'
3
- import { ClientOptions } from 'ws'
4
- import { ClientRequestArgs } from 'http'
5
- import { QoS, UserProperties } from 'mqtt-packet'
6
-
7
- export declare type StorePutCallback = () => void
8
-
9
- export interface IClientOptions extends ISecureClientOptions {
10
- port?: number // port is made into a number subsequently
11
- host?: string // host does NOT include port
12
- hostname?: string
13
- path?: string
14
- protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs'
15
-
16
- wsOptions?: ClientOptions | ClientRequestArgs
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 Store for the incoming packets
55
- */
56
- incomingStore?: Store
57
- /**
58
- * a Store for the outgoing packets
59
- */
60
- outgoingStore?: Store
61
- queueQoSZero?: boolean
62
- reschedulePings?: boolean
63
- servers?: Array<{
64
- host: string
65
- port: number
66
- protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs'
67
- }>
68
- /**
69
- * true, set to false to disable re-subscribe functionality
70
- */
71
- resubscribe?: boolean
72
- /**
73
- * a message that will sent by the broker automatically when the client disconnect badly.
74
- */
75
- will?: {
76
- /**
77
- * the topic to publish
78
- */
79
- topic: string
80
- /**
81
- * the message to publish
82
- */
83
- payload: Buffer | string
84
- /**
85
- * the QoS
86
- */
87
- qos: QoS
88
- /**
89
- * the retain flag
90
- */
91
- retain: boolean,
92
- /*
93
- * properies object of will
94
- * */
95
- properties?: {
96
- willDelayInterval?: number,
97
- payloadFormatIndicator?: boolean,
98
- messageExpiryInterval?: number,
99
- contentType?: string,
100
- responseTopic?: string,
101
- correlationData?: Buffer,
102
- userProperties?: UserProperties
103
- }
104
- }
105
- transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string,
106
- properties?: {
107
- sessionExpiryInterval?: number,
108
- receiveMaximum?: number,
109
- maximumPacketSize?: number,
110
- topicAliasMaximum?: number,
111
- requestResponseInformation?: boolean,
112
- requestProblemInformation?: boolean,
113
- userProperties?: UserProperties,
114
- authenticationMethod?: string,
115
- authenticationData?: Buffer
116
- }
117
- }
118
- export interface ISecureClientOptions {
119
- /**
120
- * optional private keys in PEM format
121
- */
122
- key?: string | string[] | Buffer | Buffer[] | Object[]
123
- /**
124
- * optional cert chains in PEM format
125
- */
126
- cert?: string | string[] | Buffer | Buffer[]
127
- /**
128
- * Optionally override the trusted CA certificates in PEM format
129
- */
130
- ca?: string | string[] | Buffer | Buffer[]
131
- rejectUnauthorized?: boolean
132
- }
133
- export interface IClientPublishOptions {
134
- /**
135
- * the QoS
136
- */
137
- qos?: QoS
138
- /**
139
- * the retain flag
140
- */
141
- retain?: boolean
142
- /**
143
- * whether or not mark a message as duplicate
144
- */
145
- dup?: boolean
146
- /*
147
- * MQTT 5.0 properties object
148
- */
149
- properties?: {
150
- payloadFormatIndicator?: number,
151
- messageExpiryInterval?: number,
152
- topicAlias?: string,
153
- responseTopic?: string,
154
- correlationData?: Buffer,
155
- userProperties?: UserProperties,
156
- subscriptionIdentifier?: number,
157
- contentType?: string
158
- }
159
- /**
160
- * callback called when message is put into `outgoingStore`
161
- */
162
- cbStorePut?: StorePutCallback
163
- }
164
- export interface IClientSubscribeOptions {
165
- /**
166
- * the QoS
167
- */
168
- qos: QoS,
169
- /*
170
- * no local flag
171
- * */
172
- nl?: boolean,
173
- /*
174
- * Retain As Published flag
175
- * */
176
- rap?: boolean,
177
- /*
178
- * Retain Handling option
179
- * */
180
- rh?: number
181
- }
182
- export interface IClientReconnectOptions {
183
- /**
184
- * a Store for the incoming packets
185
- */
186
- incomingStore?: Store
187
- /**
188
- * a Store for the outgoing packets
189
- */
190
- outgoingStore?: Store
191
- }
1
+ import { MqttClient } from './client'
2
+ import { Store } from './store'
3
+ import { ClientOptions } from 'ws'
4
+ import { ClientRequestArgs } from 'http'
5
+ import { QoS, UserProperties } from 'mqtt-packet'
6
+ import { IMessageIdProvider } from './message-id-provider'
7
+
8
+ export declare type StorePutCallback = () => void
9
+
10
+ export interface IClientOptions extends ISecureClientOptions {
11
+ port?: number // port is made into a number subsequently
12
+ host?: string // host does NOT include port
13
+ hostname?: string
14
+ path?: string
15
+ protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs'
16
+
17
+ wsOptions?: ClientOptions | ClientRequestArgs
18
+ /**
19
+ * 10 seconds, set to 0 to disable
20
+ */
21
+ keepalive?: number
22
+ /**
23
+ * 'mqttjs_' + Math.random().toString(16).substr(2, 8)
24
+ */
25
+ clientId?: string
26
+ /**
27
+ * 'MQTT'
28
+ */
29
+ protocolId?: string
30
+ /**
31
+ * 4
32
+ */
33
+ protocolVersion?: number
34
+ /**
35
+ * true, set to false to receive QoS 1 and 2 messages while offline
36
+ */
37
+ clean?: boolean
38
+ /**
39
+ * 1000 milliseconds, interval between two reconnections
40
+ */
41
+ reconnectPeriod?: number
42
+ /**
43
+ * 30 * 1000 milliseconds, time to wait before a CONNACK is received
44
+ */
45
+ connectTimeout?: number
46
+ /**
47
+ * the username required by your broker, if any
48
+ */
49
+ username?: string
50
+ /**
51
+ * the password required by your broker, if any
52
+ */
53
+ password?: string
54
+ /**
55
+ * a Store for the incoming packets
56
+ */
57
+ incomingStore?: Store
58
+ /**
59
+ * a Store for the outgoing packets
60
+ */
61
+ outgoingStore?: Store
62
+ queueQoSZero?: boolean
63
+ reschedulePings?: boolean
64
+ servers?: Array<{
65
+ host: string
66
+ port: number
67
+ protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs'
68
+ }>
69
+ /**
70
+ * true, set to false to disable re-subscribe functionality
71
+ */
72
+ resubscribe?: boolean
73
+ /**
74
+ * a message that will sent by the broker automatically when the client disconnect badly.
75
+ */
76
+ will?: {
77
+ /**
78
+ * the topic to publish
79
+ */
80
+ topic: string
81
+ /**
82
+ * the message to publish
83
+ */
84
+ payload: Buffer | string
85
+ /**
86
+ * the QoS
87
+ */
88
+ qos: QoS
89
+ /**
90
+ * the retain flag
91
+ */
92
+ retain: boolean,
93
+ /*
94
+ * properies object of will
95
+ * */
96
+ properties?: {
97
+ willDelayInterval?: number,
98
+ payloadFormatIndicator?: boolean,
99
+ messageExpiryInterval?: number,
100
+ contentType?: string,
101
+ responseTopic?: string,
102
+ correlationData?: Buffer,
103
+ userProperties?: UserProperties
104
+ }
105
+ }
106
+ transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string,
107
+ properties?: {
108
+ sessionExpiryInterval?: number,
109
+ receiveMaximum?: number,
110
+ maximumPacketSize?: number,
111
+ topicAliasMaximum?: number,
112
+ requestResponseInformation?: boolean,
113
+ requestProblemInformation?: boolean,
114
+ userProperties?: UserProperties,
115
+ authenticationMethod?: string,
116
+ authenticationData?: Buffer
117
+ },
118
+ messageIdProvider?: IMessageIdProvider
119
+ }
120
+ export interface ISecureClientOptions {
121
+ /**
122
+ * optional private keys in PEM format
123
+ */
124
+ key?: string | string[] | Buffer | Buffer[] | Object[]
125
+ /**
126
+ * optional cert chains in PEM format
127
+ */
128
+ cert?: string | string[] | Buffer | Buffer[]
129
+ /**
130
+ * Optionally override the trusted CA certificates in PEM format
131
+ */
132
+ ca?: string | string[] | Buffer | Buffer[]
133
+ rejectUnauthorized?: boolean
134
+ /**
135
+ * optional alpn's
136
+ */
137
+ ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array
138
+ }
139
+ export interface IClientPublishOptions {
140
+ /**
141
+ * the QoS
142
+ */
143
+ qos?: QoS
144
+ /**
145
+ * the retain flag
146
+ */
147
+ retain?: boolean
148
+ /**
149
+ * whether or not mark a message as duplicate
150
+ */
151
+ dup?: boolean
152
+ /*
153
+ * MQTT 5.0 properties object
154
+ */
155
+ properties?: {
156
+ payloadFormatIndicator?: boolean,
157
+ messageExpiryInterval?: number,
158
+ topicAlias?: number,
159
+ responseTopic?: string,
160
+ correlationData?: Buffer,
161
+ userProperties?: UserProperties,
162
+ subscriptionIdentifier?: number,
163
+ contentType?: string
164
+ }
165
+ /**
166
+ * callback called when message is put into `outgoingStore`
167
+ */
168
+ cbStorePut?: StorePutCallback
169
+ }
170
+ export interface IClientSubscribeOptions {
171
+ /**
172
+ * the QoS
173
+ */
174
+ qos: QoS,
175
+ /*
176
+ * no local flag
177
+ * */
178
+ nl?: boolean,
179
+ /*
180
+ * Retain As Published flag
181
+ * */
182
+ rap?: boolean,
183
+ /*
184
+ * Retain Handling option
185
+ * */
186
+ rh?: number,
187
+ /*
188
+ * MQTT 5.0 properies object of subscribe
189
+ * */
190
+ properties?: {
191
+ subscriptionIdentifier?: number,
192
+ userProperties?: UserProperties
193
+ }
194
+ }
195
+ export interface IClientReconnectOptions {
196
+ /**
197
+ * a Store for the incoming packets
198
+ */
199
+ incomingStore?: Store
200
+ /**
201
+ * a Store for the outgoing packets
202
+ */
203
+ outgoingStore?: Store
204
+ }