mqtt 2.18.5 → 2.18.9

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 (66) hide show
  1. package/CONTRIBUTING.md +27 -27
  2. package/LICENSE.md +15 -15
  3. package/README.md +612 -612
  4. package/bin/pub.js +146 -146
  5. package/bin/sub.js +123 -123
  6. package/dist/mqtt.js +14275 -10729
  7. package/dist/mqtt.min.js +1 -1
  8. package/doc/help.txt +8 -8
  9. package/doc/publish.txt +26 -26
  10. package/doc/subscribe.txt +26 -26
  11. package/examples/client/secure-client.js +24 -24
  12. package/examples/client/simple-both.js +13 -13
  13. package/examples/client/simple-publish.js +7 -7
  14. package/examples/client/simple-subscribe.js +9 -9
  15. package/examples/tls client/crt.ca.cg.pem +34 -34
  16. package/examples/tls client/mqttclient.js +48 -48
  17. package/examples/tls client/tls-cert.pem +13 -13
  18. package/examples/tls client/tls-key.pem +15 -15
  19. package/examples/wss/client.js +49 -49
  20. package/examples/wss/client_with_proxy.js +58 -58
  21. package/lib/client.js +1129 -1102
  22. package/lib/connect/index.js +149 -149
  23. package/lib/connect/tcp.js +19 -19
  24. package/lib/connect/tls.js +41 -41
  25. package/lib/connect/ws.js +92 -92
  26. package/lib/connect/wx.js +110 -110
  27. package/lib/store.js +140 -140
  28. package/lib/validations.js +52 -52
  29. package/mqtt.js +41 -41
  30. package/package.json +107 -111
  31. package/test/abstract_client.js +2667 -2533
  32. package/test/abstract_store.js +135 -133
  33. package/test/browser/server.js +132 -132
  34. package/test/browser/test.js +92 -92
  35. package/test/browser/wx.js +93 -93
  36. package/test/client.js +544 -544
  37. package/test/helpers/private-csr.pem +16 -16
  38. package/test/helpers/private-key.pem +27 -27
  39. package/test/helpers/public-cert.pem +19 -19
  40. package/test/helpers/public-key.pem +9 -9
  41. package/test/helpers/server.js +52 -52
  42. package/test/helpers/server_process.js +9 -9
  43. package/test/helpers/tls-cert.pem +14 -14
  44. package/test/helpers/tls-csr.pem +11 -11
  45. package/test/helpers/tls-key.pem +15 -15
  46. package/test/helpers/wrong-cert.pem +13 -13
  47. package/test/helpers/wrong-csr.pem +11 -11
  48. package/test/helpers/wrong-key.pem +15 -15
  49. package/test/mocha.opts +4 -4
  50. package/test/mqtt.js +230 -230
  51. package/test/mqtt_store.js +9 -9
  52. package/test/secure_client.js +157 -157
  53. package/test/server.js +65 -65
  54. package/test/store.js +10 -10
  55. package/test/typescript/broker-connect-subscribe-and-publish.ts +22 -22
  56. package/test/typescript/tsconfig.json +14 -14
  57. package/test/util.js +13 -13
  58. package/test/websocket_client.js +144 -144
  59. package/types/index.d.ts +27 -27
  60. package/types/lib/client-options.d.ts +137 -137
  61. package/types/lib/client.d.ts +196 -196
  62. package/types/lib/connect/index.d.ts +10 -10
  63. package/types/lib/store-options.d.ts +6 -6
  64. package/types/lib/store.d.ts +46 -46
  65. package/test/typescript/broker-connect-subscribe-and-publish.js +0 -24
  66. package/test/typescript/broker-connect-subscribe-and-publish.js.map +0 -1
@@ -1,92 +1,92 @@
1
- 'use strict'
2
-
3
- var mqtt = require('../../lib/connect')
4
- var _URL = require('url')
5
- var xtend = require('xtend')
6
- var parsed = _URL.parse(document.URL)
7
- var isHttps = parsed.protocol === 'https:'
8
- var port = parsed.port || (isHttps ? 443 : 80)
9
- var host = parsed.hostname
10
- var protocol = isHttps ? 'wss' : 'ws'
11
-
12
- function clientTests (buildClient) {
13
- var client
14
-
15
- beforeEach(function () {
16
- client = buildClient()
17
- client.on('offline', function () {
18
- console.log('client offline')
19
- })
20
- client.on('connect', function () {
21
- console.log('client connect')
22
- })
23
- client.on('reconnect', function () {
24
- console.log('client reconnect')
25
- })
26
- })
27
-
28
- afterEach(function (done) {
29
- client.once('close', function () {
30
- done()
31
- })
32
- client.end()
33
- })
34
-
35
- it('should connect', function (done) {
36
- client.on('connect', function () {
37
- done()
38
- })
39
- })
40
-
41
- it('should publish and subscribe', function (done) {
42
- client.subscribe('hello', function () {
43
- done()
44
- }).publish('hello', 'world')
45
- })
46
- }
47
-
48
- function suiteFactory (configName, opts) {
49
- function setVersion (base) {
50
- return xtend(base || {}, opts)
51
- }
52
-
53
- var suiteName = 'MqttClient(' + configName + '=' + JSON.stringify(opts) + ')'
54
- describe(suiteName, function () {
55
- this.timeout(10000)
56
-
57
- describe('specifying nothing', function () {
58
- clientTests(function () {
59
- return mqtt.connect(setVersion())
60
- })
61
- })
62
-
63
- if (parsed.hostname === 'localhost') {
64
- describe('specifying a port', function () {
65
- clientTests(function () {
66
- return mqtt.connect(setVersion({ protocol: protocol, port: port }))
67
- })
68
- })
69
- }
70
-
71
- describe('specifying a port and host', function () {
72
- clientTests(function () {
73
- return mqtt.connect(setVersion({ protocol: protocol, port: port, host: host }))
74
- })
75
- })
76
-
77
- describe('specifying a URL', function () {
78
- clientTests(function () {
79
- return mqtt.connect(protocol + '://' + host + ':' + port, setVersion())
80
- })
81
- })
82
-
83
- describe('specifying a URL with a path', function () {
84
- clientTests(function () {
85
- return mqtt.connect(protocol + '://' + host + ':' + port + '/mqtt', setVersion())
86
- })
87
- })
88
- })
89
- }
90
-
91
- suiteFactory('v3', {protocolId: 'MQIsdp', protocolVersion: 3})
92
- suiteFactory('default', {})
1
+ 'use strict'
2
+
3
+ var mqtt = require('../../lib/connect')
4
+ var _URL = require('url')
5
+ var xtend = require('xtend')
6
+ var parsed = _URL.parse(document.URL)
7
+ var isHttps = parsed.protocol === 'https:'
8
+ var port = parsed.port || (isHttps ? 443 : 80)
9
+ var host = parsed.hostname
10
+ var protocol = isHttps ? 'wss' : 'ws'
11
+
12
+ function clientTests (buildClient) {
13
+ var client
14
+
15
+ beforeEach(function () {
16
+ client = buildClient()
17
+ client.on('offline', function () {
18
+ console.log('client offline')
19
+ })
20
+ client.on('connect', function () {
21
+ console.log('client connect')
22
+ })
23
+ client.on('reconnect', function () {
24
+ console.log('client reconnect')
25
+ })
26
+ })
27
+
28
+ afterEach(function (done) {
29
+ client.once('close', function () {
30
+ done()
31
+ })
32
+ client.end()
33
+ })
34
+
35
+ it('should connect', function (done) {
36
+ client.on('connect', function () {
37
+ done()
38
+ })
39
+ })
40
+
41
+ it('should publish and subscribe', function (done) {
42
+ client.subscribe('hello', function () {
43
+ done()
44
+ }).publish('hello', 'world')
45
+ })
46
+ }
47
+
48
+ function suiteFactory (configName, opts) {
49
+ function setVersion (base) {
50
+ return xtend(base || {}, opts)
51
+ }
52
+
53
+ var suiteName = 'MqttClient(' + configName + '=' + JSON.stringify(opts) + ')'
54
+ describe(suiteName, function () {
55
+ this.timeout(10000)
56
+
57
+ describe('specifying nothing', function () {
58
+ clientTests(function () {
59
+ return mqtt.connect(setVersion())
60
+ })
61
+ })
62
+
63
+ if (parsed.hostname === 'localhost') {
64
+ describe('specifying a port', function () {
65
+ clientTests(function () {
66
+ return mqtt.connect(setVersion({ protocol: protocol, port: port }))
67
+ })
68
+ })
69
+ }
70
+
71
+ describe('specifying a port and host', function () {
72
+ clientTests(function () {
73
+ return mqtt.connect(setVersion({ protocol: protocol, port: port, host: host }))
74
+ })
75
+ })
76
+
77
+ describe('specifying a URL', function () {
78
+ clientTests(function () {
79
+ return mqtt.connect(protocol + '://' + host + ':' + port, setVersion())
80
+ })
81
+ })
82
+
83
+ describe('specifying a URL with a path', function () {
84
+ clientTests(function () {
85
+ return mqtt.connect(protocol + '://' + host + ':' + port + '/mqtt', setVersion())
86
+ })
87
+ })
88
+ })
89
+ }
90
+
91
+ suiteFactory('v3', {protocolId: 'MQIsdp', protocolVersion: 3})
92
+ suiteFactory('default', {})
@@ -1,93 +1,93 @@
1
- 'use strict'
2
-
3
- var mqtt = require('../../lib/connect')
4
- var _URL = require('url')
5
- var xtend = require('xtend')
6
- var parsed = _URL.parse(document.URL)
7
- var isHttps = parsed.protocol === 'https:'
8
- var port = parsed.port || (isHttps ? 443 : 80)
9
- var host = parsed.hostname
10
- var protocol = isHttps ? 'wxs' : 'wx'
11
- require('../helpers/wx')
12
-
13
- function clientTests (buildClient) {
14
- var client
15
-
16
- beforeEach(function () {
17
- client = buildClient()
18
- client.on('offline', function () {
19
- console.log('client offline')
20
- })
21
- client.on('connect', function () {
22
- console.log('client connect')
23
- })
24
- client.on('reconnect', function () {
25
- console.log('client reconnect')
26
- })
27
- })
28
-
29
- afterEach(function (done) {
30
- client.once('close', function () {
31
- done()
32
- })
33
- client.end()
34
- })
35
-
36
- it('should connect', function (done) {
37
- client.on('connect', function () {
38
- done()
39
- })
40
- })
41
-
42
- it('should publish and subscribe', function (done) {
43
- client.subscribe('hello', function () {
44
- done()
45
- }).publish('hello', 'world')
46
- })
47
- }
48
-
49
- function suiteFactory (configName, opts) {
50
- function setVersion (base) {
51
- return xtend(base || {}, opts)
52
- }
53
-
54
- var suiteName = 'MqttClient(' + configName + '=' + JSON.stringify(opts) + ')'
55
- describe(suiteName, function () {
56
- this.timeout(10000)
57
-
58
- describe('specifying nothing', function () {
59
- clientTests(function () {
60
- return mqtt.connect(setVersion())
61
- })
62
- })
63
-
64
- if (parsed.hostname === 'localhost') {
65
- describe('specifying a port', function () {
66
- clientTests(function () {
67
- return mqtt.connect(setVersion({ protocol: protocol, port: port }))
68
- })
69
- })
70
- }
71
-
72
- describe('specifying a port and host', function () {
73
- clientTests(function () {
74
- return mqtt.connect(setVersion({ protocol: protocol, port: port, host: host }))
75
- })
76
- })
77
-
78
- describe('specifying a URL', function () {
79
- clientTests(function () {
80
- return mqtt.connect(protocol + '://' + host + ':' + port, setVersion())
81
- })
82
- })
83
-
84
- describe('specifying a URL with a path', function () {
85
- clientTests(function () {
86
- return mqtt.connect(protocol + '://' + host + ':' + port + '/mqtt', setVersion())
87
- })
88
- })
89
- })
90
- }
91
-
92
- suiteFactory('v3', {protocolId: 'MQIsdp', protocolVersion: 3})
93
- suiteFactory('default', {})
1
+ 'use strict'
2
+
3
+ var mqtt = require('../../lib/connect')
4
+ var _URL = require('url')
5
+ var xtend = require('xtend')
6
+ var parsed = _URL.parse(document.URL)
7
+ var isHttps = parsed.protocol === 'https:'
8
+ var port = parsed.port || (isHttps ? 443 : 80)
9
+ var host = parsed.hostname
10
+ var protocol = isHttps ? 'wxs' : 'wx'
11
+ require('../helpers/wx')
12
+
13
+ function clientTests (buildClient) {
14
+ var client
15
+
16
+ beforeEach(function () {
17
+ client = buildClient()
18
+ client.on('offline', function () {
19
+ console.log('client offline')
20
+ })
21
+ client.on('connect', function () {
22
+ console.log('client connect')
23
+ })
24
+ client.on('reconnect', function () {
25
+ console.log('client reconnect')
26
+ })
27
+ })
28
+
29
+ afterEach(function (done) {
30
+ client.once('close', function () {
31
+ done()
32
+ })
33
+ client.end()
34
+ })
35
+
36
+ it('should connect', function (done) {
37
+ client.on('connect', function () {
38
+ done()
39
+ })
40
+ })
41
+
42
+ it('should publish and subscribe', function (done) {
43
+ client.subscribe('hello', function () {
44
+ done()
45
+ }).publish('hello', 'world')
46
+ })
47
+ }
48
+
49
+ function suiteFactory (configName, opts) {
50
+ function setVersion (base) {
51
+ return xtend(base || {}, opts)
52
+ }
53
+
54
+ var suiteName = 'MqttClient(' + configName + '=' + JSON.stringify(opts) + ')'
55
+ describe(suiteName, function () {
56
+ this.timeout(10000)
57
+
58
+ describe('specifying nothing', function () {
59
+ clientTests(function () {
60
+ return mqtt.connect(setVersion())
61
+ })
62
+ })
63
+
64
+ if (parsed.hostname === 'localhost') {
65
+ describe('specifying a port', function () {
66
+ clientTests(function () {
67
+ return mqtt.connect(setVersion({ protocol: protocol, port: port }))
68
+ })
69
+ })
70
+ }
71
+
72
+ describe('specifying a port and host', function () {
73
+ clientTests(function () {
74
+ return mqtt.connect(setVersion({ protocol: protocol, port: port, host: host }))
75
+ })
76
+ })
77
+
78
+ describe('specifying a URL', function () {
79
+ clientTests(function () {
80
+ return mqtt.connect(protocol + '://' + host + ':' + port, setVersion())
81
+ })
82
+ })
83
+
84
+ describe('specifying a URL with a path', function () {
85
+ clientTests(function () {
86
+ return mqtt.connect(protocol + '://' + host + ':' + port + '/mqtt', setVersion())
87
+ })
88
+ })
89
+ })
90
+ }
91
+
92
+ suiteFactory('v3', {protocolId: 'MQIsdp', protocolVersion: 3})
93
+ suiteFactory('default', {})