Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2022-12-08
version: v7.2.2
changes:
- type: bug
text: "Fixes issue of getFileUrl not setting auth value as token string when token is set."
- date: 2022-11-10
version: v7.2.1
changes:
Expand Down Expand Up @@ -879,7 +884,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.2.1.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.2.2.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1550,7 +1555,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v7.2.1/pubnub.7.2.1.js
location: https://github.com/pubnub/javascript/releases/download/v7.2.2/pubnub.7.2.2.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v7.2.2
December 08 2022

#### Fixed
- Fixes issue of getFileUrl not setting auth value as token string when token is set. Fixed the following issues reported by [@abdalla-nayer](https://github.com/abdalla-nayer): [#302](https://github.com/pubnub/javascript/issues/302).

## v7.2.1
November 10 2022

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.7.2.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.1.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.2.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.2.min.js

2. Configure your keys:

Expand Down
9 changes: 5 additions & 4 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@
return this;
};
default_1.prototype.getVersion = function () {
return '7.2.1';
return '7.2.2';
};
default_1.prototype._addPnsdkSuffix = function (name, suffix) {
this._PNSDKSuffix[name] = suffix;
Expand Down Expand Up @@ -4817,7 +4817,7 @@
/** */
var getFileUrlFunction = (function (modules, _a) {
var channel = _a.channel, id = _a.id, name = _a.name;
var config = modules.config, networking = modules.networking;
var config = modules.config, networking = modules.networking, tokenManager = modules.tokenManager;
if (!channel) {
throw new PubNubError('Validation failed, check status for details', createValidationError("channel can't be empty"));
}
Expand All @@ -4831,8 +4831,9 @@
var params = {};
params.uuid = config.getUUID();
params.pnsdk = generatePNSDK(config);
if (config.getAuthKey()) {
params.auth = config.getAuthKey();
var tokenOrKey = tokenManager.getToken() || config.getAuthKey();
if (tokenOrKey) {
params.auth = tokenOrKey;
}
if (config.secretKey) {
signRequest(modules, url, params, {}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var default_1 = /** @class */ (function () {
return this;
};
default_1.prototype.getVersion = function () {
return '7.2.1';
return '7.2.2';
};
default_1.prototype._addPnsdkSuffix = function (name, suffix) {
this._PNSDKSuffix[name] = suffix;
Expand Down
7 changes: 4 additions & 3 deletions lib/core/endpoints/file_upload/get_file_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var endpoint_1 = require("../../components/endpoint");
var utils_1 = __importDefault(require("../../utils"));
exports.default = (function (modules, _a) {
var channel = _a.channel, id = _a.id, name = _a.name;
var config = modules.config, networking = modules.networking;
var config = modules.config, networking = modules.networking, tokenManager = modules.tokenManager;
if (!channel) {
throw new endpoint_1.PubNubError('Validation failed, check status for details', (0, endpoint_1.createValidationError)("channel can't be empty"));
}
Expand All @@ -22,8 +22,9 @@ exports.default = (function (modules, _a) {
var params = {};
params.uuid = config.getUUID();
params.pnsdk = (0, endpoint_1.generatePNSDK)(config);
if (config.getAuthKey()) {
params.auth = config.getAuthKey();
var tokenOrKey = tokenManager.getToken() || config.getAuthKey();
if (tokenOrKey) {
params.auth = tokenOrKey;
}
if (config.secretKey) {
(0, endpoint_1.signRequest)(modules, url, params, {}, {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "7.2.1",
"version": "7.2.2",
"author": "PubNub <support@pubnub.com>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export default class {
}

getVersion() {
return '7.2.1';
return '7.2.2';
}

_addPnsdkSuffix(name, suffix) {
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/file_upload/get_file_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PubNubError, createValidationError, signRequest, generatePNSDK } from '
import utils from '../../utils';

export default (modules, { channel, id, name }) => {
const { config, networking } = modules;
const { config, networking, tokenManager } = modules;

if (!channel) {
throw new PubNubError(
Expand Down Expand Up @@ -34,8 +34,9 @@ export default (modules, { channel, id, name }) => {
params.uuid = config.getUUID();
params.pnsdk = generatePNSDK(config);

if (config.getAuthKey()) {
params.auth = config.getAuthKey();
const tokenOrKey = tokenManager.getToken() || config.getAuthKey();
if (tokenOrKey) {
params.auth = tokenOrKey;
}

if (config.secretKey) {
Expand Down
21 changes: 19 additions & 2 deletions test/integration/endpoints/get_file_url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/* eslint no-console: 0 */

import assert from 'assert';
import nock from 'nock';
import utils from '../../utils';
import PubNub from '../../../src/node/index';

describe('getFileUrl', () => {
Expand Down Expand Up @@ -35,4 +33,23 @@ describe('getFileUrl', () => {
assert(url === `https://test1.example.com/v1/files/demo/channels/channel/files/id/name?uuid=myUUID&pnsdk=${pnsdk}`
|| url === `https://test2.example.com/v1/files/demo/channels/channel/files/id/name?uuid=myUUID&pnsdk=${pnsdk}`);
});

it('constructs proper url when token is set', () => {
const pubnub = new PubNub({
subscribeKey: 'demo',
publishKey: 'demo',
uuid: 'myUUID',
origin: 'example.com',
});

pubnub.setToken('tokenString');

const url = pubnub.getFileUrl({ channel: 'channel', id: 'id', name: 'name' });
const pnsdk = `PubNub-JS-${pubnub._config.sdkFamily}%2F${pubnub._config.getVersion()}`;

assert.equal(
url,
`https://example.com/v1/files/demo/channels/channel/files/id/name?uuid=myUUID&pnsdk=${pnsdk}&auth=tokenString`,
);
});
});