Skip to content

Commit

Permalink
mandatory uuid parameter (#240)
Browse files Browse the repository at this point in the history
* 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 Bot@users.noreply.github.com>
  • Loading branch information
mohitpubnub and Client Engineering Bot authored Jan 12, 2022
1 parent 5a5acfc commit 4f9d197
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 195 deletions.
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2022-01-12
version: v5.0.0
changes:
- type: improvement
text: "BREAKING CHANGES: `uuid` is required parameter in PubNub constructor."
- date: 2021-12-16
version: v4.37.0
changes:
Expand Down Expand Up @@ -1091,7 +1096,7 @@ supported-platforms:
- "Ubuntu 14.04 and up"
- "Windows 7 and up"
version: "Pubnub Javascript for Node"
version: "4.37.0"
version: "5.0.0"
sdks:
-
full-name: PubNub Javascript SDK
Expand All @@ -1110,7 +1115,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v4.37.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v5.0.0.zip
requires:
-
name: "agentkeepalive"
Expand Down Expand Up @@ -1874,7 +1879,7 @@ sdks:
distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v4.37.0/pubnub.4.37.0.js
location: https://github.com/pubnub/javascript/releases/download/v5.0.0/pubnub.5.0.0.js
requires:
-
name: "agentkeepalive"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v5.0.0
January 12 2022

#### Modified
- BREAKING CHANGES: `uuid` is required parameter in PubNub constructor.

## v4.37.0
December 16 2021

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ You will need the publish and subscribe keys to authenticate your app. Get your
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.37.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.37.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.5.0.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.5.0.0.min.js
2. Configure your keys:
Expand Down
35 changes: 10 additions & 25 deletions dist/titanium/pubnub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! 4.37.0 / Consumer */
/*! 5.0.0 / Consumer */
exports["PubNub"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
Expand Down Expand Up @@ -379,10 +379,8 @@ var _default = function () {
function _default(_ref) {
var _setup$fileUploadPubl, _setup$useRandomIVs;

var setup = _ref.setup,
db = _ref.db;
var setup = _ref.setup;
(0, _classCallCheck2["default"])(this, _default);
(0, _defineProperty2["default"])(this, "_db", void 0);
(0, _defineProperty2["default"])(this, "subscribeKey", void 0);
(0, _defineProperty2["default"])(this, "publishKey", void 0);
(0, _defineProperty2["default"])(this, "secretKey", void 0);
Expand Down Expand Up @@ -421,7 +419,6 @@ var _default = function () {
(0, _defineProperty2["default"])(this, "fileUploadPublishRetryLimit", void 0);
(0, _defineProperty2["default"])(this, "useRandomIVs", void 0);
this._PNSDKSuffix = {};
this._db = db;
this.instanceId = "pn-".concat(_uuid["default"].createUUID());
this.secretKey = setup.secretKey || setup.secret_key;
this.subscribeKey = setup.subscribeKey || setup.subscribe_key;
Expand Down Expand Up @@ -476,7 +473,7 @@ var _default = function () {
this.setHeartbeatInterval(setup.heartbeatInterval);
}

this.setUUID(this._decideUUID(setup.uuid));
this.setUUID(setup.uuid);
}

(0, _createClass2["default"])(_default, [{
Expand Down Expand Up @@ -504,7 +501,10 @@ var _default = function () {
}, {
key: "setUUID",
value: function setUUID(val) {
if (this._db && this._db.set) this._db.set("".concat(this.subscribeKey, "uuid"), val);
if (!val || typeof val !== 'string' || val.trim().length === 0) {
throw new Error('Missing uuid parameter. Provide a valid string uuid');
}

this.UUID = val;
return this;
}
Expand Down Expand Up @@ -589,7 +589,7 @@ var _default = function () {
}, {
key: "getVersion",
value: function getVersion() {
return '4.37.0';
return '5.0.0';
}
}, {
key: "_addPnsdkSuffix",
Expand All @@ -605,19 +605,6 @@ var _default = function () {
return result + separator + _this._PNSDKSuffix[key];
}, '');
}
}, {
key: "_decideUUID",
value: function _decideUUID(providedUUID) {
if (providedUUID) {
return providedUUID;
}

if (this._db && this._db.get && this._db.get("".concat(this.subscribeKey, "uuid"))) {
return this._db.get("".concat(this.subscribeKey, "uuid"));
}

return "pn-".concat(_uuid["default"].createUUID());
}
}]);
return _default;
}();
Expand Down Expand Up @@ -2579,12 +2566,10 @@ var _default = function () {
(0, _defineProperty2["default"])(this, "setProxy", void 0);
(0, _defineProperty2["default"])(this, "encrypt", void 0);
(0, _defineProperty2["default"])(this, "decrypt", void 0);
var db = setup.db,
networking = setup.networking,
var networking = setup.networking,
cbor = setup.cbor;
var config = this._config = new _config["default"]({
setup: setup,
db: db
setup: setup
});
var crypto = new _index["default"]({
config: config
Expand Down
4 changes: 2 additions & 2 deletions dist/titanium/pubnub.min.js

Large diffs are not rendered by default.

35 changes: 10 additions & 25 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! 4.37.0 / Consumer */
/*! 5.0.0 / Consumer */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -389,10 +389,8 @@ var _default = function () {
function _default(_ref) {
var _setup$fileUploadPubl, _setup$useRandomIVs;

var setup = _ref.setup,
db = _ref.db;
var setup = _ref.setup;
(0, _classCallCheck2["default"])(this, _default);
(0, _defineProperty2["default"])(this, "_db", void 0);
(0, _defineProperty2["default"])(this, "subscribeKey", void 0);
(0, _defineProperty2["default"])(this, "publishKey", void 0);
(0, _defineProperty2["default"])(this, "secretKey", void 0);
Expand Down Expand Up @@ -431,7 +429,6 @@ var _default = function () {
(0, _defineProperty2["default"])(this, "fileUploadPublishRetryLimit", void 0);
(0, _defineProperty2["default"])(this, "useRandomIVs", void 0);
this._PNSDKSuffix = {};
this._db = db;
this.instanceId = "pn-".concat(_uuid["default"].createUUID());
this.secretKey = setup.secretKey || setup.secret_key;
this.subscribeKey = setup.subscribeKey || setup.subscribe_key;
Expand Down Expand Up @@ -486,7 +483,7 @@ var _default = function () {
this.setHeartbeatInterval(setup.heartbeatInterval);
}

this.setUUID(this._decideUUID(setup.uuid));
this.setUUID(setup.uuid);
}

(0, _createClass2["default"])(_default, [{
Expand Down Expand Up @@ -514,7 +511,10 @@ var _default = function () {
}, {
key: "setUUID",
value: function setUUID(val) {
if (this._db && this._db.set) this._db.set("".concat(this.subscribeKey, "uuid"), val);
if (!val || typeof val !== 'string' || val.trim().length === 0) {
throw new Error('Missing uuid parameter. Provide a valid string uuid');
}

this.UUID = val;
return this;
}
Expand Down Expand Up @@ -599,7 +599,7 @@ var _default = function () {
}, {
key: "getVersion",
value: function getVersion() {
return '4.37.0';
return '5.0.0';
}
}, {
key: "_addPnsdkSuffix",
Expand All @@ -615,19 +615,6 @@ var _default = function () {
return result + separator + _this._PNSDKSuffix[key];
}, '');
}
}, {
key: "_decideUUID",
value: function _decideUUID(providedUUID) {
if (providedUUID) {
return providedUUID;
}

if (this._db && this._db.get && this._db.get("".concat(this.subscribeKey, "uuid"))) {
return this._db.get("".concat(this.subscribeKey, "uuid"));
}

return "pn-".concat(_uuid["default"].createUUID());
}
}]);
return _default;
}();
Expand Down Expand Up @@ -5848,12 +5835,10 @@ var _default = function () {
(0, _defineProperty2["default"])(this, "setProxy", void 0);
(0, _defineProperty2["default"])(this, "encrypt", void 0);
(0, _defineProperty2["default"])(this, "decrypt", void 0);
var db = setup.db,
networking = setup.networking,
var networking = setup.networking,
cbor = setup.cbor;
var config = this._config = new _config["default"]({
setup: setup,
db: db
setup: setup
});
var crypto = new _index["default"]({
config: config
Expand Down
8 changes: 4 additions & 4 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

27 changes: 7 additions & 20 deletions lib/core/components/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/core/components/config.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 4f9d197

Please sign in to comment.