mqtt 5.10.2 → 5.10.4
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/README.md +11 -1
- package/build/bin/mqtt.js.map +1 -1
- package/build/bin/pub.js +1 -1
- package/build/bin/pub.js.map +1 -1
- package/build/bin/sub.js +1 -1
- package/build/bin/sub.js.map +1 -1
- package/build/index.js +17 -7
- package/build/index.js.map +1 -1
- package/build/lib/BufferedDuplex.js +3 -3
- package/build/lib/BufferedDuplex.js.map +1 -1
- package/build/lib/KeepaliveManager.js.map +1 -1
- package/build/lib/client.d.ts +1 -2
- package/build/lib/client.js +17 -7
- package/build/lib/client.js.map +1 -1
- package/build/lib/connect/ali.js.map +1 -1
- package/build/lib/connect/index.js +6 -7
- package/build/lib/connect/index.js.map +1 -1
- package/build/lib/connect/tls.js.map +1 -1
- package/build/lib/connect/ws.js +4 -3
- package/build/lib/connect/ws.js.map +1 -1
- package/build/lib/connect/wx.js.map +1 -1
- package/build/lib/default-message-id-provider.js.map +1 -1
- package/build/lib/get-timer.js +17 -7
- package/build/lib/get-timer.js.map +1 -1
- package/build/lib/handlers/ack.js.map +1 -1
- package/build/lib/handlers/auth.js.map +1 -1
- package/build/lib/handlers/connack.js +3 -0
- package/build/lib/handlers/connack.js.map +1 -1
- package/build/lib/handlers/index.js.map +1 -1
- package/build/lib/handlers/publish.js.map +1 -1
- package/build/lib/handlers/pubrel.js.map +1 -1
- package/build/lib/is-browser.js.map +1 -1
- package/build/lib/shared.d.ts +0 -1
- package/build/lib/shared.js +2 -2
- package/build/lib/shared.js.map +1 -1
- package/build/lib/store.js.map +1 -1
- package/build/lib/topic-alias-recv.js.map +1 -1
- package/build/lib/topic-alias-send.js.map +1 -1
- package/build/lib/validations.js +2 -3
- package/build/lib/validations.js.map +1 -1
- package/build/mqtt.js +17 -7
- package/build/mqtt.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/dist/mqtt.esm.js +8 -5
- package/dist/mqtt.js +4474 -5381
- package/dist/mqtt.min.js +8 -5
- package/package.json +34 -35
- package/src/lib/BufferedDuplex.ts +1 -1
- package/src/lib/client.ts +7 -1
- package/src/lib/connect/index.ts +2 -5
- package/src/lib/connect/ws.ts +4 -3
- package/src/lib/handlers/connack.ts +3 -0
- package/src/lib/shared.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mqtt",
|
|
3
3
|
"description": "A library for the MQTT protocol",
|
|
4
|
-
"version": "5.10.
|
|
4
|
+
"version": "5.10.4",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Adam Rudd <adamvrr@gmail.com>",
|
|
7
7
|
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"build:browser": "node esbuild.js",
|
|
64
64
|
"build": "npm run build:ts && npm run build:browser",
|
|
65
65
|
"prepare": "npm run build",
|
|
66
|
-
"unit-test:node": "
|
|
66
|
+
"unit-test:node": "node -r esbuild-register --test-concurrency 4 --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout --test test/node/*.ts ",
|
|
67
67
|
"unit-test:browser": "wtr",
|
|
68
|
-
"test:node": "npm run unit-test:node
|
|
68
|
+
"test:node": "node_modules/.bin/nyc npm run unit-test:node",
|
|
69
69
|
"test:browser": "npm run build && npm run unit-test:browser",
|
|
70
70
|
"test": "npm run test:node",
|
|
71
71
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
|
@@ -111,49 +111,48 @@
|
|
|
111
111
|
"net": false
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@types/readable-stream": "^4.0.
|
|
115
|
-
"@types/ws": "^8.5.
|
|
114
|
+
"@types/readable-stream": "^4.0.18",
|
|
115
|
+
"@types/ws": "^8.5.14",
|
|
116
116
|
"commist": "^3.2.0",
|
|
117
117
|
"concat-stream": "^2.0.0",
|
|
118
|
-
"debug": "^4.
|
|
118
|
+
"debug": "^4.4.0",
|
|
119
119
|
"help-me": "^5.0.0",
|
|
120
|
-
"lru-cache": "^10.
|
|
120
|
+
"lru-cache": "^10.4.3",
|
|
121
121
|
"minimist": "^1.2.8",
|
|
122
122
|
"mqtt-packet": "^9.0.1",
|
|
123
123
|
"number-allocator": "^1.0.14",
|
|
124
|
-
"readable-stream": "^4.
|
|
124
|
+
"readable-stream": "^4.7.0",
|
|
125
125
|
"reinterval": "^1.1.0",
|
|
126
|
-
"rfdc": "^1.
|
|
126
|
+
"rfdc": "^1.4.1",
|
|
127
127
|
"split2": "^4.2.0",
|
|
128
|
-
"worker-timers": "^7.1.
|
|
129
|
-
"ws": "^8.
|
|
128
|
+
"worker-timers": "^7.1.8",
|
|
129
|
+
"ws": "^8.18.0"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
|
-
"@esm-bundle/chai": "^4.3.4
|
|
132
|
+
"@esm-bundle/chai": "^4.3.4",
|
|
133
133
|
"@release-it/conventional-changelog": "^7.0.2",
|
|
134
|
-
"@types/chai": "^4.3.
|
|
135
|
-
"@types/node": "^20.
|
|
136
|
-
"@types/sinon": "^17.0.
|
|
137
|
-
"@types/tape": "^5.
|
|
138
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
139
|
-
"@typescript-eslint/parser": "^6.
|
|
140
|
-
"@web/test-runner": "^0.
|
|
134
|
+
"@types/chai": "^4.3.20",
|
|
135
|
+
"@types/node": "^20.17.16",
|
|
136
|
+
"@types/sinon": "^17.0.3",
|
|
137
|
+
"@types/tape": "^5.8.1",
|
|
138
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
139
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
140
|
+
"@web/test-runner": "^0.19.0",
|
|
141
141
|
"@web/test-runner-playwright": "^0.11.0",
|
|
142
142
|
"aedes-cli": "^0.8.0",
|
|
143
|
-
"chai": "^4.
|
|
144
|
-
"chokidar": "^3.
|
|
145
|
-
"codecov": "^3.8.2",
|
|
143
|
+
"chai": "^4.5.0",
|
|
144
|
+
"chokidar": "^3.6.0",
|
|
146
145
|
"conventional-changelog-cli": "^4.1.0",
|
|
147
146
|
"end-of-stream": "^1.4.4",
|
|
148
|
-
"esbuild": "^0.
|
|
147
|
+
"esbuild": "^0.24.2",
|
|
149
148
|
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
150
|
-
"esbuild-register": "^3.
|
|
151
|
-
"eslint": "^8.
|
|
149
|
+
"esbuild-register": "^3.6.0",
|
|
150
|
+
"eslint": "^8.57.1",
|
|
152
151
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
153
152
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
154
|
-
"eslint-config-prettier": "^9.
|
|
155
|
-
"eslint-plugin-import": "^2.
|
|
156
|
-
"eslint-plugin-prettier": "^5.
|
|
153
|
+
"eslint-config-prettier": "^9.1.0",
|
|
154
|
+
"eslint-plugin-import": "^2.31.0",
|
|
155
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
157
156
|
"global": "^4.4.0",
|
|
158
157
|
"leaked-handles": "^5.2.0",
|
|
159
158
|
"mkdirp": "^3.0.1",
|
|
@@ -161,14 +160,14 @@
|
|
|
161
160
|
"mqtt-level-store": "^3.1.0",
|
|
162
161
|
"nyc": "^15.1.0",
|
|
163
162
|
"pre-commit": "^1.2.2",
|
|
164
|
-
"prettier": "^3.
|
|
165
|
-
"release-it": "^16.
|
|
166
|
-
"rimraf": "^5.0.
|
|
163
|
+
"prettier": "^3.4.2",
|
|
164
|
+
"release-it": "^16.3.0",
|
|
165
|
+
"rimraf": "^5.0.10",
|
|
167
166
|
"should": "^13.2.3",
|
|
168
|
-
"sinon": "^17.0.
|
|
167
|
+
"sinon": "^17.0.2",
|
|
169
168
|
"snazzy": "^9.0.0",
|
|
170
|
-
"tape": "^5.
|
|
171
|
-
"ts-node": "^10.9.
|
|
172
|
-
"typescript": "^5.
|
|
169
|
+
"tape": "^5.9.0",
|
|
170
|
+
"ts-node": "^10.9.2",
|
|
171
|
+
"typescript": "^5.7.3"
|
|
173
172
|
}
|
|
174
173
|
}
|
package/src/lib/client.ts
CHANGED
|
@@ -162,6 +162,12 @@ export interface IClientOptions extends ISecureClientOptions {
|
|
|
162
162
|
* 1000 milliseconds, interval between two reconnections
|
|
163
163
|
*/
|
|
164
164
|
reconnectPeriod?: number
|
|
165
|
+
/**
|
|
166
|
+
* Set to true to enable the reconnect period to apply if the initial
|
|
167
|
+
* connection is denied with an error in the CONNACK packet, such as with an
|
|
168
|
+
* authentication error.
|
|
169
|
+
*/
|
|
170
|
+
reconnectOnConnackError?: boolean
|
|
165
171
|
/**
|
|
166
172
|
* 30 * 1000 milliseconds, time to wait before a CONNACK is received
|
|
167
173
|
*/
|
|
@@ -565,7 +571,7 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
565
571
|
? options.customHandleAcks
|
|
566
572
|
: (...args) => {
|
|
567
573
|
args[3](null, 0)
|
|
568
|
-
|
|
574
|
+
}
|
|
569
575
|
|
|
570
576
|
// Disable pre-generated write cache if requested. Will allocate buffers on-the-fly instead. WARNING: This can affect write performance
|
|
571
577
|
if (!this.options.writeCache) {
|
package/src/lib/connect/index.ts
CHANGED
|
@@ -72,17 +72,14 @@ function connect(
|
|
|
72
72
|
parsedOptions.protocol = parsedUrl.protocol as MqttProtocol
|
|
73
73
|
parsedOptions.path = parsedUrl.path
|
|
74
74
|
|
|
75
|
-
parsedOptions.protocol = parsedOptions.protocol?.replace(
|
|
76
|
-
/:$/,
|
|
77
|
-
'',
|
|
78
|
-
) as MqttProtocol
|
|
79
|
-
|
|
80
75
|
opts = { ...parsedOptions, ...opts }
|
|
81
76
|
|
|
82
77
|
// when parsing an url expect the protocol to be set
|
|
83
78
|
if (!opts.protocol) {
|
|
84
79
|
throw new Error('Missing protocol')
|
|
85
80
|
}
|
|
81
|
+
|
|
82
|
+
opts.protocol = opts.protocol.replace(/:$/, '') as MqttProtocol
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
opts.unixSocket = opts.unixSocket || opts.protocol?.includes('+unix')
|
package/src/lib/connect/ws.ts
CHANGED
|
@@ -257,14 +257,15 @@ const browserStreamBuilder: StreamBuilder = (client, opts) => {
|
|
|
257
257
|
* https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/message_event
|
|
258
258
|
*/
|
|
259
259
|
async function onMessage(event: MessageEvent) {
|
|
260
|
+
if (!proxy || proxy.destroyed || !proxy.readable) {
|
|
261
|
+
return
|
|
262
|
+
}
|
|
260
263
|
let { data } = event
|
|
261
264
|
if (data instanceof ArrayBuffer) data = Buffer.from(data)
|
|
262
265
|
else if (data instanceof Blob)
|
|
263
266
|
data = Buffer.from(await new Response(data).arrayBuffer())
|
|
264
267
|
else data = Buffer.from(data as string, 'utf8')
|
|
265
|
-
|
|
266
|
-
proxy.push(data)
|
|
267
|
-
}
|
|
268
|
+
proxy.push(data)
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
function socketWriteBrowser(
|
package/src/lib/shared.ts
CHANGED