mqtt 5.10.3 → 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.
Files changed (51) hide show
  1. package/README.md +2 -1
  2. package/build/bin/mqtt.js.map +1 -1
  3. package/build/bin/pub.js +1 -1
  4. package/build/bin/pub.js.map +1 -1
  5. package/build/bin/sub.js +1 -1
  6. package/build/bin/sub.js.map +1 -1
  7. package/build/index.js +17 -7
  8. package/build/index.js.map +1 -1
  9. package/build/lib/BufferedDuplex.js +3 -3
  10. package/build/lib/BufferedDuplex.js.map +1 -1
  11. package/build/lib/KeepaliveManager.js.map +1 -1
  12. package/build/lib/client.d.ts +0 -2
  13. package/build/lib/client.js +17 -7
  14. package/build/lib/client.js.map +1 -1
  15. package/build/lib/connect/ali.js.map +1 -1
  16. package/build/lib/connect/index.js +6 -7
  17. package/build/lib/connect/index.js.map +1 -1
  18. package/build/lib/connect/tls.js.map +1 -1
  19. package/build/lib/connect/ws.js +4 -3
  20. package/build/lib/connect/ws.js.map +1 -1
  21. package/build/lib/connect/wx.js.map +1 -1
  22. package/build/lib/default-message-id-provider.js.map +1 -1
  23. package/build/lib/get-timer.js +17 -7
  24. package/build/lib/get-timer.js.map +1 -1
  25. package/build/lib/handlers/ack.js.map +1 -1
  26. package/build/lib/handlers/auth.js.map +1 -1
  27. package/build/lib/handlers/connack.js.map +1 -1
  28. package/build/lib/handlers/index.js.map +1 -1
  29. package/build/lib/handlers/publish.js.map +1 -1
  30. package/build/lib/handlers/pubrel.js.map +1 -1
  31. package/build/lib/is-browser.js.map +1 -1
  32. package/build/lib/shared.d.ts +0 -1
  33. package/build/lib/shared.js +2 -2
  34. package/build/lib/shared.js.map +1 -1
  35. package/build/lib/store.js.map +1 -1
  36. package/build/lib/topic-alias-recv.js.map +1 -1
  37. package/build/lib/topic-alias-send.js.map +1 -1
  38. package/build/lib/validations.js +2 -3
  39. package/build/lib/validations.js.map +1 -1
  40. package/build/mqtt.js +17 -7
  41. package/build/mqtt.js.map +1 -1
  42. package/build/tsconfig.build.tsbuildinfo +1 -1
  43. package/dist/mqtt.esm.js +8 -5
  44. package/dist/mqtt.js +4471 -5381
  45. package/dist/mqtt.min.js +8 -5
  46. package/package.json +32 -32
  47. package/src/lib/BufferedDuplex.ts +1 -1
  48. package/src/lib/client.ts +1 -1
  49. package/src/lib/connect/index.ts +2 -5
  50. package/src/lib/connect/ws.ts +4 -3
  51. 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.3",
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)",
@@ -111,48 +111,48 @@
111
111
  "net": false
112
112
  },
113
113
  "dependencies": {
114
- "@types/readable-stream": "^4.0.5",
115
- "@types/ws": "^8.5.9",
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.3.4",
118
+ "debug": "^4.4.0",
119
119
  "help-me": "^5.0.0",
120
- "lru-cache": "^10.0.1",
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.4.2",
124
+ "readable-stream": "^4.7.0",
125
125
  "reinterval": "^1.1.0",
126
- "rfdc": "^1.3.0",
126
+ "rfdc": "^1.4.1",
127
127
  "split2": "^4.2.0",
128
- "worker-timers": "^7.1.4",
129
- "ws": "^8.17.1"
128
+ "worker-timers": "^7.1.8",
129
+ "ws": "^8.18.0"
130
130
  },
131
131
  "devDependencies": {
132
- "@esm-bundle/chai": "^4.3.4-fix.0",
132
+ "@esm-bundle/chai": "^4.3.4",
133
133
  "@release-it/conventional-changelog": "^7.0.2",
134
- "@types/chai": "^4.3.10",
135
- "@types/node": "^20.9.0",
136
- "@types/sinon": "^17.0.1",
137
- "@types/tape": "^5.6.4",
138
- "@typescript-eslint/eslint-plugin": "^6.10.0",
139
- "@typescript-eslint/parser": "^6.10.0",
140
- "@web/test-runner": "^0.18.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.3.10",
144
- "chokidar": "^3.5.3",
143
+ "chai": "^4.5.0",
144
+ "chokidar": "^3.6.0",
145
145
  "conventional-changelog-cli": "^4.1.0",
146
146
  "end-of-stream": "^1.4.4",
147
- "esbuild": "^0.19.5",
147
+ "esbuild": "^0.24.2",
148
148
  "esbuild-plugin-polyfill-node": "^0.3.0",
149
- "esbuild-register": "^3.5.0",
150
- "eslint": "^8.53.0",
149
+ "esbuild-register": "^3.6.0",
150
+ "eslint": "^8.57.1",
151
151
  "eslint-config-airbnb-base": "^15.0.0",
152
152
  "eslint-config-airbnb-typescript": "^17.1.0",
153
- "eslint-config-prettier": "^9.0.0",
154
- "eslint-plugin-import": "^2.29.0",
155
- "eslint-plugin-prettier": "^5.0.1",
153
+ "eslint-config-prettier": "^9.1.0",
154
+ "eslint-plugin-import": "^2.31.0",
155
+ "eslint-plugin-prettier": "^5.2.3",
156
156
  "global": "^4.4.0",
157
157
  "leaked-handles": "^5.2.0",
158
158
  "mkdirp": "^3.0.1",
@@ -160,14 +160,14 @@
160
160
  "mqtt-level-store": "^3.1.0",
161
161
  "nyc": "^15.1.0",
162
162
  "pre-commit": "^1.2.2",
163
- "prettier": "^3.0.3",
164
- "release-it": "^16.2.1",
165
- "rimraf": "^5.0.5",
163
+ "prettier": "^3.4.2",
164
+ "release-it": "^16.3.0",
165
+ "rimraf": "^5.0.10",
166
166
  "should": "^13.2.3",
167
- "sinon": "^17.0.1",
167
+ "sinon": "^17.0.2",
168
168
  "snazzy": "^9.0.0",
169
- "tape": "^5.7.2",
170
- "ts-node": "^10.9.1",
171
- "typescript": "^5.2.2"
169
+ "tape": "^5.9.0",
170
+ "ts-node": "^10.9.2",
171
+ "typescript": "^5.7.3"
172
172
  }
173
173
  }
@@ -56,7 +56,7 @@ export class BufferedDuplex extends Duplex {
56
56
  this.isSocketOpen = false
57
57
 
58
58
  this.proxy.on('data', (chunk) => {
59
- if (!this.destroyed) {
59
+ if (!this.destroyed && this.readable) {
60
60
  this.push(chunk)
61
61
  }
62
62
  })
package/src/lib/client.ts CHANGED
@@ -571,7 +571,7 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
571
571
  ? options.customHandleAcks
572
572
  : (...args) => {
573
573
  args[3](null, 0)
574
- }
574
+ }
575
575
 
576
576
  // Disable pre-generated write cache if requested. Will allocate buffers on-the-fly instead. WARNING: This can affect write performance
577
577
  if (!this.options.writeCache) {
@@ -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')
@@ -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
- if (proxy && !proxy.destroyed) {
266
- proxy.push(data)
267
- }
268
+ proxy.push(data)
268
269
  }
269
270
 
270
271
  function socketWriteBrowser(
package/src/lib/shared.ts CHANGED
@@ -81,7 +81,7 @@ export const nextTick =
81
81
  ? process.nextTick
82
82
  : (callback: () => void) => {
83
83
  setTimeout(callback, 0)
84
- }
84
+ }
85
85
 
86
86
  // eslint-disable-next-line @typescript-eslint/no-var-requires
87
87
  export const MQTTJS_VERSION = require('../../package.json').version