mqtt 4.3.4 → 4.3.7

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.
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ const { Buffer } = require('buffer')
3
4
  const Transform = require('readable-stream').Transform
4
5
  const duplexify = require('duplexify')
5
6
 
package/lib/connect/ws.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ const { Buffer } = require('buffer')
3
4
  const WS = require('ws')
4
5
  const debug = require('debug')('mqttjs:ws')
5
6
  const duplexify = require('duplexify')
package/lib/connect/wx.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ const { Buffer } = require('buffer')
3
4
  const Transform = require('readable-stream').Transform
4
5
  const duplexify = require('duplexify')
5
6
 
@@ -1,91 +1,91 @@
1
- 'use strict'
2
-
3
- /**
4
- * Module dependencies
5
- */
6
- const LruMap = require('lru-cache')
7
- const NumberAllocator = require('number-allocator').NumberAllocator
8
-
9
- /**
10
- * Topic Alias sending manager
11
- * This holds both topic to alias and alias to topic map
12
- * @param {Number} [max] - topic alias maximum entries
13
- */
14
- function TopicAliasSend (max) {
15
- if (!(this instanceof TopicAliasSend)) {
16
- return new TopicAliasSend(max)
17
- }
18
-
19
- if (max > 0) {
20
- this.aliasToTopic = new LruMap({ max: max })
21
- this.topicToAlias = {}
22
- this.numberAllocator = new NumberAllocator(1, max)
23
- this.max = max
24
- this.length = 0
25
- }
26
- }
27
-
28
- /**
29
- * Insert or update topic - alias entry.
30
- * @param {String} [topic] - topic
31
- * @param {Number} [alias] - topic alias
32
- * @returns {Boolean} - if success return true otherwise false
33
- */
34
- TopicAliasSend.prototype.put = function (topic, alias) {
35
- if (alias === 0 || alias > this.max) {
36
- return false
37
- }
38
- const entry = this.aliasToTopic.get(alias)
39
- if (entry) {
40
- delete this.topicToAlias[entry]
41
- }
42
- this.aliasToTopic.set(alias, topic)
43
- this.topicToAlias[topic] = alias
44
- this.numberAllocator.use(alias)
45
- this.length = this.aliasToTopic.length
46
- return true
47
- }
48
-
49
- /**
50
- * Get topic by alias
51
- * @param {Number} [alias] - topic alias
52
- * @returns {String} - if mapped topic exists return topic, otherwise return undefined
53
- */
54
- TopicAliasSend.prototype.getTopicByAlias = function (alias) {
55
- return this.aliasToTopic.get(alias)
56
- }
57
-
58
- /**
59
- * Get topic by alias
60
- * @param {String} [topic] - topic
61
- * @returns {Number} - if mapped topic exists return topic alias, otherwise return undefined
62
- */
63
- TopicAliasSend.prototype.getAliasByTopic = function (topic) {
64
- const alias = this.topicToAlias[topic]
65
- if (typeof alias !== 'undefined') {
66
- this.aliasToTopic.get(alias) // LRU update
67
- }
68
- return alias
69
- }
70
-
71
- /**
72
- * Clear all entries
73
- */
74
- TopicAliasSend.prototype.clear = function () {
75
- this.aliasToTopic.reset()
76
- this.topicToAlias = {}
77
- this.numberAllocator.clear()
78
- this.length = 0
79
- }
80
-
81
- /**
82
- * Get Least Recently Used (LRU) topic alias
83
- * @returns {Number} - if vacant alias exists then return it, otherwise then return LRU alias
84
- */
85
- TopicAliasSend.prototype.getLruAlias = function () {
86
- const alias = this.numberAllocator.firstVacant()
87
- if (alias) return alias
88
- return this.aliasToTopic.keys()[this.aliasToTopic.length - 1]
89
- }
90
-
91
- module.exports = TopicAliasSend
1
+ 'use strict'
2
+
3
+ /**
4
+ * Module dependencies
5
+ */
6
+ const LruMap = require('lru-cache')
7
+ const NumberAllocator = require('number-allocator').NumberAllocator
8
+
9
+ /**
10
+ * Topic Alias sending manager
11
+ * This holds both topic to alias and alias to topic map
12
+ * @param {Number} [max] - topic alias maximum entries
13
+ */
14
+ function TopicAliasSend (max) {
15
+ if (!(this instanceof TopicAliasSend)) {
16
+ return new TopicAliasSend(max)
17
+ }
18
+
19
+ if (max > 0) {
20
+ this.aliasToTopic = new LruMap({ max: max })
21
+ this.topicToAlias = {}
22
+ this.numberAllocator = new NumberAllocator(1, max)
23
+ this.max = max
24
+ this.length = 0
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Insert or update topic - alias entry.
30
+ * @param {String} [topic] - topic
31
+ * @param {Number} [alias] - topic alias
32
+ * @returns {Boolean} - if success return true otherwise false
33
+ */
34
+ TopicAliasSend.prototype.put = function (topic, alias) {
35
+ if (alias === 0 || alias > this.max) {
36
+ return false
37
+ }
38
+ const entry = this.aliasToTopic.get(alias)
39
+ if (entry) {
40
+ delete this.topicToAlias[entry]
41
+ }
42
+ this.aliasToTopic.set(alias, topic)
43
+ this.topicToAlias[topic] = alias
44
+ this.numberAllocator.use(alias)
45
+ this.length = this.aliasToTopic.length
46
+ return true
47
+ }
48
+
49
+ /**
50
+ * Get topic by alias
51
+ * @param {Number} [alias] - topic alias
52
+ * @returns {String} - if mapped topic exists return topic, otherwise return undefined
53
+ */
54
+ TopicAliasSend.prototype.getTopicByAlias = function (alias) {
55
+ return this.aliasToTopic.get(alias)
56
+ }
57
+
58
+ /**
59
+ * Get topic by alias
60
+ * @param {String} [topic] - topic
61
+ * @returns {Number} - if mapped topic exists return topic alias, otherwise return undefined
62
+ */
63
+ TopicAliasSend.prototype.getAliasByTopic = function (topic) {
64
+ const alias = this.topicToAlias[topic]
65
+ if (typeof alias !== 'undefined') {
66
+ this.aliasToTopic.get(alias) // LRU update
67
+ }
68
+ return alias
69
+ }
70
+
71
+ /**
72
+ * Clear all entries
73
+ */
74
+ TopicAliasSend.prototype.clear = function () {
75
+ this.aliasToTopic.reset()
76
+ this.topicToAlias = {}
77
+ this.numberAllocator.clear()
78
+ this.length = 0
79
+ }
80
+
81
+ /**
82
+ * Get Least Recently Used (LRU) topic alias
83
+ * @returns {Number} - if vacant alias exists then return it, otherwise then return LRU alias
84
+ */
85
+ TopicAliasSend.prototype.getLruAlias = function () {
86
+ const alias = this.numberAllocator.firstVacant()
87
+ if (alias) return alias
88
+ return this.aliasToTopic.keys()[this.aliasToTopic.length - 1]
89
+ }
90
+
91
+ module.exports = TopicAliasSend
package/package.json CHANGED
@@ -1,122 +1,113 @@
1
- {
2
- "name": "mqtt",
3
- "description": "A library for the MQTT protocol",
4
- "version": "4.3.4",
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 --exit",
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
- "lru-cache": "^6.0.0",
72
- "minimist": "^1.2.5",
73
- "mqtt-packet": "^6.8.0",
74
- "number-allocator": "^1.0.9",
75
- "pump": "^3.0.0",
76
- "readable-stream": "^3.6.0",
77
- "reinterval": "^1.1.0",
78
- "rfdc": "^1.3.0",
79
- "split2": "^3.1.0",
80
- "ws": "^7.5.5",
81
- "xtend": "^4.0.2"
82
- },
83
- "devDependencies": {
84
- "@types/node": "^10.0.0",
85
- "@types/ws": "^7.4.7",
86
- "aedes": "^0.42.5",
87
- "airtap": "^4.0.4",
88
- "browserify": "^16.5.0",
89
- "chai": "^4.2.0",
90
- "codecov": "^3.0.4",
91
- "end-of-stream": "^1.4.1",
92
- "global": "^4.3.2",
93
- "mkdirp": "^0.5.1",
94
- "mocha": "^9.1.3",
95
- "mqtt-connection": "^4.0.0",
96
- "nyc": "^15.0.1",
97
- "pre-commit": "^1.2.2",
98
- "rimraf": "^3.0.2",
99
- "should": "^13.2.1",
100
- "sinon": "^9.0.0",
101
- "snazzy": "^9.0.0",
102
- "standard": "^16.0.4",
103
- "tslint": "^5.11.0",
104
- "tslint-config-standard": "^8.0.1",
105
- "typescript": "^3.2.2",
106
- "uglify-es": "^3.3.9"
107
- },
108
- "standard": {
109
- "env": [
110
- "mocha"
111
- ],
112
- "globals": [
113
- "expect",
114
- "test",
115
- "describe",
116
- "it",
117
- "beforeEach",
118
- "beforeAll",
119
- "afterAll"
120
- ]
121
- }
122
- }
1
+ {
2
+ "name": "mqtt",
3
+ "description": "A library for the MQTT protocol",
4
+ "version": "4.3.7",
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
+ "pretest": "standard | snazzy",
26
+ "typescript-compile-test": "tsc -p test/typescript/tsconfig.json",
27
+ "typescript-compile-execute": "node test/typescript/broker-connect-subscribe-and-publish.js",
28
+ "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",
29
+ "prepare": "npm run browser-build",
30
+ "unit-test:node": "node_modules/.bin/nyc --reporter=lcov --reporter=text ./node_modules/mocha/bin/_mocha --exit",
31
+ "unit-test:browser": "airtap --server test/browser/server.js test/browser/test.js",
32
+ "test:node": "npm run unit-test:node && codecov",
33
+ "test:browser": "npm run browser-build && npm run unit-test:browser",
34
+ "test:typescript": "npm run typescript-compile-test && npm run typescript-compile-execute",
35
+ "test": "npm run test:node && npm run test:typescript"
36
+ },
37
+ "pre-commit": [
38
+ "pretest"
39
+ ],
40
+ "bin": {
41
+ "mqtt_pub": "./bin/pub.js",
42
+ "mqtt_sub": "./bin/sub.js",
43
+ "mqtt": "./bin/mqtt.js"
44
+ },
45
+ "files": [
46
+ "dist/",
47
+ "CONTRIBUTING.md",
48
+ "doc",
49
+ "lib",
50
+ "bin",
51
+ "types",
52
+ "mqtt.js"
53
+ ],
54
+ "engines": {
55
+ "node": ">=10.0.0"
56
+ },
57
+ "browser": {
58
+ "./mqtt.js": "./lib/connect/index.js",
59
+ "fs": false,
60
+ "tls": false,
61
+ "net": false
62
+ },
63
+ "dependencies": {
64
+ "commist": "^1.0.0",
65
+ "concat-stream": "^2.0.0",
66
+ "debug": "^4.1.1",
67
+ "duplexify": "^4.1.1",
68
+ "help-me": "^3.0.0",
69
+ "inherits": "^2.0.3",
70
+ "lru-cache": "^6.0.0",
71
+ "minimist": "^1.2.5",
72
+ "mqtt-packet": "^6.8.0",
73
+ "number-allocator": "^1.0.9",
74
+ "pump": "^3.0.0",
75
+ "readable-stream": "^3.6.0",
76
+ "reinterval": "^1.1.0",
77
+ "rfdc": "^1.3.0",
78
+ "split2": "^3.1.0",
79
+ "ws": "^7.5.5",
80
+ "xtend": "^4.0.2"
81
+ },
82
+ "devDependencies": {
83
+ "@types/node": "^10.0.0",
84
+ "@types/tape": "^4.13.2",
85
+ "@types/ws": "^7.4.7",
86
+ "aedes": "^0.46.2",
87
+ "airtap": "^4.0.4",
88
+ "browserify": "^16.5.0",
89
+ "chai": "^4.2.0",
90
+ "chokidar": "^3.5.3",
91
+ "codecov": "^3.0.4",
92
+ "end-of-stream": "^1.4.1",
93
+ "global": "^4.3.2",
94
+ "mkdirp": "^0.5.1",
95
+ "mocha": "^9.2.0",
96
+ "mqtt-connection": "^4.0.0",
97
+ "nyc": "^15.0.1",
98
+ "pre-commit": "^1.2.2",
99
+ "rimraf": "^3.0.2",
100
+ "should": "^13.2.1",
101
+ "sinon": "^9.0.0",
102
+ "snazzy": "^9.0.0",
103
+ "standard": "^16.0.4",
104
+ "tape": "^5.5.2",
105
+ "typescript": "^4.5.5",
106
+ "uglify-es": "^3.3.9"
107
+ },
108
+ "standard": {
109
+ "env": [
110
+ "mocha"
111
+ ]
112
+ }
113
+ }
@@ -1,10 +1,19 @@
1
1
  import { IClientOptions, MqttClient } from '../client'
2
+
2
3
  /**
3
4
  * connect - connect to an MQTT broker.
4
5
  *
5
- * @param {String} [brokerUrl] - url of the broker, optional
6
6
  * @param {Object} opts - see MqttClient#constructor
7
7
  */
8
- declare function connect (brokerUrl?: string | any, opts?: IClientOptions): MqttClient
8
+ declare function connect (opts: IClientOptions): MqttClient
9
+
10
+ /**
11
+ * connect - connect to an MQTT broker.
12
+ *
13
+ * @param {String} brokerUrl - url of the broker
14
+ * @param {Object} opts - see MqttClient#constructor
15
+ */
16
+ declare function connect (brokerUrl: string, opts?: IClientOptions): MqttClient
17
+
9
18
  export { connect }
10
19
  export { MqttClient }
package/CHANGELOG.md DELETED
@@ -1,89 +0,0 @@
1
- # Release History
2
-
3
- ## 4.3.4
4
-
5
- fix(dependency): migrate LruMap from collections to lru-cache (#1396)
6
-
7
- ## 4.3.3
8
-
9
- fix(publish): call callback when messageId available (#1393)
10
-
11
- fix: remove collections.js depdendency from number-allocator (#1394)
12
-
13
- ### PR
14
-
15
- fix(dependencies): update collections (#1386)
16
-
17
- ## 4.3.2
18
-
19
- ### PR
20
-
21
- fix(dependencies): update collections (#1386)
22
-
23
- ## 4.3.1
24
-
25
- ### PR
26
-
27
- fix(dependencies): remove babel-eslint and snazzy (#1383)
28
-
29
- ## 4.3.0
30
-
31
- ### PR
32
-
33
- refined topic alias support (#1301)
34
-
35
- fix security vulnerability in ws stream (#1307)
36
-
37
- skip TLS SNI if host is IP address (#1311)
38
-
39
- update readme about vNext discussions (#1328)
40
-
41
- update readme sample (#1331)
42
-
43
- add support for ALPN TLS extension (#1332)
44
-
45
- align onConnectCallback with specs expecting connack packet (#1333)
46
-
47
- fix resubscribe messageId allocate twice (#1337)
48
-
49
- rework examples to be a bit more specific (#1352)
50
-
51
- readme typo fixed (#1353)
52
-
53
- fix(typescript): use correct version of @types/ws (#1358)
54
-
55
- fix(type): fix push properties types (#1359)
56
-
57
- fix: audit dev dependencies (#1374)
58
-
59
- fix(type): add properties type for IClientSubscribeOptions (#1378)
60
-
61
- feat(client): auth handler for enhanced auth (#1380)
62
-
63
- ## 4.2.8
64
-
65
- ### PR
66
-
67
- Fix ws vulnerability and typescript bug (#1292)
68
-
69
- ## 4.2.7
70
-
71
- ### PR
72
-
73
- #1287 - Fix production vulnerabilities (#1289)
74
-
75
- #1215 - Add missing 'duplexify' dependency (#1266)
76
-
77
- Improve type definition for 'wsOptions' (#1256)
78
-
79
- Improve Typescript Declaratiosn for userProperties (#1249)
80
-
81
- #1235 - Call the end on the WebSocket stream when WebSocket close event is emitted. (#1239)
82
-
83
- #1201 - Uncaught TypeError: net.createConnection is not a function. (#1236)
84
-
85
- Improve Documentation for Browserify (#1224)
86
-
87
- ## v4.2.6 and Below
88
-
89
- The release history has beend documented in the GitHub releases and tags historically.