mqtt 4.2.7 → 4.3.2
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.
- package/CHANGELOG.md +53 -1
- package/CONTRIBUTING.md +27 -27
- package/LICENSE.md +15 -15
- package/README.md +843 -792
- package/bin/mqtt.js +27 -27
- package/bin/pub.js +146 -146
- package/bin/sub.js +123 -123
- package/dist/mqtt.js +12628 -4503
- package/dist/mqtt.min.js +1 -1
- package/doc/help.txt +8 -8
- package/doc/publish.txt +26 -26
- package/doc/subscribe.txt +26 -26
- package/lib/client.js +1890 -1581
- package/lib/connect/ali.js +128 -128
- package/lib/connect/index.js +165 -164
- package/lib/connect/tcp.js +20 -21
- package/lib/connect/tls.js +48 -45
- package/lib/connect/ws.js +256 -256
- package/lib/connect/wx.js +132 -134
- package/lib/default-message-id-provider.js +69 -0
- package/lib/store.js +128 -128
- package/lib/topic-alias-recv.js +47 -0
- package/lib/topic-alias-send.js +93 -0
- package/lib/unique-message-id-provider.js +65 -0
- package/lib/validations.js +52 -52
- package/mqtt.js +21 -17
- package/package.json +21 -8
- package/types/index.d.ts +30 -28
- package/types/lib/client-options.d.ts +204 -191
- package/types/lib/client.d.ts +261 -239
- package/types/lib/connect/index.d.ts +10 -10
- package/types/lib/default-message-id-provider.d.ts +49 -0
- package/types/lib/message-id-provider.d.ts +40 -0
- package/types/lib/store-options.d.ts +6 -6
- package/types/lib/store.d.ts +46 -46
- package/types/lib/unique-message-id-provider.d.ts +48 -0
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
*
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
}
|