mqtt 5.9.0 → 5.10.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.
- package/build/lib/BufferedDuplex.js +3 -1
- package/build/lib/BufferedDuplex.js.map +1 -1
- package/build/lib/client.d.ts +9 -6
- package/build/lib/client.js +1 -1
- package/build/lib/client.js.map +1 -1
- package/build/lib/connect/ws.js +3 -1
- package/build/lib/connect/ws.js.map +1 -1
- package/build/lib/handlers/ack.js +4 -5
- package/build/lib/handlers/ack.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/dist/mqtt.esm.js +5 -5
- package/dist/mqtt.js +12 -9
- package/dist/mqtt.min.js +5 -5
- package/package.json +1 -2
- package/src/lib/BufferedDuplex.ts +3 -1
- package/src/lib/client.ts +19 -8
- package/src/lib/connect/ws.ts +3 -1
- package/src/lib/handlers/ack.ts +10 -6
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.
|
|
4
|
+
"version": "5.10.0",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Adam Rudd <adamvrr@gmail.com>",
|
|
7
7
|
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
|
|
@@ -116,7 +116,6 @@
|
|
|
116
116
|
"help-me": "^5.0.0",
|
|
117
117
|
"lru-cache": "^10.0.1",
|
|
118
118
|
"minimist": "^1.2.8",
|
|
119
|
-
"mqtt": "^5.2.0",
|
|
120
119
|
"mqtt-packet": "^9.0.0",
|
|
121
120
|
"number-allocator": "^1.0.14",
|
|
122
121
|
"readable-stream": "^4.4.2",
|
package/src/lib/client.ts
CHANGED
|
@@ -323,7 +323,7 @@ export interface IClientReconnectOptions {
|
|
|
323
323
|
}
|
|
324
324
|
export interface IClientSubscribeProperties {
|
|
325
325
|
/*
|
|
326
|
-
* MQTT 5.0
|
|
326
|
+
* MQTT 5.0 properties object of subscribe
|
|
327
327
|
* */
|
|
328
328
|
properties?: ISubscribePacket['properties']
|
|
329
329
|
}
|
|
@@ -370,12 +370,20 @@ export type ISubscriptionMap = {
|
|
|
370
370
|
resubscribe?: boolean
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
export interface IClientUnsubscribeProperties {
|
|
374
|
+
/*
|
|
375
|
+
* MQTT 5.0 properties object for unsubscribe
|
|
376
|
+
* */
|
|
377
|
+
properties?: IUnsubscribePacket['properties']
|
|
378
|
+
}
|
|
379
|
+
|
|
373
380
|
export { IConnackPacket, IDisconnectPacket, IPublishPacket, Packet }
|
|
374
381
|
export type OnConnectCallback = (packet: IConnackPacket) => void
|
|
375
382
|
export type OnDisconnectCallback = (packet: IDisconnectPacket) => void
|
|
376
383
|
export type ClientSubscribeCallback = (
|
|
377
384
|
err: Error | null,
|
|
378
385
|
granted?: ISubscriptionGrant[],
|
|
386
|
+
packet?: ISubackPacket,
|
|
379
387
|
) => void
|
|
380
388
|
export type OnMessageCallback = (
|
|
381
389
|
topic: string,
|
|
@@ -385,7 +393,10 @@ export type OnMessageCallback = (
|
|
|
385
393
|
export type OnPacketCallback = (packet: Packet) => void
|
|
386
394
|
export type OnCloseCallback = () => void
|
|
387
395
|
export type OnErrorCallback = (error: Error | ErrorWithReasonCode) => void
|
|
388
|
-
export type PacketCallback = (
|
|
396
|
+
export type PacketCallback = (
|
|
397
|
+
error?: Error | ErrorWithReasonCode,
|
|
398
|
+
packet?: Packet,
|
|
399
|
+
) => any
|
|
389
400
|
export type CloseCallback = (error?: Error) => void
|
|
390
401
|
|
|
391
402
|
export interface MqttClientEventCallbacks {
|
|
@@ -1238,7 +1249,7 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
1238
1249
|
}
|
|
1239
1250
|
}
|
|
1240
1251
|
|
|
1241
|
-
callback(err, subs)
|
|
1252
|
+
callback(err, subs, packet2)
|
|
1242
1253
|
},
|
|
1243
1254
|
}
|
|
1244
1255
|
this.log('subscribe :: call _sendPacket')
|
|
@@ -1297,7 +1308,7 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
1297
1308
|
public unsubscribe(topic: string | string[]): MqttClient
|
|
1298
1309
|
public unsubscribe(
|
|
1299
1310
|
topic: string | string[],
|
|
1300
|
-
opts?:
|
|
1311
|
+
opts?: IClientUnsubscribeProperties,
|
|
1301
1312
|
): MqttClient
|
|
1302
1313
|
public unsubscribe(
|
|
1303
1314
|
topic: string | string[],
|
|
@@ -1305,12 +1316,12 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
1305
1316
|
): MqttClient
|
|
1306
1317
|
public unsubscribe(
|
|
1307
1318
|
topic: string | string[],
|
|
1308
|
-
opts?:
|
|
1319
|
+
opts?: IClientUnsubscribeProperties,
|
|
1309
1320
|
callback?: PacketCallback,
|
|
1310
1321
|
): MqttClient
|
|
1311
1322
|
public unsubscribe(
|
|
1312
1323
|
topic: string | string[],
|
|
1313
|
-
opts?:
|
|
1324
|
+
opts?: IClientUnsubscribeProperties | PacketCallback,
|
|
1314
1325
|
callback?: PacketCallback,
|
|
1315
1326
|
): MqttClient {
|
|
1316
1327
|
if (typeof topic === 'string') {
|
|
@@ -1392,11 +1403,11 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
|
|
|
1392
1403
|
): Promise<Packet | undefined>
|
|
1393
1404
|
public unsubscribeAsync(
|
|
1394
1405
|
topic: string | string[],
|
|
1395
|
-
opts?:
|
|
1406
|
+
opts?: IClientUnsubscribeProperties,
|
|
1396
1407
|
): Promise<Packet | undefined>
|
|
1397
1408
|
public unsubscribeAsync(
|
|
1398
1409
|
topic: string | string[],
|
|
1399
|
-
opts?:
|
|
1410
|
+
opts?: IClientUnsubscribeProperties,
|
|
1400
1411
|
): Promise<Packet | undefined> {
|
|
1401
1412
|
return new Promise((resolve, reject) => {
|
|
1402
1413
|
this.unsubscribe(topic, opts, (err, packet) => {
|
package/src/lib/connect/ws.ts
CHANGED
|
@@ -260,7 +260,9 @@ const browserStreamBuilder: StreamBuilder = (client, opts) => {
|
|
|
260
260
|
let { data } = event
|
|
261
261
|
if (data instanceof ArrayBuffer) data = Buffer.from(data)
|
|
262
262
|
else data = Buffer.from(data as string, 'utf8')
|
|
263
|
-
proxy.
|
|
263
|
+
if (proxy && !proxy.destroyed) {
|
|
264
|
+
proxy.push(data)
|
|
265
|
+
}
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
function socketWriteBrowser(
|
package/src/lib/handlers/ack.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Other Socket Errors: EADDRINUSE, ECONNRESET, ENOTFOUND, ETIMEDOUT.
|
|
2
2
|
|
|
3
|
-
import { PacketHandler } from '../shared'
|
|
3
|
+
import { PacketHandler, ErrorWithReasonCode } from '../shared'
|
|
4
4
|
|
|
5
5
|
export const ReasonCodes = {
|
|
6
6
|
0: '',
|
|
@@ -82,8 +82,10 @@ const handleAck: PacketHandler = (client, packet) => {
|
|
|
82
82
|
const pubackRC = packet.reasonCode
|
|
83
83
|
// Callback - we're done
|
|
84
84
|
if (pubackRC && pubackRC > 0 && pubackRC !== 16) {
|
|
85
|
-
err = new
|
|
86
|
-
|
|
85
|
+
err = new ErrorWithReasonCode(
|
|
86
|
+
`Publish error: ${ReasonCodes[pubackRC]}`,
|
|
87
|
+
pubackRC,
|
|
88
|
+
)
|
|
87
89
|
client['_removeOutgoingAndStoreMessage'](messageId, () => {
|
|
88
90
|
cb(err, packet)
|
|
89
91
|
})
|
|
@@ -102,8 +104,10 @@ const handleAck: PacketHandler = (client, packet) => {
|
|
|
102
104
|
const pubrecRC = packet.reasonCode
|
|
103
105
|
|
|
104
106
|
if (pubrecRC && pubrecRC > 0 && pubrecRC !== 16) {
|
|
105
|
-
err = new
|
|
106
|
-
|
|
107
|
+
err = new ErrorWithReasonCode(
|
|
108
|
+
`Publish error: ${ReasonCodes[pubrecRC]}`,
|
|
109
|
+
pubrecRC,
|
|
110
|
+
)
|
|
107
111
|
client['_removeOutgoingAndStoreMessage'](messageId, () => {
|
|
108
112
|
cb(err, packet)
|
|
109
113
|
})
|
|
@@ -140,7 +144,7 @@ const handleAck: PacketHandler = (client, packet) => {
|
|
|
140
144
|
delete client.outgoing[messageId]
|
|
141
145
|
client.messageIdProvider.deallocate(messageId)
|
|
142
146
|
client['_invokeStoreProcessingQueue']()
|
|
143
|
-
cb(null)
|
|
147
|
+
cb(null, packet)
|
|
144
148
|
break
|
|
145
149
|
}
|
|
146
150
|
default:
|