Skip to content

Commit

Permalink
Releasing v4.29.9
Browse files Browse the repository at this point in the history
  • Loading branch information
client-engineering-bot committed Oct 5, 2020
1 parent 565853e commit 403e14c
Show file tree
Hide file tree
Showing 26 changed files with 355 additions and 138 deletions.
16 changes: 15 additions & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
---
changelog:
-
changes:
-
text: "Adds timetoken of file publish in the sendFile response."
type: feature
-
text: "Fixes getFileUrl so that it includes auth and signature query params."
type: bug
-
text: "Fixes downloadFile method to generate correct signature."
type: bug
date: 2020-10-05
version: v4.29.9
-
changes:
-
Expand Down Expand Up @@ -841,6 +854,7 @@ features:
- ACCESS-GRANT-MANAGE
- ACCESS-GRANT-DELETE
- ACCESS-TOKEN-MANAGEMENT
- ACCESS-OBJECTS-V2-MANAGEMENT
channel-groups:
- CHANNEL-GROUPS-ADD-CHANNELS
- CHANNEL-GROUPS-REMOVE-CHANNELS
Expand Down Expand Up @@ -964,4 +978,4 @@ supported-platforms:
- "Ubuntu 14.04 and up"
- "Windows 7 and up"
version: "Pubnub Javascript for Node"
version: "4.29.8"
version: "4.29.9"
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [v4.29.9](https://github.com/pubnub/javascript/releases/tag/v4.29.9)
October-05-2020

[Full Changelog](https://github.com/pubnub/javascript/compare/v4.29.8...v4.29.9)

- 🌟️ Adds timetoken of file publish in the sendFile response.
- 🐛 Fixes getFileUrl so that it includes auth and signature query params.
- 🐛 Fixes downloadFile method to generate correct signature.

## [v4.29.8](https://github.com/pubnub/javascript/releases/tag/v4.29.8)
September-21-2020

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ please use the [master_3x](https://github.com/pubnub/javascript/tree/master_3x)



* https://cdn.pubnub.com/sdk/javascript/pubnub.4.29.8.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.29.8.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.29.9.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.29.9.js
122 changes: 86 additions & 36 deletions dist/titanium/pubnub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! 4.29.8 / Consumer */
/*! 4.29.9 / Consumer */
exports["PubNub"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
Expand Down Expand Up @@ -566,7 +566,7 @@ var _default = function () {
}, {
key: "getVersion",
value: function getVersion() {
return '4.29.8';
return '4.29.9';
}
}, {
key: "_addPnsdkSuffix",
Expand Down Expand Up @@ -756,6 +756,8 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createValidationError = createValidationError;
exports.generatePNSDK = generatePNSDK;
exports.signRequest = signRequest;
exports["default"] = _default;
exports.PubNubError = void 0;

Expand Down Expand Up @@ -892,6 +894,10 @@ function signRequest(modules, url, outgoingParams, incomingParams, endpoint) {
httpMethod = 'GET';
}

if (httpMethod === 'GETFILE') {
httpMethod = 'GET';
}

var signInput = "".concat(httpMethod, "\n").concat(config.publishKey, "\n").concat(url, "\n").concat(_utils["default"].signPamFromParams(outgoingParams), "\n");

if (httpMethod === 'POST') {
Expand Down Expand Up @@ -7686,6 +7692,18 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(22));

var _endpoint = __webpack_require__(16);

var getErrorFromResponse = function getErrorFromResponse(response) {
return new Promise(function (resolve) {
var result = '';
response.on('data', function (data) {
result += data.toString('utf8');
});
response.on('end', function () {
resolve(result);
});
});
};

var sendFile = function sendFile(_ref) {
var generateUploadUrl = _ref.generateUploadUrl,
publishFile = _ref.publishFile,
Expand All @@ -7696,7 +7714,7 @@ var sendFile = function sendFile(_ref) {
networking = _ref$modules.networking;
return function () {
var _ref3 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref2) {
var channel, input, message, cipherKey, meta, ttl, storeInHistory, file, _yield$generateUpload, _yield$generateUpload2, url, formFields, _yield$generateUpload3, id, name, formFieldsWithMimeType, result, retries, wasSuccessful;
var channel, input, message, cipherKey, meta, ttl, storeInHistory, file, _yield$generateUpload, _yield$generateUpload2, url, formFields, _yield$generateUpload3, id, name, formFieldsWithMimeType, result, errorBody, reason, retries, wasSuccessful, publishResult;

return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
Expand Down Expand Up @@ -7852,34 +7870,43 @@ var sendFile = function sendFile(_ref) {
throw new Error('Unsupported environment');

case 71:
_context.next = 76;
_context.next = 80;
break;

case 73:
_context.prev = 73;
_context.t16 = _context["catch"](21);
throw new _endpoint.PubNubError('Upload to bucket failed', _context.t16);
_context.next = 77;
return getErrorFromResponse(_context.t16.response);

case 76:
case 77:
errorBody = _context.sent;
reason = /<Message>(.*)<\/Message>/gi.exec(errorBody);
throw new _endpoint.PubNubError(reason ? "Upload to bucket failed: ".concat(reason[1]) : 'Upload to bucket failed.', _context.t16);

case 80:
if (!(result.status !== 204)) {
_context.next = 78;
_context.next = 82;
break;
}

throw new _endpoint.PubNubError('Upload to bucket was unsuccessful', result);

case 78:
case 82:
retries = 5;
wasSuccessful = false;
publishResult = {
timetoken: '0'
};

case 80:
case 85:
if (!(!wasSuccessful && retries > 0)) {
_context.next = 92;
_context.next = 98;
break;
}

_context.prev = 81;
_context.next = 84;
_context.prev = 86;
_context.next = 89;
return publishFile({
channel: channel,
message: message,
Expand All @@ -7890,23 +7917,24 @@ var sendFile = function sendFile(_ref) {
ttl: ttl
});

case 84:
case 89:
publishResult = _context.sent;
wasSuccessful = true;
_context.next = 90;
_context.next = 96;
break;

case 87:
_context.prev = 87;
_context.t17 = _context["catch"](81);
case 93:
_context.prev = 93;
_context.t17 = _context["catch"](86);
retries -= 1;

case 90:
_context.next = 80;
case 96:
_context.next = 85;
break;

case 92:
case 98:
if (wasSuccessful) {
_context.next = 96;
_context.next = 102;
break;
}

Expand All @@ -7916,18 +7944,19 @@ var sendFile = function sendFile(_ref) {
name: name
});

case 96:
case 102:
return _context.abrupt("return", {
timetoken: publishResult.timetoken,
id: id,
name: name
});

case 97:
case 103:
case "end":
return _context.stop();
}
}
}, _callee, null, [[21, 73], [81, 87]]);
}, _callee, null, [[21, 73], [86, 93]]);
}));

return function (_x) {
Expand Down Expand Up @@ -8725,11 +8754,11 @@ exports["default"] = void 0;

var _endpoint = __webpack_require__(16);

var _default = function _default(_ref, _ref2) {
var config = _ref.config;
var channel = _ref2.channel,
id = _ref2.id,
name = _ref2.name;
var _default = function _default(modules, _ref) {
var channel = _ref.channel,
id = _ref.id,
name = _ref.name;
var config = modules.config;

if (!channel) {
throw new _endpoint.PubNubError('Validation failed, check status for details', (0, _endpoint.createValidationError)("channel can't be empty"));
Expand All @@ -8743,7 +8772,32 @@ var _default = function _default(_ref, _ref2) {
throw new _endpoint.PubNubError('Validation failed, check status for details', (0, _endpoint.createValidationError)("file name can't be empty"));
}

return "https://".concat(config.origin, "/v1/files/").concat(config.subscribeKey, "/channels/").concat(channel, "/files/").concat(id, "/").concat(name);
var url = "/v1/files/".concat(config.subscribeKey, "/channels/").concat(channel, "/files/").concat(id, "/").concat(name);
var params = {};
params.uuid = config.getUUID();
params.pnsdk = (0, _endpoint.generatePNSDK)(config);

if (config.getAuthKey()) {
params.auth = config.getAuthKey();
}

if (config.secretKey) {
(0, _endpoint.signRequest)(modules, url, params, {}, {
getOperation: function getOperation() {
return 'PubNubGetFileUrlOperation';
}
});
}

var queryParams = Object.keys(params).map(function (key) {
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(params[key]));
}).join('&');

if (queryParams !== '') {
return "https://".concat(config.origin).concat(url, "?").concat(queryParams);
}

return "https://".concat(config.origin).concat(url);
};

exports["default"] = _default;
Expand Down Expand Up @@ -8806,15 +8860,11 @@ var endpoint = {
forceBuffered: function forceBuffered() {
return true;
},
getAuthToken: function getAuthToken(_ref3) {
var tokenManager = _ref3.tokenManager;
return tokenManager.getToken('fileUpload');
},
prepareParams: function prepareParams() {
return {};
},
handleResponse: function () {
var _handleResponse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref4, res, params) {
var _handleResponse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref3, res, params) {
var _res$response$name;

var PubNubFile, config, cryptography, body, _params$cipherKey;
Expand All @@ -8823,7 +8873,7 @@ var endpoint = {
while (1) {
switch (_context.prev = _context.next) {
case 0:
PubNubFile = _ref4.PubNubFile, config = _ref4.config, cryptography = _ref4.cryptography;
PubNubFile = _ref3.PubNubFile, config = _ref3.config, cryptography = _ref3.cryptography;
body = res.response.body;

if (!(PubNubFile.supportsEncryptFile && config.cipherKey)) {
Expand Down
4 changes: 2 additions & 2 deletions dist/titanium/pubnub.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 403e14c

Please sign in to comment.