Skip to content

Commit 4f9d197

Browse files
mohitpubnubClient Engineering Bot
and
Client Engineering Bot
authored
mandatory uuid parameter (pubnub#240)
* ref: throw when valid uuid is not provided in PubNub * fix: tests with mandatory uuid * fix: web-titanium tests * test: include test for setUUID with invalid uuid value. * PubNub SDK v5.0.0 release. Co-authored-by: Client Engineering Bot <60980775+Client Engineering [email protected]>
1 parent 5a5acfc commit 4f9d197

25 files changed

+138
-195
lines changed

.pubnub.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
changelog:
3+
- date: 2022-01-12
4+
version: v5.0.0
5+
changes:
6+
- type: improvement
7+
text: "BREAKING CHANGES: `uuid` is required parameter in PubNub constructor."
38
- date: 2021-12-16
49
version: v4.37.0
510
changes:
@@ -1091,7 +1096,7 @@ supported-platforms:
10911096
- "Ubuntu 14.04 and up"
10921097
- "Windows 7 and up"
10931098
version: "Pubnub Javascript for Node"
1094-
version: "4.37.0"
1099+
version: "5.0.0"
10951100
sdks:
10961101
-
10971102
full-name: PubNub Javascript SDK
@@ -1110,7 +1115,7 @@ sdks:
11101115
distribution-type: source
11111116
distribution-repository: GitHub release
11121117
package-name: pubnub.js
1113-
location: https://github.com/pubnub/javascript/archive/refs/tags/v4.37.0.zip
1118+
location: https://github.com/pubnub/javascript/archive/refs/tags/v5.0.0.zip
11141119
requires:
11151120
-
11161121
name: "agentkeepalive"
@@ -1874,7 +1879,7 @@ sdks:
18741879
distribution-type: library
18751880
distribution-repository: GitHub release
18761881
package-name: pubnub.js
1877-
location: https://github.com/pubnub/javascript/releases/download/v4.37.0/pubnub.4.37.0.js
1882+
location: https://github.com/pubnub/javascript/releases/download/v5.0.0/pubnub.5.0.0.js
18781883
requires:
18791884
-
18801885
name: "agentkeepalive"

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v5.0.0
2+
January 12 2022
3+
4+
#### Modified
5+
- BREAKING CHANGES: `uuid` is required parameter in PubNub constructor.
6+
17
## v4.37.0
28
December 16 2021
39

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ You will need the publish and subscribe keys to authenticate your app. Get your
2222
npm install pubnub
2323
```
2424
* or download one of our builds from our CDN:
25-
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.37.0.js
26-
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.37.0.min.js
25+
* https://cdn.pubnub.com/sdk/javascript/pubnub.5.0.0.js
26+
* https://cdn.pubnub.com/sdk/javascript/pubnub.5.0.0.min.js
2727
2828
2. Configure your keys:
2929

dist/titanium/pubnub.js

+10-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! 4.37.0 / Consumer */
1+
/*! 5.0.0 / Consumer */
22
exports["PubNub"] =
33
/******/ (function(modules) { // webpackBootstrap
44
/******/ // The module cache
@@ -379,10 +379,8 @@ var _default = function () {
379379
function _default(_ref) {
380380
var _setup$fileUploadPubl, _setup$useRandomIVs;
381381

382-
var setup = _ref.setup,
383-
db = _ref.db;
382+
var setup = _ref.setup;
384383
(0, _classCallCheck2["default"])(this, _default);
385-
(0, _defineProperty2["default"])(this, "_db", void 0);
386384
(0, _defineProperty2["default"])(this, "subscribeKey", void 0);
387385
(0, _defineProperty2["default"])(this, "publishKey", void 0);
388386
(0, _defineProperty2["default"])(this, "secretKey", void 0);
@@ -421,7 +419,6 @@ var _default = function () {
421419
(0, _defineProperty2["default"])(this, "fileUploadPublishRetryLimit", void 0);
422420
(0, _defineProperty2["default"])(this, "useRandomIVs", void 0);
423421
this._PNSDKSuffix = {};
424-
this._db = db;
425422
this.instanceId = "pn-".concat(_uuid["default"].createUUID());
426423
this.secretKey = setup.secretKey || setup.secret_key;
427424
this.subscribeKey = setup.subscribeKey || setup.subscribe_key;
@@ -476,7 +473,7 @@ var _default = function () {
476473
this.setHeartbeatInterval(setup.heartbeatInterval);
477474
}
478475

479-
this.setUUID(this._decideUUID(setup.uuid));
476+
this.setUUID(setup.uuid);
480477
}
481478

482479
(0, _createClass2["default"])(_default, [{
@@ -504,7 +501,10 @@ var _default = function () {
504501
}, {
505502
key: "setUUID",
506503
value: function setUUID(val) {
507-
if (this._db && this._db.set) this._db.set("".concat(this.subscribeKey, "uuid"), val);
504+
if (!val || typeof val !== 'string' || val.trim().length === 0) {
505+
throw new Error('Missing uuid parameter. Provide a valid string uuid');
506+
}
507+
508508
this.UUID = val;
509509
return this;
510510
}
@@ -589,7 +589,7 @@ var _default = function () {
589589
}, {
590590
key: "getVersion",
591591
value: function getVersion() {
592-
return '4.37.0';
592+
return '5.0.0';
593593
}
594594
}, {
595595
key: "_addPnsdkSuffix",
@@ -605,19 +605,6 @@ var _default = function () {
605605
return result + separator + _this._PNSDKSuffix[key];
606606
}, '');
607607
}
608-
}, {
609-
key: "_decideUUID",
610-
value: function _decideUUID(providedUUID) {
611-
if (providedUUID) {
612-
return providedUUID;
613-
}
614-
615-
if (this._db && this._db.get && this._db.get("".concat(this.subscribeKey, "uuid"))) {
616-
return this._db.get("".concat(this.subscribeKey, "uuid"));
617-
}
618-
619-
return "pn-".concat(_uuid["default"].createUUID());
620-
}
621608
}]);
622609
return _default;
623610
}();
@@ -2579,12 +2566,10 @@ var _default = function () {
25792566
(0, _defineProperty2["default"])(this, "setProxy", void 0);
25802567
(0, _defineProperty2["default"])(this, "encrypt", void 0);
25812568
(0, _defineProperty2["default"])(this, "decrypt", void 0);
2582-
var db = setup.db,
2583-
networking = setup.networking,
2569+
var networking = setup.networking,
25842570
cbor = setup.cbor;
25852571
var config = this._config = new _config["default"]({
2586-
setup: setup,
2587-
db: db
2572+
setup: setup
25882573
});
25892574
var crypto = new _index["default"]({
25902575
config: config

dist/titanium/pubnub.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web/pubnub.js

+10-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! 4.37.0 / Consumer */
1+
/*! 5.0.0 / Consumer */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -389,10 +389,8 @@ var _default = function () {
389389
function _default(_ref) {
390390
var _setup$fileUploadPubl, _setup$useRandomIVs;
391391

392-
var setup = _ref.setup,
393-
db = _ref.db;
392+
var setup = _ref.setup;
394393
(0, _classCallCheck2["default"])(this, _default);
395-
(0, _defineProperty2["default"])(this, "_db", void 0);
396394
(0, _defineProperty2["default"])(this, "subscribeKey", void 0);
397395
(0, _defineProperty2["default"])(this, "publishKey", void 0);
398396
(0, _defineProperty2["default"])(this, "secretKey", void 0);
@@ -431,7 +429,6 @@ var _default = function () {
431429
(0, _defineProperty2["default"])(this, "fileUploadPublishRetryLimit", void 0);
432430
(0, _defineProperty2["default"])(this, "useRandomIVs", void 0);
433431
this._PNSDKSuffix = {};
434-
this._db = db;
435432
this.instanceId = "pn-".concat(_uuid["default"].createUUID());
436433
this.secretKey = setup.secretKey || setup.secret_key;
437434
this.subscribeKey = setup.subscribeKey || setup.subscribe_key;
@@ -486,7 +483,7 @@ var _default = function () {
486483
this.setHeartbeatInterval(setup.heartbeatInterval);
487484
}
488485

489-
this.setUUID(this._decideUUID(setup.uuid));
486+
this.setUUID(setup.uuid);
490487
}
491488

492489
(0, _createClass2["default"])(_default, [{
@@ -514,7 +511,10 @@ var _default = function () {
514511
}, {
515512
key: "setUUID",
516513
value: function setUUID(val) {
517-
if (this._db && this._db.set) this._db.set("".concat(this.subscribeKey, "uuid"), val);
514+
if (!val || typeof val !== 'string' || val.trim().length === 0) {
515+
throw new Error('Missing uuid parameter. Provide a valid string uuid');
516+
}
517+
518518
this.UUID = val;
519519
return this;
520520
}
@@ -599,7 +599,7 @@ var _default = function () {
599599
}, {
600600
key: "getVersion",
601601
value: function getVersion() {
602-
return '4.37.0';
602+
return '5.0.0';
603603
}
604604
}, {
605605
key: "_addPnsdkSuffix",
@@ -615,19 +615,6 @@ var _default = function () {
615615
return result + separator + _this._PNSDKSuffix[key];
616616
}, '');
617617
}
618-
}, {
619-
key: "_decideUUID",
620-
value: function _decideUUID(providedUUID) {
621-
if (providedUUID) {
622-
return providedUUID;
623-
}
624-
625-
if (this._db && this._db.get && this._db.get("".concat(this.subscribeKey, "uuid"))) {
626-
return this._db.get("".concat(this.subscribeKey, "uuid"));
627-
}
628-
629-
return "pn-".concat(_uuid["default"].createUUID());
630-
}
631618
}]);
632619
return _default;
633620
}();
@@ -5848,12 +5835,10 @@ var _default = function () {
58485835
(0, _defineProperty2["default"])(this, "setProxy", void 0);
58495836
(0, _defineProperty2["default"])(this, "encrypt", void 0);
58505837
(0, _defineProperty2["default"])(this, "decrypt", void 0);
5851-
var db = setup.db,
5852-
networking = setup.networking,
5838+
var networking = setup.networking,
58535839
cbor = setup.cbor;
58545840
var config = this._config = new _config["default"]({
5855-
setup: setup,
5856-
db: db
5841+
setup: setup
58575842
});
58585843
var crypto = new _index["default"]({
58595844
config: config

dist/web/pubnub.min.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/components/config.js

+7-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/components/config.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)