mqtt 4.2.4 → 4.2.8
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 +23 -0
- package/CONTRIBUTING.md +27 -27
- package/LICENSE.md +15 -15
- package/README.md +792 -784
- package/bin/mqtt.js +27 -27
- package/bin/pub.js +146 -146
- package/bin/sub.js +123 -123
- package/dist/mqtt.js +7466 -8450
- 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 +1581 -1581
- package/lib/connect/ali.js +128 -128
- package/lib/connect/index.js +164 -177
- package/lib/connect/tcp.js +21 -21
- package/lib/connect/tls.js +45 -45
- package/lib/connect/ws.js +256 -255
- package/lib/connect/wx.js +134 -134
- package/lib/store.js +128 -128
- package/lib/validations.js +52 -52
- package/mqtt.js +17 -17
- package/package.json +109 -108
- package/types/index.d.ts +28 -27
- package/types/lib/client-options.d.ts +191 -191
- package/types/lib/client.d.ts +240 -232
- package/types/lib/connect/index.d.ts +10 -10
- package/types/lib/store-options.d.ts +6 -6
- package/types/lib/store.d.ts +46 -46
package/package.json
CHANGED
|
@@ -1,108 +1,109 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mqtt",
|
|
3
|
-
"description": "A library for the MQTT protocol",
|
|
4
|
-
"version": "4.2.
|
|
5
|
-
"contributors": [
|
|
6
|
-
"Adam Rudd <adamvrr@gmail.com>",
|
|
7
|
-
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
|
|
8
|
-
"Siarhei Buntsevich <scarry0506@gmail.com> (https://github.com/scarry1992)",
|
|
9
|
-
"Yoseph Maguire <yomaguir@microsoft.com> (https://github.com/YoDaMa)"
|
|
10
|
-
],
|
|
11
|
-
"keywords": [
|
|
12
|
-
"mqtt",
|
|
13
|
-
"publish/subscribe",
|
|
14
|
-
"publish",
|
|
15
|
-
"subscribe"
|
|
16
|
-
],
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git://github.com/mqttjs/MQTT.js.git"
|
|
21
|
-
},
|
|
22
|
-
"main": "mqtt.js",
|
|
23
|
-
"types": "types/index.d.ts",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "node_modules/.bin/nyc --reporter=lcov --reporter=text ./node_modules/mocha/bin/_mocha",
|
|
26
|
-
"pretest": "standard | snazzy",
|
|
27
|
-
"tslint": "tslint types/**/*.d.ts",
|
|
28
|
-
"typescript-compile-test": "tsc -p test/typescript/tsconfig.json",
|
|
29
|
-
"typescript-compile-execute": "node test/typescript/*.js",
|
|
30
|
-
"typescript-test": "npm run typescript-compile-test && npm run typescript-compile-execute",
|
|
31
|
-
"browser-build": "rimraf dist/ && mkdirp dist/ && browserify mqtt.js --standalone mqtt > dist/mqtt.js && uglifyjs dist/mqtt.js --compress --mangle --output dist/mqtt.min.js",
|
|
32
|
-
"prepare": "npm run browser-build",
|
|
33
|
-
"browser-test": "airtap --server test/browser/server.js --local --open test/browser/test.js",
|
|
34
|
-
"sauce-test": "airtap --server test/browser/server.js -- test/browser/test.js",
|
|
35
|
-
"ci": "npm run tslint && npm run typescript-compile-test && npm run test && codecov"
|
|
36
|
-
},
|
|
37
|
-
"pre-commit": [
|
|
38
|
-
"
|
|
39
|
-
"tslint"
|
|
40
|
-
],
|
|
41
|
-
"bin": {
|
|
42
|
-
"mqtt_pub": "./bin/pub.js",
|
|
43
|
-
"mqtt_sub": "./bin/sub.js",
|
|
44
|
-
"mqtt": "./bin/mqtt.js"
|
|
45
|
-
},
|
|
46
|
-
"files": [
|
|
47
|
-
"dist/",
|
|
48
|
-
"CONTRIBUTING.md",
|
|
49
|
-
"doc",
|
|
50
|
-
"lib",
|
|
51
|
-
"bin",
|
|
52
|
-
"types",
|
|
53
|
-
"mqtt.js"
|
|
54
|
-
],
|
|
55
|
-
"engines": {
|
|
56
|
-
"node": ">=10.0.0"
|
|
57
|
-
},
|
|
58
|
-
"browser": {
|
|
59
|
-
"./mqtt.js": "./lib/connect/index.js",
|
|
60
|
-
"fs": false,
|
|
61
|
-
"tls": false,
|
|
62
|
-
"net": false
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"commist": "^1.0.0",
|
|
66
|
-
"concat-stream": "^2.0.0",
|
|
67
|
-
"debug": "^4.1.1",
|
|
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
|
-
"tslint
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mqtt",
|
|
3
|
+
"description": "A library for the MQTT protocol",
|
|
4
|
+
"version": "4.2.8",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Adam Rudd <adamvrr@gmail.com>",
|
|
7
|
+
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
|
|
8
|
+
"Siarhei Buntsevich <scarry0506@gmail.com> (https://github.com/scarry1992)",
|
|
9
|
+
"Yoseph Maguire <yomaguir@microsoft.com> (https://github.com/YoDaMa)"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"mqtt",
|
|
13
|
+
"publish/subscribe",
|
|
14
|
+
"publish",
|
|
15
|
+
"subscribe"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git://github.com/mqttjs/MQTT.js.git"
|
|
21
|
+
},
|
|
22
|
+
"main": "mqtt.js",
|
|
23
|
+
"types": "types/index.d.ts",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "node_modules/.bin/nyc --reporter=lcov --reporter=text ./node_modules/mocha/bin/_mocha",
|
|
26
|
+
"pretest": "standard | snazzy",
|
|
27
|
+
"tslint": "tslint types/**/*.d.ts",
|
|
28
|
+
"typescript-compile-test": "tsc -p test/typescript/tsconfig.json",
|
|
29
|
+
"typescript-compile-execute": "node test/typescript/*.js",
|
|
30
|
+
"typescript-test": "npm run typescript-compile-test && npm run typescript-compile-execute",
|
|
31
|
+
"browser-build": "rimraf dist/ && mkdirp dist/ && browserify mqtt.js --standalone mqtt > dist/mqtt.js && uglifyjs dist/mqtt.js --compress --mangle --output dist/mqtt.min.js",
|
|
32
|
+
"prepare": "npm run browser-build",
|
|
33
|
+
"browser-test": "airtap --server test/browser/server.js --local --open test/browser/test.js",
|
|
34
|
+
"sauce-test": "airtap --server test/browser/server.js -- test/browser/test.js",
|
|
35
|
+
"ci": "npm run tslint && npm run typescript-compile-test && npm run test && codecov"
|
|
36
|
+
},
|
|
37
|
+
"pre-commit": [
|
|
38
|
+
"pretest",
|
|
39
|
+
"tslint"
|
|
40
|
+
],
|
|
41
|
+
"bin": {
|
|
42
|
+
"mqtt_pub": "./bin/pub.js",
|
|
43
|
+
"mqtt_sub": "./bin/sub.js",
|
|
44
|
+
"mqtt": "./bin/mqtt.js"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist/",
|
|
48
|
+
"CONTRIBUTING.md",
|
|
49
|
+
"doc",
|
|
50
|
+
"lib",
|
|
51
|
+
"bin",
|
|
52
|
+
"types",
|
|
53
|
+
"mqtt.js"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=10.0.0"
|
|
57
|
+
},
|
|
58
|
+
"browser": {
|
|
59
|
+
"./mqtt.js": "./lib/connect/index.js",
|
|
60
|
+
"fs": false,
|
|
61
|
+
"tls": false,
|
|
62
|
+
"net": false
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"commist": "^1.0.0",
|
|
66
|
+
"concat-stream": "^2.0.0",
|
|
67
|
+
"debug": "^4.1.1",
|
|
68
|
+
"duplexify": "^4.1.1",
|
|
69
|
+
"help-me": "^3.0.0",
|
|
70
|
+
"inherits": "^2.0.3",
|
|
71
|
+
"minimist": "^1.2.5",
|
|
72
|
+
"mqtt-packet": "^6.8.0",
|
|
73
|
+
"pump": "^3.0.0",
|
|
74
|
+
"readable-stream": "^3.6.0",
|
|
75
|
+
"reinterval": "^1.1.0",
|
|
76
|
+
"split2": "^3.1.0",
|
|
77
|
+
"ws": "^7.5.0",
|
|
78
|
+
"xtend": "^4.0.2"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@types/node": "^10.0.0",
|
|
82
|
+
"airtap": "^3.0.0",
|
|
83
|
+
"browserify": "^16.5.0",
|
|
84
|
+
"chai": "^4.2.0",
|
|
85
|
+
"codecov": "^3.0.4",
|
|
86
|
+
"end-of-stream": "^1.4.1",
|
|
87
|
+
"global": "^4.3.2",
|
|
88
|
+
"aedes": "^0.42.5",
|
|
89
|
+
"mkdirp": "^0.5.1",
|
|
90
|
+
"mocha": "^4.1.0",
|
|
91
|
+
"mqtt-connection": "^4.0.0",
|
|
92
|
+
"nyc": "^15.0.1",
|
|
93
|
+
"pre-commit": "^1.2.2",
|
|
94
|
+
"rimraf": "^3.0.2",
|
|
95
|
+
"should": "^13.2.1",
|
|
96
|
+
"sinon": "^9.0.0",
|
|
97
|
+
"snazzy": "^8.0.0",
|
|
98
|
+
"standard": "^11.0.1",
|
|
99
|
+
"tslint": "^5.11.0",
|
|
100
|
+
"tslint-config-standard": "^8.0.1",
|
|
101
|
+
"typescript": "^3.2.2",
|
|
102
|
+
"uglify-es": "^3.3.9"
|
|
103
|
+
},
|
|
104
|
+
"standard": {
|
|
105
|
+
"env": [
|
|
106
|
+
"mocha"
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
export * from './lib/client'
|
|
2
|
-
export * from './lib/connect'
|
|
3
|
-
export * from './lib/store'
|
|
4
|
-
export * from './lib/client-options'
|
|
5
|
-
import { MqttClient } from './lib/client'
|
|
6
|
-
export { MqttClient as Client }
|
|
7
|
-
export {
|
|
8
|
-
QoS,
|
|
9
|
-
PacketCmd,
|
|
10
|
-
IPacket,
|
|
11
|
-
IConnectPacket,
|
|
12
|
-
IPublishPacket,
|
|
13
|
-
IConnackPacket,
|
|
14
|
-
ISubscription,
|
|
15
|
-
ISubscribePacket,
|
|
16
|
-
ISubackPacket,
|
|
17
|
-
IUnsubscribePacket,
|
|
18
|
-
IUnsubackPacket,
|
|
19
|
-
IPubackPacket,
|
|
20
|
-
IPubcompPacket,
|
|
21
|
-
IPubrelPacket,
|
|
22
|
-
IPubrecPacket,
|
|
23
|
-
IPingreqPacket,
|
|
24
|
-
IPingrespPacket,
|
|
25
|
-
IDisconnectPacket,
|
|
26
|
-
Packet
|
|
27
|
-
|
|
1
|
+
export * from './lib/client'
|
|
2
|
+
export * from './lib/connect'
|
|
3
|
+
export * from './lib/store'
|
|
4
|
+
export * from './lib/client-options'
|
|
5
|
+
import { MqttClient } from './lib/client'
|
|
6
|
+
export { MqttClient as Client }
|
|
7
|
+
export {
|
|
8
|
+
QoS,
|
|
9
|
+
PacketCmd,
|
|
10
|
+
IPacket,
|
|
11
|
+
IConnectPacket,
|
|
12
|
+
IPublishPacket,
|
|
13
|
+
IConnackPacket,
|
|
14
|
+
ISubscription,
|
|
15
|
+
ISubscribePacket,
|
|
16
|
+
ISubackPacket,
|
|
17
|
+
IUnsubscribePacket,
|
|
18
|
+
IUnsubackPacket,
|
|
19
|
+
IPubackPacket,
|
|
20
|
+
IPubcompPacket,
|
|
21
|
+
IPubrelPacket,
|
|
22
|
+
IPubrecPacket,
|
|
23
|
+
IPingreqPacket,
|
|
24
|
+
IPingrespPacket,
|
|
25
|
+
IDisconnectPacket,
|
|
26
|
+
Packet,
|
|
27
|
+
UserProperties
|
|
28
|
+
} from 'mqtt-packet'
|
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
import { MqttClient } from './client'
|
|
2
|
-
import { Store } from './store'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 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?:
|
|
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?:
|
|
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?:
|
|
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
|
+
|
|
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
|
+
}
|